fix: a step the router lets fail is marked, and a balance check it lets fail sets no minimum (closes #602)
Each Universal Router release now carries the command types its dispatch() can return a failure for instead of reverting, read from its source; only a step of one of those with the allow-revert flag (0x80) set can fail while the transaction goes on. Such a step is listed with "(allowed to fail)". A BALANCE_CHECK_ERC20 the router lets fail guarantees nothing, so it is read as a zero check and keeps an earlier step's minimum. Every swap and every payment of ETH or an ERC-20 token succeeds or reverts the whole transaction, so the flag on them has no effect and they read as without it. Model: opus-5-5
This commit is contained in:
+15
-7
@@ -987,13 +987,23 @@ describe("uniswap decoder", () => {
|
||||
);
|
||||
|
||||
// A sub-plan holding a V3 swap of USDT for WETH, which the decoder does
|
||||
// not read. With the allow-revert flag (0x80) the command byte is 0xa1.
|
||||
// not read. With the allow-revert flag (0x80) the command byte is 0xa1,
|
||||
// and the router lets the step fail
|
||||
// (https://git.eeqj.de/sneak/AutistMask/issues/602).
|
||||
test.each([
|
||||
{ flag: "without", command: 0x21 },
|
||||
{ flag: "with", command: 0xa1 },
|
||||
{
|
||||
flag: "without",
|
||||
command: 0x21,
|
||||
steps: "Execute Sub-Plan (its steps are not shown)",
|
||||
},
|
||||
{
|
||||
flag: "with",
|
||||
command: 0xa1,
|
||||
steps: "Execute Sub-Plan (its steps are not shown) (allowed to fail)",
|
||||
},
|
||||
])(
|
||||
"an EXECUTE_SUB_PLAN step $flag the allow-revert flag says its steps are not shown",
|
||||
({ command }) => {
|
||||
({ command, steps }) => {
|
||||
const subPlan = encodeSubPlan("0x00", [
|
||||
encodeV3SwapExactIn(USER_ADDR, 2000000n, ONE_WETH, [
|
||||
USDT_ADDR,
|
||||
@@ -1013,9 +1023,7 @@ describe("uniswap decoder", () => {
|
||||
USER_ADDR,
|
||||
);
|
||||
expect(result.name).toBe("Uniswap Swap");
|
||||
expect(detail(result, "Steps").value).toBe(
|
||||
"Execute Sub-Plan (its steps are not shown)",
|
||||
);
|
||||
expect(detail(result, "Steps").value).toBe(steps);
|
||||
// The sub-plan names both currencies, so the lines must not say
|
||||
// the calldata did not.
|
||||
expect(detail(result, "Token In").value).toBe(
|
||||
|
||||
Reference in New Issue
Block a user