fix: a V4 step that spends some of its output currency shows no Min. received (closes #574)
A V4 step's Min. received was the sum of the minimums of the swap actions that buy its output currency, even when another swap action in the same step spends some of that currency. The user then receives less than that figure. decodeV4Swap() now gives no minimum when a swap action in the step also spends the output currency, as it already does for other minimums it cannot state. A multi-hop action counts only the currency it spends and the one it ends with, so a path through an intermediate currency is not read as spending it. Model: opus-5-5
This commit was merged in pull request #667.
This commit is contained in:
@@ -1332,6 +1332,10 @@ describe("any token left in the router is not received", () => {
|
||||
),
|
||||
),
|
||||
left: tokenLine(WETH, "WETH"),
|
||||
// The second swap action spends 1 USDC of what the first buys,
|
||||
// so the step states no minimum
|
||||
// (https://git.eeqj.de/sneak/AutistMask/issues/574).
|
||||
noMin: true,
|
||||
},
|
||||
{
|
||||
kind: "a WRAP_ETH of 1 ETH into the router, then a V4 SETTLE of OPEN_DELTA from the router before the swap, which the user settles",
|
||||
@@ -1432,7 +1436,7 @@ describe("any token left in the router is not received", () => {
|
||||
),
|
||||
left: { label: "Token moved into the router", value: "ETH" },
|
||||
},
|
||||
])("$kind", ({ data, left, spent, unread }) => {
|
||||
])("$kind", ({ data, left, spent, unread, noMin }) => {
|
||||
const result = decode(data);
|
||||
expect(labels(result)).toEqual([
|
||||
"Protocol",
|
||||
@@ -1458,7 +1462,7 @@ describe("any token left in the router is not received", () => {
|
||||
"Token Out",
|
||||
"Paid to",
|
||||
"Token moved into the router",
|
||||
"Min. paid out",
|
||||
...(noMin ? [] : ["Min. paid out"]),
|
||||
"Steps",
|
||||
"Deadline",
|
||||
]);
|
||||
@@ -1474,7 +1478,9 @@ describe("any token left in the router is not received", () => {
|
||||
}
|
||||
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");
|
||||
expect(detail(result, "Min. paid out")?.value).toBe(
|
||||
noMin ? undefined : "1990.0000 USDC",
|
||||
);
|
||||
});
|
||||
|
||||
// Uniswap's own routes: a swap paid in ETH wraps into the router what its
|
||||
|
||||
Reference in New Issue
Block a user