feat(swap-widget): broadcast api-supplied approval txs - #12518
Open
kaladinlight wants to merge 3 commits into
Open
feat(swap-widget): broadcast api-supplied approval txs#12518kaladinlight wants to merge 3 commits into
kaladinlight wants to merge 3 commits into
Conversation
Populate approval.approvalTxs on the quote response: ready-to-sign exact-amount approve transactions in broadcast order, with a preceding approve(spender, 0) when the token requires resetting a non-zero allowance before changing it (USDT-style, detected by simulating the approve as the owner - no token list). Replaces the never-populated singular approvalTx field. Expose the first-hop allowanceContract on rates so clients can check or set allowances manually before quoting. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
kaladinlight
force-pushed
the
feat/swap-widget-approval-txs
branch
2 times, most recently
from
August 3, 2026 22:13
c91b5d5 to
3196dbb
Compare
Probe via simulateContract so a token whose approve() fulfills but returns false also lands on the reset side (return-less tokens reject decoding and do too). Docs no longer claim every swap needs a fresh approval - approvalTxs is empty when the current allowance covers the amount. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Use quote.approval.approvalTxs (sequential broadcast, wait for each receipt) instead of hand-encoding a single approve. Inherits the API's USDT-style reset handling - the previous single approve reverted on-chain for tokens requiring a zero-allowance reset whenever a prior exact approval was left unspent. Local encoding remains as fallback for API versions predating approvalTxs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
kaladinlight
force-pushed
the
feat/public-api-approval-txs
branch
from
August 3, 2026 22:25
c7fa6f9 to
8f9d84f
Compare
kaladinlight
force-pushed
the
feat/swap-widget-approval-txs
branch
from
August 3, 2026 22:25
3196dbb to
86b1f6a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to #12517 (stacked on it) — the widget now consumes the API's
approval.approvalTxsinstead of hand-encoding a single approve.useSwapApprovalbroadcasts the supplied transactions sequentially, waiting for each receipt, and reports the final hash to the machine. This inherits the API's USDT-style reset handling and fixes a latent on-chain revert: the previous singleapprove(spender, amount)fails for reset-requiring tokens whenever a prior exact approval was left unspent (e.g. the widget's own approve-then-abandon flow leaves a dangling non-zero USDT allowance, breaking the next larger sell through the same spender).Local exact-approve encoding remains as a fallback for API deployments predating
approvalTxs, so widget and API can release in either order.Issue (if applicable)
closes #
Risk
Low. Approval flow only; the common case (no reset needed) broadcasts the same single exact-amount approve as before, now server-encoded. Swap execution untouched.
Widget ERC-20 approval transactions on EVM sells. Same spender, same exact amount; USDT-style tokens gain the required
approve(spender, 0)reset first.Testing
Engineering
approvalTxsshapes (single exact approve, USDT reset pair, no false-positive reset on USDC, empty when approved) were E2E-verified against live mainnet state in feat(public-api): approval txs on quote, allowance contract on rates #12517.Operations
Screenshots (if applicable)
🤖 Generated with Claude Code