fix: each router release names and reads its own commands (closes #592)
Each Universal Router release now carries the command it runs for each command type, by the name its pinned Commands.sol gives it, and the decoder names and reads each step as that command instead of using one table for every router. On UniversalRouterV1 and UniversalRouterV1_2_V2Support, 0x10 to 0x13 are NFT commands, such as Seaport: they are no longer read as V4 commands, so they draw no swap lines and their payouts count as unread. UniversalRouterV1 has no BALANCE_CHECK_ERC20 and reverts on 0x0e, which is now listed as Command 0x0e and sets no minimum. No release lets a V4 swap fail, so the zero-minimum reading for a flagged one is gone. Model: opus-5-5
This commit was merged in pull request #616.
This commit is contained in:
@@ -2983,15 +2983,25 @@ Currently supported:
|
||||
in the parameter shape deployed on mainnet and Sepolia, not in the newer one
|
||||
on `v4-periphery` `main`, which adds a `minHopPriceX36` field. An action in
|
||||
any other shape is not read, and its step is listed as
|
||||
`V4 Swap (could not be decoded)`. Each step is named by its command type,
|
||||
which the decoder reads from the command byte with the mask the router at that
|
||||
address uses: `0x1f` for `UniversalRouterV1`, `0x3f` for
|
||||
`UniversalRouterV1_2_V2Support` and `UniversalRouterV2`, and `0x7f` for
|
||||
`UniversalRouterV2_1_1` and `UniversalRouterV2_1_2`. The allow-revert flag
|
||||
(`0x80`) therefore does not change the command a step is read as. The router
|
||||
reverts the whole transaction when a step fails, unless the step's command
|
||||
byte has that flag set and its command is one the router lets fail, as each
|
||||
release's `contracts/base/Dispatcher.sol` shows: on `UniversalRouterV2`,
|
||||
`V4 Swap (could not be decoded)`. Each step is named and read as the command
|
||||
that the release of the router at that address runs for its command type, as
|
||||
that release's `contracts/libraries/Commands.sol` names it. The decoder reads
|
||||
the type from the command byte with the mask that router uses: `0x1f` for
|
||||
`UniversalRouterV1`, `0x3f` for `UniversalRouterV1_2_V2Support` and
|
||||
`UniversalRouterV2`, and `0x7f` for `UniversalRouterV2_1_1` and
|
||||
`UniversalRouterV2_1_2`. The allow-revert flag (`0x80`) therefore does not
|
||||
change the command a step is read as. Releases run different commands for some
|
||||
types: on `UniversalRouterV1` and `UniversalRouterV1_2_V2Support`, `0x10` to
|
||||
`0x13` are NFT commands, where the later routers run `V4_SWAP`,
|
||||
`V3_POSITION_MANAGER_PERMIT`, `V3_POSITION_MANAGER_CALL` and
|
||||
`V4_INITIALIZE_POOL`. The decoder does not read those routers' NFT commands,
|
||||
and lists each by its name there, for example `Seaport` for `SEAPORT` (`0x10`
|
||||
on `UniversalRouterV1`). A type a release names no command for is listed by
|
||||
its number, for example `Command 0x0e` on `UniversalRouterV1`, which has no
|
||||
`BALANCE_CHECK_ERC20` and reverts on it. The router reverts the whole
|
||||
transaction when a step fails, unless the step's command byte has that flag
|
||||
set and its command is one the router lets fail, as each release's
|
||||
`contracts/base/Dispatcher.sol` shows: on `UniversalRouterV2`,
|
||||
`UniversalRouterV2_1_1` and `UniversalRouterV2_1_2`, `PERMIT2_PERMIT`,
|
||||
`PERMIT2_PERMIT_BATCH`, `BALANCE_CHECK_ERC20`, `V3_POSITION_MANAGER_PERMIT`,
|
||||
`V3_POSITION_MANAGER_CALL`, `V4_INITIALIZE_POOL`, `V4_POSITION_MANAGER_CALL`
|
||||
@@ -3004,11 +3014,7 @@ Currently supported:
|
||||
V3 and V4 swap and each payment of ETH or an ERC-20 token, the flag has no
|
||||
effect: the step succeeds or the whole transaction reverts, so the step reads
|
||||
as it does without the flag. A `BALANCE_CHECK_ERC20` the router lets fail
|
||||
guarantees nothing, so it is read as one whose `minBalance` is zero. On
|
||||
`UniversalRouterV1` and `UniversalRouterV1_2_V2Support`, `0x10` is an NFT
|
||||
market call the router lets fail, which the decoder still reads as a V4 swap
|
||||
([#592](https://git.eeqj.de/sneak/AutistMask/issues/592)); with the flag set,
|
||||
a minimum it states is read as zero: `None (no minimum guaranteed)`. Only the
|
||||
guarantees nothing, so it is read as one whose `minBalance` is zero. Only the
|
||||
routers with the `0x7f` mask have `PAY_PORTION_FULL_PRECISION` (`0x07`),
|
||||
listed as `Pay Portion (Full Precision)`, and `ACROSS_V4_DEPOSIT_V3` (`0x40`),
|
||||
listed as `Across Bridge Deposit`; the other routers revert on `0x07`, and it
|
||||
@@ -3083,7 +3089,8 @@ Currently supported:
|
||||
`V3_SWAP_EXACT_IN`, `V4_SWAP`, `SWEEP`, `TRANSFER`, `PAY_PORTION`,
|
||||
`PAY_PORTION_FULL_PRECISION`, `ACROSS_V4_DEPOSIT_V3`, `WRAP_ETH`,
|
||||
`UNWRAP_WETH` and `BALANCE_CHECK_ERC20` (`V3_SWAP_EXACT_OUT`,
|
||||
`PERMIT2_TRANSFER_FROM_BATCH` and `EXECUTE_SUB_PLAN` among them).
|
||||
`PERMIT2_TRANSFER_FROM_BATCH`, `EXECUTE_SUB_PLAN` and the NFT commands among
|
||||
them), or a type its release names no command for.
|
||||
|
||||
### Non-Goals Forever
|
||||
|
||||
|
||||
Reference in New Issue
Block a user