Conversation
- Add MAINNET_HIP3_CONFIG to filter DEXs dynamically from allowlist - Extract DEX names from allowlist patterns (xyz:*, xyz:TSLA, xyz) - Add pending promise tracking to prevent duplicate subscriptions - Fix candle subscription cleanup when component unmounts early Impact: - 75% reduction in DEX subscriptions (8 → 2) - Prevents race condition duplicate subscriptions - Eliminates candle subscription leaks Co-Authored-By: Claude <noreply@anthropic.com>
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
These are internal optimizations and bug fixes within the Perps module that:
The SmokePerps tag is the appropriate test suite as it covers perpetuals trading functionality on Arbitrum One, including Add Funds flow, balance verification, and Perps interface interactions. These tests will validate that the subscription management changes don't break the core Perps functionality. Performance Test Selection: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #25496 +/- ##
==========================================
- Coverage 80.28% 80.26% -0.02%
==========================================
Files 4261 4261
Lines 110173 110228 +55
Branches 23475 23486 +11
==========================================
+ Hits 88452 88478 +26
- Misses 15513 15541 +28
- Partials 6208 6209 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|


Description
This PR addresses WebSocket subscription issues identified during the rate limiting incident investigation. The fixes reduce subscription message volume by ~75% and prevent subscription leaks.
Root Causes Identified
Fixes Implemented
1. Filter DEXs by Allowlist on Mainnet (HIGH PRIORITY)
Files:
hyperLiquidConfig.ts,HyperLiquidProvider.tsMAINNET_HIP3_CONFIGwithAutoDiscoverAll: falseallowlistMarketsfeature flag patternsextractDexsFromAllowlist()method that parses patterns likexyz:*,xyz:TSLA, orxyz2. Prevent Duplicate DEX Subscriptions (HIGH PRIORITY)
File:
HyperLiquidSubscriptionService.tspendingClearinghouseSubscriptionsandpendingOpenOrdersSubscriptionsMapsensureClearinghouseStateSubscription()andensureOpenOrdersSubscription()to check for pending promises3. Fix Candle Subscription Cleanup (HIGH PRIORITY)
File:
HyperLiquidClientService.tsTest Results
Changelog
CHANGELOG entry: null
Related issues
Fixes: Rate limiting incident from WebSocket over-subscription
Related: WebSocket Subscription Investigation Report
Manual testing steps
Screenshots/Recordings
Before
WebSocket subscription breakdown (full trading flow):
After
WebSocket subscription breakdown (full trading flow):
Total outgoing messages: 44
Total incoming messages: 402 (down from ~750)
Pre-merge author checklist
Pre-merge reviewer checklist
Subscription Breakdown
clearinghouseState: 2 (main + xyz)openOrders: 2 (main + xyz)userFills: 1webData3: 1allMids: 1assetCtxs: 2 (xyz only, subscribed/unsubscribed on navigation)activeAssetCtx: 2 (xyz:XYZ100, subscribed/unsubscribed on navigation)candle: 2 (1h + 15m intervals)bbo: 2 (subscribed/unsubscribed during order flow)Future Optimization Opportunity
Trading operations (order placement, cancellation, modification) currently use HTTP transport:
ExchangeClientis configured withhttpTransportto avoid 429 rate limitingInfoClientuseswsTransportfor info queries (multiplexed over single WS connection)Now that subscription volume is reduced by 75%, we could consider moving
ExchangeClientto WebSocket transport (see follow-up investigation).Note
Medium Risk
Touches core perps WebSocket subscription and DEX-discovery behavior; bugs could lead to missing market data or stale positions/orders, though changes are localized and defensive.
Overview
Reduces perps WebSocket load by filtering mainnet HIP-3 DEX discovery/subscription based on the
allowlistMarketsfeature flag, falling back to main DEX only when no HIP-3 patterns are allowlisted (via newMAINNET_HIP3_CONFIGand allowlist DEX parsing inHyperLiquidProvider).Prevents subscription churn/leaks by deduplicating concurrent
clearinghouseState/openOrderssubscriptions with pending-promise tracking inHyperLiquidSubscriptionService, and by fixing candle unsubscription when the async subscribe promise hasn’t resolved yet inHyperLiquidClientService.Written by Cursor Bugbot for commit 73e62ff. This will update automatically on new commits. Configure here.