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 named the step and showed no token or amount. It now takes the path's first token with amountInMax as the input side and the last token with amountOut as the output side, through setInputOnce() and setOutput() like 0x08. amountInMax is the most the swap may spend, so the Amount line reads "Up to <amount>", including the value the wait and error screens show. The eslint-disable comment on decodeV2SwapExactOut() is gone. Model: opus-5-5
This commit is contained in:
@@ -953,16 +953,23 @@ 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 step that set it is a V2
|
||||
exact-out swap. The figure is that step's `amountInMax`, the most the swap may
|
||||
spend, not the amount it spends; the wait, success and error screens show it
|
||||
with the same words. When such a step also 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
|
||||
|
||||
Reference in New Issue
Block a user