Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c59883991 | ||
|
|
c13385b270 |
No files matched your search
@@ -3185,8 +3185,7 @@ Currently supported:
|
|||||||
step whose input it cannot read, in whole or in part, and a step it fails on.
|
step whose input it cannot read, in whole or in part, and a step it fails on.
|
||||||
In any other case the line gives the total, as with no permit. When the step
|
In any other case the line gives the total, as with no permit. When the step
|
||||||
that sets the input side spends a token other than the permit's, or one the
|
that sets the input side spends a token other than the permit's, or one the
|
||||||
decoder does not know, its amount gets lines of its own, unless it states no
|
decoder does not know, its amount gets lines of its own and the total has no
|
||||||
amount and the user pays it none of its input token, and the total has no
|
|
||||||
figure to start from: unless the permit's amount stands there is no `Amount`
|
figure to start from: unless the permit's amount stands there is no `Amount`
|
||||||
line, and each take of the permit's token gets lines of its own. Each take the
|
line, and each take of the permit's token gets lines of its own. Each take the
|
||||||
total does not count gives three lines after the `Amount` line (after
|
total does not count gives three lines after the `Amount` line (after
|
||||||
@@ -3198,13 +3197,11 @@ Currently supported:
|
|||||||
it some of its input token, and there is no `Amount` line, that step gets them
|
it some of its input token, and there is no `Amount` line, that step gets them
|
||||||
too whenever another take's lines give a figure, or a `PERMIT2_TRANSFER_FROM`
|
too whenever another take's lines give a figure, or a `PERMIT2_TRANSFER_FROM`
|
||||||
of its token gives one, on the lines below or, into the router, on its
|
of its token gives one, on the lines below or, into the router, on its
|
||||||
`Paid to` line, so that figure cannot read as all that leaves. When it states
|
`Paid to` line, so that figure cannot read as all that leaves. Paid from the
|
||||||
no amount and the user pays it none of its input token, as when the router
|
router, that step takes nothing from the user's wallet and never gets them.
|
||||||
pays it, that step takes none of that token from the user's wallet and never
|
They come in step order, the step that sets the input side first when it has
|
||||||
gets them, with a permit or without. They come in step order, the step that
|
them: `Moved from the sender`, its amount, worded as the `Amount` line words
|
||||||
sets the input side first when it has them: `Moved from the sender`, its
|
one, or `Unknown (could not be decoded)` when the decoder does not know it;
|
||||||
amount, worded as the `Amount` line words one, or
|
|
||||||
`Unknown (could not be decoded)` when the decoder does not know it;
|
|
||||||
`Token moved`, giving the token's address as the `Token In` line does; and
|
`Token moved`, giving the token's address as the `Token In` line does; and
|
||||||
`Moved to`, which reads `The swap step that spends it`. A token the decoder
|
`Moved to`, which reads `The swap step that spends it`. A token the decoder
|
||||||
does not know gives the `Moved from the sender` line alone. A step may also
|
does not know gives the `Moved from the sender` line alone. A step may also
|
||||||
|
|||||||
+6
-11
@@ -1849,22 +1849,17 @@ function decode(data, toAddress, chainId, sources, fromAddress) {
|
|||||||
// (see spentUnread()), or a token it does not know.
|
// (see spentUnread()), or a token it does not know.
|
||||||
const spentFromSender = [];
|
const spentFromSender = [];
|
||||||
let total = null;
|
let total = null;
|
||||||
// Whether the step that set the input side counts as a take from the
|
// The take of the step that set the input side, when the user pays
|
||||||
// sender, which may get lines of its own. The amount it stated counts
|
// that step, the total starts from it and it stated no amount (see
|
||||||
// whoever pays it. Stating none, it counts only when the user pays it
|
// below), or null. Paid from the router, the step takes nothing from
|
||||||
// some of its input token: paid from the router, it takes nothing
|
// the sender.
|
||||||
// from the sender.
|
|
||||||
const hasFirstTake =
|
|
||||||
inputEstablished && (present(inputAmount) || inputPaidByUser);
|
|
||||||
// The take of the step that set the input side, when the total
|
|
||||||
// starts from it and it stated no amount (see below), or null.
|
|
||||||
let firstTakeUnstated = null;
|
let firstTakeUnstated = null;
|
||||||
if (permit === null || sameAddress(inputToken, permit.token)) {
|
if (permit === null || sameAddress(inputToken, permit.token)) {
|
||||||
total = inputAmount;
|
total = inputAmount;
|
||||||
if (hasFirstTake && !present(inputAmount)) {
|
if (inputEstablished && inputPaidByUser && !present(inputAmount)) {
|
||||||
firstTakeUnstated = { token: inputToken, amount: null };
|
firstTakeUnstated = { token: inputToken, amount: null };
|
||||||
}
|
}
|
||||||
} else if (hasFirstTake) {
|
} else if (inputEstablished) {
|
||||||
// The step that set the input side spent a token other than the
|
// The step that set the input side spent a token other than the
|
||||||
// permit's, or one not known, so the total starts with no figure.
|
// permit's, or one not known, so the total starts with no figure.
|
||||||
spentFromSender.push({ token: inputToken, amount: inputAmount });
|
spentFromSender.push({ token: inputToken, amount: inputAmount });
|
||||||
|
|||||||
@@ -2395,36 +2395,6 @@ describe("uniswap decoder", () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// https://git.eeqj.de/sneak/AutistMask/issues/634 — after a
|
|
||||||
// PERMIT2_PERMIT of another token, the V4 exact-out step paid from
|
|
||||||
// the router still takes nothing from the wallet, so it gets no lines
|
|
||||||
// of its own. On next it got lines saying its amount is not known.
|
|
||||||
const ONE_DAI_PERMIT = encodePermit2(DAI_ADDR, 10n ** 18n, ROUTER_ADDR);
|
|
||||||
test.each([
|
|
||||||
{
|
|
||||||
kind: "a PERMIT2_PERMIT of 1 DAI, then a V4 exact-out step of at most 600 USDT paid from the router",
|
|
||||||
commands: [0x0a, 0x10],
|
|
||||||
inputs: [ONE_DAI_PERMIT, V4_EXACT_OUT_600_FROM_ROUTER],
|
|
||||||
lines: [["Amount", "1.0000 DAI"]],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: "a PERMIT2_PERMIT of 1 DAI, a V4 exact-out step of at most 600 USDT paid from the router, then a V2 exact-out of at most 400 USDT the user pays for",
|
|
||||||
commands: [0x0a, 0x10, 0x09],
|
|
||||||
inputs: [
|
|
||||||
ONE_DAI_PERMIT,
|
|
||||||
V4_EXACT_OUT_600_FROM_ROUTER,
|
|
||||||
V2_EXACT_OUT_400,
|
|
||||||
],
|
|
||||||
lines: [["Amount", "1.0000 DAI"], ...UP_TO_400_USDT],
|
|
||||||
},
|
|
||||||
])(
|
|
||||||
"$kind, gives the V4 step no lines of its own",
|
|
||||||
({ commands, inputs, lines }) => {
|
|
||||||
const result = decodeSteps(commands, inputs);
|
|
||||||
expect(linesBetweenTokens(result)).toEqual(lines);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// The V4 exact-out route above the other way round, where the later
|
// The V4 exact-out route above the other way round, where the later
|
||||||
// take's unknown amount leaves no figure at all, and other ways the
|
// take's unknown amount leaves no figure at all, and other ways the
|
||||||
// step that sets the input side states no amount.
|
// step that sets the input side states no amount.
|
||||||
|
|||||||
Reference in new issue
Block a user