@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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ACF,IAAI,EAAE,IAAI;iBACX;aACF;SACF,CAAC;QACF,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IAED,qBAAqB;IACrB,MAAM,aAAa,GACjB,QAAQ,IAAI,CAAC,CAAC,eAAe,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAEzE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;AAC7C,CAAC","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nimport { BASIS_POINTS_DIVISOR } from '../constants/hyperLiquidConfig.js';\nimport {\n DECIMAL_PRECISION_CONFIG,\n MAX_ORDER_MARGIN_BUFFER,\n ORDER_SLIPPAGE_CONFIG,\n} from '../constants/perpsConfig.js';\nimport { PERPS_ERROR_CODES } from '../perpsErrorCodes.js';\nimport type { SDKOrderParams } from '../types/hyperliquid-types.js';\nimport type { PerpsDebugLogger } from '../types/index.js';\nimport type { OrdinaryOrderType, OrderType } from '../types/perps-types.js';\nimport {\n formatHyperLiquidPrice,\n formatHyperLiquidSize,\n} from './hyperLiquidAdapter.js';\nimport {\n getTriggerDirection,\n isLimitExecutionOrderType,\n isTriggerOrderType,\n SCALE_ORDER_COUNT,\n toSDKTimeInForce,\n} from './orderTypes.js';\n\n/**\n * Optional debug logger for order calculation functions.\n * When provided, enables detailed logging for debugging.\n */\nexport type OrderCalculationsDebugLogger = PerpsDebugLogger | undefined;\n\n/**\n * Tolerance used when deciding whether a scaled size is already on the size\n * grid, guarding against floating-point representation error.\n */\nconst FLOAT_TOLERANCE = 1e-6;\n\ntype PositionSizeParams = {\n amount: string;\n price: number;\n szDecimals: number;\n};\n\ntype MarginRequiredParams = {\n amount: string;\n leverage: number;\n};\n\ntype MaxAllowedAmountParams = {\n spendableBalance: number;\n assetPrice: number;\n assetSzDecimals: number;\n leverage: number;\n // Placement type. Only a resting order is margin-checked against its own\n // submitted price; a marketable order is charged at the fill price. Defaults\n // to 'market'.\n orderType?: 'market' | 'limit';\n // Price a limit order will rest at. Needed to size a limit order that rests\n // above the market price.\n limitPrice?: number;\n};\n\n// Advanced order calculation interfaces\nexport type CalculateFinalPositionSizeParams = {\n usdAmount?: string;\n size?: string;\n currentPrice: number;\n priceAtCalculation?: number;\n maxSlippageBps?: number;\n szDecimals: number;\n leverage?: number;\n // Reduce-only orders (position closes) may never round up: HyperLiquid\n // rejects a reduce-only order whose size exceeds the live position with\n // \"Reduce only order would increase position\".\n reduceOnly?: boolean;\n debugLogger?: OrderCalculationsDebugLogger;\n};\n\nexport type CalculateFinalPositionSizeResult = {\n finalPositionSize: number;\n};\n\nexport type CalculateOrderPriceAndSizeParams = {\n // Strategy placements are excluded: each derives its own prices and sizes and\n // never reaches this helper. Left in, `chase` would fall through as a\n // limit-priced order it carries no price for, and `twap`/`scale` would be\n // serialized as ordinary FrontendMarket orders.\n orderType: OrdinaryOrderType;\n isBuy: boolean;\n finalPositionSize: number;\n currentPrice: number;\n limitPrice?: string;\n // Trigger price for stop_*/take_profit_* placements. Required for those types:\n // `*_limit` executes at `limitPrice`, `*_market` derives a slippage-capped\n // limit price from this trigger price.\n triggerPrice?: string;\n // Max slippage in basis points (e.g. 300 = 3%). Applied to market orders and to\n // market-executing trigger orders (where it caps the limit price derived from\n // the trigger price); limit orders use limitPrice directly. Falls back to\n // ORDER_SLIPPAGE_CONFIG.DefaultMarketSlippageBps for market orders and\n // .DefaultTpslSlippageBps for market-executing triggers.\n maxSlippageBps?: number;\n szDecimals: number;\n};\n\nexport type CalculateOrderPriceAndSizeResult = {\n orderPrice: number;\n formattedSize: string;\n formattedPrice: string;\n};\n\nexport type BuildOrdersArrayParams = {\n assetId: number;\n isBuy: boolean;\n formattedPrice: string;\n formattedSize: string;\n reduceOnly: boolean;\n // Strategy placements never reach here; see `CalculateOrderPriceAndSizeParams`.\n orderType: OrdinaryOrderType;\n timeInForce?: 'GTC' | 'IOC' | 'ALO';\n clientOrderId?: string;\n // Trigger price for stop_*/take_profit_* placements (required for those types)\n triggerPrice?: string;\n takeProfitPrice?: string;\n stopLossPrice?: string;\n // Partial TP/SL sizes; default to the full order size when omitted\n takeProfitSize?: string;\n stopLossSize?: string;\n szDecimals: number;\n grouping?: 'na' | 'normalTpsl' | 'positionTpsl';\n};\n\nexport type BuildOrdersArrayResult = {\n orders: SDKOrderParams[];\n grouping: 'na' | 'normalTpsl' | 'positionTpsl';\n};\n\n/**\n * Calculate position size based on USD amount and asset price\n *\n * @param params - Amount in USD, current asset price, and required decimal precision\n * @returns Position size formatted to the asset's decimal precision\n */\nexport function calculatePositionSize(params: PositionSizeParams): string {\n const { amount, price, szDecimals } = params;\n\n // Validate required parameters\n if (szDecimals === undefined || szDecimals === null) {\n throw new Error('szDecimals is required for position size calculation');\n }\n if (szDecimals < 0) {\n throw new Error(`szDecimals must be >= 0, got: ${szDecimals}`);\n }\n\n const amountNum = parseFloat(amount || '0');\n\n if (isNaN(amountNum) || isNaN(price) || amountNum === 0 || price === 0) {\n return (0).toFixed(szDecimals);\n }\n\n const positionSize = amountNum / price;\n const multiplier = Math.pow(10, szDecimals);\n let rounded = Math.round(positionSize * multiplier) / multiplier;\n\n // Ensure rounded size meets requested USD (fix validation gap)\n const actualUsd = rounded * price;\n if (actualUsd < amountNum) {\n rounded += 1 / multiplier;\n }\n\n return rounded.toFixed(szDecimals);\n}\n\n/**\n * Calculate margin required for a position\n *\n * @param params - Position amount and leverage\n * @returns Margin required formatted to 2 decimal places\n */\nexport function calculateMarginRequired(params: MarginRequiredParams): string {\n const { amount, leverage } = params;\n const amountNum = parseFloat(amount || '0');\n\n if (\n isNaN(amountNum) ||\n isNaN(leverage) ||\n amountNum === 0 ||\n leverage === 0\n ) {\n return '0.00';\n }\n\n return (amountNum / leverage).toFixed(2);\n}\n\nexport function getMaxAllowedAmount(params: MaxAllowedAmountParams): number {\n const {\n spendableBalance,\n assetPrice,\n assetSzDecimals,\n leverage,\n orderType = 'market',\n limitPrice,\n } = params;\n if (spendableBalance === 0 || !assetPrice || assetSzDecimals === undefined) {\n return 0;\n }\n\n // HyperLiquid reserves initial margin for a RESTING order against the price\n // the order is submitted at, not the market price its size was derived from.\n // A limit order resting above the market price - typically a sell - therefore\n // needs more margin than a market-priced notional budgets for, and the\n // exchange refuses it with \"insufficient margin to place order\". Price the max\n // off that submitted price instead. A marketable order is charged at the fill\n // price, so it needs no adjustment.\n const executionPriceRatio =\n orderType === 'limit' && limitPrice && limitPrice > assetPrice\n ? limitPrice / assetPrice\n : 1;\n\n // The theoretical maximum is spendableBalance * leverage, expressed in the\n // market-price notional the caller works with.\n const theoreticalMax = (spendableBalance * leverage) / executionPriceRatio;\n\n // But we need to account for position size rounding\n // Find the largest whole dollar amount that fits within this limit\n let maxAmount = Math.floor(theoreticalMax);\n\n // Verify this amount doesn't exceed available balance after rounding\n const testPositionSize = calculatePositionSize({\n amount: maxAmount.toString(),\n price: assetPrice,\n szDecimals: assetSzDecimals,\n });\n\n const actualNotionalValue =\n parseFloat(testPositionSize) * assetPrice * executionPriceRatio;\n const requiredMargin = actualNotionalValue / leverage;\n\n // If rounding caused us to exceed available balance, step down by one position increment\n if (requiredMargin > spendableBalance) {\n const minPositionSizeIncrement = 1 / Math.pow(10, assetSzDecimals);\n const positionSizeIncrementUsd = Math.ceil(\n minPositionSizeIncrement * assetPrice,\n );\n maxAmount -= positionSizeIncrementUsd;\n }\n\n // Apply margin buffer to reduce \"Insufficient margin\" rejections from the exchange\n // (fees, rounding, and exchange-side checks can make 100% theoretical max fail)\n const bufferedMax = maxAmount * (1 - MAX_ORDER_MARGIN_BUFFER);\n\n return Math.max(0, Math.floor(bufferedMax));\n}\n\n/**\n * Round a size down onto the asset's size grid.\n *\n * Used for reduce-only orders, where rounding up would push the size past the\n * live position size. Values already on the grid are snapped rather than\n * truncated, because floating-point math can leave them just below a grid\n * point (0.0123 * 10000 === 122.99999999999999) and truncating would drop a\n * whole increment.\n *\n * The result is never greater than `size`, for negative sizes as well as\n * positive: the snap only ever recovers a grid point the input already\n * represents, so a value genuinely below a grid point is stepped down even when\n * the tolerance would have reached the point above it.\n *\n * A size whose scaled form reaches `2^53` is returned unchanged: doubles cannot\n * represent consecutive integers there, so the grid is finer than the spacing\n * between representable values and there is nothing to round down to.\n *\n * @param size - Size to round down.\n * @param szDecimals - The asset's size decimal precision.\n * @returns The size rounded down onto the size grid, never exceeding `size`.\n */\nexport function floorToSizeDecimals(size: number, szDecimals: number): number {\n const multiplier = Math.pow(10, szDecimals);\n const scaled = size * multiplier;\n\n // Past 2^53 a double cannot represent consecutive integers, so `units -= 1`\n // below would be a no-op and the step-down loop would never terminate. The\n // size grid is finer than the spacing between representable values at that\n // magnitude, so there is no increment to shave: return the input unchanged.\n if (!Number.isFinite(scaled) || Math.abs(scaled) >= Number.MAX_SAFE_INTEGER) {\n return size;\n }\n\n const nearest = Math.round(scaled);\n // The tolerance scales with the magnitude, because double-precision error\n // does too: a fixed epsilon would stop absorbing representation error for\n // sizes that scale past ~1e10 and would then shave off a whole increment.\n const tolerance = Math.max(\n FLOAT_TOLERANCE,\n Math.abs(scaled) * Number.EPSILON * 8,\n );\n let units =\n Math.abs(scaled - nearest) < tolerance ? nearest : Math.floor(scaled);\n\n // Step down until the result no longer exceeds the input. One pass is not\n // enough: a tolerance wide enough to absorb representation error at large\n // magnitudes also reaches the next grid point, and for an input less than half\n // an ulp below a grid point `size * multiplier` evaluates to exactly that grid\n // integer, so flooring the scaled value returns the same too-large result.\n // The comparison alone is the whole termination condition: for a non-negative\n // size the loop stops at or before zero, and for a negative size it stops once\n // the value is no longer above the input. Guarding on `units` instead would\n // skip a negative size below the tolerance, which snaps to `-0` — and\n // `-0 !== 0` is false. The 2^53 bail-out above keeps this bounded.\n while (units / multiplier > size) {\n units -= 1;\n }\n\n return units / multiplier;\n}\n\n/**\n * The smallest price increment the venue will represent at a given price.\n *\n * HyperLiquid bounds a perp price two ways at once — a decimal-place cap that\n * depends on the asset's size precision, and a significant-figure cap — so the\n * tick widens as the price grows. Whichever bound is coarser at this price is\n * the tick.\n *\n * @param params - Tick parameters.\n * @param params.price - Price to measure the increment at.\n * @param params.szDecimals - The asset's size decimal precision.\n * @returns The tick size at that price.\n */\nexport function getPriceTick(params: {\n price: number;\n szDecimals: number;\n}): number {\n const { price, szDecimals } = params;\n\n const byDecimals = Math.pow(\n 10,\n -(DECIMAL_PRECISION_CONFIG.MaxPriceDecimals - szDecimals),\n );\n const bySignificantFigures = Math.pow(\n 10,\n Math.floor(Math.log10(Math.abs(price))) -\n (DECIMAL_PRECISION_CONFIG.MaxSignificantFigures - 1),\n );\n\n return Math.max(byDecimals, bySignificantFigures);\n}\n\n/**\n * Price a chase order against the book it is chasing.\n *\n * The venue's own definition: a chase rests one tick *inside* the spread —\n * above the best bid for a buy, below the best ask for a sell — except when the\n * spread is already a single tick, where there is no room to improve and the\n * order joins the touch instead.\n *\n * Rests inside rather than at the touch because a chase is post-only: sitting\n * one tick ahead of the rest of the queue is the whole point, and joining the\n * touch would leave it behind every order already resting there.\n *\n * @param params - Quote parameters.\n * @param params.bestBid - Best bid, excluding the chase's own resting order.\n * @param params.bestAsk - Best ask, excluding the chase's own resting order.\n * @param params.isBuy - Which side the chase rests on.\n * @param params.szDecimals - The asset's size decimal precision.\n * @returns The formatted price the chase should rest at.\n */\nexport function computeChaseQuotePrice(params: {\n bestBid: number;\n bestAsk: number;\n isBuy: boolean;\n szDecimals: number;\n}): string {\n const { bestBid, bestAsk, isBuy, szDecimals } = params;\n\n const reference = isBuy ? bestBid : bestAsk;\n const tick = getPriceTick({ price: reference, szDecimals });\n const improved = isBuy ? bestBid + tick : bestAsk - tick;\n\n // A single-tick spread leaves nowhere to improve to: the improved price would\n // cross, which a post-only order cannot do. Join the touch instead.\n const crosses = isBuy ? improved >= bestAsk : improved <= bestBid;\n\n return formatHyperLiquidPrice({\n price: crosses ? reference : improved,\n szDecimals,\n });\n}\n\n/**\n * Compute the price ladder a scale placement fans out over.\n *\n * The ladder is inclusive of both ends — the first rung sits exactly on\n * `minPrice`, the last exactly on `maxPrice` — so the range the caller asked\n * for is the range that actually reaches the exchange.\n *\n * @param params - Ladder parameters.\n * @param params.minPrice - Lowest price in the ladder.\n * @param params.maxPrice - Highest price in the ladder; must exceed `minPrice`.\n * @param params.count - Number of rungs.\n * @returns The rung prices, ascending.\n */\nexport function computeScalePriceLadder(params: {\n minPrice: number;\n maxPrice: number;\n count: number;\n}): number[] {\n const { minPrice, maxPrice, count } = params;\n\n if (\n !Number.isInteger(count) ||\n count < SCALE_ORDER_COUNT.min ||\n count > SCALE_ORDER_COUNT.max\n ) {\n throw new Error(PERPS_ERROR_CODES.ORDER_SCALE_COUNT_INVALID);\n }\n if (\n !Number.isFinite(minPrice) ||\n !Number.isFinite(maxPrice) ||\n minPrice <= 0 ||\n maxPrice <= minPrice\n ) {\n throw new Error(PERPS_ERROR_CODES.ORDER_SCALE_RANGE_INVALID);\n }\n\n const step = (maxPrice - minPrice) / (count - 1);\n // The top rung is assigned rather than accumulated: `minPrice + step * n`\n // drifts, and a ladder that stops short of the caller's maxPrice would quietly\n // narrow the range they asked for.\n return Array.from({ length: count }, (_unused, index) =>\n index === count - 1 ? maxPrice : minPrice + step * index,\n );\n}\n\n/**\n * Split a scale placement's total size across its ladder rungs.\n *\n * The split is done in whole units of the asset's size grid rather than in\n * decimal sizes: dividing and re-flooring in floating point loses a sub-unit of\n * dust on every rung, and a ladder that submits less than the size that was\n * validated is not the order the caller placed. Either allocation below sums to\n * exactly `totalSize` in grid units.\n *\n * This is the one place the ladder's sizes are decided. Clients previewing a\n * scale placement must call it rather than reproduce the ramp, or the preview\n * and the placement will disagree at the rounding.\n *\n * **Even (no `skew`, or `skew` exactly 1).** Every rung gets `floor(total /\n * count)` units and whatever does not divide evenly goes onto the first rung —\n * 11 units across 3 rungs is `5, 3, 3`, not three equal slices.\n *\n * **Skewed.** Rung weights ramp linearly from 1 at index 0 to `skew` at the last\n * index, in ladder order — which is ascending price, `scaleMinPrice` to\n * `scaleMaxPrice`, for a buy and a sell alike. Each rung takes\n * `floor(weight / sumOfWeights * totalUnits)` units, and the units left over go\n * to the rungs with the largest discarded fraction, ties broken by ascending\n * index. The leftover is deliberately *not* dumped on the first rung the way the\n * even split does it: on a `skew` above 1 that would push size back to the end\n * of the ladder the caller weighted away from.\n *\n * The total is expected to sit on the grid already — `calculateFinalPositionSize`\n * floors it there — so rounding onto the grid here only absorbs representation\n * error. A total too small to give every rung a whole unit is rejected: placing\n * fewer orders than asked for would silently change the strategy. A `skew` far\n * enough from 1 can starve a rung the same way, and is rejected the same way.\n *\n * @param params - Split parameters.\n * @param params.totalSize - Total size to distribute.\n * @param params.count - Number of rungs.\n * @param params.szDecimals - The asset's size decimal precision.\n * @param params.skew - Optional size weighting across the ladder; any finite\n * value above 0, used exactly as given.\n * @returns One size string per rung, in ladder order.\n */\nexport function splitScaleSizes(params: {\n totalSize: number;\n count: number;\n szDecimals: number;\n skew?: number;\n}): string[] {\n const { totalSize, count, szDecimals, skew } = params;\n\n // Checked here as well as in `computeScalePriceLadder`: this is exported on\n // its own, and a count of zero would otherwise return an empty split while a\n // fractional one would return slices that do not sum to the total.\n if (\n !Number.isInteger(count) ||\n count < SCALE_ORDER_COUNT.min ||\n count > SCALE_ORDER_COUNT.max\n ) {\n throw new Error(PERPS_ERROR_CODES.ORDER_SCALE_COUNT_INVALID);\n }\n\n // Checked here rather than left to the arithmetic: a non-finite or\n // non-positive skew produces weights that are NaN or run negative, and either\n // one would come back as a ladder of zero-size rungs instead of a rejection.\n if (skew !== undefined && (!Number.isFinite(skew) || skew <= 0)) {\n throw new Error(PERPS_ERROR_CODES.ORDER_SCALE_RANGE_INVALID);\n }\n\n const multiplier = Math.pow(10, szDecimals);\n const totalUnits = Math.round(totalSize * multiplier);\n\n if (!Number.isSafeInteger(totalUnits) || totalUnits < count) {\n throw new Error(PERPS_ERROR_CODES.ORDER_SCALE_SIZE_TOO_SMALL);\n }\n\n const unitsPerRung =\n skew === undefined || skew === 1\n ? splitUnitsEvenly({ totalUnits, count })\n : splitUnitsBySkew({ totalUnits, count, skew });\n\n // A rung the ramp starved of every unit would be submitted as a zero-size\n // order. That is the same failure the total-size check above rejects, and it\n // is reported the same way, so a caller reads one reason for \"this ladder\n // cannot be cut this finely\" rather than two.\n if (unitsPerRung.some((units) => units === 0)) {\n throw new Error(PERPS_ERROR_CODES.ORDER_SCALE_SIZE_TOO_SMALL);\n }\n\n return unitsPerRung.map((units) =>\n formatHyperLiquidSize({ size: units / multiplier, szDecimals }),\n );\n}\n\n/**\n * Spread the ladder's units evenly, leftover on the first rung.\n *\n * @param params - Split parameters.\n * @param params.totalUnits - Total size, in whole size-grid units.\n * @param params.count - Number of rungs.\n * @returns Units per rung, in ladder order.\n */\nfunction splitUnitsEvenly(params: {\n totalUnits: number;\n count: number;\n}): number[] {\n const { totalUnits, count } = params;\n\n const sliceUnits = Math.floor(totalUnits / count);\n const remainderUnits = totalUnits - sliceUnits * count;\n\n return Array.from({ length: count }, (_unused, index) =>\n index === 0 ? sliceUnits + remainderUnits : sliceUnits,\n );\n}\n\n/**\n * Spread the ladder's units along a linear weight ramp.\n *\n * Flooring every rung leaves up to `count - 1` units unallocated, and they go to\n * the rungs that lost the most to the floor — the standard largest-remainder\n * allocation. Ties go to the lower index, which keeps the result a function of\n * the inputs alone rather than of sort stability.\n *\n * @param params - Split parameters.\n * @param params.totalUnits - Total size, in whole size-grid units.\n * @param params.count - Number of rungs.\n * @param params.skew - Weight of the last rung relative to the first.\n * @returns Units per rung, in ladder order.\n */\nfunction splitUnitsBySkew(params: {\n totalUnits: number;\n count: number;\n skew: number;\n}): number[] {\n const { totalUnits, count, skew } = params;\n\n const weights = Array.from(\n { length: count },\n (_unused, index) => 1 + ((skew - 1) * index) / (count - 1),\n );\n const weightSum = weights.reduce((sum, weight) => sum + weight, 0);\n\n const ideal = weights.map((weight) => (weight / weightSum) * totalUnits);\n const unitsPerRung = ideal.map((units) => Math.floor(units));\n const leftoverUnits =\n totalUnits - unitsPerRung.reduce((sum, units) => sum + units, 0);\n\n Array.from({ length: count }, (_unused, index) => index)\n .sort((left, right) => {\n const fractionDelta =\n ideal[right] - unitsPerRung[right] - (ideal[left] - unitsPerRung[left]);\n return fractionDelta === 0 ? left - right : fractionDelta;\n })\n .slice(0, leftoverUnits)\n .forEach((index) => {\n unitsPerRung[index] += 1;\n });\n\n return unitsPerRung;\n}\n\n/**\n * Calculates final position size using USD as source of truth with price validation\n *\n * This function implements the hybrid approach where USD is the source of truth,\n * but includes price staleness validation and proper rounding to prevent precision loss.\n *\n * @param params - USD amount, size, prices, and configuration\n * @returns Final position size as a number\n */\nexport function calculateFinalPositionSize(\n params: CalculateFinalPositionSizeParams,\n): CalculateFinalPositionSizeResult {\n const {\n usdAmount,\n size,\n currentPrice,\n priceAtCalculation,\n maxSlippageBps,\n szDecimals,\n leverage,\n reduceOnly,\n debugLogger,\n } = params;\n\n let finalPositionSize: number;\n\n // Validate price staleness whenever the caller supplied a calculation-time\n // price. This runs before the sizing branches on purpose: a full close submits\n // the exact live position size rather than a USD-derived one, and it must still\n // be rejected when the price has moved past the caller's tolerance.\n if (priceAtCalculation) {\n const priceDeltaBps = Math.abs(\n ((currentPrice - priceAtCalculation) / priceAtCalculation) * 10000,\n );\n const maxSlippageBpsValue =\n maxSlippageBps ?? ORDER_SLIPPAGE_CONFIG.DefaultMarketSlippageBps;\n\n if (priceDeltaBps > maxSlippageBpsValue) {\n throw new Error(\n `Price moved too much: ${priceDeltaBps.toFixed(0)} bps (max: ${maxSlippageBpsValue} bps). ` +\n `Expected: ${priceAtCalculation.toFixed(2)}, Current: ${currentPrice.toFixed(2)}`,\n );\n }\n\n debugLogger?.log('Price validation passed:', {\n priceAtCalculation,\n currentPrice,\n deltaBps: priceDeltaBps.toFixed(2),\n maxSlippageBps: maxSlippageBpsValue,\n });\n }\n\n if (usdAmount && parseFloat(usdAmount) > 0) {\n // USD amount provided - use it as source of truth\n const usdValue = parseFloat(usdAmount);\n\n // Recalculate position size with fresh price\n finalPositionSize = usdValue / currentPrice;\n\n // A reduce-only order may never exceed the size the caller asked to close:\n // that size is already clamped to the live position, while the USD amount was\n // computed against an older price and can imply a larger size after an\n // adverse move. Capping here keeps USD accuracy in the common case and makes\n // the caller's clamp binding.\n if (reduceOnly && size) {\n const requestedSize = parseFloat(size);\n\n // A supplied size must be positive, or the cap below would submit a\n // zero/negative order. Reject it rather than silently falling back to the\n // USD-derived size, matching how closePosition treats the same input.\n if (!Number.isFinite(requestedSize) || requestedSize <= 0) {\n throw new Error(PERPS_ERROR_CODES.ORDER_SIZE_POSITIVE);\n }\n\n finalPositionSize = Math.min(finalPositionSize, requestedSize);\n }\n\n // 3. Apply size decimals rounding (reduce-only never rounds up)\n const multiplier = Math.pow(10, szDecimals);\n const sizeBeforeRounding = finalPositionSize;\n finalPositionSize = reduceOnly\n ? floorToSizeDecimals(finalPositionSize, szDecimals)\n : Math.round(finalPositionSize * multiplier) / multiplier;\n\n // Rounding down can zero out a reduce-only order whose USD value is worth\n // less than one size increment. Fail with a clear error instead of\n // submitting a size of \"0\" the exchange will reject.\n if (reduceOnly && finalPositionSize <= 0 && sizeBeforeRounding > 0) {\n throw new Error(PERPS_ERROR_CODES.ORDER_SIZE_POSITIVE);\n }\n\n // 4. Ensure rounded size meets requested USD (fix validation gap).\n // Skipped for reduce-only orders: adding an increment there would submit\n // more than the position holds and HyperLiquid rejects the order.\n let actualNotionalValue = finalPositionSize * currentPrice;\n if (!reduceOnly && actualNotionalValue < usdValue) {\n // Add 1 minimum increment to meet requested USD\n finalPositionSize += 1 / multiplier;\n actualNotionalValue = finalPositionSize * currentPrice;\n\n debugLogger?.log('Position size adjusted to meet USD minimum:', {\n requestedUsd: usdValue,\n beforeAdjustment: finalPositionSize - 1 / multiplier,\n afterAdjustment: finalPositionSize,\n actualUsd: actualNotionalValue,\n });\n }\n\n const requiredMargin = actualNotionalValue / (leverage ?? 1);\n\n // Log if rounding caused significant difference\n const usdDifference = Math.abs(actualNotionalValue - usdValue);\n if (usdDifference > 0.01) {\n debugLogger?.log(\n 'Position size rounding caused USD difference (acceptable):',\n {\n requestedUsd: usdValue,\n actualUsd: actualNotionalValue,\n difference: usdDifference,\n positionSize: finalPositionSize,\n },\n );\n }\n\n debugLogger?.log('Recalculated position size with fresh price:', {\n usdAmount: usdValue,\n priceAtCalculation,\n currentPrice,\n originalSize: size,\n recalculatedSize: finalPositionSize,\n requiredMargin,\n minIncrement: 1 / multiplier,\n });\n } else {\n // Legacy: Use provided size (backward compatibility)\n finalPositionSize = parseFloat(size ?? '0');\n\n // Reduce-only sizes are formatted with toFixed() further down, which rounds\n // up; truncate onto the size grid first so a close can never exceed the\n // position it is closing.\n if (reduceOnly) {\n // A supplied size must be positive, or formatHyperLiquidSize would render\n // a zero or negative order size. The USD branch above rejects the same\n // input.\n if (size && !(finalPositionSize > 0)) {\n throw new Error(PERPS_ERROR_CODES.ORDER_SIZE_POSITIVE);\n }\n\n const sizeBeforeFlooring = finalPositionSize;\n finalPositionSize = floorToSizeDecimals(finalPositionSize, szDecimals);\n\n // A positive size that floors to zero is worth less than one increment\n if (finalPositionSize <= 0 && sizeBeforeFlooring > 0) {\n throw new Error(PERPS_ERROR_CODES.ORDER_SIZE_POSITIVE);\n }\n }\n\n debugLogger?.log(\n 'Using legacy size calculation (no USD amount provided):',\n {\n providedSize: size,\n finalSize: finalPositionSize,\n },\n );\n }\n\n return { finalPositionSize };\n}\n\n/**\n * Calculates order price and formatted size based on order type\n *\n * @param params - Order parameters including type, direction, size, and prices\n * @returns Formatted order price, size, and price string\n */\nexport function calculateOrderPriceAndSize(\n params: CalculateOrderPriceAndSizeParams,\n): CalculateOrderPriceAndSizeResult {\n const {\n orderType,\n isBuy,\n finalPositionSize,\n currentPrice,\n limitPrice,\n triggerPrice,\n maxSlippageBps,\n szDecimals,\n } = params;\n\n let orderPrice: number;\n let formattedSize: string;\n\n if (isTriggerOrderType(orderType)) {\n // Trigger placements price off the trigger, not the live market: the order\n // rests off-book until the trigger fires.\n if (!triggerPrice) {\n throw new Error(PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_REQUIRED);\n }\n\n const triggerPriceNum = parseFloat(triggerPrice);\n if (isNaN(triggerPriceNum) || triggerPriceNum <= 0) {\n throw new Error(PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_POSITIVE);\n }\n\n if (isLimitExecutionOrderType(orderType)) {\n if (!limitPrice) {\n throw new Error(PERPS_ERROR_CODES.ORDER_LIMIT_PRICE_REQUIRED);\n }\n orderPrice = parseFloat(limitPrice);\n } else {\n // Market execution on trigger: HyperLiquid still needs a limit price, used\n // as a slippage cap. The caller's tolerance wins when supplied; otherwise\n // the 10% convention of the existing TP/SL children applies.\n const effectiveBps =\n maxSlippageBps ?? ORDER_SLIPPAGE_CONFIG.DefaultTpslSlippageBps;\n const slippageValue = effectiveBps / BASIS_POINTS_DIVISOR;\n orderPrice = isBuy\n ? triggerPriceNum * (1 + slippageValue)\n : triggerPriceNum * (1 - slippageValue);\n }\n\n formattedSize = formatHyperLiquidSize({\n size: finalPositionSize,\n szDecimals,\n });\n } else if (orderType === 'market') {\n // Market orders: apply slippage buffer to the live price so HyperLiquid\n // receives a worst-case acceptable limit price. Falls back to the\n // documented default if the caller does not provide one.\n const effectiveBps =\n maxSlippageBps ?? ORDER_SLIPPAGE_CONFIG.DefaultMarketSlippageBps;\n const slippageValue = effectiveBps / BASIS_POINTS_DIVISOR;\n orderPrice = isBuy\n ? currentPrice * (1 + slippageValue)\n : currentPrice * (1 - slippageValue);\n formattedSize = formatHyperLiquidSize({\n size: finalPositionSize,\n szDecimals,\n });\n } else {\n // Limit orders: use provided price (no slippage applied)\n if (!limitPrice) {\n throw new Error(PERPS_ERROR_CODES.ORDER_LIMIT_PRICE_REQUIRED);\n }\n orderPrice = parseFloat(limitPrice);\n formattedSize = formatHyperLiquidSize({\n size: finalPositionSize,\n szDecimals,\n });\n }\n\n const formattedPrice = formatHyperLiquidPrice({\n price: orderPrice,\n szDecimals,\n });\n\n return { orderPrice, formattedSize, formattedPrice };\n}\n\n/**\n * Build the SDK order-type field for the main order.\n *\n * Trigger placements map to the SDK's trigger shape; everything else keeps the\n * existing Gtc/FrontendMarket limit shape.\n *\n * @param params - Order type parameters\n * @param params.orderType - Placement type\n * @param params.timeInForce - Time in force; only limit orders may carry one\n * @param params.triggerPrice - Trigger price (required for trigger placements)\n * @param params.szDecimals - Asset size decimals, for price formatting\n * @returns The SDK `t` field for the main order\n */\nfunction buildMainOrderTypeField(params: {\n orderType: OrderType;\n timeInForce?: 'GTC' | 'IOC' | 'ALO';\n triggerPrice?: string;\n szDecimals: number;\n}): SDKOrderParams['t'] {\n const { orderType, timeInForce, triggerPrice, szDecimals } = params;\n\n if (!isTriggerOrderType(orderType)) {\n if (orderType === 'limit') {\n return { limit: { tif: toSDKTimeInForce(timeInForce) } };\n }\n if (timeInForce !== undefined) {\n throw new Error(PERPS_ERROR_CODES.ORDER_TIME_IN_FORCE_NOT_SUPPORTED);\n }\n return { limit: { tif: 'FrontendMarket' } };\n }\n\n if (timeInForce !== undefined) {\n throw new Error(PERPS_ERROR_CODES.ORDER_TIME_IN_FORCE_NOT_SUPPORTED);\n }\n\n if (!triggerPrice) {\n throw new Error(PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_REQUIRED);\n }\n\n return {\n trigger: {\n isMarket: !isLimitExecutionOrderType(orderType),\n triggerPx: formatTriggerPrice({\n price: triggerPrice,\n szDecimals,\n error: PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_POSITIVE,\n }),\n tpsl: getTriggerDirection(orderType) === 'stop' ? 'sl' : 'tp',\n },\n };\n}\n\n/**\n * Format a price that becomes a `triggerPx`, rejecting one that disappears at\n * the asset's precision.\n *\n * A positive price below the asset's tick (`0.0004` where the asset quotes to\n * three places) formats to `'0'`, which the exchange rejects. Callers validate\n * this up front via `validateOrderPrecision`; this is the guard on the build\n * path itself, so no caller can assemble an order that cannot be accepted.\n *\n * @param params - Price parameters\n * @param params.price - The requested price\n * @param params.szDecimals - Asset size decimals\n * @param params.error - Typed error to throw when the price rounds away\n * @returns The exchange-formatted price, guaranteed positive.\n */\nfunction formatTriggerPrice(params: {\n price: string;\n szDecimals: number;\n error: string;\n}): string {\n const { price, szDecimals, error } = params;\n const formatted = formatHyperLiquidPrice({ price, szDecimals });\n\n if (parseFloat(formatted) <= 0) {\n throw new Error(error);\n }\n\n return formatted;\n}\n\n/**\n * Resolve the size of an attached TP/SL order.\n *\n * @param params - Size parameters\n * @param params.tpslSize - Requested partial size, if any\n * @param params.formattedSize - Full order size, used when no partial size is given\n * @param params.szDecimals - Asset size decimals\n * @returns The exchange-formatted TP/SL order size\n */\nfunction formatTpslSize(params: {\n tpslSize?: string;\n formattedSize: string;\n szDecimals: number;\n}): string {\n const { tpslSize, formattedSize, szDecimals } = params;\n\n if (tpslSize === undefined) {\n return formattedSize;\n }\n\n // Validation compares the requested size against `params.size`, but a\n // usdAmount-based order is finally sized from a fresher price, so the parent\n // can end up smaller than the child that validated cleanly. Clamp so the\n // attached TP/SL never exceeds the order it protects.\n const requested = parseFloat(tpslSize);\n const parentSize = parseFloat(formattedSize);\n const size =\n Number.isFinite(parentSize) && Number.isFinite(requested)\n ? Math.min(requested, parentSize)\n : requested;\n\n return formatPartialTpslSize({ size, szDecimals });\n}\n\n/**\n * Check that an order's prices and partial sizes survive the asset's precision.\n *\n * Validation elsewhere sees the values the caller supplied; this sees what the\n * exchange will actually receive. A positive value below the asset's tick\n * formats to `'0'`, which either changes the order's meaning (a zero-sized\n * trigger covers the whole position) or is rejected outright (a zero\n * `triggerPx`).\n *\n * Callers run this before taking any side effect — cancelling the position's\n * existing triggers, changing leverage, moving HIP-3 margin — so a value that\n * would only fail once the orders are built cannot leave a position stripped of\n * its protection, or an account with leverage moved, for an order that was\n * never going to be accepted.\n *\n * @param params - Price and size parameters\n * @param params.triggerPrice - Trigger price for a trigger placement, if any\n * @param params.takeProfitPrice - Attached take profit price, if any\n * @param params.stopLossPrice - Attached stop loss price, if any\n * @param params.takeProfitSize - Requested partial take profit size, if any\n * @param params.stopLossSize - Requested partial stop loss size, if any\n * @param params.szDecimals - Asset size decimals\n * @returns Validation result with isValid flag and optional error message\n */\nexport function validateOrderPrecision(params: {\n triggerPrice?: string;\n takeProfitPrice?: string;\n stopLossPrice?: string;\n takeProfitSize?: string;\n stopLossSize?: string;\n szDecimals: number;\n}): { isValid: boolean; error?: string } {\n const {\n triggerPrice,\n takeProfitPrice,\n stopLossPrice,\n takeProfitSize,\n stopLossSize,\n szDecimals,\n } = params;\n\n for (const size of [takeProfitSize, stopLossSize]) {\n if (size === undefined) {\n continue;\n }\n\n // Mirror how the size is actually submitted. A partial TP/SL size is\n // floored onto the size grid (formatPartialTpslSize) because a reduce-only\n // trigger must not exceed its position, so checking it with the half-up\n // formatter accepted sizes in [0.5, 1) increments here and refused them\n // later — after trading setup had prompted for signatures and written\n // approvals, and after the pre-cancel sweep had cleared the position's\n // existing triggers. Flooring here refuses them before any of that.\n const parsedSize = parseFloat(size);\n const flooredSize = Number.isFinite(parsedSize)\n ? floorToSizeDecimals(parsedSize, szDecimals)\n : parsedSize;\n\n if (!(flooredSize > 0)) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TPSL_SIZE_INVALID,\n };\n }\n }\n\n // Prices carry their own precision: an asset quotes to\n // `MaxPriceDecimals - szDecimals` places, so a positive price under that tick\n // formats to '0'. Every one of these becomes a `triggerPx` the exchange\n // rejects outright.\n const priceChecks: [string | undefined, string][] = [\n [triggerPrice, PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_POSITIVE],\n [takeProfitPrice, PERPS_ERROR_CODES.ORDER_PRICE_POSITIVE],\n [stopLossPrice, PERPS_ERROR_CODES.ORDER_PRICE_POSITIVE],\n ];\n\n for (const [price, error] of priceChecks) {\n if (price === undefined) {\n continue;\n }\n\n if (parseFloat(formatHyperLiquidPrice({ price, szDecimals })) <= 0) {\n return { isValid: false, error };\n }\n }\n\n return { isValid: true };\n}\n\n/**\n * Format a partial TP/SL size, rejecting one that disappears at the asset\n * precision.\n *\n * Validation only sees the requested size, so a positive value below the\n * asset's precision (0.0004 against `szDecimals: 3`) passes and then formats to\n * `'0'`. HyperLiquid reads a zero-sized trigger as covering the whole position,\n * which would silently turn a partial TP/SL into a full close.\n *\n * The size is floored onto the asset's size grid before formatting. A partial\n * TP/SL is a reduce-only trigger, so it may never exceed the position it\n * protects: `formatHyperLiquidSize` rounds half-up, which turns a size sitting\n * on a half-increment into one the position cannot absorb (0.115 at\n * `szDecimals: 2` becomes '0.12'), and HyperLiquid rejects that with \"Reduce\n * only order would increase position\". Callers clamp to the position or parent\n * order before calling, so rounding up here would undo their clamp.\n *\n * @param params - Size parameters\n * @param params.size - The requested partial size\n * @param params.szDecimals - Asset size decimals\n * @returns The exchange-formatted size, guaranteed positive.\n */\nexport function formatPartialTpslSize(params: {\n size: string | number;\n szDecimals: number;\n}): string {\n const { size, szDecimals } = params;\n const requested = typeof size === 'string' ? parseFloat(size) : size;\n\n // A non-numeric size cannot be floored; leave it to formatHyperLiquidSize,\n // which renders it as '0' and is rejected just below.\n const flooredSize = Number.isFinite(requested)\n ? floorToSizeDecimals(requested, szDecimals)\n : requested;\n\n const formatted = formatHyperLiquidSize({ size: flooredSize, szDecimals });\n\n if (parseFloat(formatted) <= 0) {\n throw new Error(PERPS_ERROR_CODES.ORDER_TPSL_SIZE_INVALID);\n }\n\n return formatted;\n}\n\n/**\n * Builds orders array including main order and optional TP/SL orders\n *\n * @param params - Order construction parameters\n * @returns Array of SDK order params and grouping type\n */\nexport function buildOrdersArray(\n params: BuildOrdersArrayParams,\n): BuildOrdersArrayResult {\n const {\n assetId,\n isBuy,\n formattedPrice,\n formattedSize,\n reduceOnly,\n orderType,\n timeInForce,\n clientOrderId,\n triggerPrice,\n takeProfitPrice,\n stopLossPrice,\n takeProfitSize,\n stopLossSize,\n szDecimals,\n grouping,\n } = params;\n\n const orders: SDKOrderParams[] = [];\n\n // 1. Main order\n const mainOrder: SDKOrderParams = {\n a: assetId,\n b: isBuy,\n p: formattedPrice,\n s: formattedSize,\n r: reduceOnly || false,\n t: buildMainOrderTypeField({\n orderType,\n timeInForce,\n triggerPrice,\n szDecimals,\n }),\n c: clientOrderId ? (clientOrderId as Hex) : undefined,\n };\n orders.push(mainOrder);\n\n // 2. Take Profit order\n if (takeProfitPrice) {\n const tpOrder: SDKOrderParams = {\n a: assetId,\n b: !isBuy,\n p: formatHyperLiquidPrice({\n price: parseFloat(takeProfitPrice),\n szDecimals,\n }),\n s: formatTpslSize({\n tpslSize: takeProfitSize,\n formattedSize,\n szDecimals,\n }),\n r: true,\n t: {\n trigger: {\n isMarket: false,\n triggerPx: formatTriggerPrice({\n price: takeProfitPrice,\n szDecimals,\n error: PERPS_ERROR_CODES.ORDER_PRICE_POSITIVE,\n }),\n tpsl: 'tp',\n },\n },\n };\n orders.push(tpOrder);\n }\n\n // 3. Stop Loss order\n if (stopLossPrice) {\n // Apply 10% slippage to SL limit price (executes as market order when triggered)\n // HyperLiquid recommended: 10% for TP/SL orders\n const stopLossPriceNum = parseFloat(stopLossPrice);\n const slippageValue = ORDER_SLIPPAGE_CONFIG.DefaultTpslSlippageBps / 10000;\n const limitPriceWithSlippage = isBuy\n ? stopLossPriceNum * (1 - slippageValue) // Selling to close long: willing to accept LESS (slippage protection)\n : stopLossPriceNum * (1 + slippageValue); // Buying to close short: willing to pay MORE (slippage protection)\n\n const slOrder: SDKOrderParams = {\n a: assetId,\n b: !isBuy,\n p: formatHyperLiquidPrice({\n price: limitPriceWithSlippage,\n szDecimals,\n }),\n s: formatTpslSize({ tpslSize: stopLossSize, formattedSize, szDecimals }),\n r: true,\n t: {\n trigger: {\n isMarket: true,\n triggerPx: formatTriggerPrice({\n price: stopLossPrice,\n szDecimals,\n error: PERPS_ERROR_CODES.ORDER_PRICE_POSITIVE,\n }),\n tpsl: 'sl',\n },\n },\n };\n orders.push(slOrder);\n }\n\n // Determine grouping\n const finalGrouping: 'na' | 'normalTpsl' | 'positionTpsl' =\n grouping ?? ((takeProfitPrice ?? stopLossPrice) ? 'normalTpsl' : 'na');\n\n return { orders, grouping: finalGrouping };\n}\n"]}
@@ -0,0 +1,166 @@
1
+ import type { Order, PositionTriggerOrder } from '../types/index.js';
2
+ import type { OrderExecution, OrderType, StrategyOrderType, TriggerDirection, TriggerOrderType } from '../types/perps-types.js';
3
+ /**
4
+ * All trigger placement types, in a stable order suitable for iteration
5
+ * (validation tables, e2e matrices).
6
+ */
7
+ export declare const TRIGGER_ORDER_TYPES: readonly ["stop_market", "stop_limit", "take_profit_market", "take_profit_limit"];
8
+ /**
9
+ * All strategy placement types, in a stable order suitable for iteration
10
+ * (validation tables, e2e matrices).
11
+ */
12
+ export declare const STRATEGY_ORDER_TYPES: readonly ["twap", "scale", "chase"];
13
+ /**
14
+ * Bounds on how many limit orders a scale placement may fan out into.
15
+ *
16
+ * A ladder needs at least two rungs to span a range at all; the upper bound
17
+ * keeps a single placement from consuming a venue's per-account open-order
18
+ * budget. Protocol-agnostic: a provider whose venue is stricter narrows this
19
+ * further in its own validation.
20
+ */
21
+ export declare const SCALE_ORDER_COUNT: {
22
+ readonly min: 2;
23
+ readonly max: 20;
24
+ };
25
+ /**
26
+ * Check whether an order type is a trigger placement (stop / take profit).
27
+ *
28
+ * @param orderType - Order type to check.
29
+ * @returns True when the type requires `OrderParams.triggerPrice`.
30
+ */
31
+ export declare function isTriggerOrderType(orderType: OrderType): orderType is TriggerOrderType;
32
+ /**
33
+ * Check whether an order type is a strategy placement (TWAP / scale / chase).
34
+ *
35
+ * @param orderType - Order type to check.
36
+ * @returns True when the placement expands into an execution schedule rather
37
+ * than a single order.
38
+ */
39
+ export declare function isStrategyOrderType(orderType: OrderType): orderType is StrategyOrderType;
40
+ /**
41
+ * Check whether an order type executes as a limit order.
42
+ *
43
+ * Covers plain limit orders and the `*_limit` trigger types, both of which
44
+ * require `OrderParams.price`.
45
+ *
46
+ * @param orderType - Order type to check.
47
+ * @returns True when the order executes as a limit order.
48
+ */
49
+ export declare function isLimitExecutionOrderType(orderType: OrderType): boolean;
50
+ /**
51
+ * Get how an order executes, ignoring whether it is trigger-gated.
52
+ *
53
+ * This is also the coarse execution type that consumers predating trigger orders
54
+ * understand (fee tiers, max order value, analytics). It answers "does this rest
55
+ * on the book or cross it", which is not the same question as
56
+ * `isLimitExecutionOrderType` — a scale ladder and a chase rest limit orders
57
+ * without carrying an `OrderParams.price`.
58
+ *
59
+ * @param orderType - Order type to inspect.
60
+ * @returns `'limit'` for limit, `*_limit`, `scale` and `chase`; `'market'`
61
+ * otherwise, including `twap`, whose suborders cross the book.
62
+ */
63
+ export declare function getTriggerExecution(orderType: OrderType): OrderExecution;
64
+ /**
65
+ * Get the direction a trigger order fires in.
66
+ *
67
+ * @param orderType - Trigger order type.
68
+ * @returns `'stop'` for `stop_*`, `'take_profit'` for `take_profit_*`.
69
+ */
70
+ export declare function getTriggerDirection(orderType: TriggerOrderType): TriggerDirection;
71
+ /**
72
+ * Recover which way a trigger fires from its price relative to the entry.
73
+ *
74
+ * Used when the exchange reports a trigger without naming its placement type:
75
+ * a long takes profit above its entry and stops out below, a short the other
76
+ * way round. Shared by both transports so they classify identically.
77
+ *
78
+ * @param params - Classification parameters
79
+ * @param params.triggerPrice - Price at which the order activates
80
+ * @param params.entryPrice - Entry price of the position it is attached to
81
+ * @param params.positionSize - Signed position size; its sign gives the side
82
+ * @returns The direction, or undefined when there is nothing to compare against
83
+ */
84
+ export declare function classifyTriggerDirection(params: {
85
+ triggerPrice?: string;
86
+ entryPrice?: string;
87
+ positionSize: string;
88
+ }): TriggerDirection | undefined;
89
+ /**
90
+ * Project a normalized open order onto the position-state view of a trigger order.
91
+ *
92
+ * Returns undefined when the order is not a trigger, or when its direction can
93
+ * be established neither from a named placement type nor from its price.
94
+ *
95
+ * @param params - Mapping parameters
96
+ * @param params.order - Normalized open order
97
+ * @param params.positionSize - Size of the position the trigger is attached to
98
+ * @param params.entryPrice - Entry price, used to classify an unnamed trigger
99
+ * @returns The position trigger order, or undefined
100
+ */
101
+ export declare function buildPositionTriggerOrderFromOrder(params: {
102
+ order: Order;
103
+ positionSize: string;
104
+ entryPrice?: string;
105
+ }): PositionTriggerOrder | undefined;
106
+ /**
107
+ * Resolve the scalar TP/SL summary price a position reports for one direction.
108
+ *
109
+ * The scalar fields are only ever scanned from position-bound triggers, so a
110
+ * position whose only take profit (or stop loss) is quantity-scoped reported a
111
+ * count of 1 with no price — and a client that renders the scalar showed
112
+ * nothing. When the direction has exactly one trigger order, that order is the
113
+ * price, whether or not it is position-bound.
114
+ *
115
+ * Two or more triggers keep the scanned value: no single price describes them,
116
+ * and clients render the count instead. Zero triggers keep it too, because it
117
+ * still carries the TP/SL of a *pending* order on the market, which the arrays
118
+ * deliberately exclude.
119
+ *
120
+ * @param params - Resolution parameters
121
+ * @param params.triggerOrders - Trigger orders attached to the position for one direction
122
+ * @param params.scannedPrice - Price scanned from position-bound triggers, if any
123
+ * @returns The price to report, or undefined when there is none
124
+ */
125
+ export declare function resolvePositionTriggerSummaryPrice(params: {
126
+ triggerOrders: PositionTriggerOrder[];
127
+ scannedPrice?: string;
128
+ }): string | undefined;
129
+ /**
130
+ * Build a trigger order type from its two independent dimensions.
131
+ *
132
+ * @param params - Trigger dimensions.
133
+ * @param params.direction - Whether the trigger is a stop or a take profit.
134
+ * @param params.execution - How the order executes once triggered.
135
+ * @returns The matching trigger order type.
136
+ */
137
+ export declare function buildTriggerOrderType(params: {
138
+ direction: TriggerDirection;
139
+ execution: OrderExecution;
140
+ }): TriggerOrderType;
141
+ /**
142
+ * Map the controller's time in force onto the exchange's spelling.
143
+ *
144
+ * Shared by the two order-building paths so they cannot drift apart.
145
+ *
146
+ * @param timeInForce - Requested time in force; defaults to GTC.
147
+ * @returns The SDK time-in-force value.
148
+ */
149
+ export declare function toSDKTimeInForce(timeInForce?: 'GTC' | 'IOC' | 'ALO'): 'Gtc' | 'Ioc' | 'Alo';
150
+ /**
151
+ * Hash the identity of a position's trigger orders for change detection.
152
+ *
153
+ * Streamed positions only re-emit when their hash changes, so this has to move
154
+ * when a trigger is added, removed, repriced, resized, or retyped — otherwise
155
+ * subscribers never receive the updated arrays.
156
+ *
157
+ * The placement type is part of the identity because a trigger can be modified
158
+ * in place: switching a stop from market to limit execution keeps its order ID,
159
+ * trigger price, and size, so nothing else here would move even though the
160
+ * execution semantics subscribers rely on have changed.
161
+ *
162
+ * @param orders - Trigger orders attached to a position, if any.
163
+ * @returns A stable string; `'0'` for both empty and absent.
164
+ */
165
+ export declare function hashTriggerOrders(orders?: PositionTriggerOrder[]): string;
166
+ //# sourceMappingURL=orderTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orderTypes.d.ts","sourceRoot":"","sources":["../../src/utils/orderTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAEjC;;;GAGG;AACH,eAAO,MAAM,mBAAmB,mFAKgB,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,qCAIgB,CAAC;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB;aAAK,GAAG,EAAE,CAAC;aAAE,GAAG,EAAE,EAAE;CAAW,CAAC;AA8B9D;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,SAAS,GACnB,SAAS,IAAI,gBAAgB,CAE/B;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,SAAS,GACnB,SAAS,IAAI,iBAAiB,CAEhC;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAIvE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,SAAS,GAAG,cAAc,CAIxE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,gBAAgB,GAC1B,gBAAgB,CAIlB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,gBAAgB,GAAG,SAAS,CAuB/B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kCAAkC,CAAC,MAAM,EAAE;IACzD,KAAK,EAAE,KAAK,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,oBAAoB,GAAG,SAAS,CAqDnC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kCAAkC,CAAC,MAAM,EAAE;IACzD,aAAa,EAAE,oBAAoB,EAAE,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,MAAM,GAAG,SAAS,CAQrB;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,SAAS,EAAE,gBAAgB,CAAC;IAC5B,SAAS,EAAE,cAAc,CAAC;CAC3B,GAAG,gBAAgB,CAQnB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,GAClC,KAAK,GAAG,KAAK,GAAG,KAAK,CASvB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAUzE"}
@@ -0,0 +1,287 @@
1
+ /**
2
+ * All trigger placement types, in a stable order suitable for iteration
3
+ * (validation tables, e2e matrices).
4
+ */
5
+ export const TRIGGER_ORDER_TYPES = [
6
+ 'stop_market',
7
+ 'stop_limit',
8
+ 'take_profit_market',
9
+ 'take_profit_limit',
10
+ ];
11
+ /**
12
+ * All strategy placement types, in a stable order suitable for iteration
13
+ * (validation tables, e2e matrices).
14
+ */
15
+ export const STRATEGY_ORDER_TYPES = [
16
+ 'twap',
17
+ 'scale',
18
+ 'chase',
19
+ ];
20
+ /**
21
+ * Bounds on how many limit orders a scale placement may fan out into.
22
+ *
23
+ * A ladder needs at least two rungs to span a range at all; the upper bound
24
+ * keeps a single placement from consuming a venue's per-account open-order
25
+ * budget. Protocol-agnostic: a provider whose venue is stricter narrows this
26
+ * further in its own validation.
27
+ */
28
+ export const SCALE_ORDER_COUNT = { min: 2, max: 20 };
29
+ /**
30
+ * Order types whose price field (`OrderParams.price`) is a real limit price the
31
+ * exchange must honour, as opposed to a slippage cap derived from the market.
32
+ */
33
+ const LIMIT_EXECUTION_ORDER_TYPES = [
34
+ 'limit',
35
+ 'stop_limit',
36
+ 'take_profit_limit',
37
+ ];
38
+ /**
39
+ * Order types that rest limit orders on the book, whatever decides their price.
40
+ *
41
+ * A superset of `LIMIT_EXECUTION_ORDER_TYPES`: a scale ladder and a chase both
42
+ * rest limit orders, but they derive their own prices rather than taking one
43
+ * from `OrderParams.price`, so they are limit *execution* without being
44
+ * limit-*priced*. A TWAP is absent because its suborders cross the book.
45
+ *
46
+ * The distinction matters wherever execution is what is being charged or
47
+ * bounded — fee tier, max order value — as opposed to where the caller's price
48
+ * field is being read.
49
+ */
50
+ const LIMIT_RESTING_ORDER_TYPES = [
51
+ ...LIMIT_EXECUTION_ORDER_TYPES,
52
+ 'scale',
53
+ 'chase',
54
+ ];
55
+ /**
56
+ * Check whether an order type is a trigger placement (stop / take profit).
57
+ *
58
+ * @param orderType - Order type to check.
59
+ * @returns True when the type requires `OrderParams.triggerPrice`.
60
+ */
61
+ export function isTriggerOrderType(orderType) {
62
+ return TRIGGER_ORDER_TYPES.includes(orderType);
63
+ }
64
+ /**
65
+ * Check whether an order type is a strategy placement (TWAP / scale / chase).
66
+ *
67
+ * @param orderType - Order type to check.
68
+ * @returns True when the placement expands into an execution schedule rather
69
+ * than a single order.
70
+ */
71
+ export function isStrategyOrderType(orderType) {
72
+ return STRATEGY_ORDER_TYPES.includes(orderType);
73
+ }
74
+ /**
75
+ * Check whether an order type executes as a limit order.
76
+ *
77
+ * Covers plain limit orders and the `*_limit` trigger types, both of which
78
+ * require `OrderParams.price`.
79
+ *
80
+ * @param orderType - Order type to check.
81
+ * @returns True when the order executes as a limit order.
82
+ */
83
+ export function isLimitExecutionOrderType(orderType) {
84
+ return LIMIT_EXECUTION_ORDER_TYPES.includes(orderType);
85
+ }
86
+ /**
87
+ * Get how an order executes, ignoring whether it is trigger-gated.
88
+ *
89
+ * This is also the coarse execution type that consumers predating trigger orders
90
+ * understand (fee tiers, max order value, analytics). It answers "does this rest
91
+ * on the book or cross it", which is not the same question as
92
+ * `isLimitExecutionOrderType` — a scale ladder and a chase rest limit orders
93
+ * without carrying an `OrderParams.price`.
94
+ *
95
+ * @param orderType - Order type to inspect.
96
+ * @returns `'limit'` for limit, `*_limit`, `scale` and `chase`; `'market'`
97
+ * otherwise, including `twap`, whose suborders cross the book.
98
+ */
99
+ export function getTriggerExecution(orderType) {
100
+ return LIMIT_RESTING_ORDER_TYPES.includes(orderType)
101
+ ? 'limit'
102
+ : 'market';
103
+ }
104
+ /**
105
+ * Get the direction a trigger order fires in.
106
+ *
107
+ * @param orderType - Trigger order type.
108
+ * @returns `'stop'` for `stop_*`, `'take_profit'` for `take_profit_*`.
109
+ */
110
+ export function getTriggerDirection(orderType) {
111
+ return orderType === 'stop_market' || orderType === 'stop_limit'
112
+ ? 'stop'
113
+ : 'take_profit';
114
+ }
115
+ /**
116
+ * Recover which way a trigger fires from its price relative to the entry.
117
+ *
118
+ * Used when the exchange reports a trigger without naming its placement type:
119
+ * a long takes profit above its entry and stops out below, a short the other
120
+ * way round. Shared by both transports so they classify identically.
121
+ *
122
+ * @param params - Classification parameters
123
+ * @param params.triggerPrice - Price at which the order activates
124
+ * @param params.entryPrice - Entry price of the position it is attached to
125
+ * @param params.positionSize - Signed position size; its sign gives the side
126
+ * @returns The direction, or undefined when there is nothing to compare against
127
+ */
128
+ export function classifyTriggerDirection(params) {
129
+ const { triggerPrice, entryPrice, positionSize } = params;
130
+ const trigger = parseFloat(triggerPrice ?? '');
131
+ const entry = parseFloat(entryPrice ?? '');
132
+ const signedSize = parseFloat(positionSize || '0');
133
+ if (!Number.isFinite(trigger) || !Number.isFinite(entry) || entry <= 0) {
134
+ return undefined;
135
+ }
136
+ // A long takes profit above its entry and stops out below; a short is the
137
+ // mirror image. A trigger sitting exactly at entry is neither, so both sides
138
+ // fall to 'stop' — matching the legacy price fallback the scalar
139
+ // takeProfitPrice/stopLossPrice fields still use. Splitting that tie the
140
+ // other way would file the order under takeProfitOrders while the scalar
141
+ // still reported it as a stop.
142
+ const isLong = signedSize > 0;
143
+ if (isLong) {
144
+ return trigger > entry ? 'take_profit' : 'stop';
145
+ }
146
+ return trigger < entry ? 'take_profit' : 'stop';
147
+ }
148
+ /**
149
+ * Project a normalized open order onto the position-state view of a trigger order.
150
+ *
151
+ * Returns undefined when the order is not a trigger, or when its direction can
152
+ * be established neither from a named placement type nor from its price.
153
+ *
154
+ * @param params - Mapping parameters
155
+ * @param params.order - Normalized open order
156
+ * @param params.positionSize - Size of the position the trigger is attached to
157
+ * @param params.entryPrice - Entry price, used to classify an unnamed trigger
158
+ * @returns The position trigger order, or undefined
159
+ */
160
+ export function buildPositionTriggerOrderFromOrder(params) {
161
+ const { order, positionSize, entryPrice } = params;
162
+ if (!order.isTrigger) {
163
+ return undefined;
164
+ }
165
+ // HyperLiquid sometimes reports a bare 'Trigger', naming neither direction
166
+ // nor execution. The direction is still recoverable from the trigger price
167
+ // against the entry, and it is what decides which array the order belongs
168
+ // to — so an unnamed trigger is kept rather than dropped, with its execution
169
+ // mode left unstated. Without a position to compare against there is nothing
170
+ // to recover, and it is dropped.
171
+ const direction = order.triggerOrderType === undefined
172
+ ? classifyTriggerDirection({
173
+ triggerPrice: order.triggerPrice ?? order.price,
174
+ entryPrice,
175
+ positionSize,
176
+ })
177
+ : getTriggerDirection(order.triggerOrderType);
178
+ if (!direction) {
179
+ return undefined;
180
+ }
181
+ const absolutePositionSize = Math.abs(parseFloat(positionSize || '0'));
182
+ const rawSize = Math.abs(parseFloat(order.size || '0'));
183
+ // A position-bound TP/SL covers whatever the position currently is. The
184
+ // exchange encodes that as size 0, but `adaptOrderFromSDK` has already
185
+ // resolved it against the position as it stood when the order was adapted,
186
+ // so the size carried here goes stale as soon as the position is resized.
187
+ // The flag is the durable statement of what the trigger covers; the number
188
+ // is not. Reading the number instead would report the old size, and would
189
+ // call the order partial whenever the position had since grown.
190
+ const isPositionBound = order.isPositionTpsl === true;
191
+ const size = isPositionBound || rawSize === 0 ? absolutePositionSize : rawSize;
192
+ return {
193
+ orderId: order.orderId,
194
+ direction,
195
+ orderType: order.triggerOrderType,
196
+ triggerPrice: order.triggerPrice ?? order.price,
197
+ size: size.toString(),
198
+ isPartial: !isPositionBound &&
199
+ rawSize > 0 &&
200
+ absolutePositionSize > 0 &&
201
+ rawSize < absolutePositionSize,
202
+ reduceOnly: Boolean(order.reduceOnly),
203
+ };
204
+ }
205
+ /**
206
+ * Resolve the scalar TP/SL summary price a position reports for one direction.
207
+ *
208
+ * The scalar fields are only ever scanned from position-bound triggers, so a
209
+ * position whose only take profit (or stop loss) is quantity-scoped reported a
210
+ * count of 1 with no price — and a client that renders the scalar showed
211
+ * nothing. When the direction has exactly one trigger order, that order is the
212
+ * price, whether or not it is position-bound.
213
+ *
214
+ * Two or more triggers keep the scanned value: no single price describes them,
215
+ * and clients render the count instead. Zero triggers keep it too, because it
216
+ * still carries the TP/SL of a *pending* order on the market, which the arrays
217
+ * deliberately exclude.
218
+ *
219
+ * @param params - Resolution parameters
220
+ * @param params.triggerOrders - Trigger orders attached to the position for one direction
221
+ * @param params.scannedPrice - Price scanned from position-bound triggers, if any
222
+ * @returns The price to report, or undefined when there is none
223
+ */
224
+ export function resolvePositionTriggerSummaryPrice(params) {
225
+ const { triggerOrders, scannedPrice } = params;
226
+ if (triggerOrders.length === 1) {
227
+ return triggerOrders[0].triggerPrice;
228
+ }
229
+ return scannedPrice;
230
+ }
231
+ /**
232
+ * Build a trigger order type from its two independent dimensions.
233
+ *
234
+ * @param params - Trigger dimensions.
235
+ * @param params.direction - Whether the trigger is a stop or a take profit.
236
+ * @param params.execution - How the order executes once triggered.
237
+ * @returns The matching trigger order type.
238
+ */
239
+ export function buildTriggerOrderType(params) {
240
+ const { direction, execution } = params;
241
+ if (direction === 'stop') {
242
+ return execution === 'limit' ? 'stop_limit' : 'stop_market';
243
+ }
244
+ return execution === 'limit' ? 'take_profit_limit' : 'take_profit_market';
245
+ }
246
+ /**
247
+ * Map the controller's time in force onto the exchange's spelling.
248
+ *
249
+ * Shared by the two order-building paths so they cannot drift apart.
250
+ *
251
+ * @param timeInForce - Requested time in force; defaults to GTC.
252
+ * @returns The SDK time-in-force value.
253
+ */
254
+ export function toSDKTimeInForce(timeInForce) {
255
+ switch (timeInForce) {
256
+ case 'IOC':
257
+ return 'Ioc';
258
+ case 'ALO':
259
+ return 'Alo';
260
+ default:
261
+ return 'Gtc';
262
+ }
263
+ }
264
+ /**
265
+ * Hash the identity of a position's trigger orders for change detection.
266
+ *
267
+ * Streamed positions only re-emit when their hash changes, so this has to move
268
+ * when a trigger is added, removed, repriced, resized, or retyped — otherwise
269
+ * subscribers never receive the updated arrays.
270
+ *
271
+ * The placement type is part of the identity because a trigger can be modified
272
+ * in place: switching a stop from market to limit execution keeps its order ID,
273
+ * trigger price, and size, so nothing else here would move even though the
274
+ * execution semantics subscribers rely on have changed.
275
+ *
276
+ * @param orders - Trigger orders attached to a position, if any.
277
+ * @returns A stable string; `'0'` for both empty and absent.
278
+ */
279
+ export function hashTriggerOrders(orders) {
280
+ if (!orders || orders.length === 0) {
281
+ return '0';
282
+ }
283
+ return orders
284
+ .map((order) => `${order.orderId}:${order.direction}:${order.orderType ?? '?'}@${order.triggerPrice}x${order.size}${order.isPartial ? 'p' : ''}`)
285
+ .join(',');
286
+ }
287
+ //# sourceMappingURL=orderTypes.js.map