@metamask-previews/perps-controller 4.0.0-preview-56dd1249f → 4.0.0-preview-a89313ea9
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 +0 -16
- package/dist/constants/eventNames.cjs +0 -5
- package/dist/constants/eventNames.cjs.map +1 -1
- package/dist/constants/eventNames.d.cts +0 -4
- package/dist/constants/eventNames.d.cts.map +1 -1
- package/dist/constants/eventNames.d.mts +0 -4
- package/dist/constants/eventNames.d.mts.map +1 -1
- package/dist/constants/eventNames.mjs +0 -5
- package/dist/constants/eventNames.mjs.map +1 -1
- package/dist/providers/HyperLiquidProvider.cjs +57 -230
- package/dist/providers/HyperLiquidProvider.cjs.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.cts +1 -1
- package/dist/providers/HyperLiquidProvider.d.cts.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.mts +1 -1
- package/dist/providers/HyperLiquidProvider.d.mts.map +1 -1
- package/dist/providers/HyperLiquidProvider.mjs +57 -230
- package/dist/providers/HyperLiquidProvider.mjs.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.cjs +20 -108
- package/dist/services/HyperLiquidSubscriptionService.cjs.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.d.cts +0 -19
- package/dist/services/HyperLiquidSubscriptionService.d.cts.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.d.mts +0 -19
- package/dist/services/HyperLiquidSubscriptionService.d.mts.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.mjs +20 -108
- package/dist/services/HyperLiquidSubscriptionService.mjs.map +1 -1
- package/dist/services/HyperLiquidWalletService.cjs +0 -20
- package/dist/services/HyperLiquidWalletService.cjs.map +1 -1
- package/dist/services/HyperLiquidWalletService.d.cts +0 -6
- package/dist/services/HyperLiquidWalletService.d.cts.map +1 -1
- package/dist/services/HyperLiquidWalletService.d.mts +0 -6
- package/dist/services/HyperLiquidWalletService.d.mts.map +1 -1
- package/dist/services/HyperLiquidWalletService.mjs +2 -22
- package/dist/services/HyperLiquidWalletService.mjs.map +1 -1
- package/dist/services/TradingReadinessCache.cjs +16 -16
- package/dist/services/TradingReadinessCache.cjs.map +1 -1
- package/dist/services/TradingReadinessCache.d.cts +12 -12
- package/dist/services/TradingReadinessCache.d.mts +12 -12
- package/dist/services/TradingReadinessCache.mjs +16 -16
- package/dist/services/TradingReadinessCache.mjs.map +1 -1
- package/dist/types/hyperliquid-types.cjs +0 -39
- package/dist/types/hyperliquid-types.cjs.map +1 -1
- package/dist/types/hyperliquid-types.d.cts +2 -34
- package/dist/types/hyperliquid-types.d.cts.map +1 -1
- package/dist/types/hyperliquid-types.d.mts +2 -34
- package/dist/types/hyperliquid-types.d.mts.map +1 -1
- package/dist/types/hyperliquid-types.mjs +1 -37
- package/dist/types/hyperliquid-types.mjs.map +1 -1
- package/dist/types/index.cjs +0 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +1 -2
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.mts +1 -2
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs +0 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/accountUtils.cjs +8 -20
- package/dist/utils/accountUtils.cjs.map +1 -1
- package/dist/utils/accountUtils.d.cts +5 -9
- package/dist/utils/accountUtils.d.cts.map +1 -1
- package/dist/utils/accountUtils.d.mts +5 -9
- package/dist/utils/accountUtils.d.mts.map +1 -1
- package/dist/utils/accountUtils.mjs +8 -20
- package/dist/utils/accountUtils.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -10,13 +10,12 @@ 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, _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,
|
|
13
|
+
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;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.HyperLiquidSubscriptionService = void 0;
|
|
16
16
|
const utils_1 = require("@metamask/utils");
|
|
17
17
|
const perpsConfig_1 = require("../constants/perpsConfig.cjs");
|
|
18
18
|
const types_1 = require("../types/index.cjs");
|
|
19
|
-
const hyperliquid_types_1 = require("../types/hyperliquid-types.cjs");
|
|
20
19
|
const accountUtils_1 = require("../utils/accountUtils.cjs");
|
|
21
20
|
const errorUtils_1 = require("../utils/errorUtils.cjs");
|
|
22
21
|
const hyperLiquidAdapter_1 = require("../utils/hyperLiquidAdapter.cjs");
|
|
@@ -89,7 +88,6 @@ class HyperLiquidSubscriptionService {
|
|
|
89
88
|
_HyperLiquidSubscriptionService_dexAccountCache.set(this, new Map()); // Per-DEX account state
|
|
90
89
|
_HyperLiquidSubscriptionService_cachedSpotState.set(this, null);
|
|
91
90
|
_HyperLiquidSubscriptionService_cachedSpotStateUserAddress.set(this, null);
|
|
92
|
-
_HyperLiquidSubscriptionService_abstractionModeByUser.set(this, new Map());
|
|
93
91
|
_HyperLiquidSubscriptionService_spotStatePromise.set(this, void 0);
|
|
94
92
|
_HyperLiquidSubscriptionService_spotStatePromiseUserAddress.set(this, void 0);
|
|
95
93
|
// Monotonic token bumped on cleanUp/clearAll and on each new fetch.
|
|
@@ -273,34 +271,6 @@ class HyperLiquidSubscriptionService {
|
|
|
273
271
|
}
|
|
274
272
|
}
|
|
275
273
|
}
|
|
276
|
-
/**
|
|
277
|
-
* Record a user's resolved abstraction mode and immediately re-aggregate.
|
|
278
|
-
* Call after the provider has confirmed the on-chain mode (already-enabled
|
|
279
|
-
* or just-migrated). Setting the mode (rather than deleting it) ensures
|
|
280
|
-
* `hyperLiquidModeFoldsSpot` returns the correct fold decision on the next
|
|
281
|
-
* aggregation — a delete would leave the user pinned to fail-closed
|
|
282
|
-
* (no fold) until the next refresh, under-reporting balance for Unified
|
|
283
|
-
* and Portfolio Margin users.
|
|
284
|
-
*
|
|
285
|
-
* Seals `#cachedSpotStateUserAddress` if spot is already cached for this
|
|
286
|
-
* user (fast-path optimization for the next `#ensureSpotState`). Skips the
|
|
287
|
-
* seal if spot belongs to a different user — the next refresh will sort
|
|
288
|
-
* everything out.
|
|
289
|
-
*
|
|
290
|
-
* @param userAddress - The EVM address whose mode is being recorded.
|
|
291
|
-
* @param mode - The current abstraction mode for this user.
|
|
292
|
-
*/
|
|
293
|
-
setUserAbstractionMode(userAddress, mode) {
|
|
294
|
-
const lower = userAddress.toLowerCase();
|
|
295
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeByUser, "f").set(lower, mode);
|
|
296
|
-
// No need to seal #cachedSpotStateUserAddress here — the WS handler and
|
|
297
|
-
// #refreshSpotState success path always set it to the spot owner. The
|
|
298
|
-
// re-aggregation below will pick up the new mode via the now-populated
|
|
299
|
-
// #abstractionModeByUser entry.
|
|
300
|
-
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAccountCache, "f").size > 0) {
|
|
301
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_aggregateAndNotifySubscribers).call(this);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
274
|
/**
|
|
305
275
|
* Subscribe to live price updates with singleton subscription architecture
|
|
306
276
|
* Uses allMids for fast price updates and predictedFundings for accurate funding rates
|
|
@@ -914,7 +884,6 @@ class HyperLiquidSubscriptionService {
|
|
|
914
884
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAccountCache, "f").clear();
|
|
915
885
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotState, null, "f");
|
|
916
886
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, null, "f");
|
|
917
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeByUser, "f").clear();
|
|
918
887
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStateGeneration, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateGeneration, "f") + 1, "f");
|
|
919
888
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStatePromise, undefined, "f");
|
|
920
889
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStatePromiseUserAddress, undefined, "f");
|
|
@@ -997,7 +966,7 @@ class HyperLiquidSubscriptionService {
|
|
|
997
966
|
}
|
|
998
967
|
}
|
|
999
968
|
exports.HyperLiquidSubscriptionService = HyperLiquidSubscriptionService;
|
|
1000
|
-
_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(),
|
|
969
|
+
_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) {
|
|
1001
970
|
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_isClearing, "f")) {
|
|
1002
971
|
return;
|
|
1003
972
|
}
|
|
@@ -1113,7 +1082,7 @@ async function _HyperLiquidSubscriptionService_waitForDexDiscovery(timeoutMs = 5
|
|
|
1113
1082
|
.map((ord) => `${ord.symbol}:${ord.side}:${ord.size}:${ord.price}:${ord.orderType}`)
|
|
1114
1083
|
.join('|');
|
|
1115
1084
|
}, _HyperLiquidSubscriptionService_hashAccountState = function _HyperLiquidSubscriptionService_hashAccountState(account) {
|
|
1116
|
-
return `${account.availableBalance}:${account.
|
|
1085
|
+
return `${account.availableBalance}:${account.totalBalance}:${account.marginUsed}:${account.unrealizedPnl}`;
|
|
1117
1086
|
}, _HyperLiquidSubscriptionService_extractTPSLFromOrders = function _HyperLiquidSubscriptionService_extractTPSLFromOrders(orders, positions, cachedProcessedOrders) {
|
|
1118
1087
|
const tpslMap = new Map();
|
|
1119
1088
|
const tpslCountMap = new Map();
|
|
@@ -1306,26 +1275,11 @@ async function _HyperLiquidSubscriptionService_waitForDexDiscovery(timeoutMs = 5
|
|
|
1306
1275
|
unrealizedPnl: totalUnrealizedPnl.toString(),
|
|
1307
1276
|
subAccountBreakdown,
|
|
1308
1277
|
returnOnEquity,
|
|
1309
|
-
}, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotState, "f")
|
|
1310
|
-
}, _HyperLiquidSubscriptionService_getAbstractionModeForUser = function _HyperLiquidSubscriptionService_getAbstractionModeForUser(userAddress) {
|
|
1311
|
-
if (!userAddress) {
|
|
1312
|
-
return null;
|
|
1313
|
-
}
|
|
1314
|
-
return __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeByUser, "f").get(userAddress.toLowerCase()) ?? null;
|
|
1315
|
-
}, _HyperLiquidSubscriptionService_getSpotBalanceOptions = function _HyperLiquidSubscriptionService_getSpotBalanceOptions() {
|
|
1316
|
-
return {
|
|
1317
|
-
foldIntoCollateral: (0, hyperliquid_types_1.hyperLiquidModeFoldsSpot)(__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getAbstractionModeForUser).call(this, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, "f"))),
|
|
1318
|
-
};
|
|
1278
|
+
}, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotState, "f"));
|
|
1319
1279
|
}, _HyperLiquidSubscriptionService_ensureSpotState = async function _HyperLiquidSubscriptionService_ensureSpotState(accountId) {
|
|
1320
1280
|
const userAddress = await __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_walletService, "f").getUserAddressWithDefault(accountId);
|
|
1321
|
-
const lowerUserAddress = userAddress.toLowerCase();
|
|
1322
|
-
// Fast-path only when we have spot for this user AND a resolved
|
|
1323
|
-
// abstraction mode. Without the mode, `#getSpotBalanceOptions` would
|
|
1324
|
-
// fall back to fail-closed (no fold), under-reporting Unified /
|
|
1325
|
-
// Portfolio Margin balances — force a refresh instead.
|
|
1326
1281
|
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotState, "f") &&
|
|
1327
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, "f") ===
|
|
1328
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeByUser, "f").has(lowerUserAddress)) {
|
|
1282
|
+
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, "f") === userAddress) {
|
|
1329
1283
|
return;
|
|
1330
1284
|
}
|
|
1331
1285
|
// Share an in-flight fetch only if it targets the same user.
|
|
@@ -1359,60 +1313,20 @@ async function _HyperLiquidSubscriptionService_waitForDexDiscovery(timeoutMs = 5
|
|
|
1359
1313
|
// instance subscribeToAccount can race ahead of the webData3 path,
|
|
1360
1314
|
// so initialize here first — subsequent calls are no-ops.
|
|
1361
1315
|
await __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_clientService, "f").ensureSubscriptionClient(__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_walletService, "f").createWalletAdapter());
|
|
1362
|
-
// Don't bail here even if generation has bumped (e.g. WS spot snapshot
|
|
1363
|
-
// arrived while we awaited the subscription client). We still need to
|
|
1364
|
-
// resolve `userAbstraction` for this user — the mode is user-keyed,
|
|
1365
|
-
// independent of the spot generation, and the post-fetch path below
|
|
1366
|
-
// correctly handles the generation-changed case (seal + re-aggregate
|
|
1367
|
-
// instead of overwriting WS spot).
|
|
1368
|
-
const infoClient = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_clientService, "f").getInfoClient();
|
|
1369
|
-
const [spotResult, abstractionResult] = await Promise.allSettled([
|
|
1370
|
-
infoClient.spotClearinghouseState({
|
|
1371
|
-
user: userAddress,
|
|
1372
|
-
}),
|
|
1373
|
-
infoClient.userAbstraction({ user: userAddress }),
|
|
1374
|
-
]);
|
|
1375
|
-
const lowerUserAddress = userAddress.toLowerCase();
|
|
1376
|
-
// Record the abstraction mode regardless of generation. The mode is
|
|
1377
|
-
// user-keyed (independent of the spot snapshot generation) so a WS
|
|
1378
|
-
// push that bumped generation while we awaited cannot make this
|
|
1379
|
-
// result wrong for this user. Discarding it would strand
|
|
1380
|
-
// Unified / Portfolio Margin users at fail-closed until another
|
|
1381
|
-
// subscribe runs — exactly the race the WS-vs-REST guard creates.
|
|
1382
|
-
if (abstractionResult.status === 'fulfilled') {
|
|
1383
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeByUser, "f").set(lowerUserAddress, abstractionResult.value);
|
|
1384
|
-
}
|
|
1385
|
-
else {
|
|
1386
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_deps, "f").debugLogger.log('User abstraction fetch failed during spot refresh; spot fold disabled until the mode resolves', {
|
|
1387
|
-
error: (0, errorUtils_1.ensureError)(abstractionResult.reason, 'HyperLiquidSubscriptionService.refreshSpotState.abstraction').message,
|
|
1388
|
-
});
|
|
1389
|
-
}
|
|
1390
1316
|
if (generation !== __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateGeneration, "f")) {
|
|
1391
|
-
// A WS push superseded our spot snapshot. The earlier WS-driven
|
|
1392
|
-
// aggregation ran with a null mode (fail-closed), so subscribers
|
|
1393
|
-
// may currently be under-reported. If we just resolved the mode
|
|
1394
|
-
// for the user whose spot is cached (strict match — null cache
|
|
1395
|
-
// owner could mean cleanUp ran for a different user), re-aggregate
|
|
1396
|
-
// now so the active subscribers immediately see the correct fold.
|
|
1397
|
-
if (abstractionResult.status === 'fulfilled' &&
|
|
1398
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotState, "f") &&
|
|
1399
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, "f") === lowerUserAddress) {
|
|
1400
|
-
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAccountCache, "f").size > 0) {
|
|
1401
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_aggregateAndNotifySubscribers).call(this);
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
1317
|
return;
|
|
1405
1318
|
}
|
|
1406
|
-
|
|
1407
|
-
|
|
1319
|
+
const infoClient = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_clientService, "f").getInfoClient();
|
|
1320
|
+
const result = await infoClient.spotClearinghouseState({
|
|
1321
|
+
user: userAddress,
|
|
1322
|
+
});
|
|
1323
|
+
// Drop stale results: cleanUp/clearAll or a newer fetch bumped generation.
|
|
1324
|
+
// Writing here would re-populate the cache with a different user's data.
|
|
1325
|
+
if (generation !== __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateGeneration, "f")) {
|
|
1326
|
+
return;
|
|
1408
1327
|
}
|
|
1409
|
-
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotState,
|
|
1410
|
-
|
|
1411
|
-
// and recovery branches can identify whose data is cached. Fast-path
|
|
1412
|
-
// eligibility is gated separately by #abstractionModeByUser.has(...);
|
|
1413
|
-
// a transient abstraction failure leaves the user out of the map and
|
|
1414
|
-
// the next #ensureSpotState retries both fetches.
|
|
1415
|
-
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, lowerUserAddress, "f");
|
|
1328
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotState, result, "f");
|
|
1329
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, userAddress, "f");
|
|
1416
1330
|
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAccountCache, "f").size > 0) {
|
|
1417
1331
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_aggregateAndNotifySubscribers).call(this);
|
|
1418
1332
|
}
|
|
@@ -1449,11 +1363,10 @@ async function _HyperLiquidSubscriptionService_waitForDexDiscovery(timeoutMs = 5
|
|
|
1449
1363
|
// its result instead of overwriting this fresher WS snapshot.
|
|
1450
1364
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStateGeneration, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateGeneration, "f") + 1, "f");
|
|
1451
1365
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotState, event.spotState, "f");
|
|
1452
|
-
//
|
|
1453
|
-
//
|
|
1454
|
-
//
|
|
1455
|
-
|
|
1456
|
-
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, userAddress.toLowerCase(), "f");
|
|
1366
|
+
// Normalize to match REST path (stores lowercase) so the
|
|
1367
|
+
// #ensureSpotState strict-equal check hits the cache regardless
|
|
1368
|
+
// of whether HL returns a checksummed or lowercase user field.
|
|
1369
|
+
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, event.user.toLowerCase(), "f");
|
|
1457
1370
|
if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAccountCache, "f").size > 0) {
|
|
1458
1371
|
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_aggregateAndNotifySubscribers).call(this);
|
|
1459
1372
|
}
|
|
@@ -1677,7 +1590,7 @@ async function _HyperLiquidSubscriptionService_createUserDataSubscription(accoun
|
|
|
1677
1590
|
// Notify subscribers (no aggregation needed - only main DEX).
|
|
1678
1591
|
// Apply spot balance so single-DEX accounts see the same
|
|
1679
1592
|
// spot-inclusive totalBalance as the HIP-3 aggregation path.
|
|
1680
|
-
const spotAdjustedAccount = (0, accountUtils_1.addSpotBalanceToAccountState)(accountState, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotState, "f")
|
|
1593
|
+
const spotAdjustedAccount = (0, accountUtils_1.addSpotBalanceToAccountState)(accountState, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotState, "f"));
|
|
1681
1594
|
const positionsHash = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_hashPositions).call(this, positionsWithTPSL);
|
|
1682
1595
|
const ordersHash = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_hashOrders).call(this, orders);
|
|
1683
1596
|
const accountHash = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_hashAccountState).call(this, spotAdjustedAccount);
|
|
@@ -2026,7 +1939,6 @@ async function _HyperLiquidSubscriptionService_createOpenOrdersSubscription(user
|
|
|
2026
1939
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedAccount, null, "f");
|
|
2027
1940
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotState, null, "f");
|
|
2028
1941
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, null, "f");
|
|
2029
|
-
__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeByUser, "f").clear();
|
|
2030
1942
|
// Bump generation so any in-flight spot fetch from a prior user discards
|
|
2031
1943
|
// its result instead of re-populating the cache post-cleanup.
|
|
2032
1944
|
__classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStateGeneration, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateGeneration, "f") + 1, "f");
|