fix: a zero-minimum balance check never sets the output side (closes #649)
check / check (push) Canceled after 0s
e2e / e2e-chrome (push) Canceled after 0s
e2e / e2e-firefox (push) Canceled after 0s

A BALANCE_CHECK_ERC20 of the sender with a zero minimum guarantees
nothing, and neither does one the router lets fail. Such a check set
Token Out and the minimum whenever the output side held no minimum.
After an UNWRAP_WETH that drops the minimum, a zero check of USDC
named USDC as Token Out. Such a check now sets neither line. A check
with a positive minimum is unchanged.

Model: opus-5-5
This commit is contained in:
2026-10-27 07:32:53 +00:00
parent fc6cffcaba
commit 7c456df556
4 changed files with 92 additions and 34 deletions
+5 -5
View File
@@ -1629,13 +1629,13 @@ function decode(data, toAddress, chainId, sources, fromAddress) {
} else {
// The router passes this check whenever the owner
// holds at least minBalance, so a zero one guarantees
// nothing and does not replace a minimum an earlier
// step stated. A check the router lets fail guarantees
// nothing either, so it is read as a zero one. Any
// nothing. A check the router lets fail guarantees
// nothing either, so it is read as a zero one. A zero
// check sets neither Token Out nor the minimum. Any
// other minBalance sets the output side as a swap
// does. It pays nobody.
// does. The check pays nobody.
const minBalance = allowedToFail ? 0n : b.minBalance;
if (!(minBalance === 0n && present(minOutput))) {
if (minBalance !== 0n) {
setOutput(i, b.token, minBalance, []);
}
keepsRouterWeth = true;