@metamask-previews/perps-controller 9.3.0-preview-02ebbf830 → 9.3.0-preview-acc8294b8
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 +25 -0
- package/dist/constants/hyperLiquidConfig.cjs +2 -18
- package/dist/constants/hyperLiquidConfig.cjs.map +1 -1
- package/dist/constants/hyperLiquidConfig.d.cts +0 -16
- package/dist/constants/hyperLiquidConfig.d.cts.map +1 -1
- package/dist/constants/hyperLiquidConfig.d.mts +0 -16
- package/dist/constants/hyperLiquidConfig.d.mts.map +1 -1
- package/dist/constants/hyperLiquidConfig.mjs +0 -16
- package/dist/constants/hyperLiquidConfig.mjs.map +1 -1
- package/dist/index.cjs +4 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/perpsErrorCodes.cjs +2 -0
- package/dist/perpsErrorCodes.cjs.map +1 -1
- package/dist/perpsErrorCodes.d.cts +1 -0
- package/dist/perpsErrorCodes.d.cts.map +1 -1
- package/dist/perpsErrorCodes.d.mts +1 -0
- package/dist/perpsErrorCodes.d.mts.map +1 -1
- package/dist/perpsErrorCodes.mjs +2 -0
- package/dist/perpsErrorCodes.mjs.map +1 -1
- package/dist/providers/HyperLiquidProvider.cjs +96 -294
- package/dist/providers/HyperLiquidProvider.cjs.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.cts.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.mts.map +1 -1
- package/dist/providers/HyperLiquidProvider.mjs +97 -295
- package/dist/providers/HyperLiquidProvider.mjs.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.cjs +171 -19
- package/dist/services/HyperLiquidSubscriptionService.cjs.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.d.cts.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.d.mts.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.mjs +171 -19
- package/dist/services/HyperLiquidSubscriptionService.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
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");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _HyperLiquidSubscriptionService_instances, _a, _HyperLiquidSubscriptionService_clientService, _HyperLiquidSubscriptionService_walletService, _HyperLiquidSubscriptionService_hip3Enabled, _HyperLiquidSubscriptionService_enabledDexs, _HyperLiquidSubscriptionService_allowlistMarkets, _HyperLiquidSubscriptionService_blocklistMarkets, _HyperLiquidSubscriptionService_priceDeviationLimit, _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_pendingActiveAssetPromises, _HyperLiquidSubscriptionService_globalBboSubscriptions, _HyperLiquidSubscriptionService_pendingBboPromises, _HyperLiquidSubscriptionService_orderFillSubscriptions, _HyperLiquidSubscriptionService_spotStateSubscriptions, _HyperLiquidSubscriptionService_spotStateSubscriptionPromises, _HyperLiquidSubscriptionService_spotStateSubscriptionGeneration, _HyperLiquidSubscriptionService_symbolSubscriberCounts, _HyperLiquidSubscriptionService_dexSubscriberCounts, _HyperLiquidSubscriptionService_webData3Subscriptions, _HyperLiquidSubscriptionService_webData3SubscriptionPromise, _HyperLiquidSubscriptionService_positionSubscriberCount, _HyperLiquidSubscriptionService_orderSubscriberCount, _HyperLiquidSubscriptionService_accountSubscriberCount, _HyperLiquidSubscriptionService_oiCapSubscriberCount, _HyperLiquidSubscriptionService_dexPositionsCache, _HyperLiquidSubscriptionService_dexOrdersCache, _HyperLiquidSubscriptionService_dexAccountCache, _HyperLiquidSubscriptionService_cachedSpotState, _HyperLiquidSubscriptionService_abstractionModeByUser, _HyperLiquidSubscriptionService_abstractionModeLastWsRefreshAtByUser, _HyperLiquidSubscriptionService_abstractionModeInflightByUser, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, _HyperLiquidSubscriptionService_spotStatePromise, _HyperLiquidSubscriptionService_spotStatePromiseUserAddress, _HyperLiquidSubscriptionService_spotStateGeneration, _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_activeAssetCtxPriceTtlMs, _HyperLiquidSubscriptionService_isClearing, _HyperLiquidSubscriptionService_restoreRetryTimeouts, _HyperLiquidSubscriptionService_deps, _HyperLiquidSubscriptionService_logErrorUnlessClearing, _HyperLiquidSubscriptionService_isTransientSdkError, _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_getAbstractionModeForUser, _HyperLiquidSubscriptionService_getSpotBalanceOptions, _HyperLiquidSubscriptionService_refreshAbstractionModeThrottled, _HyperLiquidSubscriptionService_ensureSpotState, _HyperLiquidSubscriptionService_refreshSpotState, _HyperLiquidSubscriptionService_ensureSpotStateSubscription, _HyperLiquidSubscriptionService_ensureSharedWebData3Subscription, _HyperLiquidSubscriptionService_createUserDataSubscription, _HyperLiquidSubscriptionService_ensureClearinghouseStateSubscription, _HyperLiquidSubscriptionService_createClearinghouseSubscription, _HyperLiquidSubscriptionService_ensureOpenOrdersSubscription, _HyperLiquidSubscriptionService_createOpenOrdersSubscription, _HyperLiquidSubscriptionService_aggregateAndNotifySubscribers, _HyperLiquidSubscriptionService_cleanupSharedWebData3ISubscription, _HyperLiquidSubscriptionService_ensureOrderFillISubscription, _HyperLiquidSubscriptionService_createSubscription, _HyperLiquidSubscriptionService_createPriceUpdate, _HyperLiquidSubscriptionService_getFreshActiveAssetCtxPrice, _HyperLiquidSubscriptionService_projectPriceUpdate, _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
|
+
var _HyperLiquidSubscriptionService_instances, _a, _HyperLiquidSubscriptionService_clientService, _HyperLiquidSubscriptionService_walletService, _HyperLiquidSubscriptionService_hip3Enabled, _HyperLiquidSubscriptionService_enabledDexs, _HyperLiquidSubscriptionService_allowlistMarkets, _HyperLiquidSubscriptionService_blocklistMarkets, _HyperLiquidSubscriptionService_priceDeviationLimit, _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_globalFastAssetCtxsSubscription, _HyperLiquidSubscriptionService_globalFastAssetCtxsPromise, _HyperLiquidSubscriptionService_fastAssetCtxsCoins, _HyperLiquidSubscriptionService_globalActiveAssetSubscriptions, _HyperLiquidSubscriptionService_pendingActiveAssetPromises, _HyperLiquidSubscriptionService_globalBboSubscriptions, _HyperLiquidSubscriptionService_pendingBboPromises, _HyperLiquidSubscriptionService_orderFillSubscriptions, _HyperLiquidSubscriptionService_spotStateSubscriptions, _HyperLiquidSubscriptionService_spotStateSubscriptionPromises, _HyperLiquidSubscriptionService_spotStateSubscriptionGeneration, _HyperLiquidSubscriptionService_symbolSubscriberCounts, _HyperLiquidSubscriptionService_dexSubscriberCounts, _HyperLiquidSubscriptionService_webData3Subscriptions, _HyperLiquidSubscriptionService_webData3SubscriptionPromise, _HyperLiquidSubscriptionService_positionSubscriberCount, _HyperLiquidSubscriptionService_orderSubscriberCount, _HyperLiquidSubscriptionService_accountSubscriberCount, _HyperLiquidSubscriptionService_oiCapSubscriberCount, _HyperLiquidSubscriptionService_dexPositionsCache, _HyperLiquidSubscriptionService_dexOrdersCache, _HyperLiquidSubscriptionService_dexAccountCache, _HyperLiquidSubscriptionService_cachedSpotState, _HyperLiquidSubscriptionService_abstractionModeByUser, _HyperLiquidSubscriptionService_abstractionModeLastWsRefreshAtByUser, _HyperLiquidSubscriptionService_abstractionModeInflightByUser, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, _HyperLiquidSubscriptionService_spotStatePromise, _HyperLiquidSubscriptionService_spotStatePromiseUserAddress, _HyperLiquidSubscriptionService_spotStateGeneration, _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_activeAssetCtxPriceTtlMs, _HyperLiquidSubscriptionService_isClearing, _HyperLiquidSubscriptionService_restoreRetryTimeouts, _HyperLiquidSubscriptionService_deps, _HyperLiquidSubscriptionService_logErrorUnlessClearing, _HyperLiquidSubscriptionService_isTransientSdkError, _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_getAbstractionModeForUser, _HyperLiquidSubscriptionService_getSpotBalanceOptions, _HyperLiquidSubscriptionService_refreshAbstractionModeThrottled, _HyperLiquidSubscriptionService_ensureSpotState, _HyperLiquidSubscriptionService_refreshSpotState, _HyperLiquidSubscriptionService_ensureSpotStateSubscription, _HyperLiquidSubscriptionService_ensureSharedWebData3Subscription, _HyperLiquidSubscriptionService_createUserDataSubscription, _HyperLiquidSubscriptionService_ensureClearinghouseStateSubscription, _HyperLiquidSubscriptionService_createClearinghouseSubscription, _HyperLiquidSubscriptionService_ensureOpenOrdersSubscription, _HyperLiquidSubscriptionService_createOpenOrdersSubscription, _HyperLiquidSubscriptionService_aggregateAndNotifySubscribers, _HyperLiquidSubscriptionService_cleanupSharedWebData3ISubscription, _HyperLiquidSubscriptionService_ensureOrderFillISubscription, _HyperLiquidSubscriptionService_createSubscription, _HyperLiquidSubscriptionService_createPriceUpdate, _HyperLiquidSubscriptionService_getFreshActiveAssetCtxPrice, _HyperLiquidSubscriptionService_projectPriceUpdate, _HyperLiquidSubscriptionService_ensureGlobalAllMidsSubscription, _HyperLiquidSubscriptionService_ensureGlobalFastAssetCtxsSubscription, _HyperLiquidSubscriptionService_ensureActiveAssetSubscription, _HyperLiquidSubscriptionService_cleanupActiveAssetSubscription, _HyperLiquidSubscriptionService_ensureAssetCtxsSubscription, _HyperLiquidSubscriptionService_ensureDexAllMidsSubscription, _HyperLiquidSubscriptionService_createDexAllMidsSubscription, _HyperLiquidSubscriptionService_createAssetCtxsSubscription, _HyperLiquidSubscriptionService_cleanupAssetCtxsSubscription, _HyperLiquidSubscriptionService_ensureBboSubscription, _HyperLiquidSubscriptionService_cleanupBboSubscription, _HyperLiquidSubscriptionService_processOrderBookData, _HyperLiquidSubscriptionService_notifyAllPriceSubscribers;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.HyperLiquidSubscriptionService = void 0;
|
|
16
16
|
const utils_1 = require("@metamask/utils");
|
|
@@ -62,6 +62,23 @@ class HyperLiquidSubscriptionService {
|
|
|
62
62
|
// Global singleton subscriptions
|
|
63
63
|
_HyperLiquidSubscriptionService_globalAllMidsSubscription.set(this, void 0);
|
|
64
64
|
_HyperLiquidSubscriptionService_globalAllMidsPromise.set(this, void 0); // Track in-progress subscription
|
|
65
|
+
// fastAssetCtxs (TAT-3387): single global feed (no per-DEX param) that owns
|
|
66
|
+
// the latency-sensitive mark/mid price path at HyperLiquid's fast (~5s)
|
|
67
|
+
// cadence, now that the public assetCtxs feed has been slowed down.
|
|
68
|
+
_HyperLiquidSubscriptionService_globalFastAssetCtxsSubscription.set(this, void 0);
|
|
69
|
+
_HyperLiquidSubscriptionService_globalFastAssetCtxsPromise.set(this, void 0); // Track in-progress subscription
|
|
70
|
+
// Coins with a usable price (midPx/markPx) from any fastAssetCtxs event
|
|
71
|
+
// (snapshot or diff). Once a coin appears here, the per-DEX assetCtxs
|
|
72
|
+
// handler stops writing its price into #cachedPriceData, since
|
|
73
|
+
// fastAssetCtxs is the fresher/authoritative source for that coin going
|
|
74
|
+
// forward. A coin is only added once fastAssetCtxs has actually supplied a
|
|
75
|
+
// usable price for it (not merely appeared in a message with a null/absent
|
|
76
|
+
// price), so ownership is never claimed without a fast price backing it —
|
|
77
|
+
// otherwise assetCtxs, the coin's only remaining price source, would be
|
|
78
|
+
// suppressed with nothing to fall back on. Cleared on clearAll() and when
|
|
79
|
+
// the fastAssetCtxs subscription is re-established after a reconnect, so
|
|
80
|
+
// assetCtxs can serve prices again until a fresh snapshot arrives.
|
|
81
|
+
_HyperLiquidSubscriptionService_fastAssetCtxsCoins.set(this, new Set());
|
|
65
82
|
_HyperLiquidSubscriptionService_globalActiveAssetSubscriptions.set(this, new Map());
|
|
66
83
|
// Track in-progress activeAssetCtx subscription promises to prevent leaks
|
|
67
84
|
// when cleanup fires before the async subscription resolves (#28141)
|
|
@@ -335,6 +352,7 @@ class HyperLiquidSubscriptionService {
|
|
|
335
352
|
}
|
|
336
353
|
// Ensure global subscriptions are established
|
|
337
354
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_ensureGlobalAllMidsSubscription).call(this);
|
|
355
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_ensureGlobalFastAssetCtxsSubscription).call(this);
|
|
338
356
|
// Extract unique DEXs from requested symbols
|
|
339
357
|
const dexsNeeded = new Set();
|
|
340
358
|
symbols.forEach((symbol) => {
|
|
@@ -744,6 +762,13 @@ class HyperLiquidSubscriptionService {
|
|
|
744
762
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_globalAllMidsPromise, undefined, "f");
|
|
745
763
|
// Re-establish the subscription
|
|
746
764
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_ensureGlobalAllMidsSubscription).call(this);
|
|
765
|
+
// Re-establish the fastAssetCtxs subscription alongside allMids (TAT-3387).
|
|
766
|
+
// Clear fastAssetCtxsCoins so assetCtxs can serve prices in the gap
|
|
767
|
+
// until the fresh post-reconnect snapshot re-establishes coverage.
|
|
768
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_globalFastAssetCtxsSubscription, undefined, "f");
|
|
769
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_globalFastAssetCtxsPromise, undefined, "f");
|
|
770
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_fastAssetCtxsCoins, "f").clear();
|
|
771
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_ensureGlobalFastAssetCtxsSubscription).call(this);
|
|
747
772
|
}
|
|
748
773
|
// Re-establish order fill subscriptions if there are fill subscribers
|
|
749
774
|
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_orderFillSubscribers, "f").size > 0) {
|
|
@@ -949,6 +974,16 @@ class HyperLiquidSubscriptionService {
|
|
|
949
974
|
}
|
|
950
975
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_globalAllMidsSubscription, undefined, "f");
|
|
951
976
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_globalAllMidsPromise, undefined, "f");
|
|
977
|
+
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_globalFastAssetCtxsSubscription, "f")) {
|
|
978
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_globalFastAssetCtxsSubscription, "f")
|
|
979
|
+
.unsubscribe()
|
|
980
|
+
.catch((error) => {
|
|
981
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, (0, errorUtils_1.ensureError)(error, 'HyperLiquidSubscriptionService.clearAll'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'clearAll.globalFastAssetCtxs'));
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_globalFastAssetCtxsSubscription, undefined, "f");
|
|
985
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_globalFastAssetCtxsPromise, undefined, "f");
|
|
986
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_fastAssetCtxsCoins, "f").clear();
|
|
952
987
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_globalActiveAssetSubscriptions, "f").forEach((sub, symbol) => {
|
|
953
988
|
sub.unsubscribe().catch((error) => {
|
|
954
989
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, (0, errorUtils_1.ensureError)(error, 'HyperLiquidSubscriptionService.clearAll'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'clearAll.activeAsset', { symbol }));
|
|
@@ -1017,7 +1052,7 @@ class HyperLiquidSubscriptionService {
|
|
|
1017
1052
|
}
|
|
1018
1053
|
}
|
|
1019
1054
|
exports.HyperLiquidSubscriptionService = HyperLiquidSubscriptionService;
|
|
1020
|
-
_a = HyperLiquidSubscriptionService, _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_priceDeviationLimit = 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_pendingActiveAssetPromises = new WeakMap(), _HyperLiquidSubscriptionService_globalBboSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_pendingBboPromises = new WeakMap(), _HyperLiquidSubscriptionService_orderFillSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_spotStateSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_spotStateSubscriptionPromises = new WeakMap(), _HyperLiquidSubscriptionService_spotStateSubscriptionGeneration = 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_cachedSpotState = new WeakMap(), _HyperLiquidSubscriptionService_abstractionModeByUser = new WeakMap(), _HyperLiquidSubscriptionService_abstractionModeLastWsRefreshAtByUser = new WeakMap(), _HyperLiquidSubscriptionService_abstractionModeInflightByUser = new WeakMap(), _HyperLiquidSubscriptionService_cachedSpotStateUserAddress = new WeakMap(), _HyperLiquidSubscriptionService_spotStatePromise = new WeakMap(), _HyperLiquidSubscriptionService_spotStatePromiseUserAddress = new WeakMap(), _HyperLiquidSubscriptionService_spotStateGeneration = 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) {
|
|
1055
|
+
_a = HyperLiquidSubscriptionService, _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_priceDeviationLimit = 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_globalFastAssetCtxsSubscription = new WeakMap(), _HyperLiquidSubscriptionService_globalFastAssetCtxsPromise = new WeakMap(), _HyperLiquidSubscriptionService_fastAssetCtxsCoins = new WeakMap(), _HyperLiquidSubscriptionService_globalActiveAssetSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_pendingActiveAssetPromises = new WeakMap(), _HyperLiquidSubscriptionService_globalBboSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_pendingBboPromises = new WeakMap(), _HyperLiquidSubscriptionService_orderFillSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_spotStateSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_spotStateSubscriptionPromises = new WeakMap(), _HyperLiquidSubscriptionService_spotStateSubscriptionGeneration = 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_cachedSpotState = new WeakMap(), _HyperLiquidSubscriptionService_abstractionModeByUser = new WeakMap(), _HyperLiquidSubscriptionService_abstractionModeLastWsRefreshAtByUser = new WeakMap(), _HyperLiquidSubscriptionService_abstractionModeInflightByUser = new WeakMap(), _HyperLiquidSubscriptionService_cachedSpotStateUserAddress = new WeakMap(), _HyperLiquidSubscriptionService_spotStatePromise = new WeakMap(), _HyperLiquidSubscriptionService_spotStatePromiseUserAddress = new WeakMap(), _HyperLiquidSubscriptionService_spotStateGeneration = 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) {
|
|
1021
1056
|
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_isClearing, "f")) {
|
|
1022
1057
|
return;
|
|
1023
1058
|
}
|
|
@@ -2296,8 +2331,9 @@ async function _HyperLiquidSubscriptionService_ensureOrderFillISubscription(acco
|
|
|
2296
2331
|
subscribedSymbols.add(symbol);
|
|
2297
2332
|
}
|
|
2298
2333
|
}
|
|
2299
|
-
// Track
|
|
2300
|
-
|
|
2334
|
+
// Track which subscribed symbols actually changed price, so
|
|
2335
|
+
// notification can be scoped to just those symbols
|
|
2336
|
+
const changedSymbols = new Set();
|
|
2301
2337
|
// Only process symbols that are actually subscribed to
|
|
2302
2338
|
for (const symbol in data.mids) {
|
|
2303
2339
|
// Skip if nobody is subscribed to this symbol
|
|
@@ -2313,12 +2349,12 @@ async function _HyperLiquidSubscriptionService_ensureOrderFillISubscription(acco
|
|
|
2313
2349
|
// Price changed or new symbol - update cache
|
|
2314
2350
|
const priceUpdate = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_createPriceUpdate).call(this, symbol, price);
|
|
2315
2351
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedPriceData, "f").set(symbol, priceUpdate);
|
|
2316
|
-
|
|
2352
|
+
changedSymbols.add(symbol);
|
|
2317
2353
|
}
|
|
2318
|
-
// Only notify subscribers
|
|
2354
|
+
// Only notify subscribers of symbols whose price actually changed
|
|
2319
2355
|
// This prevents unnecessary React re-renders when prices haven't changed
|
|
2320
|
-
if (
|
|
2321
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_notifyAllPriceSubscribers).call(this);
|
|
2356
|
+
if (changedSymbols.size > 0) {
|
|
2357
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_notifyAllPriceSubscribers).call(this, changedSymbols);
|
|
2322
2358
|
}
|
|
2323
2359
|
})
|
|
2324
2360
|
.then((sub) => {
|
|
@@ -2335,6 +2371,100 @@ async function _HyperLiquidSubscriptionService_ensureOrderFillISubscription(acco
|
|
|
2335
2371
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_globalAllMidsPromise, undefined, "f");
|
|
2336
2372
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, (0, errorUtils_1.ensureError)(error, 'HyperLiquidSubscriptionService.ensureGlobalAllMidsSubscription'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'ensureGlobalAllMidsSubscription'));
|
|
2337
2373
|
}), "f");
|
|
2374
|
+
}, _HyperLiquidSubscriptionService_ensureGlobalFastAssetCtxsSubscription = function _HyperLiquidSubscriptionService_ensureGlobalFastAssetCtxsSubscription() {
|
|
2375
|
+
// Check both the subscription AND the promise to prevent race conditions
|
|
2376
|
+
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_globalFastAssetCtxsSubscription, "f") ??
|
|
2377
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_globalFastAssetCtxsPromise, "f")) {
|
|
2378
|
+
return;
|
|
2379
|
+
}
|
|
2380
|
+
const subscriptionClient = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_clientService, "f").getSubscriptionClient();
|
|
2381
|
+
if (!subscriptionClient) {
|
|
2382
|
+
return;
|
|
2383
|
+
}
|
|
2384
|
+
const handleFastAssetCtxsUpdate = (data) => {
|
|
2385
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedPriceData, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedPriceData, "f") ?? new Map(), "f");
|
|
2386
|
+
// Track which subscribed symbols actually changed price, so
|
|
2387
|
+
// notification can be scoped to just those symbols
|
|
2388
|
+
const changedSymbols = new Set();
|
|
2389
|
+
for (const coin in data) {
|
|
2390
|
+
if (!(0, utils_1.hasProperty)(data, coin)) {
|
|
2391
|
+
continue;
|
|
2392
|
+
}
|
|
2393
|
+
const ctx = data[coin];
|
|
2394
|
+
const priceRaw = ctx.midPx ?? ctx.markPx;
|
|
2395
|
+
if (priceRaw === undefined || priceRaw === null) {
|
|
2396
|
+
// No usable price for this coin in this message — don't claim
|
|
2397
|
+
// ownership. Otherwise a coin with no usable price here would be
|
|
2398
|
+
// marked as fastAssetCtxs-owned while never having a fast price
|
|
2399
|
+
// cached, suppressing assetCtxs (its only remaining price source)
|
|
2400
|
+
// for that coin indefinitely.
|
|
2401
|
+
continue;
|
|
2402
|
+
}
|
|
2403
|
+
// Mark this coin as covered by fastAssetCtxs now that a usable
|
|
2404
|
+
// price backs that ownership (regardless of whether there's
|
|
2405
|
+
// currently a subscriber), so the slower per-DEX assetCtxs handler
|
|
2406
|
+
// knows to defer to this feed for the coin's price.
|
|
2407
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_fastAssetCtxsCoins, "f").add(coin);
|
|
2408
|
+
const price = priceRaw.toString();
|
|
2409
|
+
const cachedPrice = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedPriceData, "f").get(coin);
|
|
2410
|
+
// Skip if price hasn't changed
|
|
2411
|
+
if (cachedPrice?.price === price) {
|
|
2412
|
+
continue;
|
|
2413
|
+
}
|
|
2414
|
+
const priceUpdate = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_createPriceUpdate).call(this, coin, price);
|
|
2415
|
+
// Cache every valid price, even for coins nobody is subscribed to
|
|
2416
|
+
// yet (snapshot messages include every asset on the exchange), so
|
|
2417
|
+
// a later subscriber gets an immediate baseline via the
|
|
2418
|
+
// subscribe-time cached-price replay instead of an assetCtxs feed
|
|
2419
|
+
// that's been suppressed with no fastAssetCtxs price to fall back
|
|
2420
|
+
// on.
|
|
2421
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedPriceData, "f").set(coin, priceUpdate);
|
|
2422
|
+
// Scope notification to coins with an active subscriber; snapshot
|
|
2423
|
+
// messages cover the full exchange and most coins have none.
|
|
2424
|
+
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_priceSubscribers, "f").get(coin)?.size) {
|
|
2425
|
+
changedSymbols.add(coin);
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
// Only notify subscribers of symbols whose price actually changed
|
|
2429
|
+
if (changedSymbols.size > 0) {
|
|
2430
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_notifyAllPriceSubscribers).call(this, changedSymbols);
|
|
2431
|
+
}
|
|
2432
|
+
};
|
|
2433
|
+
const subscribeWithRetry = async () => {
|
|
2434
|
+
const maxAttempts = 3;
|
|
2435
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
2436
|
+
try {
|
|
2437
|
+
return await subscriptionClient.fastAssetCtxs(handleFastAssetCtxsUpdate);
|
|
2438
|
+
}
|
|
2439
|
+
catch (error) {
|
|
2440
|
+
const ensuredError = (0, errorUtils_1.ensureError)(error, 'HyperLiquidSubscriptionService.ensureGlobalFastAssetCtxsSubscription');
|
|
2441
|
+
const isLastAttempt = attempt === maxAttempts;
|
|
2442
|
+
if (isLastAttempt || !__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_isTransientSdkError).call(this, ensuredError)) {
|
|
2443
|
+
throw ensuredError;
|
|
2444
|
+
}
|
|
2445
|
+
const retryDelayMs = attempt * 500;
|
|
2446
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_deps, "f").debugLogger.log('Transient fastAssetCtxs subscription failure during reconnect, retrying', {
|
|
2447
|
+
attempt,
|
|
2448
|
+
retryDelayMs,
|
|
2449
|
+
error: ensuredError.message,
|
|
2450
|
+
});
|
|
2451
|
+
await new Promise((_resolve) => setTimeout(_resolve, retryDelayMs));
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
throw new Error('Failed to establish fastAssetCtxs subscription');
|
|
2455
|
+
};
|
|
2456
|
+
// Store the promise immediately to prevent duplicate calls
|
|
2457
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_globalFastAssetCtxsPromise, subscribeWithRetry()
|
|
2458
|
+
.then((sub) => {
|
|
2459
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_globalFastAssetCtxsSubscription, sub, "f");
|
|
2460
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_deps, "f").debugLogger.log('HyperLiquid: Global fastAssetCtxs subscription established');
|
|
2461
|
+
return undefined;
|
|
2462
|
+
})
|
|
2463
|
+
.catch((error) => {
|
|
2464
|
+
// Clear the promise on error so it can be retried
|
|
2465
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_globalFastAssetCtxsPromise, undefined, "f");
|
|
2466
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, (0, errorUtils_1.ensureError)(error, 'HyperLiquidSubscriptionService.ensureGlobalFastAssetCtxsSubscription'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'ensureGlobalFastAssetCtxsSubscription'));
|
|
2467
|
+
}), "f");
|
|
2338
2468
|
}, _HyperLiquidSubscriptionService_ensureActiveAssetSubscription = function _HyperLiquidSubscriptionService_ensureActiveAssetSubscription(symbol) {
|
|
2339
2469
|
// Increment subscriber count
|
|
2340
2470
|
const currentCount = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_symbolSubscriberCounts, "f").get(symbol) ?? 0;
|
|
@@ -2405,12 +2535,14 @@ async function _HyperLiquidSubscriptionService_ensureOrderFillISubscription(acco
|
|
|
2405
2535
|
if (priceCache && existingBaseline) {
|
|
2406
2536
|
priceCache.set(symbol, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_createPriceUpdate).call(this, symbol, existingBaseline.price));
|
|
2407
2537
|
}
|
|
2408
|
-
// Notify subscribers. #notifyAllPriceSubscribers
|
|
2409
|
-
// fast-stream price (now stored in #marketDataCache) for
|
|
2410
|
-
// (includeMarketData: true) subscribers, while list subscribers
|
|
2538
|
+
// Notify subscribers of this symbol only. #notifyAllPriceSubscribers
|
|
2539
|
+
// projects the fast-stream price (now stored in #marketDataCache) for
|
|
2540
|
+
// focused (includeMarketData: true) subscribers, while list subscribers
|
|
2411
2541
|
// continue to receive only the allMids baseline from #cachedPriceData.
|
|
2412
|
-
//
|
|
2413
|
-
|
|
2542
|
+
// Scoping to this symbol avoids redundant reference-equal allMids
|
|
2543
|
+
// updates to list subscribers watching other symbols, since their
|
|
2544
|
+
// allMids baseline hasn't changed on this tick.
|
|
2545
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_notifyAllPriceSubscribers).call(this, new Set([symbol]));
|
|
2414
2546
|
}
|
|
2415
2547
|
})
|
|
2416
2548
|
.then((sub) => {
|
|
@@ -2650,12 +2782,29 @@ async function _HyperLiquidSubscriptionService_createAssetCtxsSubscription(dex)
|
|
|
2650
2782
|
priceLastUpdated: existingMarketData?.priceLastUpdated,
|
|
2651
2783
|
};
|
|
2652
2784
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_marketDataCache, "f").set(asset.name, marketData);
|
|
2653
|
-
// HIP-3: Extract price from assetCtx and update cached prices
|
|
2785
|
+
// HIP-3: Extract price from assetCtx and update cached prices.
|
|
2786
|
+
// For HIP-3 DEXs, meta() returns asset.name already containing the
|
|
2787
|
+
// DEX prefix (e.g., "xyz:XYZ100"), so use it directly.
|
|
2788
|
+
const symbol = asset.name;
|
|
2654
2789
|
const price = ctx.midPx?.toString() ?? ctx.markPx?.toString();
|
|
2655
|
-
if (
|
|
2656
|
-
//
|
|
2657
|
-
//
|
|
2658
|
-
|
|
2790
|
+
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_fastAssetCtxsCoins, "f").has(symbol)) {
|
|
2791
|
+
// fastAssetCtxs (TAT-3387) owns the price string for this coin
|
|
2792
|
+
// with fresher, ~5s-cadence data, so don't overwrite it with
|
|
2793
|
+
// this batch's price. Still rebuild the baseline (keeping the
|
|
2794
|
+
// existing price) so derived fields just refreshed above in
|
|
2795
|
+
// #marketDataCache (funding, openInterest, volume24h,
|
|
2796
|
+
// oraclePrice, percentChange24h/isTradable via markPrice) reach
|
|
2797
|
+
// list subscribers instead of going stale until the next
|
|
2798
|
+
// fastAssetCtxs/allMids price change. Only rebuild an existing
|
|
2799
|
+
// baseline to preserve the startup zero-price guard: we never
|
|
2800
|
+
// want to synthesize a baseline from a '0' / absent allMids
|
|
2801
|
+
// price.
|
|
2802
|
+
const existingBaseline = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedPriceData, "f")?.get(symbol);
|
|
2803
|
+
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedPriceData, "f") && existingBaseline) {
|
|
2804
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedPriceData, "f").set(symbol, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_createPriceUpdate).call(this, symbol, existingBaseline.price));
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
else if (price) {
|
|
2659
2808
|
const priceUpdate = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_createPriceUpdate).call(this, symbol, price);
|
|
2660
2809
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedPriceData, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedPriceData, "f") ?? new Map(), "f");
|
|
2661
2810
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedPriceData, "f").set(symbol, priceUpdate);
|
|
@@ -2866,9 +3015,12 @@ async function _HyperLiquidSubscriptionService_createAssetCtxsSubscription(dex)
|
|
|
2866
3015
|
lastUpdated: Date.now(),
|
|
2867
3016
|
maxTotal,
|
|
2868
3017
|
};
|
|
2869
|
-
}, _HyperLiquidSubscriptionService_notifyAllPriceSubscribers = function _HyperLiquidSubscriptionService_notifyAllPriceSubscribers() {
|
|
3018
|
+
}, _HyperLiquidSubscriptionService_notifyAllPriceSubscribers = function _HyperLiquidSubscriptionService_notifyAllPriceSubscribers(changedSymbols) {
|
|
2870
3019
|
const subscriberUpdates = new Map();
|
|
2871
3020
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_priceSubscribers, "f").forEach((subscriberSet, symbol) => {
|
|
3021
|
+
if (changedSymbols && !changedSymbols.has(symbol)) {
|
|
3022
|
+
return;
|
|
3023
|
+
}
|
|
2872
3024
|
const allMidsBase = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedPriceData, "f")?.get(symbol);
|
|
2873
3025
|
const fastPrice = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getFreshActiveAssetCtxPrice).call(this, symbol);
|
|
2874
3026
|
const now = Date.now();
|