@metamask-previews/perps-controller 16.1.0-preview-abca9bcea → 17.0.0-preview-0a30e47

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 (891) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/README.md +17 -0
  3. package/dist/PerpsController-method-action-types.d.ts +1235 -0
  4. package/dist/PerpsController-method-action-types.d.ts.map +1 -0
  5. package/dist/PerpsController-method-action-types.js +6 -0
  6. package/dist/PerpsController-method-action-types.js.map +1 -0
  7. package/dist/PerpsController.d.ts +1313 -0
  8. package/dist/PerpsController.d.ts.map +1 -0
  9. package/dist/PerpsController.js +5331 -0
  10. package/dist/PerpsController.js.map +1 -0
  11. package/dist/aggregation/SubscriptionMultiplexer.d.ts +171 -0
  12. package/dist/aggregation/SubscriptionMultiplexer.d.ts.map +1 -0
  13. package/dist/aggregation/SubscriptionMultiplexer.js +451 -0
  14. package/dist/aggregation/SubscriptionMultiplexer.js.map +1 -0
  15. package/dist/aggregation/index.d.ts +6 -0
  16. package/dist/aggregation/index.d.ts.map +1 -0
  17. package/dist/aggregation/index.js +5 -0
  18. package/dist/aggregation/index.js.map +1 -0
  19. package/dist/constants/chartConfig.d.ts +228 -0
  20. package/dist/constants/chartConfig.d.ts.map +1 -0
  21. package/dist/constants/chartConfig.js +233 -0
  22. package/dist/constants/chartConfig.js.map +1 -0
  23. package/dist/constants/eventNames.d.ts +565 -0
  24. package/dist/constants/eventNames.d.ts.map +1 -0
  25. package/dist/constants/eventNames.js +657 -0
  26. package/dist/constants/eventNames.js.map +1 -0
  27. package/dist/constants/hyperLiquidConfig.d.ts +280 -0
  28. package/dist/constants/hyperLiquidConfig.d.ts.map +1 -0
  29. package/dist/constants/hyperLiquidConfig.js +596 -0
  30. package/dist/constants/hyperLiquidConfig.js.map +1 -0
  31. package/dist/constants/index.d.ts +12 -0
  32. package/dist/constants/index.d.ts.map +1 -0
  33. package/dist/constants/index.js +12 -0
  34. package/dist/constants/index.js.map +1 -0
  35. package/dist/constants/lighterConfig.d.ts +204 -0
  36. package/dist/constants/lighterConfig.d.ts.map +1 -0
  37. package/dist/constants/lighterConfig.js +317 -0
  38. package/dist/constants/lighterConfig.js.map +1 -0
  39. package/dist/constants/orderTypes.d.ts +19 -0
  40. package/dist/constants/orderTypes.d.ts.map +1 -0
  41. package/dist/constants/orderTypes.js +27 -0
  42. package/dist/constants/orderTypes.js.map +1 -0
  43. package/dist/constants/performanceMetrics.d.ts +46 -0
  44. package/dist/constants/performanceMetrics.d.ts.map +1 -0
  45. package/dist/constants/performanceMetrics.js +60 -0
  46. package/dist/constants/performanceMetrics.js.map +1 -0
  47. package/dist/constants/perpsConfig.d.ts +480 -0
  48. package/dist/constants/perpsConfig.d.ts.map +1 -0
  49. package/dist/constants/perpsConfig.js +555 -0
  50. package/dist/constants/perpsConfig.js.map +1 -0
  51. package/dist/constants/transactionsHistoryConfig.d.ts +35 -0
  52. package/dist/constants/transactionsHistoryConfig.d.ts.map +1 -0
  53. package/dist/constants/transactionsHistoryConfig.js +35 -0
  54. package/dist/constants/transactionsHistoryConfig.js.map +1 -0
  55. package/dist/index.d.ts +95 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +80 -0
  58. package/dist/index.js.map +1 -0
  59. package/dist/perpsErrorCodes.d.ts +113 -0
  60. package/dist/perpsErrorCodes.d.ts.map +1 -0
  61. package/dist/perpsErrorCodes.js +133 -0
  62. package/dist/perpsErrorCodes.js.map +1 -0
  63. package/dist/providers/AggregatedPerpsProvider.d.ts +277 -0
  64. package/dist/providers/AggregatedPerpsProvider.d.ts.map +1 -0
  65. package/dist/providers/AggregatedPerpsProvider.js +827 -0
  66. package/dist/providers/AggregatedPerpsProvider.js.map +1 -0
  67. package/dist/providers/HyperLiquidProvider.d.ts +656 -0
  68. package/dist/providers/HyperLiquidProvider.d.ts.map +1 -0
  69. package/dist/providers/HyperLiquidProvider.js +11308 -0
  70. package/dist/providers/HyperLiquidProvider.js.map +1 -0
  71. package/dist/providers/LighterProvider.d.ts +179 -0
  72. package/dist/providers/LighterProvider.d.ts.map +1 -0
  73. package/dist/providers/LighterProvider.js +6599 -0
  74. package/dist/providers/LighterProvider.js.map +1 -0
  75. package/dist/routing/ProviderRouter.d.ts +112 -0
  76. package/dist/routing/ProviderRouter.d.ts.map +1 -0
  77. package/dist/routing/ProviderRouter.js +137 -0
  78. package/dist/routing/ProviderRouter.js.map +1 -0
  79. package/dist/routing/index.d.ts +6 -0
  80. package/dist/routing/index.d.ts.map +1 -0
  81. package/dist/routing/index.js +5 -0
  82. package/dist/routing/index.js.map +1 -0
  83. package/dist/selectors.d.ts +336 -0
  84. package/dist/selectors.d.ts.map +1 -0
  85. package/dist/selectors.js +249 -0
  86. package/dist/selectors.js.map +1 -0
  87. package/dist/services/AccountService.d.ts +56 -0
  88. package/dist/services/AccountService.d.ts.map +1 -0
  89. package/dist/services/AccountService.js +307 -0
  90. package/dist/services/AccountService.js.map +1 -0
  91. package/dist/services/AggregatedOrderBookConnection.d.ts +106 -0
  92. package/dist/services/AggregatedOrderBookConnection.d.ts.map +1 -0
  93. package/dist/services/AggregatedOrderBookConnection.js +388 -0
  94. package/dist/services/AggregatedOrderBookConnection.js.map +1 -0
  95. package/dist/services/DataLakeService.d.ts +51 -0
  96. package/dist/services/DataLakeService.d.ts.map +1 -0
  97. package/dist/services/DataLakeService.js +215 -0
  98. package/dist/services/DataLakeService.js.map +1 -0
  99. package/dist/services/DepositService.d.ts +39 -0
  100. package/dist/services/DepositService.d.ts.map +1 -0
  101. package/dist/services/DepositService.js +88 -0
  102. package/dist/services/DepositService.js.map +1 -0
  103. package/dist/services/DexDiscoveryCacheManager.d.ts +52 -0
  104. package/dist/services/DexDiscoveryCacheManager.d.ts.map +1 -0
  105. package/dist/services/DexDiscoveryCacheManager.js +130 -0
  106. package/dist/services/DexDiscoveryCacheManager.js.map +1 -0
  107. package/dist/services/EligibilityService.d.ts +28 -0
  108. package/dist/services/EligibilityService.d.ts.map +1 -0
  109. package/dist/services/EligibilityService.js +61 -0
  110. package/dist/services/EligibilityService.js.map +1 -0
  111. package/dist/services/FeatureFlagConfigurationService.d.ts +73 -0
  112. package/dist/services/FeatureFlagConfigurationService.d.ts.map +1 -0
  113. package/dist/services/FeatureFlagConfigurationService.js +266 -0
  114. package/dist/services/FeatureFlagConfigurationService.js.map +1 -0
  115. package/dist/services/HyperLiquidClientService.d.ts +252 -0
  116. package/dist/services/HyperLiquidClientService.d.ts.map +1 -0
  117. package/dist/services/HyperLiquidClientService.js +1152 -0
  118. package/dist/services/HyperLiquidClientService.js.map +1 -0
  119. package/dist/services/HyperLiquidSubscriptionService.d.ts +265 -0
  120. package/dist/services/HyperLiquidSubscriptionService.d.ts.map +1 -0
  121. package/dist/services/HyperLiquidSubscriptionService.js +3874 -0
  122. package/dist/services/HyperLiquidSubscriptionService.js.map +1 -0
  123. package/dist/services/HyperLiquidWalletService.d.ts +84 -0
  124. package/dist/services/HyperLiquidWalletService.d.ts.map +1 -0
  125. package/dist/services/HyperLiquidWalletService.js +168 -0
  126. package/dist/services/HyperLiquidWalletService.js.map +1 -0
  127. package/dist/services/LighterClientService.d.ts +200 -0
  128. package/dist/services/LighterClientService.d.ts.map +1 -0
  129. package/dist/services/LighterClientService.js +634 -0
  130. package/dist/services/LighterClientService.js.map +1 -0
  131. package/dist/services/LighterWalletService.d.ts +51 -0
  132. package/dist/services/LighterWalletService.d.ts.map +1 -0
  133. package/dist/services/LighterWalletService.js +92 -0
  134. package/dist/services/LighterWalletService.js.map +1 -0
  135. package/dist/services/MarketDataService.d.ts +350 -0
  136. package/dist/services/MarketDataService.d.ts.map +1 -0
  137. package/dist/services/MarketDataService.js +1165 -0
  138. package/dist/services/MarketDataService.js.map +1 -0
  139. package/dist/services/RewardsIntegrationService.d.ts +84 -0
  140. package/dist/services/RewardsIntegrationService.d.ts.map +1 -0
  141. package/dist/services/RewardsIntegrationService.js +380 -0
  142. package/dist/services/RewardsIntegrationService.js.map +1 -0
  143. package/dist/services/ServiceContext.d.ts +102 -0
  144. package/dist/services/ServiceContext.d.ts.map +1 -0
  145. package/dist/services/ServiceContext.js +2 -0
  146. package/dist/services/ServiceContext.js.map +1 -0
  147. package/dist/services/TerminalMarketService.d.ts +45 -0
  148. package/dist/services/TerminalMarketService.d.ts.map +1 -0
  149. package/dist/services/TerminalMarketService.js +640 -0
  150. package/dist/services/TerminalMarketService.js.map +1 -0
  151. package/dist/services/TradingReadinessCache.d.ts +204 -0
  152. package/dist/services/TradingReadinessCache.d.ts.map +1 -0
  153. package/dist/services/TradingReadinessCache.js +313 -0
  154. package/dist/services/TradingReadinessCache.js.map +1 -0
  155. package/dist/services/TradingService.d.ts +201 -0
  156. package/dist/services/TradingService.d.ts.map +1 -0
  157. package/dist/services/TradingService.js +1967 -0
  158. package/dist/services/TradingService.js.map +1 -0
  159. package/dist/types/config.d.ts +49 -0
  160. package/dist/types/config.d.ts.map +1 -0
  161. package/dist/types/config.js +2 -0
  162. package/dist/types/config.js.map +1 -0
  163. package/dist/types/hyperliquid-types.d.ts +67 -0
  164. package/dist/types/hyperliquid-types.d.ts.map +1 -0
  165. package/dist/types/hyperliquid-types.js +41 -0
  166. package/dist/types/hyperliquid-types.js.map +1 -0
  167. package/dist/types/index.d.ts +2192 -0
  168. package/dist/types/index.d.ts.map +1 -0
  169. package/dist/types/index.js +133 -0
  170. package/dist/types/index.js.map +1 -0
  171. package/dist/types/lighter-types.d.ts +772 -0
  172. package/dist/types/lighter-types.d.ts.map +1 -0
  173. package/dist/types/lighter-types.js +10 -0
  174. package/dist/types/lighter-types.js.map +1 -0
  175. package/dist/types/messenger.d.ts +30 -0
  176. package/dist/types/messenger.d.ts.map +1 -0
  177. package/dist/types/messenger.js +2 -0
  178. package/dist/types/messenger.js.map +1 -0
  179. package/dist/types/perps-types.d.ts +184 -0
  180. package/dist/types/perps-types.d.ts.map +1 -0
  181. package/dist/types/perps-types.js +2 -0
  182. package/dist/types/perps-types.js.map +1 -0
  183. package/dist/types/token.d.ts +25 -0
  184. package/dist/types/token.d.ts.map +1 -0
  185. package/dist/types/token.js +2 -0
  186. package/dist/types/token.js.map +1 -0
  187. package/dist/types/transactionTypes.d.ts +60 -0
  188. package/dist/types/transactionTypes.d.ts.map +1 -0
  189. package/dist/types/transactionTypes.js +24 -0
  190. package/dist/types/transactionTypes.js.map +1 -0
  191. package/dist/utils/accountUtils.d.ts +72 -0
  192. package/dist/utils/accountUtils.d.ts.map +1 -0
  193. package/dist/utils/accountUtils.js +223 -0
  194. package/dist/utils/accountUtils.js.map +1 -0
  195. package/dist/utils/capabilitySymbols.d.ts +15 -0
  196. package/dist/utils/capabilitySymbols.d.ts.map +1 -0
  197. package/dist/utils/capabilitySymbols.js +21 -0
  198. package/dist/utils/capabilitySymbols.js.map +1 -0
  199. package/dist/utils/coalescePerpsRestRequest.d.ts +32 -0
  200. package/dist/utils/coalescePerpsRestRequest.d.ts.map +1 -0
  201. package/dist/utils/coalescePerpsRestRequest.js +66 -0
  202. package/dist/utils/coalescePerpsRestRequest.js.map +1 -0
  203. package/dist/utils/errorUtils.d.ts +50 -0
  204. package/dist/utils/errorUtils.d.ts.map +1 -0
  205. package/dist/utils/errorUtils.js +96 -0
  206. package/dist/utils/errorUtils.js.map +1 -0
  207. package/dist/utils/hyperLiquidAbstraction.d.ts +11 -0
  208. package/dist/utils/hyperLiquidAbstraction.d.ts.map +1 -0
  209. package/dist/utils/hyperLiquidAbstraction.js +19 -0
  210. package/dist/utils/hyperLiquidAbstraction.js.map +1 -0
  211. package/dist/utils/hyperLiquidAdapter.d.ts +77 -0
  212. package/dist/utils/hyperLiquidAdapter.d.ts.map +1 -0
  213. package/dist/utils/hyperLiquidAdapter.js +495 -0
  214. package/dist/utils/hyperLiquidAdapter.js.map +1 -0
  215. package/dist/utils/hyperLiquidOrderBookProcessor.d.ts +55 -0
  216. package/dist/utils/hyperLiquidOrderBookProcessor.d.ts.map +1 -0
  217. package/dist/utils/hyperLiquidOrderBookProcessor.js +78 -0
  218. package/dist/utils/hyperLiquidOrderBookProcessor.js.map +1 -0
  219. package/dist/utils/hyperLiquidPositionPreview.d.ts +124 -0
  220. package/dist/utils/hyperLiquidPositionPreview.d.ts.map +1 -0
  221. package/dist/utils/hyperLiquidPositionPreview.js +347 -0
  222. package/dist/utils/hyperLiquidPositionPreview.js.map +1 -0
  223. package/dist/utils/hyperLiquidValidation.d.ts +192 -0
  224. package/dist/utils/hyperLiquidValidation.d.ts.map +1 -0
  225. package/dist/utils/hyperLiquidValidation.js +786 -0
  226. package/dist/utils/hyperLiquidValidation.js.map +1 -0
  227. package/dist/utils/idUtils.d.ts +6 -0
  228. package/dist/utils/idUtils.d.ts.map +1 -0
  229. package/dist/utils/idUtils.js +10 -0
  230. package/dist/utils/idUtils.js.map +1 -0
  231. package/dist/utils/index.d.ts +29 -0
  232. package/dist/utils/index.d.ts.map +1 -0
  233. package/dist/utils/index.js +34 -0
  234. package/dist/utils/index.js.map +1 -0
  235. package/dist/utils/lighterAdapter.d.ts +117 -0
  236. package/dist/utils/lighterAdapter.d.ts.map +1 -0
  237. package/dist/utils/lighterAdapter.js +562 -0
  238. package/dist/utils/lighterAdapter.js.map +1 -0
  239. package/dist/utils/marketDataTransform.d.ts +71 -0
  240. package/dist/utils/marketDataTransform.d.ts.map +1 -0
  241. package/dist/utils/marketDataTransform.js +243 -0
  242. package/dist/utils/marketDataTransform.js.map +1 -0
  243. package/dist/utils/marketSearch.d.ts +48 -0
  244. package/dist/utils/marketSearch.d.ts.map +1 -0
  245. package/dist/utils/marketSearch.js +106 -0
  246. package/dist/utils/marketSearch.js.map +1 -0
  247. package/dist/utils/marketUtils.d.ts +73 -0
  248. package/dist/utils/marketUtils.d.ts.map +1 -0
  249. package/dist/utils/marketUtils.js +248 -0
  250. package/dist/utils/marketUtils.js.map +1 -0
  251. package/dist/utils/orderCalculations.d.ts +306 -0
  252. package/dist/utils/orderCalculations.d.ts.map +1 -0
  253. package/dist/utils/orderCalculations.js +833 -0
  254. package/dist/utils/orderCalculations.js.map +1 -0
  255. package/dist/utils/orderTypes.d.ts +166 -0
  256. package/dist/utils/orderTypes.d.ts.map +1 -0
  257. package/dist/utils/orderTypes.js +287 -0
  258. package/dist/utils/orderTypes.js.map +1 -0
  259. package/dist/utils/perpsConnectionAttemptContext.d.ts +7 -0
  260. package/dist/utils/perpsConnectionAttemptContext.d.ts.map +1 -0
  261. package/dist/utils/perpsConnectionAttemptContext.js +15 -0
  262. package/dist/utils/perpsConnectionAttemptContext.js.map +1 -0
  263. package/dist/utils/perpsDiskPersistence.d.ts +112 -0
  264. package/dist/utils/perpsDiskPersistence.d.ts.map +1 -0
  265. package/dist/utils/perpsDiskPersistence.js +251 -0
  266. package/dist/utils/perpsDiskPersistence.js.map +1 -0
  267. package/dist/utils/perpsFormatters.d.ts +204 -0
  268. package/dist/utils/perpsFormatters.d.ts.map +1 -0
  269. package/dist/utils/perpsFormatters.js +500 -0
  270. package/dist/utils/perpsFormatters.js.map +1 -0
  271. package/dist/utils/rewardsUtils.d.ts +33 -0
  272. package/dist/utils/rewardsUtils.d.ts.map +1 -0
  273. package/dist/utils/rewardsUtils.js +92 -0
  274. package/dist/utils/rewardsUtils.js.map +1 -0
  275. package/dist/utils/significantFigures.d.ts +25 -0
  276. package/dist/utils/significantFigures.d.ts.map +1 -0
  277. package/dist/utils/significantFigures.js +82 -0
  278. package/dist/utils/significantFigures.js.map +1 -0
  279. package/dist/utils/sortMarkets.d.ts +25 -0
  280. package/dist/utils/sortMarkets.d.ts.map +1 -0
  281. package/dist/utils/sortMarkets.js +88 -0
  282. package/dist/utils/sortMarkets.js.map +1 -0
  283. package/dist/utils/standaloneInfoClient.d.ts +37 -0
  284. package/dist/utils/standaloneInfoClient.d.ts.map +1 -0
  285. package/dist/utils/standaloneInfoClient.js +64 -0
  286. package/dist/utils/standaloneInfoClient.js.map +1 -0
  287. package/dist/utils/stringParseUtils.d.ts +11 -0
  288. package/dist/utils/stringParseUtils.d.ts.map +1 -0
  289. package/dist/utils/stringParseUtils.js +28 -0
  290. package/dist/utils/stringParseUtils.js.map +1 -0
  291. package/dist/utils/transferData.d.ts +9 -0
  292. package/dist/utils/transferData.d.ts.map +1 -0
  293. package/dist/utils/transferData.js +29 -0
  294. package/dist/utils/transferData.js.map +1 -0
  295. package/dist/utils/wait.d.ts +2 -0
  296. package/dist/utils/wait.d.ts.map +1 -0
  297. package/dist/utils/wait.js +2 -0
  298. package/dist/utils/wait.js.map +1 -0
  299. package/package.json +33 -61
  300. package/dist/PerpsController-method-action-types.cjs +0 -7
  301. package/dist/PerpsController-method-action-types.cjs.map +0 -1
  302. package/dist/PerpsController-method-action-types.d.cts +0 -1235
  303. package/dist/PerpsController-method-action-types.d.cts.map +0 -1
  304. package/dist/PerpsController-method-action-types.d.mts +0 -1235
  305. package/dist/PerpsController-method-action-types.d.mts.map +0 -1
  306. package/dist/PerpsController-method-action-types.mjs +0 -6
  307. package/dist/PerpsController-method-action-types.mjs.map +0 -1
  308. package/dist/PerpsController.cjs +0 -5154
  309. package/dist/PerpsController.cjs.map +0 -1
  310. package/dist/PerpsController.d.cts +0 -1313
  311. package/dist/PerpsController.d.cts.map +0 -1
  312. package/dist/PerpsController.d.mts +0 -1313
  313. package/dist/PerpsController.d.mts.map +0 -1
  314. package/dist/PerpsController.mjs +0 -5142
  315. package/dist/PerpsController.mjs.map +0 -1
  316. package/dist/aggregation/SubscriptionMultiplexer.cjs +0 -441
  317. package/dist/aggregation/SubscriptionMultiplexer.cjs.map +0 -1
  318. package/dist/aggregation/SubscriptionMultiplexer.d.cts +0 -171
  319. package/dist/aggregation/SubscriptionMultiplexer.d.cts.map +0 -1
  320. package/dist/aggregation/SubscriptionMultiplexer.d.mts +0 -171
  321. package/dist/aggregation/SubscriptionMultiplexer.d.mts.map +0 -1
  322. package/dist/aggregation/SubscriptionMultiplexer.mjs +0 -437
  323. package/dist/aggregation/SubscriptionMultiplexer.mjs.map +0 -1
  324. package/dist/aggregation/index.cjs +0 -9
  325. package/dist/aggregation/index.cjs.map +0 -1
  326. package/dist/aggregation/index.d.cts +0 -6
  327. package/dist/aggregation/index.d.cts.map +0 -1
  328. package/dist/aggregation/index.d.mts +0 -6
  329. package/dist/aggregation/index.d.mts.map +0 -1
  330. package/dist/aggregation/index.mjs +0 -5
  331. package/dist/aggregation/index.mjs.map +0 -1
  332. package/dist/constants/chartConfig.cjs +0 -239
  333. package/dist/constants/chartConfig.cjs.map +0 -1
  334. package/dist/constants/chartConfig.d.cts +0 -228
  335. package/dist/constants/chartConfig.d.cts.map +0 -1
  336. package/dist/constants/chartConfig.d.mts +0 -228
  337. package/dist/constants/chartConfig.d.mts.map +0 -1
  338. package/dist/constants/chartConfig.mjs +0 -233
  339. package/dist/constants/chartConfig.mjs.map +0 -1
  340. package/dist/constants/eventNames.cjs +0 -660
  341. package/dist/constants/eventNames.cjs.map +0 -1
  342. package/dist/constants/eventNames.d.cts +0 -565
  343. package/dist/constants/eventNames.d.cts.map +0 -1
  344. package/dist/constants/eventNames.d.mts +0 -565
  345. package/dist/constants/eventNames.d.mts.map +0 -1
  346. package/dist/constants/eventNames.mjs +0 -657
  347. package/dist/constants/eventNames.mjs.map +0 -1
  348. package/dist/constants/hyperLiquidConfig.cjs +0 -607
  349. package/dist/constants/hyperLiquidConfig.cjs.map +0 -1
  350. package/dist/constants/hyperLiquidConfig.d.cts +0 -280
  351. package/dist/constants/hyperLiquidConfig.d.cts.map +0 -1
  352. package/dist/constants/hyperLiquidConfig.d.mts +0 -280
  353. package/dist/constants/hyperLiquidConfig.d.mts.map +0 -1
  354. package/dist/constants/hyperLiquidConfig.mjs +0 -596
  355. package/dist/constants/hyperLiquidConfig.mjs.map +0 -1
  356. package/dist/constants/index.cjs +0 -28
  357. package/dist/constants/index.cjs.map +0 -1
  358. package/dist/constants/index.d.cts +0 -12
  359. package/dist/constants/index.d.cts.map +0 -1
  360. package/dist/constants/index.d.mts +0 -12
  361. package/dist/constants/index.d.mts.map +0 -1
  362. package/dist/constants/index.mjs +0 -12
  363. package/dist/constants/index.mjs.map +0 -1
  364. package/dist/constants/lighterConfig.cjs +0 -328
  365. package/dist/constants/lighterConfig.cjs.map +0 -1
  366. package/dist/constants/lighterConfig.d.cts +0 -204
  367. package/dist/constants/lighterConfig.d.cts.map +0 -1
  368. package/dist/constants/lighterConfig.d.mts +0 -204
  369. package/dist/constants/lighterConfig.d.mts.map +0 -1
  370. package/dist/constants/lighterConfig.mjs +0 -317
  371. package/dist/constants/lighterConfig.mjs.map +0 -1
  372. package/dist/constants/orderTypes.cjs +0 -31
  373. package/dist/constants/orderTypes.cjs.map +0 -1
  374. package/dist/constants/orderTypes.d.cts +0 -19
  375. package/dist/constants/orderTypes.d.cts.map +0 -1
  376. package/dist/constants/orderTypes.d.mts +0 -19
  377. package/dist/constants/orderTypes.d.mts.map +0 -1
  378. package/dist/constants/orderTypes.mjs +0 -27
  379. package/dist/constants/orderTypes.mjs.map +0 -1
  380. package/dist/constants/performanceMetrics.cjs +0 -63
  381. package/dist/constants/performanceMetrics.cjs.map +0 -1
  382. package/dist/constants/performanceMetrics.d.cts +0 -46
  383. package/dist/constants/performanceMetrics.d.cts.map +0 -1
  384. package/dist/constants/performanceMetrics.d.mts +0 -46
  385. package/dist/constants/performanceMetrics.d.mts.map +0 -1
  386. package/dist/constants/performanceMetrics.mjs +0 -60
  387. package/dist/constants/performanceMetrics.mjs.map +0 -1
  388. package/dist/constants/perpsConfig.cjs +0 -560
  389. package/dist/constants/perpsConfig.cjs.map +0 -1
  390. package/dist/constants/perpsConfig.d.cts +0 -480
  391. package/dist/constants/perpsConfig.d.cts.map +0 -1
  392. package/dist/constants/perpsConfig.d.mts +0 -480
  393. package/dist/constants/perpsConfig.d.mts.map +0 -1
  394. package/dist/constants/perpsConfig.mjs +0 -555
  395. package/dist/constants/perpsConfig.mjs.map +0 -1
  396. package/dist/constants/transactionsHistoryConfig.cjs +0 -38
  397. package/dist/constants/transactionsHistoryConfig.cjs.map +0 -1
  398. package/dist/constants/transactionsHistoryConfig.d.cts +0 -35
  399. package/dist/constants/transactionsHistoryConfig.d.cts.map +0 -1
  400. package/dist/constants/transactionsHistoryConfig.d.mts +0 -35
  401. package/dist/constants/transactionsHistoryConfig.d.mts.map +0 -1
  402. package/dist/constants/transactionsHistoryConfig.mjs +0 -35
  403. package/dist/constants/transactionsHistoryConfig.mjs.map +0 -1
  404. package/dist/index.cjs +0 -334
  405. package/dist/index.cjs.map +0 -1
  406. package/dist/index.d.cts +0 -95
  407. package/dist/index.d.cts.map +0 -1
  408. package/dist/index.d.mts +0 -95
  409. package/dist/index.d.mts.map +0 -1
  410. package/dist/index.mjs +0 -80
  411. package/dist/index.mjs.map +0 -1
  412. package/dist/perpsErrorCodes.cjs +0 -128
  413. package/dist/perpsErrorCodes.cjs.map +0 -1
  414. package/dist/perpsErrorCodes.d.cts +0 -105
  415. package/dist/perpsErrorCodes.d.cts.map +0 -1
  416. package/dist/perpsErrorCodes.d.mts +0 -105
  417. package/dist/perpsErrorCodes.d.mts.map +0 -1
  418. package/dist/perpsErrorCodes.mjs +0 -125
  419. package/dist/perpsErrorCodes.mjs.map +0 -1
  420. package/dist/providers/AggregatedPerpsProvider.cjs +0 -810
  421. package/dist/providers/AggregatedPerpsProvider.cjs.map +0 -1
  422. package/dist/providers/AggregatedPerpsProvider.d.cts +0 -277
  423. package/dist/providers/AggregatedPerpsProvider.d.cts.map +0 -1
  424. package/dist/providers/AggregatedPerpsProvider.d.mts +0 -277
  425. package/dist/providers/AggregatedPerpsProvider.d.mts.map +0 -1
  426. package/dist/providers/AggregatedPerpsProvider.mjs +0 -805
  427. package/dist/providers/AggregatedPerpsProvider.mjs.map +0 -1
  428. package/dist/providers/HyperLiquidProvider.cjs +0 -10963
  429. package/dist/providers/HyperLiquidProvider.cjs.map +0 -1
  430. package/dist/providers/HyperLiquidProvider.d.cts +0 -656
  431. package/dist/providers/HyperLiquidProvider.d.cts.map +0 -1
  432. package/dist/providers/HyperLiquidProvider.d.mts +0 -656
  433. package/dist/providers/HyperLiquidProvider.d.mts.map +0 -1
  434. package/dist/providers/HyperLiquidProvider.mjs +0 -10959
  435. package/dist/providers/HyperLiquidProvider.mjs.map +0 -1
  436. package/dist/providers/LighterProvider.cjs +0 -6575
  437. package/dist/providers/LighterProvider.cjs.map +0 -1
  438. package/dist/providers/LighterProvider.d.cts +0 -179
  439. package/dist/providers/LighterProvider.d.cts.map +0 -1
  440. package/dist/providers/LighterProvider.d.mts +0 -179
  441. package/dist/providers/LighterProvider.d.mts.map +0 -1
  442. package/dist/providers/LighterProvider.mjs +0 -6571
  443. package/dist/providers/LighterProvider.mjs.map +0 -1
  444. package/dist/routing/ProviderRouter.cjs +0 -154
  445. package/dist/routing/ProviderRouter.cjs.map +0 -1
  446. package/dist/routing/ProviderRouter.d.cts +0 -112
  447. package/dist/routing/ProviderRouter.d.cts.map +0 -1
  448. package/dist/routing/ProviderRouter.d.mts +0 -112
  449. package/dist/routing/ProviderRouter.d.mts.map +0 -1
  450. package/dist/routing/ProviderRouter.mjs +0 -150
  451. package/dist/routing/ProviderRouter.mjs.map +0 -1
  452. package/dist/routing/index.cjs +0 -9
  453. package/dist/routing/index.cjs.map +0 -1
  454. package/dist/routing/index.d.cts +0 -6
  455. package/dist/routing/index.d.cts.map +0 -1
  456. package/dist/routing/index.d.mts +0 -6
  457. package/dist/routing/index.d.mts.map +0 -1
  458. package/dist/routing/index.mjs +0 -5
  459. package/dist/routing/index.mjs.map +0 -1
  460. package/dist/selectors.cjs +0 -264
  461. package/dist/selectors.cjs.map +0 -1
  462. package/dist/selectors.d.cts +0 -336
  463. package/dist/selectors.d.cts.map +0 -1
  464. package/dist/selectors.d.mts +0 -336
  465. package/dist/selectors.d.mts.map +0 -1
  466. package/dist/selectors.mjs +0 -249
  467. package/dist/selectors.mjs.map +0 -1
  468. package/dist/services/AccountService.cjs +0 -324
  469. package/dist/services/AccountService.cjs.map +0 -1
  470. package/dist/services/AccountService.d.cts +0 -56
  471. package/dist/services/AccountService.d.cts.map +0 -1
  472. package/dist/services/AccountService.d.mts +0 -56
  473. package/dist/services/AccountService.d.mts.map +0 -1
  474. package/dist/services/AccountService.mjs +0 -320
  475. package/dist/services/AccountService.mjs.map +0 -1
  476. package/dist/services/AggregatedOrderBookConnection.cjs +0 -405
  477. package/dist/services/AggregatedOrderBookConnection.cjs.map +0 -1
  478. package/dist/services/AggregatedOrderBookConnection.d.cts +0 -106
  479. package/dist/services/AggregatedOrderBookConnection.d.cts.map +0 -1
  480. package/dist/services/AggregatedOrderBookConnection.d.mts +0 -106
  481. package/dist/services/AggregatedOrderBookConnection.d.mts.map +0 -1
  482. package/dist/services/AggregatedOrderBookConnection.mjs +0 -400
  483. package/dist/services/AggregatedOrderBookConnection.mjs.map +0 -1
  484. package/dist/services/DataLakeService.cjs +0 -233
  485. package/dist/services/DataLakeService.cjs.map +0 -1
  486. package/dist/services/DataLakeService.d.cts +0 -51
  487. package/dist/services/DataLakeService.d.cts.map +0 -1
  488. package/dist/services/DataLakeService.d.mts +0 -51
  489. package/dist/services/DataLakeService.d.mts.map +0 -1
  490. package/dist/services/DataLakeService.mjs +0 -229
  491. package/dist/services/DataLakeService.mjs.map +0 -1
  492. package/dist/services/DepositService.cjs +0 -105
  493. package/dist/services/DepositService.cjs.map +0 -1
  494. package/dist/services/DepositService.d.cts +0 -39
  495. package/dist/services/DepositService.d.cts.map +0 -1
  496. package/dist/services/DepositService.d.mts +0 -39
  497. package/dist/services/DepositService.d.mts.map +0 -1
  498. package/dist/services/DepositService.mjs +0 -101
  499. package/dist/services/DepositService.mjs.map +0 -1
  500. package/dist/services/DexDiscoveryCacheManager.cjs +0 -147
  501. package/dist/services/DexDiscoveryCacheManager.cjs.map +0 -1
  502. package/dist/services/DexDiscoveryCacheManager.d.cts +0 -52
  503. package/dist/services/DexDiscoveryCacheManager.d.cts.map +0 -1
  504. package/dist/services/DexDiscoveryCacheManager.d.mts +0 -52
  505. package/dist/services/DexDiscoveryCacheManager.d.mts.map +0 -1
  506. package/dist/services/DexDiscoveryCacheManager.mjs +0 -143
  507. package/dist/services/DexDiscoveryCacheManager.mjs.map +0 -1
  508. package/dist/services/EligibilityService.cjs +0 -78
  509. package/dist/services/EligibilityService.cjs.map +0 -1
  510. package/dist/services/EligibilityService.d.cts +0 -28
  511. package/dist/services/EligibilityService.d.cts.map +0 -1
  512. package/dist/services/EligibilityService.d.mts +0 -28
  513. package/dist/services/EligibilityService.d.mts.map +0 -1
  514. package/dist/services/EligibilityService.mjs +0 -74
  515. package/dist/services/EligibilityService.mjs.map +0 -1
  516. package/dist/services/FeatureFlagConfigurationService.cjs +0 -257
  517. package/dist/services/FeatureFlagConfigurationService.cjs.map +0 -1
  518. package/dist/services/FeatureFlagConfigurationService.d.cts +0 -73
  519. package/dist/services/FeatureFlagConfigurationService.d.cts.map +0 -1
  520. package/dist/services/FeatureFlagConfigurationService.d.mts +0 -73
  521. package/dist/services/FeatureFlagConfigurationService.d.mts.map +0 -1
  522. package/dist/services/FeatureFlagConfigurationService.mjs +0 -253
  523. package/dist/services/FeatureFlagConfigurationService.mjs.map +0 -1
  524. package/dist/services/HyperLiquidClientService.cjs +0 -1114
  525. package/dist/services/HyperLiquidClientService.cjs.map +0 -1
  526. package/dist/services/HyperLiquidClientService.d.cts +0 -252
  527. package/dist/services/HyperLiquidClientService.d.cts.map +0 -1
  528. package/dist/services/HyperLiquidClientService.d.mts +0 -252
  529. package/dist/services/HyperLiquidClientService.d.mts.map +0 -1
  530. package/dist/services/HyperLiquidClientService.mjs +0 -1109
  531. package/dist/services/HyperLiquidClientService.mjs.map +0 -1
  532. package/dist/services/HyperLiquidSubscriptionService.cjs +0 -3594
  533. package/dist/services/HyperLiquidSubscriptionService.cjs.map +0 -1
  534. package/dist/services/HyperLiquidSubscriptionService.d.cts +0 -265
  535. package/dist/services/HyperLiquidSubscriptionService.d.cts.map +0 -1
  536. package/dist/services/HyperLiquidSubscriptionService.d.mts +0 -265
  537. package/dist/services/HyperLiquidSubscriptionService.d.mts.map +0 -1
  538. package/dist/services/HyperLiquidSubscriptionService.mjs +0 -3590
  539. package/dist/services/HyperLiquidSubscriptionService.mjs.map +0 -1
  540. package/dist/services/HyperLiquidWalletService.cjs +0 -186
  541. package/dist/services/HyperLiquidWalletService.cjs.map +0 -1
  542. package/dist/services/HyperLiquidWalletService.d.cts +0 -84
  543. package/dist/services/HyperLiquidWalletService.d.cts.map +0 -1
  544. package/dist/services/HyperLiquidWalletService.d.mts +0 -84
  545. package/dist/services/HyperLiquidWalletService.d.mts.map +0 -1
  546. package/dist/services/HyperLiquidWalletService.mjs +0 -182
  547. package/dist/services/HyperLiquidWalletService.mjs.map +0 -1
  548. package/dist/services/LighterClientService.cjs +0 -643
  549. package/dist/services/LighterClientService.cjs.map +0 -1
  550. package/dist/services/LighterClientService.d.cts +0 -200
  551. package/dist/services/LighterClientService.d.cts.map +0 -1
  552. package/dist/services/LighterClientService.d.mts +0 -200
  553. package/dist/services/LighterClientService.d.mts.map +0 -1
  554. package/dist/services/LighterClientService.mjs +0 -637
  555. package/dist/services/LighterClientService.mjs.map +0 -1
  556. package/dist/services/LighterWalletService.cjs +0 -109
  557. package/dist/services/LighterWalletService.cjs.map +0 -1
  558. package/dist/services/LighterWalletService.d.cts +0 -51
  559. package/dist/services/LighterWalletService.d.cts.map +0 -1
  560. package/dist/services/LighterWalletService.d.mts +0 -51
  561. package/dist/services/LighterWalletService.d.mts.map +0 -1
  562. package/dist/services/LighterWalletService.mjs +0 -105
  563. package/dist/services/LighterWalletService.mjs.map +0 -1
  564. package/dist/services/MarketDataService.cjs +0 -1171
  565. package/dist/services/MarketDataService.cjs.map +0 -1
  566. package/dist/services/MarketDataService.d.cts +0 -350
  567. package/dist/services/MarketDataService.d.cts.map +0 -1
  568. package/dist/services/MarketDataService.d.mts +0 -350
  569. package/dist/services/MarketDataService.d.mts.map +0 -1
  570. package/dist/services/MarketDataService.mjs +0 -1167
  571. package/dist/services/MarketDataService.mjs.map +0 -1
  572. package/dist/services/RewardsIntegrationService.cjs +0 -391
  573. package/dist/services/RewardsIntegrationService.cjs.map +0 -1
  574. package/dist/services/RewardsIntegrationService.d.cts +0 -84
  575. package/dist/services/RewardsIntegrationService.d.cts.map +0 -1
  576. package/dist/services/RewardsIntegrationService.d.mts +0 -84
  577. package/dist/services/RewardsIntegrationService.d.mts.map +0 -1
  578. package/dist/services/RewardsIntegrationService.mjs +0 -387
  579. package/dist/services/RewardsIntegrationService.mjs.map +0 -1
  580. package/dist/services/ServiceContext.cjs +0 -3
  581. package/dist/services/ServiceContext.cjs.map +0 -1
  582. package/dist/services/ServiceContext.d.cts +0 -102
  583. package/dist/services/ServiceContext.d.cts.map +0 -1
  584. package/dist/services/ServiceContext.d.mts +0 -102
  585. package/dist/services/ServiceContext.d.mts.map +0 -1
  586. package/dist/services/ServiceContext.mjs +0 -2
  587. package/dist/services/ServiceContext.mjs.map +0 -1
  588. package/dist/services/TerminalMarketService.cjs +0 -623
  589. package/dist/services/TerminalMarketService.cjs.map +0 -1
  590. package/dist/services/TerminalMarketService.d.cts +0 -45
  591. package/dist/services/TerminalMarketService.d.cts.map +0 -1
  592. package/dist/services/TerminalMarketService.d.mts +0 -45
  593. package/dist/services/TerminalMarketService.d.mts.map +0 -1
  594. package/dist/services/TerminalMarketService.mjs +0 -619
  595. package/dist/services/TerminalMarketService.mjs.map +0 -1
  596. package/dist/services/TradingReadinessCache.cjs +0 -329
  597. package/dist/services/TradingReadinessCache.cjs.map +0 -1
  598. package/dist/services/TradingReadinessCache.d.cts +0 -204
  599. package/dist/services/TradingReadinessCache.d.cts.map +0 -1
  600. package/dist/services/TradingReadinessCache.d.mts +0 -204
  601. package/dist/services/TradingReadinessCache.d.mts.map +0 -1
  602. package/dist/services/TradingReadinessCache.mjs +0 -326
  603. package/dist/services/TradingReadinessCache.mjs.map +0 -1
  604. package/dist/services/TradingService.cjs +0 -1895
  605. package/dist/services/TradingService.cjs.map +0 -1
  606. package/dist/services/TradingService.d.cts +0 -201
  607. package/dist/services/TradingService.d.cts.map +0 -1
  608. package/dist/services/TradingService.d.mts +0 -201
  609. package/dist/services/TradingService.d.mts.map +0 -1
  610. package/dist/services/TradingService.mjs +0 -1891
  611. package/dist/services/TradingService.mjs.map +0 -1
  612. package/dist/types/config.cjs +0 -3
  613. package/dist/types/config.cjs.map +0 -1
  614. package/dist/types/config.d.cts +0 -49
  615. package/dist/types/config.d.cts.map +0 -1
  616. package/dist/types/config.d.mts +0 -49
  617. package/dist/types/config.d.mts.map +0 -1
  618. package/dist/types/config.mjs +0 -2
  619. package/dist/types/config.mjs.map +0 -1
  620. package/dist/types/hyperliquid-types.cjs +0 -45
  621. package/dist/types/hyperliquid-types.cjs.map +0 -1
  622. package/dist/types/hyperliquid-types.d.cts +0 -67
  623. package/dist/types/hyperliquid-types.d.cts.map +0 -1
  624. package/dist/types/hyperliquid-types.d.mts +0 -67
  625. package/dist/types/hyperliquid-types.d.mts.map +0 -1
  626. package/dist/types/hyperliquid-types.mjs +0 -41
  627. package/dist/types/hyperliquid-types.mjs.map +0 -1
  628. package/dist/types/index.cjs +0 -151
  629. package/dist/types/index.cjs.map +0 -1
  630. package/dist/types/index.d.cts +0 -2183
  631. package/dist/types/index.d.cts.map +0 -1
  632. package/dist/types/index.d.mts +0 -2183
  633. package/dist/types/index.d.mts.map +0 -1
  634. package/dist/types/index.mjs +0 -133
  635. package/dist/types/index.mjs.map +0 -1
  636. package/dist/types/lighter-types.cjs +0 -11
  637. package/dist/types/lighter-types.cjs.map +0 -1
  638. package/dist/types/lighter-types.d.cts +0 -763
  639. package/dist/types/lighter-types.d.cts.map +0 -1
  640. package/dist/types/lighter-types.d.mts +0 -763
  641. package/dist/types/lighter-types.d.mts.map +0 -1
  642. package/dist/types/lighter-types.mjs +0 -10
  643. package/dist/types/lighter-types.mjs.map +0 -1
  644. package/dist/types/messenger.cjs +0 -3
  645. package/dist/types/messenger.cjs.map +0 -1
  646. package/dist/types/messenger.d.cts +0 -30
  647. package/dist/types/messenger.d.cts.map +0 -1
  648. package/dist/types/messenger.d.mts +0 -30
  649. package/dist/types/messenger.d.mts.map +0 -1
  650. package/dist/types/messenger.mjs +0 -2
  651. package/dist/types/messenger.mjs.map +0 -1
  652. package/dist/types/perps-types.cjs +0 -7
  653. package/dist/types/perps-types.cjs.map +0 -1
  654. package/dist/types/perps-types.d.cts +0 -184
  655. package/dist/types/perps-types.d.cts.map +0 -1
  656. package/dist/types/perps-types.d.mts +0 -184
  657. package/dist/types/perps-types.d.mts.map +0 -1
  658. package/dist/types/perps-types.mjs +0 -5
  659. package/dist/types/perps-types.mjs.map +0 -1
  660. package/dist/types/token.cjs +0 -3
  661. package/dist/types/token.cjs.map +0 -1
  662. package/dist/types/token.d.cts +0 -25
  663. package/dist/types/token.d.cts.map +0 -1
  664. package/dist/types/token.d.mts +0 -25
  665. package/dist/types/token.d.mts.map +0 -1
  666. package/dist/types/token.mjs +0 -2
  667. package/dist/types/token.mjs.map +0 -1
  668. package/dist/types/transactionTypes.cjs +0 -29
  669. package/dist/types/transactionTypes.cjs.map +0 -1
  670. package/dist/types/transactionTypes.d.cts +0 -60
  671. package/dist/types/transactionTypes.d.cts.map +0 -1
  672. package/dist/types/transactionTypes.d.mts +0 -60
  673. package/dist/types/transactionTypes.d.mts.map +0 -1
  674. package/dist/types/transactionTypes.mjs +0 -24
  675. package/dist/types/transactionTypes.mjs.map +0 -1
  676. package/dist/utils/accountUtils.cjs +0 -236
  677. package/dist/utils/accountUtils.cjs.map +0 -1
  678. package/dist/utils/accountUtils.d.cts +0 -72
  679. package/dist/utils/accountUtils.d.cts.map +0 -1
  680. package/dist/utils/accountUtils.d.mts +0 -72
  681. package/dist/utils/accountUtils.d.mts.map +0 -1
  682. package/dist/utils/accountUtils.mjs +0 -223
  683. package/dist/utils/accountUtils.mjs.map +0 -1
  684. package/dist/utils/capabilitySymbols.cjs +0 -25
  685. package/dist/utils/capabilitySymbols.cjs.map +0 -1
  686. package/dist/utils/capabilitySymbols.d.cts +0 -15
  687. package/dist/utils/capabilitySymbols.d.cts.map +0 -1
  688. package/dist/utils/capabilitySymbols.d.mts +0 -15
  689. package/dist/utils/capabilitySymbols.d.mts.map +0 -1
  690. package/dist/utils/capabilitySymbols.mjs +0 -21
  691. package/dist/utils/capabilitySymbols.mjs.map +0 -1
  692. package/dist/utils/coalescePerpsRestRequest.cjs +0 -71
  693. package/dist/utils/coalescePerpsRestRequest.cjs.map +0 -1
  694. package/dist/utils/coalescePerpsRestRequest.d.cts +0 -32
  695. package/dist/utils/coalescePerpsRestRequest.d.cts.map +0 -1
  696. package/dist/utils/coalescePerpsRestRequest.d.mts +0 -32
  697. package/dist/utils/coalescePerpsRestRequest.d.mts.map +0 -1
  698. package/dist/utils/coalescePerpsRestRequest.mjs +0 -66
  699. package/dist/utils/coalescePerpsRestRequest.mjs.map +0 -1
  700. package/dist/utils/errorUtils.cjs +0 -104
  701. package/dist/utils/errorUtils.cjs.map +0 -1
  702. package/dist/utils/errorUtils.d.cts +0 -50
  703. package/dist/utils/errorUtils.d.cts.map +0 -1
  704. package/dist/utils/errorUtils.d.mts +0 -50
  705. package/dist/utils/errorUtils.d.mts.map +0 -1
  706. package/dist/utils/errorUtils.mjs +0 -96
  707. package/dist/utils/errorUtils.mjs.map +0 -1
  708. package/dist/utils/hyperLiquidAbstraction.cjs +0 -23
  709. package/dist/utils/hyperLiquidAbstraction.cjs.map +0 -1
  710. package/dist/utils/hyperLiquidAbstraction.d.cts +0 -11
  711. package/dist/utils/hyperLiquidAbstraction.d.cts.map +0 -1
  712. package/dist/utils/hyperLiquidAbstraction.d.mts +0 -11
  713. package/dist/utils/hyperLiquidAbstraction.d.mts.map +0 -1
  714. package/dist/utils/hyperLiquidAbstraction.mjs +0 -19
  715. package/dist/utils/hyperLiquidAbstraction.mjs.map +0 -1
  716. package/dist/utils/hyperLiquidAdapter.cjs +0 -512
  717. package/dist/utils/hyperLiquidAdapter.cjs.map +0 -1
  718. package/dist/utils/hyperLiquidAdapter.d.cts +0 -77
  719. package/dist/utils/hyperLiquidAdapter.d.cts.map +0 -1
  720. package/dist/utils/hyperLiquidAdapter.d.mts +0 -77
  721. package/dist/utils/hyperLiquidAdapter.d.mts.map +0 -1
  722. package/dist/utils/hyperLiquidAdapter.mjs +0 -494
  723. package/dist/utils/hyperLiquidAdapter.mjs.map +0 -1
  724. package/dist/utils/hyperLiquidOrderBookProcessor.cjs +0 -83
  725. package/dist/utils/hyperLiquidOrderBookProcessor.cjs.map +0 -1
  726. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts +0 -55
  727. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts.map +0 -1
  728. package/dist/utils/hyperLiquidOrderBookProcessor.d.mts +0 -55
  729. package/dist/utils/hyperLiquidOrderBookProcessor.d.mts.map +0 -1
  730. package/dist/utils/hyperLiquidOrderBookProcessor.mjs +0 -78
  731. package/dist/utils/hyperLiquidOrderBookProcessor.mjs.map +0 -1
  732. package/dist/utils/hyperLiquidPositionPreview.cjs +0 -355
  733. package/dist/utils/hyperLiquidPositionPreview.cjs.map +0 -1
  734. package/dist/utils/hyperLiquidPositionPreview.d.cts +0 -124
  735. package/dist/utils/hyperLiquidPositionPreview.d.cts.map +0 -1
  736. package/dist/utils/hyperLiquidPositionPreview.d.mts +0 -124
  737. package/dist/utils/hyperLiquidPositionPreview.d.mts.map +0 -1
  738. package/dist/utils/hyperLiquidPositionPreview.mjs +0 -347
  739. package/dist/utils/hyperLiquidPositionPreview.mjs.map +0 -1
  740. package/dist/utils/hyperLiquidValidation.cjs +0 -799
  741. package/dist/utils/hyperLiquidValidation.cjs.map +0 -1
  742. package/dist/utils/hyperLiquidValidation.d.cts +0 -192
  743. package/dist/utils/hyperLiquidValidation.d.cts.map +0 -1
  744. package/dist/utils/hyperLiquidValidation.d.mts +0 -192
  745. package/dist/utils/hyperLiquidValidation.d.mts.map +0 -1
  746. package/dist/utils/hyperLiquidValidation.mjs +0 -786
  747. package/dist/utils/hyperLiquidValidation.mjs.map +0 -1
  748. package/dist/utils/idUtils.cjs +0 -18
  749. package/dist/utils/idUtils.cjs.map +0 -1
  750. package/dist/utils/idUtils.d.cts +0 -6
  751. package/dist/utils/idUtils.d.cts.map +0 -1
  752. package/dist/utils/idUtils.d.mts +0 -6
  753. package/dist/utils/idUtils.d.mts.map +0 -1
  754. package/dist/utils/idUtils.mjs +0 -10
  755. package/dist/utils/idUtils.mjs.map +0 -1
  756. package/dist/utils/index.cjs +0 -66
  757. package/dist/utils/index.cjs.map +0 -1
  758. package/dist/utils/index.d.cts +0 -29
  759. package/dist/utils/index.d.cts.map +0 -1
  760. package/dist/utils/index.d.mts +0 -29
  761. package/dist/utils/index.d.mts.map +0 -1
  762. package/dist/utils/index.mjs +0 -34
  763. package/dist/utils/index.mjs.map +0 -1
  764. package/dist/utils/lighterAdapter.cjs +0 -575
  765. package/dist/utils/lighterAdapter.cjs.map +0 -1
  766. package/dist/utils/lighterAdapter.d.cts +0 -117
  767. package/dist/utils/lighterAdapter.d.cts.map +0 -1
  768. package/dist/utils/lighterAdapter.d.mts +0 -117
  769. package/dist/utils/lighterAdapter.d.mts.map +0 -1
  770. package/dist/utils/lighterAdapter.mjs +0 -562
  771. package/dist/utils/lighterAdapter.mjs.map +0 -1
  772. package/dist/utils/marketDataTransform.cjs +0 -250
  773. package/dist/utils/marketDataTransform.cjs.map +0 -1
  774. package/dist/utils/marketDataTransform.d.cts +0 -71
  775. package/dist/utils/marketDataTransform.d.cts.map +0 -1
  776. package/dist/utils/marketDataTransform.d.mts +0 -71
  777. package/dist/utils/marketDataTransform.d.mts.map +0 -1
  778. package/dist/utils/marketDataTransform.mjs +0 -243
  779. package/dist/utils/marketDataTransform.mjs.map +0 -1
  780. package/dist/utils/marketSearch.cjs +0 -111
  781. package/dist/utils/marketSearch.cjs.map +0 -1
  782. package/dist/utils/marketSearch.d.cts +0 -48
  783. package/dist/utils/marketSearch.d.cts.map +0 -1
  784. package/dist/utils/marketSearch.d.mts +0 -48
  785. package/dist/utils/marketSearch.d.mts.map +0 -1
  786. package/dist/utils/marketSearch.mjs +0 -106
  787. package/dist/utils/marketSearch.mjs.map +0 -1
  788. package/dist/utils/marketUtils.cjs +0 -266
  789. package/dist/utils/marketUtils.cjs.map +0 -1
  790. package/dist/utils/marketUtils.d.cts +0 -73
  791. package/dist/utils/marketUtils.d.cts.map +0 -1
  792. package/dist/utils/marketUtils.d.mts +0 -73
  793. package/dist/utils/marketUtils.d.mts.map +0 -1
  794. package/dist/utils/marketUtils.mjs +0 -248
  795. package/dist/utils/marketUtils.mjs.map +0 -1
  796. package/dist/utils/orderCalculations.cjs +0 -849
  797. package/dist/utils/orderCalculations.cjs.map +0 -1
  798. package/dist/utils/orderCalculations.d.cts +0 -306
  799. package/dist/utils/orderCalculations.d.cts.map +0 -1
  800. package/dist/utils/orderCalculations.d.mts +0 -306
  801. package/dist/utils/orderCalculations.d.mts.map +0 -1
  802. package/dist/utils/orderCalculations.mjs +0 -833
  803. package/dist/utils/orderCalculations.mjs.map +0 -1
  804. package/dist/utils/orderTypes.cjs +0 -301
  805. package/dist/utils/orderTypes.cjs.map +0 -1
  806. package/dist/utils/orderTypes.d.cts +0 -166
  807. package/dist/utils/orderTypes.d.cts.map +0 -1
  808. package/dist/utils/orderTypes.d.mts +0 -166
  809. package/dist/utils/orderTypes.d.mts.map +0 -1
  810. package/dist/utils/orderTypes.mjs +0 -287
  811. package/dist/utils/orderTypes.mjs.map +0 -1
  812. package/dist/utils/perpsConnectionAttemptContext.cjs +0 -20
  813. package/dist/utils/perpsConnectionAttemptContext.cjs.map +0 -1
  814. package/dist/utils/perpsConnectionAttemptContext.d.cts +0 -7
  815. package/dist/utils/perpsConnectionAttemptContext.d.cts.map +0 -1
  816. package/dist/utils/perpsConnectionAttemptContext.d.mts +0 -7
  817. package/dist/utils/perpsConnectionAttemptContext.d.mts.map +0 -1
  818. package/dist/utils/perpsConnectionAttemptContext.mjs +0 -15
  819. package/dist/utils/perpsConnectionAttemptContext.mjs.map +0 -1
  820. package/dist/utils/perpsDiskPersistence.cjs +0 -259
  821. package/dist/utils/perpsDiskPersistence.cjs.map +0 -1
  822. package/dist/utils/perpsDiskPersistence.d.cts +0 -112
  823. package/dist/utils/perpsDiskPersistence.d.cts.map +0 -1
  824. package/dist/utils/perpsDiskPersistence.d.mts +0 -112
  825. package/dist/utils/perpsDiskPersistence.d.mts.map +0 -1
  826. package/dist/utils/perpsDiskPersistence.mjs +0 -251
  827. package/dist/utils/perpsDiskPersistence.mjs.map +0 -1
  828. package/dist/utils/perpsFormatters.cjs +0 -509
  829. package/dist/utils/perpsFormatters.cjs.map +0 -1
  830. package/dist/utils/perpsFormatters.d.cts +0 -204
  831. package/dist/utils/perpsFormatters.d.cts.map +0 -1
  832. package/dist/utils/perpsFormatters.d.mts +0 -204
  833. package/dist/utils/perpsFormatters.d.mts.map +0 -1
  834. package/dist/utils/perpsFormatters.mjs +0 -500
  835. package/dist/utils/perpsFormatters.mjs.map +0 -1
  836. package/dist/utils/rewardsUtils.cjs +0 -98
  837. package/dist/utils/rewardsUtils.cjs.map +0 -1
  838. package/dist/utils/rewardsUtils.d.cts +0 -33
  839. package/dist/utils/rewardsUtils.d.cts.map +0 -1
  840. package/dist/utils/rewardsUtils.d.mts +0 -33
  841. package/dist/utils/rewardsUtils.d.mts.map +0 -1
  842. package/dist/utils/rewardsUtils.mjs +0 -92
  843. package/dist/utils/rewardsUtils.mjs.map +0 -1
  844. package/dist/utils/significantFigures.cjs +0 -88
  845. package/dist/utils/significantFigures.cjs.map +0 -1
  846. package/dist/utils/significantFigures.d.cts +0 -25
  847. package/dist/utils/significantFigures.d.cts.map +0 -1
  848. package/dist/utils/significantFigures.d.mts +0 -25
  849. package/dist/utils/significantFigures.d.mts.map +0 -1
  850. package/dist/utils/significantFigures.mjs +0 -82
  851. package/dist/utils/significantFigures.mjs.map +0 -1
  852. package/dist/utils/sortMarkets.cjs +0 -93
  853. package/dist/utils/sortMarkets.cjs.map +0 -1
  854. package/dist/utils/sortMarkets.d.cts +0 -25
  855. package/dist/utils/sortMarkets.d.cts.map +0 -1
  856. package/dist/utils/sortMarkets.d.mts +0 -25
  857. package/dist/utils/sortMarkets.d.mts.map +0 -1
  858. package/dist/utils/sortMarkets.mjs +0 -88
  859. package/dist/utils/sortMarkets.mjs.map +0 -1
  860. package/dist/utils/standaloneInfoClient.cjs +0 -70
  861. package/dist/utils/standaloneInfoClient.cjs.map +0 -1
  862. package/dist/utils/standaloneInfoClient.d.cts +0 -37
  863. package/dist/utils/standaloneInfoClient.d.cts.map +0 -1
  864. package/dist/utils/standaloneInfoClient.d.mts +0 -37
  865. package/dist/utils/standaloneInfoClient.d.mts.map +0 -1
  866. package/dist/utils/standaloneInfoClient.mjs +0 -64
  867. package/dist/utils/standaloneInfoClient.mjs.map +0 -1
  868. package/dist/utils/stringParseUtils.cjs +0 -34
  869. package/dist/utils/stringParseUtils.cjs.map +0 -1
  870. package/dist/utils/stringParseUtils.d.cts +0 -11
  871. package/dist/utils/stringParseUtils.d.cts.map +0 -1
  872. package/dist/utils/stringParseUtils.d.mts +0 -11
  873. package/dist/utils/stringParseUtils.d.mts.map +0 -1
  874. package/dist/utils/stringParseUtils.mjs +0 -28
  875. package/dist/utils/stringParseUtils.mjs.map +0 -1
  876. package/dist/utils/transferData.cjs +0 -33
  877. package/dist/utils/transferData.cjs.map +0 -1
  878. package/dist/utils/transferData.d.cts +0 -9
  879. package/dist/utils/transferData.d.cts.map +0 -1
  880. package/dist/utils/transferData.d.mts +0 -9
  881. package/dist/utils/transferData.d.mts.map +0 -1
  882. package/dist/utils/transferData.mjs +0 -29
  883. package/dist/utils/transferData.mjs.map +0 -1
  884. package/dist/utils/wait.cjs +0 -6
  885. package/dist/utils/wait.cjs.map +0 -1
  886. package/dist/utils/wait.d.cts +0 -2
  887. package/dist/utils/wait.d.cts.map +0 -1
  888. package/dist/utils/wait.d.mts +0 -2
  889. package/dist/utils/wait.d.mts.map +0 -1
  890. package/dist/utils/wait.mjs +0 -2
  891. package/dist/utils/wait.mjs.map +0 -1
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;QAErC,IAAI,CAAC;YACH,OAAO,MAAM,QAAQ,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACnD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CACrB,WAAW,CAAC,KAAK,EAAE,mCAAmC,CAAC,EACvD;gBACE,IAAI,EAAE,EAAE,OAAO,EAAE,eAAe,CAAC,WAAW,EAAE;gBAC9C,OAAO,EAAE;oBACP,IAAI,EAAE,mCAAmC;oBACzC,IAAI,EAAE,EAAE,MAAM,EAAE;iBACjB;aACF,CACF,CAAC;YACF,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF","sourcesContent":["import { v4 as uuidv4 } from 'uuid';\n\nimport {\n PERPS_EVENT_PROPERTY,\n PERPS_EVENT_VALUE,\n} from '../constants/eventNames.js';\nimport { USDC_SYMBOL } from '../constants/hyperLiquidConfig.js';\nimport {\n PERPS_CONSTANTS,\n WITHDRAWAL_CONSTANTS,\n} from '../constants/perpsConfig.js';\nimport { PERPS_ERROR_CODES } from '../perpsErrorCodes.js';\nimport {\n PerpsAnalyticsEvent,\n PerpsTraceNames,\n PerpsTraceOperations,\n} from '../types/index.js';\nimport type {\n PerpsProvider,\n WithdrawParams,\n WithdrawResult,\n PerpsPlatformDependencies,\n} from '../types/index.js';\nimport type { PerpsControllerMessengerBase } from '../types/messenger.js';\nimport type { TransactionStatus } from '../types/transactionTypes.js';\nimport { getSelectedEvmAccountFromMessenger } from '../utils/accountUtils.js';\nimport { ensureError } from '../utils/errorUtils.js';\nimport type { ServiceContext } from './ServiceContext.js';\n\n/**\n * AccountService\n *\n * Handles account operations (deposits, withdrawals).\n * Stateless service that delegates to provider.\n * Controller handles state updates and analytics.\n *\n * Instance-based service with constructor injection of platform dependencies\n * and messenger for inter-controller communication.\n */\nexport class AccountService {\n readonly #deps: PerpsPlatformDependencies;\n\n readonly #messenger: PerpsControllerMessengerBase;\n\n /**\n * Create a new AccountService instance\n *\n * @param deps - Platform dependencies for logging, metrics, etc.\n * @param messenger - Controller messenger for cross-controller communication.\n */\n constructor(\n deps: PerpsPlatformDependencies,\n messenger: PerpsControllerMessengerBase,\n ) {\n this.#deps = deps;\n this.#messenger = messenger;\n }\n\n /**\n * Withdraw funds with full orchestration\n * Handles tracing, state management, analytics, and account refresh\n *\n * @param options - The withdrawal configuration.\n * @param options.provider - The perps provider to execute the withdrawal.\n * @param options.params - The withdrawal parameters (amount, destination, etc.).\n * @param options.context - The service context for tracing and dependencies.\n * @param options.refreshAccountState - Callback to refresh account state after withdrawal.\n * @returns The withdrawal result containing success status and transaction details.\n */\n async withdraw(options: {\n provider: PerpsProvider;\n params: WithdrawParams;\n context: ServiceContext;\n refreshAccountState: () => Promise<void>;\n }): Promise<WithdrawResult> {\n const { provider, params, context, refreshAccountState } = options;\n\n const traceId = uuidv4();\n const startTime = this.#deps.performance.now();\n let traceData:\n | {\n success: boolean;\n error?: string;\n txHash?: string;\n withdrawalId?: string;\n }\n | undefined;\n\n // Generate withdrawal request ID for tracking\n const currentWithdrawalId = `withdraw-${Date.now()}-${Math.random()\n .toString(36)\n .substring(2, 11)}`;\n\n try {\n this.#deps.tracer.trace({\n name: PerpsTraceNames.Withdraw,\n id: traceId,\n op: PerpsTraceOperations.Operation,\n tags: {\n assetId: params.assetId ?? '',\n provider: context.tracingContext.provider,\n isTestnet: String(context.tracingContext.isTestnet),\n },\n });\n\n this.#deps.debugLogger.log('AccountService: STARTING WITHDRAWAL', {\n params,\n timestamp: new Date().toISOString(),\n assetId: params.assetId,\n amount: params.amount,\n destination: params.destination,\n activeProvider: context.tracingContext.provider,\n isTestnet: context.tracingContext.isTestnet,\n });\n\n // Set withdrawal in progress\n if (context.stateManager) {\n context.stateManager.update((state) => {\n state.withdrawInProgress = true;\n\n // Calculate net amount after fees\n const grossAmount = parseFloat(params.amount);\n const feeAmount = WITHDRAWAL_CONSTANTS.DefaultFeeAmount;\n const netAmount = Math.max(0, grossAmount - feeAmount);\n\n // Get current account address via messenger\n const evmAccount = getSelectedEvmAccountFromMessenger(\n this.#messenger,\n );\n const accountAddress = evmAccount?.address ?? 'unknown';\n\n this.#deps.debugLogger.log(\n 'AccountService: Creating withdrawal request',\n {\n accountAddress,\n hasEvmAccount: Boolean(evmAccount),\n evmAccountAddress: evmAccount?.address,\n amount: netAmount.toString(),\n },\n );\n\n // Add withdrawal request to tracking\n const withdrawalRequest = {\n id: currentWithdrawalId,\n timestamp: Date.now(),\n amount: netAmount.toString(), // Use net amount (after fees)\n asset: USDC_SYMBOL,\n accountAddress, // Track which account initiated withdrawal\n success: false, // Will be updated when transaction completes\n txHash: undefined,\n status: 'pending' as TransactionStatus,\n destination: params.destination,\n transactionId: undefined, // Will be set to withdrawalId when available\n };\n\n state.withdrawalRequests.unshift(withdrawalRequest);\n });\n }\n\n this.#deps.debugLogger.log('AccountService: DELEGATING TO PROVIDER', {\n provider: context.tracingContext.provider,\n providerReady: Boolean(provider),\n });\n\n // Execute withdrawal\n const result = await provider.withdraw(params);\n\n this.#deps.debugLogger.log('AccountService: WITHDRAWAL RESULT', {\n success: result.success,\n error: result.error,\n txHash: result.txHash,\n timestamp: new Date().toISOString(),\n });\n\n // Update state based on result\n if (result.success) {\n if (context.stateManager) {\n context.stateManager.update((state) => {\n state.lastError = null;\n state.lastUpdateTimestamp = Date.now();\n\n const withdrawalRequestIndex = state.withdrawalRequests.findIndex(\n (req) => req.id === currentWithdrawalId,\n );\n\n if (result.txHash) {\n // Direct completion: remove from queue and record the txHash\n // so the polling hook won't re-match this completion.\n // We do NOT update lastCompletedWithdrawalTimestamp here\n // because Date.now() is local device time while the FIFO guard\n // compares against API server timestamps — mixing domains can\n // poison the guard. The txHash exclusion alone prevents\n // re-matching since the item is also spliced from the queue.\n if (withdrawalRequestIndex !== -1) {\n state.withdrawalRequests.splice(withdrawalRequestIndex, 1);\n }\n\n state.lastCompletedWithdrawalTxHashes.push(result.txHash);\n\n const hasOtherPending = state.withdrawalRequests.some(\n (req) => req.status === 'pending' || req.status === 'bridging',\n );\n state.withdrawInProgress = hasOtherPending;\n } else if (withdrawalRequestIndex !== -1) {\n const requestToUpdate =\n state.withdrawalRequests[withdrawalRequestIndex];\n // Withdrawal is bridging (no txHash yet)\n requestToUpdate.status = 'bridging' as TransactionStatus;\n requestToUpdate.success = true;\n if (result.withdrawalId) {\n requestToUpdate.withdrawalId = result.withdrawalId;\n }\n }\n\n // Set lastWithdrawResult when submission is successful (even if bridging)\n // This triggers the \"confirmed\" toast telling user funds arrive in ~5 mins\n state.lastWithdrawResult = {\n success: true,\n txHash: result.txHash ?? '',\n amount: params.amount,\n asset: USDC_SYMBOL,\n timestamp: Date.now(),\n error: '',\n };\n });\n }\n\n this.#deps.debugLogger.log('AccountService: WITHDRAWAL SUCCESSFUL', {\n txHash: result.txHash,\n amount: params.amount,\n assetId: params.assetId,\n withdrawalId: result.withdrawalId,\n });\n\n // Track withdrawal transaction executed\n const completionDuration = this.#deps.performance.now() - startTime;\n this.#deps.metrics.trackPerpsEvent(\n PerpsAnalyticsEvent.WithdrawalTransaction,\n {\n [PERPS_EVENT_PROPERTY.STATUS]: PERPS_EVENT_VALUE.STATUS.EXECUTED,\n [PERPS_EVENT_PROPERTY.WITHDRAWAL_AMOUNT]: parseFloat(params.amount),\n [PERPS_EVENT_PROPERTY.COMPLETION_DURATION]: completionDuration,\n },\n );\n\n // Trigger account state refresh after withdrawal\n refreshAccountState().catch((refreshError) => {\n this.#deps.logger.error(\n ensureError(refreshError, 'AccountService.withdraw'),\n {\n tags: { feature: PERPS_CONSTANTS.FeatureName },\n context: {\n name: 'AccountService.withdraw',\n data: { operation: 'refreshAccountState' },\n },\n },\n );\n });\n\n // Invalidate standalone caches so external hooks (e.g., usePerpsPositionForAsset) refresh\n this.#deps.cacheInvalidator.invalidate({ cacheType: 'accountState' });\n\n traceData = {\n success: true,\n txHash: result.txHash ?? '',\n withdrawalId: result.withdrawalId ?? '',\n };\n\n return result;\n }\n\n // Handle failure\n if (context.stateManager) {\n context.stateManager.update((state) => {\n state.lastError = result.error ?? PERPS_ERROR_CODES.WITHDRAW_FAILED;\n state.lastUpdateTimestamp = Date.now();\n state.lastWithdrawResult = {\n success: false,\n error: result.error ?? PERPS_ERROR_CODES.WITHDRAW_FAILED,\n amount: params.amount,\n asset: USDC_SYMBOL,\n timestamp: Date.now(),\n txHash: '',\n };\n\n const withdrawalRequestIndex = state.withdrawalRequests.findIndex(\n (req) => req.id === currentWithdrawalId,\n );\n if (withdrawalRequestIndex !== -1) {\n state.withdrawalRequests.splice(withdrawalRequestIndex, 1);\n }\n state.withdrawInProgress = state.withdrawalRequests.some(\n (req) => req.status === 'pending' || req.status === 'bridging',\n );\n });\n }\n\n this.#deps.debugLogger.log('AccountService: WITHDRAWAL FAILED', {\n error: result.error,\n params,\n });\n\n // Track withdrawal transaction failed\n const completionDuration = this.#deps.performance.now() - startTime;\n this.#deps.metrics.trackPerpsEvent(\n PerpsAnalyticsEvent.WithdrawalTransaction,\n {\n [PERPS_EVENT_PROPERTY.STATUS]: PERPS_EVENT_VALUE.STATUS.FAILED,\n [PERPS_EVENT_PROPERTY.WITHDRAWAL_AMOUNT]: parseFloat(params.amount),\n [PERPS_EVENT_PROPERTY.COMPLETION_DURATION]: completionDuration,\n [PERPS_EVENT_PROPERTY.ERROR_MESSAGE]: result.error ?? 'Unknown error',\n },\n );\n\n traceData = {\n success: false,\n error: result.error ?? 'Unknown error',\n };\n\n return result;\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : PERPS_ERROR_CODES.WITHDRAW_FAILED;\n\n this.#deps.logger.error(ensureError(error, 'AccountService.withdraw'), {\n tags: { feature: PERPS_CONSTANTS.FeatureName },\n context: {\n name: 'AccountService.withdraw',\n data: { assetId: params.assetId, amount: params.amount },\n },\n });\n\n if (context.stateManager) {\n context.stateManager.update((state) => {\n state.lastError = errorMessage;\n state.lastUpdateTimestamp = Date.now();\n state.lastWithdrawResult = {\n success: false,\n error: errorMessage,\n amount: '0',\n asset: USDC_SYMBOL,\n timestamp: Date.now(),\n txHash: '',\n };\n\n const withdrawalRequestIndex = state.withdrawalRequests.findIndex(\n (req) => req.id === currentWithdrawalId,\n );\n if (withdrawalRequestIndex !== -1) {\n state.withdrawalRequests.splice(withdrawalRequestIndex, 1);\n }\n state.withdrawInProgress = state.withdrawalRequests.some(\n (req) => req.status === 'pending' || req.status === 'bridging',\n );\n });\n }\n\n // Track withdrawal transaction failed (catch block)\n const completionDuration = this.#deps.performance.now() - startTime;\n this.#deps.metrics.trackPerpsEvent(\n PerpsAnalyticsEvent.WithdrawalTransaction,\n {\n [PERPS_EVENT_PROPERTY.STATUS]: PERPS_EVENT_VALUE.STATUS.FAILED,\n [PERPS_EVENT_PROPERTY.WITHDRAWAL_AMOUNT]: params.amount,\n [PERPS_EVENT_PROPERTY.COMPLETION_DURATION]: completionDuration,\n [PERPS_EVENT_PROPERTY.ERROR_MESSAGE]: errorMessage,\n },\n );\n\n traceData = {\n success: false,\n error: errorMessage,\n };\n\n return { success: false, error: errorMessage };\n } finally {\n this.#deps.tracer.endTrace({\n name: PerpsTraceNames.Withdraw,\n id: traceId,\n data: traceData,\n });\n }\n }\n\n /**\n * Validate withdrawal parameters\n *\n * @param options - The validation configuration.\n * @param options.provider - The perps provider to validate against.\n * @param options.params - The withdrawal parameters to validate.\n * @returns An object indicating whether the withdrawal is valid, with an optional error message.\n */\n async validateWithdrawal(options: {\n provider: PerpsProvider;\n params: WithdrawParams;\n }): Promise<{ isValid: boolean; error?: string }> {\n const { provider, params } = options;\n\n try {\n return await provider.validateWithdrawal(params);\n } catch (error) {\n this.#deps.logger.error(\n ensureError(error, 'AccountService.validateWithdrawal'),\n {\n tags: { feature: PERPS_CONSTANTS.FeatureName },\n context: {\n name: 'AccountService.validateWithdrawal',\n data: { params },\n },\n },\n );\n throw error;\n }\n }\n}\n"]}
@@ -0,0 +1,106 @@
1
+ import type { OrderBookData } from '../types/index.js';
2
+ /**
3
+ * A single L2 book price level as delivered by Hyperliquid's `l2Book`
4
+ * subscription. Declared locally to avoid coupling to the SDK's exported type
5
+ * names (and to keep this the only file that references the SDK's shapes).
6
+ */
7
+ type HyperliquidL2BookLevel = {
8
+ /** Price. */
9
+ px: string;
10
+ /** Total size resting at this price. */
11
+ sz: string;
12
+ /** Number of individual orders. */
13
+ n: number;
14
+ };
15
+ /** `l2Book` snapshot event (index 0 = bids, index 1 = asks). */
16
+ type HyperliquidL2BookEvent = {
17
+ coin: string;
18
+ time: number;
19
+ levels: [bids: HyperliquidL2BookLevel[], asks: HyperliquidL2BookLevel[]];
20
+ spread?: string;
21
+ };
22
+ /**
23
+ * Health of the dedicated order-book socket, surfaced to the UI so the panel
24
+ * can show a reconnect affordance.
25
+ *
26
+ * - `connecting`: socket opening or reconnecting after a transient drop.
27
+ * - `connected`: subscription is live.
28
+ * - `error`: dropped and automatic reconnection was exhausted; needs a manual reconnect.
29
+ */
30
+ export type OrderBookConnectionStatus = 'connecting' | 'connected' | 'error';
31
+ export type SubscribeAggregatedOrderBookParams = {
32
+ /** Market symbol (e.g. 'BTC'). */
33
+ symbol: string;
34
+ /** Number of levels per side to keep. */
35
+ levels?: number;
36
+ /**
37
+ * Server-side aggregation significant figures. Required: omitting it would
38
+ * request the raw, full-precision book instead of an aggregated one, which
39
+ * contradicts this service's contract.
40
+ */
41
+ nSigFigs: 2 | 3 | 4 | 5;
42
+ /** Mantissa refinement when `nSigFigs` is 5. */
43
+ mantissa?: 2 | 5;
44
+ /** Invoked with each processed snapshot. */
45
+ callback: (data: OrderBookData) => void;
46
+ /** Invoked when the underlying socket's health changes. */
47
+ onStatusChange?: (status: OrderBookConnectionStatus) => void;
48
+ };
49
+ export type AggregatedOrderBookConnectionOptions = {
50
+ /** Resolves the current network at subscribe time. */
51
+ isTestnet: () => boolean;
52
+ };
53
+ /**
54
+ * Transforms a raw Hyperliquid `l2Book` snapshot into the `OrderBookData` shape
55
+ * the UI consumes. Mirrors the subscription service's internal
56
+ * `processOrderBookData` so this dedicated connection is a drop-in replacement
57
+ * for `subscribeToOrderBook` on the aggregated channel.
58
+ *
59
+ * @param data - Raw `l2Book` event.
60
+ * @param levels - Number of levels per side to keep.
61
+ * @returns Processed order-book snapshot.
62
+ */
63
+ export declare function processAggregatedOrderBook(data: HyperliquidL2BookEvent, levels: number): OrderBookData;
64
+ /**
65
+ * Owns a dedicated Hyperliquid WebSocket connection used solely for the
66
+ * order-book panel's server-aggregated `l2Book` subscription.
67
+ *
68
+ * The main connection (managed by the subscription service) multiplexes every
69
+ * subscription onto a single socket. The Hyperliquid SDK dispatches `l2Book`
70
+ * events by `coin` only, so running the raw (full-precision) and the aggregated
71
+ * (`nSigFigs`) subscriptions for the same coin on that shared socket
72
+ * cross-contaminates them — the coarse ladder and the precise spread/slippage
73
+ * clobber each other. Giving the aggregated subscription its own socket removes
74
+ * the collision entirely: this socket only ever carries a single `l2Book`
75
+ * stream, and the main socket is never touched by the panel's grouping.
76
+ *
77
+ * The socket is created lazily on the first subscription and torn down once the
78
+ * last subscription is removed, so it exists only while an order-book panel is
79
+ * open. Because network is a global setting, the transport is recreated if
80
+ * `isTestnet` changes between (re)subscriptions.
81
+ */
82
+ export declare class AggregatedOrderBookConnection {
83
+ #private;
84
+ constructor({ isTestnet }: AggregatedOrderBookConnectionOptions);
85
+ /**
86
+ * Opens an aggregated `l2Book` subscription on the dedicated socket.
87
+ *
88
+ * Mirrors the subscription service's synchronous-unsubscribe contract: the
89
+ * returned function can be called before the async subscribe resolves and
90
+ * will cancel the pending subscription.
91
+ *
92
+ * Only one `l2Book` payload per asset may be active at a time. Subscribing to
93
+ * an asset that already has a live subscription with different params (e.g. a
94
+ * different `nSigFigs` or `mantissa`) throws, because the shared socket
95
+ * dispatches by `coin` and the conflicting streams would clobber each other.
96
+ *
97
+ * @param params - Subscription parameters.
98
+ * @returns An unsubscribe function.
99
+ * @throws If the asset already has an active subscription with different params.
100
+ */
101
+ subscribe(params: SubscribeAggregatedOrderBookParams): () => void;
102
+ /** Closes the dedicated socket and drops all subscriptions. */
103
+ close(): void;
104
+ }
105
+ export {};
106
+ //# sourceMappingURL=AggregatedOrderBookConnection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AggregatedOrderBookConnection.d.ts","sourceRoot":"","sources":["../../src/services/AggregatedOrderBookConnection.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;;GAIG;AACH,KAAK,sBAAsB,GAAG;IAC5B,aAAa;IACb,EAAE,EAAE,MAAM,CAAC;IACX,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,mCAAmC;IACnC,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,gEAAgE;AAChE,KAAK,sBAAsB,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,CAAC,IAAI,EAAE,sBAAsB,EAAE,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC,CAAC;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,yBAAyB,GAAG,YAAY,GAAG,WAAW,GAAG,OAAO,CAAC;AAE7E,MAAM,MAAM,kCAAkC,GAAG;IAC/C,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,QAAQ,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACjB,4CAA4C;IAC5C,QAAQ,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,2DAA2D;IAC3D,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,yBAAyB,KAAK,IAAI,CAAC;CAC9D,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG;IACjD,sDAAsD;IACtD,SAAS,EAAE,MAAM,OAAO,CAAC;CAC1B,CAAC;AAMF;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,sBAAsB,EAC5B,MAAM,EAAE,MAAM,GACb,aAAa,CAyDf;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,6BAA6B;;IA8BxC,YAAY,EAAE,SAAS,EAAE,EAAE,oCAAoC,EAE9D;IAED;;;;;;;;;;;;;;;OAeG;IACH,SAAS,CAAC,MAAM,EAAE,kCAAkC,GAAG,MAAM,IAAI,CAuNhE;IAED,+DAA+D;IAC/D,KAAK,IAAI,IAAI,CAEZ;CAgEF"}
@@ -0,0 +1,388 @@
1
+ import { SubscriptionClient, WebSocketTransport } from '@nktkas/hyperliquid';
2
+ import { HYPERLIQUID_TRANSPORT_CONFIG } from '../constants/hyperLiquidConfig.js';
3
+ // Fast mode streams 5 levels per side (slow mode streams 20). We run fast mode
4
+ // for lower-latency ladder updates, so the book never carries more than this.
5
+ const DEFAULT_LEVELS = 5;
6
+ /**
7
+ * Transforms a raw Hyperliquid `l2Book` snapshot into the `OrderBookData` shape
8
+ * the UI consumes. Mirrors the subscription service's internal
9
+ * `processOrderBookData` so this dedicated connection is a drop-in replacement
10
+ * for `subscribeToOrderBook` on the aggregated channel.
11
+ *
12
+ * @param data - Raw `l2Book` event.
13
+ * @param levels - Number of levels per side to keep.
14
+ * @returns Processed order-book snapshot.
15
+ */
16
+ export function processAggregatedOrderBook(data, levels) {
17
+ const bidsRaw = data?.levels?.[0] ?? [];
18
+ const asksRaw = data?.levels?.[1] ?? [];
19
+ let bidCumulativeSize = 0;
20
+ let bidCumulativeNotional = 0;
21
+ const bids = bidsRaw.slice(0, levels).map((level) => {
22
+ const price = Number.parseFloat(level.px);
23
+ const size = Number.parseFloat(level.sz);
24
+ const notional = price * size;
25
+ bidCumulativeSize += size;
26
+ bidCumulativeNotional += notional;
27
+ return {
28
+ price: level.px,
29
+ size: level.sz,
30
+ total: bidCumulativeSize.toString(),
31
+ notional: notional.toFixed(2),
32
+ totalNotional: bidCumulativeNotional.toFixed(2),
33
+ };
34
+ });
35
+ let askCumulativeSize = 0;
36
+ let askCumulativeNotional = 0;
37
+ const asks = asksRaw.slice(0, levels).map((level) => {
38
+ const price = Number.parseFloat(level.px);
39
+ const size = Number.parseFloat(level.sz);
40
+ const notional = price * size;
41
+ askCumulativeSize += size;
42
+ askCumulativeNotional += notional;
43
+ return {
44
+ price: level.px,
45
+ size: level.sz,
46
+ total: askCumulativeSize.toString(),
47
+ notional: notional.toFixed(2),
48
+ totalNotional: askCumulativeNotional.toFixed(2),
49
+ };
50
+ });
51
+ const bestBid = bids[0];
52
+ const bestAsk = asks[0];
53
+ const bidPrice = bestBid ? Number.parseFloat(bestBid.price) : 0;
54
+ const askPrice = bestAsk ? Number.parseFloat(bestAsk.price) : 0;
55
+ const spread = askPrice > 0 && bidPrice > 0 ? askPrice - bidPrice : 0;
56
+ const midPrice = askPrice > 0 && bidPrice > 0 ? (askPrice + bidPrice) / 2 : 0;
57
+ const spreadPercentage = midPrice > 0 ? ((spread / midPrice) * 100).toFixed(4) : '0';
58
+ const maxTotal = Math.max(bidCumulativeSize, askCumulativeSize).toString();
59
+ return {
60
+ bids,
61
+ asks,
62
+ spread: spread.toFixed(5),
63
+ spreadPercentage,
64
+ midPrice: midPrice.toFixed(5),
65
+ lastUpdated: Date.now(),
66
+ maxTotal,
67
+ };
68
+ }
69
+ /**
70
+ * Owns a dedicated Hyperliquid WebSocket connection used solely for the
71
+ * order-book panel's server-aggregated `l2Book` subscription.
72
+ *
73
+ * The main connection (managed by the subscription service) multiplexes every
74
+ * subscription onto a single socket. The Hyperliquid SDK dispatches `l2Book`
75
+ * events by `coin` only, so running the raw (full-precision) and the aggregated
76
+ * (`nSigFigs`) subscriptions for the same coin on that shared socket
77
+ * cross-contaminates them — the coarse ladder and the precise spread/slippage
78
+ * clobber each other. Giving the aggregated subscription its own socket removes
79
+ * the collision entirely: this socket only ever carries a single `l2Book`
80
+ * stream, and the main socket is never touched by the panel's grouping.
81
+ *
82
+ * The socket is created lazily on the first subscription and torn down once the
83
+ * last subscription is removed, so it exists only while an order-book panel is
84
+ * open. Because network is a global setting, the transport is recreated if
85
+ * `isTestnet` changes between (re)subscriptions.
86
+ */
87
+ export class AggregatedOrderBookConnection {
88
+ #isTestnet;
89
+ #transport = null;
90
+ #transportIsTestnet = false;
91
+ #activeCount = 0;
92
+ // Tracks the single `l2Book` payload the dedicated socket carries per asset,
93
+ // keyed by symbol. The SDK dispatches `l2Book` events by `coin` only, so two
94
+ // subscriptions for the same asset with different params (e.g. `nSigFigs`)
95
+ // would cross-contaminate on this shared socket — exactly the collision this
96
+ // connection exists to avoid. `count` refcounts the (identical) subscriptions
97
+ // sharing a payload so the entry is dropped once the last one unsubscribes.
98
+ #payloads = new Map();
99
+ // Force-terminate callback for every currently-active subscription. When a
100
+ // transport rebuild (`#closeTransport`) shuts the socket down out from under
101
+ // live subscriptions, these tear each one down — notifying the caller and
102
+ // releasing its SDK subscription / socket listeners — instead of orphaning
103
+ // them (stale handle, no more updates, and no further status because
104
+ // reporting is suppressed once `transport !== this.#transport`).
105
+ #activeSubscriptions = new Set();
106
+ // Set when the socket's auto-reconnection is exhausted (its
107
+ // `terminationSignal` aborts). A terminated socket cannot recover, so the next
108
+ // subscribe must build a fresh transport instead of reusing the dead one.
109
+ #terminated = false;
110
+ constructor({ isTestnet }) {
111
+ this.#isTestnet = isTestnet;
112
+ }
113
+ /**
114
+ * Opens an aggregated `l2Book` subscription on the dedicated socket.
115
+ *
116
+ * Mirrors the subscription service's synchronous-unsubscribe contract: the
117
+ * returned function can be called before the async subscribe resolves and
118
+ * will cancel the pending subscription.
119
+ *
120
+ * Only one `l2Book` payload per asset may be active at a time. Subscribing to
121
+ * an asset that already has a live subscription with different params (e.g. a
122
+ * different `nSigFigs` or `mantissa`) throws, because the shared socket
123
+ * dispatches by `coin` and the conflicting streams would clobber each other.
124
+ *
125
+ * @param params - Subscription parameters.
126
+ * @returns An unsubscribe function.
127
+ * @throws If the asset already has an active subscription with different params.
128
+ */
129
+ subscribe(params) {
130
+ const levels = params.levels ?? DEFAULT_LEVELS;
131
+ // The `l2Book` subscription params the socket carries. `levels` is
132
+ // client-side only (it slices each snapshot), so it is deliberately excluded
133
+ // from the params and their signature.
134
+ const l2BookParams = {
135
+ coin: params.symbol,
136
+ nSigFigs: params.nSigFigs,
137
+ mantissa: params.mantissa ?? null,
138
+ fast: true,
139
+ };
140
+ const signature = JSON.stringify(l2BookParams);
141
+ const transport = this.#ensureTransport(this.#isTestnet());
142
+ // Reject a conflicting payload for an asset already on this socket. A
143
+ // recreated transport (first use, network change, or terminate) starts with
144
+ // an empty payload map, so this can only trip on the reuse path — the shared
145
+ // socket that would actually suffer the collision.
146
+ const existingPayload = this.#payloads.get(params.symbol);
147
+ if (existingPayload && existingPayload.signature !== signature) {
148
+ throw new Error(`AggregatedOrderBookConnection: "${params.symbol}" is already subscribed with different params; only one l2Book payload per asset is allowed on the dedicated socket.`);
149
+ }
150
+ const { socket } = transport;
151
+ let cancelled = false;
152
+ let subscription = null;
153
+ this.#activeCount += 1;
154
+ if (existingPayload) {
155
+ existingPayload.count += 1;
156
+ }
157
+ else {
158
+ this.#payloads.set(params.symbol, { signature, count: 1 });
159
+ }
160
+ // Set once this subscription's socket terminates (reconnection exhausted).
161
+ // The `error` state is terminal until teardown/resubscribe, so once set we
162
+ // suppress any late `connected`/`connecting` — e.g. from a subscribe promise
163
+ // that resolves *after* the socket died — which would otherwise flip the UI
164
+ // back to a healthy state on a dead socket and hide the manual-reconnect
165
+ // affordance.
166
+ let terminated = false;
167
+ const reportStatus = (status) => {
168
+ // Suppress reports from a subscription that no longer drives the UI: it
169
+ // was unsubscribed (`cancelled`), its transport was replaced by a network
170
+ // flip or recreate (`transport !== this.#transport`, so its socket is
171
+ // dead), or its socket permanently terminated and `error` is now sticky
172
+ // until teardown (`terminated`).
173
+ if (cancelled ||
174
+ transport !== this.#transport ||
175
+ (terminated && status !== 'error')) {
176
+ return;
177
+ }
178
+ params.onStatusChange?.(status);
179
+ };
180
+ // Reflect the socket's live health. Every drop dispatches a `close` event;
181
+ // the reconnecting socket only exposes permanent termination through its
182
+ // `terminationSignal` (an `AbortSignal`), which it aborts *before* the final
183
+ // close. So an aborted signal on close — unless it was our own `close()`
184
+ // (`TERMINATED_BY_USER`) — means automatic reconnection is exhausted: the
185
+ // unrecoverable state the UI surfaces with a manual reconnect button. A
186
+ // still-live signal means a transient drop the socket will auto-reconnect.
187
+ const handleOpen = () => reportStatus('connected');
188
+ const handleClose = () => {
189
+ // A torn-down subscription must not mutate shared connection state. Its
190
+ // listeners are normally detached before the socket closes, but guard
191
+ // anyway so a late `close` (e.g. from `transport.close()` racing listener
192
+ // removal) can't wrongly flip `#terminated`.
193
+ if (cancelled) {
194
+ return;
195
+ }
196
+ const { terminationSignal } = socket;
197
+ const terminatedByUser = terminationSignal.reason?.code ===
198
+ 'TERMINATED_BY_USER';
199
+ if (terminationSignal.aborted && !terminatedByUser) {
200
+ this.#terminated = true;
201
+ terminated = true;
202
+ reportStatus('error');
203
+ return;
204
+ }
205
+ reportStatus('connecting');
206
+ };
207
+ socket.addEventListener('open', handleOpen);
208
+ socket.addEventListener('close', handleClose);
209
+ const removeSocketListeners = () => {
210
+ socket.removeEventListener('open', handleOpen);
211
+ socket.removeEventListener('close', handleClose);
212
+ };
213
+ // Ends this subscription when its transport is torn down beneath it (network
214
+ // flip, post-termination resubscribe, or `close()`). Unlike `teardown` it
215
+ // leaves the shared refcount/payload state alone — `#closeTransport` clears
216
+ // those wholesale — but still notifies the caller and releases this
217
+ // subscription's resources so nothing leaks on the dead socket.
218
+ const forceTerminate = () => {
219
+ if (cancelled) {
220
+ return;
221
+ }
222
+ // Notify directly rather than via `reportStatus`: `#closeTransport`
223
+ // detaches `#transport` before invoking these callbacks (so a reentrant
224
+ // subscribe from this handler builds a fresh transport instead of binding
225
+ // to the dying one), which would otherwise trip `reportStatus`'s
226
+ // stale-transport guard. A subscription whose socket already terminated
227
+ // has reported `error`; a still-live one (abandoned by a network flip or
228
+ // `close()`) needs the terminal signal so the caller stops trusting a
229
+ // now-dead book.
230
+ if (!terminated) {
231
+ params.onStatusChange?.('error');
232
+ }
233
+ cancelled = true;
234
+ removeSocketListeners();
235
+ this.#activeSubscriptions.delete(forceTerminate);
236
+ if (subscription) {
237
+ subscription.unsubscribe().catch(() => undefined);
238
+ subscription = null;
239
+ }
240
+ };
241
+ this.#activeSubscriptions.add(forceTerminate);
242
+ // Releases this subscription's refcount and tears down the socket once no
243
+ // subscriptions remain. Idempotent via `cancelled`, so it's safe whether it
244
+ // runs from the returned unsubscribe or from a failed subscribe.
245
+ const teardown = () => {
246
+ if (cancelled) {
247
+ return;
248
+ }
249
+ cancelled = true;
250
+ removeSocketListeners();
251
+ this.#activeSubscriptions.delete(forceTerminate);
252
+ if (subscription) {
253
+ subscription.unsubscribe().catch(() => undefined);
254
+ subscription = null;
255
+ }
256
+ // Only touch the refcount/current socket if this subscription still
257
+ // belongs to the active transport. If the transport was recreated (network
258
+ // change or terminate), this subscription's socket is already dead and
259
+ // `#activeCount` now tracks only the new transport's subscriptions — so an
260
+ // older unsubscribe must not decrement it and tear down the live socket.
261
+ if (transport === this.#transport) {
262
+ this.#activeCount = Math.max(0, this.#activeCount - 1);
263
+ const entry = this.#payloads.get(params.symbol);
264
+ if (entry) {
265
+ entry.count -= 1;
266
+ if (entry.count <= 0) {
267
+ this.#payloads.delete(params.symbol);
268
+ }
269
+ }
270
+ if (this.#activeCount === 0) {
271
+ this.#closeTransport();
272
+ }
273
+ }
274
+ };
275
+ // Surfaces a subscription failure the same way regardless of when it
276
+ // happens: report `error` (before teardown flips `cancelled`, which gates
277
+ // status updates) then release the refcount so the dead subscription doesn't
278
+ // keep the dedicated socket open. Used for both the initial subscribe
279
+ // rejection (`.catch`) and post-confirmation failures the SDK reports only
280
+ // through `onError` — e.g. the server rejecting the re-subscription after a
281
+ // reconnect, which removes the listener and stops all further events (a
282
+ // frozen order book that would otherwise still read as `connected`).
283
+ // Idempotent via `teardown`'s `cancelled` guard.
284
+ const handleSubscriptionError = () => {
285
+ reportStatus('error');
286
+ teardown();
287
+ };
288
+ reportStatus('connecting');
289
+ // Subscribe through the typed `l2Book` client so the params are validated
290
+ // before they reach the wire (`fast: true` requests fast mode — 5 levels at
291
+ // ~0.5s). The listener receives the decoded snapshot directly.
292
+ new SubscriptionClient({ transport })
293
+ .l2Book(l2BookParams, (data) => {
294
+ if (cancelled || data?.coin !== params.symbol || !data?.levels) {
295
+ return;
296
+ }
297
+ params.callback(processAggregatedOrderBook(data, levels));
298
+ },
299
+ // `onError` fires at most once for an *already confirmed* subscription
300
+ // that later fails (rejected re-subscription after reconnect, permanent
301
+ // termination, or a drop while re-subscription is disabled). The SDK
302
+ // removes the listener and emits nothing further, so treat it exactly
303
+ // like an initial failure.
304
+ { onError: handleSubscriptionError })
305
+ .then(async (sub) => {
306
+ // Stale if this subscription was unsubscribed (`cancelled`) or its
307
+ // transport was replaced (network flip / recreate) before the subscribe
308
+ // settled — either way the captured socket is dead, so clean up the SDK
309
+ // subscription instead of storing it or announcing `connected`.
310
+ if (cancelled || transport !== this.#transport) {
311
+ try {
312
+ await sub.unsubscribe();
313
+ }
314
+ catch {
315
+ // Ignore cleanup errors on an already-cancelled/stale subscription.
316
+ }
317
+ return undefined;
318
+ }
319
+ subscription = sub;
320
+ reportStatus('connected');
321
+ return undefined;
322
+ })
323
+ .catch(handleSubscriptionError);
324
+ return teardown;
325
+ }
326
+ /** Closes the dedicated socket and drops all subscriptions. */
327
+ close() {
328
+ this.#closeTransport();
329
+ }
330
+ #ensureTransport(isTestnet) {
331
+ if (this.#transport &&
332
+ this.#transportIsTestnet === isTestnet &&
333
+ !this.#terminated) {
334
+ return this.#transport;
335
+ }
336
+ // First use, the network changed, or the previous socket was terminated —
337
+ // (re)create the dedicated transport. Reuse the package's transport config
338
+ // so this socket shares the finite five-attempt reconnection policy; without
339
+ // it the SDK defaults `maxRetries` to Infinity and a sustained outage would
340
+ // never exhaust reconnection to reach the `error`/manual-reconnect state.
341
+ this.#closeTransport();
342
+ // `#closeTransport` notifies subscribers, which may synchronously re-enter
343
+ // `subscribe` and build a matching transport. Reuse it instead of orphaning
344
+ // it (which would leak the reentrant subscription on an unreferenced socket).
345
+ if (this.#transport &&
346
+ this.#transportIsTestnet === isTestnet &&
347
+ !this.#terminated) {
348
+ return this.#transport;
349
+ }
350
+ const transport = new WebSocketTransport({
351
+ isTestnet,
352
+ ...HYPERLIQUID_TRANSPORT_CONFIG,
353
+ reconnect: HYPERLIQUID_TRANSPORT_CONFIG.reconnect,
354
+ });
355
+ this.#transport = transport;
356
+ this.#transportIsTestnet = isTestnet;
357
+ return transport;
358
+ }
359
+ #closeTransport() {
360
+ const transport = this.#transport;
361
+ // Snapshot the subscriptions to force-terminate, then detach ALL shared
362
+ // state (the set, `#transport`, refcounts) *before* invoking any callback.
363
+ // Those callbacks notify subscribers via `onStatusChange`, which can
364
+ // synchronously re-enter `subscribe`; detaching first guarantees a reentrant
365
+ // subscribe builds a fresh transport (rather than reusing this dying one)
366
+ // and registers itself in a clean set (rather than being swept up by, or
367
+ // lingering past, this teardown). Subscriptions torn down normally have
368
+ // already removed themselves, so their entry is a no-op here.
369
+ const subscriptions = [...this.#activeSubscriptions];
370
+ this.#activeSubscriptions.clear();
371
+ this.#transport = null;
372
+ this.#activeCount = 0;
373
+ this.#payloads.clear();
374
+ this.#terminated = false;
375
+ // Force-terminate (which detaches each subscription's socket listeners)
376
+ // BEFORE closing the transport. `close()` on an already-exhausted socket
377
+ // dispatches a final `close`; if a stale `handleClose` were still attached
378
+ // it would re-set `#terminated` right after we cleared it, making the next
379
+ // `#ensureTransport` tear down the healthy replacement socket.
380
+ for (const forceTerminate of subscriptions) {
381
+ forceTerminate();
382
+ }
383
+ if (transport) {
384
+ transport.close();
385
+ }
386
+ }
387
+ }
388
+ //# sourceMappingURL=AggregatedOrderBookConnection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AggregatedOrderBookConnection.js","sourceRoot":"","sources":["../../src/services/AggregatedOrderBookConnection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG7E,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AA2DjF,+EAA+E;AAC/E,8EAA8E;AAC9E,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB;;;;;;;;;GASG;AACH,MAAM,UAAU,0BAA0B,CACxC,IAA4B,EAC5B,MAAc;IAEd,MAAM,OAAO,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACxC,MAAM,OAAO,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAExC,IAAI,iBAAiB,GAAG,CAAC,CAAC;IAC1B,IAAI,qBAAqB,GAAG,CAAC,CAAC;IAC9B,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAClD,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAG,KAAK,GAAG,IAAI,CAAC;QAC9B,iBAAiB,IAAI,IAAI,CAAC;QAC1B,qBAAqB,IAAI,QAAQ,CAAC;QAClC,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,EAAE;YACf,IAAI,EAAE,KAAK,CAAC,EAAE;YACd,KAAK,EAAE,iBAAiB,CAAC,QAAQ,EAAE;YACnC,QAAQ,EAAE,QAAQ,C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E,+DAA+D;QAC/D,KAAK,MAAM,cAAc,IAAI,aAAa,EAAE,CAAC;YAC3C,cAAc,EAAE,CAAC;QACnB,CAAC;QACD,IAAI,SAAS,EAAE,CAAC;YACd,SAAS,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC;IACH,CAAC;CACF","sourcesContent":["import { SubscriptionClient, WebSocketTransport } from '@nktkas/hyperliquid';\nimport type { ISubscription } from '@nktkas/hyperliquid';\n\nimport { HYPERLIQUID_TRANSPORT_CONFIG } from '../constants/hyperLiquidConfig.js';\nimport type { OrderBookData } from '../types/index.js';\n\n/**\n * A single L2 book price level as delivered by Hyperliquid's `l2Book`\n * subscription. Declared locally to avoid coupling to the SDK's exported type\n * names (and to keep this the only file that references the SDK's shapes).\n */\ntype HyperliquidL2BookLevel = {\n /** Price. */\n px: string;\n /** Total size resting at this price. */\n sz: string;\n /** Number of individual orders. */\n n: number;\n};\n\n/** `l2Book` snapshot event (index 0 = bids, index 1 = asks). */\ntype HyperliquidL2BookEvent = {\n coin: string;\n time: number;\n levels: [bids: HyperliquidL2BookLevel[], asks: HyperliquidL2BookLevel[]];\n spread?: string;\n};\n\n/**\n * Health of the dedicated order-book socket, surfaced to the UI so the panel\n * can show a reconnect affordance.\n *\n * - `connecting`: socket opening or reconnecting after a transient drop.\n * - `connected`: subscription is live.\n * - `error`: dropped and automatic reconnection was exhausted; needs a manual reconnect.\n */\nexport type OrderBookConnectionStatus = 'connecting' | 'connected' | 'error';\n\nexport type SubscribeAggregatedOrderBookParams = {\n /** Market symbol (e.g. 'BTC'). */\n symbol: string;\n /** Number of levels per side to keep. */\n levels?: number;\n /**\n * Server-side aggregation significant figures. Required: omitting it would\n * request the raw, full-precision book instead of an aggregated one, which\n * contradicts this service's contract.\n */\n nSigFigs: 2 | 3 | 4 | 5;\n /** Mantissa refinement when `nSigFigs` is 5. */\n mantissa?: 2 | 5;\n /** Invoked with each processed snapshot. */\n callback: (data: OrderBookData) => void;\n /** Invoked when the underlying socket's health changes. */\n onStatusChange?: (status: OrderBookConnectionStatus) => void;\n};\n\nexport type AggregatedOrderBookConnectionOptions = {\n /** Resolves the current network at subscribe time. */\n isTestnet: () => boolean;\n};\n\n// Fast mode streams 5 levels per side (slow mode streams 20). We run fast mode\n// for lower-latency ladder updates, so the book never carries more than this.\nconst DEFAULT_LEVELS = 5;\n\n/**\n * Transforms a raw Hyperliquid `l2Book` snapshot into the `OrderBookData` shape\n * the UI consumes. Mirrors the subscription service's internal\n * `processOrderBookData` so this dedicated connection is a drop-in replacement\n * for `subscribeToOrderBook` on the aggregated channel.\n *\n * @param data - Raw `l2Book` event.\n * @param levels - Number of levels per side to keep.\n * @returns Processed order-book snapshot.\n */\nexport function processAggregatedOrderBook(\n data: HyperliquidL2BookEvent,\n levels: number,\n): OrderBookData {\n const bidsRaw = data?.levels?.[0] ?? [];\n const asksRaw = data?.levels?.[1] ?? [];\n\n let bidCumulativeSize = 0;\n let bidCumulativeNotional = 0;\n const bids = bidsRaw.slice(0, levels).map((level) => {\n const price = Number.parseFloat(level.px);\n const size = Number.parseFloat(level.sz);\n const notional = price * size;\n bidCumulativeSize += size;\n bidCumulativeNotional += notional;\n return {\n price: level.px,\n size: level.sz,\n total: bidCumulativeSize.toString(),\n notional: notional.toFixed(2),\n totalNotional: bidCumulativeNotional.toFixed(2),\n };\n });\n\n let askCumulativeSize = 0;\n let askCumulativeNotional = 0;\n const asks = asksRaw.slice(0, levels).map((level) => {\n const price = Number.parseFloat(level.px);\n const size = Number.parseFloat(level.sz);\n const notional = price * size;\n askCumulativeSize += size;\n askCumulativeNotional += notional;\n return {\n price: level.px,\n size: level.sz,\n total: askCumulativeSize.toString(),\n notional: notional.toFixed(2),\n totalNotional: askCumulativeNotional.toFixed(2),\n };\n });\n\n const bestBid = bids[0];\n const bestAsk = asks[0];\n const bidPrice = bestBid ? Number.parseFloat(bestBid.price) : 0;\n const askPrice = bestAsk ? Number.parseFloat(bestAsk.price) : 0;\n const spread = askPrice > 0 && bidPrice > 0 ? askPrice - bidPrice : 0;\n const midPrice = askPrice > 0 && bidPrice > 0 ? (askPrice + bidPrice) / 2 : 0;\n const spreadPercentage =\n midPrice > 0 ? ((spread / midPrice) * 100).toFixed(4) : '0';\n const maxTotal = Math.max(bidCumulativeSize, askCumulativeSize).toString();\n\n return {\n bids,\n asks,\n spread: spread.toFixed(5),\n spreadPercentage,\n midPrice: midPrice.toFixed(5),\n lastUpdated: Date.now(),\n maxTotal,\n };\n}\n\n/**\n * Owns a dedicated Hyperliquid WebSocket connection used solely for the\n * order-book panel's server-aggregated `l2Book` subscription.\n *\n * The main connection (managed by the subscription service) multiplexes every\n * subscription onto a single socket. The Hyperliquid SDK dispatches `l2Book`\n * events by `coin` only, so running the raw (full-precision) and the aggregated\n * (`nSigFigs`) subscriptions for the same coin on that shared socket\n * cross-contaminates them — the coarse ladder and the precise spread/slippage\n * clobber each other. Giving the aggregated subscription its own socket removes\n * the collision entirely: this socket only ever carries a single `l2Book`\n * stream, and the main socket is never touched by the panel's grouping.\n *\n * The socket is created lazily on the first subscription and torn down once the\n * last subscription is removed, so it exists only while an order-book panel is\n * open. Because network is a global setting, the transport is recreated if\n * `isTestnet` changes between (re)subscriptions.\n */\nexport class AggregatedOrderBookConnection {\n readonly #isTestnet: () => boolean;\n\n #transport: WebSocketTransport | null = null;\n\n #transportIsTestnet = false;\n\n #activeCount = 0;\n\n // Tracks the single `l2Book` payload the dedicated socket carries per asset,\n // keyed by symbol. The SDK dispatches `l2Book` events by `coin` only, so two\n // subscriptions for the same asset with different params (e.g. `nSigFigs`)\n // would cross-contaminate on this shared socket — exactly the collision this\n // connection exists to avoid. `count` refcounts the (identical) subscriptions\n // sharing a payload so the entry is dropped once the last one unsubscribes.\n readonly #payloads = new Map<string, { signature: string; count: number }>();\n\n // Force-terminate callback for every currently-active subscription. When a\n // transport rebuild (`#closeTransport`) shuts the socket down out from under\n // live subscriptions, these tear each one down — notifying the caller and\n // releasing its SDK subscription / socket listeners — instead of orphaning\n // them (stale handle, no more updates, and no further status because\n // reporting is suppressed once `transport !== this.#transport`).\n readonly #activeSubscriptions = new Set<() => void>();\n\n // Set when the socket's auto-reconnection is exhausted (its\n // `terminationSignal` aborts). A terminated socket cannot recover, so the next\n // subscribe must build a fresh transport instead of reusing the dead one.\n #terminated = false;\n\n constructor({ isTestnet }: AggregatedOrderBookConnectionOptions) {\n this.#isTestnet = isTestnet;\n }\n\n /**\n * Opens an aggregated `l2Book` subscription on the dedicated socket.\n *\n * Mirrors the subscription service's synchronous-unsubscribe contract: the\n * returned function can be called before the async subscribe resolves and\n * will cancel the pending subscription.\n *\n * Only one `l2Book` payload per asset may be active at a time. Subscribing to\n * an asset that already has a live subscription with different params (e.g. a\n * different `nSigFigs` or `mantissa`) throws, because the shared socket\n * dispatches by `coin` and the conflicting streams would clobber each other.\n *\n * @param params - Subscription parameters.\n * @returns An unsubscribe function.\n * @throws If the asset already has an active subscription with different params.\n */\n subscribe(params: SubscribeAggregatedOrderBookParams): () => void {\n const levels = params.levels ?? DEFAULT_LEVELS;\n // The `l2Book` subscription params the socket carries. `levels` is\n // client-side only (it slices each snapshot), so it is deliberately excluded\n // from the params and their signature.\n const l2BookParams = {\n coin: params.symbol,\n nSigFigs: params.nSigFigs,\n mantissa: params.mantissa ?? null,\n fast: true as const,\n };\n const signature = JSON.stringify(l2BookParams);\n\n const transport = this.#ensureTransport(this.#isTestnet());\n\n // Reject a conflicting payload for an asset already on this socket. A\n // recreated transport (first use, network change, or terminate) starts with\n // an empty payload map, so this can only trip on the reuse path — the shared\n // socket that would actually suffer the collision.\n const existingPayload = this.#payloads.get(params.symbol);\n if (existingPayload && existingPayload.signature !== signature) {\n throw new Error(\n `AggregatedOrderBookConnection: \"${params.symbol}\" is already subscribed with different params; only one l2Book payload per asset is allowed on the dedicated socket.`,\n );\n }\n\n const { socket } = transport;\n\n let cancelled = false;\n let subscription: ISubscription | null = null;\n this.#activeCount += 1;\n if (existingPayload) {\n existingPayload.count += 1;\n } else {\n this.#payloads.set(params.symbol, { signature, count: 1 });\n }\n\n // Set once this subscription's socket terminates (reconnection exhausted).\n // The `error` state is terminal until teardown/resubscribe, so once set we\n // suppress any late `connected`/`connecting` — e.g. from a subscribe promise\n // that resolves *after* the socket died — which would otherwise flip the UI\n // back to a healthy state on a dead socket and hide the manual-reconnect\n // affordance.\n let terminated = false;\n const reportStatus = (status: OrderBookConnectionStatus): void => {\n // Suppress reports from a subscription that no longer drives the UI: it\n // was unsubscribed (`cancelled`), its transport was replaced by a network\n // flip or recreate (`transport !== this.#transport`, so its socket is\n // dead), or its socket permanently terminated and `error` is now sticky\n // until teardown (`terminated`).\n if (\n cancelled ||\n transport !== this.#transport ||\n (terminated && status !== 'error')\n ) {\n return;\n }\n params.onStatusChange?.(status);\n };\n\n // Reflect the socket's live health. Every drop dispatches a `close` event;\n // the reconnecting socket only exposes permanent termination through its\n // `terminationSignal` (an `AbortSignal`), which it aborts *before* the final\n // close. So an aborted signal on close — unless it was our own `close()`\n // (`TERMINATED_BY_USER`) — means automatic reconnection is exhausted: the\n // unrecoverable state the UI surfaces with a manual reconnect button. A\n // still-live signal means a transient drop the socket will auto-reconnect.\n const handleOpen = (): void => reportStatus('connected');\n const handleClose = (): void => {\n // A torn-down subscription must not mutate shared connection state. Its\n // listeners are normally detached before the socket closes, but guard\n // anyway so a late `close` (e.g. from `transport.close()` racing listener\n // removal) can't wrongly flip `#terminated`.\n if (cancelled) {\n return;\n }\n const { terminationSignal } = socket;\n const terminatedByUser =\n (terminationSignal.reason as { code?: string } | undefined)?.code ===\n 'TERMINATED_BY_USER';\n if (terminationSignal.aborted && !terminatedByUser) {\n this.#terminated = true;\n terminated = true;\n reportStatus('error');\n return;\n }\n reportStatus('connecting');\n };\n socket.addEventListener('open', handleOpen);\n socket.addEventListener('close', handleClose);\n\n const removeSocketListeners = (): void => {\n socket.removeEventListener('open', handleOpen);\n socket.removeEventListener('close', handleClose);\n };\n\n // Ends this subscription when its transport is torn down beneath it (network\n // flip, post-termination resubscribe, or `close()`). Unlike `teardown` it\n // leaves the shared refcount/payload state alone — `#closeTransport` clears\n // those wholesale — but still notifies the caller and releases this\n // subscription's resources so nothing leaks on the dead socket.\n const forceTerminate = (): void => {\n if (cancelled) {\n return;\n }\n // Notify directly rather than via `reportStatus`: `#closeTransport`\n // detaches `#transport` before invoking these callbacks (so a reentrant\n // subscribe from this handler builds a fresh transport instead of binding\n // to the dying one), which would otherwise trip `reportStatus`'s\n // stale-transport guard. A subscription whose socket already terminated\n // has reported `error`; a still-live one (abandoned by a network flip or\n // `close()`) needs the terminal signal so the caller stops trusting a\n // now-dead book.\n if (!terminated) {\n params.onStatusChange?.('error');\n }\n cancelled = true;\n removeSocketListeners();\n this.#activeSubscriptions.delete(forceTerminate);\n if (subscription) {\n subscription.unsubscribe().catch(() => undefined);\n subscription = null;\n }\n };\n this.#activeSubscriptions.add(forceTerminate);\n\n // Releases this subscription's refcount and tears down the socket once no\n // subscriptions remain. Idempotent via `cancelled`, so it's safe whether it\n // runs from the returned unsubscribe or from a failed subscribe.\n const teardown = (): void => {\n if (cancelled) {\n return;\n }\n cancelled = true;\n removeSocketListeners();\n this.#activeSubscriptions.delete(forceTerminate);\n if (subscription) {\n subscription.unsubscribe().catch(() => undefined);\n subscription = null;\n }\n // Only touch the refcount/current socket if this subscription still\n // belongs to the active transport. If the transport was recreated (network\n // change or terminate), this subscription's socket is already dead and\n // `#activeCount` now tracks only the new transport's subscriptions — so an\n // older unsubscribe must not decrement it and tear down the live socket.\n if (transport === this.#transport) {\n this.#activeCount = Math.max(0, this.#activeCount - 1);\n const entry = this.#payloads.get(params.symbol);\n if (entry) {\n entry.count -= 1;\n if (entry.count <= 0) {\n this.#payloads.delete(params.symbol);\n }\n }\n if (this.#activeCount === 0) {\n this.#closeTransport();\n }\n }\n };\n\n // Surfaces a subscription failure the same way regardless of when it\n // happens: report `error` (before teardown flips `cancelled`, which gates\n // status updates) then release the refcount so the dead subscription doesn't\n // keep the dedicated socket open. Used for both the initial subscribe\n // rejection (`.catch`) and post-confirmation failures the SDK reports only\n // through `onError` — e.g. the server rejecting the re-subscription after a\n // reconnect, which removes the listener and stops all further events (a\n // frozen order book that would otherwise still read as `connected`).\n // Idempotent via `teardown`'s `cancelled` guard.\n const handleSubscriptionError = (): void => {\n reportStatus('error');\n teardown();\n };\n\n reportStatus('connecting');\n\n // Subscribe through the typed `l2Book` client so the params are validated\n // before they reach the wire (`fast: true` requests fast mode — 5 levels at\n // ~0.5s). The listener receives the decoded snapshot directly.\n new SubscriptionClient({ transport })\n .l2Book(\n l2BookParams,\n (data: HyperliquidL2BookEvent) => {\n if (cancelled || data?.coin !== params.symbol || !data?.levels) {\n return;\n }\n params.callback(processAggregatedOrderBook(data, levels));\n },\n // `onError` fires at most once for an *already confirmed* subscription\n // that later fails (rejected re-subscription after reconnect, permanent\n // termination, or a drop while re-subscription is disabled). The SDK\n // removes the listener and emits nothing further, so treat it exactly\n // like an initial failure.\n { onError: handleSubscriptionError },\n )\n .then(async (sub) => {\n // Stale if this subscription was unsubscribed (`cancelled`) or its\n // transport was replaced (network flip / recreate) before the subscribe\n // settled — either way the captured socket is dead, so clean up the SDK\n // subscription instead of storing it or announcing `connected`.\n if (cancelled || transport !== this.#transport) {\n try {\n await sub.unsubscribe();\n } catch {\n // Ignore cleanup errors on an already-cancelled/stale subscription.\n }\n return undefined;\n }\n subscription = sub;\n reportStatus('connected');\n return undefined;\n })\n .catch(handleSubscriptionError);\n\n return teardown;\n }\n\n /** Closes the dedicated socket and drops all subscriptions. */\n close(): void {\n this.#closeTransport();\n }\n\n #ensureTransport(isTestnet: boolean): WebSocketTransport {\n if (\n this.#transport &&\n this.#transportIsTestnet === isTestnet &&\n !this.#terminated\n ) {\n return this.#transport;\n }\n // First use, the network changed, or the previous socket was terminated —\n // (re)create the dedicated transport. Reuse the package's transport config\n // so this socket shares the finite five-attempt reconnection policy; without\n // it the SDK defaults `maxRetries` to Infinity and a sustained outage would\n // never exhaust reconnection to reach the `error`/manual-reconnect state.\n this.#closeTransport();\n // `#closeTransport` notifies subscribers, which may synchronously re-enter\n // `subscribe` and build a matching transport. Reuse it instead of orphaning\n // it (which would leak the reentrant subscription on an unreferenced socket).\n if (\n this.#transport &&\n this.#transportIsTestnet === isTestnet &&\n !this.#terminated\n ) {\n return this.#transport;\n }\n const transport = new WebSocketTransport({\n isTestnet,\n ...HYPERLIQUID_TRANSPORT_CONFIG,\n reconnect: HYPERLIQUID_TRANSPORT_CONFIG.reconnect,\n });\n this.#transport = transport;\n this.#transportIsTestnet = isTestnet;\n return transport;\n }\n\n #closeTransport(): void {\n const transport = this.#transport;\n // Snapshot the subscriptions to force-terminate, then detach ALL shared\n // state (the set, `#transport`, refcounts) *before* invoking any callback.\n // Those callbacks notify subscribers via `onStatusChange`, which can\n // synchronously re-enter `subscribe`; detaching first guarantees a reentrant\n // subscribe builds a fresh transport (rather than reusing this dying one)\n // and registers itself in a clean set (rather than being swept up by, or\n // lingering past, this teardown). Subscriptions torn down normally have\n // already removed themselves, so their entry is a no-op here.\n const subscriptions = [...this.#activeSubscriptions];\n this.#activeSubscriptions.clear();\n this.#transport = null;\n this.#activeCount = 0;\n this.#payloads.clear();\n this.#terminated = false;\n // Force-terminate (which detaches each subscription's socket listeners)\n // BEFORE closing the transport. `close()` on an already-exhausted socket\n // dispatches a final `close`; if a stale `handleClose` were still attached\n // it would re-set `#terminated` right after we cleared it, making the next\n // `#ensureTransport` tear down the healthy replacement socket.\n for (const forceTerminate of subscriptions) {\n forceTerminate();\n }\n if (transport) {\n transport.close();\n }\n }\n}\n"]}