Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69f8e10cc7 |
@@ -1260,9 +1260,8 @@ user WETH, then an unwrap, shows WETH with the second swap's minimum. The
|
|||||||
minimum reads in ETH when that step paid all its WETH to the router. When it
|
minimum reads in ETH when that step paid all its WETH to the router. When it
|
||||||
paid only part of it to the router, as a V4 step does that `TAKE`s some of its
|
paid only part of it to the router, as a V4 step does that `TAKE`s some of its
|
||||||
WETH to the user and the rest to the router, or paid the router WETH beside a
|
WETH to the user and the rest to the router, or paid the router WETH beside a
|
||||||
payout the decoder cannot read, the swap shows ETH with no minimum: the decoder
|
payout the decoder cannot read, the swap shows ETH with no minimum, since the
|
||||||
does not count how much of that step's minimum reaches the router, nor read the
|
calldata states none for the ETH. A later step that sets the output side sets it
|
||||||
`UNWRAP_WETH`'s own minimum. A later step that sets the output side sets it
|
|
||||||
anew. Otherwise `Token Out` and `Min. received` keep the output side's own token
|
anew. 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
|
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
|
that buys USDC and then unwraps the WETH it did not spend shows USDC. The token
|
||||||
|
|||||||
@@ -1224,10 +1224,9 @@ function decode(data, toAddress, chainId, sources, fromAddress) {
|
|||||||
// again.
|
// again.
|
||||||
let outputUnwrapped = false;
|
let outputUnwrapped = false;
|
||||||
// Where the step that set the output side paid its output: the
|
// Where the step that set the output side paid its output: the
|
||||||
// recipient of a swap step, as written, or of each TAKE, TAKE_ALL and
|
// recipient of a swap step, as written, or of each TAKE and
|
||||||
// TAKE_PORTION of it in a V4 step, a TAKE_ALL as paid to the sender,
|
// TAKE_PORTION of it in a V4 step, with null for a payout of that
|
||||||
// with null for a payout of that step this decoder did not read. A
|
// step this decoder did not read. A BALANCE_CHECK_ERC20 pays nobody.
|
||||||
// BALANCE_CHECK_ERC20 pays nobody.
|
|
||||||
let outputRecipients = [];
|
let outputRecipients = [];
|
||||||
let hasV2OrV3ExactOut = false;
|
let hasV2OrV3ExactOut = false;
|
||||||
let swapUndecoded = false;
|
let swapUndecoded = false;
|
||||||
@@ -1801,10 +1800,9 @@ function decode(data, toAddress, chainId, sources, fromAddress) {
|
|||||||
// that step paid to the user, or to anyone else, stays
|
// that step paid to the user, or to anyone else, stays
|
||||||
// WETH, so when that step also paid some of its output
|
// WETH, so when that step also paid some of its output
|
||||||
// elsewhere, or made a payout this decoder did not read,
|
// elsewhere, or made a payout this decoder did not read,
|
||||||
// only part of it may be unwrapped. This decoder does not
|
// only part of it may be unwrapped. The calldata then
|
||||||
// count how much of that step's minimum then reaches the
|
// states no minimum for the ETH, and the output side keeps
|
||||||
// router, nor read the UNWRAP_WETH's own minimum, so the
|
// no figure.
|
||||||
// output side keeps no figure.
|
|
||||||
const toRouter = (r) => present(r) && isRouter(r);
|
const toRouter = (r) => present(r) && isRouter(r);
|
||||||
if (
|
if (
|
||||||
present(outputToken) &&
|
present(outputToken) &&
|
||||||
|
|||||||
@@ -603,20 +603,6 @@ describe("an UNWRAP_WETH makes the output ETH only when the router holds it", ()
|
|||||||
expect(detail(result, "Min. received").value).toBe("1.0000 ETH");
|
expect(detail(result, "Min. received").value).toBe("1.0000 ETH");
|
||||||
});
|
});
|
||||||
|
|
||||||
// The SWEEP pays the user all the WETH the router holds, so the
|
|
||||||
// UNWRAP_WETH finds none of it.
|
|
||||||
test("a swap paying its WETH to the router, then a SWEEP of it to the user, then an UNWRAP_WETH, reads as WETH", () => {
|
|
||||||
const result = decode(
|
|
||||||
execute(
|
|
||||||
swapToWeth(ADDRESS_THIS),
|
|
||||||
sweep(WETH, MSG_SENDER),
|
|
||||||
unwrapWeth(MSG_SENDER),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
expect(result.name).toBe("Swap USDT → WETH");
|
|
||||||
expect(detail(result, "Min. received").value).toBe("1.0000 WETH");
|
|
||||||
});
|
|
||||||
|
|
||||||
// The user receives the first step's WETH as WETH and the second's as
|
// The user receives the first step's WETH as WETH and the second's as
|
||||||
// ETH. The second step sets the output side and pays its WETH to the
|
// ETH. The second step sets the output side and pays its WETH to the
|
||||||
// router, so the output reads as ETH with the second step's minimum.
|
// router, so the output reads as ETH with the second step's minimum.
|
||||||
@@ -655,9 +641,8 @@ describe("an UNWRAP_WETH makes the output ETH only when the router holds it", ()
|
|||||||
});
|
});
|
||||||
|
|
||||||
// One V4 step buys at least 1 WETH and TAKEs 0.6 WETH to the user and the
|
// One V4 step buys at least 1 WETH and TAKEs 0.6 WETH to the user and the
|
||||||
// rest to the router. The user receives 0.6 WETH and the rest as ETH.
|
// rest to the router. The user receives 0.6 WETH and the rest as ETH, so
|
||||||
// Neither minimum is shown: the decoder does not count how much of the
|
// neither minimum is shown: the calldata states none for the ETH.
|
||||||
// step's minimum reaches the router, nor read the UNWRAP_WETH's own.
|
|
||||||
test("one V4 step paying part of its WETH to the user and the rest to the router, then an UNWRAP_WETH, reads as ETH with no minimum", () => {
|
test("one V4 step paying part of its WETH to the user and the rest to the router, then an UNWRAP_WETH, reads as ETH with no minimum", () => {
|
||||||
const result = decode(
|
const result = decode(
|
||||||
execute(
|
execute(
|
||||||
@@ -714,35 +699,6 @@ describe("an UNWRAP_WETH makes the output ETH only when the router holds it", ()
|
|||||||
expect(result.name).toBe("Swap USDT → WETH");
|
expect(result.name).toBe("Swap USDT → WETH");
|
||||||
expect(detail(result, "Min. received").value).toBe("0.5000 WETH");
|
expect(detail(result, "Min. received").value).toBe("0.5000 WETH");
|
||||||
});
|
});
|
||||||
|
|
||||||
// The EXECUTE_SUB_PLAN's own steps, which the decoder does not read, buy
|
|
||||||
// the user USDC as well, so Token Out is not named.
|
|
||||||
test("a swap paying its WETH to the router, then an UNWRAP_WETH, then an EXECUTE_SUB_PLAN, names no Token Out", () => {
|
|
||||||
const subPlan = [
|
|
||||||
0x21,
|
|
||||||
coder.encode(
|
|
||||||
["bytes", "bytes[]"],
|
|
||||||
[
|
|
||||||
"0x00",
|
|
||||||
[
|
|
||||||
v3SwapExactIn(
|
|
||||||
MSG_SENDER,
|
|
||||||
USDT_2000,
|
|
||||||
USDC_1990,
|
|
||||||
USDT,
|
|
||||||
USDC,
|
|
||||||
)[1],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
|
||||||
];
|
|
||||||
const result = decode(
|
|
||||||
execute(swapToWeth(ADDRESS_THIS), unwrapWeth(MSG_SENDER), subPlan),
|
|
||||||
);
|
|
||||||
expect(result.name).toBe("Uniswap Swap");
|
|
||||||
expect(detail(result, "Token Out").value).toBe(UNDECODED);
|
|
||||||
expect(detail(result, "Min. received")).toBeUndefined();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// https://git.eeqj.de/sneak/AutistMask/issues/606: any token a step pays the
|
// https://git.eeqj.de/sneak/AutistMask/issues/606: any token a step pays the
|
||||||
|
|||||||
Reference in New Issue
Block a user