fix: a split swap's Min. received is the sum of its steps' minimums (closes #647)
The step that sets the output side gives the minimum. When that step and earlier swap steps each pay the output token to the sender, the minimum is now the sum of their minimums. There is no figure when the decoder reads none from one of them, or when one of them pays part of that token elsewhere. These steps drop earlier steps from the sum: - a V2 or V3 swap step that spends the output token; - a V4 step with a swap action that spends that token, or with a SETTLE or SETTLE_ALL of that token; - a PERMIT2_TRANSFER_FROM of that token. A step after the step that sets the output side drops nothing from the sum. Model: opus-5-5
This commit is contained in:
@@ -1266,7 +1266,8 @@ see Transaction Decoding), do not always read as a number. They can read:
|
||||
the same words. `Unlimited`, `All available (V4 open delta)` and
|
||||
`Whatever an earlier step sent to the pair (V2 already paid)` keep their
|
||||
wording. When a V2 or V3 exact-out step sets `Min. received`, that line shows
|
||||
its `amountOut`, the exact amount it buys.
|
||||
its `amountOut`, the exact amount it buys. When earlier swap steps also pay
|
||||
that token to the user, the line shows the sum (see Transaction Decoding).
|
||||
- `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. Transaction Decoding
|
||||
@@ -3459,19 +3460,29 @@ Currently supported:
|
||||
name); and one more reads `Unknown (could not be decoded)` when a step that
|
||||
may pay an address went unread. When no step pays anyone, a single line reads
|
||||
`Unknown (not named in the calldata)`. Wherever there is a `Paid to` line, the
|
||||
minimum reads `Min. paid out`. The `Amount` line gives the total the steps
|
||||
take of `Token In`, from the step that sets the input side on: the first V2 or
|
||||
V3 exact-in or exact-out, `WRAP_ETH` or V4 swap step that names an input token
|
||||
or amount. A V4 step with a swap action sets the input side when no earlier
|
||||
step set it, even when it names neither (see Display Consistency). That step
|
||||
counts its own amount, whoever pays it: a V2 or V3 exact-out step its
|
||||
`amountInMax`, and a V4 step what it takes of its input token from the user's
|
||||
wallet, as below, or, when the user pays it none of that token, the `amountIn`
|
||||
of the swap action that spends it. Each later V2 or V3 exact-in or exact-out
|
||||
step whose `payerIsUser` is true takes its amount, found in the same way, from
|
||||
the user's wallet. Every V4 step, with a swap action or without, takes from
|
||||
the user's wallet what its `SETTLE`s paid by the user (`payerIsUser` true) and
|
||||
its `SETTLE_ALL`s pay, for each token on its own; what the step that sets the
|
||||
minimum reads `Min. paid out`. The step that sets the output side gives the
|
||||
minimum. When that step and earlier swap steps each pay the output token to
|
||||
the transaction's sender, the minimum is the sum of their minimums. There is
|
||||
no minimum when the decoder reads none from one of them, or when one of them
|
||||
pays part of that token elsewhere. There is also no minimum when the decoder
|
||||
did not read one of them, or a step between them, in full. A swap step that
|
||||
spends the output token drops earlier steps from the sum. A V4 step spends
|
||||
each token that its swap actions spend. A V4 `SETTLE` or `SETTLE_ALL` of the
|
||||
output token also drops earlier steps. A `PERMIT2_TRANSFER_FROM` of the output
|
||||
token drops earlier steps too. A step after the step that sets the output side
|
||||
drops nothing from the sum. The `Amount` line gives the total the steps take
|
||||
of `Token In`, from the step that sets the input side on: the first V2 or V3
|
||||
exact-in or exact-out, `WRAP_ETH` or V4 swap step that names an input token or
|
||||
amount. A V4 step with a swap action sets the input side when no earlier step
|
||||
set it, even when it names neither (see Display Consistency). That step counts
|
||||
its own amount, whoever pays it: a V2 or V3 exact-out step its `amountInMax`,
|
||||
and a V4 step what it takes of its input token from the user's wallet, as
|
||||
below, or, when the user pays it none of that token, the `amountIn` of the
|
||||
swap action that spends it. Each later V2 or V3 exact-in or exact-out step
|
||||
whose `payerIsUser` is true takes its amount, found in the same way, from the
|
||||
user's wallet. Every V4 step, with a swap action or without, takes from the
|
||||
user's wallet what its `SETTLE`s paid by the user (`payerIsUser` true) and its
|
||||
`SETTLE_ALL`s pay, for each token on its own; what the step that sets the
|
||||
input side takes of any other token counts as a later step's take. A `SETTLE`
|
||||
of any amount but `OPEN_DELTA` pays that amount, and a `SETTLE` of
|
||||
`OPEN_DELTA` or a `SETTLE_ALL` pays what the step owes, as above. So a V4 step
|
||||
|
||||
Reference in New Issue
Block a user