fix(hyperliquid): bump HL_DEPOSIT_LOOKBACK default to 7 days#3438
Open
droplet-rl wants to merge 1 commit into
Open
fix(hyperliquid): bump HL_DEPOSIT_LOOKBACK default to 7 days#3438droplet-rl wants to merge 1 commit into
droplet-rl wants to merge 1 commit into
Conversation
HyperliquidExecutor.initialize() anchors dstSearchConfig.from at (startup_timestamp - lookback) and never widens it backward. Any SwapFlowInitialized event older than that boundary is permanently invisible to the running bot instance. With the previous 1h default, a routine pod restart can silently drop in-flight SwapFlows: the SwapHandler still holds the swapped-out finalToken, but no SwapFlowFinalized is ever submitted and the user's funds sit at the SwapHandler indefinitely. We hit this in production with a 15,940 USDT0 -> USDC HyperCore deposit that was skipped while a later 932 USDT0 deposit on the same SwapHandler finalised normally. Bump the default to 7 days so a pod restart inside a normal operational window cannot lose visibility of an outstanding swap. HL_DEPOSIT_LOOKBACK is still env-overridable for operators that want a shorter or longer window. A cleaner fix (Redis-backed cursor that survives restarts) is tracked separately. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Bumps the
HL_DEPOSIT_LOOKBACKdefault inHyperliquidExecutorConfigfrom 1 hour → 7 days, so the HyperliquidExecutor / HyperliquidFinalizer pod can survive a normal-cadence restart without losing visibility of in-flightSwapFlowInitializedevents.Failure mode this addresses
HyperliquidExecutor.initialize()(src/hyperliquid/HyperliquidExecutor.ts:187-194) anchors:dstSearchConfig.fromis fixed at startup and never advances backward.finalizeSwapFlowsqueries outstanding orders via that anchored window. So anySwapFlowInitializedolder than(last_startup_ts − lookback)is permanently invisible to the running instance — no retry, no catch-up scan.With the previous 1h default, any pod restart longer than ~1h after a
SwapFlowInitializedevent causes that flow to be dropped silently: the L1 limit order still fills, the SwapHandler retains the resulting finalToken, butfinalizeSwapFlowsis never called and the recipient never receives funds.Production hit
Sponsored-OFT ETH → HyperCore deposit
0xc582a7440f1b…f380(15,940 USDT0 → USDC, recipient0xD103CC…7fb2).SwapFlowInitializedfired 2026-05-29 12:14:50 UTC,quoteNonce = 0xa5133bb1…b4a3,finalToken = 0xb88339cb…630f(USDC HyperEVM), via DstOFTHandler0xeb8feE79…2284.0x6aa49d33…602enow holds 15,937.39965114 USDC on HL spot.SwapFlowFinalizedever emitted. User has 0 USDT0 on HL spot and never received the USDC.0x85cfea68…) initiated 2026-05-30 00:21 UTC, processed 2.5 h later — consistent with the bot having restarted between the two events and the older one falling outside the 1h lookback.Full investigation thread: https://app.slack.com/client/T90K0AL22/C0AQEHGS56Z/thread/C0AQEHGS56Z-1780148503.175839
Why 7 days
CHAIN_MAX_BLOCK_LOOKBACK— one-time RPC cost on startup, no steady-state overhead.HL_DEPOSIT_LOOKBACK) for operators that want a different value.Recovery for the stuck deposit
Once this lands and the
HyperliquidFinalizerpod is restarted with the new default (or withHL_DEPOSIT_LOOKBACK≥ ~96000), the bot should:SwapFlowInitializedatquoteNonce 0xa5133bb1…b4a3.limitOrderOut(≈ 15,932 USDC at current stable rates).DstOFTHandler.finalizeSwapFlows(USDC, [0xa5133bb1…b4a3], [limitOrderOut]).SwapFlowFinalized; SwapHandler L1-spotSends to the user.Pre-conditions to verify before relying on this path:
PERMISSIONED_BOT_ROLEon DstOFTHandler0xeb8feE79…2284.limitOrderOut. Edge case if USDT0/USDC drifts notably above 1 before restart.If those don't hold, recovery falls back to an admin
FUNDS_SWEEPER_ROLEsweep + manual L1 spotSend.Follow-ups (not in this PR)
SwapFlowInitialized > 30 min ago AND no matching SwapFlowFinalized.across-protocol/dapp) coherence patches for OFT/HyperCore deposits — separate work referenced in the Slack thread.Test plan
yarn typecheck— passes locally.yarn prettier --checkon the edited file — clean.yarn eslinton the edited file — no warnings.dstSearchConfig.fromextends ≥ 7 days back.HyperliquidFinalizerand watch forSwapFlowFinalized(0xa5133bb1…b4a3, 0xD103CC…7fb2, …)on DstOFTHandler0xeb8feE79…2284.0xD103CC…7fb2HL spot USDC balance increases by ≈ 15,937 USDC.🤖 Generated with Claude Code