harden: a V4 swap with an undetermined output token is asserted to the user as ETH at 18 decimals #353
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?
Raised by the review of #352 (#352 (comment)). Pre-existing and latent; not introduced there.
src/shared/uniswap.js:426-435— a V4 swap can setminOutputwhile leavingoutputTokennull, because the assignment is gated onif (v4.tokenOut).tokenInfo(null)then returns{symbol: "ETH", decimals: 18}, so an undetermined output token is stated to the user as ETH, with itsMin. receivedformatted at 18 decimals.This is the same class as #340 and #306: the approval screen asserting a fact it has not established. Here it is worse than a wrong scale — it names the wrong asset.
It may be deliberate, which is why this needs determining rather than patching: Uniswap V4 represents native ETH as the zero address, so collapsing a null
tokenOutto ETH could be correct protocol semantics. The reviewer declined to call it a defect for that reason. Establish which it is before changing anything.Definition of done
tokenOutgenuinely means native ETH in the V4 encoding, or whether it means undetermined. Cite the encoding, do not infer from the current code.make checkgreen.