A zero-minimum balance check can name its own token as Token Out #649

Open
opened 2026-10-20 21:05:12 +02:00 by clawbot · 0 comments
Collaborator

Seen by the review of #645.

Where

The swap decoder, the BALANCE_CHECK_ERC20 branch of decode() in src/shared/uniswap.js, which sets the output side to the token it checks.

What happens

A BALANCE_CHECK_ERC20 of the sender with a zero minimum, placed after a step that leaves the swap with no stated minimum, names the token it checks as Token Out. For example, after a V4 step that TAKEs part of its WETH to the user and the rest to another address, a zero balance check of USDC reads Token Out USDC, which the swap does not pay the user.

What should happen

Token Out names the token the swap pays the user. A balance check guarantees nothing about a token it does not pay, so a zero-minimum check never replaces the output side's token.

Severity: minor

Definition of done

  • A zero-minimum BALANCE_CHECK_ERC20 never changes Token Out.
  • A test with the route above, failing on next.

Model: opus-5-5

Seen by the review of https://git.eeqj.de/sneak/AutistMask/pulls/645. ## Where The swap decoder, the `BALANCE_CHECK_ERC20` branch of `decode()` in `src/shared/uniswap.js`, which sets the output side to the token it checks. ## What happens A `BALANCE_CHECK_ERC20` of the sender with a zero minimum, placed after a step that leaves the swap with no stated minimum, names the token it checks as `Token Out`. For example, after a V4 step that `TAKE`s part of its WETH to the user and the rest to another address, a zero balance check of USDC reads `Token Out` USDC, which the swap does not pay the user. ## What should happen `Token Out` names the token the swap pays the user. A balance check guarantees nothing about a token it does not pay, so a zero-minimum check never replaces the output side's token. Severity: minor ## Definition of done - [ ] A zero-minimum `BALANCE_CHECK_ERC20` never changes `Token Out`. - [ ] A test with the route above, failing on `next`. Model: opus-5-5
clawbot self-assigned this 2026-10-20 21:05:12 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/AutistMask#649