fix: WETH paid to the user before an UNWRAP_WETH reads as WETH (closes #607)
check / check (push) Canceled after 0s
e2e / e2e-chrome (push) Canceled after 0s
e2e / e2e-firefox (push) Canceled after 0s

An UNWRAP_WETH made Token Out ETH whenever the output side was WETH, so
a swap that paid its WETH to the user before it read as ETH, though the
user receives WETH. decode() now turns the output into ETH only when the
router holds the output side's WETH when the step runs, which it reads
from what it already follows the router to hold; a later step that sets
the output side sets it anew. So an UNWRAP_WETH that runs before the
swap no longer makes the WETH the swap leaves in the router read as ETH.
README Display Consistency says the same.

Model: opus-5-5
This commit is contained in:
2026-10-20 10:52:09 +00:00
parent 070ad82338
commit e3745a2acf
4 changed files with 98 additions and 16 deletions
+8 -2
View File
@@ -1251,8 +1251,14 @@ A V4 step with no swap action sets only the sides its `SETTLE`, `SETTLE_ALL`,
`TAKE` or `TAKE_ALL` names.
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
on mainnet or Sepolia, that the router holds when the step runs (Transaction
Decoding below gives what the router holds), or when no step set the output
side; a WETH `Min. received` figure then reads in ETH. A later step that sets
the output side sets it anew. The router unwraps only the WETH it holds, so a
swap that pays its WETH to the user and then unwraps shows WETH. The decoder
follows what the router holds by token, not by step: a swap that pays part of
its WETH to the user and part to the router, and then unwraps, shows ETH with
the minimum of the step that set the output side. 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