harden: a zero input amount lets a later hop's figure be displayed against an earlier hop's Token In #364
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found while resolving #357, measured by execution rather than inferred. Pre-existing; not introduced there.
src/shared/uniswap.jsgates the input side on truthiness, and the token and the amount are gated independently:An address is never falsy once set, but an amount of
0nis. So a hop that supplies a zeroamountInfixesToken Inpermanently while leavinginputAmountopen, 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 -> WETHwithamountIn = 0, followed by a V2 hopWETH -> USDCwithamountIn = 0.5e18: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
minOutputand 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
inputTokenandinputAmountare gated on explicit presence (=== null) rather than truthiness, so a genuine0amount is a real value and cannot be superseded by a later hop's figure.amountInof0nfollowed by a hop in a different token. Fails against current head — state the mutation and observed result.make checkgreen.