Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d223cb810c |
@@ -3026,10 +3026,7 @@ Currently supported:
|
||||
`address(1)` and `address(2)` there are addresses too. A check of any address
|
||||
but the transaction's sender's says nothing about what the user receives: it
|
||||
sets neither `Token Out` nor the minimum, and it is listed as
|
||||
`Balance Check (of another address)`. A check whose input does not decode,
|
||||
such as one whose owner word has a nonzero top byte (the router reads the
|
||||
owner from the word's last 20 bytes), likewise sets neither, and it is listed
|
||||
as `Balance Check (could not be decoded)`. When a swap step, `TAKE` or
|
||||
`Balance Check (of another address)`. When a swap step, `TAKE` or
|
||||
`TAKE_PORTION` pays the router the swap's output token, the output stays in
|
||||
the router unless a later step pays all the router holds of it to anyone but
|
||||
the router: a `SWEEP` of that token, an `UNWRAP_WETH` when it is WETH, a
|
||||
|
||||
@@ -1093,14 +1093,7 @@ function decode(data, toAddress, chainId, sources, fromAddress) {
|
||||
}
|
||||
} else if (cmdId === 0x0e) {
|
||||
const b = decodeBalanceCheck(inputs[i]);
|
||||
if (!b) {
|
||||
// The router still runs a check whose input does not
|
||||
// decode, such as an owner word with a nonzero top
|
||||
// byte, of which it reads the last 20 bytes, so the
|
||||
// owner may be any address. It sets no side, and the
|
||||
// step says so.
|
||||
commandNames[i] += " (could not be decoded)";
|
||||
} else if (b.owner.toLowerCase() !== sender) {
|
||||
if (b && b.owner.toLowerCase() !== sender) {
|
||||
// The router reads the owner as written (see
|
||||
// decodeBalanceCheck()), so address(1) and address(2)
|
||||
// are not the sender and the router here. A check of
|
||||
@@ -1108,7 +1101,7 @@ function decode(data, toAddress, chainId, sources, fromAddress) {
|
||||
// what the user receives: it sets no side, and the
|
||||
// step says so.
|
||||
commandNames[i] += " (of another address)";
|
||||
} else {
|
||||
} else if (b) {
|
||||
// The router passes this check whenever the owner
|
||||
// holds at least minBalance, so a zero one guarantees
|
||||
// nothing and does not replace a minimum an earlier
|
||||
|
||||
@@ -1796,24 +1796,6 @@ describe.each([
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
test("an owner word with a nonzero top byte: the check is said not to decode and sets no minimum", () => {
|
||||
// The router checks the balance of the address in the word's last 20
|
||||
// bytes, here OTHER's.
|
||||
const check = withDirtyWord(balanceCheck(WETH, ONE_WETH, OTHER), 0);
|
||||
|
||||
const plain = decode(execute(swap, check), USER, address);
|
||||
expect(detail(plain, "Steps").value).toBe(
|
||||
"V3 Swap (Exact In) → Balance Check (could not be decoded)",
|
||||
);
|
||||
expect(detail(plain, "Min. received").value).toBe(NO_MINIMUM);
|
||||
|
||||
const withFlag = decode(execute(swap, flagged(check)), USER, address);
|
||||
expect(detail(withFlag, "Steps").value).toBe(
|
||||
"V3 Swap (Exact In) → Balance Check (could not be decoded) (allowed to fail)",
|
||||
);
|
||||
expect(detail(withFlag, "Min. received").value).toBe(NO_MINIMUM);
|
||||
});
|
||||
});
|
||||
|
||||
// The DOM stub both screens are drawn into.
|
||||
|
||||
Reference in New Issue
Block a user