@metamask-previews/perps-controller 1.3.0-preview-3ce0062c4 → 1.3.0-preview-dbd93752f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/PerpsController-method-action-types.cjs +3 -0
- package/dist/PerpsController-method-action-types.cjs.map +1 -0
- package/dist/PerpsController-method-action-types.d.cts +147 -0
- package/dist/PerpsController-method-action-types.d.cts.map +1 -0
- package/dist/PerpsController-method-action-types.d.mts +147 -0
- package/dist/PerpsController-method-action-types.d.mts.map +1 -0
- package/dist/PerpsController-method-action-types.mjs +2 -0
- package/dist/PerpsController-method-action-types.mjs.map +1 -0
- package/dist/PerpsController.cjs +488 -183
- package/dist/PerpsController.cjs.map +1 -1
- package/dist/PerpsController.d.cts +91 -131
- package/dist/PerpsController.d.cts.map +1 -1
- package/dist/PerpsController.d.mts +91 -131
- package/dist/PerpsController.d.mts.map +1 -1
- package/dist/PerpsController.mjs +485 -182
- package/dist/PerpsController.mjs.map +1 -1
- package/dist/constants/eventNames.cjs +26 -0
- package/dist/constants/eventNames.cjs.map +1 -1
- package/dist/constants/eventNames.d.cts +19 -0
- package/dist/constants/eventNames.d.cts.map +1 -1
- package/dist/constants/eventNames.d.mts +19 -0
- package/dist/constants/eventNames.d.mts.map +1 -1
- package/dist/constants/eventNames.mjs +26 -0
- package/dist/constants/eventNames.mjs.map +1 -1
- package/dist/constants/hyperLiquidConfig.cjs +24 -4
- package/dist/constants/hyperLiquidConfig.cjs.map +1 -1
- package/dist/constants/hyperLiquidConfig.d.cts +8 -3
- package/dist/constants/hyperLiquidConfig.d.cts.map +1 -1
- package/dist/constants/hyperLiquidConfig.d.mts +8 -3
- package/dist/constants/hyperLiquidConfig.d.mts.map +1 -1
- package/dist/constants/hyperLiquidConfig.mjs +23 -3
- package/dist/constants/hyperLiquidConfig.mjs.map +1 -1
- package/dist/constants/myxConfig.cjs +75 -51
- package/dist/constants/myxConfig.cjs.map +1 -1
- package/dist/constants/myxConfig.d.cts +58 -19
- package/dist/constants/myxConfig.d.cts.map +1 -1
- package/dist/constants/myxConfig.d.mts +58 -19
- package/dist/constants/myxConfig.d.mts.map +1 -1
- package/dist/constants/myxConfig.mjs +74 -50
- package/dist/constants/myxConfig.mjs.map +1 -1
- package/dist/constants/perpsConfig.cjs +6 -2
- package/dist/constants/perpsConfig.cjs.map +1 -1
- package/dist/constants/perpsConfig.d.cts +5 -1
- package/dist/constants/perpsConfig.d.cts.map +1 -1
- package/dist/constants/perpsConfig.d.mts +5 -1
- package/dist/constants/perpsConfig.d.mts.map +1 -1
- package/dist/constants/perpsConfig.mjs +5 -1
- package/dist/constants/perpsConfig.mjs.map +1 -1
- package/dist/index.cjs +243 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -5
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +48 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +36 -10
- package/dist/index.mjs.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.cjs +24 -0
- package/dist/providers/AggregatedPerpsProvider.cjs.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.d.cts +4 -0
- package/dist/providers/AggregatedPerpsProvider.d.cts.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.d.mts +4 -0
- package/dist/providers/AggregatedPerpsProvider.d.mts.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.mjs +24 -0
- package/dist/providers/AggregatedPerpsProvider.mjs.map +1 -1
- package/dist/providers/HyperLiquidProvider.cjs +470 -154
- package/dist/providers/HyperLiquidProvider.cjs.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.cts +11 -2
- package/dist/providers/HyperLiquidProvider.d.cts.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.mts +11 -2
- package/dist/providers/HyperLiquidProvider.d.mts.map +1 -1
- package/dist/providers/HyperLiquidProvider.mjs +471 -155
- package/dist/providers/HyperLiquidProvider.mjs.map +1 -1
- package/dist/selectors.cjs +1 -1
- package/dist/selectors.cjs.map +1 -1
- package/dist/selectors.mjs +1 -1
- package/dist/selectors.mjs.map +1 -1
- package/dist/services/AccountService.cjs +1 -1
- package/dist/services/AccountService.cjs.map +1 -1
- package/dist/services/AccountService.d.cts.map +1 -1
- package/dist/services/AccountService.d.mts.map +1 -1
- package/dist/services/AccountService.mjs +2 -2
- package/dist/services/AccountService.mjs.map +1 -1
- package/dist/services/DepositService.cjs +2 -1
- package/dist/services/DepositService.cjs.map +1 -1
- package/dist/services/DepositService.d.cts.map +1 -1
- package/dist/services/DepositService.d.mts.map +1 -1
- package/dist/services/DepositService.mjs +2 -1
- package/dist/services/DepositService.mjs.map +1 -1
- package/dist/services/EligibilityService.cjs +8 -103
- package/dist/services/EligibilityService.cjs.map +1 -1
- package/dist/services/EligibilityService.d.cts +4 -15
- package/dist/services/EligibilityService.d.cts.map +1 -1
- package/dist/services/EligibilityService.d.mts +4 -15
- package/dist/services/EligibilityService.d.mts.map +1 -1
- package/dist/services/EligibilityService.mjs +8 -103
- package/dist/services/EligibilityService.mjs.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.cjs +252 -46
- package/dist/services/HyperLiquidSubscriptionService.cjs.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.d.cts +1 -0
- package/dist/services/HyperLiquidSubscriptionService.d.cts.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.d.mts +1 -0
- package/dist/services/HyperLiquidSubscriptionService.d.mts.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.mjs +252 -46
- package/dist/services/HyperLiquidSubscriptionService.mjs.map +1 -1
- package/dist/services/MarketDataService.cjs +2 -4
- package/dist/services/MarketDataService.cjs.map +1 -1
- package/dist/services/MarketDataService.d.cts.map +1 -1
- package/dist/services/MarketDataService.d.mts.map +1 -1
- package/dist/services/MarketDataService.mjs +2 -4
- package/dist/services/MarketDataService.mjs.map +1 -1
- package/dist/services/TradingService.cjs +72 -6
- package/dist/services/TradingService.cjs.map +1 -1
- package/dist/services/TradingService.d.cts.map +1 -1
- package/dist/services/TradingService.d.mts.map +1 -1
- package/dist/services/TradingService.mjs +72 -6
- package/dist/services/TradingService.mjs.map +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +51 -3
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.mts +51 -3
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/types/messenger.cjs.map +1 -1
- package/dist/types/messenger.d.cts +2 -1
- package/dist/types/messenger.d.cts.map +1 -1
- package/dist/types/messenger.d.mts +2 -1
- package/dist/types/messenger.d.mts.map +1 -1
- package/dist/types/messenger.mjs.map +1 -1
- package/dist/types/myx-types.cjs +19 -3
- package/dist/types/myx-types.cjs.map +1 -1
- package/dist/types/myx-types.d.cts +33 -2
- package/dist/types/myx-types.d.cts.map +1 -1
- package/dist/types/myx-types.d.mts +33 -2
- package/dist/types/myx-types.d.mts.map +1 -1
- package/dist/types/myx-types.mjs +6 -2
- package/dist/types/myx-types.mjs.map +1 -1
- package/dist/types/perps-types.cjs +3 -0
- package/dist/types/perps-types.cjs.map +1 -1
- package/dist/types/perps-types.d.cts +3 -3
- package/dist/types/perps-types.d.cts.map +1 -1
- package/dist/types/perps-types.d.mts +3 -3
- package/dist/types/perps-types.d.mts.map +1 -1
- package/dist/types/perps-types.mjs +3 -0
- package/dist/types/perps-types.mjs.map +1 -1
- package/dist/utils/accountUtils.cjs.map +1 -1
- package/dist/utils/accountUtils.d.cts.map +1 -1
- package/dist/utils/accountUtils.d.mts.map +1 -1
- package/dist/utils/accountUtils.mjs.map +1 -1
- package/dist/utils/myxAdapter.cjs +360 -15
- package/dist/utils/myxAdapter.cjs.map +1 -1
- package/dist/utils/myxAdapter.d.cts +94 -7
- package/dist/utils/myxAdapter.d.cts.map +1 -1
- package/dist/utils/myxAdapter.d.mts +94 -7
- package/dist/utils/myxAdapter.d.mts.map +1 -1
- package/dist/utils/myxAdapter.mjs +351 -16
- package/dist/utils/myxAdapter.mjs.map +1 -1
- package/package.json +5 -3
|
@@ -145,6 +145,7 @@ export declare class HyperLiquidSubscriptionService {
|
|
|
145
145
|
* @returns Price string, or undefined if not cached
|
|
146
146
|
*/
|
|
147
147
|
getCachedPrice(symbol: string): string | undefined;
|
|
148
|
+
getLastAllMidsSnapshot(dex?: string): Record<string, string> | null;
|
|
148
149
|
/**
|
|
149
150
|
* Get cached fills from WebSocket userFills subscription
|
|
150
151
|
* OPTIMIZATION: Use this instead of REST userFills() to avoid rate limiting
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HyperLiquidSubscriptionService.d.cts","sourceRoot":"","sources":["../../src/services/HyperLiquidSubscriptionService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAUV,gBAAgB,EAIjB,4BAA4B;AAE7B,OAAO,KAAK,EAAE,wBAAwB,EAAE,uCAAmC;AAC3E,OAAO,KAAK,EAAE,wBAAwB,EAAE,uCAAmC;
|
|
1
|
+
{"version":3,"file":"HyperLiquidSubscriptionService.d.cts","sourceRoot":"","sources":["../../src/services/HyperLiquidSubscriptionService.ts"],"names":[],"mappings":"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"}
|
|
@@ -145,6 +145,7 @@ export declare class HyperLiquidSubscriptionService {
|
|
|
145
145
|
* @returns Price string, or undefined if not cached
|
|
146
146
|
*/
|
|
147
147
|
getCachedPrice(symbol: string): string | undefined;
|
|
148
|
+
getLastAllMidsSnapshot(dex?: string): Record<string, string> | null;
|
|
148
149
|
/**
|
|
149
150
|
* Get cached fills from WebSocket userFills subscription
|
|
150
151
|
* OPTIMIZATION: Use this instead of REST userFills() to avoid rate limiting
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HyperLiquidSubscriptionService.d.mts","sourceRoot":"","sources":["../../src/services/HyperLiquidSubscriptionService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAUV,gBAAgB,EAIjB,4BAA4B;AAE7B,OAAO,KAAK,EAAE,wBAAwB,EAAE,uCAAmC;AAC3E,OAAO,KAAK,EAAE,wBAAwB,EAAE,uCAAmC;
|
|
1
|
+
{"version":3,"file":"HyperLiquidSubscriptionService.d.mts","sourceRoot":"","sources":["../../src/services/HyperLiquidSubscriptionService.ts"],"names":[],"mappings":"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"}
|
|
@@ -9,8 +9,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _HyperLiquidSubscriptionService_instances, _HyperLiquidSubscriptionService_clientService, _HyperLiquidSubscriptionService_walletService, _HyperLiquidSubscriptionService_hip3Enabled, _HyperLiquidSubscriptionService_enabledDexs, _HyperLiquidSubscriptionService_allowlistMarkets, _HyperLiquidSubscriptionService_blocklistMarkets, _HyperLiquidSubscriptionService_discoveredDexNames, _HyperLiquidSubscriptionService_dexDiscoveryPromise, _HyperLiquidSubscriptionService_dexDiscoveryResolver, _HyperLiquidSubscriptionService_expectedDexs, _HyperLiquidSubscriptionService_initializedDexs, _HyperLiquidSubscriptionService_priceSubscribers, _HyperLiquidSubscriptionService_positionSubscribers, _HyperLiquidSubscriptionService_orderFillSubscribers, _HyperLiquidSubscriptionService_orderSubscribers, _HyperLiquidSubscriptionService_accountSubscribers, _HyperLiquidSubscriptionService_marketDataSubscribers, _HyperLiquidSubscriptionService_orderBookSubscribers, _HyperLiquidSubscriptionService_globalAllMidsSubscription, _HyperLiquidSubscriptionService_globalAllMidsPromise, _HyperLiquidSubscriptionService_globalActiveAssetSubscriptions, _HyperLiquidSubscriptionService_globalBboSubscriptions, _HyperLiquidSubscriptionService_orderFillSubscriptions, _HyperLiquidSubscriptionService_symbolSubscriberCounts, _HyperLiquidSubscriptionService_dexSubscriberCounts, _HyperLiquidSubscriptionService_webData3Subscriptions, _HyperLiquidSubscriptionService_webData3SubscriptionPromise, _HyperLiquidSubscriptionService_positionSubscriberCount, _HyperLiquidSubscriptionService_orderSubscriberCount, _HyperLiquidSubscriptionService_accountSubscriberCount, _HyperLiquidSubscriptionService_oiCapSubscriberCount, _HyperLiquidSubscriptionService_dexPositionsCache, _HyperLiquidSubscriptionService_dexOrdersCache, _HyperLiquidSubscriptionService_dexAccountCache, _HyperLiquidSubscriptionService_cachedPositions, _HyperLiquidSubscriptionService_cachedOrders, _HyperLiquidSubscriptionService_cachedAccount, _HyperLiquidSubscriptionService_ordersCacheInitialized, _HyperLiquidSubscriptionService_positionsCacheInitialized, _HyperLiquidSubscriptionService_oiCapSubscribers, _HyperLiquidSubscriptionService_cachedOICaps, _HyperLiquidSubscriptionService_cachedOICapsHash, _HyperLiquidSubscriptionService_oiCapsCacheInitialized, _HyperLiquidSubscriptionService_cachedPriceData, _HyperLiquidSubscriptionService_cachedFills, _HyperLiquidSubscriptionService_fillsCacheInitialized, _HyperLiquidSubscriptionService_assetCtxsSubscriptions, _HyperLiquidSubscriptionService_dexAssetCtxsCache, _HyperLiquidSubscriptionService_assetCtxsSubscriptionPromises, _HyperLiquidSubscriptionService_clearinghouseStateSubscriptions, _HyperLiquidSubscriptionService_openOrdersSubscriptions, _HyperLiquidSubscriptionService_pendingClearinghouseSubscriptions, _HyperLiquidSubscriptionService_pendingOpenOrdersSubscriptions, _HyperLiquidSubscriptionService_dexMetaCache, _HyperLiquidSubscriptionService_orderBookCache, _HyperLiquidSubscriptionService_marketDataCache, _HyperLiquidSubscriptionService_isClearing, _HyperLiquidSubscriptionService_deps, _HyperLiquidSubscriptionService_logErrorUnlessClearing, _HyperLiquidSubscriptionService_getErrorContext, _HyperLiquidSubscriptionService_isDexEnabled, _HyperLiquidSubscriptionService_waitForDexDiscovery, _HyperLiquidSubscriptionService_hashPositions, _HyperLiquidSubscriptionService_hashOrders, _HyperLiquidSubscriptionService_hashAccountState, _HyperLiquidSubscriptionService_cachedPositionsHash, _HyperLiquidSubscriptionService_cachedOrdersHash, _HyperLiquidSubscriptionService_cachedAccountHash, _HyperLiquidSubscriptionService_extractTPSLFromOrders, _HyperLiquidSubscriptionService_mergeTPSLIntoPositions, _HyperLiquidSubscriptionService_aggregateAccountStates, _HyperLiquidSubscriptionService_ensureSharedWebData3Subscription, _HyperLiquidSubscriptionService_createUserDataSubscription, _HyperLiquidSubscriptionService_ensureClearinghouseStateSubscription, _HyperLiquidSubscriptionService_createClearinghouseSubscription, _HyperLiquidSubscriptionService_ensureOpenOrdersSubscription, _HyperLiquidSubscriptionService_createOpenOrdersSubscription, _HyperLiquidSubscriptionService_aggregateAndNotifySubscribers, _HyperLiquidSubscriptionService_cleanupSharedWebData3ISubscription, _HyperLiquidSubscriptionService_ensureOrderFillISubscription, _HyperLiquidSubscriptionService_createSubscription, _HyperLiquidSubscriptionService_createPriceUpdate, _HyperLiquidSubscriptionService_ensureGlobalAllMidsSubscription, _HyperLiquidSubscriptionService_ensureActiveAssetSubscription, _HyperLiquidSubscriptionService_cleanupActiveAssetSubscription, _HyperLiquidSubscriptionService_ensureAssetCtxsSubscription, _HyperLiquidSubscriptionService_createAssetCtxsSubscription, _HyperLiquidSubscriptionService_cleanupAssetCtxsSubscription, _HyperLiquidSubscriptionService_ensureBboSubscription, _HyperLiquidSubscriptionService_cleanupBboSubscription, _HyperLiquidSubscriptionService_processOrderBookData, _HyperLiquidSubscriptionService_notifyAllPriceSubscribers;
|
|
12
|
+
var _HyperLiquidSubscriptionService_instances, _HyperLiquidSubscriptionService_clientService, _HyperLiquidSubscriptionService_walletService, _HyperLiquidSubscriptionService_hip3Enabled, _HyperLiquidSubscriptionService_enabledDexs, _HyperLiquidSubscriptionService_allowlistMarkets, _HyperLiquidSubscriptionService_blocklistMarkets, _HyperLiquidSubscriptionService_discoveredDexNames, _HyperLiquidSubscriptionService_dexDiscoveryPromise, _HyperLiquidSubscriptionService_dexDiscoveryResolver, _HyperLiquidSubscriptionService_expectedDexs, _HyperLiquidSubscriptionService_initializedDexs, _HyperLiquidSubscriptionService_priceSubscribers, _HyperLiquidSubscriptionService_positionSubscribers, _HyperLiquidSubscriptionService_orderFillSubscribers, _HyperLiquidSubscriptionService_orderSubscribers, _HyperLiquidSubscriptionService_accountSubscribers, _HyperLiquidSubscriptionService_marketDataSubscribers, _HyperLiquidSubscriptionService_orderBookSubscribers, _HyperLiquidSubscriptionService_globalAllMidsSubscription, _HyperLiquidSubscriptionService_globalAllMidsPromise, _HyperLiquidSubscriptionService_globalActiveAssetSubscriptions, _HyperLiquidSubscriptionService_globalBboSubscriptions, _HyperLiquidSubscriptionService_orderFillSubscriptions, _HyperLiquidSubscriptionService_symbolSubscriberCounts, _HyperLiquidSubscriptionService_dexSubscriberCounts, _HyperLiquidSubscriptionService_webData3Subscriptions, _HyperLiquidSubscriptionService_webData3SubscriptionPromise, _HyperLiquidSubscriptionService_positionSubscriberCount, _HyperLiquidSubscriptionService_orderSubscriberCount, _HyperLiquidSubscriptionService_accountSubscriberCount, _HyperLiquidSubscriptionService_oiCapSubscriberCount, _HyperLiquidSubscriptionService_dexPositionsCache, _HyperLiquidSubscriptionService_dexOrdersCache, _HyperLiquidSubscriptionService_dexAccountCache, _HyperLiquidSubscriptionService_cachedPositions, _HyperLiquidSubscriptionService_cachedOrders, _HyperLiquidSubscriptionService_cachedAccount, _HyperLiquidSubscriptionService_ordersCacheInitialized, _HyperLiquidSubscriptionService_positionsCacheInitialized, _HyperLiquidSubscriptionService_oiCapSubscribers, _HyperLiquidSubscriptionService_cachedOICaps, _HyperLiquidSubscriptionService_cachedOICapsHash, _HyperLiquidSubscriptionService_oiCapsCacheInitialized, _HyperLiquidSubscriptionService_cachedPriceData, _HyperLiquidSubscriptionService_allMidsSnapshots, _HyperLiquidSubscriptionService_cachedFills, _HyperLiquidSubscriptionService_fillsCacheInitialized, _HyperLiquidSubscriptionService_assetCtxsSubscriptions, _HyperLiquidSubscriptionService_dexAssetCtxsCache, _HyperLiquidSubscriptionService_assetCtxsSubscriptionPromises, _HyperLiquidSubscriptionService_dexAllMidsSubscriptions, _HyperLiquidSubscriptionService_dexAllMidsSubscriptionPromises, _HyperLiquidSubscriptionService_clearinghouseStateSubscriptions, _HyperLiquidSubscriptionService_openOrdersSubscriptions, _HyperLiquidSubscriptionService_pendingClearinghouseSubscriptions, _HyperLiquidSubscriptionService_pendingOpenOrdersSubscriptions, _HyperLiquidSubscriptionService_dexMetaCache, _HyperLiquidSubscriptionService_orderBookCache, _HyperLiquidSubscriptionService_marketDataCache, _HyperLiquidSubscriptionService_isClearing, _HyperLiquidSubscriptionService_restoreRetryTimeouts, _HyperLiquidSubscriptionService_deps, _HyperLiquidSubscriptionService_logErrorUnlessClearing, _HyperLiquidSubscriptionService_isTransientAssetCtxsError, _HyperLiquidSubscriptionService_scheduleRestoreRetry, _HyperLiquidSubscriptionService_getErrorContext, _HyperLiquidSubscriptionService_isDexEnabled, _HyperLiquidSubscriptionService_waitForDexDiscovery, _HyperLiquidSubscriptionService_hashPositions, _HyperLiquidSubscriptionService_hashOrders, _HyperLiquidSubscriptionService_hashAccountState, _HyperLiquidSubscriptionService_cachedPositionsHash, _HyperLiquidSubscriptionService_cachedOrdersHash, _HyperLiquidSubscriptionService_cachedAccountHash, _HyperLiquidSubscriptionService_extractTPSLFromOrders, _HyperLiquidSubscriptionService_mergeTPSLIntoPositions, _HyperLiquidSubscriptionService_aggregateAccountStates, _HyperLiquidSubscriptionService_ensureSharedWebData3Subscription, _HyperLiquidSubscriptionService_createUserDataSubscription, _HyperLiquidSubscriptionService_ensureClearinghouseStateSubscription, _HyperLiquidSubscriptionService_createClearinghouseSubscription, _HyperLiquidSubscriptionService_ensureOpenOrdersSubscription, _HyperLiquidSubscriptionService_createOpenOrdersSubscription, _HyperLiquidSubscriptionService_aggregateAndNotifySubscribers, _HyperLiquidSubscriptionService_cleanupSharedWebData3ISubscription, _HyperLiquidSubscriptionService_ensureOrderFillISubscription, _HyperLiquidSubscriptionService_createSubscription, _HyperLiquidSubscriptionService_createPriceUpdate, _HyperLiquidSubscriptionService_ensureGlobalAllMidsSubscription, _HyperLiquidSubscriptionService_ensureActiveAssetSubscription, _HyperLiquidSubscriptionService_cleanupActiveAssetSubscription, _HyperLiquidSubscriptionService_ensureAssetCtxsSubscription, _HyperLiquidSubscriptionService_ensureDexAllMidsSubscription, _HyperLiquidSubscriptionService_createDexAllMidsSubscription, _HyperLiquidSubscriptionService_createAssetCtxsSubscription, _HyperLiquidSubscriptionService_cleanupAssetCtxsSubscription, _HyperLiquidSubscriptionService_ensureBboSubscription, _HyperLiquidSubscriptionService_cleanupBboSubscription, _HyperLiquidSubscriptionService_processOrderBookData, _HyperLiquidSubscriptionService_notifyAllPriceSubscribers;
|
|
13
13
|
import { TP_SL_CONFIG, PERPS_CONSTANTS } from "../constants/perpsConfig.mjs";
|
|
14
|
+
import { WebSocketConnectionState } from "../types/index.mjs";
|
|
14
15
|
import { calculateWeightedReturnOnEquity } from "../utils/accountUtils.mjs";
|
|
15
16
|
import { ensureError } from "../utils/errorUtils.mjs";
|
|
16
17
|
import { adaptPositionFromSDK, adaptOrderFromSDK, adaptAccountStateFromSDK, parseAssetName } from "../utils/hyperLiquidAdapter.mjs";
|
|
@@ -82,6 +83,8 @@ export class HyperLiquidSubscriptionService {
|
|
|
82
83
|
_HyperLiquidSubscriptionService_oiCapsCacheInitialized.set(this, false);
|
|
83
84
|
// Global price data cache
|
|
84
85
|
_HyperLiquidSubscriptionService_cachedPriceData.set(this, null);
|
|
86
|
+
// Raw allMids WS snapshots keyed by DEX ('' for main DEX)
|
|
87
|
+
_HyperLiquidSubscriptionService_allMidsSnapshots.set(this, new Map());
|
|
85
88
|
// Fills cache for cache-first pattern (similar to price caching)
|
|
86
89
|
_HyperLiquidSubscriptionService_cachedFills.set(this, null);
|
|
87
90
|
_HyperLiquidSubscriptionService_fillsCacheInitialized.set(this, false);
|
|
@@ -89,6 +92,8 @@ export class HyperLiquidSubscriptionService {
|
|
|
89
92
|
_HyperLiquidSubscriptionService_assetCtxsSubscriptions.set(this, new Map()); // Key: dex name ('' for main)
|
|
90
93
|
_HyperLiquidSubscriptionService_dexAssetCtxsCache.set(this, new Map()); // Per-DEX asset contexts
|
|
91
94
|
_HyperLiquidSubscriptionService_assetCtxsSubscriptionPromises.set(this, new Map()); // Track in-progress subscriptions
|
|
95
|
+
_HyperLiquidSubscriptionService_dexAllMidsSubscriptions.set(this, new Map());
|
|
96
|
+
_HyperLiquidSubscriptionService_dexAllMidsSubscriptionPromises.set(this, new Map());
|
|
92
97
|
_HyperLiquidSubscriptionService_clearinghouseStateSubscriptions.set(this, new Map()); // Key: dex name ('' for main)
|
|
93
98
|
_HyperLiquidSubscriptionService_openOrdersSubscriptions.set(this, new Map()); // Key: dex name ('' for main)
|
|
94
99
|
// Pending subscription promises to prevent race conditions
|
|
@@ -106,6 +111,7 @@ export class HyperLiquidSubscriptionService {
|
|
|
106
111
|
// Flag to suppress error logging during intentional disconnect
|
|
107
112
|
// Set in clearAll() and never reset (service instance is discarded after disconnect)
|
|
108
113
|
_HyperLiquidSubscriptionService_isClearing.set(this, false);
|
|
114
|
+
_HyperLiquidSubscriptionService_restoreRetryTimeouts.set(this, new Map());
|
|
109
115
|
// Platform dependencies for logging
|
|
110
116
|
_HyperLiquidSubscriptionService_deps.set(this, void 0);
|
|
111
117
|
// Cache hashes to avoid recomputation
|
|
@@ -270,20 +276,30 @@ export class HyperLiquidSubscriptionService {
|
|
|
270
276
|
}
|
|
271
277
|
// Ensure global subscriptions are established
|
|
272
278
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_ensureGlobalAllMidsSubscription).call(this);
|
|
273
|
-
//
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
279
|
+
// Extract unique DEXs from requested symbols
|
|
280
|
+
const dexsNeeded = new Set();
|
|
281
|
+
symbols.forEach((symbol) => {
|
|
282
|
+
const { dex } = parseAssetName(symbol);
|
|
283
|
+
dexsNeeded.add(dex);
|
|
284
|
+
});
|
|
285
|
+
// Always ensure assetCtxs subscriptions (1 per DEX, lightweight).
|
|
286
|
+
// Provides prevDayPx for percentChange24h even without includeMarketData
|
|
287
|
+
// (e.g., prewarm after reconnection). Uses incrementRefCount: false when
|
|
288
|
+
// not explicitly requested so lifecycle is managed by component subscriptions.
|
|
289
|
+
dexsNeeded.forEach((dex) => {
|
|
290
|
+
const dexName = dex ?? '';
|
|
291
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_ensureAssetCtxsSubscription).call(this, dexName, {
|
|
292
|
+
incrementRefCount: includeMarketData,
|
|
293
|
+
}).catch((error) => {
|
|
294
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.subscribeToPrices'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'subscribeToPrices.ensureAssetCtxsSubscription', { dex: dexName }));
|
|
281
295
|
});
|
|
282
|
-
|
|
296
|
+
});
|
|
297
|
+
// dexAllMids and activeAssetCtx only when market data explicitly requested
|
|
298
|
+
if (includeMarketData) {
|
|
283
299
|
dexsNeeded.forEach((dex) => {
|
|
284
300
|
const dexName = dex ?? '';
|
|
285
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m",
|
|
286
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.subscribeToPrices'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'subscribeToPrices.
|
|
301
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_ensureDexAllMidsSubscription).call(this, dexName).catch((error) => {
|
|
302
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.subscribeToPrices'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'subscribeToPrices.ensureDexAllMidsSubscription', { dex: dexName }));
|
|
287
303
|
});
|
|
288
304
|
});
|
|
289
305
|
}
|
|
@@ -321,13 +337,6 @@ export class HyperLiquidSubscriptionService {
|
|
|
321
337
|
});
|
|
322
338
|
// Cleanup DEX-level assetCtxs subscriptions
|
|
323
339
|
if (includeMarketData) {
|
|
324
|
-
// Extract unique DEXs from requested symbols
|
|
325
|
-
const dexsNeeded = new Set();
|
|
326
|
-
symbols.forEach((symbol) => {
|
|
327
|
-
const { dex } = parseAssetName(symbol);
|
|
328
|
-
dexsNeeded.add(dex);
|
|
329
|
-
});
|
|
330
|
-
// Cleanup assetCtxs subscription for each DEX
|
|
331
340
|
dexsNeeded.forEach((dex) => {
|
|
332
341
|
const dexName = dex ?? '';
|
|
333
342
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_cleanupAssetCtxsSubscription).call(this, dexName);
|
|
@@ -533,6 +542,14 @@ export class HyperLiquidSubscriptionService {
|
|
|
533
542
|
getCachedPrice(symbol) {
|
|
534
543
|
return __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedPriceData, "f")?.get(symbol)?.price;
|
|
535
544
|
}
|
|
545
|
+
getLastAllMidsSnapshot(dex) {
|
|
546
|
+
const dexKey = dex ?? '';
|
|
547
|
+
const snapshot = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_allMidsSnapshots, "f").get(dexKey);
|
|
548
|
+
if (!snapshot) {
|
|
549
|
+
return null;
|
|
550
|
+
}
|
|
551
|
+
return { ...snapshot };
|
|
552
|
+
}
|
|
536
553
|
/**
|
|
537
554
|
* Get cached fills from WebSocket userFills subscription
|
|
538
555
|
* OPTIMIZATION: Use this instead of REST userFills() to avoid rate limiting
|
|
@@ -705,8 +722,8 @@ export class HyperLiquidSubscriptionService {
|
|
|
705
722
|
// Clear existing subscriptions (they're dead after reconnection)
|
|
706
723
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_assetCtxsSubscriptions, "f").clear();
|
|
707
724
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_assetCtxsSubscriptionPromises, "f").clear();
|
|
708
|
-
|
|
709
|
-
__classPrivateFieldGet(this,
|
|
725
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAllMidsSubscriptions, "f").clear();
|
|
726
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAllMidsSubscriptionPromises, "f").clear();
|
|
710
727
|
// Re-establish subscriptions for all DEXs with market data subscribers
|
|
711
728
|
const dexsNeeded = new Set();
|
|
712
729
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_marketDataSubscribers, "f").forEach((_subscribers, symbol) => {
|
|
@@ -723,10 +740,46 @@ export class HyperLiquidSubscriptionService {
|
|
|
723
740
|
if (hasMainDexSubscribers) {
|
|
724
741
|
dexsNeeded.add('');
|
|
725
742
|
}
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
743
|
+
const marketDataRestoreOperations = Array.from(dexsNeeded).flatMap((dex) => {
|
|
744
|
+
const operations = [
|
|
745
|
+
{
|
|
746
|
+
dex,
|
|
747
|
+
kind: 'assetCtxs',
|
|
748
|
+
promise: __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_ensureAssetCtxsSubscription).call(this, dex, {
|
|
749
|
+
incrementRefCount: false,
|
|
750
|
+
}),
|
|
751
|
+
},
|
|
752
|
+
];
|
|
753
|
+
if (dex) {
|
|
754
|
+
operations.push({
|
|
755
|
+
dex,
|
|
756
|
+
kind: 'allMids',
|
|
757
|
+
promise: __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_ensureDexAllMidsSubscription).call(this, dex),
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
return operations;
|
|
761
|
+
});
|
|
762
|
+
const marketDataRestoreResults = await Promise.allSettled(marketDataRestoreOperations.map(({ promise }) => promise));
|
|
763
|
+
const marketDataRestoreFailures = marketDataRestoreResults.flatMap((result, index) => {
|
|
764
|
+
if (result.status === 'fulfilled') {
|
|
765
|
+
return [];
|
|
766
|
+
}
|
|
767
|
+
const operation = marketDataRestoreOperations[index];
|
|
768
|
+
return [
|
|
769
|
+
{
|
|
770
|
+
...operation,
|
|
771
|
+
error: ensureError(result.reason, 'HyperLiquidSubscriptionService.restoreSubscriptions'),
|
|
772
|
+
},
|
|
773
|
+
];
|
|
774
|
+
});
|
|
775
|
+
if (marketDataRestoreFailures.length > 0) {
|
|
776
|
+
marketDataRestoreFailures.forEach(({ dex, kind }) => {
|
|
777
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_scheduleRestoreRetry).call(this, dex, kind);
|
|
778
|
+
});
|
|
779
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, new Error(`Failed to restore ${marketDataRestoreFailures.length} market data subscriptions`), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'restoreSubscriptions.marketData', {
|
|
780
|
+
failures: marketDataRestoreFailures.map(({ dex, kind, error }) => `${kind}:${dex || 'main'}:${error.message}`),
|
|
781
|
+
}));
|
|
782
|
+
}
|
|
730
783
|
}
|
|
731
784
|
}
|
|
732
785
|
/**
|
|
@@ -754,6 +807,7 @@ export class HyperLiquidSubscriptionService {
|
|
|
754
807
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_orderFillSubscriptions, "f").clear();
|
|
755
808
|
// Clear cached data
|
|
756
809
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedPriceData, null, "f");
|
|
810
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_allMidsSnapshots, "f").clear();
|
|
757
811
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedPositions, null, "f");
|
|
758
812
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedOrders, null, "f");
|
|
759
813
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedAccount, null, "f");
|
|
@@ -784,6 +838,7 @@ export class HyperLiquidSubscriptionService {
|
|
|
784
838
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAssetCtxsCache, "f").clear();
|
|
785
839
|
// Clear subscription references (actual cleanup handled by client service)
|
|
786
840
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_globalAllMidsSubscription, undefined, "f");
|
|
841
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_globalAllMidsPromise, undefined, "f");
|
|
787
842
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_globalActiveAssetSubscriptions, "f").clear();
|
|
788
843
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_globalBboSubscriptions, "f").clear();
|
|
789
844
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_webData3Subscriptions, "f").clear();
|
|
@@ -791,6 +846,13 @@ export class HyperLiquidSubscriptionService {
|
|
|
791
846
|
// HIP-3: Clear assetCtxs subscriptions (clearinghouseState no longer needed with webData3)
|
|
792
847
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_assetCtxsSubscriptions, "f").clear();
|
|
793
848
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_assetCtxsSubscriptionPromises, "f").clear();
|
|
849
|
+
// HIP-3: Clear per-DEX allMids subscriptions
|
|
850
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAllMidsSubscriptions, "f").clear();
|
|
851
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAllMidsSubscriptionPromises, "f").clear();
|
|
852
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_restoreRetryTimeouts, "f").forEach((timeoutId) => {
|
|
853
|
+
clearTimeout(timeoutId);
|
|
854
|
+
});
|
|
855
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_restoreRetryTimeouts, "f").clear();
|
|
794
856
|
// Cleanup individual subscriptions (clearinghouseState + openOrders)
|
|
795
857
|
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_clearinghouseStateSubscriptions, "f").size > 0) {
|
|
796
858
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_clearinghouseStateSubscriptions, "f").forEach((subscription, dexName) => {
|
|
@@ -817,11 +879,49 @@ export class HyperLiquidSubscriptionService {
|
|
|
817
879
|
});
|
|
818
880
|
}
|
|
819
881
|
}
|
|
820
|
-
_HyperLiquidSubscriptionService_clientService = new WeakMap(), _HyperLiquidSubscriptionService_walletService = new WeakMap(), _HyperLiquidSubscriptionService_hip3Enabled = new WeakMap(), _HyperLiquidSubscriptionService_enabledDexs = new WeakMap(), _HyperLiquidSubscriptionService_allowlistMarkets = new WeakMap(), _HyperLiquidSubscriptionService_blocklistMarkets = new WeakMap(), _HyperLiquidSubscriptionService_discoveredDexNames = new WeakMap(), _HyperLiquidSubscriptionService_dexDiscoveryPromise = new WeakMap(), _HyperLiquidSubscriptionService_dexDiscoveryResolver = new WeakMap(), _HyperLiquidSubscriptionService_expectedDexs = new WeakMap(), _HyperLiquidSubscriptionService_initializedDexs = new WeakMap(), _HyperLiquidSubscriptionService_priceSubscribers = new WeakMap(), _HyperLiquidSubscriptionService_positionSubscribers = new WeakMap(), _HyperLiquidSubscriptionService_orderFillSubscribers = new WeakMap(), _HyperLiquidSubscriptionService_orderSubscribers = new WeakMap(), _HyperLiquidSubscriptionService_accountSubscribers = new WeakMap(), _HyperLiquidSubscriptionService_marketDataSubscribers = new WeakMap(), _HyperLiquidSubscriptionService_orderBookSubscribers = new WeakMap(), _HyperLiquidSubscriptionService_globalAllMidsSubscription = new WeakMap(), _HyperLiquidSubscriptionService_globalAllMidsPromise = new WeakMap(), _HyperLiquidSubscriptionService_globalActiveAssetSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_globalBboSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_orderFillSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_symbolSubscriberCounts = new WeakMap(), _HyperLiquidSubscriptionService_dexSubscriberCounts = new WeakMap(), _HyperLiquidSubscriptionService_webData3Subscriptions = new WeakMap(), _HyperLiquidSubscriptionService_webData3SubscriptionPromise = new WeakMap(), _HyperLiquidSubscriptionService_positionSubscriberCount = new WeakMap(), _HyperLiquidSubscriptionService_orderSubscriberCount = new WeakMap(), _HyperLiquidSubscriptionService_accountSubscriberCount = new WeakMap(), _HyperLiquidSubscriptionService_oiCapSubscriberCount = new WeakMap(), _HyperLiquidSubscriptionService_dexPositionsCache = new WeakMap(), _HyperLiquidSubscriptionService_dexOrdersCache = new WeakMap(), _HyperLiquidSubscriptionService_dexAccountCache = new WeakMap(), _HyperLiquidSubscriptionService_cachedPositions = new WeakMap(), _HyperLiquidSubscriptionService_cachedOrders = new WeakMap(), _HyperLiquidSubscriptionService_cachedAccount = new WeakMap(), _HyperLiquidSubscriptionService_ordersCacheInitialized = new WeakMap(), _HyperLiquidSubscriptionService_positionsCacheInitialized = new WeakMap(), _HyperLiquidSubscriptionService_oiCapSubscribers = new WeakMap(), _HyperLiquidSubscriptionService_cachedOICaps = new WeakMap(), _HyperLiquidSubscriptionService_cachedOICapsHash = new WeakMap(), _HyperLiquidSubscriptionService_oiCapsCacheInitialized = new WeakMap(), _HyperLiquidSubscriptionService_cachedPriceData = new WeakMap(), _HyperLiquidSubscriptionService_cachedFills = new WeakMap(), _HyperLiquidSubscriptionService_fillsCacheInitialized = new WeakMap(), _HyperLiquidSubscriptionService_assetCtxsSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_dexAssetCtxsCache = new WeakMap(), _HyperLiquidSubscriptionService_assetCtxsSubscriptionPromises = new WeakMap(), _HyperLiquidSubscriptionService_clearinghouseStateSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_openOrdersSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_pendingClearinghouseSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_pendingOpenOrdersSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_dexMetaCache = new WeakMap(), _HyperLiquidSubscriptionService_orderBookCache = new WeakMap(), _HyperLiquidSubscriptionService_marketDataCache = new WeakMap(), _HyperLiquidSubscriptionService_isClearing = new WeakMap(), _HyperLiquidSubscriptionService_deps = new WeakMap(), _HyperLiquidSubscriptionService_cachedPositionsHash = new WeakMap(), _HyperLiquidSubscriptionService_cachedOrdersHash = new WeakMap(), _HyperLiquidSubscriptionService_cachedAccountHash = new WeakMap(), _HyperLiquidSubscriptionService_instances = new WeakSet(), _HyperLiquidSubscriptionService_logErrorUnlessClearing = function _HyperLiquidSubscriptionService_logErrorUnlessClearing(error, context) {
|
|
882
|
+
_HyperLiquidSubscriptionService_clientService = new WeakMap(), _HyperLiquidSubscriptionService_walletService = new WeakMap(), _HyperLiquidSubscriptionService_hip3Enabled = new WeakMap(), _HyperLiquidSubscriptionService_enabledDexs = new WeakMap(), _HyperLiquidSubscriptionService_allowlistMarkets = new WeakMap(), _HyperLiquidSubscriptionService_blocklistMarkets = new WeakMap(), _HyperLiquidSubscriptionService_discoveredDexNames = new WeakMap(), _HyperLiquidSubscriptionService_dexDiscoveryPromise = new WeakMap(), _HyperLiquidSubscriptionService_dexDiscoveryResolver = new WeakMap(), _HyperLiquidSubscriptionService_expectedDexs = new WeakMap(), _HyperLiquidSubscriptionService_initializedDexs = new WeakMap(), _HyperLiquidSubscriptionService_priceSubscribers = new WeakMap(), _HyperLiquidSubscriptionService_positionSubscribers = new WeakMap(), _HyperLiquidSubscriptionService_orderFillSubscribers = new WeakMap(), _HyperLiquidSubscriptionService_orderSubscribers = new WeakMap(), _HyperLiquidSubscriptionService_accountSubscribers = new WeakMap(), _HyperLiquidSubscriptionService_marketDataSubscribers = new WeakMap(), _HyperLiquidSubscriptionService_orderBookSubscribers = new WeakMap(), _HyperLiquidSubscriptionService_globalAllMidsSubscription = new WeakMap(), _HyperLiquidSubscriptionService_globalAllMidsPromise = new WeakMap(), _HyperLiquidSubscriptionService_globalActiveAssetSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_globalBboSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_orderFillSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_symbolSubscriberCounts = new WeakMap(), _HyperLiquidSubscriptionService_dexSubscriberCounts = new WeakMap(), _HyperLiquidSubscriptionService_webData3Subscriptions = new WeakMap(), _HyperLiquidSubscriptionService_webData3SubscriptionPromise = new WeakMap(), _HyperLiquidSubscriptionService_positionSubscriberCount = new WeakMap(), _HyperLiquidSubscriptionService_orderSubscriberCount = new WeakMap(), _HyperLiquidSubscriptionService_accountSubscriberCount = new WeakMap(), _HyperLiquidSubscriptionService_oiCapSubscriberCount = new WeakMap(), _HyperLiquidSubscriptionService_dexPositionsCache = new WeakMap(), _HyperLiquidSubscriptionService_dexOrdersCache = new WeakMap(), _HyperLiquidSubscriptionService_dexAccountCache = new WeakMap(), _HyperLiquidSubscriptionService_cachedPositions = new WeakMap(), _HyperLiquidSubscriptionService_cachedOrders = new WeakMap(), _HyperLiquidSubscriptionService_cachedAccount = new WeakMap(), _HyperLiquidSubscriptionService_ordersCacheInitialized = new WeakMap(), _HyperLiquidSubscriptionService_positionsCacheInitialized = new WeakMap(), _HyperLiquidSubscriptionService_oiCapSubscribers = new WeakMap(), _HyperLiquidSubscriptionService_cachedOICaps = new WeakMap(), _HyperLiquidSubscriptionService_cachedOICapsHash = new WeakMap(), _HyperLiquidSubscriptionService_oiCapsCacheInitialized = new WeakMap(), _HyperLiquidSubscriptionService_cachedPriceData = new WeakMap(), _HyperLiquidSubscriptionService_allMidsSnapshots = new WeakMap(), _HyperLiquidSubscriptionService_cachedFills = new WeakMap(), _HyperLiquidSubscriptionService_fillsCacheInitialized = new WeakMap(), _HyperLiquidSubscriptionService_assetCtxsSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_dexAssetCtxsCache = new WeakMap(), _HyperLiquidSubscriptionService_assetCtxsSubscriptionPromises = new WeakMap(), _HyperLiquidSubscriptionService_dexAllMidsSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_dexAllMidsSubscriptionPromises = new WeakMap(), _HyperLiquidSubscriptionService_clearinghouseStateSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_openOrdersSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_pendingClearinghouseSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_pendingOpenOrdersSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_dexMetaCache = new WeakMap(), _HyperLiquidSubscriptionService_orderBookCache = new WeakMap(), _HyperLiquidSubscriptionService_marketDataCache = new WeakMap(), _HyperLiquidSubscriptionService_isClearing = new WeakMap(), _HyperLiquidSubscriptionService_restoreRetryTimeouts = new WeakMap(), _HyperLiquidSubscriptionService_deps = new WeakMap(), _HyperLiquidSubscriptionService_cachedPositionsHash = new WeakMap(), _HyperLiquidSubscriptionService_cachedOrdersHash = new WeakMap(), _HyperLiquidSubscriptionService_cachedAccountHash = new WeakMap(), _HyperLiquidSubscriptionService_instances = new WeakSet(), _HyperLiquidSubscriptionService_logErrorUnlessClearing = function _HyperLiquidSubscriptionService_logErrorUnlessClearing(error, context) {
|
|
821
883
|
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_isClearing, "f")) {
|
|
822
884
|
return;
|
|
823
885
|
}
|
|
824
886
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_deps, "f").logger.error(error, context);
|
|
887
|
+
}, _HyperLiquidSubscriptionService_isTransientAssetCtxsError = function _HyperLiquidSubscriptionService_isTransientAssetCtxsError(error) {
|
|
888
|
+
const ensuredError = ensureError(error, 'HyperLiquidSubscriptionService.createAssetCtxsSubscription');
|
|
889
|
+
const connectionState = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_clientService, "f").getConnectionState?.();
|
|
890
|
+
const messageParts = [
|
|
891
|
+
ensuredError.message,
|
|
892
|
+
error instanceof Error ? error.name : '',
|
|
893
|
+
typeof error === 'string' ? error : '',
|
|
894
|
+
String(error),
|
|
895
|
+
]
|
|
896
|
+
.join(' ')
|
|
897
|
+
.toLowerCase();
|
|
898
|
+
const isReconnectChurn = connectionState === WebSocketConnectionState.Connecting ||
|
|
899
|
+
connectionState === WebSocketConnectionState.Disconnected;
|
|
900
|
+
return (messageParts.includes('websocketrequesterror') ||
|
|
901
|
+
messageParts.includes('unknown error while making a websocket request') ||
|
|
902
|
+
(isReconnectChurn &&
|
|
903
|
+
(messageParts.includes('unknown error (no details provided)') ||
|
|
904
|
+
messageParts.includes('undefined'))));
|
|
905
|
+
}, _HyperLiquidSubscriptionService_scheduleRestoreRetry = function _HyperLiquidSubscriptionService_scheduleRestoreRetry(dex, kind) {
|
|
906
|
+
const retryKey = `${kind}:${dex}`;
|
|
907
|
+
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_isClearing, "f") || __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_restoreRetryTimeouts, "f").has(retryKey)) {
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
const timeoutId = setTimeout(() => {
|
|
911
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_restoreRetryTimeouts, "f").delete(retryKey);
|
|
912
|
+
const retryPromise = kind === 'assetCtxs'
|
|
913
|
+
? __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_ensureAssetCtxsSubscription).call(this, dex, {
|
|
914
|
+
incrementRefCount: false,
|
|
915
|
+
})
|
|
916
|
+
: __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_ensureDexAllMidsSubscription).call(this, dex);
|
|
917
|
+
retryPromise.catch((error) => {
|
|
918
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.restoreSubscriptions.retry'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'restoreSubscriptions.retry', {
|
|
919
|
+
dex,
|
|
920
|
+
kind,
|
|
921
|
+
}));
|
|
922
|
+
});
|
|
923
|
+
}, 1000);
|
|
924
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_restoreRetryTimeouts, "f").set(retryKey, timeoutId);
|
|
825
925
|
}, _HyperLiquidSubscriptionService_getErrorContext = function _HyperLiquidSubscriptionService_getErrorContext(method, extra) {
|
|
826
926
|
return {
|
|
827
927
|
tags: {
|
|
@@ -1770,6 +1870,8 @@ async function _HyperLiquidSubscriptionService_ensureOrderFillISubscription(acco
|
|
|
1770
1870
|
wsMetrics.lastMessageTime = Date.now();
|
|
1771
1871
|
// Initialize cache if needed
|
|
1772
1872
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedPriceData, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedPriceData, "f") ?? new Map(), "f");
|
|
1873
|
+
// Store raw snapshot for the main DEX so market fetches can reuse it without REST.
|
|
1874
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_allMidsSnapshots, "f").set('', data.mids);
|
|
1773
1875
|
const subscribedSymbols = new Set();
|
|
1774
1876
|
// Collect all symbols that have subscribers
|
|
1775
1877
|
for (const [symbol, subscriberSet,] of __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_priceSubscribers, "f").entries()) {
|
|
@@ -1917,32 +2019,98 @@ async function _HyperLiquidSubscriptionService_ensureOrderFillISubscription(acco
|
|
|
1917
2019
|
* Implements reference counting to track active subscribers per DEX
|
|
1918
2020
|
*
|
|
1919
2021
|
* @param dex - The DEX identifier (empty string for main DEX).
|
|
2022
|
+
* @param options - Subscription behavior overrides.
|
|
2023
|
+
* @param options.incrementRefCount - Skip incrementing when restoring existing subscribers after reconnect.
|
|
1920
2024
|
*/
|
|
1921
|
-
async function _HyperLiquidSubscriptionService_ensureAssetCtxsSubscription(dex) {
|
|
2025
|
+
async function _HyperLiquidSubscriptionService_ensureAssetCtxsSubscription(dex, options = {}) {
|
|
1922
2026
|
const dexKey = dex || '';
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
2027
|
+
const { incrementRefCount = true } = options;
|
|
2028
|
+
if (incrementRefCount) {
|
|
2029
|
+
const currentCount = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexSubscriberCounts, "f").get(dexKey) ?? 0;
|
|
2030
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexSubscriberCounts, "f").set(dexKey, currentCount + 1);
|
|
2031
|
+
}
|
|
1926
2032
|
// Return if subscription already exists
|
|
1927
2033
|
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_assetCtxsSubscriptions, "f").has(dexKey)) {
|
|
1928
2034
|
return;
|
|
1929
2035
|
}
|
|
1930
|
-
|
|
1931
|
-
if (
|
|
1932
|
-
|
|
2036
|
+
let promise = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_assetCtxsSubscriptionPromises, "f").get(dexKey);
|
|
2037
|
+
if (!promise) {
|
|
2038
|
+
promise = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_createAssetCtxsSubscription).call(this, dex);
|
|
2039
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_assetCtxsSubscriptionPromises, "f").set(dexKey, promise);
|
|
2040
|
+
}
|
|
2041
|
+
try {
|
|
2042
|
+
await promise;
|
|
2043
|
+
}
|
|
2044
|
+
catch (error) {
|
|
2045
|
+
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_assetCtxsSubscriptionPromises, "f").get(dexKey) === promise) {
|
|
2046
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_assetCtxsSubscriptionPromises, "f").delete(dexKey);
|
|
2047
|
+
}
|
|
2048
|
+
if (incrementRefCount) {
|
|
2049
|
+
const currentCount = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexSubscriberCounts, "f").get(dexKey) ?? 0;
|
|
2050
|
+
if (currentCount <= 1) {
|
|
2051
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexSubscriberCounts, "f").delete(dexKey);
|
|
2052
|
+
}
|
|
2053
|
+
else {
|
|
2054
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexSubscriberCounts, "f").set(dexKey, currentCount - 1);
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
throw error;
|
|
2058
|
+
}
|
|
2059
|
+
}, _HyperLiquidSubscriptionService_ensureDexAllMidsSubscription =
|
|
2060
|
+
/**
|
|
2061
|
+
* Ensure a per-DEX allMids WS subscription exists (singleton per DEX).
|
|
2062
|
+
* Mirrors the assetCtxs subscription dedup pattern and is used only for HIP-3 DEXs.
|
|
2063
|
+
*
|
|
2064
|
+
* @param dex - The HIP-3 DEX name.
|
|
2065
|
+
*/
|
|
2066
|
+
async function _HyperLiquidSubscriptionService_ensureDexAllMidsSubscription(dex) {
|
|
2067
|
+
if (!dex) {
|
|
2068
|
+
return;
|
|
2069
|
+
}
|
|
2070
|
+
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAllMidsSubscriptions, "f").has(dex)) {
|
|
1933
2071
|
return;
|
|
1934
2072
|
}
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
2073
|
+
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAllMidsSubscriptionPromises, "f").has(dex)) {
|
|
2074
|
+
await __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAllMidsSubscriptionPromises, "f").get(dex);
|
|
2075
|
+
return;
|
|
2076
|
+
}
|
|
2077
|
+
const promise = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_createDexAllMidsSubscription).call(this, dex);
|
|
2078
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAllMidsSubscriptionPromises, "f").set(dex, promise);
|
|
1938
2079
|
try {
|
|
1939
2080
|
await promise;
|
|
1940
2081
|
}
|
|
1941
2082
|
catch (error) {
|
|
1942
|
-
|
|
1943
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_assetCtxsSubscriptionPromises, "f").delete(dexKey);
|
|
2083
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAllMidsSubscriptionPromises, "f").delete(dex);
|
|
1944
2084
|
throw error;
|
|
1945
2085
|
}
|
|
2086
|
+
}, _HyperLiquidSubscriptionService_createDexAllMidsSubscription =
|
|
2087
|
+
/**
|
|
2088
|
+
* Create allMids WS subscription for a specific HIP-3 DEX.
|
|
2089
|
+
*
|
|
2090
|
+
* @param dex - The HIP-3 DEX name.
|
|
2091
|
+
*/
|
|
2092
|
+
async function _HyperLiquidSubscriptionService_createDexAllMidsSubscription(dex) {
|
|
2093
|
+
await __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_clientService, "f").ensureSubscriptionClient(__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_walletService, "f").createWalletAdapter());
|
|
2094
|
+
const subscriptionClient = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_clientService, "f").getSubscriptionClient();
|
|
2095
|
+
if (!subscriptionClient) {
|
|
2096
|
+
throw new Error('Subscription client not initialized');
|
|
2097
|
+
}
|
|
2098
|
+
return new Promise((resolve, reject) => {
|
|
2099
|
+
subscriptionClient
|
|
2100
|
+
.allMids({ dex }, (data) => {
|
|
2101
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_allMidsSnapshots, "f").set(dex, data.mids);
|
|
2102
|
+
})
|
|
2103
|
+
.then((sub) => {
|
|
2104
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAllMidsSubscriptions, "f").set(dex, sub);
|
|
2105
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_deps, "f").debugLogger.log(`allMids subscription established for DEX: ${dex}`);
|
|
2106
|
+
resolve();
|
|
2107
|
+
return undefined;
|
|
2108
|
+
})
|
|
2109
|
+
.catch((error) => {
|
|
2110
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.createDexAllMidsSubscription'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'createDexAllMidsSubscription', { dex }));
|
|
2111
|
+
reject(ensureError(error, 'HyperLiquidSubscriptionService.createDexAllMidsSubscription'));
|
|
2112
|
+
});
|
|
2113
|
+
});
|
|
1946
2114
|
}, _HyperLiquidSubscriptionService_createAssetCtxsSubscription =
|
|
1947
2115
|
/**
|
|
1948
2116
|
* Create assetCtxs subscription for specific DEX
|
|
@@ -1986,8 +2154,7 @@ async function _HyperLiquidSubscriptionService_createAssetCtxsSubscription(dex)
|
|
|
1986
2154
|
});
|
|
1987
2155
|
return new Promise((resolve, reject) => {
|
|
1988
2156
|
const subscriptionParams = dex ? { dex } : {};
|
|
1989
|
-
|
|
1990
|
-
.assetCtxs(subscriptionParams, (data) => {
|
|
2157
|
+
const handleAssetCtxsUpdate = (data) => {
|
|
1991
2158
|
// Cache asset contexts for this DEX
|
|
1992
2159
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAssetCtxsCache, "f").set(dexKey, data.ctxs);
|
|
1993
2160
|
// Use cached meta to map ctxs array indices to symbols (no REST API call!)
|
|
@@ -2026,7 +2193,33 @@ async function _HyperLiquidSubscriptionService_createAssetCtxsSubscription(dex)
|
|
|
2026
2193
|
});
|
|
2027
2194
|
// Notify price subscribers with updated market data
|
|
2028
2195
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_notifyAllPriceSubscribers).call(this);
|
|
2029
|
-
}
|
|
2196
|
+
};
|
|
2197
|
+
const subscribeWithRetry = async () => {
|
|
2198
|
+
const maxAttempts = 3;
|
|
2199
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
2200
|
+
try {
|
|
2201
|
+
return await subscriptionClient.assetCtxs(subscriptionParams, handleAssetCtxsUpdate);
|
|
2202
|
+
}
|
|
2203
|
+
catch (error) {
|
|
2204
|
+
const ensuredError = ensureError(error, 'HyperLiquidSubscriptionService.createAssetCtxsSubscription');
|
|
2205
|
+
const isLastAttempt = attempt === maxAttempts;
|
|
2206
|
+
if (isLastAttempt ||
|
|
2207
|
+
!__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_isTransientAssetCtxsError).call(this, ensuredError)) {
|
|
2208
|
+
throw ensuredError;
|
|
2209
|
+
}
|
|
2210
|
+
const retryDelayMs = attempt * 500;
|
|
2211
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_deps, "f").debugLogger.log('Transient assetCtxs subscription failure during reconnect, retrying', {
|
|
2212
|
+
dex: dexKey || 'main',
|
|
2213
|
+
attempt,
|
|
2214
|
+
retryDelayMs,
|
|
2215
|
+
error: ensuredError.message,
|
|
2216
|
+
});
|
|
2217
|
+
await new Promise((_resolve) => setTimeout(_resolve, retryDelayMs));
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
throw new Error(`Failed to establish assetCtxs subscription for ${dexIdentifier}`);
|
|
2221
|
+
};
|
|
2222
|
+
subscribeWithRetry()
|
|
2030
2223
|
.then((sub) => {
|
|
2031
2224
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_assetCtxsSubscriptions, "f").set(dexKey, sub);
|
|
2032
2225
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_deps, "f").debugLogger.log(`assetCtxs subscription established for ${dex ? `DEX: ${dex}` : 'main DEX'}`);
|
|
@@ -2045,16 +2238,29 @@ async function _HyperLiquidSubscriptionService_createAssetCtxsSubscription(dex)
|
|
|
2045
2238
|
if (currentCount <= 1) {
|
|
2046
2239
|
// Last subscriber - cleanup the subscription
|
|
2047
2240
|
const subscription = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_assetCtxsSubscriptions, "f").get(dexKey);
|
|
2241
|
+
const allMidsSubscription = dex
|
|
2242
|
+
? __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAllMidsSubscriptions, "f").get(dex)
|
|
2243
|
+
: undefined;
|
|
2048
2244
|
if (subscription) {
|
|
2049
2245
|
subscription.unsubscribe().catch((error) => {
|
|
2050
2246
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.cleanupAssetCtxsSubscription'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'cleanupAssetCtxsSubscription', { dex }));
|
|
2051
2247
|
});
|
|
2052
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_assetCtxsSubscriptions, "f").delete(dexKey);
|
|
2053
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAssetCtxsCache, "f").delete(dexKey);
|
|
2054
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_assetCtxsSubscriptionPromises, "f").delete(dexKey);
|
|
2055
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexSubscriberCounts, "f").delete(dexKey);
|
|
2056
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_deps, "f").debugLogger.log(`Cleaned up assetCtxs subscription for ${dex ? `DEX: ${dex}` : 'main DEX'}`);
|
|
2057
2248
|
}
|
|
2249
|
+
if (allMidsSubscription) {
|
|
2250
|
+
allMidsSubscription.unsubscribe().catch((error) => {
|
|
2251
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.cleanupDexAllMidsSubscription'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'cleanupDexAllMidsSubscription', { dex }));
|
|
2252
|
+
});
|
|
2253
|
+
}
|
|
2254
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_assetCtxsSubscriptions, "f").delete(dexKey);
|
|
2255
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAssetCtxsCache, "f").delete(dexKey);
|
|
2256
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_assetCtxsSubscriptionPromises, "f").delete(dexKey);
|
|
2257
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexSubscriberCounts, "f").delete(dexKey);
|
|
2258
|
+
if (dex) {
|
|
2259
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAllMidsSubscriptions, "f").delete(dex);
|
|
2260
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAllMidsSubscriptionPromises, "f").delete(dex);
|
|
2261
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_allMidsSnapshots, "f").delete(dex);
|
|
2262
|
+
}
|
|
2263
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_deps, "f").debugLogger.log(`Cleaned up assetCtxs subscription for ${dex ? `DEX: ${dex}` : 'main DEX'}`);
|
|
2058
2264
|
}
|
|
2059
2265
|
else {
|
|
2060
2266
|
// Still has subscribers - just decrement count
|