@metamask-previews/perps-controller 3.2.0-preview-6ce5d58fa → 4.0.0-preview-1e2fe74a0
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 +29 -1
- package/dist/PerpsController-method-action-types.cjs.map +1 -1
- package/dist/PerpsController-method-action-types.d.cts +9 -0
- package/dist/PerpsController-method-action-types.d.cts.map +1 -1
- package/dist/PerpsController-method-action-types.d.mts +9 -0
- package/dist/PerpsController-method-action-types.d.mts.map +1 -1
- package/dist/PerpsController-method-action-types.mjs.map +1 -1
- package/dist/PerpsController.cjs +15 -3
- package/dist/PerpsController.cjs.map +1 -1
- package/dist/PerpsController.d.cts +18 -3
- package/dist/PerpsController.d.cts.map +1 -1
- package/dist/PerpsController.d.mts +18 -3
- package/dist/PerpsController.d.mts.map +1 -1
- package/dist/PerpsController.mjs +15 -3
- package/dist/PerpsController.mjs.map +1 -1
- package/dist/constants/perpsConfig.cjs +28 -0
- package/dist/constants/perpsConfig.cjs.map +1 -1
- package/dist/constants/perpsConfig.d.cts +3 -0
- package/dist/constants/perpsConfig.d.cts.map +1 -1
- package/dist/constants/perpsConfig.d.mts +3 -0
- package/dist/constants/perpsConfig.d.mts.map +1 -1
- package/dist/constants/perpsConfig.mjs +28 -0
- package/dist/constants/perpsConfig.mjs.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.cjs +16 -6
- package/dist/providers/AggregatedPerpsProvider.cjs.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.d.cts +12 -4
- package/dist/providers/AggregatedPerpsProvider.d.cts.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.d.mts +12 -4
- package/dist/providers/AggregatedPerpsProvider.d.mts.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.mjs +16 -6
- package/dist/providers/AggregatedPerpsProvider.mjs.map +1 -1
- package/dist/providers/HyperLiquidProvider.cjs +56 -20
- package/dist/providers/HyperLiquidProvider.cjs.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.cts +29 -4
- package/dist/providers/HyperLiquidProvider.d.cts.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.mts +29 -4
- package/dist/providers/HyperLiquidProvider.d.mts.map +1 -1
- package/dist/providers/HyperLiquidProvider.mjs +57 -21
- package/dist/providers/HyperLiquidProvider.mjs.map +1 -1
- package/dist/services/HyperLiquidClientService.cjs +131 -60
- package/dist/services/HyperLiquidClientService.cjs.map +1 -1
- package/dist/services/HyperLiquidClientService.d.cts +23 -0
- package/dist/services/HyperLiquidClientService.d.cts.map +1 -1
- package/dist/services/HyperLiquidClientService.d.mts +23 -0
- package/dist/services/HyperLiquidClientService.d.mts.map +1 -1
- package/dist/services/HyperLiquidClientService.mjs +132 -61
- package/dist/services/HyperLiquidClientService.mjs.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.cjs +193 -11
- 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 +194 -12
- package/dist/services/HyperLiquidSubscriptionService.mjs.map +1 -1
- package/dist/services/MarketDataService.cjs +89 -6
- package/dist/services/MarketDataService.cjs.map +1 -1
- package/dist/services/MarketDataService.d.cts +19 -0
- package/dist/services/MarketDataService.d.cts.map +1 -1
- package/dist/services/MarketDataService.d.mts +19 -0
- package/dist/services/MarketDataService.d.mts.map +1 -1
- package/dist/services/MarketDataService.mjs +89 -6
- package/dist/services/MarketDataService.mjs.map +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +21 -3
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.mts +21 -3
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/accountUtils.cjs +74 -1
- package/dist/utils/accountUtils.cjs.map +1 -1
- package/dist/utils/accountUtils.d.cts +4 -0
- package/dist/utils/accountUtils.d.cts.map +1 -1
- package/dist/utils/accountUtils.d.mts +4 -0
- package/dist/utils/accountUtils.d.mts.map +1 -1
- package/dist/utils/accountUtils.mjs +70 -0
- package/dist/utils/accountUtils.mjs.map +1 -1
- package/dist/utils/coalescePerpsRestRequest.cjs +71 -0
- package/dist/utils/coalescePerpsRestRequest.cjs.map +1 -0
- package/dist/utils/coalescePerpsRestRequest.d.cts +32 -0
- package/dist/utils/coalescePerpsRestRequest.d.cts.map +1 -0
- package/dist/utils/coalescePerpsRestRequest.d.mts +32 -0
- package/dist/utils/coalescePerpsRestRequest.d.mts.map +1 -0
- package/dist/utils/coalescePerpsRestRequest.mjs +66 -0
- package/dist/utils/coalescePerpsRestRequest.mjs.map +1 -0
- package/dist/utils/hyperLiquidAdapter.cjs +7 -7
- package/dist/utils/hyperLiquidAdapter.cjs.map +1 -1
- package/dist/utils/hyperLiquidAdapter.d.cts +2 -2
- package/dist/utils/hyperLiquidAdapter.d.cts.map +1 -1
- package/dist/utils/hyperLiquidAdapter.d.mts +2 -2
- package/dist/utils/hyperLiquidAdapter.d.mts.map +1 -1
- package/dist/utils/hyperLiquidAdapter.mjs +7 -7
- package/dist/utils/hyperLiquidAdapter.mjs.map +1 -1
- package/dist/utils/perpsFormatters.cjs +5 -1
- package/dist/utils/perpsFormatters.cjs.map +1 -1
- package/dist/utils/perpsFormatters.d.cts.map +1 -1
- package/dist/utils/perpsFormatters.d.mts.map +1 -1
- package/dist/utils/perpsFormatters.mjs +5 -1
- package/dist/utils/perpsFormatters.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HyperLiquidSubscriptionService.d.cts","sourceRoot":"","sources":["../../src/services/HyperLiquidSubscriptionService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAUV,gBAAgB,
|
|
1
|
+
{"version":3,"file":"HyperLiquidSubscriptionService.d.cts","sourceRoot":"","sources":["../../src/services/HyperLiquidSubscriptionService.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HyperLiquidSubscriptionService.d.mts","sourceRoot":"","sources":["../../src/services/HyperLiquidSubscriptionService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAUV,gBAAgB,
|
|
1
|
+
{"version":3,"file":"HyperLiquidSubscriptionService.d.mts","sourceRoot":"","sources":["../../src/services/HyperLiquidSubscriptionService.ts"],"names":[],"mappings":"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"}
|
|
@@ -9,11 +9,11 @@ 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_pendingActiveAssetPromises, _HyperLiquidSubscriptionService_globalBboSubscriptions, _HyperLiquidSubscriptionService_pendingBboPromises, _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;
|
|
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_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_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_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_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_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 { hasProperty } from "@metamask/utils";
|
|
14
14
|
import { TP_SL_CONFIG, PERPS_CONSTANTS } from "../constants/perpsConfig.mjs";
|
|
15
15
|
import { WebSocketConnectionState } from "../types/index.mjs";
|
|
16
|
-
import { calculateWeightedReturnOnEquity } from "../utils/accountUtils.mjs";
|
|
16
|
+
import { addSpotBalanceToAccountState, calculateWeightedReturnOnEquity } from "../utils/accountUtils.mjs";
|
|
17
17
|
import { ensureError } from "../utils/errorUtils.mjs";
|
|
18
18
|
import { adaptPositionFromSDK, adaptOrderFromSDK, adaptAccountStateFromSDK, parseAssetName } from "../utils/hyperLiquidAdapter.mjs";
|
|
19
19
|
import { processBboData } from "../utils/hyperLiquidOrderBookProcessor.mjs";
|
|
@@ -64,6 +64,12 @@ export class HyperLiquidSubscriptionService {
|
|
|
64
64
|
_HyperLiquidSubscriptionService_pendingBboPromises.set(this, new Map());
|
|
65
65
|
// Order fill subscriptions keyed by accountId (normalized: undefined -> 'default')
|
|
66
66
|
_HyperLiquidSubscriptionService_orderFillSubscriptions.set(this, new Map());
|
|
67
|
+
_HyperLiquidSubscriptionService_spotStateSubscriptions.set(this, new Map());
|
|
68
|
+
_HyperLiquidSubscriptionService_spotStateSubscriptionPromises.set(this, new Map());
|
|
69
|
+
// Bumped on cleanup so in-flight #ensureSpotStateSubscription
|
|
70
|
+
// continuations discard their subscription instead of rehydrating
|
|
71
|
+
// #spotStateSubscriptions after clearAll/cleanupSharedWebData3.
|
|
72
|
+
_HyperLiquidSubscriptionService_spotStateSubscriptionGeneration.set(this, 0);
|
|
67
73
|
_HyperLiquidSubscriptionService_symbolSubscriberCounts.set(this, new Map());
|
|
68
74
|
_HyperLiquidSubscriptionService_dexSubscriberCounts.set(this, new Map()); // Track subscribers per DEX for assetCtxs
|
|
69
75
|
// Multi-DEX webData3 subscription for all user data (positions, orders, account, OI caps)
|
|
@@ -77,6 +83,15 @@ export class HyperLiquidSubscriptionService {
|
|
|
77
83
|
_HyperLiquidSubscriptionService_dexPositionsCache.set(this, new Map()); // Per-DEX positions
|
|
78
84
|
_HyperLiquidSubscriptionService_dexOrdersCache.set(this, new Map()); // Per-DEX orders
|
|
79
85
|
_HyperLiquidSubscriptionService_dexAccountCache.set(this, new Map()); // Per-DEX account state
|
|
86
|
+
_HyperLiquidSubscriptionService_cachedSpotState.set(this, null);
|
|
87
|
+
_HyperLiquidSubscriptionService_cachedSpotStateUserAddress.set(this, null);
|
|
88
|
+
_HyperLiquidSubscriptionService_spotStatePromise.set(this, void 0);
|
|
89
|
+
_HyperLiquidSubscriptionService_spotStatePromiseUserAddress.set(this, void 0);
|
|
90
|
+
// Monotonic token bumped on cleanUp/clearAll and on each new fetch.
|
|
91
|
+
// Any in-flight #refreshSpotState that resolves with a stale token
|
|
92
|
+
// discards its result, preventing cross-account cache contamination
|
|
93
|
+
// when accounts are switched mid-fetch.
|
|
94
|
+
_HyperLiquidSubscriptionService_spotStateGeneration.set(this, 0);
|
|
80
95
|
_HyperLiquidSubscriptionService_cachedPositions.set(this, null); // Aggregated positions
|
|
81
96
|
_HyperLiquidSubscriptionService_cachedOrders.set(this, null); // Aggregated orders
|
|
82
97
|
_HyperLiquidSubscriptionService_cachedAccount.set(this, null); // Aggregated account
|
|
@@ -480,10 +495,20 @@ export class HyperLiquidSubscriptionService {
|
|
|
480
495
|
const unsubscribe = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_createSubscription).call(this, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_accountSubscribers, "f"), callback);
|
|
481
496
|
// Increment account subscriber count
|
|
482
497
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_accountSubscriberCount, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_accountSubscriberCount, "f") + 1, "f");
|
|
483
|
-
// Immediately provide cached data if available
|
|
498
|
+
// Immediately provide cached data if available. May be spot-less if the
|
|
499
|
+
// spot fetch has not resolved yet (or permanently failed) — subscribers
|
|
500
|
+
// prefer stale-but-present data over silent starvation; the next
|
|
501
|
+
// aggregation after #ensureSpotState / next WebSocket update pushes the
|
|
502
|
+
// spot-inclusive value.
|
|
484
503
|
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedAccount, "f")) {
|
|
485
504
|
callback(__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedAccount, "f"));
|
|
486
505
|
}
|
|
506
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_ensureSpotState).call(this, accountId).catch((error) => {
|
|
507
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.subscribeToAccount'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'subscribeToAccount.ensureSpotState'));
|
|
508
|
+
});
|
|
509
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_ensureSpotStateSubscription).call(this, accountId).catch((error) => {
|
|
510
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.subscribeToAccount'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'subscribeToAccount.ensureSpotStateSubscription'));
|
|
511
|
+
});
|
|
487
512
|
// Ensure shared subscription is active (reuses existing connection)
|
|
488
513
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_ensureSharedWebData3Subscription).call(this, accountId).catch((error) => {
|
|
489
514
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.subscribeToAccount'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'subscribeToAccount'));
|
|
@@ -813,6 +838,17 @@ export class HyperLiquidSubscriptionService {
|
|
|
813
838
|
});
|
|
814
839
|
});
|
|
815
840
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_orderFillSubscriptions, "f").clear();
|
|
841
|
+
// Clear spotState subscriptions. Bump generation + drop in-flight
|
|
842
|
+
// promises so any racing #ensureSpotStateSubscription continuation
|
|
843
|
+
// unsubscribes its fresh sub instead of rehydrating the cleared map.
|
|
844
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStateSubscriptionGeneration, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateSubscriptionGeneration, "f") + 1, "f");
|
|
845
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateSubscriptionPromises, "f").clear();
|
|
846
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateSubscriptions, "f").forEach((subscription) => {
|
|
847
|
+
subscription.unsubscribe().catch(() => {
|
|
848
|
+
// Ignore errors during cleanup
|
|
849
|
+
});
|
|
850
|
+
});
|
|
851
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateSubscriptions, "f").clear();
|
|
816
852
|
// Clear cached data
|
|
817
853
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedPriceData, null, "f");
|
|
818
854
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_allMidsSnapshots, "f").clear();
|
|
@@ -843,6 +879,11 @@ export class HyperLiquidSubscriptionService {
|
|
|
843
879
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexPositionsCache, "f").clear();
|
|
844
880
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexOrdersCache, "f").clear();
|
|
845
881
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAccountCache, "f").clear();
|
|
882
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotState, null, "f");
|
|
883
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, null, "f");
|
|
884
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStateGeneration, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateGeneration, "f") + 1, "f");
|
|
885
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStatePromise, undefined, "f");
|
|
886
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStatePromiseUserAddress, undefined, "f");
|
|
846
887
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAssetCtxsCache, "f").clear();
|
|
847
888
|
// Unsubscribe all active subscriptions before clearing references.
|
|
848
889
|
// Without this, orphaned subscriptions try to send unsubscribe frames
|
|
@@ -921,7 +962,7 @@ export class HyperLiquidSubscriptionService {
|
|
|
921
962
|
});
|
|
922
963
|
}
|
|
923
964
|
}
|
|
924
|
-
_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_pendingActiveAssetPromises = new WeakMap(), _HyperLiquidSubscriptionService_globalBboSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_pendingBboPromises = 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) {
|
|
965
|
+
_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_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_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) {
|
|
925
966
|
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_isClearing, "f")) {
|
|
926
967
|
return;
|
|
927
968
|
}
|
|
@@ -1222,7 +1263,7 @@ async function _HyperLiquidSubscriptionService_waitForDexDiscovery(timeoutMs = 5
|
|
|
1222
1263
|
const firstDexAccount = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAccountCache, "f").values().next().value ?? {};
|
|
1223
1264
|
// Calculate weighted returnOnEquity across all DEXs
|
|
1224
1265
|
const returnOnEquity = calculateWeightedReturnOnEquity(accountStatesForROE);
|
|
1225
|
-
return {
|
|
1266
|
+
return addSpotBalanceToAccountState({
|
|
1226
1267
|
...firstDexAccount,
|
|
1227
1268
|
availableBalance: totalAvailableBalance.toString(),
|
|
1228
1269
|
totalBalance: totalBalance.toString(),
|
|
@@ -1230,7 +1271,124 @@ async function _HyperLiquidSubscriptionService_waitForDexDiscovery(timeoutMs = 5
|
|
|
1230
1271
|
unrealizedPnl: totalUnrealizedPnl.toString(),
|
|
1231
1272
|
subAccountBreakdown,
|
|
1232
1273
|
returnOnEquity,
|
|
1233
|
-
};
|
|
1274
|
+
}, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotState, "f"));
|
|
1275
|
+
}, _HyperLiquidSubscriptionService_ensureSpotState = async function _HyperLiquidSubscriptionService_ensureSpotState(accountId) {
|
|
1276
|
+
const userAddress = await __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_walletService, "f").getUserAddressWithDefault(accountId);
|
|
1277
|
+
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotState, "f") &&
|
|
1278
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, "f") === userAddress) {
|
|
1279
|
+
return;
|
|
1280
|
+
}
|
|
1281
|
+
// Share an in-flight fetch only if it targets the same user.
|
|
1282
|
+
// A pending fetch for a different user is stale after an account switch —
|
|
1283
|
+
// start a fresh fetch; the stale one will self-discard via generation check.
|
|
1284
|
+
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStatePromise, "f") &&
|
|
1285
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStatePromiseUserAddress, "f") === userAddress) {
|
|
1286
|
+
await __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStatePromise, "f");
|
|
1287
|
+
return;
|
|
1288
|
+
}
|
|
1289
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStateGeneration, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateGeneration, "f") + 1, "f");
|
|
1290
|
+
const generation = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateGeneration, "f");
|
|
1291
|
+
const promise = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_refreshSpotState).call(this, userAddress, generation);
|
|
1292
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStatePromise, promise, "f");
|
|
1293
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStatePromiseUserAddress, userAddress, "f");
|
|
1294
|
+
try {
|
|
1295
|
+
await promise;
|
|
1296
|
+
}
|
|
1297
|
+
finally {
|
|
1298
|
+
// Only clear tracker if we're still the latest in-flight fetch.
|
|
1299
|
+
// A newer fetch may have already replaced us.
|
|
1300
|
+
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStatePromise, "f") === promise) {
|
|
1301
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStatePromise, undefined, "f");
|
|
1302
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStatePromiseUserAddress, undefined, "f");
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
}, _HyperLiquidSubscriptionService_refreshSpotState = async function _HyperLiquidSubscriptionService_refreshSpotState(userAddress, generation) {
|
|
1306
|
+
try {
|
|
1307
|
+
// Cold-start safety: getInfoClient() throws until the SDK has been
|
|
1308
|
+
// initialized via ensureSubscriptionClient. On a fresh service
|
|
1309
|
+
// instance subscribeToAccount can race ahead of the webData3 path,
|
|
1310
|
+
// so initialize here first — subsequent calls are no-ops.
|
|
1311
|
+
await __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_clientService, "f").ensureSubscriptionClient(__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_walletService, "f").createWalletAdapter());
|
|
1312
|
+
if (generation !== __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateGeneration, "f")) {
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1315
|
+
const infoClient = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_clientService, "f").getInfoClient();
|
|
1316
|
+
const result = await infoClient.spotClearinghouseState({
|
|
1317
|
+
user: userAddress,
|
|
1318
|
+
});
|
|
1319
|
+
// Drop stale results: cleanUp/clearAll or a newer fetch bumped generation.
|
|
1320
|
+
// Writing here would re-populate the cache with a different user's data.
|
|
1321
|
+
if (generation !== __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateGeneration, "f")) {
|
|
1322
|
+
return;
|
|
1323
|
+
}
|
|
1324
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotState, result, "f");
|
|
1325
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, userAddress, "f");
|
|
1326
|
+
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAccountCache, "f").size > 0) {
|
|
1327
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_aggregateAndNotifySubscribers).call(this);
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
catch (error) {
|
|
1331
|
+
if (generation !== __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateGeneration, "f")) {
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.refreshSpotState'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'refreshSpotState'));
|
|
1335
|
+
}
|
|
1336
|
+
}, _HyperLiquidSubscriptionService_ensureSpotStateSubscription = async function _HyperLiquidSubscriptionService_ensureSpotStateSubscription(accountId) {
|
|
1337
|
+
const userAddress = await __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_walletService, "f").getUserAddressWithDefault(accountId);
|
|
1338
|
+
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateSubscriptions, "f").has(userAddress)) {
|
|
1339
|
+
return;
|
|
1340
|
+
}
|
|
1341
|
+
const inFlight = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateSubscriptionPromises, "f").get(userAddress);
|
|
1342
|
+
if (inFlight) {
|
|
1343
|
+
await inFlight;
|
|
1344
|
+
return;
|
|
1345
|
+
}
|
|
1346
|
+
const startGeneration = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateSubscriptionGeneration, "f");
|
|
1347
|
+
const promise = (async () => {
|
|
1348
|
+
await __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_clientService, "f").ensureSubscriptionClient(__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_walletService, "f").createWalletAdapter());
|
|
1349
|
+
const subscriptionClient = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_clientService, "f").getSubscriptionClient();
|
|
1350
|
+
if (!subscriptionClient) {
|
|
1351
|
+
throw new Error('SubscriptionClient not available');
|
|
1352
|
+
}
|
|
1353
|
+
const subscription = await subscriptionClient.spotState({ user: userAddress }, (event) => {
|
|
1354
|
+
try {
|
|
1355
|
+
if (event.user.toLowerCase() !== userAddress.toLowerCase()) {
|
|
1356
|
+
return;
|
|
1357
|
+
}
|
|
1358
|
+
// Invalidate any in-flight REST refreshSpotState so it drops
|
|
1359
|
+
// its result instead of overwriting this fresher WS snapshot.
|
|
1360
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStateGeneration, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateGeneration, "f") + 1, "f");
|
|
1361
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotState, event.spotState, "f");
|
|
1362
|
+
// Normalize to match REST path (stores lowercase) so the
|
|
1363
|
+
// #ensureSpotState strict-equal check hits the cache regardless
|
|
1364
|
+
// of whether HL returns a checksummed or lowercase user field.
|
|
1365
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, event.user.toLowerCase(), "f");
|
|
1366
|
+
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAccountCache, "f").size > 0) {
|
|
1367
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_aggregateAndNotifySubscribers).call(this);
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
catch (error) {
|
|
1371
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.ensureSpotStateSubscription'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'spotState callback error', {
|
|
1372
|
+
user: userAddress,
|
|
1373
|
+
}));
|
|
1374
|
+
}
|
|
1375
|
+
});
|
|
1376
|
+
// Discard if cleanup ran while we were awaiting the subscription
|
|
1377
|
+
// handshake; rehydrating #spotStateSubscriptions here would leave
|
|
1378
|
+
// a stale entry that short-circuits future resubscribe attempts.
|
|
1379
|
+
if (startGeneration !== __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateSubscriptionGeneration, "f")) {
|
|
1380
|
+
await subscription.unsubscribe().catch(() => undefined);
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateSubscriptions, "f").set(userAddress, subscription);
|
|
1384
|
+
})();
|
|
1385
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateSubscriptionPromises, "f").set(userAddress, promise);
|
|
1386
|
+
try {
|
|
1387
|
+
await promise;
|
|
1388
|
+
}
|
|
1389
|
+
finally {
|
|
1390
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateSubscriptionPromises, "f").delete(userAddress);
|
|
1391
|
+
}
|
|
1234
1392
|
}, _HyperLiquidSubscriptionService_ensureSharedWebData3Subscription =
|
|
1235
1393
|
/**
|
|
1236
1394
|
* Ensure shared webData3 subscription is active (singleton pattern with multi-DEX support)
|
|
@@ -1409,7 +1567,7 @@ async function _HyperLiquidSubscriptionService_createUserDataSubscription(accoun
|
|
|
1409
1567
|
// Merge TP/SL data into positions
|
|
1410
1568
|
const positionsWithTPSL = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_mergeTPSLIntoPositions).call(this, positions, tpslMap, tpslCountMap);
|
|
1411
1569
|
// Extract account data (webData2 provides clearinghouseState)
|
|
1412
|
-
const accountState = adaptAccountStateFromSDK(data.clearinghouseState
|
|
1570
|
+
const accountState = adaptAccountStateFromSDK(data.clearinghouseState);
|
|
1413
1571
|
// Store in caches (main DEX only)
|
|
1414
1572
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexPositionsCache, "f").set(currentDexName, positionsWithTPSL);
|
|
1415
1573
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexOrdersCache, "f").set(currentDexName, orders);
|
|
@@ -1425,10 +1583,13 @@ async function _HyperLiquidSubscriptionService_createUserDataSubscription(accoun
|
|
|
1425
1583
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_oiCapsCacheInitialized, true, "f");
|
|
1426
1584
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_oiCapSubscribers, "f").forEach((callback) => callback(oiCaps));
|
|
1427
1585
|
}
|
|
1428
|
-
// Notify subscribers (no aggregation needed - only main DEX)
|
|
1586
|
+
// Notify subscribers (no aggregation needed - only main DEX).
|
|
1587
|
+
// Apply spot balance so single-DEX accounts see the same
|
|
1588
|
+
// spot-inclusive totalBalance as the HIP-3 aggregation path.
|
|
1589
|
+
const spotAdjustedAccount = addSpotBalanceToAccountState(accountState, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotState, "f"));
|
|
1429
1590
|
const positionsHash = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_hashPositions).call(this, positionsWithTPSL);
|
|
1430
1591
|
const ordersHash = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_hashOrders).call(this, orders);
|
|
1431
|
-
const accountHash = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_hashAccountState).call(this,
|
|
1592
|
+
const accountHash = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_hashAccountState).call(this, spotAdjustedAccount);
|
|
1432
1593
|
if (positionsHash !== __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedPositionsHash, "f")) {
|
|
1433
1594
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedPositions, positionsWithTPSL, "f");
|
|
1434
1595
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedPositionsHash, positionsHash, "f");
|
|
@@ -1442,9 +1603,9 @@ async function _HyperLiquidSubscriptionService_createUserDataSubscription(accoun
|
|
|
1442
1603
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_orderSubscribers, "f").forEach((callback) => callback(orders));
|
|
1443
1604
|
}
|
|
1444
1605
|
if (accountHash !== __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedAccountHash, "f")) {
|
|
1445
|
-
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedAccount,
|
|
1606
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedAccount, spotAdjustedAccount, "f");
|
|
1446
1607
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedAccountHash, accountHash, "f");
|
|
1447
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_accountSubscribers, "f").forEach((callback) => callback(
|
|
1608
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_accountSubscribers, "f").forEach((callback) => callback(spotAdjustedAccount));
|
|
1448
1609
|
}
|
|
1449
1610
|
}
|
|
1450
1611
|
catch (error) {
|
|
@@ -1540,7 +1701,7 @@ async function _HyperLiquidSubscriptionService_createClearinghouseSubscription(u
|
|
|
1540
1701
|
positionsWithTPSL = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_mergeTPSLIntoPositions).call(this, positions, tpslMap, tpslCountMap);
|
|
1541
1702
|
}
|
|
1542
1703
|
// Update account state
|
|
1543
|
-
const accountState = adaptAccountStateFromSDK(data.clearinghouseState
|
|
1704
|
+
const accountState = adaptAccountStateFromSDK(data.clearinghouseState);
|
|
1544
1705
|
// Update caches
|
|
1545
1706
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexPositionsCache, "f").set(cacheKey, positionsWithTPSL);
|
|
1546
1707
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAccountCache, "f").set(cacheKey, accountState);
|
|
@@ -1718,6 +1879,20 @@ async function _HyperLiquidSubscriptionService_createOpenOrdersSubscription(user
|
|
|
1718
1879
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_webData3Subscriptions, "f").clear();
|
|
1719
1880
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_webData3SubscriptionPromise, undefined, "f");
|
|
1720
1881
|
}
|
|
1882
|
+
// Cleanup spotState subscriptions (per-user). Bump generation +
|
|
1883
|
+
// drop in-flight promises so a racing #ensureSpotStateSubscription
|
|
1884
|
+
// continuation discards its subscription rather than rehydrating
|
|
1885
|
+
// #spotStateSubscriptions after this clear.
|
|
1886
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStateSubscriptionGeneration, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateSubscriptionGeneration, "f") + 1, "f");
|
|
1887
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateSubscriptionPromises, "f").clear();
|
|
1888
|
+
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateSubscriptions, "f").size > 0) {
|
|
1889
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateSubscriptions, "f").forEach((subscription, user) => {
|
|
1890
|
+
subscription.unsubscribe().catch((error) => {
|
|
1891
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.cleanupSharedWebData3ISubscription'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'cleanupSharedWebData3ISubscription.spotState', { user }));
|
|
1892
|
+
});
|
|
1893
|
+
});
|
|
1894
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateSubscriptions, "f").clear();
|
|
1895
|
+
}
|
|
1721
1896
|
// Cleanup individual subscriptions (clearinghouseState + openOrders)
|
|
1722
1897
|
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_clearinghouseStateSubscriptions, "f").size > 0) {
|
|
1723
1898
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_clearinghouseStateSubscriptions, "f").forEach((subscription, dexName) => {
|
|
@@ -1758,6 +1933,13 @@ async function _HyperLiquidSubscriptionService_createOpenOrdersSubscription(user
|
|
|
1758
1933
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedPositions, null, "f");
|
|
1759
1934
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedOrders, null, "f");
|
|
1760
1935
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedAccount, null, "f");
|
|
1936
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotState, null, "f");
|
|
1937
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, null, "f");
|
|
1938
|
+
// Bump generation so any in-flight spot fetch from a prior user discards
|
|
1939
|
+
// its result instead of re-populating the cache post-cleanup.
|
|
1940
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStateGeneration, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateGeneration, "f") + 1, "f");
|
|
1941
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStatePromise, undefined, "f");
|
|
1942
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStatePromiseUserAddress, undefined, "f");
|
|
1761
1943
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_ordersCacheInitialized, false, "f"); // Reset cache initialization flag
|
|
1762
1944
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_positionsCacheInitialized, false, "f"); // Reset cache initialization flag
|
|
1763
1945
|
// Clear hash caches
|