@metamask-previews/perps-controller 4.0.0-preview-e0eba6dbb → 4.0.0-preview-56dd1249f

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/constants/eventNames.cjs +5 -0
  3. package/dist/constants/eventNames.cjs.map +1 -1
  4. package/dist/constants/eventNames.d.cts +4 -0
  5. package/dist/constants/eventNames.d.cts.map +1 -1
  6. package/dist/constants/eventNames.d.mts +4 -0
  7. package/dist/constants/eventNames.d.mts.map +1 -1
  8. package/dist/constants/eventNames.mjs +5 -0
  9. package/dist/constants/eventNames.mjs.map +1 -1
  10. package/dist/providers/HyperLiquidProvider.cjs +230 -57
  11. package/dist/providers/HyperLiquidProvider.cjs.map +1 -1
  12. package/dist/providers/HyperLiquidProvider.d.cts +1 -1
  13. package/dist/providers/HyperLiquidProvider.d.cts.map +1 -1
  14. package/dist/providers/HyperLiquidProvider.d.mts +1 -1
  15. package/dist/providers/HyperLiquidProvider.d.mts.map +1 -1
  16. package/dist/providers/HyperLiquidProvider.mjs +230 -57
  17. package/dist/providers/HyperLiquidProvider.mjs.map +1 -1
  18. package/dist/services/HyperLiquidSubscriptionService.cjs +108 -20
  19. package/dist/services/HyperLiquidSubscriptionService.cjs.map +1 -1
  20. package/dist/services/HyperLiquidSubscriptionService.d.cts +19 -0
  21. package/dist/services/HyperLiquidSubscriptionService.d.cts.map +1 -1
  22. package/dist/services/HyperLiquidSubscriptionService.d.mts +19 -0
  23. package/dist/services/HyperLiquidSubscriptionService.d.mts.map +1 -1
  24. package/dist/services/HyperLiquidSubscriptionService.mjs +108 -20
  25. package/dist/services/HyperLiquidSubscriptionService.mjs.map +1 -1
  26. package/dist/services/HyperLiquidWalletService.cjs +20 -0
  27. package/dist/services/HyperLiquidWalletService.cjs.map +1 -1
  28. package/dist/services/HyperLiquidWalletService.d.cts +6 -0
  29. package/dist/services/HyperLiquidWalletService.d.cts.map +1 -1
  30. package/dist/services/HyperLiquidWalletService.d.mts +6 -0
  31. package/dist/services/HyperLiquidWalletService.d.mts.map +1 -1
  32. package/dist/services/HyperLiquidWalletService.mjs +22 -2
  33. package/dist/services/HyperLiquidWalletService.mjs.map +1 -1
  34. package/dist/services/TradingReadinessCache.cjs +16 -16
  35. package/dist/services/TradingReadinessCache.cjs.map +1 -1
  36. package/dist/services/TradingReadinessCache.d.cts +12 -12
  37. package/dist/services/TradingReadinessCache.d.mts +12 -12
  38. package/dist/services/TradingReadinessCache.mjs +16 -16
  39. package/dist/services/TradingReadinessCache.mjs.map +1 -1
  40. package/dist/types/hyperliquid-types.cjs +39 -0
  41. package/dist/types/hyperliquid-types.cjs.map +1 -1
  42. package/dist/types/hyperliquid-types.d.cts +34 -2
  43. package/dist/types/hyperliquid-types.d.cts.map +1 -1
  44. package/dist/types/hyperliquid-types.d.mts +34 -2
  45. package/dist/types/hyperliquid-types.d.mts.map +1 -1
  46. package/dist/types/hyperliquid-types.mjs +37 -1
  47. package/dist/types/hyperliquid-types.mjs.map +1 -1
  48. package/dist/types/index.cjs +1 -0
  49. package/dist/types/index.cjs.map +1 -1
  50. package/dist/types/index.d.cts +2 -1
  51. package/dist/types/index.d.cts.map +1 -1
  52. package/dist/types/index.d.mts +2 -1
  53. package/dist/types/index.d.mts.map +1 -1
  54. package/dist/types/index.mjs +1 -0
  55. package/dist/types/index.mjs.map +1 -1
  56. package/dist/utils/accountUtils.cjs +20 -8
  57. package/dist/utils/accountUtils.cjs.map +1 -1
  58. package/dist/utils/accountUtils.d.cts +9 -5
  59. package/dist/utils/accountUtils.d.cts.map +1 -1
  60. package/dist/utils/accountUtils.d.mts +9 -5
  61. package/dist/utils/accountUtils.d.mts.map +1 -1
  62. package/dist/utils/accountUtils.mjs +20 -8
  63. package/dist/utils/accountUtils.mjs.map +1 -1
  64. package/package.json +3 -3
@@ -10,12 +10,13 @@ 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, _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
+ 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_abstractionModeByUser, _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_getAbstractionModeForUser, _HyperLiquidSubscriptionService_getSpotBalanceOptions, _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");
19
20
  const accountUtils_1 = require("../utils/accountUtils.cjs");
20
21
  const errorUtils_1 = require("../utils/errorUtils.cjs");
21
22
  const hyperLiquidAdapter_1 = require("../utils/hyperLiquidAdapter.cjs");
@@ -88,6 +89,7 @@ class HyperLiquidSubscriptionService {
88
89
  _HyperLiquidSubscriptionService_dexAccountCache.set(this, new Map()); // Per-DEX account state
89
90
  _HyperLiquidSubscriptionService_cachedSpotState.set(this, null);
90
91
  _HyperLiquidSubscriptionService_cachedSpotStateUserAddress.set(this, null);
92
+ _HyperLiquidSubscriptionService_abstractionModeByUser.set(this, new Map());
91
93
  _HyperLiquidSubscriptionService_spotStatePromise.set(this, void 0);
92
94
  _HyperLiquidSubscriptionService_spotStatePromiseUserAddress.set(this, void 0);
93
95
  // Monotonic token bumped on cleanUp/clearAll and on each new fetch.
@@ -271,6 +273,34 @@ class HyperLiquidSubscriptionService {
271
273
  }
272
274
  }
273
275
  }
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
+ }
274
304
  /**
275
305
  * Subscribe to live price updates with singleton subscription architecture
276
306
  * Uses allMids for fast price updates and predictedFundings for accurate funding rates
@@ -884,6 +914,7 @@ class HyperLiquidSubscriptionService {
884
914
  __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAccountCache, "f").clear();
885
915
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotState, null, "f");
886
916
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, null, "f");
917
+ __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeByUser, "f").clear();
887
918
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStateGeneration, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateGeneration, "f") + 1, "f");
888
919
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStatePromise, undefined, "f");
889
920
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStatePromiseUserAddress, undefined, "f");
@@ -966,7 +997,7 @@ class HyperLiquidSubscriptionService {
966
997
  }
967
998
  }
968
999
  exports.HyperLiquidSubscriptionService = HyperLiquidSubscriptionService;
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) {
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(), _HyperLiquidSubscriptionService_abstractionModeByUser = 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) {
970
1001
  if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_isClearing, "f")) {
971
1002
  return;
972
1003
  }
@@ -1082,7 +1113,7 @@ async function _HyperLiquidSubscriptionService_waitForDexDiscovery(timeoutMs = 5
1082
1113
  .map((ord) => `${ord.symbol}:${ord.side}:${ord.size}:${ord.price}:${ord.orderType}`)
1083
1114
  .join('|');
1084
1115
  }, _HyperLiquidSubscriptionService_hashAccountState = function _HyperLiquidSubscriptionService_hashAccountState(account) {
1085
- return `${account.availableBalance}:${account.totalBalance}:${account.marginUsed}:${account.unrealizedPnl}`;
1116
+ return `${account.availableBalance}:${account.availableToTradeBalance ?? ''}:${account.totalBalance}:${account.marginUsed}:${account.unrealizedPnl}`;
1086
1117
  }, _HyperLiquidSubscriptionService_extractTPSLFromOrders = function _HyperLiquidSubscriptionService_extractTPSLFromOrders(orders, positions, cachedProcessedOrders) {
1087
1118
  const tpslMap = new Map();
1088
1119
  const tpslCountMap = new Map();
@@ -1275,11 +1306,26 @@ async function _HyperLiquidSubscriptionService_waitForDexDiscovery(timeoutMs = 5
1275
1306
  unrealizedPnl: totalUnrealizedPnl.toString(),
1276
1307
  subAccountBreakdown,
1277
1308
  returnOnEquity,
1278
- }, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotState, "f"));
1309
+ }, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotState, "f"), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getSpotBalanceOptions).call(this));
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
+ };
1279
1319
  }, _HyperLiquidSubscriptionService_ensureSpotState = async function _HyperLiquidSubscriptionService_ensureSpotState(accountId) {
1280
1320
  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.
1281
1326
  if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotState, "f") &&
1282
- __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, "f") === userAddress) {
1327
+ __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, "f") === lowerUserAddress &&
1328
+ __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeByUser, "f").has(lowerUserAddress)) {
1283
1329
  return;
1284
1330
  }
1285
1331
  // Share an in-flight fetch only if it targets the same user.
@@ -1313,20 +1359,60 @@ async function _HyperLiquidSubscriptionService_waitForDexDiscovery(timeoutMs = 5
1313
1359
  // instance subscribeToAccount can race ahead of the webData3 path,
1314
1360
  // so initialize here first — subsequent calls are no-ops.
1315
1361
  await __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_clientService, "f").ensureSubscriptionClient(__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_walletService, "f").createWalletAdapter());
1316
- if (generation !== __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateGeneration, "f")) {
1317
- return;
1318
- }
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).
1319
1368
  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.
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
+ }
1325
1390
  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
+ }
1326
1404
  return;
1327
1405
  }
1328
- __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotState, result, "f");
1329
- __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, userAddress, "f");
1406
+ if (spotResult.status === 'rejected') {
1407
+ throw spotResult.reason;
1408
+ }
1409
+ __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotState, spotResult.value, "f");
1410
+ // Always record the spot owner so subsequent #ensureSpotState calls
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");
1330
1416
  if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAccountCache, "f").size > 0) {
1331
1417
  __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_aggregateAndNotifySubscribers).call(this);
1332
1418
  }
@@ -1363,10 +1449,11 @@ async function _HyperLiquidSubscriptionService_waitForDexDiscovery(timeoutMs = 5
1363
1449
  // its result instead of overwriting this fresher WS snapshot.
1364
1450
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStateGeneration, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateGeneration, "f") + 1, "f");
1365
1451
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotState, event.spotState, "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");
1452
+ // Always record the spot owner so subsequent generation guards
1453
+ // and recovery branches can identify whose data is cached.
1454
+ // Fast-path eligibility is gated separately in #ensureSpotState
1455
+ // by checking #abstractionModeByUser.has(...).
1456
+ __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, userAddress.toLowerCase(), "f");
1370
1457
  if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAccountCache, "f").size > 0) {
1371
1458
  __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_aggregateAndNotifySubscribers).call(this);
1372
1459
  }
@@ -1590,7 +1677,7 @@ async function _HyperLiquidSubscriptionService_createUserDataSubscription(accoun
1590
1677
  // Notify subscribers (no aggregation needed - only main DEX).
1591
1678
  // Apply spot balance so single-DEX accounts see the same
1592
1679
  // spot-inclusive totalBalance as the HIP-3 aggregation path.
1593
- const spotAdjustedAccount = (0, accountUtils_1.addSpotBalanceToAccountState)(accountState, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotState, "f"));
1680
+ const spotAdjustedAccount = (0, accountUtils_1.addSpotBalanceToAccountState)(accountState, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotState, "f"), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getSpotBalanceOptions).call(this));
1594
1681
  const positionsHash = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_hashPositions).call(this, positionsWithTPSL);
1595
1682
  const ordersHash = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_hashOrders).call(this, orders);
1596
1683
  const accountHash = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_hashAccountState).call(this, spotAdjustedAccount);
@@ -1939,6 +2026,7 @@ async function _HyperLiquidSubscriptionService_createOpenOrdersSubscription(user
1939
2026
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedAccount, null, "f");
1940
2027
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotState, null, "f");
1941
2028
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, null, "f");
2029
+ __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeByUser, "f").clear();
1942
2030
  // Bump generation so any in-flight spot fetch from a prior user discards
1943
2031
  // its result instead of re-populating the cache post-cleanup.
1944
2032
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStateGeneration, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateGeneration, "f") + 1, "f");