Open
Conversation
Withdraw used order.maxAmount directly without verifying the actual on-chain balance, causing reverts when float-to-wei rounding produced amounts slightly exceeding the real token balance (e.g. ~2.8 gwei difference on Polygon/ZCHF rule 171). Mirror the existing deposit() pattern: read L2 balance, reject if below minAmount, and clamp to Math.min(maxAmount, l2Liquidity).
Prevents transfer failures caused by Number↔Wei precision rounding. When converting token amounts through parseFloat (fromWeiAmount) and back to Wei (toWeiAmount), floating-point precision loss can produce a Wei amount 1-2 wei higher than the actual balance, causing reverts like Dai/insufficient-balance.
Order 118943 has been InProgress since 2026-04-02 because the on-chain TX reverted with Dai/insufficient-balance but the completion check only looks for Binance deposits and never detects reverted TXs. Sets order + pipeline to Failed and rule 82 to Active.
This reverts commit d5d8b28.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bug 1 (L2 Bridge): Redundancy pipeline for Polygon/ZCHF (rule 171) fails with
ERC20: burn amount exceeds balancebecausewithdraw()usesorder.maxAmountdirectly without verifying the actual on-chain L2 balanceRoot cause:
Util.round(..., 8)rounds7605.78999999716...up to7605.79, which converts to7605790000000000000000wei — 2,837,029,865 wei more than the actual on-chain balance (7605789999997162970135wei)Fix: Mirror the existing
deposit()pattern inwithdraw(): read L2 balance, reject if belowminAmount, clamp amount toMath.min(maxAmount, l2Liquidity). ExtendL2BridgeEvmClientinterface withgetNativeCoinBalance()andgetTokenBalance()(already inherited fromEvmClientby all L2 clients)Bug 2 (DfxDex / ERC20 general): Redundancy pipeline for Ethereum/DAI (rule 82) fails with
Dai/insufficient-balance— stuck InProgress since 2026-04-02Root cause:
fromWeiAmountusesparseFloat()which loses precision for 18-decimal tokens. The roundtripWei → parseFloat(Number) → BigNumber.toFixed(18) → parseUnits → Weican produce a value 1-2 wei higher than the actual balanceFix: In
EvmClient.sendToken(), read the actual on-chain balance viacontract.balanceOf()before callingcontract.transfer(), and captargetAmountto the balance if it exceeds itRelated
Test plan