@metamask-previews/perps-controller 0.0.0-preview-e4aa1532 → 0.0.0-preview-6dfa4aeba

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 (498) hide show
  1. package/CHANGELOG.md +1 -11
  2. package/dist/PerpsController.cjs +66 -2224
  3. package/dist/PerpsController.cjs.map +1 -1
  4. package/dist/PerpsController.d.cts +79 -933
  5. package/dist/PerpsController.d.cts.map +1 -1
  6. package/dist/PerpsController.d.mts +79 -933
  7. package/dist/PerpsController.d.mts.map +1 -1
  8. package/dist/PerpsController.mjs +64 -2221
  9. package/dist/PerpsController.mjs.map +1 -1
  10. package/dist/index.cjs +1 -32
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +2 -6
  13. package/dist/index.d.cts.map +1 -1
  14. package/dist/index.d.mts +2 -6
  15. package/dist/index.d.mts.map +1 -1
  16. package/dist/index.mjs +1 -9
  17. package/dist/index.mjs.map +1 -1
  18. package/package.json +4 -19
  19. package/dist/__mocks__/hyperliquidMock.cjs +0 -68
  20. package/dist/__mocks__/hyperliquidMock.cjs.map +0 -1
  21. package/dist/__mocks__/hyperliquidMock.d.cts +0 -15
  22. package/dist/__mocks__/hyperliquidMock.d.cts.map +0 -1
  23. package/dist/__mocks__/hyperliquidMock.d.mts +0 -15
  24. package/dist/__mocks__/hyperliquidMock.d.mts.map +0 -1
  25. package/dist/__mocks__/hyperliquidMock.mjs +0 -65
  26. package/dist/__mocks__/hyperliquidMock.mjs.map +0 -1
  27. package/dist/__mocks__/providerMocks.cjs +0 -144
  28. package/dist/__mocks__/providerMocks.cjs.map +0 -1
  29. package/dist/__mocks__/providerMocks.d.cts +0 -44
  30. package/dist/__mocks__/providerMocks.d.cts.map +0 -1
  31. package/dist/__mocks__/providerMocks.d.mts +0 -44
  32. package/dist/__mocks__/providerMocks.d.mts.map +0 -1
  33. package/dist/__mocks__/providerMocks.mjs +0 -136
  34. package/dist/__mocks__/providerMocks.mjs.map +0 -1
  35. package/dist/__mocks__/serviceMocks.cjs +0 -187
  36. package/dist/__mocks__/serviceMocks.cjs.map +0 -1
  37. package/dist/__mocks__/serviceMocks.d.cts +0 -58
  38. package/dist/__mocks__/serviceMocks.d.cts.map +0 -1
  39. package/dist/__mocks__/serviceMocks.d.mts +0 -58
  40. package/dist/__mocks__/serviceMocks.d.mts.map +0 -1
  41. package/dist/__mocks__/serviceMocks.mjs +0 -180
  42. package/dist/__mocks__/serviceMocks.mjs.map +0 -1
  43. package/dist/aggregation/SubscriptionMultiplexer.cjs +0 -459
  44. package/dist/aggregation/SubscriptionMultiplexer.cjs.map +0 -1
  45. package/dist/aggregation/SubscriptionMultiplexer.d.cts +0 -222
  46. package/dist/aggregation/SubscriptionMultiplexer.d.cts.map +0 -1
  47. package/dist/aggregation/SubscriptionMultiplexer.d.mts +0 -222
  48. package/dist/aggregation/SubscriptionMultiplexer.d.mts.map +0 -1
  49. package/dist/aggregation/SubscriptionMultiplexer.mjs +0 -455
  50. package/dist/aggregation/SubscriptionMultiplexer.mjs.map +0 -1
  51. package/dist/aggregation/index.cjs +0 -9
  52. package/dist/aggregation/index.cjs.map +0 -1
  53. package/dist/aggregation/index.d.cts +0 -6
  54. package/dist/aggregation/index.d.cts.map +0 -1
  55. package/dist/aggregation/index.d.mts +0 -6
  56. package/dist/aggregation/index.d.mts.map +0 -1
  57. package/dist/aggregation/index.mjs +0 -5
  58. package/dist/aggregation/index.mjs.map +0 -1
  59. package/dist/constants/eventNames.cjs +0 -117
  60. package/dist/constants/eventNames.cjs.map +0 -1
  61. package/dist/constants/eventNames.d.cts +0 -106
  62. package/dist/constants/eventNames.d.cts.map +0 -1
  63. package/dist/constants/eventNames.d.mts +0 -106
  64. package/dist/constants/eventNames.d.mts.map +0 -1
  65. package/dist/constants/eventNames.mjs +0 -114
  66. package/dist/constants/eventNames.mjs.map +0 -1
  67. package/dist/constants/hyperLiquidConfig.cjs +0 -366
  68. package/dist/constants/hyperLiquidConfig.cjs.map +0 -1
  69. package/dist/constants/hyperLiquidConfig.d.cts +0 -276
  70. package/dist/constants/hyperLiquidConfig.d.cts.map +0 -1
  71. package/dist/constants/hyperLiquidConfig.d.mts +0 -276
  72. package/dist/constants/hyperLiquidConfig.d.mts.map +0 -1
  73. package/dist/constants/hyperLiquidConfig.mjs +0 -357
  74. package/dist/constants/hyperLiquidConfig.mjs.map +0 -1
  75. package/dist/constants/index.cjs +0 -23
  76. package/dist/constants/index.cjs.map +0 -1
  77. package/dist/constants/index.d.cts +0 -7
  78. package/dist/constants/index.d.cts.map +0 -1
  79. package/dist/constants/index.d.mts +0 -7
  80. package/dist/constants/index.d.mts.map +0 -1
  81. package/dist/constants/index.mjs +0 -7
  82. package/dist/constants/index.mjs.map +0 -1
  83. package/dist/constants/orderTypes.cjs +0 -31
  84. package/dist/constants/orderTypes.cjs.map +0 -1
  85. package/dist/constants/orderTypes.d.cts +0 -19
  86. package/dist/constants/orderTypes.d.cts.map +0 -1
  87. package/dist/constants/orderTypes.d.mts +0 -19
  88. package/dist/constants/orderTypes.d.mts.map +0 -1
  89. package/dist/constants/orderTypes.mjs +0 -27
  90. package/dist/constants/orderTypes.mjs.map +0 -1
  91. package/dist/constants/performanceMetrics.cjs +0 -61
  92. package/dist/constants/performanceMetrics.cjs.map +0 -1
  93. package/dist/constants/performanceMetrics.d.cts +0 -44
  94. package/dist/constants/performanceMetrics.d.cts.map +0 -1
  95. package/dist/constants/performanceMetrics.d.mts +0 -44
  96. package/dist/constants/performanceMetrics.d.mts.map +0 -1
  97. package/dist/constants/performanceMetrics.mjs +0 -58
  98. package/dist/constants/performanceMetrics.mjs.map +0 -1
  99. package/dist/constants/perpsConfig.cjs +0 -461
  100. package/dist/constants/perpsConfig.cjs.map +0 -1
  101. package/dist/constants/perpsConfig.d.cts +0 -343
  102. package/dist/constants/perpsConfig.d.cts.map +0 -1
  103. package/dist/constants/perpsConfig.d.mts +0 -343
  104. package/dist/constants/perpsConfig.d.mts.map +0 -1
  105. package/dist/constants/perpsConfig.mjs +0 -458
  106. package/dist/constants/perpsConfig.mjs.map +0 -1
  107. package/dist/constants/perpsErrorCodes.cjs +0 -79
  108. package/dist/constants/perpsErrorCodes.cjs.map +0 -1
  109. package/dist/constants/perpsErrorCodes.d.cts +0 -64
  110. package/dist/constants/perpsErrorCodes.d.cts.map +0 -1
  111. package/dist/constants/perpsErrorCodes.d.mts +0 -64
  112. package/dist/constants/perpsErrorCodes.d.mts.map +0 -1
  113. package/dist/constants/perpsErrorCodes.mjs +0 -76
  114. package/dist/constants/perpsErrorCodes.mjs.map +0 -1
  115. package/dist/platform-services/HyperLiquidClientService.cjs +0 -857
  116. package/dist/platform-services/HyperLiquidClientService.cjs.map +0 -1
  117. package/dist/platform-services/HyperLiquidClientService.d.cts +0 -263
  118. package/dist/platform-services/HyperLiquidClientService.d.cts.map +0 -1
  119. package/dist/platform-services/HyperLiquidClientService.d.mts +0 -263
  120. package/dist/platform-services/HyperLiquidClientService.d.mts.map +0 -1
  121. package/dist/platform-services/HyperLiquidClientService.mjs +0 -853
  122. package/dist/platform-services/HyperLiquidClientService.mjs.map +0 -1
  123. package/dist/platform-services/HyperLiquidSubscriptionService.cjs +0 -2170
  124. package/dist/platform-services/HyperLiquidSubscriptionService.cjs.map +0 -1
  125. package/dist/platform-services/HyperLiquidSubscriptionService.d.cts +0 -424
  126. package/dist/platform-services/HyperLiquidSubscriptionService.d.cts.map +0 -1
  127. package/dist/platform-services/HyperLiquidSubscriptionService.d.mts +0 -424
  128. package/dist/platform-services/HyperLiquidSubscriptionService.d.mts.map +0 -1
  129. package/dist/platform-services/HyperLiquidSubscriptionService.mjs +0 -2166
  130. package/dist/platform-services/HyperLiquidSubscriptionService.mjs.map +0 -1
  131. package/dist/platform-services/HyperLiquidWalletService.cjs +0 -140
  132. package/dist/platform-services/HyperLiquidWalletService.cjs.map +0 -1
  133. package/dist/platform-services/HyperLiquidWalletService.d.cts +0 -78
  134. package/dist/platform-services/HyperLiquidWalletService.d.cts.map +0 -1
  135. package/dist/platform-services/HyperLiquidWalletService.d.mts +0 -78
  136. package/dist/platform-services/HyperLiquidWalletService.d.mts.map +0 -1
  137. package/dist/platform-services/HyperLiquidWalletService.mjs +0 -136
  138. package/dist/platform-services/HyperLiquidWalletService.mjs.map +0 -1
  139. package/dist/providers/AggregatedPerpsProvider.cjs +0 -777
  140. package/dist/providers/AggregatedPerpsProvider.cjs.map +0 -1
  141. package/dist/providers/AggregatedPerpsProvider.d.cts +0 -466
  142. package/dist/providers/AggregatedPerpsProvider.d.cts.map +0 -1
  143. package/dist/providers/AggregatedPerpsProvider.d.mts +0 -466
  144. package/dist/providers/AggregatedPerpsProvider.d.mts.map +0 -1
  145. package/dist/providers/AggregatedPerpsProvider.mjs +0 -773
  146. package/dist/providers/AggregatedPerpsProvider.mjs.map +0 -1
  147. package/dist/providers/HyperLiquidProvider.cjs +0 -5172
  148. package/dist/providers/HyperLiquidProvider.cjs.map +0 -1
  149. package/dist/providers/HyperLiquidProvider.d.cts +0 -881
  150. package/dist/providers/HyperLiquidProvider.d.cts.map +0 -1
  151. package/dist/providers/HyperLiquidProvider.d.mts +0 -881
  152. package/dist/providers/HyperLiquidProvider.d.mts.map +0 -1
  153. package/dist/providers/HyperLiquidProvider.mjs +0 -5168
  154. package/dist/providers/HyperLiquidProvider.mjs.map +0 -1
  155. package/dist/providers/index.cjs +0 -11
  156. package/dist/providers/index.cjs.map +0 -1
  157. package/dist/providers/index.d.cts +0 -6
  158. package/dist/providers/index.d.cts.map +0 -1
  159. package/dist/providers/index.d.mts +0 -6
  160. package/dist/providers/index.d.mts.map +0 -1
  161. package/dist/providers/index.mjs +0 -6
  162. package/dist/providers/index.mjs.map +0 -1
  163. package/dist/routing/ProviderRouter.cjs +0 -148
  164. package/dist/routing/ProviderRouter.cjs.map +0 -1
  165. package/dist/routing/ProviderRouter.d.cts +0 -124
  166. package/dist/routing/ProviderRouter.d.cts.map +0 -1
  167. package/dist/routing/ProviderRouter.d.mts +0 -124
  168. package/dist/routing/ProviderRouter.d.mts.map +0 -1
  169. package/dist/routing/ProviderRouter.mjs +0 -144
  170. package/dist/routing/ProviderRouter.mjs.map +0 -1
  171. package/dist/routing/index.cjs +0 -9
  172. package/dist/routing/index.cjs.map +0 -1
  173. package/dist/routing/index.d.cts +0 -6
  174. package/dist/routing/index.d.cts.map +0 -1
  175. package/dist/routing/index.d.mts +0 -6
  176. package/dist/routing/index.d.mts.map +0 -1
  177. package/dist/routing/index.mjs +0 -5
  178. package/dist/routing/index.mjs.map +0 -1
  179. package/dist/selectors.cjs +0 -161
  180. package/dist/selectors.cjs.map +0 -1
  181. package/dist/selectors.d.cts +0 -345
  182. package/dist/selectors.d.cts.map +0 -1
  183. package/dist/selectors.d.mts +0 -345
  184. package/dist/selectors.d.mts.map +0 -1
  185. package/dist/selectors.mjs +0 -153
  186. package/dist/selectors.mjs.map +0 -1
  187. package/dist/services/AccountService.cjs +0 -313
  188. package/dist/services/AccountService.cjs.map +0 -1
  189. package/dist/services/AccountService.d.cts +0 -53
  190. package/dist/services/AccountService.d.cts.map +0 -1
  191. package/dist/services/AccountService.d.mts +0 -53
  192. package/dist/services/AccountService.d.mts.map +0 -1
  193. package/dist/services/AccountService.mjs +0 -309
  194. package/dist/services/AccountService.mjs.map +0 -1
  195. package/dist/services/DataLakeService.cjs +0 -219
  196. package/dist/services/DataLakeService.cjs.map +0 -1
  197. package/dist/services/DataLakeService.d.cts +0 -49
  198. package/dist/services/DataLakeService.d.cts.map +0 -1
  199. package/dist/services/DataLakeService.d.mts +0 -49
  200. package/dist/services/DataLakeService.d.mts.map +0 -1
  201. package/dist/services/DataLakeService.mjs +0 -215
  202. package/dist/services/DataLakeService.mjs.map +0 -1
  203. package/dist/services/DepositService.cjs +0 -96
  204. package/dist/services/DepositService.cjs.map +0 -1
  205. package/dist/services/DepositService.d.cts +0 -37
  206. package/dist/services/DepositService.d.cts.map +0 -1
  207. package/dist/services/DepositService.d.mts +0 -37
  208. package/dist/services/DepositService.d.mts.map +0 -1
  209. package/dist/services/DepositService.mjs +0 -92
  210. package/dist/services/DepositService.mjs.map +0 -1
  211. package/dist/services/EligibilityService.cjs +0 -156
  212. package/dist/services/EligibilityService.cjs.map +0 -1
  213. package/dist/services/EligibilityService.d.cts +0 -48
  214. package/dist/services/EligibilityService.d.cts.map +0 -1
  215. package/dist/services/EligibilityService.d.mts +0 -48
  216. package/dist/services/EligibilityService.d.mts.map +0 -1
  217. package/dist/services/EligibilityService.mjs +0 -152
  218. package/dist/services/EligibilityService.mjs.map +0 -1
  219. package/dist/services/FeatureFlagConfigurationService.cjs +0 -258
  220. package/dist/services/FeatureFlagConfigurationService.cjs.map +0 -1
  221. package/dist/services/FeatureFlagConfigurationService.d.cts +0 -100
  222. package/dist/services/FeatureFlagConfigurationService.d.cts.map +0 -1
  223. package/dist/services/FeatureFlagConfigurationService.d.mts +0 -100
  224. package/dist/services/FeatureFlagConfigurationService.d.mts.map +0 -1
  225. package/dist/services/FeatureFlagConfigurationService.mjs +0 -254
  226. package/dist/services/FeatureFlagConfigurationService.mjs.map +0 -1
  227. package/dist/services/MarketDataService.cjs +0 -875
  228. package/dist/services/MarketDataService.cjs.map +0 -1
  229. package/dist/services/MarketDataService.d.cts +0 -289
  230. package/dist/services/MarketDataService.d.cts.map +0 -1
  231. package/dist/services/MarketDataService.d.mts +0 -289
  232. package/dist/services/MarketDataService.d.mts.map +0 -1
  233. package/dist/services/MarketDataService.mjs +0 -871
  234. package/dist/services/MarketDataService.mjs.map +0 -1
  235. package/dist/services/RewardsIntegrationService.cjs +0 -94
  236. package/dist/services/RewardsIntegrationService.cjs.map +0 -1
  237. package/dist/services/RewardsIntegrationService.d.cts +0 -30
  238. package/dist/services/RewardsIntegrationService.d.cts.map +0 -1
  239. package/dist/services/RewardsIntegrationService.d.mts +0 -30
  240. package/dist/services/RewardsIntegrationService.d.mts.map +0 -1
  241. package/dist/services/RewardsIntegrationService.mjs +0 -90
  242. package/dist/services/RewardsIntegrationService.mjs.map +0 -1
  243. package/dist/services/ServiceContext.cjs +0 -3
  244. package/dist/services/ServiceContext.cjs.map +0 -1
  245. package/dist/services/ServiceContext.d.cts +0 -110
  246. package/dist/services/ServiceContext.d.cts.map +0 -1
  247. package/dist/services/ServiceContext.d.mts +0 -110
  248. package/dist/services/ServiceContext.d.mts.map +0 -1
  249. package/dist/services/ServiceContext.mjs +0 -2
  250. package/dist/services/ServiceContext.mjs.map +0 -1
  251. package/dist/services/TradingService.cjs +0 -1481
  252. package/dist/services/TradingService.cjs.map +0 -1
  253. package/dist/services/TradingService.d.cts +0 -308
  254. package/dist/services/TradingService.d.cts.map +0 -1
  255. package/dist/services/TradingService.d.mts +0 -308
  256. package/dist/services/TradingService.d.mts.map +0 -1
  257. package/dist/services/TradingService.mjs +0 -1477
  258. package/dist/services/TradingService.mjs.map +0 -1
  259. package/dist/services/index.cjs +0 -26
  260. package/dist/services/index.cjs.map +0 -1
  261. package/dist/services/index.d.cts +0 -11
  262. package/dist/services/index.d.cts.map +0 -1
  263. package/dist/services/index.d.mts +0 -11
  264. package/dist/services/index.d.mts.map +0 -1
  265. package/dist/services/index.mjs +0 -10
  266. package/dist/services/index.mjs.map +0 -1
  267. package/dist/services/utils.cjs +0 -16
  268. package/dist/services/utils.cjs.map +0 -1
  269. package/dist/services/utils.d.cts +0 -8
  270. package/dist/services/utils.d.cts.map +0 -1
  271. package/dist/services/utils.d.mts +0 -8
  272. package/dist/services/utils.d.mts.map +0 -1
  273. package/dist/services/utils.mjs +0 -12
  274. package/dist/services/utils.mjs.map +0 -1
  275. package/dist/types/chart.cjs +0 -42
  276. package/dist/types/chart.cjs.map +0 -1
  277. package/dist/types/chart.d.cts +0 -62
  278. package/dist/types/chart.d.cts.map +0 -1
  279. package/dist/types/chart.d.mts +0 -62
  280. package/dist/types/chart.d.mts.map +0 -1
  281. package/dist/types/chart.mjs +0 -39
  282. package/dist/types/chart.mjs.map +0 -1
  283. package/dist/types/hyperliquid-types.cjs +0 -3
  284. package/dist/types/hyperliquid-types.cjs.map +0 -1
  285. package/dist/types/hyperliquid-types.d.cts +0 -52
  286. package/dist/types/hyperliquid-types.d.cts.map +0 -1
  287. package/dist/types/hyperliquid-types.d.mts +0 -52
  288. package/dist/types/hyperliquid-types.d.mts.map +0 -1
  289. package/dist/types/hyperliquid-types.mjs +0 -2
  290. package/dist/types/hyperliquid-types.mjs.map +0 -1
  291. package/dist/types/index.cjs +0 -96
  292. package/dist/types/index.cjs.map +0 -1
  293. package/dist/types/index.d.cts +0 -1153
  294. package/dist/types/index.d.cts.map +0 -1
  295. package/dist/types/index.d.mts +0 -1153
  296. package/dist/types/index.d.mts.map +0 -1
  297. package/dist/types/index.mjs +0 -79
  298. package/dist/types/index.mjs.map +0 -1
  299. package/dist/types/transactionTypes.cjs +0 -28
  300. package/dist/types/transactionTypes.cjs.map +0 -1
  301. package/dist/types/transactionTypes.d.cts +0 -64
  302. package/dist/types/transactionTypes.d.cts.map +0 -1
  303. package/dist/types/transactionTypes.d.mts +0 -64
  304. package/dist/types/transactionTypes.d.mts.map +0 -1
  305. package/dist/types/transactionTypes.mjs +0 -23
  306. package/dist/types/transactionTypes.mjs.map +0 -1
  307. package/dist/utils/accountUtils.cjs +0 -65
  308. package/dist/utils/accountUtils.cjs.map +0 -1
  309. package/dist/utils/accountUtils.d.cts +0 -26
  310. package/dist/utils/accountUtils.d.cts.map +0 -1
  311. package/dist/utils/accountUtils.d.mts +0 -26
  312. package/dist/utils/accountUtils.d.mts.map +0 -1
  313. package/dist/utils/accountUtils.mjs +0 -61
  314. package/dist/utils/accountUtils.mjs.map +0 -1
  315. package/dist/utils/amountConversion.cjs +0 -61
  316. package/dist/utils/amountConversion.cjs.map +0 -1
  317. package/dist/utils/amountConversion.d.cts +0 -16
  318. package/dist/utils/amountConversion.d.cts.map +0 -1
  319. package/dist/utils/amountConversion.d.mts +0 -16
  320. package/dist/utils/amountConversion.d.mts.map +0 -1
  321. package/dist/utils/amountConversion.mjs +0 -54
  322. package/dist/utils/amountConversion.mjs.map +0 -1
  323. package/dist/utils/chartUtils.cjs +0 -98
  324. package/dist/utils/chartUtils.cjs.map +0 -1
  325. package/dist/utils/chartUtils.d.cts +0 -14
  326. package/dist/utils/chartUtils.d.cts.map +0 -1
  327. package/dist/utils/chartUtils.d.mts +0 -14
  328. package/dist/utils/chartUtils.d.mts.map +0 -1
  329. package/dist/utils/chartUtils.mjs +0 -94
  330. package/dist/utils/chartUtils.mjs.map +0 -1
  331. package/dist/utils/errorUtils.cjs +0 -22
  332. package/dist/utils/errorUtils.cjs.map +0 -1
  333. package/dist/utils/errorUtils.d.cts +0 -13
  334. package/dist/utils/errorUtils.d.cts.map +0 -1
  335. package/dist/utils/errorUtils.d.mts +0 -13
  336. package/dist/utils/errorUtils.d.mts.map +0 -1
  337. package/dist/utils/errorUtils.mjs +0 -18
  338. package/dist/utils/errorUtils.mjs.map +0 -1
  339. package/dist/utils/formatUtils.cjs +0 -987
  340. package/dist/utils/formatUtils.cjs.map +0 -1
  341. package/dist/utils/formatUtils.d.cts +0 -387
  342. package/dist/utils/formatUtils.d.cts.map +0 -1
  343. package/dist/utils/formatUtils.d.mts +0 -387
  344. package/dist/utils/formatUtils.d.mts.map +0 -1
  345. package/dist/utils/formatUtils.mjs +0 -966
  346. package/dist/utils/formatUtils.mjs.map +0 -1
  347. package/dist/utils/hyperLiquidAdapter.cjs +0 -454
  348. package/dist/utils/hyperLiquidAdapter.cjs.map +0 -1
  349. package/dist/utils/hyperLiquidAdapter.d.cts +0 -158
  350. package/dist/utils/hyperLiquidAdapter.d.cts.map +0 -1
  351. package/dist/utils/hyperLiquidAdapter.d.mts +0 -158
  352. package/dist/utils/hyperLiquidAdapter.d.mts.map +0 -1
  353. package/dist/utils/hyperLiquidAdapter.mjs +0 -439
  354. package/dist/utils/hyperLiquidAdapter.mjs.map +0 -1
  355. package/dist/utils/hyperLiquidOrderBookProcessor.cjs +0 -89
  356. package/dist/utils/hyperLiquidOrderBookProcessor.cjs.map +0 -1
  357. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts +0 -58
  358. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts.map +0 -1
  359. package/dist/utils/hyperLiquidOrderBookProcessor.d.mts +0 -58
  360. package/dist/utils/hyperLiquidOrderBookProcessor.d.mts.map +0 -1
  361. package/dist/utils/hyperLiquidOrderBookProcessor.mjs +0 -84
  362. package/dist/utils/hyperLiquidOrderBookProcessor.mjs.map +0 -1
  363. package/dist/utils/hyperLiquidValidation.cjs +0 -426
  364. package/dist/utils/hyperLiquidValidation.cjs.map +0 -1
  365. package/dist/utils/hyperLiquidValidation.d.cts +0 -143
  366. package/dist/utils/hyperLiquidValidation.d.cts.map +0 -1
  367. package/dist/utils/hyperLiquidValidation.d.mts +0 -143
  368. package/dist/utils/hyperLiquidValidation.d.mts.map +0 -1
  369. package/dist/utils/hyperLiquidValidation.mjs +0 -413
  370. package/dist/utils/hyperLiquidValidation.mjs.map +0 -1
  371. package/dist/utils/idUtils.cjs +0 -50
  372. package/dist/utils/idUtils.cjs.map +0 -1
  373. package/dist/utils/idUtils.d.cts +0 -38
  374. package/dist/utils/idUtils.d.cts.map +0 -1
  375. package/dist/utils/idUtils.d.mts +0 -38
  376. package/dist/utils/idUtils.d.mts.map +0 -1
  377. package/dist/utils/idUtils.mjs +0 -42
  378. package/dist/utils/idUtils.mjs.map +0 -1
  379. package/dist/utils/marginUtils.cjs +0 -137
  380. package/dist/utils/marginUtils.cjs.map +0 -1
  381. package/dist/utils/marginUtils.d.cts +0 -64
  382. package/dist/utils/marginUtils.d.cts.map +0 -1
  383. package/dist/utils/marginUtils.d.mts +0 -64
  384. package/dist/utils/marginUtils.d.mts.map +0 -1
  385. package/dist/utils/marginUtils.mjs +0 -131
  386. package/dist/utils/marginUtils.mjs.map +0 -1
  387. package/dist/utils/marketDataTransform.cjs +0 -227
  388. package/dist/utils/marketDataTransform.cjs.map +0 -1
  389. package/dist/utils/marketDataTransform.d.cts +0 -45
  390. package/dist/utils/marketDataTransform.d.cts.map +0 -1
  391. package/dist/utils/marketDataTransform.d.mts +0 -45
  392. package/dist/utils/marketDataTransform.d.mts.map +0 -1
  393. package/dist/utils/marketDataTransform.mjs +0 -220
  394. package/dist/utils/marketDataTransform.mjs.map +0 -1
  395. package/dist/utils/marketUtils.cjs +0 -420
  396. package/dist/utils/marketUtils.cjs.map +0 -1
  397. package/dist/utils/marketUtils.d.cts +0 -227
  398. package/dist/utils/marketUtils.d.cts.map +0 -1
  399. package/dist/utils/marketUtils.d.mts +0 -227
  400. package/dist/utils/marketUtils.d.mts.map +0 -1
  401. package/dist/utils/marketUtils.mjs +0 -404
  402. package/dist/utils/marketUtils.mjs.map +0 -1
  403. package/dist/utils/orderBookGrouping.cjs +0 -151
  404. package/dist/utils/orderBookGrouping.cjs.map +0 -1
  405. package/dist/utils/orderBookGrouping.d.cts +0 -76
  406. package/dist/utils/orderBookGrouping.d.cts.map +0 -1
  407. package/dist/utils/orderBookGrouping.d.mts +0 -76
  408. package/dist/utils/orderBookGrouping.d.mts.map +0 -1
  409. package/dist/utils/orderBookGrouping.mjs +0 -143
  410. package/dist/utils/orderBookGrouping.mjs.map +0 -1
  411. package/dist/utils/orderCalculations.cjs +0 -283
  412. package/dist/utils/orderCalculations.cjs.map +0 -1
  413. package/dist/utils/orderCalculations.d.cts +0 -107
  414. package/dist/utils/orderCalculations.d.cts.map +0 -1
  415. package/dist/utils/orderCalculations.d.mts +0 -107
  416. package/dist/utils/orderCalculations.d.mts.map +0 -1
  417. package/dist/utils/orderCalculations.mjs +0 -274
  418. package/dist/utils/orderCalculations.mjs.map +0 -1
  419. package/dist/utils/orderUtils.cjs +0 -159
  420. package/dist/utils/orderUtils.cjs.map +0 -1
  421. package/dist/utils/orderUtils.d.cts +0 -66
  422. package/dist/utils/orderUtils.d.cts.map +0 -1
  423. package/dist/utils/orderUtils.d.mts +0 -66
  424. package/dist/utils/orderUtils.d.mts.map +0 -1
  425. package/dist/utils/orderUtils.mjs +0 -151
  426. package/dist/utils/orderUtils.mjs.map +0 -1
  427. package/dist/utils/pnlCalculations.cjs +0 -107
  428. package/dist/utils/pnlCalculations.cjs.map +0 -1
  429. package/dist/utils/pnlCalculations.d.cts +0 -79
  430. package/dist/utils/pnlCalculations.d.cts.map +0 -1
  431. package/dist/utils/pnlCalculations.d.mts +0 -79
  432. package/dist/utils/pnlCalculations.d.mts.map +0 -1
  433. package/dist/utils/pnlCalculations.mjs +0 -97
  434. package/dist/utils/pnlCalculations.mjs.map +0 -1
  435. package/dist/utils/positionCalculations.cjs +0 -176
  436. package/dist/utils/positionCalculations.cjs.map +0 -1
  437. package/dist/utils/positionCalculations.d.cts +0 -85
  438. package/dist/utils/positionCalculations.d.cts.map +0 -1
  439. package/dist/utils/positionCalculations.d.mts +0 -85
  440. package/dist/utils/positionCalculations.d.mts.map +0 -1
  441. package/dist/utils/positionCalculations.mjs +0 -165
  442. package/dist/utils/positionCalculations.mjs.map +0 -1
  443. package/dist/utils/sortMarkets.cjs +0 -88
  444. package/dist/utils/sortMarkets.cjs.map +0 -1
  445. package/dist/utils/sortMarkets.d.cts +0 -21
  446. package/dist/utils/sortMarkets.d.cts.map +0 -1
  447. package/dist/utils/sortMarkets.d.mts +0 -21
  448. package/dist/utils/sortMarkets.d.mts.map +0 -1
  449. package/dist/utils/sortMarkets.mjs +0 -84
  450. package/dist/utils/sortMarkets.mjs.map +0 -1
  451. package/dist/utils/standaloneInfoClient.cjs +0 -34
  452. package/dist/utils/standaloneInfoClient.cjs.map +0 -1
  453. package/dist/utils/standaloneInfoClient.d.cts +0 -31
  454. package/dist/utils/standaloneInfoClient.d.cts.map +0 -1
  455. package/dist/utils/standaloneInfoClient.d.mts +0 -31
  456. package/dist/utils/standaloneInfoClient.d.mts.map +0 -1
  457. package/dist/utils/standaloneInfoClient.mjs +0 -30
  458. package/dist/utils/standaloneInfoClient.mjs.map +0 -1
  459. package/dist/utils/stringParseUtils.cjs +0 -49
  460. package/dist/utils/stringParseUtils.cjs.map +0 -1
  461. package/dist/utils/stringParseUtils.d.cts +0 -35
  462. package/dist/utils/stringParseUtils.d.cts.map +0 -1
  463. package/dist/utils/stringParseUtils.d.mts +0 -35
  464. package/dist/utils/stringParseUtils.d.mts.map +0 -1
  465. package/dist/utils/stringParseUtils.mjs +0 -44
  466. package/dist/utils/stringParseUtils.mjs.map +0 -1
  467. package/dist/utils/time.cjs +0 -37
  468. package/dist/utils/time.cjs.map +0 -1
  469. package/dist/utils/time.d.cts +0 -17
  470. package/dist/utils/time.d.cts.map +0 -1
  471. package/dist/utils/time.d.mts +0 -17
  472. package/dist/utils/time.d.mts.map +0 -1
  473. package/dist/utils/time.mjs +0 -33
  474. package/dist/utils/time.mjs.map +0 -1
  475. package/dist/utils/tpslValidation.cjs +0 -505
  476. package/dist/utils/tpslValidation.cjs.map +0 -1
  477. package/dist/utils/tpslValidation.d.cts +0 -182
  478. package/dist/utils/tpslValidation.d.cts.map +0 -1
  479. package/dist/utils/tpslValidation.d.mts +0 -182
  480. package/dist/utils/tpslValidation.d.mts.map +0 -1
  481. package/dist/utils/tpslValidation.mjs +0 -482
  482. package/dist/utils/tpslValidation.mjs.map +0 -1
  483. package/dist/utils/transactionUtils.cjs +0 -36
  484. package/dist/utils/transactionUtils.cjs.map +0 -1
  485. package/dist/utils/transactionUtils.d.cts +0 -17
  486. package/dist/utils/transactionUtils.d.cts.map +0 -1
  487. package/dist/utils/transactionUtils.d.mts +0 -17
  488. package/dist/utils/transactionUtils.d.mts.map +0 -1
  489. package/dist/utils/transactionUtils.mjs +0 -32
  490. package/dist/utils/transactionUtils.mjs.map +0 -1
  491. package/dist/utils/wait.cjs +0 -12
  492. package/dist/utils/wait.cjs.map +0 -1
  493. package/dist/utils/wait.d.cts +0 -8
  494. package/dist/utils/wait.d.cts.map +0 -1
  495. package/dist/utils/wait.d.mts +0 -8
  496. package/dist/utils/wait.d.mts.map +0 -1
  497. package/dist/utils/wait.mjs +0 -8
  498. package/dist/utils/wait.mjs.map +0 -1
@@ -1,881 +0,0 @@
1
- import { CaipAccountId } from "@metamask/utils";
2
- import { WebSocketConnectionState } from "../platform-services/HyperLiquidClientService.cjs";
3
- import type { AccountState, AssetRoute, BatchCancelOrdersParams, CancelOrderParams, CancelOrderResult, CancelOrdersResult, ClosePositionParams, ClosePositionsParams, ClosePositionsResult, DepositParams, DisconnectResult, EditOrderParams, FeeCalculationParams, FeeCalculationResult, Funding, GetAccountStateParams, GetAvailableDexsParams, GetFundingParams, GetHistoricalPortfolioParams, GetMarketsParams, GetOrderFillsParams, GetOrdersParams, GetPositionsParams, GetSupportedPathsParams, HistoricalPortfolioResult, InitializeResult, PerpsPlatformDependencies, PerpsProvider, LiquidationPriceParams, LiveDataConfig, MaintenanceMarginParams, MarginResult, MarketInfo, Order, OrderFill, OrderParams, OrderResult, PerpsMarketData, Position, RawHyperLiquidLedgerUpdate, ReadyToTradeResult, SubscribeAccountParams, SubscribeCandlesParams, SubscribeOICapsParams, SubscribeOrderBookParams, SubscribeOrderFillsParams, SubscribeOrdersParams, SubscribePositionsParams, SubscribePricesParams, ToggleTestnetResult, TransferBetweenDexsParams, TransferBetweenDexsResult, UpdatePositionTPSLParams, UserHistoryItem, WithdrawParams, WithdrawResult } from "../types/index.cjs";
4
- /**
5
- * HyperLiquid provider implementation
6
- *
7
- * Implements the PerpsProvider interface for HyperLiquid protocol.
8
- * Uses the @nktkas/hyperliquid SDK for all operations.
9
- * Delegates to service classes for client management, wallet integration, and subscriptions.
10
- *
11
- * HIP-3 Balance Management:
12
- * Attempts to use HyperLiquid's native DEX abstraction for automatic collateral transfers.
13
- * If not supported, falls back to programmatic balance management using SDK's sendAsset.
14
- */
15
- export declare class HyperLiquidProvider implements PerpsProvider {
16
- readonly protocolId = "hyperliquid";
17
- private readonly deps;
18
- private readonly clientService;
19
- private readonly walletService;
20
- private readonly subscriptionService;
21
- private readonly symbolToAssetId;
22
- private readonly userFeeCache;
23
- private readonly maxLeverageCache;
24
- private readonly cachedMetaByDex;
25
- private perpDexsCache;
26
- private readonly referralCheckCache;
27
- private readonly builderFeeCheckCache;
28
- private ensureReadyPromise;
29
- private readonly pendingBuilderFeeApprovals;
30
- private readonly compiledAllowlistPatterns;
31
- private readonly compiledBlocklistPatterns;
32
- private userFeeDiscountBips?;
33
- private readonly hip3Enabled;
34
- private readonly allowlistMarkets;
35
- private readonly blocklistMarkets;
36
- private useDexAbstraction;
37
- private cachedValidatedDexs;
38
- private cachedAllPerpDexs;
39
- private pendingValidatedDexsPromise;
40
- private cachedUsdcTokenId?;
41
- private readonly errorMappings;
42
- private clientsInitialized;
43
- private initializationPromise;
44
- constructor(options: {
45
- isTestnet?: boolean;
46
- hip3Enabled?: boolean;
47
- allowlistMarkets?: string[];
48
- blocklistMarkets?: string[];
49
- useDexAbstraction?: boolean;
50
- platformDependencies: PerpsPlatformDependencies;
51
- });
52
- /**
53
- * Initialize HyperLiquid SDK clients (lazy initialization)
54
- *
55
- * This is called on first API operation to ensure Engine.context is ready.
56
- * Creating the wallet adapter requires accessing Engine.context.AccountTreeController,
57
- * which may not be available during early app initialization.
58
- *
59
- * IMPORTANT: This method awaits the WebSocket transport.ready() to ensure
60
- * the connection is fully established before marking initialization complete.
61
- */
62
- private ensureClientsInitialized;
63
- /**
64
- * Attempt to enable HIP-3 native balance abstraction
65
- *
66
- * If successful, HyperLiquid automatically manages collateral transfers for HIP-3 orders.
67
- * If not supported, disables the flag to trigger programmatic transfer fallback.
68
- *
69
- * @private
70
- */
71
- private ensureDexAbstractionEnabled;
72
- /**
73
- * Ensure clients are initialized and asset mapping is loaded
74
- * Asset mapping is built once on first call and reused for the provider's lifetime
75
- * since HIP-3 configuration is immutable after construction
76
- */
77
- private ensureReady;
78
- /**
79
- * Get all available DEXs without allowlist filtering
80
- * Used when skipFilters=true in getMarkets()
81
- *
82
- * @returns Array of all DEX names (null for main DEX, strings for HIP-3 DEXs)
83
- */
84
- private getAllAvailableDexs;
85
- /**
86
- * Get validated list of DEXs to use based on feature flags and allowlist
87
- * Implements Step 3b from HIP-3-IMPLEMENTATION.md (lines 108-134)
88
- *
89
- * Logic Flow:
90
- * 1. If hip3Enabled === false → Return [null] (main DEX only)
91
- * 2. Fetch available DEXs via SDK: infoClient.perpDexs()
92
- * 3. If enabledDexs is empty [] → Return [null, ...allDiscoveredDexs] (auto-discover)
93
- * 4. Else filter enabledDexs against available DEXs → Return [null, ...validatedDexs] (allowlist)
94
- *
95
- * Invalid DEX names are silently filtered with debugLogger warning.
96
- *
97
- * @returns Array of DEX names to use (null = main DEX, strings = HIP-3 DEXs)
98
- */
99
- private getValidatedDexs;
100
- /**
101
- * Internal method that performs the actual perpDexs fetch and caching
102
- * Separated from getValidatedDexs to enable promise deduplication
103
- */
104
- private fetchValidatedDexsInternal;
105
- /**
106
- * Get cached meta response for a DEX, fetching from API if not cached
107
- * This helper consolidates cache logic to avoid redundant API calls across the provider
108
- *
109
- * @param params.dexName - DEX name (null for main DEX)
110
- * @param params.skipCache - If true, bypass cache and fetch fresh data
111
- * @param params
112
- * @returns MetaResponse with universe data
113
- * @throws Error if API returns invalid data
114
- */
115
- private getCachedMeta;
116
- /**
117
- * Fetch perpDexs data with TTL-based caching
118
- * Returns deployerFeeScale info needed for dynamic fee calculation
119
- *
120
- * @returns Array of ExtendedPerpDex objects (null entries represent main DEX)
121
- */
122
- private getCachedPerpDexs;
123
- /**
124
- * Calculate HIP-3 fee multiplier using HyperLiquid's official formula
125
- * Fetches deployerFeeScale from perpDexs API and growthMode from meta API
126
- *
127
- * Formula from HyperLiquid docs:
128
- * - scaleIfHip3 = deployerFeeScale < 1 ? deployerFeeScale + 1 : deployerFeeScale * 2
129
- * - growthModeScale = growthMode ? 0.1 : 1
130
- * - finalMultiplier = scaleIfHip3 * growthModeScale
131
- *
132
- * @param params
133
- * @param params.dexName
134
- * @param params.assetSymbol
135
- * @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees#fee-formula-for-developers
136
- */
137
- private calculateHip3FeeMultiplier;
138
- /**
139
- * Generate session cache key for user-specific caches
140
- * Format: "network:userAddress" (address normalized to lowercase)
141
- *
142
- * @param network - 'mainnet' or 'testnet'
143
- * @param userAddress - User's Ethereum address
144
- * @returns Cache key for session-based caches
145
- */
146
- private getCacheKey;
147
- /**
148
- * Fetch markets for a specific DEX with optional filtering
149
- * Uses session-based caching via getCachedMeta() - no TTL, cleared on disconnect
150
- *
151
- * @param params.dex - DEX name (null for main DEX)
152
- * @param params.skipFilters - If true, skip HIP-3 filtering (return all markets)
153
- * @param params.skipCache - If true, bypass cache and fetch fresh data
154
- * @param params
155
- * @returns Array of MarketInfo objects
156
- */
157
- private fetchMarketsForDex;
158
- /**
159
- * Get USDC token ID from spot metadata
160
- * Returns format: "USDC:{hex_token_id}"
161
- * Caches result to avoid repeated API calls
162
- */
163
- private getUsdcTokenId;
164
- /**
165
- * Check if a HIP-3 DEX uses USDH as collateral (vs USDC)
166
- * Per HyperLiquid docs: USDH DEXs pull collateral from spot balance automatically
167
- *
168
- * @param dexName
169
- */
170
- private isUsdhCollateralDex;
171
- /**
172
- * Get user's USDH balance in spot wallet
173
- */
174
- private getSpotUsdhBalance;
175
- /**
176
- * Get user's USDC balance in spot wallet
177
- * Required for USDH DEX orders - need USDC in spot to swap to USDH
178
- */
179
- private getSpotUsdcBalance;
180
- /**
181
- * Transfer USDC from main perps wallet to spot wallet
182
- * Required before swapping USDC→USDH for USDH DEX orders
183
- *
184
- * @param amount
185
- */
186
- private transferUsdcToSpot;
187
- /**
188
- * Swap USDC to USDH on spot market
189
- * Returns the result of the swap including filled size
190
- *
191
- * @param amount
192
- */
193
- private swapUsdcToUsdh;
194
- /**
195
- * Ensure sufficient USDH collateral in spot for HIP-3 DEX order
196
- * If user lacks USDH, auto-swap from USDC
197
- *
198
- * @param dexName
199
- * @param requiredMargin
200
- */
201
- private ensureUsdhCollateralForOrder;
202
- /**
203
- * Build asset ID mapping from market metadata
204
- * Fetches metadata for feature-flag-enabled DEXs and builds a unified mapping
205
- * with DEX-prefixed keys for HIP-3 assets (e.g., "xyz:XYZ100" → assetId)
206
- *
207
- * Per HIP-3-IMPLEMENTATION.md:
208
- * - Main DEX: assetId = index (0, 1, 2, ...)
209
- * - HIP-3 DEX: assetId = BASE_ASSET_ID + (perpDexIndex × DEX_MULTIPLIER) + index
210
- *
211
- * This enables proper order routing - when placeOrder({ symbol: "xyz:XYZ100" }) is called,
212
- * the asset ID lookup succeeds and the order routes to the correct DEX.
213
- */
214
- private buildAssetMapping;
215
- /**
216
- * Set user fee discount context for next operations
217
- * Used by PerpsController to apply MetaMask reward discounts
218
- *
219
- * @param discountBips - The discount in basis points (e.g., 550 = 5.5%)
220
- */
221
- setUserFeeDiscount(discountBips: number | undefined): void;
222
- /**
223
- * Query user data across all enabled DEXs in parallel
224
- *
225
- * DRY helper for multi-DEX user data queries. Handles feature flag logic
226
- * and DEX iteration in one place. Uses cached getValidatedDexs() to avoid
227
- * redundant perpDexs() API calls.
228
- *
229
- * @param baseParams - Base parameters (e.g., { user: '0x...' })
230
- * @param queryFn - API method to call per DEX
231
- * @returns Array of results per DEX with DEX identifier
232
- *
233
- * @example
234
- * ```typescript
235
- * const results = await this.queryUserDataAcrossDexs(
236
- * { user: userAddress },
237
- * (p) => infoClient.clearinghouseState(p)
238
- * );
239
- * ```
240
- */
241
- private queryUserDataAcrossDexs;
242
- /**
243
- * Map HyperLiquid API errors to standardized PERPS_ERROR_CODES
244
- *
245
- * @param error
246
- */
247
- private mapError;
248
- /**
249
- * Get error context for logging with searchable tags and context.
250
- * Enables Sentry dashboard filtering by feature, provider, and network.
251
- *
252
- * @param method - The method name where the error occurred
253
- * @param extra - Optional additional context fields (becomes searchable context data)
254
- * @returns LoggerErrorOptions with tags (searchable) and context (searchable)
255
- * @private
256
- *
257
- * @example
258
- * this.deps.logger.error(error, this.getErrorContext('placeOrder', { symbol: 'BTC', orderType: 'limit' }));
259
- * // Creates searchable tags: feature:perps, provider:hyperliquid, network:mainnet
260
- * // Creates searchable context: perps_provider.method:placeOrder, perps_provider.symbol:BTC, perps_provider.orderType:limit
261
- */
262
- private getErrorContext;
263
- /**
264
- * Get supported deposit routes with complete asset and routing information
265
- *
266
- * @param params
267
- */
268
- getDepositRoutes(params?: GetSupportedPathsParams): AssetRoute[];
269
- /**
270
- * Get supported withdrawal routes with complete asset and routing information
271
- *
272
- * @param params
273
- */
274
- getWithdrawalRoutes(params?: GetSupportedPathsParams): AssetRoute[];
275
- /**
276
- * Check current builder fee approval for the user
277
- *
278
- * @param builder - Builder address to check approval for
279
- * @returns Current max fee rate or null if not approved
280
- */
281
- private checkBuilderFeeApproval;
282
- /**
283
- * Ensure builder fee is approved for MetaMask
284
- * Called once during initialization (ensureReady) to set up builder fee for the session
285
- * Uses session cache to avoid redundant API calls until disconnect/reconnect
286
- *
287
- * Cache semantics: Only caches successful approvals (never caches "not approved" state)
288
- * This allows detection of external approvals between retries while avoiding redundant checks
289
- *
290
- * Note: This is network-specific - testnet and mainnet have separate builder fee states
291
- */
292
- private ensureBuilderFeeApproval;
293
- /**
294
- * Check if builder fee is approved for the current user
295
- *
296
- * @returns Object with approval status and current rate
297
- */
298
- private checkBuilderFeeStatus;
299
- /**
300
- * Get available balance for a specific DEX
301
- *
302
- * @param params - Balance query parameters
303
- * @param params.dex - DEX name (null = main, 'xyz' = HIP-3)
304
- * @returns Available balance in USDC
305
- * @private
306
- */
307
- private getBalanceForDex;
308
- /**
309
- * Find source DEX with sufficient balance for transfer
310
- * Strategy: Prefer main DEX → other HIP-3 DEXs
311
- *
312
- * @param params - Source search parameters
313
- * @param params.targetDex - Target DEX name
314
- * @param params.requiredAmount - Required balance shortfall
315
- * @returns Source DEX info or null if insufficient funds
316
- * @private
317
- */
318
- private findSourceDexWithBalance;
319
- /**
320
- * Auto-transfer funds for HIP-3 orders when insufficient balance
321
- * Only called for HIP-3 markets (not main DEX)
322
- *
323
- * @param params - Transfer parameters
324
- * @param params.targetDex - HIP-3 DEX name (e.g., 'xyz')
325
- * @param params.requiredMargin - Required margin with buffer
326
- * @returns Transfer info for rollback, or null if no transfer needed
327
- * @private
328
- */
329
- private autoTransferForHip3Order;
330
- /**
331
- * Auto-transfer freed margin back to main DEX after closing a HIP-3 position
332
- *
333
- * This method transfers the margin released from closing a position back to
334
- * the main DEX to prevent balance fragmentation across HIP-3 DEXs.
335
- *
336
- * Design: Non-blocking operation - failures are logged but don't affect the
337
- * position close operation. Extensible for future configuration options.
338
- *
339
- * @param params - Transfer configuration
340
- * @param params.sourceDex - HIP-3 DEX name to transfer from
341
- * @param params.freedMargin - Amount of margin released from position close
342
- * @param params.transferAll - (Future) Transfer all available balance instead
343
- * @param params.skipTransfer - (Future) Skip auto-transfer if disabled
344
- * @returns Transfer info if successful, null if skipped/failed
345
- * @private
346
- */
347
- private autoTransferBackAfterClose;
348
- /**
349
- * Calculate required margin for HIP-3 order based on existing position
350
- * Handles three scenarios:
351
- * 1. Increasing existing position - requires TOTAL margin (temporary over-funding)
352
- * 2. Reducing/flipping position - requires margin for new order only
353
- * 3. New position - requires margin for new order only
354
- *
355
- * @param params
356
- * @param params.symbol
357
- * @param params.dexName
358
- * @param params.positionSize
359
- * @param params.orderPrice
360
- * @param params.leverage
361
- * @param params.isBuy
362
- * @private
363
- */
364
- private calculateHip3RequiredMargin;
365
- /**
366
- * Handle post-order balance check and auto-rebalance for HIP-3 orders
367
- * After a successful order, checks available balance and transfers excess back to main DEX
368
- * Does not throw errors - logs them for monitoring
369
- *
370
- * @param params
371
- * @param params.dexName
372
- * @param params.transferInfo
373
- * @param params.transferInfo.amount
374
- * @param params.transferInfo.sourceDex
375
- * @private
376
- */
377
- private handleHip3PostOrderRebalance;
378
- /**
379
- * Handle rollback of HIP-3 transfer when order fails
380
- * Attempts to return funds to source DEX
381
- * Does not throw errors - logs them for monitoring
382
- *
383
- * @param params
384
- * @param params.dexName
385
- * @param params.transferInfo
386
- * @param params.transferInfo.amount
387
- * @param params.transferInfo.sourceDex
388
- * @private
389
- */
390
- private handleHip3OrderRollback;
391
- /**
392
- * Validates order parameters before placement using provider-level validation
393
- *
394
- * @param params
395
- * @throws Error if validation fails
396
- */
397
- private validateOrderBeforePlacement;
398
- /**
399
- * Gets asset info and current price from the correct DEX
400
- *
401
- * @param params
402
- */
403
- private getAssetInfo;
404
- /**
405
- * Prepares asset for trading by updating leverage if specified
406
- *
407
- * @param params
408
- */
409
- private prepareAssetForTrading;
410
- /**
411
- * Handles HIP-3 pre-order balance management
412
- *
413
- * @param params
414
- */
415
- private handleHip3PreOrder;
416
- /**
417
- * Submits order with atomic rollback for HIP-3 failures
418
- *
419
- * @param params
420
- */
421
- private submitOrderWithRollback;
422
- /**
423
- * Handles order errors with proper error mapping
424
- *
425
- * @param params
426
- */
427
- private handleOrderError;
428
- /**
429
- * Place an order using direct wallet signing
430
- *
431
- * Refactored to use helper methods for better maintainability and reduced complexity.
432
- * Each helper method is focused on a single responsibility.
433
- *
434
- * @param params - Order parameters
435
- * @param retryCount - Internal retry counter to prevent infinite loops (default: 0)
436
- */
437
- placeOrder(params: OrderParams, retryCount?: number): Promise<OrderResult>;
438
- /**
439
- * Edit an existing order (pending/unfilled order)
440
- *
441
- * Note: This modifies price/size of a pending order. It CANNOT add TP/SL to an existing order.
442
- * For adding TP/SL to an existing position, use updatePositionTPSL instead.
443
- *
444
- * @param params.orderId - The order ID to modify
445
- * @param params.newOrder - New order parameters (price, size, etc.)
446
- * @param params
447
- */
448
- editOrder(params: EditOrderParams): Promise<OrderResult>;
449
- /**
450
- * Cancel an order
451
- *
452
- * @param params
453
- */
454
- cancelOrder(params: CancelOrderParams): Promise<CancelOrderResult>;
455
- /**
456
- * Cancel multiple orders in a single batch API call
457
- * Optimized implementation that uses HyperLiquid's batch cancel endpoint
458
- *
459
- * @param params
460
- */
461
- cancelOrders(params: BatchCancelOrdersParams): Promise<CancelOrdersResult>;
462
- closePositions(params: ClosePositionsParams): Promise<ClosePositionsResult>;
463
- /**
464
- * Update TP/SL for an existing position
465
- *
466
- * This creates new TP/SL orders for the position using 'positionTpsl' grouping.
467
- * These are separate orders that will close the position when triggered.
468
- *
469
- * Key differences from editOrder:
470
- * - editOrder: Modifies pending orders (before fill)
471
- * - updatePositionTPSL: Creates TP/SL orders for filled positions
472
- *
473
- * HyperLiquid supports two TP/SL types:
474
- * 1. 'normalTpsl' - Tied to a parent order (set when placing the order)
475
- * 2. 'positionTpsl' - Tied to a position (can be set/modified after fill)
476
- *
477
- * @param params.symbol - Asset symbol of the position
478
- * @param params.takeProfitPrice - TP price (undefined to remove)
479
- * @param params.stopLossPrice - SL price (undefined to remove)
480
- * @param params
481
- */
482
- updatePositionTPSL(params: UpdatePositionTPSLParams): Promise<OrderResult>;
483
- /**
484
- * Close a position
485
- *
486
- * For HIP-3 positions, this method automatically transfers freed margin
487
- * back to the main DEX after successfully closing the position.
488
- *
489
- * @param params
490
- */
491
- closePosition(params: ClosePositionParams): Promise<OrderResult>;
492
- /**
493
- * Update margin for an existing position (add or remove)
494
- *
495
- * @param params - Margin adjustment parameters
496
- * @param params.symbol - Asset symbol (e.g., 'BTC', 'ETH')
497
- * @param params.amount - Amount to adjust as string (positive = add, negative = remove)
498
- * @returns Promise resolving to margin adjustment result
499
- *
500
- * Note: HyperLiquid uses micro-units (multiply by 1e6) for the ntli parameter.
501
- * The SDK's updateIsolatedMargin requires:
502
- * - asset: Asset ID (number)
503
- * - isBuy: Position direction (true for long, false for short)
504
- * - ntli: Amount in micro-units (amount * 1e6)
505
- */
506
- updateMargin(params: {
507
- symbol: string;
508
- amount: string;
509
- }): Promise<MarginResult>;
510
- /**
511
- * Get current positions with TP/SL prices
512
- *
513
- * Note on TP/SL orders:
514
- * - normalTpsl: TP/SL tied to parent order, only placed after parent fills
515
- * - positionTpsl: TP/SL tied to position, placed immediately
516
- *
517
- * This means TP/SL prices may not appear immediately after placing an order
518
- * with TP/SL. They will only show up once the parent order is filled and
519
- * the child TP/SL orders are actually placed on the order book.
520
- *
521
- * @param params
522
- */
523
- getPositions(params?: GetPositionsParams): Promise<Position[]>;
524
- /**
525
- * Get historical user fills (trade executions)
526
- *
527
- * @param params
528
- */
529
- getOrderFills(params?: GetOrderFillsParams): Promise<OrderFill[]>;
530
- /**
531
- * Get historical orders (order lifecycle)
532
- *
533
- * @param params
534
- */
535
- getOrders(params?: GetOrdersParams): Promise<Order[]>;
536
- /**
537
- * Get currently open orders (real-time status)
538
- * Uses frontendOpenOrders API to get only currently active orders
539
- * Aggregates orders from all enabled DEXs (main + HIP-3)
540
- *
541
- * @param params
542
- */
543
- getOpenOrders(params?: GetOrdersParams): Promise<Order[]>;
544
- /**
545
- * Get user funding history
546
- *
547
- * @param params
548
- */
549
- getFunding(params?: GetFundingParams): Promise<Funding[]>;
550
- /**
551
- * Get user non-funding ledger updates (deposits, transfers, withdrawals)
552
- *
553
- * @param params
554
- * @param params.accountId
555
- * @param params.startTime
556
- * @param params.endTime
557
- */
558
- getUserNonFundingLedgerUpdates(params?: {
559
- accountId?: string;
560
- startTime?: number;
561
- endTime?: number;
562
- }): Promise<RawHyperLiquidLedgerUpdate[]>;
563
- /**
564
- * Get user history (deposits, withdrawals, transfers)
565
- *
566
- * @param params
567
- * @param params.accountId
568
- * @param params.startTime
569
- * @param params.endTime
570
- */
571
- getUserHistory(params?: {
572
- accountId?: CaipAccountId;
573
- startTime?: number;
574
- endTime?: number;
575
- }): Promise<UserHistoryItem[]>;
576
- getHistoricalPortfolio(params?: GetHistoricalPortfolioParams): Promise<HistoricalPortfolioResult>;
577
- /**
578
- * Get account state
579
- * Aggregates balances across all enabled DEXs (main + HIP-3)
580
- *
581
- * @param params
582
- */
583
- getAccountState(params?: GetAccountStateParams): Promise<AccountState>;
584
- /**
585
- * Get available markets with multi-DEX aggregation support (HIP-3)
586
- * Handles three query patterns:
587
- * 1. Symbol filtering: Groups symbols by DEX, fetches in parallel
588
- * 2. Multi-DEX aggregation: Fetches from all enabled DEXs when no specific DEX requested
589
- * 3. Single DEX query: Fetches from main or specific DEX
590
- *
591
- * @param params - Optional parameters for filtering
592
- */
593
- getMarkets(params?: GetMarketsParams): Promise<MarketInfo[]>;
594
- /**
595
- * Get list of available HIP-3 DEXs that have markets
596
- * Useful for debugging and manual DEX selection
597
- *
598
- * @returns Array of DEX names (excluding main DEX)
599
- */
600
- getAvailableHip3Dexs(): Promise<string[]>;
601
- /**
602
- * Get market data with prices, volumes, and 24h changes
603
- * Aggregates data from all enabled DEXs (main + HIP-3) when equity is enabled
604
- *
605
- * Note: This is called once during initialization and cached by PerpsStreamManager.
606
- * Real-time price updates come from WebSocket subscriptions, not this method.
607
- */
608
- getMarketDataWithPrices(): Promise<PerpsMarketData[]>;
609
- /**
610
- * Validate deposit parameters according to HyperLiquid-specific rules
611
- * This method enforces protocol-specific requirements like minimum amounts
612
- *
613
- * @param params
614
- */
615
- validateDeposit(params: DepositParams): Promise<{
616
- isValid: boolean;
617
- error?: string;
618
- }>;
619
- /**
620
- * Validate order parameters according to HyperLiquid-specific rules
621
- * This includes minimum order sizes, leverage limits, and other protocol requirements
622
- *
623
- * @param params
624
- */
625
- validateOrder(params: OrderParams): Promise<{
626
- isValid: boolean;
627
- error?: string;
628
- }>;
629
- /**
630
- * Validate close position parameters according to HyperLiquid-specific rules
631
- * Note: Full validation including remaining position size requires position data
632
- * which should be passed from the UI layer
633
- *
634
- * @param params
635
- */
636
- validateClosePosition(params: ClosePositionParams): Promise<{
637
- isValid: boolean;
638
- error?: string;
639
- }>;
640
- /**
641
- * Validate withdrawal parameters - placeholder for future implementation
642
- *
643
- * @param _params
644
- */
645
- validateWithdrawal(_params: WithdrawParams): Promise<{
646
- isValid: boolean;
647
- error?: string;
648
- }>;
649
- /**
650
- * Withdraw funds from HyperLiquid trading account
651
- *
652
- * This initiates a withdrawal request via HyperLiquid's API (withdraw3 endpoint).
653
- *
654
- * HyperLiquid Bridge Process:
655
- * - Funds are immediately deducted from L1 balance on HyperLiquid
656
- * - Validators sign the withdrawal (2/3 of staking power required)
657
- * - Bridge contract on destination chain processes the withdrawal
658
- * - After dispute period, USDC is sent to destination address
659
- * - Total time: ~5 minutes
660
- * - Fee: 1 USDC (covers Arbitrum gas costs)
661
- * - No ETH required from user
662
- *
663
- * Note: Withdrawals won't appear as incoming transactions until the
664
- * finalization phase completes (~5 minutes after initiation)
665
- *
666
- * @param params Withdrawal parameters
667
- * @returns Result with txHash (HyperLiquid internal) and withdrawal ID
668
- */
669
- withdraw(params: WithdrawParams): Promise<WithdrawResult>;
670
- /**
671
- * Transfer USDC collateral between DEXs (main ↔ HIP-3)
672
- *
673
- * Verified working on mainnet via Phantom wallet testing (10/15/2025).
674
- * See docs/perps/HIP-3-IMPLEMENTATION.md for complete transaction flow.
675
- *
676
- * @param params - Transfer parameters
677
- * @param params.sourceDex - Source DEX name ('' = main, 'xyz' = HIP-3)
678
- * @param params.destinationDex - Destination DEX name ('' = main, 'xyz' = HIP-3)
679
- * @param params.amount - USDC amount to transfer
680
- * @returns Transfer result with success status and transaction hash
681
- *
682
- * @example
683
- * // Transfer 10 USDC from main DEX to xyz HIP-3 DEX
684
- * await transferBetweenDexs({
685
- * sourceDex: '',
686
- * destinationDex: 'xyz',
687
- * amount: '10'
688
- * });
689
- */
690
- transferBetweenDexs(params: TransferBetweenDexsParams): Promise<TransferBetweenDexsResult>;
691
- /**
692
- * Subscribe to live price updates
693
- *
694
- * @param params
695
- */
696
- subscribeToPrices(params: SubscribePricesParams): () => void;
697
- /**
698
- * Subscribe to live position updates
699
- *
700
- * @param params
701
- */
702
- subscribeToPositions(params: SubscribePositionsParams): () => void;
703
- /**
704
- * Subscribe to live order fill updates
705
- *
706
- * @param params
707
- */
708
- subscribeToOrderFills(params: SubscribeOrderFillsParams): () => void;
709
- /**
710
- * Subscribe to live order updates
711
- *
712
- * @param params
713
- */
714
- subscribeToOrders(params: SubscribeOrdersParams): () => void;
715
- /**
716
- * Subscribe to live account updates
717
- *
718
- * @param params
719
- */
720
- subscribeToAccount(params: SubscribeAccountParams): () => void;
721
- /**
722
- * Subscribe to open interest cap updates
723
- * Zero additional overhead - data extracted from existing webData2 subscription
724
- *
725
- * @param params
726
- */
727
- subscribeToOICaps(params: SubscribeOICapsParams): () => void;
728
- /**
729
- * Subscribe to full order book updates with multiple depth levels
730
- * Creates a dedicated L2Book subscription for real-time order book data
731
- *
732
- * @param params
733
- */
734
- subscribeToOrderBook(params: SubscribeOrderBookParams): () => void;
735
- /**
736
- * Subscribe to live candle updates
737
- *
738
- * @param params
739
- */
740
- subscribeToCandles(params: SubscribeCandlesParams): () => void;
741
- /**
742
- * Configure live data settings
743
- *
744
- * @param config
745
- */
746
- setLiveDataConfig(config: Partial<LiveDataConfig>): void;
747
- /**
748
- * Toggle testnet mode
749
- */
750
- toggleTestnet(): Promise<ToggleTestnetResult>;
751
- /**
752
- * Initialize provider (ensures clients are ready)
753
- */
754
- initialize(): Promise<InitializeResult>;
755
- /**
756
- * Check if ready to trade
757
- */
758
- isReadyToTrade(): Promise<ReadyToTradeResult>;
759
- /**
760
- * Calculate liquidation price using HyperLiquid's formula
761
- * Formula: liq_price = price - side * margin_available / position_size / (1 - l * side)
762
- * where l = 1 / MAINTENANCE_LEVERAGE = 1 / (2 * max_leverage)
763
- *
764
- * @param params
765
- */
766
- calculateLiquidationPrice(params: LiquidationPriceParams): Promise<string>;
767
- /**
768
- * Calculate maintenance margin for a specific asset
769
- * According to HyperLiquid docs: maintenance_margin = 1 / (2 * max_leverage)
770
- *
771
- * @param params
772
- */
773
- calculateMaintenanceMargin(params: MaintenanceMarginParams): Promise<number>;
774
- /**
775
- * Get maximum leverage allowed for an asset
776
- *
777
- * @param asset
778
- */
779
- getMaxLeverage(asset: string): Promise<number>;
780
- /**
781
- * Calculate fees based on HyperLiquid's fee structure
782
- * Returns fee rate as decimal (e.g., 0.00045 for 0.045%)
783
- *
784
- * Uses the SDK's userFees API to get actual discounted rates when available,
785
- * falling back to base rates if the API is unavailable or user not connected.
786
- *
787
- * @param params
788
- */
789
- calculateFees(params: FeeCalculationParams): Promise<FeeCalculationResult>;
790
- /**
791
- * Check if the fee cache is valid for a user
792
- *
793
- * @param userAddress
794
- * @private
795
- */
796
- private isFeeCacheValid;
797
- /**
798
- * Clear fee cache for a specific user or all users
799
- *
800
- * @param userAddress - Optional address to clear cache for
801
- */
802
- clearFeeCache(userAddress?: string): void;
803
- /**
804
- * Disconnect provider
805
- */
806
- disconnect(): Promise<DisconnectResult>;
807
- /**
808
- * Lightweight WebSocket health check using SDK's built-in ready() method
809
- * Checks if WebSocket connection is open without making expensive API calls
810
- *
811
- * @param timeoutMs - Optional timeout in milliseconds (defaults to WEBSOCKET_PING_TIMEOUT_MS)
812
- * @throws {Error} If WebSocket connection times out or fails
813
- */
814
- ping(timeoutMs?: number): Promise<void>;
815
- /**
816
- * Get the current WebSocket connection state from the client service.
817
- * Used by the UI to monitor connection health and show notifications.
818
- *
819
- * @returns The current WebSocket connection state
820
- */
821
- getWebSocketConnectionState(): WebSocketConnectionState;
822
- /**
823
- * Subscribe to WebSocket connection state changes.
824
- * The listener will be called immediately with the current state and whenever the state changes.
825
- *
826
- * @param listener - Callback function that receives the new connection state and reconnection attempt
827
- * @returns Unsubscribe function to remove the listener
828
- */
829
- subscribeToConnectionState(listener: (state: WebSocketConnectionState, reconnectionAttempt: number) => void): () => void;
830
- /**
831
- * Manually trigger a WebSocket reconnection attempt.
832
- * Used by the UI retry button when connection is lost.
833
- */
834
- reconnect(): Promise<void>;
835
- /**
836
- * Get list of available HIP-3 builder-deployed DEXs
837
- *
838
- * @param _params - Optional parameters (reserved for future filters/pagination)
839
- * @returns Array of DEX names (empty string '' represents main DEX)
840
- */
841
- getAvailableDexs(_params?: GetAvailableDexsParams): Promise<string[]>;
842
- /**
843
- * Get block explorer URL for an address or just the base URL
844
- *
845
- * @param address - Optional address to append to the base URL
846
- * @returns Block explorer URL
847
- */
848
- getBlockExplorerUrl(address?: string): string;
849
- private getBuilderAddress;
850
- private getReferralCode;
851
- /**
852
- * Ensure user has a MetaMask referral code set
853
- * Called once during initialization (ensureReady) to set up referral for the session
854
- * Uses session cache to avoid redundant API calls until disconnect/reconnect
855
- *
856
- * Cache semantics: Only caches successful referral sets (never caches "not set" state)
857
- * This allows detection of external referral changes between retries while avoiding redundant checks
858
- *
859
- * Note: This is network-specific - testnet and mainnet have separate referral states
860
- * Note: Non-blocking - failures are logged to Sentry but don't prevent trading
861
- * Note: Will automatically retry on next session if failed (cache cleared on disconnect)
862
- */
863
- private ensureReferralSet;
864
- /**
865
- * Check if the referral code is ready to be used
866
- *
867
- * @returns Promise resolving to true if referral code is ready
868
- */
869
- private isReferralCodeReady;
870
- /**
871
- * Check if user has a referral code set with HyperLiquid
872
- *
873
- * @returns Promise resolving to true if referral is set, false otherwise
874
- */
875
- private checkReferralSet;
876
- /**
877
- * Set MetaMask as the user's referrer on HyperLiquid
878
- */
879
- private setReferralCode;
880
- }
881
- //# sourceMappingURL=HyperLiquidProvider.d.cts.map