fix(swapRebalancer): align Binance pre-deposit TTL with OFT bridge#3436
Merged
nicholaspai merged 2 commits intoMay 29, 2026
Merged
Conversation
The Binance swap adapter created its PENDING_BRIDGE_PRE_DEPOSIT order with the default 1h Redis TTL even when the underlying bridge was a long-finality OFT route (USDT0 from HyperEVM, ~12h). The order was then silently pruned by BaseAdapter._redisCleanupPendingOrders while the bridge was still in flight, so the swap context (deposit-to-Binance, market order, withdraw-to-destination, "Order has finalized" Slack message) was lost. Extract getOftPreDepositOrderTtlOverride from OftAdapter and reuse it in BinanceStablecoinSwapAdapter so both adapters keep the same TTL on the same underlying bridge. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
nicholaspai
approved these changes
May 29, 2026
Contributor
Author
|
Reviewed the approval — nicholaspai's review left no body text and no inline comments, and the PR has already been merged ( For the record, the two open boxes from the PR description are still worth tracking:
Happy to follow up on either if you want. |
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
The
BinanceStablecoinSwapAdaptercreated itsPENDING_BRIDGE_PRE_DEPOSITorder with the default 1h Redis TTL even when the underlying bridge was a long-finality OFT route (USDT0 from HyperEVM, ~12h). The order was then silently pruned byBaseAdapter._redisCleanupPendingOrderswhile the bridge was still in flight, so the entire swap context (deposit-to-Binance, market order, withdraw-to-destination, "Order has finalized" Slack message) was lost.OftAdapteralready handles this for its own pending-order entry via a 24httlOverrideininitializeRebalance. This PR extracts that decision intogetOftPreDepositOrderTtlOverrideand re-uses it inBinanceStablecoinSwapAdapterso both adapters keep the same TTL on the same underlying bridge.Repro
For order
0xa7baaec4e0bdc6effd2c833033b057e1(Slack: zbot-across-rebalancer-circle-hypercore) the swap-rebalancer logs inbots-across-3839show:+0m— order created, statusPENDING_BRIDGE_PRE_DEPOSIT+56m—"Not enough USDT balance on Binance deposit network 42161 to progress the order ... with status PENDING_BRIDGE_TO_BINANCE_NETWORK"(the OFT bridge from HyperEVM hadn't landed yet)+60m—BaseAdapter._redisCleanupPendingOrders: "Deleting expired order details for cloid ... from status set binance-stablecoin-swap:pending-bridge-pre-deposit:..."The OFT adapter's own entry kept the bridge tracked (24h TTL), but the Binance adapter's swap tag was lost when its entry was pruned, so the eventual Binance deposit was no longer recognized as belonging to a swap.
Changes
src/rebalancer/adapters/oftAdapter.ts— extractgetOftPreDepositOrderTtlOverride(rebalanceRoute)and use it insideOftAdapter.initializeRebalance(no behavior change for OFT).src/rebalancer/adapters/binance.ts— passgetOftPreDepositOrderTtlOverride(rebalanceRoute)to_redisCreateOrderon the pre-deposit-bridge path. Only USDT routes go through OFT today (_bridgeToChainswitches on token); USDC goes through CCTP, which has short finality (≤~20m) and stays on the default 1h TTL.src/rebalancer/README.md— short note on per-adapter TTL overrides and the fact that_redisUpdateOrderStatusdoes not refresh the TTL.Notes / follow-ups
_redisUpdateOrderStatus(baseAdapter.ts:153-170) does not refresh it, so the value set up front is the lifetime of the whole order across all status transitions. The 24h budget cleanly covers the ~12h OFT leg + Binance deposit + market order + Binance withdrawal._redisCleanupPendingOrdersemit awarn(or Slack alert) when it expires an order withPENDING_BRIDGE_*/PENDING_DEPOSIT/ etc., so future silent drops become visible.REBALANCER_PENDING_ORDER_TTL=86400on the swap-rebalancer pod (overrides the default for all orders).Test plan
yarn typecheckyarn lintyarn test test/PendingBridgeAdapters.ts test/BinanceAdapter.helpers.ts test/BinanceAdapter.conversions.tstest/PendingBridgeAdapters.tsortest/BinanceAdapter.*.ts— no existing test exercises_redisCreateOrder's TTL.🤖 Generated with Claude Code