@metamask-previews/perps-controller 5.0.0-preview-4e0ae1bc9 → 5.0.0-preview-bd0d4d2e9

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 (76) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/constants/hyperLiquidConfig.cjs +1 -1
  3. package/dist/constants/hyperLiquidConfig.cjs.map +1 -1
  4. package/dist/constants/hyperLiquidConfig.d.cts +1 -1
  5. package/dist/constants/hyperLiquidConfig.d.mts +1 -1
  6. package/dist/constants/hyperLiquidConfig.mjs +1 -1
  7. package/dist/constants/hyperLiquidConfig.mjs.map +1 -1
  8. package/dist/constants/perpsConfig.cjs +15 -3
  9. package/dist/constants/perpsConfig.cjs.map +1 -1
  10. package/dist/constants/perpsConfig.d.cts +8 -1
  11. package/dist/constants/perpsConfig.d.cts.map +1 -1
  12. package/dist/constants/perpsConfig.d.mts +8 -1
  13. package/dist/constants/perpsConfig.d.mts.map +1 -1
  14. package/dist/constants/perpsConfig.mjs +14 -2
  15. package/dist/constants/perpsConfig.mjs.map +1 -1
  16. package/dist/providers/HyperLiquidProvider.cjs +33 -21
  17. package/dist/providers/HyperLiquidProvider.cjs.map +1 -1
  18. package/dist/providers/HyperLiquidProvider.d.cts.map +1 -1
  19. package/dist/providers/HyperLiquidProvider.d.mts.map +1 -1
  20. package/dist/providers/HyperLiquidProvider.mjs +33 -21
  21. package/dist/providers/HyperLiquidProvider.mjs.map +1 -1
  22. package/dist/services/HyperLiquidSubscriptionService.cjs +127 -27
  23. package/dist/services/HyperLiquidSubscriptionService.cjs.map +1 -1
  24. package/dist/services/HyperLiquidSubscriptionService.d.cts +4 -12
  25. package/dist/services/HyperLiquidSubscriptionService.d.cts.map +1 -1
  26. package/dist/services/HyperLiquidSubscriptionService.d.mts +4 -12
  27. package/dist/services/HyperLiquidSubscriptionService.d.mts.map +1 -1
  28. package/dist/services/HyperLiquidSubscriptionService.mjs +128 -28
  29. package/dist/services/HyperLiquidSubscriptionService.mjs.map +1 -1
  30. package/dist/types/hyperliquid-types.cjs +11 -8
  31. package/dist/types/hyperliquid-types.cjs.map +1 -1
  32. package/dist/types/hyperliquid-types.d.cts +24 -9
  33. package/dist/types/hyperliquid-types.d.cts.map +1 -1
  34. package/dist/types/hyperliquid-types.d.mts +24 -9
  35. package/dist/types/hyperliquid-types.d.mts.map +1 -1
  36. package/dist/types/hyperliquid-types.mjs +11 -8
  37. package/dist/types/hyperliquid-types.mjs.map +1 -1
  38. package/dist/types/index.cjs.map +1 -1
  39. package/dist/types/index.d.cts +26 -3
  40. package/dist/types/index.d.cts.map +1 -1
  41. package/dist/types/index.d.mts +26 -3
  42. package/dist/types/index.d.mts.map +1 -1
  43. package/dist/types/index.mjs.map +1 -1
  44. package/dist/utils/accountUtils.cjs +49 -35
  45. package/dist/utils/accountUtils.cjs.map +1 -1
  46. package/dist/utils/accountUtils.d.cts +30 -4
  47. package/dist/utils/accountUtils.d.cts.map +1 -1
  48. package/dist/utils/accountUtils.d.mts +30 -4
  49. package/dist/utils/accountUtils.d.mts.map +1 -1
  50. package/dist/utils/accountUtils.mjs +49 -35
  51. package/dist/utils/accountUtils.mjs.map +1 -1
  52. package/dist/utils/hyperLiquidAdapter.cjs +3 -2
  53. package/dist/utils/hyperLiquidAdapter.cjs.map +1 -1
  54. package/dist/utils/hyperLiquidAdapter.d.cts.map +1 -1
  55. package/dist/utils/hyperLiquidAdapter.d.mts.map +1 -1
  56. package/dist/utils/hyperLiquidAdapter.mjs +3 -2
  57. package/dist/utils/hyperLiquidAdapter.mjs.map +1 -1
  58. package/dist/utils/hyperLiquidValidation.cjs +11 -11
  59. package/dist/utils/hyperLiquidValidation.cjs.map +1 -1
  60. package/dist/utils/hyperLiquidValidation.d.cts +2 -2
  61. package/dist/utils/hyperLiquidValidation.d.cts.map +1 -1
  62. package/dist/utils/hyperLiquidValidation.d.mts +2 -2
  63. package/dist/utils/hyperLiquidValidation.d.mts.map +1 -1
  64. package/dist/utils/hyperLiquidValidation.mjs +11 -11
  65. package/dist/utils/hyperLiquidValidation.mjs.map +1 -1
  66. package/dist/utils/myxAdapter.cjs +2 -2
  67. package/dist/utils/myxAdapter.cjs.map +1 -1
  68. package/dist/utils/myxAdapter.mjs +2 -2
  69. package/dist/utils/myxAdapter.mjs.map +1 -1
  70. package/dist/utils/orderCalculations.cjs +5 -5
  71. package/dist/utils/orderCalculations.cjs.map +1 -1
  72. package/dist/utils/orderCalculations.d.cts +1 -1
  73. package/dist/utils/orderCalculations.d.mts +1 -1
  74. package/dist/utils/orderCalculations.mjs +5 -5
  75. package/dist/utils/orderCalculations.mjs.map +1 -1
  76. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import type { AssetCtxsWsEvent } from "@nktkas/hyperliquid";
2
2
  import type { Position, OrderFill, Order, SubscribePricesParams, SubscribePositionsParams, SubscribeOrderFillsParams, SubscribeOrdersParams, SubscribeAccountParams, SubscribeOICapsParams, SubscribeOrderBookParams, PerpsPlatformDependencies } from "../types/index.cjs";
3
- import type { UserAbstractionResponse } from "../types/hyperliquid-types.cjs";
3
+ import type { HyperLiquidAbstractionMode } from "../types/hyperliquid-types.cjs";
4
4
  import type { HyperLiquidClientService } from "./HyperLiquidClientService.cjs";
5
5
  import type { HyperLiquidWalletService } from "./HyperLiquidWalletService.cjs";
6
6
  /**
@@ -56,21 +56,13 @@ export declare class HyperLiquidSubscriptionService {
56
56
  /**
57
57
  * Record a user's resolved abstraction mode and immediately re-aggregate.
58
58
  * Call after the provider has confirmed the on-chain mode (already-enabled
59
- * or just-migrated). Setting the mode (rather than deleting it) ensures
60
- * `hyperLiquidModeFoldsSpot` returns the correct fold decision on the next
61
- * aggregation — a delete would leave the user pinned to fail-closed
62
- * (no fold) until the next refresh, under-reporting balance for Unified
63
- * and Portfolio Margin users.
64
- *
65
- * Seals `#cachedSpotStateUserAddress` if spot is already cached for this
66
- * user (fast-path optimization for the next `#ensureSpotState`). Skips the
67
- * seal if spot belongs to a different user — the next refresh will sort
68
- * everything out.
59
+ * or just-migrated) so the WS-driven aggregator picks up the correct fold
60
+ * decision on the next tick.
69
61
  *
70
62
  * @param userAddress - The EVM address whose mode is being recorded.
71
63
  * @param mode - The current abstraction mode for this user.
72
64
  */
73
- setUserAbstractionMode(userAddress: string, mode: UserAbstractionResponse): void;
65
+ setUserAbstractionMode(userAddress: string, mode: HyperLiquidAbstractionMode): void;
74
66
  /**
75
67
  * Subscribe to live price updates with singleton subscription architecture
76
68
  * Uses allMids for fast price updates and predictedFundings for accurate funding rates
@@ -1 +1 @@
1
- {"version":3,"file":"HyperLiquidSubscriptionService.d.cts","sourceRoot":"","sources":["../../src/services/HyperLiquidSubscriptionService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAUV,gBAAgB,EAKjB,4BAA4B;AAI7B,OAAO,KAAK,EAEV,QAAQ,EACR,SAAS,EACT,KAAK,EAEL,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EAGxB,yBAAyB,EAE1B,2BAAiB;AAElB,OAAO,KAAK,EAEV,uBAAuB,EACxB,uCAAmC;AAepC,OAAO,KAAK,EAAE,wBAAwB,EAAE,uCAAmC;AAC3E,OAAO,KAAK,EAAE,wBAAwB,EAAE,uCAAmC;AAE3E;;;GAGG;AACH,qBAAa,8BAA8B;;gBA0OvC,aAAa,EAAE,wBAAwB,EACvC,aAAa,EAAE,wBAAwB,EACvC,oBAAoB,EAAE,yBAAyB,EAC/C,WAAW,CAAC,EAAE,OAAO,EACrB,WAAW,CAAC,EAAE,MAAM,EAAE,EACtB,gBAAgB,CAAC,EAAE,MAAM,EAAE,EAC3B,gBAAgB,CAAC,EAAE,MAAM,EAAE;IA2I7B;;;;;;;;OAQG;IACI,eAAe,CACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;QACJ,QAAQ,EAAE;YACR,IAAI,EAAE,MAAM,CAAC;YACb,U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EAAE,yBAAyB,GAAG,MAAM,IAAI;IAkJ3E;;;;;;OAMG;IACI,iBAAiB,CAAC,MAAM,EAAE,qBAAqB,GAAG,MAAM,IAAI;IA8BnE;;;;;;OAMG;IACI,kBAAkB,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,IAAI;IAgDrE;;;;OAIG;IACI,wBAAwB,IAAI,OAAO;IAI1C;;;;OAIG;IACI,2BAA2B,IAAI,OAAO;IAI7C;;;;OAIG;IACI,kBAAkB,IAAI,QAAQ,EAAE,GAAG,IAAI;IAI9C;;;;OAIG;IACI,eAAe,IAAI,KAAK,EAAE,GAAG,IAAI;IAIxC;;;;;OAKG;IACI,2BAA2B,IAAI,KAAK,EAAE,GAAG,IAAI;IAOpD;;;;;;OAMG;IACI,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIlD,sBAAsB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAS1E;;;;;OAKG;IACI,cAAc,IAAI,SAAS,EAAE,GAAG,IAAI;IAI3C;;;;;;;;OAQG;IACI,0BAA0B,IAAI,SAAS,EAAE,GAAG,IAAI;IAs0BvD;;;;;;;OAOG;IACI,oBAAoB,CAAC,MAAM,EAAE,wBAAwB,GAAG,MAAM,IAAI;IAmNzE;;;;;;OAMG;IACU,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAsMlD;;OAEG;IACI,QAAQ,IAAI,IAAI;CAiMxB"}
@@ -1,6 +1,6 @@
1
1
  import type { AssetCtxsWsEvent } from "@nktkas/hyperliquid";
2
2
  import type { Position, OrderFill, Order, SubscribePricesParams, SubscribePositionsParams, SubscribeOrderFillsParams, SubscribeOrdersParams, SubscribeAccountParams, SubscribeOICapsParams, SubscribeOrderBookParams, PerpsPlatformDependencies } from "../types/index.mjs";
3
- import type { UserAbstractionResponse } from "../types/hyperliquid-types.mjs";
3
+ import type { HyperLiquidAbstractionMode } from "../types/hyperliquid-types.mjs";
4
4
  import type { HyperLiquidClientService } from "./HyperLiquidClientService.mjs";
5
5
  import type { HyperLiquidWalletService } from "./HyperLiquidWalletService.mjs";
6
6
  /**
@@ -56,21 +56,13 @@ export declare class HyperLiquidSubscriptionService {
56
56
  /**
57
57
  * Record a user's resolved abstraction mode and immediately re-aggregate.
58
58
  * Call after the provider has confirmed the on-chain mode (already-enabled
59
- * or just-migrated). Setting the mode (rather than deleting it) ensures
60
- * `hyperLiquidModeFoldsSpot` returns the correct fold decision on the next
61
- * aggregation — a delete would leave the user pinned to fail-closed
62
- * (no fold) until the next refresh, under-reporting balance for Unified
63
- * and Portfolio Margin users.
64
- *
65
- * Seals `#cachedSpotStateUserAddress` if spot is already cached for this
66
- * user (fast-path optimization for the next `#ensureSpotState`). Skips the
67
- * seal if spot belongs to a different user — the next refresh will sort
68
- * everything out.
59
+ * or just-migrated) so the WS-driven aggregator picks up the correct fold
60
+ * decision on the next tick.
69
61
  *
70
62
  * @param userAddress - The EVM address whose mode is being recorded.
71
63
  * @param mode - The current abstraction mode for this user.
72
64
  */
73
- setUserAbstractionMode(userAddress: string, mode: UserAbstractionResponse): void;
65
+ setUserAbstractionMode(userAddress: string, mode: HyperLiquidAbstractionMode): void;
74
66
  /**
75
67
  * Subscribe to live price updates with singleton subscription architecture
76
68
  * Uses allMids for fast price updates and predictedFundings for accurate funding rates
@@ -1 +1 @@
1
- {"version":3,"file":"HyperLiquidSubscriptionService.d.mts","sourceRoot":"","sources":["../../src/services/HyperLiquidSubscriptionService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAUV,gBAAgB,EAKjB,4BAA4B;AAI7B,OAAO,KAAK,EAEV,QAAQ,EACR,SAAS,EACT,KAAK,EAEL,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EAGxB,yBAAyB,EAE1B,2BAAiB;AAElB,OAAO,KA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;OAQG;IACI,0BAA0B,IAAI,SAAS,EAAE,GAAG,IAAI;IAs0BvD;;;;;;;OAOG;IACI,oBAAoB,CAAC,MAAM,EAAE,wBAAwB,GAAG,MAAM,IAAI;IAmNzE;;;;;;OAMG;IACU,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAsMlD;;OAEG;IACI,QAAQ,IAAI,IAAI;CAiMxB"}
@@ -9,9 +9,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _HyperLiquidSubscriptionService_instances, _HyperLiquidSubscriptionService_clientService, _HyperLiquidSubscriptionService_walletService, _HyperLiquidSubscriptionService_hip3Enabled, _HyperLiquidSubscriptionService_enabledDexs, _HyperLiquidSubscriptionService_allowlistMarkets, _HyperLiquidSubscriptionService_blocklistMarkets, _HyperLiquidSubscriptionService_discoveredDexNames, _HyperLiquidSubscriptionService_dexDiscoveryPromise, _HyperLiquidSubscriptionService_dexDiscoveryResolver, _HyperLiquidSubscriptionService_expectedDexs, _HyperLiquidSubscriptionService_initializedDexs, _HyperLiquidSubscriptionService_priceSubscribers, _HyperLiquidSubscriptionService_positionSubscribers, _HyperLiquidSubscriptionService_orderFillSubscribers, _HyperLiquidSubscriptionService_orderSubscribers, _HyperLiquidSubscriptionService_accountSubscribers, _HyperLiquidSubscriptionService_marketDataSubscribers, _HyperLiquidSubscriptionService_orderBookSubscribers, _HyperLiquidSubscriptionService_globalAllMidsSubscription, _HyperLiquidSubscriptionService_globalAllMidsPromise, _HyperLiquidSubscriptionService_globalActiveAssetSubscriptions, _HyperLiquidSubscriptionService_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;
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_abstractionModeByUser, _HyperLiquidSubscriptionService_abstractionModeLastWsRefreshAtByUser, _HyperLiquidSubscriptionService_abstractionModeInflightByUser, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, _HyperLiquidSubscriptionService_spotStatePromise, _HyperLiquidSubscriptionService_spotStatePromiseUserAddress, _HyperLiquidSubscriptionService_spotStateGeneration, _HyperLiquidSubscriptionService_cachedPositions, _HyperLiquidSubscriptionService_cachedOrders, _HyperLiquidSubscriptionService_cachedAccount, _HyperLiquidSubscriptionService_ordersCacheInitialized, _HyperLiquidSubscriptionService_positionsCacheInitialized, _HyperLiquidSubscriptionService_oiCapSubscribers, _HyperLiquidSubscriptionService_cachedOICaps, _HyperLiquidSubscriptionService_cachedOICapsHash, _HyperLiquidSubscriptionService_oiCapsCacheInitialized, _HyperLiquidSubscriptionService_cachedPriceData, _HyperLiquidSubscriptionService_allMidsSnapshots, _HyperLiquidSubscriptionService_cachedFills, _HyperLiquidSubscriptionService_fillsCacheInitialized, _HyperLiquidSubscriptionService_assetCtxsSubscriptions, _HyperLiquidSubscriptionService_dexAssetCtxsCache, _HyperLiquidSubscriptionService_assetCtxsSubscriptionPromises, _HyperLiquidSubscriptionService_dexAllMidsSubscriptions, _HyperLiquidSubscriptionService_dexAllMidsSubscriptionPromises, _HyperLiquidSubscriptionService_clearinghouseStateSubscriptions, _HyperLiquidSubscriptionService_openOrdersSubscriptions, _HyperLiquidSubscriptionService_pendingClearinghouseSubscriptions, _HyperLiquidSubscriptionService_pendingOpenOrdersSubscriptions, _HyperLiquidSubscriptionService_dexMetaCache, _HyperLiquidSubscriptionService_orderBookCache, _HyperLiquidSubscriptionService_marketDataCache, _HyperLiquidSubscriptionService_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_refreshAbstractionModeThrottled, _HyperLiquidSubscriptionService_ensureSpotState, _HyperLiquidSubscriptionService_refreshSpotState, _HyperLiquidSubscriptionService_ensureSpotStateSubscription, _HyperLiquidSubscriptionService_ensureSharedWebData3Subscription, _HyperLiquidSubscriptionService_createUserDataSubscription, _HyperLiquidSubscriptionService_ensureClearinghouseStateSubscription, _HyperLiquidSubscriptionService_createClearinghouseSubscription, _HyperLiquidSubscriptionService_ensureOpenOrdersSubscription, _HyperLiquidSubscriptionService_createOpenOrdersSubscription, _HyperLiquidSubscriptionService_aggregateAndNotifySubscribers, _HyperLiquidSubscriptionService_cleanupSharedWebData3ISubscription, _HyperLiquidSubscriptionService_ensureOrderFillISubscription, _HyperLiquidSubscriptionService_createSubscription, _HyperLiquidSubscriptionService_createPriceUpdate, _HyperLiquidSubscriptionService_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
- import { TP_SL_CONFIG, PERPS_CONSTANTS } from "../constants/perpsConfig.mjs";
14
+ import { TP_SL_CONFIG, PERPS_CONSTANTS, ABSTRACTION_MODE_REFRESH_THROTTLE_MS } from "../constants/perpsConfig.mjs";
15
15
  import { WebSocketConnectionState } from "../types/index.mjs";
16
16
  import { hyperLiquidModeFoldsSpot } from "../types/hyperliquid-types.mjs";
17
17
  import { addSpotBalanceToAccountState, calculateWeightedReturnOnEquity } from "../utils/accountUtils.mjs";
@@ -85,8 +85,21 @@ export class HyperLiquidSubscriptionService {
85
85
  _HyperLiquidSubscriptionService_dexOrdersCache.set(this, new Map()); // Per-DEX orders
86
86
  _HyperLiquidSubscriptionService_dexAccountCache.set(this, new Map()); // Per-DEX account state
87
87
  _HyperLiquidSubscriptionService_cachedSpotState.set(this, null);
88
- _HyperLiquidSubscriptionService_cachedSpotStateUserAddress.set(this, null);
88
+ // HL abstraction mode (Unified / Standard / Portfolio / DEX-abstraction).
89
+ // Gates spot→perps folding in addSpotBalanceToAccountState. Keyed by user
90
+ // address so an in-flight refresh or late response for one wallet cannot
91
+ // overwrite another wallet's fold semantics after an account switch.
89
92
  _HyperLiquidSubscriptionService_abstractionModeByUser.set(this, new Map());
93
+ // Timestamp of the last successful WS-driven userAbstraction refresh per
94
+ // user. This throttle intentionally does not count the initial bootstrap
95
+ // fetch so the first spot tick after app launch can still detect an HL-web
96
+ // mode flip immediately.
97
+ _HyperLiquidSubscriptionService_abstractionModeLastWsRefreshAtByUser.set(this, new Map());
98
+ // In-flight promises for WS-triggered refreshes, keyed by user so concurrent
99
+ // ticks for the same wallet share one fetch while account switches can start
100
+ // their own refresh immediately.
101
+ _HyperLiquidSubscriptionService_abstractionModeInflightByUser.set(this, new Map());
102
+ _HyperLiquidSubscriptionService_cachedSpotStateUserAddress.set(this, null);
90
103
  _HyperLiquidSubscriptionService_spotStatePromise.set(this, void 0);
91
104
  _HyperLiquidSubscriptionService_spotStatePromiseUserAddress.set(this, void 0);
92
105
  // Monotonic token bumped on cleanUp/clearAll and on each new fetch.
@@ -273,16 +286,8 @@ export class HyperLiquidSubscriptionService {
273
286
  /**
274
287
  * Record a user's resolved abstraction mode and immediately re-aggregate.
275
288
  * Call after the provider has confirmed the on-chain mode (already-enabled
276
- * or just-migrated). Setting the mode (rather than deleting it) ensures
277
- * `hyperLiquidModeFoldsSpot` returns the correct fold decision on the next
278
- * aggregation — a delete would leave the user pinned to fail-closed
279
- * (no fold) until the next refresh, under-reporting balance for Unified
280
- * and Portfolio Margin users.
281
- *
282
- * Seals `#cachedSpotStateUserAddress` if spot is already cached for this
283
- * user (fast-path optimization for the next `#ensureSpotState`). Skips the
284
- * seal if spot belongs to a different user — the next refresh will sort
285
- * everything out.
289
+ * or just-migrated) so the WS-driven aggregator picks up the correct fold
290
+ * decision on the next tick.
286
291
  *
287
292
  * @param userAddress - The EVM address whose mode is being recorded.
288
293
  * @param mode - The current abstraction mode for this user.
@@ -290,10 +295,6 @@ export class HyperLiquidSubscriptionService {
290
295
  setUserAbstractionMode(userAddress, mode) {
291
296
  const lower = userAddress.toLowerCase();
292
297
  __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeByUser, "f").set(lower, mode);
293
- // No need to seal #cachedSpotStateUserAddress here — the WS handler and
294
- // #refreshSpotState success path always set it to the spot owner. The
295
- // re-aggregation below will pick up the new mode via the now-populated
296
- // #abstractionModeByUser entry.
297
298
  if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAccountCache, "f").size > 0) {
298
299
  __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_aggregateAndNotifySubscribers).call(this);
299
300
  }
@@ -912,6 +913,8 @@ export class HyperLiquidSubscriptionService {
912
913
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotState, null, "f");
913
914
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, null, "f");
914
915
  __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeByUser, "f").clear();
916
+ __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeLastWsRefreshAtByUser, "f").clear();
917
+ __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeInflightByUser, "f").clear();
915
918
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStateGeneration, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateGeneration, "f") + 1, "f");
916
919
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStatePromise, undefined, "f");
917
920
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStatePromiseUserAddress, undefined, "f");
@@ -993,7 +996,7 @@ export class HyperLiquidSubscriptionService {
993
996
  });
994
997
  }
995
998
  }
996
- _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) {
999
+ _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_abstractionModeByUser = new WeakMap(), _HyperLiquidSubscriptionService_abstractionModeLastWsRefreshAtByUser = new WeakMap(), _HyperLiquidSubscriptionService_abstractionModeInflightByUser = new WeakMap(), _HyperLiquidSubscriptionService_cachedSpotStateUserAddress = new WeakMap(), _HyperLiquidSubscriptionService_spotStatePromise = new WeakMap(), _HyperLiquidSubscriptionService_spotStatePromiseUserAddress = new WeakMap(), _HyperLiquidSubscriptionService_spotStateGeneration = new WeakMap(), _HyperLiquidSubscriptionService_cachedPositions = new WeakMap(), _HyperLiquidSubscriptionService_cachedOrders = new WeakMap(), _HyperLiquidSubscriptionService_cachedAccount = new WeakMap(), _HyperLiquidSubscriptionService_ordersCacheInitialized = new WeakMap(), _HyperLiquidSubscriptionService_positionsCacheInitialized = new WeakMap(), _HyperLiquidSubscriptionService_oiCapSubscribers = new WeakMap(), _HyperLiquidSubscriptionService_cachedOICaps = new WeakMap(), _HyperLiquidSubscriptionService_cachedOICapsHash = new WeakMap(), _HyperLiquidSubscriptionService_oiCapsCacheInitialized = new WeakMap(), _HyperLiquidSubscriptionService_cachedPriceData = new WeakMap(), _HyperLiquidSubscriptionService_allMidsSnapshots = new WeakMap(), _HyperLiquidSubscriptionService_cachedFills = new WeakMap(), _HyperLiquidSubscriptionService_fillsCacheInitialized = new WeakMap(), _HyperLiquidSubscriptionService_assetCtxsSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_dexAssetCtxsCache = new WeakMap(), _HyperLiquidSubscriptionService_assetCtxsSubscriptionPromises = new WeakMap(), _HyperLiquidSubscriptionService_dexAllMidsSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_dexAllMidsSubscriptionPromises = new WeakMap(), _HyperLiquidSubscriptionService_clearinghouseStateSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_openOrdersSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_pendingClearinghouseSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_pendingOpenOrdersSubscriptions = new WeakMap(), _HyperLiquidSubscriptionService_dexMetaCache = new WeakMap(), _HyperLiquidSubscriptionService_orderBookCache = new WeakMap(), _HyperLiquidSubscriptionService_marketDataCache = new WeakMap(), _HyperLiquidSubscriptionService_isClearing = new WeakMap(), _HyperLiquidSubscriptionService_restoreRetryTimeouts = new WeakMap(), _HyperLiquidSubscriptionService_deps = new WeakMap(), _HyperLiquidSubscriptionService_cachedPositionsHash = new WeakMap(), _HyperLiquidSubscriptionService_cachedOrdersHash = new WeakMap(), _HyperLiquidSubscriptionService_cachedAccountHash = new WeakMap(), _HyperLiquidSubscriptionService_instances = new WeakSet(), _HyperLiquidSubscriptionService_logErrorUnlessClearing = function _HyperLiquidSubscriptionService_logErrorUnlessClearing(error, context) {
997
1000
  if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_isClearing, "f")) {
998
1001
  return;
999
1002
  }
@@ -1109,7 +1112,7 @@ async function _HyperLiquidSubscriptionService_waitForDexDiscovery(timeoutMs = 5
1109
1112
  .map((ord) => `${ord.symbol}:${ord.side}:${ord.size}:${ord.price}:${ord.orderType}`)
1110
1113
  .join('|');
1111
1114
  }, _HyperLiquidSubscriptionService_hashAccountState = function _HyperLiquidSubscriptionService_hashAccountState(account) {
1112
- return `${account.availableBalance}:${account.availableToTradeBalance ?? ''}:${account.totalBalance}:${account.marginUsed}:${account.unrealizedPnl}`;
1115
+ return `${account.spendableBalance}:${account.withdrawableBalance}:${account.totalBalance}:${account.marginUsed}:${account.unrealizedPnl}`;
1113
1116
  }, _HyperLiquidSubscriptionService_extractTPSLFromOrders = function _HyperLiquidSubscriptionService_extractTPSLFromOrders(orders, positions, cachedProcessedOrders) {
1114
1117
  const tpslMap = new Map();
1115
1118
  const tpslCountMap = new Map();
@@ -1267,7 +1270,8 @@ async function _HyperLiquidSubscriptionService_waitForDexDiscovery(timeoutMs = 5
1267
1270
  });
1268
1271
  }, _HyperLiquidSubscriptionService_aggregateAccountStates = function _HyperLiquidSubscriptionService_aggregateAccountStates() {
1269
1272
  const subAccountBreakdown = {};
1270
- let totalAvailableBalance = 0;
1273
+ let totalSpendableBalance = 0;
1274
+ let totalWithdrawableBalance = 0;
1271
1275
  let totalBalance = 0;
1272
1276
  let totalMarginUsed = 0;
1273
1277
  let totalUnrealizedPnl = 0;
@@ -1277,10 +1281,12 @@ async function _HyperLiquidSubscriptionService_waitForDexDiscovery(timeoutMs = 5
1277
1281
  Array.from(__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAccountCache, "f").entries()).forEach(([currentDex, state]) => {
1278
1282
  const dexKey = currentDex === '' ? 'main' : currentDex;
1279
1283
  subAccountBreakdown[dexKey] = {
1280
- availableBalance: state.availableBalance,
1284
+ spendableBalance: state.spendableBalance,
1285
+ withdrawableBalance: state.withdrawableBalance,
1281
1286
  totalBalance: state.totalBalance,
1282
1287
  };
1283
- totalAvailableBalance += parseFloat(state.availableBalance);
1288
+ totalSpendableBalance += parseFloat(state.spendableBalance);
1289
+ totalWithdrawableBalance += parseFloat(state.withdrawableBalance);
1284
1290
  totalBalance += parseFloat(state.totalBalance);
1285
1291
  totalMarginUsed += parseFloat(state.marginUsed);
1286
1292
  totalUnrealizedPnl += parseFloat(state.unrealizedPnl);
@@ -1296,7 +1302,8 @@ async function _HyperLiquidSubscriptionService_waitForDexDiscovery(timeoutMs = 5
1296
1302
  const returnOnEquity = calculateWeightedReturnOnEquity(accountStatesForROE);
1297
1303
  return addSpotBalanceToAccountState({
1298
1304
  ...firstDexAccount,
1299
- availableBalance: totalAvailableBalance.toString(),
1305
+ spendableBalance: totalSpendableBalance.toString(),
1306
+ withdrawableBalance: totalWithdrawableBalance.toString(),
1300
1307
  totalBalance: totalBalance.toString(),
1301
1308
  marginUsed: totalMarginUsed.toString(),
1302
1309
  unrealizedPnl: totalUnrealizedPnl.toString(),
@@ -1312,6 +1319,75 @@ async function _HyperLiquidSubscriptionService_waitForDexDiscovery(timeoutMs = 5
1312
1319
  return {
1313
1320
  foldIntoCollateral: hyperLiquidModeFoldsSpot(__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getAbstractionModeForUser).call(this, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, "f"))),
1314
1321
  };
1322
+ }, _HyperLiquidSubscriptionService_refreshAbstractionModeThrottled =
1323
+ /**
1324
+ * Fetch userAbstraction and update the cache, throttled so the long-lived
1325
+ * spotState WebSocket can trigger a background refresh on every tick
1326
+ * without burning REST quota. Handles HL-web mode flips propagating back
1327
+ * to mobile without requiring a restart or account switch.
1328
+ *
1329
+ * Concurrent callers share the same in-flight promise so an in-flight
1330
+ * fetch (especially a slow-failing one) doesn't ratchet the throttle
1331
+ * forward on every WS tick and leave mode stale during a network hang.
1332
+ *
1333
+ * @param userAddress - Current user address to refresh the cache for.
1334
+ * @returns Promise that resolves once the refresh completes (or immediately when throttled).
1335
+ */
1336
+ async function _HyperLiquidSubscriptionService_refreshAbstractionModeThrottled(userAddress) {
1337
+ const normalizedUser = userAddress.toLowerCase();
1338
+ const existing = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeInflightByUser, "f").get(normalizedUser);
1339
+ if (existing) {
1340
+ await existing;
1341
+ return undefined;
1342
+ }
1343
+ const now = Date.now();
1344
+ const lastWsRefreshAt = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeLastWsRefreshAtByUser, "f").get(normalizedUser) ?? 0;
1345
+ if (now - lastWsRefreshAt < ABSTRACTION_MODE_REFRESH_THROTTLE_MS) {
1346
+ return undefined;
1347
+ }
1348
+ const inflight = (async () => {
1349
+ try {
1350
+ const infoClient = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_clientService, "f").getInfoClient();
1351
+ const mode = await infoClient.userAbstraction({ user: userAddress });
1352
+ const previousMode = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeByUser, "f").get(normalizedUser) ?? null;
1353
+ __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeByUser, "f").set(normalizedUser, mode);
1354
+ // Set timestamp only on success; a hanging/failed fetch must not
1355
+ // ratchet the throttle window forward (which would silence every
1356
+ // subsequent spot WS tick for the full throttle duration).
1357
+ __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeLastWsRefreshAtByUser, "f").set(normalizedUser, Date.now());
1358
+ // If the fold semantics actually changed for this user, trigger a
1359
+ // re-aggregation so balance-dependent UI (withdraw cap, order-entry
1360
+ // validation) picks up the new mode immediately — otherwise a
1361
+ // Unified→Standard flip can stay folded with old semantics until the
1362
+ // next spot/account event happens to arrive.
1363
+ const foldChanged = hyperLiquidModeFoldsSpot(previousMode) !==
1364
+ hyperLiquidModeFoldsSpot(mode);
1365
+ if (foldChanged && __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAccountCache, "f").size > 0) {
1366
+ __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_aggregateAndNotifySubscribers).call(this);
1367
+ }
1368
+ }
1369
+ catch (error) {
1370
+ // Non-fatal — preserve the last known mode for this user. Leave
1371
+ // timestamp at its previous value so a genuine retry on the next
1372
+ // WS tick is allowed (no forward ratchet on slow failures). Route
1373
+ // through the shared Sentry helper so repeated failures become
1374
+ // visible on the perps ops dashboard (consistent with other async
1375
+ // boundary errors in this file, e.g. #refreshSpotState).
1376
+ __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_logErrorUnlessClearing).call(this, ensureError(error, 'HyperLiquidSubscriptionService.refreshAbstractionModeThrottled'), __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_getErrorContext).call(this, 'refreshAbstractionModeThrottled', {
1377
+ user: normalizedUser,
1378
+ }));
1379
+ }
1380
+ })();
1381
+ __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeInflightByUser, "f").set(normalizedUser, inflight);
1382
+ try {
1383
+ await inflight;
1384
+ }
1385
+ finally {
1386
+ if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeInflightByUser, "f").get(normalizedUser) === inflight) {
1387
+ __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeInflightByUser, "f").delete(normalizedUser);
1388
+ }
1389
+ }
1390
+ return undefined;
1315
1391
  }, _HyperLiquidSubscriptionService_ensureSpotState = async function _HyperLiquidSubscriptionService_ensureSpotState(accountId) {
1316
1392
  const userAddress = await __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_walletService, "f").getUserAddressWithDefault(accountId);
1317
1393
  const lowerUserAddress = userAddress.toLowerCase();
@@ -1362,13 +1438,25 @@ async function _HyperLiquidSubscriptionService_waitForDexDiscovery(timeoutMs = 5
1362
1438
  // correctly handles the generation-changed case (seal + re-aggregate
1363
1439
  // instead of overwriting WS spot).
1364
1440
  const infoClient = __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_clientService, "f").getInfoClient();
1441
+ const lowerUserAddress = userAddress.toLowerCase();
1442
+ // Fetch spot state + abstraction mode in parallel — mode decides
1443
+ // whether the spot fold applies in addSpotBalanceToAccountState.
1444
+ // Register the userAbstraction call in `#abstractionModeInflightByUser`
1445
+ // so a concurrent WS-driven `#refreshAbstractionModeThrottled` awaits
1446
+ // this fetch instead of duplicating the REST round-trip.
1447
+ const abstractionFetch = infoClient.userAbstraction({
1448
+ user: userAddress,
1449
+ });
1450
+ const trackedAbstraction = abstractionFetch.then(() => undefined, () => undefined);
1451
+ __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeInflightByUser, "f").set(lowerUserAddress, trackedAbstraction);
1365
1452
  const [spotResult, abstractionResult] = await Promise.allSettled([
1366
- infoClient.spotClearinghouseState({
1367
- user: userAddress,
1368
- }),
1369
- infoClient.userAbstraction({ user: userAddress }),
1453
+ infoClient.spotClearinghouseState({ user: userAddress }),
1454
+ abstractionFetch,
1370
1455
  ]);
1371
- const lowerUserAddress = userAddress.toLowerCase();
1456
+ if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeInflightByUser, "f").get(lowerUserAddress) ===
1457
+ trackedAbstraction) {
1458
+ __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeInflightByUser, "f").delete(lowerUserAddress);
1459
+ }
1372
1460
  // Record the abstraction mode regardless of generation. The mode is
1373
1461
  // user-keyed (independent of the spot snapshot generation) so a WS
1374
1462
  // push that bumped generation while we awaited cannot make this
@@ -1450,6 +1538,14 @@ async function _HyperLiquidSubscriptionService_waitForDexDiscovery(timeoutMs = 5
1450
1538
  // Fast-path eligibility is gated separately in #ensureSpotState
1451
1539
  // by checking #abstractionModeByUser.has(...).
1452
1540
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, userAddress.toLowerCase(), "f");
1541
+ // Kick a throttled userAbstraction refresh so HL-web mode
1542
+ // flips (Unified → Standard or vice versa) propagate back to
1543
+ // mobile while the app stays open. Fire-and-forget: the
1544
+ // refresh updates the per-user abstraction-mode cache and the next
1545
+ // fold picks up the new value.
1546
+ __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_refreshAbstractionModeThrottled).call(this, event.user.toLowerCase()).catch(() => {
1547
+ // Errors are logged inside the throttled refresh helper.
1548
+ });
1453
1549
  if (__classPrivateFieldGet(this, _HyperLiquidSubscriptionService_dexAccountCache, "f").size > 0) {
1454
1550
  __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_instances, "m", _HyperLiquidSubscriptionService_aggregateAndNotifySubscribers).call(this);
1455
1551
  }
@@ -2023,6 +2119,10 @@ async function _HyperLiquidSubscriptionService_createOpenOrdersSubscription(user
2023
2119
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotState, null, "f");
2024
2120
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_cachedSpotStateUserAddress, null, "f");
2025
2121
  __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeByUser, "f").clear();
2122
+ __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeLastWsRefreshAtByUser, "f").clear();
2123
+ // Drop in-flight refresh handles so stale hanging userAbstraction
2124
+ // requests from the prior connection can't be awaited by future calls.
2125
+ __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_abstractionModeInflightByUser, "f").clear();
2026
2126
  // Bump generation so any in-flight spot fetch from a prior user discards
2027
2127
  // its result instead of re-populating the cache post-cleanup.
2028
2128
  __classPrivateFieldSet(this, _HyperLiquidSubscriptionService_spotStateGeneration, __classPrivateFieldGet(this, _HyperLiquidSubscriptionService_spotStateGeneration, "f") + 1, "f");