fix: a swap split across steps the user pays for shows every amount it spends (closes #625)
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run

The swap's Amount line took only the first swap step's amount. Each later
step the user pays for now adds what it takes of Token In, and what it
takes of another token, or an amount the decoder cannot tell, gets lines
of its own. A V4 step counts every SETTLE paid by the user and every
SETTLE_ALL, with or without a swap action. A step that may take from the
sender what the decoder did not read leaves no Amount figure and gets one
line saying so. Only a permit to the router that the router does not let
fail still covers later takes of its token.

Model: opus-5-5
This commit is contained in:
2026-10-19 23:53:32 +00:00
parent 5376723c41
commit 08d760d195
4 changed files with 921 additions and 136 deletions
+537
View File
@@ -1289,6 +1289,543 @@ describe("uniswap decoder", () => {
expect(detail(result, "Amount").value).not.toContain("500000000000");
});
// https://git.eeqj.de/sneak/AutistMask/issues/625 — a route split across
// two swap steps the user pays for, with no PERMIT2_PERMIT, takes both
// steps' amounts from the wallet. On next at 671b4d3 the Amount line read
// only the first step's 600.0000 USDT.
describe("a swap split across steps the user pays for", () => {
const USDT_600 = 600000000n;
const USDT_400 = 400000000n;
const DAI_400 = 400000000000000000000n;
const OTHER_ADDR = "0x1111111111111111111111111111111111111111";
const UNDECODED = "Unknown (could not be decoded)";
// The lines between Token In and Token Out, as [label, value].
function linesBetweenTokens(result) {
const lines = result.details.map((d) => [d.label, d.value]);
const from = lines.findIndex(([label]) => label === "Token In");
const to = lines.findIndex(([label]) => label === "Token Out");
return lines.slice(from + 1, to);
}
// execute() of these command bytes and inputs, decoded as sent by
// the user.
function decodeSteps(commands, inputs) {
const data = buildExecute(
solidityPacked(
commands.map(() => "uint8"),
commands,
),
inputs,
9999999999n,
);
return uniswap.decode(data, ROUTER_ADDR, "0x1", {}, USER_ADDR);
}
// The first step: a V3 exact-in of 600 USDT for USDC, paid by the
// user, which sets the input side.
const V3_600 = encodeV3SwapExactIn(USER_ADDR, USDT_600, 590000000n, [
USDT_ADDR,
USDC_ADDR,
]);
// V4 SETTLE of `amount` of `currency`, and TAKE of `amount` of
// `currency` to `recipient`.
const settle = (currency, amount, payerIsUser) =>
coder.encode(
["address", "uint256", "bool"],
[currency, amount, payerIsUser],
);
const take = (currency, recipient, amount) =>
coder.encode(
["address", "address", "uint256"],
[currency, recipient, amount],
);
// `input` with the top byte of its word at `index` set. This decoder
// cannot read such a word as an address or a length; the router reads
// its low bytes and runs the step.
const dirtyWord = (input, index) => {
const at = 2 + index * 64;
return input.slice(0, at) + "ff" + input.slice(at + 2);
};
test("a split across a V3 and a V2 step the user pays for shows the total", () => {
const data = buildExecute(
solidityPacked(["uint8", "uint8"], [0x00, 0x08]),
[
encodeV3SwapExactIn(USER_ADDR, USDT_600, 590000000n, [
USDT_ADDR,
USDC_ADDR,
]),
encodeV2SwapExactIn(USER_ADDR, USDT_400, 390000000n, [
USDT_ADDR,
USDC_ADDR,
]),
],
9999999999n,
);
const result = uniswap.decode(
data,
ROUTER_ADDR,
"0x1",
{},
USER_ADDR,
);
expect(result).not.toBeNull();
expect(detail(result, "Token In").address.toLowerCase()).toBe(
USDT_ADDR.toLowerCase(),
);
expect(detail(result, "Amount").value).toBe("1000.0000 USDT");
expect(detail(result, "Amount").rawValue).toBe("1000.0000");
expect(detail(result, "Moved from the sender")).toBeUndefined();
});
// In the order of Uniswap's own V4 routes: the swap, then a SETTLE of
// OPEN_DELTA by the user, which pays what the swap spends.
test("a split across a V3 step and a V4 step the user pays for shows the total", () => {
const data = buildExecute(
solidityPacked(["uint8", "uint8"], [0x00, 0x10]),
[
encodeV3SwapExactIn(USER_ADDR, USDT_600, 590000000n, [
USDT_ADDR,
USDC_ADDR,
]),
encodeV4Swap(
new Uint8Array([
V4_SWAP_EXACT_IN_SINGLE_ID,
V4_SETTLE_ID,
V4_TAKE_ID,
]),
[
encodeV4ExactInSingle(
USDT_ADDR,
USDC_ADDR,
USDT_400,
390000000n,
),
encodeV4Settle(USDT_ADDR), // paid by the user
encodeV4Take(USDC_ADDR),
],
),
],
9999999999n,
);
const result = uniswap.decode(
data,
ROUTER_ADDR,
"0x1",
{},
USER_ADDR,
);
expect(result).not.toBeNull();
expect(detail(result, "Amount").value).toBe("1000.0000 USDT");
expect(detail(result, "Moved from the sender")).toBeUndefined();
});
test("a second step the user pays for that spends another token shows that token's amount", () => {
const data = buildExecute(
solidityPacked(["uint8", "uint8"], [0x00, 0x08]),
[
encodeV3SwapExactIn(USER_ADDR, USDT_600, 590000000n, [
USDT_ADDR,
USDC_ADDR,
]),
encodeV2SwapExactIn(
USER_ADDR,
400000000000000000000n, // 400 DAI
390000000n,
[DAI_ADDR, USDC_ADDR],
),
],
9999999999n,
);
const result = uniswap.decode(
data,
ROUTER_ADDR,
"0x1",
{},
USER_ADDR,
);
expect(result).not.toBeNull();
expect(linesBetweenTokens(result)).toEqual([
["Amount", "600.0000 USDT"],
["Moved from the sender", "400.0000 DAI"],
["Token moved", "DAI (" + DAI_ADDR + ")"],
["Moved to", "The swap step that spends it"],
]);
});
// Every later V4 step takes from the sender what its SETTLEs paid by
// the user and its SETTLE_ALLs pay, each currency on its own, with a
// swap action or without. Each of these read 600.0000 USDT alone
// before.
const USDT_FOR_USDC_400 = encodeV4ExactInSingle(
USDT_ADDR,
USDC_ADDR,
USDT_400,
390000000n,
);
const DAI_FOR_USDC_400 = encodeV4ExactInSingle(
DAI_ADDR,
USDC_ADDR,
DAI_400,
390000000n,
);
const DAI_GROUP = [
["Moved from the sender", "400.0000 DAI"],
["Token moved", "DAI (" + DAI_ADDR + ")"],
["Moved to", "The swap step that spends it"],
];
test.each([
{
kind: "a V4 step paying USDT and DAI by a SETTLE_ALL of each",
actions: [
V4_SWAP_EXACT_IN_SINGLE_ID,
V4_SWAP_EXACT_IN_SINGLE_ID,
V4_SETTLE_ALL_ID,
V4_SETTLE_ALL_ID,
V4_TAKE_ALL_ID,
],
params: [
USDT_FOR_USDC_400,
DAI_FOR_USDC_400,
encodeV4SettleAll(USDT_ADDR, USDT_400),
encodeV4SettleAll(DAI_ADDR, DAI_400),
encodeV4TakeAll(USDC_ADDR, 0n),
],
lines: [["Amount", "1000.0000 USDT"], ...DAI_GROUP],
},
{
kind: "a V4 step with a SETTLE of USDT by the user, then a SETTLE of WETH from the router",
actions: [
V4_SETTLE_ID,
V4_SETTLE_ID,
V4_SWAP_EXACT_IN_SINGLE_ID,
V4_SWAP_EXACT_IN_SINGLE_ID,
V4_TAKE_ALL_ID,
],
params: [
settle(USDT_ADDR, USDT_400, true),
settle(WETH_ADDR, 2n ** 255n, false), // CONTRACT_BALANCE
USDT_FOR_USDC_400,
encodeV4ExactInSingle(WETH_ADDR, USDC_ADDR, 0n, 1n),
encodeV4TakeAll(USDC_ADDR, 0n),
],
lines: [["Amount", "1000.0000 USDT"]],
},
{
kind: "a V4 step with no swap action: a SETTLE of 400 USDT by the user and a TAKE of it to another address",
actions: [V4_SETTLE_ID, V4_TAKE_ID],
params: [
settle(USDT_ADDR, USDT_400, true),
take(USDT_ADDR, OTHER_ADDR, USDT_400),
],
lines: [["Amount", "1000.0000 USDT"]],
},
// The SETTLE's amount, not the swap's, is what the user pays.
{
kind: "a V4 step swapping 400 USDT with a SETTLE of 5,000 USDT by the user, the rest taken to another address",
actions: [
V4_SETTLE_ID,
V4_SWAP_EXACT_IN_SINGLE_ID,
V4_TAKE_ID,
V4_TAKE_ALL_ID,
],
params: [
settle(USDT_ADDR, 5000000000n, true),
USDT_FOR_USDC_400,
take(USDT_ADDR, OTHER_ADDR, 0n),
encodeV4TakeAll(USDC_ADDR, 0n),
],
lines: [["Amount", "5600.0000 USDT"]],
},
// A SETTLE_ALL pays all the step owes, here what the TAKE takes as
// well as what the swap spends, so its amount is not known.
{
kind: "a V4 step with no swap action: a TAKE of 400 USDT to another address, then a SETTLE_ALL of USDT",
actions: [V4_TAKE_ID, V4_SETTLE_ALL_ID],
params: [
take(USDT_ADDR, OTHER_ADDR, USDT_400),
encodeV4SettleAll(USDT_ADDR, USDT_400),
],
lines: [
["Moved from the sender", UNDECODED],
["Token moved", "USDT (" + USDT_ADDR + ")"],
["Moved to", "The swap step that spends it"],
],
},
{
kind: "a V4 step swapping 400 USDT, with a TAKE of 400 USDT to another address before its SETTLE_ALL of USDT",
actions: [
V4_SWAP_EXACT_IN_SINGLE_ID,
V4_TAKE_ID,
V4_SETTLE_ALL_ID,
V4_TAKE_ALL_ID,
],
params: [
USDT_FOR_USDC_400,
take(USDT_ADDR, OTHER_ADDR, USDT_400),
encodeV4SettleAll(USDT_ADDR, 800000000n),
encodeV4TakeAll(USDC_ADDR, 0n),
],
lines: [
["Moved from the sender", UNDECODED],
["Token moved", "USDT (" + USDT_ADDR + ")"],
["Moved to", "The swap step that spends it"],
],
},
])(
"a V3 step of 600 USDT, then $kind",
({ actions, params, lines }) => {
const result = decodeSteps(
[0x00, 0x10],
[V3_600, encodeV4Swap(new Uint8Array(actions), params)],
);
expect(linesBetweenTokens(result)).toEqual(lines);
},
);
// A step that may take from the sender what the decoder did not read
// leaves no Amount figure, which may be too low, and one line says so.
const UNREAD_SWAP = V4_SWAP_ACTION_SHAPES[0].newer;
test.each([
{
kind: "a V4 step whose SETTLE by the user cannot be read",
actions: [
V4_SWAP_EXACT_IN_SINGLE_ID,
V4_SETTLE_ID,
V4_TAKE_ALL_ID,
],
params: [
USDT_FOR_USDC_400,
dirtyWord(settle(USDT_ADDR, USDT_400, true), 0),
encodeV4TakeAll(USDC_ADDR, 0n),
],
},
{
kind: "a V4 step whose SETTLE_ALL cannot be read",
actions: [
V4_SWAP_EXACT_IN_SINGLE_ID,
V4_SETTLE_ALL_ID,
V4_TAKE_ALL_ID,
],
params: [
USDT_FOR_USDC_400,
dirtyWord(encodeV4SettleAll(USDT_ADDR, USDT_400), 0),
encodeV4TakeAll(USDC_ADDR, 0n),
],
},
{
kind: "a V4 step whose swap action and SETTLE_ALL cannot be read",
actions: [
V4_SWAP_EXACT_IN_SINGLE_ID,
V4_SETTLE_ALL_ID,
V4_TAKE_ALL_ID,
],
params: [
UNREAD_SWAP,
dirtyWord(encodeV4SettleAll(WETH_ADDR, ONE_WETH), 0),
encodeV4TakeAll(USDC_ADDR, 0n),
],
},
])("a V3 step of 600 USDT, then $kind", ({ actions, params }) => {
const result = decodeSteps(
[0x00, 0x10],
[V3_600, encodeV4Swap(new Uint8Array(actions), params)],
);
expect(linesBetweenTokens(result)).toEqual([
["Moved from the sender", UNDECODED],
]);
});
test.each([
{
kind: "a V3 step of 600 USDT, then a V4 step whose input cannot be read",
commands: [0x00, 0x10],
inputs: [
V3_600,
dirtyWord(
encodeV4Swap(new Uint8Array([V4_SETTLE_ID]), [
settle(USDT_ADDR, USDT_400, true),
]),
2,
),
],
},
{
kind: "a V4 step with no swap action whose SETTLE_ALL cannot be read, then a V3 step of 600 USDT",
commands: [0x10, 0x00],
inputs: [
encodeV4Swap(
new Uint8Array([V4_TAKE_ID, V4_SETTLE_ALL_ID]),
[
take(USDT_ADDR, OTHER_ADDR, USDT_400),
dirtyWord(
encodeV4SettleAll(USDT_ADDR, USDT_400),
0,
),
],
),
V3_600,
],
},
{
kind: "a V3 step of 600 USDT, then a V2 step the user pays for whose input cannot be read",
commands: [0x00, 0x08],
inputs: [
V3_600,
dirtyWord(
encodeV2SwapExactIn(OTHER_ADDR, USDT_400, 1n, [
USDT_ADDR,
USDC_ADDR,
]),
0,
),
],
},
{
kind: "a V3 step of 600 USDT, then a PERMIT2_TRANSFER_FROM whose input cannot be read",
commands: [0x00, 0x02],
inputs: [
V3_600,
dirtyWord(
coder.encode(
["address", "address", "uint160"],
[USDT_ADDR, OTHER_ADDR, USDT_400],
),
1,
),
],
},
{
kind: "a V3 step of 600 USDT, then a PERMIT2_TRANSFER_FROM_BATCH",
commands: [0x00, 0x0d],
inputs: [
V3_600,
coder.encode(
["tuple(address,address,uint160,address)[]"],
[[[USER_ADDR, OTHER_ADDR, USDT_400, USDT_ADDR]]],
),
],
},
])("$kind", ({ commands, inputs }) => {
const result = decodeSteps(commands, inputs);
expect(linesBetweenTokens(result)).toEqual([
["Moved from the sender", UNDECODED],
]);
});
// A PERMIT2_PERMIT that sets the input side keeps its own amount: the
// steps it lets the router spend do not add to it.
test("a split after a PERMIT2_PERMIT shows the permit's amount", () => {
const data = buildExecute(
solidityPacked(["uint8", "uint8", "uint8"], [0x0a, 0x00, 0x08]),
[
encodePermit2(USDT_ADDR, 5000000000n, ROUTER_ADDR), // 5000 USDT
encodeV3SwapExactIn(USER_ADDR, USDT_600, 590000000n, [
USDT_ADDR,
USDC_ADDR,
]),
encodeV2SwapExactIn(USER_ADDR, USDT_400, 390000000n, [
USDT_ADDR,
USDC_ADDR,
]),
],
9999999999n,
);
const result = uniswap.decode(
data,
ROUTER_ADDR,
"0x1",
{},
USER_ADDR,
);
expect(result).not.toBeNull();
expect(detail(result, "Amount").value).toBe("5000.0000 USDT");
expect(detail(result, "Moved from the sender")).toBeUndefined();
});
// A permit to another spender, or one the router lets fail (0x80 on
// the command byte), caps nothing the router takes, so what each
// later step takes of its token gets its own lines.
test.each([
{
kind: "to another spender",
command: 0x0a,
spender: OTHER_ADDR,
},
{
kind: "that the router lets fail",
command: 0x8a,
spender: ROUTER_ADDR,
},
])(
"a split after a PERMIT2_PERMIT $kind shows what each step takes",
({ command, spender }) => {
const result = decodeSteps(
[command, 0x00, 0x08],
[
encodePermit2(USDT_ADDR, 1000000n, spender), // 1 USDT
V3_600,
encodeV2SwapExactIn(USER_ADDR, USDT_400, 390000000n, [
USDT_ADDR,
USDC_ADDR,
]),
],
);
// The V3 step names its token as its path spells it, in
// lower case.
const moved = ["Moved to", "The swap step that spends it"];
expect(linesBetweenTokens(result)).toEqual([
["Amount", "1.0000 USDT"],
["Moved from the sender", "600.0000 USDT"],
["Token moved", "USDT (" + USDT_ADDR.toLowerCase() + ")"],
moved,
["Moved from the sender", "400.0000 USDT"],
["Token moved", "USDT (" + USDT_ADDR + ")"],
moved,
]);
},
);
// A V2 exact-out step makes every amount the swap steps spend a maximum,
// the total included.
test("a split with a V2 exact-out step the user pays for shows the total as a maximum", () => {
const data = buildExecute(
solidityPacked(["uint8", "uint8"], [0x00, 0x09]),
[
encodeV3SwapExactIn(USER_ADDR, USDT_600, 590000000n, [
USDT_ADDR,
USDC_ADDR,
]),
encodeV2SwapExactOut(USER_ADDR, 390000000n, USDT_400, [
USDT_ADDR,
USDC_ADDR,
]),
],
9999999999n,
);
const result = uniswap.decode(
data,
ROUTER_ADDR,
"0x1",
{},
USER_ADDR,
);
expect(result).not.toBeNull();
expect(detail(result, "Amount").value).toBe("Up to 1000.0000 USDT");
});
});
// https://git.eeqj.de/sneak/AutistMask/issues/359 — the output half, in
// the shape the issue measured: a V4 step that states a minimum of zero
// and names no output currency.
+55 -12
View File
@@ -160,8 +160,8 @@ function transfer(command, token, recipient, amount) {
];
}
// PERMIT2_PERMIT (0x0a) of `amount` of `token`, for the router to spend.
function permit2Permit(token, amount) {
// PERMIT2_PERMIT (0x0a) of `amount` of `token`, for `spender` to spend.
function permit2Permit(token, amount, spender) {
return [
0x0a,
coder.encode(
@@ -169,7 +169,7 @@ function permit2Permit(token, amount) {
"tuple(tuple(address,uint160,uint48,uint48),address,uint256)",
"bytes",
],
[[[token, amount, 0, 0], ROUTER, 0n], "0x"],
[[[token, amount, 0, 0], spender, 0n], "0x"],
),
];
}
@@ -671,6 +671,7 @@ describe("any token left in the router is not received", () => {
v3SwapExactIn(MSG_SENDER, USDT_2000, USDC_1990, USDT, USDC),
),
left: tokenLine(WETH, "WETH"),
spent: "2000.0000 USDT",
},
{
kind: "a WRAP_ETH of 1 ETH into the router, then a swap of 0.5 WETH from the router",
@@ -697,6 +698,7 @@ describe("any token left in the router is not received", () => {
v2Swap(0x08, MSG_SENDER, ONE_WETH, USDC_1990, [WETH, USDC]),
),
left: tokenLine(WETH, "WETH"),
spent: "1.0000 WETH",
},
{
kind: "a WRAP_ETH of 1 ETH into the router, then a V3 swap of 1 WETH that the user pays for",
@@ -705,6 +707,7 @@ describe("any token left in the router is not received", () => {
v3SwapExactIn(MSG_SENDER, ONE_WETH, USDC_1990, WETH, USDC),
),
left: tokenLine(WETH, "WETH"),
spent: "1.0000 WETH",
},
{
kind: "a WRAP_ETH of 1 ETH into the router, then a V4 swap of 1 WETH with a SETTLE of 1 WETH by the user",
@@ -717,6 +720,7 @@ describe("any token left in the router is not received", () => {
),
),
left: tokenLine(WETH, "WETH"),
spent: "1.0000 WETH",
},
{
kind: "a swap paying WETH to the router, a WRAP_ETH of 1 ETH into the router, then a swap of 1 WETH from the router",
@@ -792,9 +796,13 @@ describe("any token left in the router is not received", () => {
),
),
left: tokenLine(WETH, "WETH"),
// The step has two SETTLEs of WETH, so what the user pays is not
// known.
spent: UNDECODED,
},
// The user pays for the swap by a SETTLE_ALL or SETTLE whose currency
// the decoder cannot read, so the SETTLE from the router pays nothing.
// the decoder cannot read, so the SETTLE from the router pays nothing,
// and what the user pays is not known.
{
kind: "a WRAP_ETH of 1 ETH into the router, then a V4 swap of 1 WETH with a SETTLE_ALL that cannot be read and a SETTLE of OPEN_DELTA from the router",
data: execute(
@@ -807,6 +815,7 @@ describe("any token left in the router is not received", () => {
),
),
left: tokenLine(WETH, "WETH"),
unread: true,
},
{
kind: "a WRAP_ETH of 1 ETH into the router, then a V4 swap of 1 WETH with a SETTLE by the user that cannot be read and a SETTLE of OPEN_DELTA from the router",
@@ -820,6 +829,7 @@ describe("any token left in the router is not received", () => {
),
),
left: tokenLine(WETH, "WETH"),
unread: true,
},
{
kind: "a WRAP_ETH of 1 ETH into the router, then a V4 step with an exact-in of 1 WETH less 1,000 wei and an empty path, a swap of 1,000 wei, and a SETTLE of OPEN_DELTA from the router",
@@ -873,12 +883,20 @@ describe("any token left in the router is not received", () => {
),
left: { label: "Token moved into the router", value: "ETH" },
},
])("$kind", ({ data, left }) => {
])("$kind", ({ data, left, spent, unread }) => {
const result = decode(data);
expect(labels(result)).toEqual([
"Protocol",
"Token In",
"Amount",
// A later step whose SETTLE or SETTLE_ALL the decoder cannot read
// may take anything from the sender: one line says so, in place
// of the Amount line (https://git.eeqj.de/sneak/AutistMask/issues/625).
unread ? "Moved from the sender" : "Amount",
// A later swap step the user pays for spends `spent` of a token
// other than Token In.
...(spent
? ["Moved from the sender", "Token moved", "Moved to"]
: []),
"Token Out",
"Paid to",
"Token moved into the router",
@@ -886,6 +904,14 @@ describe("any token left in the router is not received", () => {
"Steps",
"Deadline",
]);
if (spent) {
expect(detail(result, "Moved from the sender").value).toBe(spent);
}
if (unread) {
expect(detail(result, "Moved from the sender").value).toBe(
UNDECODED,
);
}
expect(paidTo(result)).toEqual([STAYS_IN_ROUTER]);
expect(detail(result, "Token moved into the router")).toEqual(left);
expect(detail(result, "Min. paid out").value).toBe("1990.0000 USDC");
@@ -2229,6 +2255,10 @@ describe("the allow-revert flag", () => {
});
// Only the routers from UniversalRouterV2 on let a PERMIT2_PERMIT fail.
// A permit to the router caps what the router takes of its token after
// it, unless the router lets it fail: then what the swap takes gets its
// own lines (https://git.eeqj.de/sneak/AutistMask/issues/625). The swap
// otherwise reads as without the flag.
test.each([
{ router: "UniversalRouterV1", address: ROUTER_V1, mark: "" },
{
@@ -2240,17 +2270,19 @@ describe("the allow-revert flag", () => {
router: "UniversalRouterV2",
address: ROUTER,
mark: " (allowed to fail)",
taken: "2000.0000 USDT",
},
{
router: "UniversalRouterV2_1_2",
address: ROUTER_V2_1_2,
mark: " (allowed to fail)",
taken: "2000.0000 USDT",
},
])(
"on $router, a PERMIT2_PERMIT with the flag is listed as 'Permit2 Permit$mark', and the swap reads as without the flag",
({ address, mark }) => {
"on $router, a PERMIT2_PERMIT with the flag is listed as 'Permit2 Permit$mark'",
({ address, mark, taken }) => {
const steps = [
permit2Permit(USDT, USDT_2000),
permit2Permit(USDT, USDT_2000, address),
swapToWeth(MSG_SENDER),
];
const plain = decode(execute(...steps), USER, address);
@@ -2262,9 +2294,20 @@ describe("the allow-revert flag", () => {
expect(detail(withFlag, "Steps").value).toBe(
"Permit2 Permit" + mark + " → V3 Swap (Exact In)",
);
const withoutSteps = (r) =>
r.details.filter((d) => d.label !== "Steps");
expect(withoutSteps(withFlag)).toEqual(withoutSteps(plain));
const takenLines = [
"Moved from the sender",
"Token moved",
"Moved to",
];
const rest = (r) =>
r.details.filter(
(d) => d.label !== "Steps" && !takenLines.includes(d.label),
);
expect(rest(withFlag)).toEqual(rest(plain));
expect(detail(plain, "Moved from the sender")).toBeUndefined();
expect(detail(withFlag, "Moved from the sender")?.value).toBe(
taken,
);
expect(detail(withFlag, "Min. received").value).toBe("1.0000 WETH");
},
);