fix: decode Uniswap V2 exact-out swaps, input amount shown as a maximum (closes #283)
decode() had no arm for Universal Router command 0x09, so the approval screen showed no token or amount for it. It now takes the path's first token and amountInMax as the input side, the last token and amountOut as the output side. With such a step, the Amount figure reads "Up to <amount>" whichever step set it, on the approval, wait, success and error screens, unless it reads "Unlimited", as an unbounded PERMIT2_PERMIT does, or "All available (V4 open delta)". In every swap, UNWRAP_WETH makes Token Out ETH only when the output side is WETH, on mainnet or Sepolia, or no step set it; otherwise the output keeps its own token and figure. decodeV2SwapExactOut() loses its eslint-disable comment. Model: opus-5-5
This commit was merged in pull request #423.
This commit is contained in:
@@ -962,16 +962,25 @@ read:
|
||||
- `Unlimited`: on the ERC-20 `Amount` line, an `approve` of the `uint256`
|
||||
maximum, an unbounded allowance. On the swap's `Amount` line, any amount at or
|
||||
above the `uint160` maximum, whichever step set the line: a `PERMIT2_PERMIT`
|
||||
amount at that maximum, which is an unbounded permit, or a V2 or V3 exact-in
|
||||
or `WRAP_ETH` amount that large, which is not an allowance. The router's
|
||||
whole-balance value, `CONTRACT_BALANCE` (`2^255`), is one such amount.
|
||||
amount at that maximum, which is an unbounded permit, or a V2 or V3 exact-in,
|
||||
V2 exact-out or `WRAP_ETH` amount that large, which is not an allowance. The
|
||||
router's whole-balance value, `CONTRACT_BALANCE` (`2^255`), is one such
|
||||
amount.
|
||||
- `Up to <amount>`: the swap's `Amount` line, when the transaction has a V2
|
||||
exact-out step, whichever step set the line, including the `WRAP_ETH` of a
|
||||
swap paid in ETH and a `PERMIT2_PERMIT`. The swap spends at most that figure,
|
||||
not necessarily all of it; the wait, success and error screens show it with
|
||||
the same words. `Unlimited` and `All available (V4 open delta)` keep their
|
||||
wording. When a V2 exact-out step sets `Min. received`, that line shows its
|
||||
`amountOut`, the exact amount it buys.
|
||||
- `All available (V4 open delta)`: the swap's `Amount` line, when the amount it
|
||||
shows is a V4 exact-in `amountIn` of zero. V4 reads that zero as "use the
|
||||
whole open delta", so the calldata states no quantity. The line shows the
|
||||
amount of one step that names an input token or amount: the last
|
||||
`PERMIT2_PERMIT` step if there is one, otherwise the first V2 or V3 exact-in,
|
||||
`WRAP_ETH` or V4 swap step, a V4 swap step giving the `amountIn` of its first
|
||||
readable exact-in action.
|
||||
V2 exact-out, `WRAP_ETH` or V4 swap step. A V2 exact-out step gives its
|
||||
`amountInMax`, and a V4 swap step the `amountIn` of its first readable
|
||||
exact-in action.
|
||||
- `None (no minimum guaranteed)`: the swap's `Min. received` line, when the
|
||||
minimum it shows is zero, whether a V2, V3 or V4 swap's minimum or a
|
||||
`BALANCE_CHECK_ERC20` step's `minBalance`. Before
|
||||
@@ -980,9 +989,14 @@ read:
|
||||
|
||||
The swap's `Token In` and `Token Out` lines name a currency, not an amount; each
|
||||
reads `Unknown (not named in the calldata)` when the decoder found no token for
|
||||
that side. The token permission warning on the signature screen has its own
|
||||
amount wording, including `Unknown`; the SignApproval section below describes
|
||||
it.
|
||||
that side. An `UNWRAP_WETH` step makes `Token Out` ETH only when the output side
|
||||
is WETH, on mainnet or Sepolia, or when no step set the output side; a WETH
|
||||
`Min. received` figure then reads in ETH. Otherwise `Token Out` and
|
||||
`Min. received` keep the output side's own token and figure, whether the swap
|
||||
was paid in ETH or in a token: a V2 exact-out swap that buys USDC and then
|
||||
unwraps the WETH it did not spend shows USDC. The token permission warning on
|
||||
the signature screen has its own amount wording, including `Unknown`; the
|
||||
SignApproval section below describes it.
|
||||
|
||||
#### Partial USD totals
|
||||
|
||||
|
||||
Reference in New Issue
Block a user