@metamask-previews/perps-controller 0.0.0-preview-ae46ab603 → 0.0.0-preview-e4aa1532

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (498) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/dist/PerpsController.cjs +2224 -66
  3. package/dist/PerpsController.cjs.map +1 -1
  4. package/dist/PerpsController.d.cts +933 -79
  5. package/dist/PerpsController.d.cts.map +1 -1
  6. package/dist/PerpsController.d.mts +933 -79
  7. package/dist/PerpsController.d.mts.map +1 -1
  8. package/dist/PerpsController.mjs +2221 -64
  9. package/dist/PerpsController.mjs.map +1 -1
  10. package/dist/__mocks__/hyperliquidMock.cjs +68 -0
  11. package/dist/__mocks__/hyperliquidMock.cjs.map +1 -0
  12. package/dist/__mocks__/hyperliquidMock.d.cts +15 -0
  13. package/dist/__mocks__/hyperliquidMock.d.cts.map +1 -0
  14. package/dist/__mocks__/hyperliquidMock.d.mts +15 -0
  15. package/dist/__mocks__/hyperliquidMock.d.mts.map +1 -0
  16. package/dist/__mocks__/hyperliquidMock.mjs +65 -0
  17. package/dist/__mocks__/hyperliquidMock.mjs.map +1 -0
  18. package/dist/__mocks__/providerMocks.cjs +144 -0
  19. package/dist/__mocks__/providerMocks.cjs.map +1 -0
  20. package/dist/__mocks__/providerMocks.d.cts +44 -0
  21. package/dist/__mocks__/providerMocks.d.cts.map +1 -0
  22. package/dist/__mocks__/providerMocks.d.mts +44 -0
  23. package/dist/__mocks__/providerMocks.d.mts.map +1 -0
  24. package/dist/__mocks__/providerMocks.mjs +136 -0
  25. package/dist/__mocks__/providerMocks.mjs.map +1 -0
  26. package/dist/__mocks__/serviceMocks.cjs +187 -0
  27. package/dist/__mocks__/serviceMocks.cjs.map +1 -0
  28. package/dist/__mocks__/serviceMocks.d.cts +58 -0
  29. package/dist/__mocks__/serviceMocks.d.cts.map +1 -0
  30. package/dist/__mocks__/serviceMocks.d.mts +58 -0
  31. package/dist/__mocks__/serviceMocks.d.mts.map +1 -0
  32. package/dist/__mocks__/serviceMocks.mjs +180 -0
  33. package/dist/__mocks__/serviceMocks.mjs.map +1 -0
  34. package/dist/aggregation/SubscriptionMultiplexer.cjs +459 -0
  35. package/dist/aggregation/SubscriptionMultiplexer.cjs.map +1 -0
  36. package/dist/aggregation/SubscriptionMultiplexer.d.cts +222 -0
  37. package/dist/aggregation/SubscriptionMultiplexer.d.cts.map +1 -0
  38. package/dist/aggregation/SubscriptionMultiplexer.d.mts +222 -0
  39. package/dist/aggregation/SubscriptionMultiplexer.d.mts.map +1 -0
  40. package/dist/aggregation/SubscriptionMultiplexer.mjs +455 -0
  41. package/dist/aggregation/SubscriptionMultiplexer.mjs.map +1 -0
  42. package/dist/aggregation/index.cjs +9 -0
  43. package/dist/aggregation/index.cjs.map +1 -0
  44. package/dist/aggregation/index.d.cts +6 -0
  45. package/dist/aggregation/index.d.cts.map +1 -0
  46. package/dist/aggregation/index.d.mts +6 -0
  47. package/dist/aggregation/index.d.mts.map +1 -0
  48. package/dist/aggregation/index.mjs +5 -0
  49. package/dist/aggregation/index.mjs.map +1 -0
  50. package/dist/constants/eventNames.cjs +117 -0
  51. package/dist/constants/eventNames.cjs.map +1 -0
  52. package/dist/constants/eventNames.d.cts +106 -0
  53. package/dist/constants/eventNames.d.cts.map +1 -0
  54. package/dist/constants/eventNames.d.mts +106 -0
  55. package/dist/constants/eventNames.d.mts.map +1 -0
  56. package/dist/constants/eventNames.mjs +114 -0
  57. package/dist/constants/eventNames.mjs.map +1 -0
  58. package/dist/constants/hyperLiquidConfig.cjs +366 -0
  59. package/dist/constants/hyperLiquidConfig.cjs.map +1 -0
  60. package/dist/constants/hyperLiquidConfig.d.cts +276 -0
  61. package/dist/constants/hyperLiquidConfig.d.cts.map +1 -0
  62. package/dist/constants/hyperLiquidConfig.d.mts +276 -0
  63. package/dist/constants/hyperLiquidConfig.d.mts.map +1 -0
  64. package/dist/constants/hyperLiquidConfig.mjs +357 -0
  65. package/dist/constants/hyperLiquidConfig.mjs.map +1 -0
  66. package/dist/constants/index.cjs +23 -0
  67. package/dist/constants/index.cjs.map +1 -0
  68. package/dist/constants/index.d.cts +7 -0
  69. package/dist/constants/index.d.cts.map +1 -0
  70. package/dist/constants/index.d.mts +7 -0
  71. package/dist/constants/index.d.mts.map +1 -0
  72. package/dist/constants/index.mjs +7 -0
  73. package/dist/constants/index.mjs.map +1 -0
  74. package/dist/constants/orderTypes.cjs +31 -0
  75. package/dist/constants/orderTypes.cjs.map +1 -0
  76. package/dist/constants/orderTypes.d.cts +19 -0
  77. package/dist/constants/orderTypes.d.cts.map +1 -0
  78. package/dist/constants/orderTypes.d.mts +19 -0
  79. package/dist/constants/orderTypes.d.mts.map +1 -0
  80. package/dist/constants/orderTypes.mjs +27 -0
  81. package/dist/constants/orderTypes.mjs.map +1 -0
  82. package/dist/constants/performanceMetrics.cjs +61 -0
  83. package/dist/constants/performanceMetrics.cjs.map +1 -0
  84. package/dist/constants/performanceMetrics.d.cts +44 -0
  85. package/dist/constants/performanceMetrics.d.cts.map +1 -0
  86. package/dist/constants/performanceMetrics.d.mts +44 -0
  87. package/dist/constants/performanceMetrics.d.mts.map +1 -0
  88. package/dist/constants/performanceMetrics.mjs +58 -0
  89. package/dist/constants/performanceMetrics.mjs.map +1 -0
  90. package/dist/constants/perpsConfig.cjs +461 -0
  91. package/dist/constants/perpsConfig.cjs.map +1 -0
  92. package/dist/constants/perpsConfig.d.cts +343 -0
  93. package/dist/constants/perpsConfig.d.cts.map +1 -0
  94. package/dist/constants/perpsConfig.d.mts +343 -0
  95. package/dist/constants/perpsConfig.d.mts.map +1 -0
  96. package/dist/constants/perpsConfig.mjs +458 -0
  97. package/dist/constants/perpsConfig.mjs.map +1 -0
  98. package/dist/constants/perpsErrorCodes.cjs +79 -0
  99. package/dist/constants/perpsErrorCodes.cjs.map +1 -0
  100. package/dist/constants/perpsErrorCodes.d.cts +64 -0
  101. package/dist/constants/perpsErrorCodes.d.cts.map +1 -0
  102. package/dist/constants/perpsErrorCodes.d.mts +64 -0
  103. package/dist/constants/perpsErrorCodes.d.mts.map +1 -0
  104. package/dist/constants/perpsErrorCodes.mjs +76 -0
  105. package/dist/constants/perpsErrorCodes.mjs.map +1 -0
  106. package/dist/index.cjs +32 -1
  107. package/dist/index.cjs.map +1 -1
  108. package/dist/index.d.cts +6 -2
  109. package/dist/index.d.cts.map +1 -1
  110. package/dist/index.d.mts +6 -2
  111. package/dist/index.d.mts.map +1 -1
  112. package/dist/index.mjs +9 -1
  113. package/dist/index.mjs.map +1 -1
  114. package/dist/platform-services/HyperLiquidClientService.cjs +857 -0
  115. package/dist/platform-services/HyperLiquidClientService.cjs.map +1 -0
  116. package/dist/platform-services/HyperLiquidClientService.d.cts +263 -0
  117. package/dist/platform-services/HyperLiquidClientService.d.cts.map +1 -0
  118. package/dist/platform-services/HyperLiquidClientService.d.mts +263 -0
  119. package/dist/platform-services/HyperLiquidClientService.d.mts.map +1 -0
  120. package/dist/platform-services/HyperLiquidClientService.mjs +853 -0
  121. package/dist/platform-services/HyperLiquidClientService.mjs.map +1 -0
  122. package/dist/platform-services/HyperLiquidSubscriptionService.cjs +2170 -0
  123. package/dist/platform-services/HyperLiquidSubscriptionService.cjs.map +1 -0
  124. package/dist/platform-services/HyperLiquidSubscriptionService.d.cts +424 -0
  125. package/dist/platform-services/HyperLiquidSubscriptionService.d.cts.map +1 -0
  126. package/dist/platform-services/HyperLiquidSubscriptionService.d.mts +424 -0
  127. package/dist/platform-services/HyperLiquidSubscriptionService.d.mts.map +1 -0
  128. package/dist/platform-services/HyperLiquidSubscriptionService.mjs +2166 -0
  129. package/dist/platform-services/HyperLiquidSubscriptionService.mjs.map +1 -0
  130. package/dist/platform-services/HyperLiquidWalletService.cjs +140 -0
  131. package/dist/platform-services/HyperLiquidWalletService.cjs.map +1 -0
  132. package/dist/platform-services/HyperLiquidWalletService.d.cts +78 -0
  133. package/dist/platform-services/HyperLiquidWalletService.d.cts.map +1 -0
  134. package/dist/platform-services/HyperLiquidWalletService.d.mts +78 -0
  135. package/dist/platform-services/HyperLiquidWalletService.d.mts.map +1 -0
  136. package/dist/platform-services/HyperLiquidWalletService.mjs +136 -0
  137. package/dist/platform-services/HyperLiquidWalletService.mjs.map +1 -0
  138. package/dist/providers/AggregatedPerpsProvider.cjs +777 -0
  139. package/dist/providers/AggregatedPerpsProvider.cjs.map +1 -0
  140. package/dist/providers/AggregatedPerpsProvider.d.cts +466 -0
  141. package/dist/providers/AggregatedPerpsProvider.d.cts.map +1 -0
  142. package/dist/providers/AggregatedPerpsProvider.d.mts +466 -0
  143. package/dist/providers/AggregatedPerpsProvider.d.mts.map +1 -0
  144. package/dist/providers/AggregatedPerpsProvider.mjs +773 -0
  145. package/dist/providers/AggregatedPerpsProvider.mjs.map +1 -0
  146. package/dist/providers/HyperLiquidProvider.cjs +5172 -0
  147. package/dist/providers/HyperLiquidProvider.cjs.map +1 -0
  148. package/dist/providers/HyperLiquidProvider.d.cts +881 -0
  149. package/dist/providers/HyperLiquidProvider.d.cts.map +1 -0
  150. package/dist/providers/HyperLiquidProvider.d.mts +881 -0
  151. package/dist/providers/HyperLiquidProvider.d.mts.map +1 -0
  152. package/dist/providers/HyperLiquidProvider.mjs +5168 -0
  153. package/dist/providers/HyperLiquidProvider.mjs.map +1 -0
  154. package/dist/providers/index.cjs +11 -0
  155. package/dist/providers/index.cjs.map +1 -0
  156. package/dist/providers/index.d.cts +6 -0
  157. package/dist/providers/index.d.cts.map +1 -0
  158. package/dist/providers/index.d.mts +6 -0
  159. package/dist/providers/index.d.mts.map +1 -0
  160. package/dist/providers/index.mjs +6 -0
  161. package/dist/providers/index.mjs.map +1 -0
  162. package/dist/routing/ProviderRouter.cjs +148 -0
  163. package/dist/routing/ProviderRouter.cjs.map +1 -0
  164. package/dist/routing/ProviderRouter.d.cts +124 -0
  165. package/dist/routing/ProviderRouter.d.cts.map +1 -0
  166. package/dist/routing/ProviderRouter.d.mts +124 -0
  167. package/dist/routing/ProviderRouter.d.mts.map +1 -0
  168. package/dist/routing/ProviderRouter.mjs +144 -0
  169. package/dist/routing/ProviderRouter.mjs.map +1 -0
  170. package/dist/routing/index.cjs +9 -0
  171. package/dist/routing/index.cjs.map +1 -0
  172. package/dist/routing/index.d.cts +6 -0
  173. package/dist/routing/index.d.cts.map +1 -0
  174. package/dist/routing/index.d.mts +6 -0
  175. package/dist/routing/index.d.mts.map +1 -0
  176. package/dist/routing/index.mjs +5 -0
  177. package/dist/routing/index.mjs.map +1 -0
  178. package/dist/selectors.cjs +161 -0
  179. package/dist/selectors.cjs.map +1 -0
  180. package/dist/selectors.d.cts +345 -0
  181. package/dist/selectors.d.cts.map +1 -0
  182. package/dist/selectors.d.mts +345 -0
  183. package/dist/selectors.d.mts.map +1 -0
  184. package/dist/selectors.mjs +153 -0
  185. package/dist/selectors.mjs.map +1 -0
  186. package/dist/services/AccountService.cjs +313 -0
  187. package/dist/services/AccountService.cjs.map +1 -0
  188. package/dist/services/AccountService.d.cts +53 -0
  189. package/dist/services/AccountService.d.cts.map +1 -0
  190. package/dist/services/AccountService.d.mts +53 -0
  191. package/dist/services/AccountService.d.mts.map +1 -0
  192. package/dist/services/AccountService.mjs +309 -0
  193. package/dist/services/AccountService.mjs.map +1 -0
  194. package/dist/services/DataLakeService.cjs +219 -0
  195. package/dist/services/DataLakeService.cjs.map +1 -0
  196. package/dist/services/DataLakeService.d.cts +49 -0
  197. package/dist/services/DataLakeService.d.cts.map +1 -0
  198. package/dist/services/DataLakeService.d.mts +49 -0
  199. package/dist/services/DataLakeService.d.mts.map +1 -0
  200. package/dist/services/DataLakeService.mjs +215 -0
  201. package/dist/services/DataLakeService.mjs.map +1 -0
  202. package/dist/services/DepositService.cjs +96 -0
  203. package/dist/services/DepositService.cjs.map +1 -0
  204. package/dist/services/DepositService.d.cts +37 -0
  205. package/dist/services/DepositService.d.cts.map +1 -0
  206. package/dist/services/DepositService.d.mts +37 -0
  207. package/dist/services/DepositService.d.mts.map +1 -0
  208. package/dist/services/DepositService.mjs +92 -0
  209. package/dist/services/DepositService.mjs.map +1 -0
  210. package/dist/services/EligibilityService.cjs +156 -0
  211. package/dist/services/EligibilityService.cjs.map +1 -0
  212. package/dist/services/EligibilityService.d.cts +48 -0
  213. package/dist/services/EligibilityService.d.cts.map +1 -0
  214. package/dist/services/EligibilityService.d.mts +48 -0
  215. package/dist/services/EligibilityService.d.mts.map +1 -0
  216. package/dist/services/EligibilityService.mjs +152 -0
  217. package/dist/services/EligibilityService.mjs.map +1 -0
  218. package/dist/services/FeatureFlagConfigurationService.cjs +258 -0
  219. package/dist/services/FeatureFlagConfigurationService.cjs.map +1 -0
  220. package/dist/services/FeatureFlagConfigurationService.d.cts +100 -0
  221. package/dist/services/FeatureFlagConfigurationService.d.cts.map +1 -0
  222. package/dist/services/FeatureFlagConfigurationService.d.mts +100 -0
  223. package/dist/services/FeatureFlagConfigurationService.d.mts.map +1 -0
  224. package/dist/services/FeatureFlagConfigurationService.mjs +254 -0
  225. package/dist/services/FeatureFlagConfigurationService.mjs.map +1 -0
  226. package/dist/services/MarketDataService.cjs +875 -0
  227. package/dist/services/MarketDataService.cjs.map +1 -0
  228. package/dist/services/MarketDataService.d.cts +289 -0
  229. package/dist/services/MarketDataService.d.cts.map +1 -0
  230. package/dist/services/MarketDataService.d.mts +289 -0
  231. package/dist/services/MarketDataService.d.mts.map +1 -0
  232. package/dist/services/MarketDataService.mjs +871 -0
  233. package/dist/services/MarketDataService.mjs.map +1 -0
  234. package/dist/services/RewardsIntegrationService.cjs +94 -0
  235. package/dist/services/RewardsIntegrationService.cjs.map +1 -0
  236. package/dist/services/RewardsIntegrationService.d.cts +30 -0
  237. package/dist/services/RewardsIntegrationService.d.cts.map +1 -0
  238. package/dist/services/RewardsIntegrationService.d.mts +30 -0
  239. package/dist/services/RewardsIntegrationService.d.mts.map +1 -0
  240. package/dist/services/RewardsIntegrationService.mjs +90 -0
  241. package/dist/services/RewardsIntegrationService.mjs.map +1 -0
  242. package/dist/services/ServiceContext.cjs +3 -0
  243. package/dist/services/ServiceContext.cjs.map +1 -0
  244. package/dist/services/ServiceContext.d.cts +110 -0
  245. package/dist/services/ServiceContext.d.cts.map +1 -0
  246. package/dist/services/ServiceContext.d.mts +110 -0
  247. package/dist/services/ServiceContext.d.mts.map +1 -0
  248. package/dist/services/ServiceContext.mjs +2 -0
  249. package/dist/services/ServiceContext.mjs.map +1 -0
  250. package/dist/services/TradingService.cjs +1481 -0
  251. package/dist/services/TradingService.cjs.map +1 -0
  252. package/dist/services/TradingService.d.cts +308 -0
  253. package/dist/services/TradingService.d.cts.map +1 -0
  254. package/dist/services/TradingService.d.mts +308 -0
  255. package/dist/services/TradingService.d.mts.map +1 -0
  256. package/dist/services/TradingService.mjs +1477 -0
  257. package/dist/services/TradingService.mjs.map +1 -0
  258. package/dist/services/index.cjs +26 -0
  259. package/dist/services/index.cjs.map +1 -0
  260. package/dist/services/index.d.cts +11 -0
  261. package/dist/services/index.d.cts.map +1 -0
  262. package/dist/services/index.d.mts +11 -0
  263. package/dist/services/index.d.mts.map +1 -0
  264. package/dist/services/index.mjs +10 -0
  265. package/dist/services/index.mjs.map +1 -0
  266. package/dist/services/utils.cjs +16 -0
  267. package/dist/services/utils.cjs.map +1 -0
  268. package/dist/services/utils.d.cts +8 -0
  269. package/dist/services/utils.d.cts.map +1 -0
  270. package/dist/services/utils.d.mts +8 -0
  271. package/dist/services/utils.d.mts.map +1 -0
  272. package/dist/services/utils.mjs +12 -0
  273. package/dist/services/utils.mjs.map +1 -0
  274. package/dist/types/chart.cjs +42 -0
  275. package/dist/types/chart.cjs.map +1 -0
  276. package/dist/types/chart.d.cts +62 -0
  277. package/dist/types/chart.d.cts.map +1 -0
  278. package/dist/types/chart.d.mts +62 -0
  279. package/dist/types/chart.d.mts.map +1 -0
  280. package/dist/types/chart.mjs +39 -0
  281. package/dist/types/chart.mjs.map +1 -0
  282. package/dist/types/hyperliquid-types.cjs +3 -0
  283. package/dist/types/hyperliquid-types.cjs.map +1 -0
  284. package/dist/types/hyperliquid-types.d.cts +52 -0
  285. package/dist/types/hyperliquid-types.d.cts.map +1 -0
  286. package/dist/types/hyperliquid-types.d.mts +52 -0
  287. package/dist/types/hyperliquid-types.d.mts.map +1 -0
  288. package/dist/types/hyperliquid-types.mjs +2 -0
  289. package/dist/types/hyperliquid-types.mjs.map +1 -0
  290. package/dist/types/index.cjs +96 -0
  291. package/dist/types/index.cjs.map +1 -0
  292. package/dist/types/index.d.cts +1153 -0
  293. package/dist/types/index.d.cts.map +1 -0
  294. package/dist/types/index.d.mts +1153 -0
  295. package/dist/types/index.d.mts.map +1 -0
  296. package/dist/types/index.mjs +79 -0
  297. package/dist/types/index.mjs.map +1 -0
  298. package/dist/types/transactionTypes.cjs +28 -0
  299. package/dist/types/transactionTypes.cjs.map +1 -0
  300. package/dist/types/transactionTypes.d.cts +64 -0
  301. package/dist/types/transactionTypes.d.cts.map +1 -0
  302. package/dist/types/transactionTypes.d.mts +64 -0
  303. package/dist/types/transactionTypes.d.mts.map +1 -0
  304. package/dist/types/transactionTypes.mjs +23 -0
  305. package/dist/types/transactionTypes.mjs.map +1 -0
  306. package/dist/utils/accountUtils.cjs +65 -0
  307. package/dist/utils/accountUtils.cjs.map +1 -0
  308. package/dist/utils/accountUtils.d.cts +26 -0
  309. package/dist/utils/accountUtils.d.cts.map +1 -0
  310. package/dist/utils/accountUtils.d.mts +26 -0
  311. package/dist/utils/accountUtils.d.mts.map +1 -0
  312. package/dist/utils/accountUtils.mjs +61 -0
  313. package/dist/utils/accountUtils.mjs.map +1 -0
  314. package/dist/utils/amountConversion.cjs +61 -0
  315. package/dist/utils/amountConversion.cjs.map +1 -0
  316. package/dist/utils/amountConversion.d.cts +16 -0
  317. package/dist/utils/amountConversion.d.cts.map +1 -0
  318. package/dist/utils/amountConversion.d.mts +16 -0
  319. package/dist/utils/amountConversion.d.mts.map +1 -0
  320. package/dist/utils/amountConversion.mjs +54 -0
  321. package/dist/utils/amountConversion.mjs.map +1 -0
  322. package/dist/utils/chartUtils.cjs +98 -0
  323. package/dist/utils/chartUtils.cjs.map +1 -0
  324. package/dist/utils/chartUtils.d.cts +14 -0
  325. package/dist/utils/chartUtils.d.cts.map +1 -0
  326. package/dist/utils/chartUtils.d.mts +14 -0
  327. package/dist/utils/chartUtils.d.mts.map +1 -0
  328. package/dist/utils/chartUtils.mjs +94 -0
  329. package/dist/utils/chartUtils.mjs.map +1 -0
  330. package/dist/utils/errorUtils.cjs +22 -0
  331. package/dist/utils/errorUtils.cjs.map +1 -0
  332. package/dist/utils/errorUtils.d.cts +13 -0
  333. package/dist/utils/errorUtils.d.cts.map +1 -0
  334. package/dist/utils/errorUtils.d.mts +13 -0
  335. package/dist/utils/errorUtils.d.mts.map +1 -0
  336. package/dist/utils/errorUtils.mjs +18 -0
  337. package/dist/utils/errorUtils.mjs.map +1 -0
  338. package/dist/utils/formatUtils.cjs +987 -0
  339. package/dist/utils/formatUtils.cjs.map +1 -0
  340. package/dist/utils/formatUtils.d.cts +387 -0
  341. package/dist/utils/formatUtils.d.cts.map +1 -0
  342. package/dist/utils/formatUtils.d.mts +387 -0
  343. package/dist/utils/formatUtils.d.mts.map +1 -0
  344. package/dist/utils/formatUtils.mjs +966 -0
  345. package/dist/utils/formatUtils.mjs.map +1 -0
  346. package/dist/utils/hyperLiquidAdapter.cjs +454 -0
  347. package/dist/utils/hyperLiquidAdapter.cjs.map +1 -0
  348. package/dist/utils/hyperLiquidAdapter.d.cts +158 -0
  349. package/dist/utils/hyperLiquidAdapter.d.cts.map +1 -0
  350. package/dist/utils/hyperLiquidAdapter.d.mts +158 -0
  351. package/dist/utils/hyperLiquidAdapter.d.mts.map +1 -0
  352. package/dist/utils/hyperLiquidAdapter.mjs +439 -0
  353. package/dist/utils/hyperLiquidAdapter.mjs.map +1 -0
  354. package/dist/utils/hyperLiquidOrderBookProcessor.cjs +89 -0
  355. package/dist/utils/hyperLiquidOrderBookProcessor.cjs.map +1 -0
  356. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts +58 -0
  357. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts.map +1 -0
  358. package/dist/utils/hyperLiquidOrderBookProcessor.d.mts +58 -0
  359. package/dist/utils/hyperLiquidOrderBookProcessor.d.mts.map +1 -0
  360. package/dist/utils/hyperLiquidOrderBookProcessor.mjs +84 -0
  361. package/dist/utils/hyperLiquidOrderBookProcessor.mjs.map +1 -0
  362. package/dist/utils/hyperLiquidValidation.cjs +426 -0
  363. package/dist/utils/hyperLiquidValidation.cjs.map +1 -0
  364. package/dist/utils/hyperLiquidValidation.d.cts +143 -0
  365. package/dist/utils/hyperLiquidValidation.d.cts.map +1 -0
  366. package/dist/utils/hyperLiquidValidation.d.mts +143 -0
  367. package/dist/utils/hyperLiquidValidation.d.mts.map +1 -0
  368. package/dist/utils/hyperLiquidValidation.mjs +413 -0
  369. package/dist/utils/hyperLiquidValidation.mjs.map +1 -0
  370. package/dist/utils/idUtils.cjs +50 -0
  371. package/dist/utils/idUtils.cjs.map +1 -0
  372. package/dist/utils/idUtils.d.cts +38 -0
  373. package/dist/utils/idUtils.d.cts.map +1 -0
  374. package/dist/utils/idUtils.d.mts +38 -0
  375. package/dist/utils/idUtils.d.mts.map +1 -0
  376. package/dist/utils/idUtils.mjs +42 -0
  377. package/dist/utils/idUtils.mjs.map +1 -0
  378. package/dist/utils/marginUtils.cjs +137 -0
  379. package/dist/utils/marginUtils.cjs.map +1 -0
  380. package/dist/utils/marginUtils.d.cts +64 -0
  381. package/dist/utils/marginUtils.d.cts.map +1 -0
  382. package/dist/utils/marginUtils.d.mts +64 -0
  383. package/dist/utils/marginUtils.d.mts.map +1 -0
  384. package/dist/utils/marginUtils.mjs +131 -0
  385. package/dist/utils/marginUtils.mjs.map +1 -0
  386. package/dist/utils/marketDataTransform.cjs +227 -0
  387. package/dist/utils/marketDataTransform.cjs.map +1 -0
  388. package/dist/utils/marketDataTransform.d.cts +45 -0
  389. package/dist/utils/marketDataTransform.d.cts.map +1 -0
  390. package/dist/utils/marketDataTransform.d.mts +45 -0
  391. package/dist/utils/marketDataTransform.d.mts.map +1 -0
  392. package/dist/utils/marketDataTransform.mjs +220 -0
  393. package/dist/utils/marketDataTransform.mjs.map +1 -0
  394. package/dist/utils/marketUtils.cjs +420 -0
  395. package/dist/utils/marketUtils.cjs.map +1 -0
  396. package/dist/utils/marketUtils.d.cts +227 -0
  397. package/dist/utils/marketUtils.d.cts.map +1 -0
  398. package/dist/utils/marketUtils.d.mts +227 -0
  399. package/dist/utils/marketUtils.d.mts.map +1 -0
  400. package/dist/utils/marketUtils.mjs +404 -0
  401. package/dist/utils/marketUtils.mjs.map +1 -0
  402. package/dist/utils/orderBookGrouping.cjs +151 -0
  403. package/dist/utils/orderBookGrouping.cjs.map +1 -0
  404. package/dist/utils/orderBookGrouping.d.cts +76 -0
  405. package/dist/utils/orderBookGrouping.d.cts.map +1 -0
  406. package/dist/utils/orderBookGrouping.d.mts +76 -0
  407. package/dist/utils/orderBookGrouping.d.mts.map +1 -0
  408. package/dist/utils/orderBookGrouping.mjs +143 -0
  409. package/dist/utils/orderBookGrouping.mjs.map +1 -0
  410. package/dist/utils/orderCalculations.cjs +283 -0
  411. package/dist/utils/orderCalculations.cjs.map +1 -0
  412. package/dist/utils/orderCalculations.d.cts +107 -0
  413. package/dist/utils/orderCalculations.d.cts.map +1 -0
  414. package/dist/utils/orderCalculations.d.mts +107 -0
  415. package/dist/utils/orderCalculations.d.mts.map +1 -0
  416. package/dist/utils/orderCalculations.mjs +274 -0
  417. package/dist/utils/orderCalculations.mjs.map +1 -0
  418. package/dist/utils/orderUtils.cjs +159 -0
  419. package/dist/utils/orderUtils.cjs.map +1 -0
  420. package/dist/utils/orderUtils.d.cts +66 -0
  421. package/dist/utils/orderUtils.d.cts.map +1 -0
  422. package/dist/utils/orderUtils.d.mts +66 -0
  423. package/dist/utils/orderUtils.d.mts.map +1 -0
  424. package/dist/utils/orderUtils.mjs +151 -0
  425. package/dist/utils/orderUtils.mjs.map +1 -0
  426. package/dist/utils/pnlCalculations.cjs +107 -0
  427. package/dist/utils/pnlCalculations.cjs.map +1 -0
  428. package/dist/utils/pnlCalculations.d.cts +79 -0
  429. package/dist/utils/pnlCalculations.d.cts.map +1 -0
  430. package/dist/utils/pnlCalculations.d.mts +79 -0
  431. package/dist/utils/pnlCalculations.d.mts.map +1 -0
  432. package/dist/utils/pnlCalculations.mjs +97 -0
  433. package/dist/utils/pnlCalculations.mjs.map +1 -0
  434. package/dist/utils/positionCalculations.cjs +176 -0
  435. package/dist/utils/positionCalculations.cjs.map +1 -0
  436. package/dist/utils/positionCalculations.d.cts +85 -0
  437. package/dist/utils/positionCalculations.d.cts.map +1 -0
  438. package/dist/utils/positionCalculations.d.mts +85 -0
  439. package/dist/utils/positionCalculations.d.mts.map +1 -0
  440. package/dist/utils/positionCalculations.mjs +165 -0
  441. package/dist/utils/positionCalculations.mjs.map +1 -0
  442. package/dist/utils/sortMarkets.cjs +88 -0
  443. package/dist/utils/sortMarkets.cjs.map +1 -0
  444. package/dist/utils/sortMarkets.d.cts +21 -0
  445. package/dist/utils/sortMarkets.d.cts.map +1 -0
  446. package/dist/utils/sortMarkets.d.mts +21 -0
  447. package/dist/utils/sortMarkets.d.mts.map +1 -0
  448. package/dist/utils/sortMarkets.mjs +84 -0
  449. package/dist/utils/sortMarkets.mjs.map +1 -0
  450. package/dist/utils/standaloneInfoClient.cjs +34 -0
  451. package/dist/utils/standaloneInfoClient.cjs.map +1 -0
  452. package/dist/utils/standaloneInfoClient.d.cts +31 -0
  453. package/dist/utils/standaloneInfoClient.d.cts.map +1 -0
  454. package/dist/utils/standaloneInfoClient.d.mts +31 -0
  455. package/dist/utils/standaloneInfoClient.d.mts.map +1 -0
  456. package/dist/utils/standaloneInfoClient.mjs +30 -0
  457. package/dist/utils/standaloneInfoClient.mjs.map +1 -0
  458. package/dist/utils/stringParseUtils.cjs +49 -0
  459. package/dist/utils/stringParseUtils.cjs.map +1 -0
  460. package/dist/utils/stringParseUtils.d.cts +35 -0
  461. package/dist/utils/stringParseUtils.d.cts.map +1 -0
  462. package/dist/utils/stringParseUtils.d.mts +35 -0
  463. package/dist/utils/stringParseUtils.d.mts.map +1 -0
  464. package/dist/utils/stringParseUtils.mjs +44 -0
  465. package/dist/utils/stringParseUtils.mjs.map +1 -0
  466. package/dist/utils/time.cjs +37 -0
  467. package/dist/utils/time.cjs.map +1 -0
  468. package/dist/utils/time.d.cts +17 -0
  469. package/dist/utils/time.d.cts.map +1 -0
  470. package/dist/utils/time.d.mts +17 -0
  471. package/dist/utils/time.d.mts.map +1 -0
  472. package/dist/utils/time.mjs +33 -0
  473. package/dist/utils/time.mjs.map +1 -0
  474. package/dist/utils/tpslValidation.cjs +505 -0
  475. package/dist/utils/tpslValidation.cjs.map +1 -0
  476. package/dist/utils/tpslValidation.d.cts +182 -0
  477. package/dist/utils/tpslValidation.d.cts.map +1 -0
  478. package/dist/utils/tpslValidation.d.mts +182 -0
  479. package/dist/utils/tpslValidation.d.mts.map +1 -0
  480. package/dist/utils/tpslValidation.mjs +482 -0
  481. package/dist/utils/tpslValidation.mjs.map +1 -0
  482. package/dist/utils/transactionUtils.cjs +36 -0
  483. package/dist/utils/transactionUtils.cjs.map +1 -0
  484. package/dist/utils/transactionUtils.d.cts +17 -0
  485. package/dist/utils/transactionUtils.d.cts.map +1 -0
  486. package/dist/utils/transactionUtils.d.mts +17 -0
  487. package/dist/utils/transactionUtils.d.mts.map +1 -0
  488. package/dist/utils/transactionUtils.mjs +32 -0
  489. package/dist/utils/transactionUtils.mjs.map +1 -0
  490. package/dist/utils/wait.cjs +12 -0
  491. package/dist/utils/wait.cjs.map +1 -0
  492. package/dist/utils/wait.d.cts +8 -0
  493. package/dist/utils/wait.d.cts.map +1 -0
  494. package/dist/utils/wait.d.mts +8 -0
  495. package/dist/utils/wait.d.mts.map +1 -0
  496. package/dist/utils/wait.mjs +8 -0
  497. package/dist/utils/wait.mjs.map +1 -0
  498. package/package.json +19 -4
@@ -0,0 +1,387 @@
1
+ /**
2
+ * Price threshold constants for PRICE_RANGES_UNIVERSAL
3
+ * These define the boundaries between different formatting ranges
4
+ */
5
+ export declare const PRICE_THRESHOLD: {
6
+ /** Very high values boundary (> $100k) */
7
+ readonly VERY_HIGH: 100000;
8
+ /** High values boundary (> $10k) */
9
+ readonly HIGH: 10000;
10
+ /** Large values boundary (> $1k) */
11
+ readonly LARGE: 1000;
12
+ /** Medium values boundary (> $100) */
13
+ readonly MEDIUM: 100;
14
+ /** Medium-low values boundary (> $10) */
15
+ readonly MEDIUM_LOW: 10;
16
+ /** Low values boundary (>= $0.01) */
17
+ readonly LOW: 0.01;
18
+ /**
19
+ * Very small values threshold (< $0.01)
20
+ * This is the minimum value for formatWithThreshold and should align with
21
+ * the 6 decimal maximum (0.000001 is the smallest representable value)
22
+ */
23
+ readonly VERY_SMALL: 0.000001;
24
+ };
25
+ /**
26
+ * Configuration for a specific number range formatting
27
+ */
28
+ export type FiatRangeConfig = {
29
+ /**
30
+ * The condition to match for this range (e.g., < 0.0001, < 1, >= 1000)
31
+ * Function should return true if this config should be applied
32
+ */
33
+ condition: (value: number) => boolean;
34
+ /** Minimum decimal places for this range */
35
+ minimumDecimals: number;
36
+ /** Maximum decimal places for this range */
37
+ maximumDecimals: number;
38
+ /** Optional threshold for formatWithThreshold (defaults to the range boundary) */
39
+ threshold?: number;
40
+ /** Optional significant digits for this range (overrides decimal places when set) */
41
+ significantDigits?: number;
42
+ /** Optional custom formatting logic for this range */
43
+ customFormat?: (value: number, locale: string, currency: string) => string;
44
+ /** Optional flag to strip trailing zeros for this range (overrides global stripTrailingZeros option) */
45
+ stripTrailingZeros?: boolean;
46
+ /**
47
+ * Optional flag for fiat-style stripping (only strips .00, preserves meaningful decimals like .10, .40)
48
+ * When true, "$1,250.00" becomes "$1,250" but "$1,250.10" stays "$1,250.10"
49
+ * When false (default), strips all trailing zeros: "$1,250.10" becomes "$1,250.1"
50
+ */
51
+ fiatStyleStripping?: boolean;
52
+ };
53
+ /**
54
+ * Formats a number to a specific number of significant digits
55
+ * Strips trailing zeros unless minDecimals requires them
56
+ *
57
+ * @param value - The numeric value to format
58
+ * @param significantDigits - Number of significant digits to maintain
59
+ * @param minDecimals - Minimum decimal places to show (may add zeros)
60
+ * @param maxDecimals - Maximum decimal places allowed
61
+ * @returns Formatted number with appropriate precision, trailing zeros removed
62
+ */
63
+ export declare function formatWithSignificantDigits(value: number, significantDigits: number, minDecimals?: number, maxDecimals?: number): {
64
+ value: number;
65
+ decimals: number;
66
+ };
67
+ /**
68
+ * Counts the number of significant figures in a numeric string
69
+ * This matches HyperLiquid's validation rules:
70
+ * - Trailing decimal zeros are trimmed first (via parseFloat().toString())
71
+ * - Count non-zero integer digits (without leading zeros)
72
+ * - Count ALL decimal digits (including leading zeros after decimal point)
73
+ *
74
+ * @param priceString - The price value as a string (may include $ or ,)
75
+ * @returns The count of significant figures
76
+ *
77
+ * @example
78
+ * countSignificantFigures('123.45') // 5 (3 integer + 2 decimal)
79
+ * countSignificantFigures('123.4500') // 5 (trailing zeros trimmed first)
80
+ * countSignificantFigures('0.000123') // 6 (0 integer + 6 decimal)
81
+ * countSignificantFigures('12.345') // 5 (2 integer + 3 decimal)
82
+ * countSignificantFigures('12000') // 2 (trailing zeros in integer not counted)
83
+ */
84
+ export declare const countSignificantFigures: (priceString: string) => number;
85
+ /**
86
+ * Checks if a price will be rounded due to exceeding significant figures
87
+ * Only applies when the price has decimals - integers are never rounded
88
+ * This matches the behavior in formatHyperLiquidPrice
89
+ *
90
+ * @param priceString - The price value as a string
91
+ * @param maxSigFigs - Maximum allowed significant figures (default: MAX_SIGNIFICANT_FIGURES from config)
92
+ * @returns true if the price will be rounded, false otherwise
93
+ */
94
+ export declare const hasExceededSignificantFigures: (priceString: string, maxSigFigs?: number) => boolean;
95
+ /**
96
+ * Rounds a price string to the maximum allowed significant figures
97
+ * Uses the same counting logic as countSignificantFigures:
98
+ * - Count non-zero integer digits + ALL decimal digits (including leading zeros)
99
+ *
100
+ * @param priceString - The price value as a string
101
+ * @param maxSigFigs - Maximum allowed significant figures (default: MAX_SIGNIFICANT_FIGURES from config)
102
+ * @returns Price string rounded to max significant figures
103
+ *
104
+ * @example
105
+ * roundToSignificantFigures('123.456') // '123.46' (3 int + 2 dec = 5)
106
+ * roundToSignificantFigures('0.065242') // '0.06524' (0 int + 5 dec = 5)
107
+ * roundToSignificantFigures('12345.67') // '12346' (5 int + 0 dec = 5)
108
+ */
109
+ export declare const roundToSignificantFigures: (priceString: string, maxSigFigs?: number) => string;
110
+ /**
111
+ * Minimal view fiat range configuration
112
+ * Uses fiat-style stripping for clean currency display
113
+ * Strips only .00 to avoid partial decimals like $1,250.1
114
+ */
115
+ export declare const PRICE_RANGES_MINIMAL_VIEW: FiatRangeConfig[];
116
+ /**
117
+ * Formats a balance value as USD currency with appropriate decimal places
118
+ *
119
+ * @param balance - Raw numeric balance value (e.g., 1234.56, not token minimal denomination)
120
+ * @param options - Optional formatting options
121
+ * @param options.minimumDecimals - Global minimum decimal places (overrides range configs)
122
+ * @param options.maximumDecimals - Global maximum decimal places (overrides range configs)
123
+ * @param options.significantDigits - Global significant digits (overrides decimal settings when set)
124
+ * @param options.ranges - Custom range configurations (defaults to PRICE_RANGES_MINIMAL_VIEW)
125
+ * @param options.currency - Currency code (default: 'USD')
126
+ * @param options.locale - Locale for formatting (default: 'en-US')
127
+ * @param options.stripTrailingZeros - Strip trailing zeros from output (default: false via PRICE_RANGES_MINIMAL_VIEW). When true, overrides minimumDecimals constraint.
128
+ * @returns Formatted currency string with variable decimals based on configured ranges
129
+ * @example
130
+ * // Using defaults (preserves trailing zeros for fiat)
131
+ * formatPerpsFiat(1234.56) => "$1,234.56"
132
+ * formatPerpsFiat(1250.00) => "$1,250.00" // Trailing zeros preserved
133
+ * formatPerpsFiat(50000) => "$50,000.00" // Trailing zeros preserved
134
+ *
135
+ * // Stripping trailing zeros when needed (e.g., for crypto)
136
+ * formatPerpsFiat(1250, { stripTrailingZeros: true }) => "$1,250"
137
+ *
138
+ * // With custom ranges
139
+ * formatPerpsFiat(0.00001, {
140
+ * ranges: [
141
+ * { condition: (val) => val < 0.001, minimumDecimals: 6, maximumDecimals: 8 },
142
+ * { condition: () => true, minimumDecimals: 2, maximumDecimals: 2 }
143
+ * ]
144
+ * }) => "$0.00001" // Trailing zero stripped
145
+ *
146
+ * // With significant digits
147
+ * formatPerpsFiat(1234.56789, { significantDigits: 5 }) => "$1,234.6"
148
+ * formatPerpsFiat(0.0001234, { significantDigits: 3 }) => "$0.000123"
149
+ */
150
+ export declare const formatPerpsFiat: (balance: string | number, options?: {
151
+ minimumDecimals?: number;
152
+ maximumDecimals?: number;
153
+ significantDigits?: number;
154
+ ranges?: FiatRangeConfig[];
155
+ currency?: string;
156
+ locale?: string;
157
+ stripTrailingZeros?: boolean;
158
+ }) => string;
159
+ /**
160
+ * Formats a fee value as USD currency with appropriate decimal places
161
+ *
162
+ * @param fee - Raw numeric or string fee value (e.g., 1234.56, not token minimal denomination)
163
+ * @returns Formatted currency string with variable decimals based on configured ranges
164
+ * @example formatPositiveFiat(1234.56) => "$1,234.56"
165
+ * @example formatPositiveFiat(0.005) => "< $0.01"
166
+ * @example formatPositiveFiat(0) => "$0"
167
+ */
168
+ export declare const formatPositiveFiat: (fee: number | string) => string;
169
+ /**
170
+ * Default price range configurations
171
+ * Applied in order - first matching condition wins
172
+ */
173
+ export declare const DEFAULT_PRICE_RANGES: FiatRangeConfig[];
174
+ /**
175
+ * Universal price range configuration following comprehensive rules from rules-decimals.md
176
+ *
177
+ * Rules:
178
+ * - Max 6 decimals across all ranges (Hyperliquid limit)
179
+ * - Strip trailing zeros by default
180
+ * - Use |v| (absolute value) for conditions
181
+ *
182
+ * Significant digits by range:
183
+ * - > $100,000: 6 sig digs
184
+ * - $100,000 > x > $0.01: 5 sig digs
185
+ * - < $0.01: 4 sig digs
186
+ *
187
+ * Decimal limits by price range:
188
+ * - |v| > 10,000: min 0, max 0 decimals; 5 sig digs (6 if >100k)
189
+ * - |v| > 1,000: min 0, max 1 decimal; 5 sig digs
190
+ * - |v| > 100: min 0, max 2 decimals; 5 sig digs
191
+ * - |v| > 10: min 0, max 4 decimals; 5 sig digs
192
+ * - |v| >= 0.01: 5 sig digs, min 2, max 6 decimals
193
+ * - |v| < 0.01: 4 sig digs, min 2, max 6 decimals
194
+ *
195
+ * Examples:
196
+ * - $123,456.78 becomes $123,457 (>$10k: 0 decimals, 6 sig figs)
197
+ * - $12,345.67 becomes $12,346 (>$10k: 0 decimals, 5 sig figs)
198
+ * - $1,234.56 becomes $1,234.6 ($1k-$10k: 1 decimal, 5 sig figs)
199
+ * - $123.456 becomes $123.46 ($100-$1k: 2 decimals, 5 sig figs)
200
+ * - $12.34567 becomes $12.346 ($10-$100: 4 decimals, 5 sig figs)
201
+ * - $1.3445555 becomes $1.3446 (>=$0.01: 5 sig figs)
202
+ * - $0.333333 becomes $0.33333 (>=$0.01: 5 sig figs)
203
+ * - $0.004236 stays $0.004236 (<$0.01: 4 sig figs, max 6 decimals)
204
+ * - $0.0000006 becomes $0.000001 (<$0.01: 4 sig figs, rounds with max 6 decimals)
205
+ */
206
+ export declare const PRICE_RANGES_UNIVERSAL: FiatRangeConfig[];
207
+ /**
208
+ * Formats a PnL (Profit and Loss) value with sign prefix
209
+ *
210
+ * @param pnl - Raw numeric PnL value (positive for profit, negative for loss)
211
+ * @returns Format: "+$X,XXX.XX" or "-$X,XXX.XX" (always shows sign, 2 decimals)
212
+ * @example formatPnl(1234.56) => "+$1,234.56"
213
+ * @example formatPnl(-500) => "-$500.00"
214
+ * @example formatPnl(0) => "+$0.00"
215
+ */
216
+ export declare const formatPnl: (pnl: string | number) => string;
217
+ /**
218
+ * Formats a percentage value with sign prefix
219
+ *
220
+ * @param value - Raw percentage value (e.g., 5.25 for 5.25%, not 0.0525)
221
+ * @param decimals - Number of decimal places to show (default: 2)
222
+ * @returns Format: "+X.XX%" or "-X.XX%" (always shows sign, 2 decimals)
223
+ * @example formatPercentage(5.25) => "+5.25%"
224
+ * @example formatPercentage(-2.75) => "-2.75%"
225
+ * @example formatPercentage(0) => "+0.00%"
226
+ */
227
+ export declare const formatPercentage: (value: string | number, decimals?: number) => string;
228
+ /**
229
+ * Formats funding rate for display
230
+ *
231
+ * @param value - Raw funding rate value (decimal, not percentage)
232
+ * @param options - Optional formatting options
233
+ * @param options.showZero - Whether to return zero display value for zero/undefined (default: true)
234
+ * @returns Formatted funding rate as percentage string
235
+ * @example formatFundingRate(0.0005) => "0.0500%"
236
+ * @example formatFundingRate(-0.0001) => "-0.0100%"
237
+ * @example formatFundingRate(undefined) => "0.0000%"
238
+ */
239
+ export declare const formatFundingRate: (value?: number | null, options?: {
240
+ showZero?: boolean;
241
+ }) => string;
242
+ /**
243
+ * Configuration for large number range formatting
244
+ */
245
+ export type LargeNumberRangeConfig = {
246
+ /** The minimum value threshold for this range (inclusive). Use 0 to catch numbers below the lowest suffix threshold */
247
+ threshold: number;
248
+ /** The suffix to use for this range (e.g., 'T', 'B', 'M', 'K', or '' for no suffix) */
249
+ suffix: string;
250
+ /** Number of decimal places for this range */
251
+ decimals: number;
252
+ };
253
+ /**
254
+ * Default large number range configurations
255
+ * Applied in order from largest to smallest
256
+ */
257
+ export declare const DEFAULT_LARGE_NUMBER_RANGES: LargeNumberRangeConfig[];
258
+ /**
259
+ * Preset for detailed large number formatting with more decimal precision
260
+ * Useful for displaying precise statistics or detailed financial data
261
+ */
262
+ export declare const LARGE_NUMBER_RANGES_DETAILED: LargeNumberRangeConfig[];
263
+ /**
264
+ * Formats large numbers with magnitude suffixes (K, M, B, T)
265
+ *
266
+ * @param value - The number to format
267
+ * @param options - Optional formatting options
268
+ * @param options.decimals - Legacy: Number of decimal places for all suffixed values (overrides range configs)
269
+ * @param options.rawDecimals - Legacy: Number of decimal places for numbers below all thresholds (overrides range config for threshold: 0)
270
+ * @param options.ranges - Custom range configurations for fine-grained control over decimals per range
271
+ * @returns Formatted string with appropriate suffix
272
+ * @example
273
+ * // Using defaults
274
+ * formatLargeNumber(1500000) => "2M"
275
+ * formatLargeNumber(1234) => "1K"
276
+ * formatLargeNumber(999) => "999.00"
277
+ *
278
+ * // Legacy: same decimals for all ranges
279
+ * formatLargeNumber(1500000, { decimals: 1 }) => "1.5M"
280
+ * formatLargeNumber(1234, { decimals: 2 }) => "1.23K"
281
+ *
282
+ * // New: custom decimals per range (including all remaining numbers)
283
+ * formatLargeNumber(1500000, {
284
+ * ranges: [
285
+ * { threshold: 1000000000000, suffix: 'T', decimals: 2 },
286
+ * { threshold: 1000000000, suffix: 'B', decimals: 1 },
287
+ * { threshold: 1000000, suffix: 'M', decimals: 1 },
288
+ * { threshold: 1000, suffix: 'K', decimals: 0 },
289
+ * { threshold: 0, suffix: '', decimals: 4 }, // < 1K (all remaining numbers)
290
+ * ]
291
+ * }) => "1.5M"
292
+ */
293
+ export declare const formatLargeNumber: (value: string | number, options?: {
294
+ decimals?: number;
295
+ rawDecimals?: number;
296
+ ranges?: LargeNumberRangeConfig[];
297
+ }) => string;
298
+ /**
299
+ * Formats volume with appropriate magnitude suffixes
300
+ *
301
+ * @param volume - Raw volume value
302
+ * @param decimals - Number of decimal places to show (optional, auto-determined by default)
303
+ * @returns Format: "$XB" / "$X.XXM" / "$XK" / "$X.XX"
304
+ * @example formatVolume(1234567890) => "$1.23B"
305
+ * @example formatVolume(12345678) => "$12.35M"
306
+ * @example formatVolume(123456) => "$123K"
307
+ */
308
+ export declare const formatVolume: (volume: string | number, decimals?: number) => string;
309
+ /**
310
+ * Formats position size with variable decimal precision based on magnitude or asset-specific decimals
311
+ * Removes trailing zeros to match task requirements
312
+ *
313
+ * @param size - Raw position size value
314
+ * @param szDecimals - Optional asset-specific decimal precision from Hyperliquid metadata (e.g., BTC=5, ETH=4, DOGE=1)
315
+ * @returns Format varies by size or uses asset-specific decimals, with trailing zeros removed:
316
+ * If szDecimals provided: Uses exact decimals (e.g., 0.00009 BTC with szDecimals=5 => "0.00009")
317
+ * Otherwise falls back to magnitude-based logic:
318
+ * - Size < 0.01: Up to 6 decimals (e.g., "0.00009" not "0.000090")
319
+ * - Size < 1: Up to 4 decimals (e.g., "0.0024" not "0.002400")
320
+ * - Size >= 1: Up to 2 decimals (e.g., "44" not "44.00")
321
+ * @example formatPositionSize(0.00009, 5) => "0.00009" (uses szDecimals)
322
+ * @example formatPositionSize(44.00, 1) => "44" (uses szDecimals, trailing zeros removed)
323
+ * @example formatPositionSize(0.0024) => "0.0024" (no szDecimals, uses magnitude logic)
324
+ * @example formatPositionSize(44.00) => "44" (no szDecimals, uses magnitude logic)
325
+ */
326
+ export declare const formatPositionSize: (size: string | number, szDecimals?: number) => string;
327
+ /**
328
+ * Formats leverage value with 'x' suffix
329
+ *
330
+ * @param leverage - Raw leverage multiplier value
331
+ * @returns Format: "X.Xx" (1 decimal place with 'x' suffix)
332
+ * @example formatLeverage(5) => "5.0x"
333
+ * @example formatLeverage(10.5) => "10.5x"
334
+ * @example formatLeverage(1) => "1.0x"
335
+ */
336
+ export declare const formatLeverage: (leverage: string | number) => string;
337
+ /**
338
+ * Parses formatted currency strings back to numeric values
339
+ *
340
+ * @param formattedValue - Formatted currency string (handles $, commas, negative values)
341
+ * @returns Raw numeric value
342
+ * @example parseCurrencyString("$1,234.56") => 1234.56
343
+ * @example parseCurrencyString("-$500.00") => -500
344
+ * @example parseCurrencyString("$-123.45") => -123.45
345
+ */
346
+ export declare const parseCurrencyString: (formattedValue: string) => number;
347
+ /**
348
+ * Parses formatted percentage strings back to numeric values
349
+ *
350
+ * @param formattedValue - Formatted percentage string (handles %, +/- signs)
351
+ * @returns Raw numeric percentage value
352
+ * @example parsePercentageString("+2.50%") => 2.5
353
+ * @example parsePercentageString("-10.75%") => -10.75
354
+ * @example parsePercentageString("5%") => 5
355
+ */
356
+ export declare const parsePercentageString: (formattedValue: string) => number;
357
+ /**
358
+ * Formats a timestamp for transaction detail views with time
359
+ *
360
+ * @param timestamp - Unix timestamp in milliseconds
361
+ * @returns Formatted date string with time (e.g., "July 24, 2025 at 2:30 PM")
362
+ * @example formatTransactionDate(1642492800000) => "January 18, 2022 at 12:00 AM"
363
+ */
364
+ export declare const formatTransactionDate: (timestamp: number) => string;
365
+ /**
366
+ * Formats a timestamp for order cards with time
367
+ *
368
+ * @param timestamp - Unix timestamp in milliseconds
369
+ * @returns Formatted date string with time (e.g., "Jan 18 at 2:30 PM")
370
+ * @example formatOrderCardDate(1642492800000) => "Jan 18 at 12:00 AM"
371
+ */
372
+ export declare const formatOrderCardDate: (timestamp: number) => string;
373
+ /**
374
+ * Formats a timestamp for transaction section headers
375
+ *
376
+ * @param timestamp - Unix timestamp in milliseconds
377
+ * @param labels - Localized labels for "Today" and "Yesterday"
378
+ * @param labels.today - Label text for today
379
+ * @param labels.yesterday - Label text for yesterday
380
+ * @returns Formatted date section string ("Today", "Yesterday", or "Month Day")
381
+ * @example formatDateSection(Date.now(), { today: 'Today', yesterday: 'Yesterday' }) => "Today"
382
+ */
383
+ export declare const formatDateSection: (timestamp: number, labels?: {
384
+ today: string;
385
+ yesterday: string;
386
+ }) => string;
387
+ //# sourceMappingURL=formatUtils.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatUtils.d.mts","sourceRoot":"","sources":["../../src/utils/formatUtils.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,eAAO,MAAM,eAAe;IAC1B,0CAA0C;;IAE1C,oCAAoC;;IAEpC,oCAAoC;;IAEpC,sCAAsC;;IAEtC,yCAAyC;;IAEzC,qCAAqC;;IAErC;;;;OAIG;;CAEK,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACtC,4CAA4C;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,4CAA4C;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qFAAq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