harden: a zero input amount lets a later hop's figure be displayed against an earlier hop's Token In #364

Closed
opened 2026-08-23 20:15:05 +02:00 by clawbot · 0 comments
Collaborator

Found while resolving #357, measured by execution rather than inferred. Pre-existing; not introduced there.

src/shared/uniswap.js gates the input side on truthiness, and the token and the amount are gated independently:

if (!inputToken) inputToken = s.tokenIn;
if (!inputAmount) inputAmount = s.amountIn;

An address is never falsy once set, but an amount of 0n is. So a hop that supplies a zero amountIn fixes Token In permanently while leaving inputAmount open, and the next hop's figure is then displayed against the first hop's token, at that token's scale.

Measured — a V3 hop USDT -> WETH with amountIn = 0, followed by a V2 hop WETH -> USDC with amountIn = 0.5e18:

Token In = USDT (0xdac17f958d2ee523a2206206994597c13d831ec7)
Amount   = 500000000000.0000 USDT

The 0.5 WETH figure of the second hop, rendered as 500 billion USDT. Nothing on the screen is true.

Same falsy-collapse class this repo keeps hitting — #246, #306, #322 — and the exact input-side counterpart of #359, whose text covers only minOutput and the output token. Both sides want the same remedy and could reasonably be one unit.

Not fixed in #365 (the fix for #357): that unit was scoped away from the truthiness gates, and its own change — null means undetermined — does not touch this, which produces a determined-but-wrong token.

Definition of done

  • inputToken and inputAmount are gated on explicit presence (=== null) rather than truthiness, so a genuine 0 amount is a real value and cannot be superseded by a later hop's figure.
  • An amount and the token it is counted in always come from the same hop; a figure is never rendered against a token that did not supply it.
  • Test: a hop with amountIn of 0n followed by a hop in a different token. Fails against current head — state the mutation and observed result.
  • make check green.
Found while resolving https://git.eeqj.de/sneak/AutistMask/issues/357, measured by execution rather than inferred. Pre-existing; not introduced there. `src/shared/uniswap.js` gates the input side on truthiness, and the token and the amount are gated independently: ```js if (!inputToken) inputToken = s.tokenIn; if (!inputAmount) inputAmount = s.amountIn; ``` An address is never falsy once set, but an amount of `0n` is. So a hop that supplies a zero `amountIn` fixes `Token In` permanently while leaving `inputAmount` open, and the next hop's figure is then displayed against the first hop's token, at that token's scale. Measured — a V3 hop `USDT -> WETH` with `amountIn = 0`, followed by a V2 hop `WETH -> USDC` with `amountIn = 0.5e18`: ``` Token In = USDT (0xdac17f958d2ee523a2206206994597c13d831ec7) Amount = 500000000000.0000 USDT ``` The 0.5 WETH figure of the second hop, rendered as 500 billion USDT. Nothing on the screen is true. Same falsy-collapse class this repo keeps hitting — https://git.eeqj.de/sneak/AutistMask/issues/246, https://git.eeqj.de/sneak/AutistMask/issues/306, https://git.eeqj.de/sneak/AutistMask/issues/322 — and the exact input-side counterpart of https://git.eeqj.de/sneak/AutistMask/issues/359, whose text covers only `minOutput` and the output token. Both sides want the same remedy and could reasonably be one unit. Not fixed in https://git.eeqj.de/sneak/AutistMask/pulls/365 (the fix for https://git.eeqj.de/sneak/AutistMask/issues/357): that unit was scoped away from the truthiness gates, and its own change — null means undetermined — does not touch this, which produces a determined-but-wrong token. ## Definition of done - [ ] `inputToken` and `inputAmount` are gated on explicit presence (`=== null`) rather than truthiness, so a genuine `0` amount is a real value and cannot be superseded by a later hop's figure. - [ ] An amount and the token it is counted in always come from the same hop; a figure is never rendered against a token that did not supply it. - [ ] Test: a hop with `amountIn` of `0n` followed by a hop in a different token. Fails against current head — state the mutation and observed result. - [ ] `make check` green.
clawbot added this to the 1.0.0 milestone 2026-08-23 20:16:54 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/AutistMask#364