fix: Binance CEX pending withdrawal logic and adapter zero-amount cleanup#3110
fix: Binance CEX pending withdrawal logic and adapter zero-amount cleanup#3110nicholaspai merged 8 commits intomasterfrom
Conversation
…inance deposit matching, and floatToBN fix - TokenUtils: getInventoryEquivalentL1TokenAddress, getInventoryBalanceContributorTokens, isL2OnlyEquivalentToken - RunningBalanceUtils: getLatestRunningBalances extracted for shared use - BinanceUtils: getOutstandingBinanceDeposits for cross-L2 deposit matching, export BinanceDeposit type - BNUtils: Fix floatToBN MAX_SAFE_INTEGER overflow via string manipulation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- BinanceCEXBridge: rewrite getL2PendingWithdrawalAmount to correctly compute outstanding deposits when finalizer batches deposits from multiple L2s into single L1 withdrawal. Uses getOutstandingBinanceDeposits with Redis-cached deposit sender lookups. - BaseChainAdapter: use getInventoryEquivalentL1TokenAddress, skip zero-amount outstanding transfers in getOutstandingCrossChainTransfers - AdapterManager: minor cleanup - MockLineaEvents: accept amount parameter for BridgingInitiatedV2/BridgingFinalizedV2 - Generic adapter tests: updated for zero-amount skip behavior Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff3f76859e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Refactor deposit sender caching to resolve the EOA once from the first readable receipt on cache miss, then reuse for the entire batch. This reduces RPC calls from O(n) per deposit to O(1) per invocation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
To use Codex here, create an environment for this repo. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 27e508d5f6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
Fixes Binance CEX bridge pending withdrawal computation and adapter cleanup (split from #3073).
BinanceCEXBridge
getL2PendingWithdrawalAmountto correctly compute outstanding deposits when the Binance finalizer batches deposits from multiple L2s into a single L1 withdrawal. The old approach (total deposits minus total withdrawals per-chain) incorrectly showed zero outstanding when a withdrawal for a different L2's deposit exceeded the current chain's deposit amountgetOutstandingBinanceDeposits(from improve: Add utility functions for inventory equivalence remapping and Binance deposit matching #3108) — a net-outstanding algorithm that computes total deposits minus total withdrawals, then attributes the remaining volume to the newest deposits (since older deposits get finalized first)depositHistory(filtered by coin and non-swap) is passed directly to the matching algorithmpendingWithdrawalLookbackPeriodSecondsto 1 hour (Binance withdrawals are fast)BaseChainAdapter
getInventoryEquivalentL1TokenAddressfor L1 token resolution (replaces hardcoded pathUSD check)getOutstandingCrossChainTransfers— a transfer withtotalAmount === 0is not outstandingAdapterManager
getOutstandingCrossChainTransferstotalBalance[chainId]whenpendingAmount > 0ingetTotalPendingWithdrawalAmountTest updates
MockLineaEvents.sol:emitBridgingInitiated/emitBridgingFinalizednow acceptamountparameter instead of hardcoding 0Upstream dependencies
npai/utils-token-binance-bn) — utility functions (must merge first)Downstream PRs
npai/monitor-simplification) — Monitor simplification (depends on this + improve: Use inventory equivalence remapping in BundleDataApproxClient, InventoryClient, TokenClient #3109)Test plan
getOutstandingBinanceDeposits)🤖 Generated with Claude Code