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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (498) hide show
  1. package/CHANGELOG.md +1 -11
  2. package/dist/PerpsController.cjs +66 -2224
  3. package/dist/PerpsController.cjs.map +1 -1
  4. package/dist/PerpsController.d.cts +79 -933
  5. package/dist/PerpsController.d.cts.map +1 -1
  6. package/dist/PerpsController.d.mts +79 -933
  7. package/dist/PerpsController.d.mts.map +1 -1
  8. package/dist/PerpsController.mjs +64 -2221
  9. package/dist/PerpsController.mjs.map +1 -1
  10. package/dist/index.cjs +1 -32
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +2 -6
  13. package/dist/index.d.cts.map +1 -1
  14. package/dist/index.d.mts +2 -6
  15. package/dist/index.d.mts.map +1 -1
  16. package/dist/index.mjs +1 -9
  17. package/dist/index.mjs.map +1 -1
  18. package/package.json +4 -19
  19. package/dist/__mocks__/hyperliquidMock.cjs +0 -68
  20. package/dist/__mocks__/hyperliquidMock.cjs.map +0 -1
  21. package/dist/__mocks__/hyperliquidMock.d.cts +0 -15
  22. package/dist/__mocks__/hyperliquidMock.d.cts.map +0 -1
  23. package/dist/__mocks__/hyperliquidMock.d.mts +0 -15
  24. package/dist/__mocks__/hyperliquidMock.d.mts.map +0 -1
  25. package/dist/__mocks__/hyperliquidMock.mjs +0 -65
  26. package/dist/__mocks__/hyperliquidMock.mjs.map +0 -1
  27. package/dist/__mocks__/providerMocks.cjs +0 -144
  28. package/dist/__mocks__/providerMocks.cjs.map +0 -1
  29. package/dist/__mocks__/providerMocks.d.cts +0 -44
  30. package/dist/__mocks__/providerMocks.d.cts.map +0 -1
  31. package/dist/__mocks__/providerMocks.d.mts +0 -44
  32. package/dist/__mocks__/providerMocks.d.mts.map +0 -1
  33. package/dist/__mocks__/providerMocks.mjs +0 -136
  34. package/dist/__mocks__/providerMocks.mjs.map +0 -1
  35. package/dist/__mocks__/serviceMocks.cjs +0 -187
  36. package/dist/__mocks__/serviceMocks.cjs.map +0 -1
  37. package/dist/__mocks__/serviceMocks.d.cts +0 -58
  38. package/dist/__mocks__/serviceMocks.d.cts.map +0 -1
  39. package/dist/__mocks__/serviceMocks.d.mts +0 -58
  40. package/dist/__mocks__/serviceMocks.d.mts.map +0 -1
  41. package/dist/__mocks__/serviceMocks.mjs +0 -180
  42. package/dist/__mocks__/serviceMocks.mjs.map +0 -1
  43. package/dist/aggregation/SubscriptionMultiplexer.cjs +0 -459
  44. package/dist/aggregation/SubscriptionMultiplexer.cjs.map +0 -1
  45. package/dist/aggregation/SubscriptionMultiplexer.d.cts +0 -222
  46. package/dist/aggregation/SubscriptionMultiplexer.d.cts.map +0 -1
  47. package/dist/aggregation/SubscriptionMultiplexer.d.mts +0 -222
  48. package/dist/aggregation/SubscriptionMultiplexer.d.mts.map +0 -1
  49. package/dist/aggregation/SubscriptionMultiplexer.mjs +0 -455
  50. package/dist/aggregation/SubscriptionMultiplexer.mjs.map +0 -1
  51. package/dist/aggregation/index.cjs +0 -9
  52. package/dist/aggregation/index.cjs.map +0 -1
  53. package/dist/aggregation/index.d.cts +0 -6
  54. package/dist/aggregation/index.d.cts.map +0 -1
  55. package/dist/aggregation/index.d.mts +0 -6
  56. package/dist/aggregation/index.d.mts.map +0 -1
  57. package/dist/aggregation/index.mjs +0 -5
  58. package/dist/aggregation/index.mjs.map +0 -1
  59. package/dist/constants/eventNames.cjs +0 -117
  60. package/dist/constants/eventNames.cjs.map +0 -1
  61. package/dist/constants/eventNames.d.cts +0 -106
  62. package/dist/constants/eventNames.d.cts.map +0 -1
  63. package/dist/constants/eventNames.d.mts +0 -106
  64. package/dist/constants/eventNames.d.mts.map +0 -1
  65. package/dist/constants/eventNames.mjs +0 -114
  66. package/dist/constants/eventNames.mjs.map +0 -1
  67. package/dist/constants/hyperLiquidConfig.cjs +0 -366
  68. package/dist/constants/hyperLiquidConfig.cjs.map +0 -1
  69. package/dist/constants/hyperLiquidConfig.d.cts +0 -276
  70. package/dist/constants/hyperLiquidConfig.d.cts.map +0 -1
  71. package/dist/constants/hyperLiquidConfig.d.mts +0 -276
  72. package/dist/constants/hyperLiquidConfig.d.mts.map +0 -1
  73. package/dist/constants/hyperLiquidConfig.mjs +0 -357
  74. package/dist/constants/hyperLiquidConfig.mjs.map +0 -1
  75. package/dist/constants/index.cjs +0 -23
  76. package/dist/constants/index.cjs.map +0 -1
  77. package/dist/constants/index.d.cts +0 -7
  78. package/dist/constants/index.d.cts.map +0 -1
  79. package/dist/constants/index.d.mts +0 -7
  80. package/dist/constants/index.d.mts.map +0 -1
  81. package/dist/constants/index.mjs +0 -7
  82. package/dist/constants/index.mjs.map +0 -1
  83. package/dist/constants/orderTypes.cjs +0 -31
  84. package/dist/constants/orderTypes.cjs.map +0 -1
  85. package/dist/constants/orderTypes.d.cts +0 -19
  86. package/dist/constants/orderTypes.d.cts.map +0 -1
  87. package/dist/constants/orderTypes.d.mts +0 -19
  88. package/dist/constants/orderTypes.d.mts.map +0 -1
  89. package/dist/constants/orderTypes.mjs +0 -27
  90. package/dist/constants/orderTypes.mjs.map +0 -1
  91. package/dist/constants/performanceMetrics.cjs +0 -61
  92. package/dist/constants/performanceMetrics.cjs.map +0 -1
  93. package/dist/constants/performanceMetrics.d.cts +0 -44
  94. package/dist/constants/performanceMetrics.d.cts.map +0 -1
  95. package/dist/constants/performanceMetrics.d.mts +0 -44
  96. package/dist/constants/performanceMetrics.d.mts.map +0 -1
  97. package/dist/constants/performanceMetrics.mjs +0 -58
  98. package/dist/constants/performanceMetrics.mjs.map +0 -1
  99. package/dist/constants/perpsConfig.cjs +0 -461
  100. package/dist/constants/perpsConfig.cjs.map +0 -1
  101. package/dist/constants/perpsConfig.d.cts +0 -343
  102. package/dist/constants/perpsConfig.d.cts.map +0 -1
  103. package/dist/constants/perpsConfig.d.mts +0 -343
  104. package/dist/constants/perpsConfig.d.mts.map +0 -1
  105. package/dist/constants/perpsConfig.mjs +0 -458
  106. package/dist/constants/perpsConfig.mjs.map +0 -1
  107. package/dist/constants/perpsErrorCodes.cjs +0 -79
  108. package/dist/constants/perpsErrorCodes.cjs.map +0 -1
  109. package/dist/constants/perpsErrorCodes.d.cts +0 -64
  110. package/dist/constants/perpsErrorCodes.d.cts.map +0 -1
  111. package/dist/constants/perpsErrorCodes.d.mts +0 -64
  112. package/dist/constants/perpsErrorCodes.d.mts.map +0 -1
  113. package/dist/constants/perpsErrorCodes.mjs +0 -76
  114. package/dist/constants/perpsErrorCodes.mjs.map +0 -1
  115. package/dist/platform-services/HyperLiquidClientService.cjs +0 -857
  116. package/dist/platform-services/HyperLiquidClientService.cjs.map +0 -1
  117. package/dist/platform-services/HyperLiquidClientService.d.cts +0 -263
  118. package/dist/platform-services/HyperLiquidClientService.d.cts.map +0 -1
  119. package/dist/platform-services/HyperLiquidClientService.d.mts +0 -263
  120. package/dist/platform-services/HyperLiquidClientService.d.mts.map +0 -1
  121. package/dist/platform-services/HyperLiquidClientService.mjs +0 -853
  122. package/dist/platform-services/HyperLiquidClientService.mjs.map +0 -1
  123. package/dist/platform-services/HyperLiquidSubscriptionService.cjs +0 -2170
  124. package/dist/platform-services/HyperLiquidSubscriptionService.cjs.map +0 -1
  125. package/dist/platform-services/HyperLiquidSubscriptionService.d.cts +0 -424
  126. package/dist/platform-services/HyperLiquidSubscriptionService.d.cts.map +0 -1
  127. package/dist/platform-services/HyperLiquidSubscriptionService.d.mts +0 -424
  128. package/dist/platform-services/HyperLiquidSubscriptionService.d.mts.map +0 -1
  129. package/dist/platform-services/HyperLiquidSubscriptionService.mjs +0 -2166
  130. package/dist/platform-services/HyperLiquidSubscriptionService.mjs.map +0 -1
  131. package/dist/platform-services/HyperLiquidWalletService.cjs +0 -140
  132. package/dist/platform-services/HyperLiquidWalletService.cjs.map +0 -1
  133. package/dist/platform-services/HyperLiquidWalletService.d.cts +0 -78
  134. package/dist/platform-services/HyperLiquidWalletService.d.cts.map +0 -1
  135. package/dist/platform-services/HyperLiquidWalletService.d.mts +0 -78
  136. package/dist/platform-services/HyperLiquidWalletService.d.mts.map +0 -1
  137. package/dist/platform-services/HyperLiquidWalletService.mjs +0 -136
  138. package/dist/platform-services/HyperLiquidWalletService.mjs.map +0 -1
  139. package/dist/providers/AggregatedPerpsProvider.cjs +0 -777
  140. package/dist/providers/AggregatedPerpsProvider.cjs.map +0 -1
  141. package/dist/providers/AggregatedPerpsProvider.d.cts +0 -466
  142. package/dist/providers/AggregatedPerpsProvider.d.cts.map +0 -1
  143. package/dist/providers/AggregatedPerpsProvider.d.mts +0 -466
  144. package/dist/providers/AggregatedPerpsProvider.d.mts.map +0 -1
  145. package/dist/providers/AggregatedPerpsProvider.mjs +0 -773
  146. package/dist/providers/AggregatedPerpsProvider.mjs.map +0 -1
  147. package/dist/providers/HyperLiquidProvider.cjs +0 -5172
  148. package/dist/providers/HyperLiquidProvider.cjs.map +0 -1
  149. package/dist/providers/HyperLiquidProvider.d.cts +0 -881
  150. package/dist/providers/HyperLiquidProvider.d.cts.map +0 -1
  151. package/dist/providers/HyperLiquidProvider.d.mts +0 -881
  152. package/dist/providers/HyperLiquidProvider.d.mts.map +0 -1
  153. package/dist/providers/HyperLiquidProvider.mjs +0 -5168
  154. package/dist/providers/HyperLiquidProvider.mjs.map +0 -1
  155. package/dist/providers/index.cjs +0 -11
  156. package/dist/providers/index.cjs.map +0 -1
  157. package/dist/providers/index.d.cts +0 -6
  158. package/dist/providers/index.d.cts.map +0 -1
  159. package/dist/providers/index.d.mts +0 -6
  160. package/dist/providers/index.d.mts.map +0 -1
  161. package/dist/providers/index.mjs +0 -6
  162. package/dist/providers/index.mjs.map +0 -1
  163. package/dist/routing/ProviderRouter.cjs +0 -148
  164. package/dist/routing/ProviderRouter.cjs.map +0 -1
  165. package/dist/routing/ProviderRouter.d.cts +0 -124
  166. package/dist/routing/ProviderRouter.d.cts.map +0 -1
  167. package/dist/routing/ProviderRouter.d.mts +0 -124
  168. package/dist/routing/ProviderRouter.d.mts.map +0 -1
  169. package/dist/routing/ProviderRouter.mjs +0 -144
  170. package/dist/routing/ProviderRouter.mjs.map +0 -1
  171. package/dist/routing/index.cjs +0 -9
  172. package/dist/routing/index.cjs.map +0 -1
  173. package/dist/routing/index.d.cts +0 -6
  174. package/dist/routing/index.d.cts.map +0 -1
  175. package/dist/routing/index.d.mts +0 -6
  176. package/dist/routing/index.d.mts.map +0 -1
  177. package/dist/routing/index.mjs +0 -5
  178. package/dist/routing/index.mjs.map +0 -1
  179. package/dist/selectors.cjs +0 -161
  180. package/dist/selectors.cjs.map +0 -1
  181. package/dist/selectors.d.cts +0 -345
  182. package/dist/selectors.d.cts.map +0 -1
  183. package/dist/selectors.d.mts +0 -345
  184. package/dist/selectors.d.mts.map +0 -1
  185. package/dist/selectors.mjs +0 -153
  186. package/dist/selectors.mjs.map +0 -1
  187. package/dist/services/AccountService.cjs +0 -313
  188. package/dist/services/AccountService.cjs.map +0 -1
  189. package/dist/services/AccountService.d.cts +0 -53
  190. package/dist/services/AccountService.d.cts.map +0 -1
  191. package/dist/services/AccountService.d.mts +0 -53
  192. package/dist/services/AccountService.d.mts.map +0 -1
  193. package/dist/services/AccountService.mjs +0 -309
  194. package/dist/services/AccountService.mjs.map +0 -1
  195. package/dist/services/DataLakeService.cjs +0 -219
  196. package/dist/services/DataLakeService.cjs.map +0 -1
  197. package/dist/services/DataLakeService.d.cts +0 -49
  198. package/dist/services/DataLakeService.d.cts.map +0 -1
  199. package/dist/services/DataLakeService.d.mts +0 -49
  200. package/dist/services/DataLakeService.d.mts.map +0 -1
  201. package/dist/services/DataLakeService.mjs +0 -215
  202. package/dist/services/DataLakeService.mjs.map +0 -1
  203. package/dist/services/DepositService.cjs +0 -96
  204. package/dist/services/DepositService.cjs.map +0 -1
  205. package/dist/services/DepositService.d.cts +0 -37
  206. package/dist/services/DepositService.d.cts.map +0 -1
  207. package/dist/services/DepositService.d.mts +0 -37
  208. package/dist/services/DepositService.d.mts.map +0 -1
  209. package/dist/services/DepositService.mjs +0 -92
  210. package/dist/services/DepositService.mjs.map +0 -1
  211. package/dist/services/EligibilityService.cjs +0 -156
  212. package/dist/services/EligibilityService.cjs.map +0 -1
  213. package/dist/services/EligibilityService.d.cts +0 -48
  214. package/dist/services/EligibilityService.d.cts.map +0 -1
  215. package/dist/services/EligibilityService.d.mts +0 -48
  216. package/dist/services/EligibilityService.d.mts.map +0 -1
  217. package/dist/services/EligibilityService.mjs +0 -152
  218. package/dist/services/EligibilityService.mjs.map +0 -1
  219. package/dist/services/FeatureFlagConfigurationService.cjs +0 -258
  220. package/dist/services/FeatureFlagConfigurationService.cjs.map +0 -1
  221. package/dist/services/FeatureFlagConfigurationService.d.cts +0 -100
  222. package/dist/services/FeatureFlagConfigurationService.d.cts.map +0 -1
  223. package/dist/services/FeatureFlagConfigurationService.d.mts +0 -100
  224. package/dist/services/FeatureFlagConfigurationService.d.mts.map +0 -1
  225. package/dist/services/FeatureFlagConfigurationService.mjs +0 -254
  226. package/dist/services/FeatureFlagConfigurationService.mjs.map +0 -1
  227. package/dist/services/MarketDataService.cjs +0 -875
  228. package/dist/services/MarketDataService.cjs.map +0 -1
  229. package/dist/services/MarketDataService.d.cts +0 -289
  230. package/dist/services/MarketDataService.d.cts.map +0 -1
  231. package/dist/services/MarketDataService.d.mts +0 -289
  232. package/dist/services/MarketDataService.d.mts.map +0 -1
  233. package/dist/services/MarketDataService.mjs +0 -871
  234. package/dist/services/MarketDataService.mjs.map +0 -1
  235. package/dist/services/RewardsIntegrationService.cjs +0 -94
  236. package/dist/services/RewardsIntegrationService.cjs.map +0 -1
  237. package/dist/services/RewardsIntegrationService.d.cts +0 -30
  238. package/dist/services/RewardsIntegrationService.d.cts.map +0 -1
  239. package/dist/services/RewardsIntegrationService.d.mts +0 -30
  240. package/dist/services/RewardsIntegrationService.d.mts.map +0 -1
  241. package/dist/services/RewardsIntegrationService.mjs +0 -90
  242. package/dist/services/RewardsIntegrationService.mjs.map +0 -1
  243. package/dist/services/ServiceContext.cjs +0 -3
  244. package/dist/services/ServiceContext.cjs.map +0 -1
  245. package/dist/services/ServiceContext.d.cts +0 -110
  246. package/dist/services/ServiceContext.d.cts.map +0 -1
  247. package/dist/services/ServiceContext.d.mts +0 -110
  248. package/dist/services/ServiceContext.d.mts.map +0 -1
  249. package/dist/services/ServiceContext.mjs +0 -2
  250. package/dist/services/ServiceContext.mjs.map +0 -1
  251. package/dist/services/TradingService.cjs +0 -1481
  252. package/dist/services/TradingService.cjs.map +0 -1
  253. package/dist/services/TradingService.d.cts +0 -308
  254. package/dist/services/TradingService.d.cts.map +0 -1
  255. package/dist/services/TradingService.d.mts +0 -308
  256. package/dist/services/TradingService.d.mts.map +0 -1
  257. package/dist/services/TradingService.mjs +0 -1477
  258. package/dist/services/TradingService.mjs.map +0 -1
  259. package/dist/services/index.cjs +0 -26
  260. package/dist/services/index.cjs.map +0 -1
  261. package/dist/services/index.d.cts +0 -11
  262. package/dist/services/index.d.cts.map +0 -1
  263. package/dist/services/index.d.mts +0 -11
  264. package/dist/services/index.d.mts.map +0 -1
  265. package/dist/services/index.mjs +0 -10
  266. package/dist/services/index.mjs.map +0 -1
  267. package/dist/services/utils.cjs +0 -16
  268. package/dist/services/utils.cjs.map +0 -1
  269. package/dist/services/utils.d.cts +0 -8
  270. package/dist/services/utils.d.cts.map +0 -1
  271. package/dist/services/utils.d.mts +0 -8
  272. package/dist/services/utils.d.mts.map +0 -1
  273. package/dist/services/utils.mjs +0 -12
  274. package/dist/services/utils.mjs.map +0 -1
  275. package/dist/types/chart.cjs +0 -42
  276. package/dist/types/chart.cjs.map +0 -1
  277. package/dist/types/chart.d.cts +0 -62
  278. package/dist/types/chart.d.cts.map +0 -1
  279. package/dist/types/chart.d.mts +0 -62
  280. package/dist/types/chart.d.mts.map +0 -1
  281. package/dist/types/chart.mjs +0 -39
  282. package/dist/types/chart.mjs.map +0 -1
  283. package/dist/types/hyperliquid-types.cjs +0 -3
  284. package/dist/types/hyperliquid-types.cjs.map +0 -1
  285. package/dist/types/hyperliquid-types.d.cts +0 -52
  286. package/dist/types/hyperliquid-types.d.cts.map +0 -1
  287. package/dist/types/hyperliquid-types.d.mts +0 -52
  288. package/dist/types/hyperliquid-types.d.mts.map +0 -1
  289. package/dist/types/hyperliquid-types.mjs +0 -2
  290. package/dist/types/hyperliquid-types.mjs.map +0 -1
  291. package/dist/types/index.cjs +0 -96
  292. package/dist/types/index.cjs.map +0 -1
  293. package/dist/types/index.d.cts +0 -1153
  294. package/dist/types/index.d.cts.map +0 -1
  295. package/dist/types/index.d.mts +0 -1153
  296. package/dist/types/index.d.mts.map +0 -1
  297. package/dist/types/index.mjs +0 -79
  298. package/dist/types/index.mjs.map +0 -1
  299. package/dist/types/transactionTypes.cjs +0 -28
  300. package/dist/types/transactionTypes.cjs.map +0 -1
  301. package/dist/types/transactionTypes.d.cts +0 -64
  302. package/dist/types/transactionTypes.d.cts.map +0 -1
  303. package/dist/types/transactionTypes.d.mts +0 -64
  304. package/dist/types/transactionTypes.d.mts.map +0 -1
  305. package/dist/types/transactionTypes.mjs +0 -23
  306. package/dist/types/transactionTypes.mjs.map +0 -1
  307. package/dist/utils/accountUtils.cjs +0 -65
  308. package/dist/utils/accountUtils.cjs.map +0 -1
  309. package/dist/utils/accountUtils.d.cts +0 -26
  310. package/dist/utils/accountUtils.d.cts.map +0 -1
  311. package/dist/utils/accountUtils.d.mts +0 -26
  312. package/dist/utils/accountUtils.d.mts.map +0 -1
  313. package/dist/utils/accountUtils.mjs +0 -61
  314. package/dist/utils/accountUtils.mjs.map +0 -1
  315. package/dist/utils/amountConversion.cjs +0 -61
  316. package/dist/utils/amountConversion.cjs.map +0 -1
  317. package/dist/utils/amountConversion.d.cts +0 -16
  318. package/dist/utils/amountConversion.d.cts.map +0 -1
  319. package/dist/utils/amountConversion.d.mts +0 -16
  320. package/dist/utils/amountConversion.d.mts.map +0 -1
  321. package/dist/utils/amountConversion.mjs +0 -54
  322. package/dist/utils/amountConversion.mjs.map +0 -1
  323. package/dist/utils/chartUtils.cjs +0 -98
  324. package/dist/utils/chartUtils.cjs.map +0 -1
  325. package/dist/utils/chartUtils.d.cts +0 -14
  326. package/dist/utils/chartUtils.d.cts.map +0 -1
  327. package/dist/utils/chartUtils.d.mts +0 -14
  328. package/dist/utils/chartUtils.d.mts.map +0 -1
  329. package/dist/utils/chartUtils.mjs +0 -94
  330. package/dist/utils/chartUtils.mjs.map +0 -1
  331. package/dist/utils/errorUtils.cjs +0 -22
  332. package/dist/utils/errorUtils.cjs.map +0 -1
  333. package/dist/utils/errorUtils.d.cts +0 -13
  334. package/dist/utils/errorUtils.d.cts.map +0 -1
  335. package/dist/utils/errorUtils.d.mts +0 -13
  336. package/dist/utils/errorUtils.d.mts.map +0 -1
  337. package/dist/utils/errorUtils.mjs +0 -18
  338. package/dist/utils/errorUtils.mjs.map +0 -1
  339. package/dist/utils/formatUtils.cjs +0 -987
  340. package/dist/utils/formatUtils.cjs.map +0 -1
  341. package/dist/utils/formatUtils.d.cts +0 -387
  342. package/dist/utils/formatUtils.d.cts.map +0 -1
  343. package/dist/utils/formatUtils.d.mts +0 -387
  344. package/dist/utils/formatUtils.d.mts.map +0 -1
  345. package/dist/utils/formatUtils.mjs +0 -966
  346. package/dist/utils/formatUtils.mjs.map +0 -1
  347. package/dist/utils/hyperLiquidAdapter.cjs +0 -454
  348. package/dist/utils/hyperLiquidAdapter.cjs.map +0 -1
  349. package/dist/utils/hyperLiquidAdapter.d.cts +0 -158
  350. package/dist/utils/hyperLiquidAdapter.d.cts.map +0 -1
  351. package/dist/utils/hyperLiquidAdapter.d.mts +0 -158
  352. package/dist/utils/hyperLiquidAdapter.d.mts.map +0 -1
  353. package/dist/utils/hyperLiquidAdapter.mjs +0 -439
  354. package/dist/utils/hyperLiquidAdapter.mjs.map +0 -1
  355. package/dist/utils/hyperLiquidOrderBookProcessor.cjs +0 -89
  356. package/dist/utils/hyperLiquidOrderBookProcessor.cjs.map +0 -1
  357. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts +0 -58
  358. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts.map +0 -1
  359. package/dist/utils/hyperLiquidOrderBookProcessor.d.mts +0 -58
  360. package/dist/utils/hyperLiquidOrderBookProcessor.d.mts.map +0 -1
  361. package/dist/utils/hyperLiquidOrderBookProcessor.mjs +0 -84
  362. package/dist/utils/hyperLiquidOrderBookProcessor.mjs.map +0 -1
  363. package/dist/utils/hyperLiquidValidation.cjs +0 -426
  364. package/dist/utils/hyperLiquidValidation.cjs.map +0 -1
  365. package/dist/utils/hyperLiquidValidation.d.cts +0 -143
  366. package/dist/utils/hyperLiquidValidation.d.cts.map +0 -1
  367. package/dist/utils/hyperLiquidValidation.d.mts +0 -143
  368. package/dist/utils/hyperLiquidValidation.d.mts.map +0 -1
  369. package/dist/utils/hyperLiquidValidation.mjs +0 -413
  370. package/dist/utils/hyperLiquidValidation.mjs.map +0 -1
  371. package/dist/utils/idUtils.cjs +0 -50
  372. package/dist/utils/idUtils.cjs.map +0 -1
  373. package/dist/utils/idUtils.d.cts +0 -38
  374. package/dist/utils/idUtils.d.cts.map +0 -1
  375. package/dist/utils/idUtils.d.mts +0 -38
  376. package/dist/utils/idUtils.d.mts.map +0 -1
  377. package/dist/utils/idUtils.mjs +0 -42
  378. package/dist/utils/idUtils.mjs.map +0 -1
  379. package/dist/utils/marginUtils.cjs +0 -137
  380. package/dist/utils/marginUtils.cjs.map +0 -1
  381. package/dist/utils/marginUtils.d.cts +0 -64
  382. package/dist/utils/marginUtils.d.cts.map +0 -1
  383. package/dist/utils/marginUtils.d.mts +0 -64
  384. package/dist/utils/marginUtils.d.mts.map +0 -1
  385. package/dist/utils/marginUtils.mjs +0 -131
  386. package/dist/utils/marginUtils.mjs.map +0 -1
  387. package/dist/utils/marketDataTransform.cjs +0 -227
  388. package/dist/utils/marketDataTransform.cjs.map +0 -1
  389. package/dist/utils/marketDataTransform.d.cts +0 -45
  390. package/dist/utils/marketDataTransform.d.cts.map +0 -1
  391. package/dist/utils/marketDataTransform.d.mts +0 -45
  392. package/dist/utils/marketDataTransform.d.mts.map +0 -1
  393. package/dist/utils/marketDataTransform.mjs +0 -220
  394. package/dist/utils/marketDataTransform.mjs.map +0 -1
  395. package/dist/utils/marketUtils.cjs +0 -420
  396. package/dist/utils/marketUtils.cjs.map +0 -1
  397. package/dist/utils/marketUtils.d.cts +0 -227
  398. package/dist/utils/marketUtils.d.cts.map +0 -1
  399. package/dist/utils/marketUtils.d.mts +0 -227
  400. package/dist/utils/marketUtils.d.mts.map +0 -1
  401. package/dist/utils/marketUtils.mjs +0 -404
  402. package/dist/utils/marketUtils.mjs.map +0 -1
  403. package/dist/utils/orderBookGrouping.cjs +0 -151
  404. package/dist/utils/orderBookGrouping.cjs.map +0 -1
  405. package/dist/utils/orderBookGrouping.d.cts +0 -76
  406. package/dist/utils/orderBookGrouping.d.cts.map +0 -1
  407. package/dist/utils/orderBookGrouping.d.mts +0 -76
  408. package/dist/utils/orderBookGrouping.d.mts.map +0 -1
  409. package/dist/utils/orderBookGrouping.mjs +0 -143
  410. package/dist/utils/orderBookGrouping.mjs.map +0 -1
  411. package/dist/utils/orderCalculations.cjs +0 -283
  412. package/dist/utils/orderCalculations.cjs.map +0 -1
  413. package/dist/utils/orderCalculations.d.cts +0 -107
  414. package/dist/utils/orderCalculations.d.cts.map +0 -1
  415. package/dist/utils/orderCalculations.d.mts +0 -107
  416. package/dist/utils/orderCalculations.d.mts.map +0 -1
  417. package/dist/utils/orderCalculations.mjs +0 -274
  418. package/dist/utils/orderCalculations.mjs.map +0 -1
  419. package/dist/utils/orderUtils.cjs +0 -159
  420. package/dist/utils/orderUtils.cjs.map +0 -1
  421. package/dist/utils/orderUtils.d.cts +0 -66
  422. package/dist/utils/orderUtils.d.cts.map +0 -1
  423. package/dist/utils/orderUtils.d.mts +0 -66
  424. package/dist/utils/orderUtils.d.mts.map +0 -1
  425. package/dist/utils/orderUtils.mjs +0 -151
  426. package/dist/utils/orderUtils.mjs.map +0 -1
  427. package/dist/utils/pnlCalculations.cjs +0 -107
  428. package/dist/utils/pnlCalculations.cjs.map +0 -1
  429. package/dist/utils/pnlCalculations.d.cts +0 -79
  430. package/dist/utils/pnlCalculations.d.cts.map +0 -1
  431. package/dist/utils/pnlCalculations.d.mts +0 -79
  432. package/dist/utils/pnlCalculations.d.mts.map +0 -1
  433. package/dist/utils/pnlCalculations.mjs +0 -97
  434. package/dist/utils/pnlCalculations.mjs.map +0 -1
  435. package/dist/utils/positionCalculations.cjs +0 -176
  436. package/dist/utils/positionCalculations.cjs.map +0 -1
  437. package/dist/utils/positionCalculations.d.cts +0 -85
  438. package/dist/utils/positionCalculations.d.cts.map +0 -1
  439. package/dist/utils/positionCalculations.d.mts +0 -85
  440. package/dist/utils/positionCalculations.d.mts.map +0 -1
  441. package/dist/utils/positionCalculations.mjs +0 -165
  442. package/dist/utils/positionCalculations.mjs.map +0 -1
  443. package/dist/utils/sortMarkets.cjs +0 -88
  444. package/dist/utils/sortMarkets.cjs.map +0 -1
  445. package/dist/utils/sortMarkets.d.cts +0 -21
  446. package/dist/utils/sortMarkets.d.cts.map +0 -1
  447. package/dist/utils/sortMarkets.d.mts +0 -21
  448. package/dist/utils/sortMarkets.d.mts.map +0 -1
  449. package/dist/utils/sortMarkets.mjs +0 -84
  450. package/dist/utils/sortMarkets.mjs.map +0 -1
  451. package/dist/utils/standaloneInfoClient.cjs +0 -34
  452. package/dist/utils/standaloneInfoClient.cjs.map +0 -1
  453. package/dist/utils/standaloneInfoClient.d.cts +0 -31
  454. package/dist/utils/standaloneInfoClient.d.cts.map +0 -1
  455. package/dist/utils/standaloneInfoClient.d.mts +0 -31
  456. package/dist/utils/standaloneInfoClient.d.mts.map +0 -1
  457. package/dist/utils/standaloneInfoClient.mjs +0 -30
  458. package/dist/utils/standaloneInfoClient.mjs.map +0 -1
  459. package/dist/utils/stringParseUtils.cjs +0 -49
  460. package/dist/utils/stringParseUtils.cjs.map +0 -1
  461. package/dist/utils/stringParseUtils.d.cts +0 -35
  462. package/dist/utils/stringParseUtils.d.cts.map +0 -1
  463. package/dist/utils/stringParseUtils.d.mts +0 -35
  464. package/dist/utils/stringParseUtils.d.mts.map +0 -1
  465. package/dist/utils/stringParseUtils.mjs +0 -44
  466. package/dist/utils/stringParseUtils.mjs.map +0 -1
  467. package/dist/utils/time.cjs +0 -37
  468. package/dist/utils/time.cjs.map +0 -1
  469. package/dist/utils/time.d.cts +0 -17
  470. package/dist/utils/time.d.cts.map +0 -1
  471. package/dist/utils/time.d.mts +0 -17
  472. package/dist/utils/time.d.mts.map +0 -1
  473. package/dist/utils/time.mjs +0 -33
  474. package/dist/utils/time.mjs.map +0 -1
  475. package/dist/utils/tpslValidation.cjs +0 -505
  476. package/dist/utils/tpslValidation.cjs.map +0 -1
  477. package/dist/utils/tpslValidation.d.cts +0 -182
  478. package/dist/utils/tpslValidation.d.cts.map +0 -1
  479. package/dist/utils/tpslValidation.d.mts +0 -182
  480. package/dist/utils/tpslValidation.d.mts.map +0 -1
  481. package/dist/utils/tpslValidation.mjs +0 -482
  482. package/dist/utils/tpslValidation.mjs.map +0 -1
  483. package/dist/utils/transactionUtils.cjs +0 -36
  484. package/dist/utils/transactionUtils.cjs.map +0 -1
  485. package/dist/utils/transactionUtils.d.cts +0 -17
  486. package/dist/utils/transactionUtils.d.cts.map +0 -1
  487. package/dist/utils/transactionUtils.d.mts +0 -17
  488. package/dist/utils/transactionUtils.d.mts.map +0 -1
  489. package/dist/utils/transactionUtils.mjs +0 -32
  490. package/dist/utils/transactionUtils.mjs.map +0 -1
  491. package/dist/utils/wait.cjs +0 -12
  492. package/dist/utils/wait.cjs.map +0 -1
  493. package/dist/utils/wait.d.cts +0 -8
  494. package/dist/utils/wait.d.cts.map +0 -1
  495. package/dist/utils/wait.d.mts +0 -8
  496. package/dist/utils/wait.d.mts.map +0 -1
  497. package/dist/utils/wait.mjs +0 -8
  498. package/dist/utils/wait.mjs.map +0 -1
@@ -1,165 +0,0 @@
1
- /**
2
- * Position calculation utilities for closing positions
3
- */
4
- import { CLOSE_POSITION_CONFIG } from "../constants/perpsConfig.mjs";
5
- /**
6
- * Calculate close amounts from percentage for both USD and token modes
7
- * Uses USD as source of truth with precision validation (matches order placement logic)
8
- *
9
- * @param params - Percentage, position size, current price, and asset-specific decimal precision
10
- * @returns Object with token amount and USD value
11
- */
12
- export function calculateCloseAmountFromPercentage(params) {
13
- const { percentage, positionSize, currentPrice, szDecimals } = params;
14
- // Validate required parameters
15
- if (szDecimals === undefined || szDecimals === null) {
16
- throw new Error('szDecimals is required for close position calculation');
17
- }
18
- if (szDecimals < 0) {
19
- throw new Error(`szDecimals must be >= 0, got: ${szDecimals}`);
20
- }
21
- if (isNaN(percentage) ||
22
- isNaN(positionSize) ||
23
- isNaN(currentPrice) ||
24
- percentage < 0 ||
25
- percentage > 100) {
26
- return { tokenAmount: 0, usdValue: 0 };
27
- }
28
- // Calculate initial token amount and USD value
29
- let tokenAmount = (percentage / 100) * Math.abs(positionSize);
30
- const usdValue = tokenAmount * currentPrice;
31
- // Apply asset-specific decimal precision rounding
32
- const multiplier = Math.pow(10, szDecimals);
33
- tokenAmount = Math.round(tokenAmount * multiplier) / multiplier;
34
- // Ensure rounded size meets requested USD value (fix validation gap)
35
- // This matches the logic in calculatePositionSize for consistency
36
- const actualUsd = tokenAmount * currentPrice;
37
- if (actualUsd < usdValue) {
38
- // Add 1 minimum increment to meet requested USD
39
- tokenAmount += 1 / multiplier;
40
- }
41
- return {
42
- tokenAmount: Number(tokenAmount.toFixed(szDecimals)),
43
- usdValue: Number(usdValue.toFixed(CLOSE_POSITION_CONFIG.UsdDecimalPlaces)),
44
- };
45
- }
46
- /**
47
- * Validate and clamp close amount within limits
48
- *
49
- * @param params - Amount to validate, maximum allowed, and optional minimum
50
- * @returns Clamped amount within valid range
51
- */
52
- export function validateCloseAmountLimits(params) {
53
- const { amount, maxAmount, minAmount = 0 } = params;
54
- if (isNaN(amount) || amount < 0) {
55
- return 0;
56
- }
57
- return Math.max(minAmount, Math.min(amount, maxAmount));
58
- }
59
- /**
60
- * Format close amount for display based on mode and decimals
61
- *
62
- * @param params - Value string, display mode, and decimal places
63
- * @returns Formatted string with appropriate decimal precision
64
- */
65
- export function formatCloseAmountDisplay(params) {
66
- const { value, displayMode, decimals } = params;
67
- if (!value || value === '') {
68
- return '0';
69
- }
70
- const numericValue = parseFloat(value);
71
- if (isNaN(numericValue)) {
72
- return '0';
73
- }
74
- const decimalPlaces = decimals ??
75
- (displayMode === 'usd'
76
- ? CLOSE_POSITION_CONFIG.UsdDecimalPlaces
77
- : CLOSE_POSITION_CONFIG.AmountCalculationPrecision);
78
- // For USD mode, limit input to specified decimal places
79
- if (displayMode === 'usd' && value.includes('.')) {
80
- const parts = value.split('.');
81
- const integerPart = parts[0] || '0';
82
- const decimalPart = (parts[1] || '').slice(0, CLOSE_POSITION_CONFIG.UsdDecimalPlaces);
83
- return `${integerPart}${decimalPart ? `.${decimalPart}` : ''}`;
84
- }
85
- return numericValue.toFixed(decimalPlaces);
86
- }
87
- /**
88
- * Calculate USD value for a given token amount
89
- *
90
- * @param params - Token amount and current price
91
- * @returns USD value formatted to 2 decimal places
92
- */
93
- export function calculateCloseValue(params) {
94
- const { amount, price } = params;
95
- if (isNaN(amount) || isNaN(price) || amount < 0 || price <= 0) {
96
- return 0;
97
- }
98
- const value = amount * price;
99
- return Number(value.toFixed(CLOSE_POSITION_CONFIG.UsdDecimalPlaces));
100
- }
101
- /**
102
- * Formats a USD value for close amount display with proper decimal places
103
- * Uses the centralized USD_DECIMAL_PLACES configuration
104
- *
105
- * @param value - Raw USD value to format
106
- * @returns Formatted string with configured decimal places
107
- */
108
- export function formatCloseAmountUSD(value) {
109
- if (isNaN(value) || value < 0) {
110
- return '0';
111
- }
112
- return value.toFixed(CLOSE_POSITION_CONFIG.UsdDecimalPlaces);
113
- }
114
- /**
115
- * Calculate percentage from token amount
116
- *
117
- * @param tokenAmount - Amount in token units
118
- * @param totalPositionSize - Total position size in token units
119
- * @returns Percentage (0-100)
120
- */
121
- export function calculatePercentageFromTokenAmount(tokenAmount, totalPositionSize) {
122
- if (isNaN(tokenAmount) ||
123
- isNaN(totalPositionSize) ||
124
- totalPositionSize === 0) {
125
- return 0;
126
- }
127
- const percentage = (Math.abs(tokenAmount) / Math.abs(totalPositionSize)) * 100;
128
- return Math.max(0, Math.min(100, percentage));
129
- }
130
- /**
131
- * Calculate percentage from USD amount
132
- *
133
- * @param usdAmount - Amount in USD
134
- * @param totalPositionValue - Total position value in USD
135
- * @returns Percentage (0-100)
136
- */
137
- export function calculatePercentageFromUSDAmount(usdAmount, totalPositionValue) {
138
- if (isNaN(usdAmount) ||
139
- isNaN(totalPositionValue) ||
140
- totalPositionValue === 0) {
141
- return 0;
142
- }
143
- const percentage = (usdAmount / totalPositionValue) * 100;
144
- return Math.max(0, Math.min(100, percentage));
145
- }
146
- /**
147
- * Helper function to determine position direction based on size value
148
- *
149
- * @param sizeString - The position size as a string
150
- * @returns 'long', 'short', or 'unknown'
151
- */
152
- export function getPositionDirection(sizeString) {
153
- const sizeValue = parseFloat(sizeString);
154
- if (!Number.isFinite(sizeValue)) {
155
- return 'unknown';
156
- }
157
- if (sizeValue > 0) {
158
- return 'long';
159
- }
160
- if (sizeValue < 0) {
161
- return 'short';
162
- }
163
- return 'unknown';
164
- }
165
- //# sourceMappingURL=positionCalculations.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"positionCalculations.mjs","sourceRoot":"","sources":["../../src/utils/positionCalculations.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,qBAAqB,EAAE,qCAAiC;AA0BjE;;;;;;GAMG;AACH,MAAM,UAAU,kCAAkC,CAChD,MAAuC;IAEvC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAEtE,+BAA+B;IAC/B,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,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G,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC;AAChD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gCAAgC,CAC9C,SAAiB,EACjB,kBAA0B;IAE1B,IACE,KAAK,CAAC,SAAS,CAAC;QAChB,KAAK,CAAC,kBAAkB,CAAC;QACzB,kBAAkB,KAAK,CAAC,EACxB,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,UAAU,GAAG,CAAC,SAAS,GAAG,kBAAkB,CAAC,GAAG,GAAG,CAAC;IAC1D,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC;AAChD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,UAAkB;IAElB,MAAM,SAAS,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;IAEzC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAChC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;QAClB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;QAClB,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["/**\n * Position calculation utilities for closing positions\n */\nimport { CLOSE_POSITION_CONFIG } from '../constants/perpsConfig';\n\ntype CloseAmountFromPercentageParams = {\n percentage: number;\n positionSize: number;\n currentPrice: number;\n szDecimals: number;\n};\n\ntype CloseAmountLimitsParams = {\n amount: number;\n maxAmount: number;\n minAmount?: number;\n};\n\ntype CloseAmountDisplayParams = {\n value: string;\n displayMode: 'usd' | 'token';\n decimals?: number;\n};\n\ntype CloseValueParams = {\n amount: number;\n price: number;\n};\n\n/**\n * Calculate close amounts from percentage for both USD and token modes\n * Uses USD as source of truth with precision validation (matches order placement logic)\n *\n * @param params - Percentage, position size, current price, and asset-specific decimal precision\n * @returns Object with token amount and USD value\n */\nexport function calculateCloseAmountFromPercentage(\n params: CloseAmountFromPercentageParams,\n): { tokenAmount: number; usdValue: number } {\n const { percentage, positionSize, currentPrice, szDecimals } = params;\n\n // Validate required parameters\n if (szDecimals === undefined || szDecimals === null) {\n throw new Error('szDecimals is required for close position calculation');\n }\n if (szDecimals < 0) {\n throw new Error(`szDecimals must be >= 0, got: ${szDecimals}`);\n }\n\n if (\n isNaN(percentage) ||\n isNaN(positionSize) ||\n isNaN(currentPrice) ||\n percentage < 0 ||\n percentage > 100\n ) {\n return { tokenAmount: 0, usdValue: 0 };\n }\n\n // Calculate initial token amount and USD value\n let tokenAmount = (percentage / 100) * Math.abs(positionSize);\n const usdValue = tokenAmount * currentPrice;\n\n // Apply asset-specific decimal precision rounding\n const multiplier = Math.pow(10, szDecimals);\n tokenAmount = Math.round(tokenAmount * multiplier) / multiplier;\n\n // Ensure rounded size meets requested USD value (fix validation gap)\n // This matches the logic in calculatePositionSize for consistency\n const actualUsd = tokenAmount * currentPrice;\n if (actualUsd < usdValue) {\n // Add 1 minimum increment to meet requested USD\n tokenAmount += 1 / multiplier;\n }\n\n return {\n tokenAmount: Number(tokenAmount.toFixed(szDecimals)),\n usdValue: Number(usdValue.toFixed(CLOSE_POSITION_CONFIG.UsdDecimalPlaces)),\n };\n}\n\n/**\n * Validate and clamp close amount within limits\n *\n * @param params - Amount to validate, maximum allowed, and optional minimum\n * @returns Clamped amount within valid range\n */\nexport function validateCloseAmountLimits(\n params: CloseAmountLimitsParams,\n): number {\n const { amount, maxAmount, minAmount = 0 } = params;\n\n if (isNaN(amount) || amount < 0) {\n return 0;\n }\n\n return Math.max(minAmount, Math.min(amount, maxAmount));\n}\n\n/**\n * Format close amount for display based on mode and decimals\n *\n * @param params - Value string, display mode, and decimal places\n * @returns Formatted string with appropriate decimal precision\n */\nexport function formatCloseAmountDisplay(\n params: CloseAmountDisplayParams,\n): string {\n const { value, displayMode, decimals } = params;\n\n if (!value || value === '') {\n return '0';\n }\n\n const numericValue = parseFloat(value);\n if (isNaN(numericValue)) {\n return '0';\n }\n\n const decimalPlaces =\n decimals ??\n (displayMode === 'usd'\n ? CLOSE_POSITION_CONFIG.UsdDecimalPlaces\n : CLOSE_POSITION_CONFIG.AmountCalculationPrecision);\n\n // For USD mode, limit input to specified decimal places\n if (displayMode === 'usd' && value.includes('.')) {\n const parts = value.split('.');\n const integerPart = parts[0] || '0';\n const decimalPart = (parts[1] || '').slice(\n 0,\n CLOSE_POSITION_CONFIG.UsdDecimalPlaces,\n );\n return `${integerPart}${decimalPart ? `.${decimalPart}` : ''}`;\n }\n\n return numericValue.toFixed(decimalPlaces);\n}\n\n/**\n * Calculate USD value for a given token amount\n *\n * @param params - Token amount and current price\n * @returns USD value formatted to 2 decimal places\n */\nexport function calculateCloseValue(params: CloseValueParams): number {\n const { amount, price } = params;\n\n if (isNaN(amount) || isNaN(price) || amount < 0 || price <= 0) {\n return 0;\n }\n\n const value = amount * price;\n return Number(value.toFixed(CLOSE_POSITION_CONFIG.UsdDecimalPlaces));\n}\n\n/**\n * Formats a USD value for close amount display with proper decimal places\n * Uses the centralized USD_DECIMAL_PLACES configuration\n *\n * @param value - Raw USD value to format\n * @returns Formatted string with configured decimal places\n */\nexport function formatCloseAmountUSD(value: number): string {\n if (isNaN(value) || value < 0) {\n return '0';\n }\n return value.toFixed(CLOSE_POSITION_CONFIG.UsdDecimalPlaces);\n}\n\n/**\n * Calculate percentage from token amount\n *\n * @param tokenAmount - Amount in token units\n * @param totalPositionSize - Total position size in token units\n * @returns Percentage (0-100)\n */\nexport function calculatePercentageFromTokenAmount(\n tokenAmount: number,\n totalPositionSize: number,\n): number {\n if (\n isNaN(tokenAmount) ||\n isNaN(totalPositionSize) ||\n totalPositionSize === 0\n ) {\n return 0;\n }\n\n const percentage =\n (Math.abs(tokenAmount) / Math.abs(totalPositionSize)) * 100;\n return Math.max(0, Math.min(100, percentage));\n}\n\n/**\n * Calculate percentage from USD amount\n *\n * @param usdAmount - Amount in USD\n * @param totalPositionValue - Total position value in USD\n * @returns Percentage (0-100)\n */\nexport function calculatePercentageFromUSDAmount(\n usdAmount: number,\n totalPositionValue: number,\n): number {\n if (\n isNaN(usdAmount) ||\n isNaN(totalPositionValue) ||\n totalPositionValue === 0\n ) {\n return 0;\n }\n\n const percentage = (usdAmount / totalPositionValue) * 100;\n return Math.max(0, Math.min(100, percentage));\n}\n\n/**\n * Helper function to determine position direction based on size value\n *\n * @param sizeString - The position size as a string\n * @returns 'long', 'short', or 'unknown'\n */\nexport function getPositionDirection(\n sizeString: string,\n): 'long' | 'short' | 'unknown' {\n const sizeValue = parseFloat(sizeString);\n\n if (!Number.isFinite(sizeValue)) {\n return 'unknown';\n }\n\n if (sizeValue > 0) {\n return 'long';\n }\n\n if (sizeValue < 0) {\n return 'short';\n }\n\n return 'unknown';\n}\n"]}
@@ -1,88 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sortMarkets = void 0;
4
- const perpsConfig_1 = require("../constants/perpsConfig.cjs");
5
- /**
6
- * Parse volume string with magnitude suffixes (e.g., '$1.2B', '$850M')
7
- *
8
- * @param volume - Volume string with optional magnitude suffix
9
- * @returns Parsed numeric value
10
- */
11
- function parseVolume(volume) {
12
- if (!volume) {
13
- return 0;
14
- }
15
- // Remove $ and any whitespace
16
- const cleanedVolume = volume.replace(/[$,\s]/gu, '');
17
- // Match number with optional suffix (K, M, B, T)
18
- const match = cleanedVolume.match(/^([\d.]+)([KMBT])?$/iu);
19
- if (!match) {
20
- return 0;
21
- }
22
- const parsedValue = parseFloat(match[1]);
23
- const suffix = match[2]?.toUpperCase();
24
- const multipliers = {
25
- K: 1000,
26
- M: 1000000,
27
- B: 1000000000,
28
- T: 1000000000000,
29
- };
30
- return suffix ? parsedValue * (multipliers[suffix] ?? 1) : parsedValue;
31
- }
32
- /**
33
- * Sorts markets based on the specified criteria.
34
- * Uses object parameters pattern for maintainability.
35
- *
36
- * @param options - Sort options object
37
- * @param options.markets - Array of market data to sort
38
- * @param options.sortBy - Field to sort by (volume, priceChange, fundingRate, openInterest)
39
- * @param options.direction - Sort direction (asc or desc, defaults to desc)
40
- * @returns Sorted array of market data
41
- */
42
- const sortMarkets = ({ markets, sortBy, direction = perpsConfig_1.MARKET_SORTING_CONFIG.DefaultDirection, }) => {
43
- const sortedMarkets = [...markets];
44
- sortedMarkets.sort((marketA, marketB) => {
45
- let compareValue = 0;
46
- switch (sortBy) {
47
- case perpsConfig_1.MARKET_SORTING_CONFIG.SortFields.Volume: {
48
- // Parse volume strings with magnitude suffixes (e.g., '$1.2B', '$850M')
49
- const volumeA = parseVolume(marketA.volume);
50
- const volumeB = parseVolume(marketB.volume);
51
- compareValue = volumeA - volumeB;
52
- break;
53
- }
54
- case perpsConfig_1.MARKET_SORTING_CONFIG.SortFields.PriceChange: {
55
- // Use 24h price change percentage (e.g., '+2.5%', '-1.8%')
56
- // Parse and remove % sign
57
- const changeA = parseFloat(marketA.change24hPercent?.replace(/[%+]/gu, '') || '0');
58
- const changeB = parseFloat(marketB.change24hPercent?.replace(/[%+]/gu, '') || '0');
59
- compareValue = changeA - changeB;
60
- break;
61
- }
62
- case perpsConfig_1.MARKET_SORTING_CONFIG.SortFields.FundingRate: {
63
- // Funding rate is a number (not string)
64
- const fundingA = marketA.fundingRate ?? 0;
65
- const fundingB = marketB.fundingRate ?? 0;
66
- compareValue = fundingA - fundingB;
67
- break;
68
- }
69
- case perpsConfig_1.MARKET_SORTING_CONFIG.SortFields.OpenInterest: {
70
- // Parse open interest strings (similar to volume)
71
- const openInterestA = parseVolume(marketA.openInterest);
72
- const openInterestB = parseVolume(marketB.openInterest);
73
- compareValue = openInterestA - openInterestB;
74
- break;
75
- }
76
- default:
77
- // Unsupported sort field - maintain current order (compareValue remains 0)
78
- break;
79
- }
80
- // Apply sort direction
81
- return direction === perpsConfig_1.MARKET_SORTING_CONFIG.DefaultDirection
82
- ? compareValue * -1 // desc (larger first)
83
- : compareValue; // asc (smaller first)
84
- });
85
- return sortedMarkets;
86
- };
87
- exports.sortMarkets = sortMarkets;
88
- //# sourceMappingURL=sortMarkets.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sortMarkets.cjs","sourceRoot":"","sources":["../../src/utils/sortMarkets.ts"],"names":[],"mappings":";;;AAAA,8DAAiE;AAgBjE;;;;;GAKG;AACH,SAAS,WAAW,CAAC,MAA0B;IAC7C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,CAAC;IACX,CAAC;IAED,8BAA8B;IAC9B,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAErD,iDAAiD;IACjD,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,WAAW,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;IAEvC,MAAM,WAAW,GAA2B;QAC1C,CAAC,EAAE,IAAK;QACR,CAAC,EAAE,OAAS;QACZ,CAAC,EAAE,UAAa;QAChB,CAAC,EAAE,aAAiB;KACrB,CAAC;IAEF,OAAO,MAAM,CAAC,CAAC,CAAC,WAAW,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;AACzE,CAAC;AAED;;;;;;;;;GASG;AACI,MAAM,WAAW,GAAG,CAAC,EAC1B,OAAO,EACP,MAAM,EACN,SAAS,GAAG,mCAAqB,CAAC,gBAAgB,GAChC,EAAqB,EAAE;IACzC,MAAM,aAAa,GAAG,CAAC,GAAG,OAAO,CAAC,C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,YAAY,CAAC,CAAC;gBACxD,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;gBACxD,YAAY,GAAG,aAAa,GAAG,aAAa,CAAC;gBAC7C,MAAM;YACR,CAAC;YAED;gBACE,2EAA2E;gBAC3E,MAAM;QACV,CAAC;QAED,uBAAuB;QACvB,OAAO,SAAS,KAAK,mCAAqB,CAAC,gBAAgB;YACzD,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,sBAAsB;YAC1C,CAAC,CAAC,YAAY,CAAC,CAAC,sBAAsB;IAC1C,CAAC,CAAC,CAAC;IAEH,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AA5DW,QAAA,WAAW,eA4DtB","sourcesContent":["import { MARKET_SORTING_CONFIG } from '../constants/perpsConfig';\nimport type { PerpsMarketData } from '../types';\n\nexport type SortField =\n | 'volume'\n | 'priceChange'\n | 'fundingRate'\n | 'openInterest';\nexport type SortDirection = 'asc' | 'desc';\n\ntype SortMarketsParams = {\n markets: PerpsMarketData[];\n sortBy: SortField;\n direction?: SortDirection;\n};\n\n/**\n * Parse volume string with magnitude suffixes (e.g., '$1.2B', '$850M')\n *\n * @param volume - Volume string with optional magnitude suffix\n * @returns Parsed numeric value\n */\nfunction parseVolume(volume: string | undefined): number {\n if (!volume) {\n return 0;\n }\n\n // Remove $ and any whitespace\n const cleanedVolume = volume.replace(/[$,\\s]/gu, '');\n\n // Match number with optional suffix (K, M, B, T)\n const match = cleanedVolume.match(/^([\\d.]+)([KMBT])?$/iu);\n if (!match) {\n return 0;\n }\n\n const parsedValue = parseFloat(match[1]);\n const suffix = match[2]?.toUpperCase();\n\n const multipliers: Record<string, number> = {\n K: 1_000,\n M: 1_000_000,\n B: 1_000_000_000,\n T: 1_000_000_000_000,\n };\n\n return suffix ? parsedValue * (multipliers[suffix] ?? 1) : parsedValue;\n}\n\n/**\n * Sorts markets based on the specified criteria.\n * Uses object parameters pattern for maintainability.\n *\n * @param options - Sort options object\n * @param options.markets - Array of market data to sort\n * @param options.sortBy - Field to sort by (volume, priceChange, fundingRate, openInterest)\n * @param options.direction - Sort direction (asc or desc, defaults to desc)\n * @returns Sorted array of market data\n */\nexport const sortMarkets = ({\n markets,\n sortBy,\n direction = MARKET_SORTING_CONFIG.DefaultDirection,\n}: SortMarketsParams): PerpsMarketData[] => {\n const sortedMarkets = [...markets];\n\n sortedMarkets.sort((marketA, marketB) => {\n let compareValue = 0;\n\n switch (sortBy) {\n case MARKET_SORTING_CONFIG.SortFields.Volume: {\n // Parse volume strings with magnitude suffixes (e.g., '$1.2B', '$850M')\n const volumeA = parseVolume(marketA.volume);\n const volumeB = parseVolume(marketB.volume);\n compareValue = volumeA - volumeB;\n break;\n }\n\n case MARKET_SORTING_CONFIG.SortFields.PriceChange: {\n // Use 24h price change percentage (e.g., '+2.5%', '-1.8%')\n // Parse and remove % sign\n const changeA = parseFloat(\n marketA.change24hPercent?.replace(/[%+]/gu, '') || '0',\n );\n const changeB = parseFloat(\n marketB.change24hPercent?.replace(/[%+]/gu, '') || '0',\n );\n compareValue = changeA - changeB;\n break;\n }\n\n case MARKET_SORTING_CONFIG.SortFields.FundingRate: {\n // Funding rate is a number (not string)\n const fundingA = marketA.fundingRate ?? 0;\n const fundingB = marketB.fundingRate ?? 0;\n compareValue = fundingA - fundingB;\n break;\n }\n\n case MARKET_SORTING_CONFIG.SortFields.OpenInterest: {\n // Parse open interest strings (similar to volume)\n const openInterestA = parseVolume(marketA.openInterest);\n const openInterestB = parseVolume(marketB.openInterest);\n compareValue = openInterestA - openInterestB;\n break;\n }\n\n default:\n // Unsupported sort field - maintain current order (compareValue remains 0)\n break;\n }\n\n // Apply sort direction\n return direction === MARKET_SORTING_CONFIG.DefaultDirection\n ? compareValue * -1 // desc (larger first)\n : compareValue; // asc (smaller first)\n });\n\n return sortedMarkets;\n};\n"]}
@@ -1,21 +0,0 @@
1
- import type { PerpsMarketData } from "../types/index.cjs";
2
- export type SortField = 'volume' | 'priceChange' | 'fundingRate' | 'openInterest';
3
- export type SortDirection = 'asc' | 'desc';
4
- type SortMarketsParams = {
5
- markets: PerpsMarketData[];
6
- sortBy: SortField;
7
- direction?: SortDirection;
8
- };
9
- /**
10
- * Sorts markets based on the specified criteria.
11
- * Uses object parameters pattern for maintainability.
12
- *
13
- * @param options - Sort options object
14
- * @param options.markets - Array of market data to sort
15
- * @param options.sortBy - Field to sort by (volume, priceChange, fundingRate, openInterest)
16
- * @param options.direction - Sort direction (asc or desc, defaults to desc)
17
- * @returns Sorted array of market data
18
- */
19
- export declare const sortMarkets: ({ markets, sortBy, direction, }: SortMarketsParams) => PerpsMarketData[];
20
- export {};
21
- //# sourceMappingURL=sortMarkets.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sortMarkets.d.cts","sourceRoot":"","sources":["../../src/utils/sortMarkets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,2BAAiB;AAEhD,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,aAAa,GACb,aAAa,GACb,cAAc,CAAC;AACnB,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,CAAC;AAE3C,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,MAAM,EAAE,SAAS,CAAC;IAClB,SAAS,CAAC,EAAE,aAAa,CAAC;CAC3B,CAAC;AAmCF;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,oCAIrB,iBAAiB,KAAG,eAAe,EAwDrC,CAAC"}
@@ -1,21 +0,0 @@
1
- import type { PerpsMarketData } from "../types/index.mjs";
2
- export type SortField = 'volume' | 'priceChange' | 'fundingRate' | 'openInterest';
3
- export type SortDirection = 'asc' | 'desc';
4
- type SortMarketsParams = {
5
- markets: PerpsMarketData[];
6
- sortBy: SortField;
7
- direction?: SortDirection;
8
- };
9
- /**
10
- * Sorts markets based on the specified criteria.
11
- * Uses object parameters pattern for maintainability.
12
- *
13
- * @param options - Sort options object
14
- * @param options.markets - Array of market data to sort
15
- * @param options.sortBy - Field to sort by (volume, priceChange, fundingRate, openInterest)
16
- * @param options.direction - Sort direction (asc or desc, defaults to desc)
17
- * @returns Sorted array of market data
18
- */
19
- export declare const sortMarkets: ({ markets, sortBy, direction, }: SortMarketsParams) => PerpsMarketData[];
20
- export {};
21
- //# sourceMappingURL=sortMarkets.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sortMarkets.d.mts","sourceRoot":"","sources":["../../src/utils/sortMarkets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,2BAAiB;AAEhD,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,aAAa,GACb,aAAa,GACb,cAAc,CAAC;AACnB,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,CAAC;AAE3C,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,MAAM,EAAE,SAAS,CAAC;IAClB,SAAS,CAAC,EAAE,aAAa,CAAC;CAC3B,CAAC;AAmCF;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,oCAIrB,iBAAiB,KAAG,eAAe,EAwDrC,CAAC"}
@@ -1,84 +0,0 @@
1
- import { MARKET_SORTING_CONFIG } from "../constants/perpsConfig.mjs";
2
- /**
3
- * Parse volume string with magnitude suffixes (e.g., '$1.2B', '$850M')
4
- *
5
- * @param volume - Volume string with optional magnitude suffix
6
- * @returns Parsed numeric value
7
- */
8
- function parseVolume(volume) {
9
- if (!volume) {
10
- return 0;
11
- }
12
- // Remove $ and any whitespace
13
- const cleanedVolume = volume.replace(/[$,\s]/gu, '');
14
- // Match number with optional suffix (K, M, B, T)
15
- const match = cleanedVolume.match(/^([\d.]+)([KMBT])?$/iu);
16
- if (!match) {
17
- return 0;
18
- }
19
- const parsedValue = parseFloat(match[1]);
20
- const suffix = match[2]?.toUpperCase();
21
- const multipliers = {
22
- K: 1000,
23
- M: 1000000,
24
- B: 1000000000,
25
- T: 1000000000000,
26
- };
27
- return suffix ? parsedValue * (multipliers[suffix] ?? 1) : parsedValue;
28
- }
29
- /**
30
- * Sorts markets based on the specified criteria.
31
- * Uses object parameters pattern for maintainability.
32
- *
33
- * @param options - Sort options object
34
- * @param options.markets - Array of market data to sort
35
- * @param options.sortBy - Field to sort by (volume, priceChange, fundingRate, openInterest)
36
- * @param options.direction - Sort direction (asc or desc, defaults to desc)
37
- * @returns Sorted array of market data
38
- */
39
- export const sortMarkets = ({ markets, sortBy, direction = MARKET_SORTING_CONFIG.DefaultDirection, }) => {
40
- const sortedMarkets = [...markets];
41
- sortedMarkets.sort((marketA, marketB) => {
42
- let compareValue = 0;
43
- switch (sortBy) {
44
- case MARKET_SORTING_CONFIG.SortFields.Volume: {
45
- // Parse volume strings with magnitude suffixes (e.g., '$1.2B', '$850M')
46
- const volumeA = parseVolume(marketA.volume);
47
- const volumeB = parseVolume(marketB.volume);
48
- compareValue = volumeA - volumeB;
49
- break;
50
- }
51
- case MARKET_SORTING_CONFIG.SortFields.PriceChange: {
52
- // Use 24h price change percentage (e.g., '+2.5%', '-1.8%')
53
- // Parse and remove % sign
54
- const changeA = parseFloat(marketA.change24hPercent?.replace(/[%+]/gu, '') || '0');
55
- const changeB = parseFloat(marketB.change24hPercent?.replace(/[%+]/gu, '') || '0');
56
- compareValue = changeA - changeB;
57
- break;
58
- }
59
- case MARKET_SORTING_CONFIG.SortFields.FundingRate: {
60
- // Funding rate is a number (not string)
61
- const fundingA = marketA.fundingRate ?? 0;
62
- const fundingB = marketB.fundingRate ?? 0;
63
- compareValue = fundingA - fundingB;
64
- break;
65
- }
66
- case MARKET_SORTING_CONFIG.SortFields.OpenInterest: {
67
- // Parse open interest strings (similar to volume)
68
- const openInterestA = parseVolume(marketA.openInterest);
69
- const openInterestB = parseVolume(marketB.openInterest);
70
- compareValue = openInterestA - openInterestB;
71
- break;
72
- }
73
- default:
74
- // Unsupported sort field - maintain current order (compareValue remains 0)
75
- break;
76
- }
77
- // Apply sort direction
78
- return direction === MARKET_SORTING_CONFIG.DefaultDirection
79
- ? compareValue * -1 // desc (larger first)
80
- : compareValue; // asc (smaller first)
81
- });
82
- return sortedMarkets;
83
- };
84
- //# sourceMappingURL=sortMarkets.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sortMarkets.mjs","sourceRoot":"","sources":["../../src/utils/sortMarkets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,qCAAiC;AAgBjE;;;;;GAKG;AACH,SAAS,WAAW,CAAC,MAA0B;IAC7C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,CAAC;IACX,CAAC;IAED,8BAA8B;IAC9B,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAErD,iDAAiD;IACjD,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,WAAW,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;IAEvC,MAAM,WAAW,GAA2B;QAC1C,CAAC,EAAE,IAAK;QACR,CAAC,EAAE,OAAS;QACZ,CAAC,EAAE,UAAa;QAChB,CAAC,EAAE,aAAiB;KACrB,CAAC;IAEF,OAAO,MAAM,CAAC,CAAC,CAAC,WAAW,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;AACzE,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAC1B,OAAO,EACP,MAAM,EACN,SAAS,GAAG,qBAAqB,CAAC,gBAAgB,GAChC,EAAqB,EAA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kD;gBAClD,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;gBACxD,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;gBACxD,YAAY,GAAG,aAAa,GAAG,aAAa,CAAC;gBAC7C,MAAM;YACR,CAAC;YAED;gBACE,2EAA2E;gBAC3E,MAAM;QACV,CAAC;QAED,uBAAuB;QACvB,OAAO,SAAS,KAAK,qBAAqB,CAAC,gBAAgB;YACzD,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,sBAAsB;YAC1C,CAAC,CAAC,YAAY,CAAC,CAAC,sBAAsB;IAC1C,CAAC,CAAC,CAAC;IAEH,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC","sourcesContent":["import { MARKET_SORTING_CONFIG } from '../constants/perpsConfig';\nimport type { PerpsMarketData } from '../types';\n\nexport type SortField =\n | 'volume'\n | 'priceChange'\n | 'fundingRate'\n | 'openInterest';\nexport type SortDirection = 'asc' | 'desc';\n\ntype SortMarketsParams = {\n markets: PerpsMarketData[];\n sortBy: SortField;\n direction?: SortDirection;\n};\n\n/**\n * Parse volume string with magnitude suffixes (e.g., '$1.2B', '$850M')\n *\n * @param volume - Volume string with optional magnitude suffix\n * @returns Parsed numeric value\n */\nfunction parseVolume(volume: string | undefined): number {\n if (!volume) {\n return 0;\n }\n\n // Remove $ and any whitespace\n const cleanedVolume = volume.replace(/[$,\\s]/gu, '');\n\n // Match number with optional suffix (K, M, B, T)\n const match = cleanedVolume.match(/^([\\d.]+)([KMBT])?$/iu);\n if (!match) {\n return 0;\n }\n\n const parsedValue = parseFloat(match[1]);\n const suffix = match[2]?.toUpperCase();\n\n const multipliers: Record<string, number> = {\n K: 1_000,\n M: 1_000_000,\n B: 1_000_000_000,\n T: 1_000_000_000_000,\n };\n\n return suffix ? parsedValue * (multipliers[suffix] ?? 1) : parsedValue;\n}\n\n/**\n * Sorts markets based on the specified criteria.\n * Uses object parameters pattern for maintainability.\n *\n * @param options - Sort options object\n * @param options.markets - Array of market data to sort\n * @param options.sortBy - Field to sort by (volume, priceChange, fundingRate, openInterest)\n * @param options.direction - Sort direction (asc or desc, defaults to desc)\n * @returns Sorted array of market data\n */\nexport const sortMarkets = ({\n markets,\n sortBy,\n direction = MARKET_SORTING_CONFIG.DefaultDirection,\n}: SortMarketsParams): PerpsMarketData[] => {\n const sortedMarkets = [...markets];\n\n sortedMarkets.sort((marketA, marketB) => {\n let compareValue = 0;\n\n switch (sortBy) {\n case MARKET_SORTING_CONFIG.SortFields.Volume: {\n // Parse volume strings with magnitude suffixes (e.g., '$1.2B', '$850M')\n const volumeA = parseVolume(marketA.volume);\n const volumeB = parseVolume(marketB.volume);\n compareValue = volumeA - volumeB;\n break;\n }\n\n case MARKET_SORTING_CONFIG.SortFields.PriceChange: {\n // Use 24h price change percentage (e.g., '+2.5%', '-1.8%')\n // Parse and remove % sign\n const changeA = parseFloat(\n marketA.change24hPercent?.replace(/[%+]/gu, '') || '0',\n );\n const changeB = parseFloat(\n marketB.change24hPercent?.replace(/[%+]/gu, '') || '0',\n );\n compareValue = changeA - changeB;\n break;\n }\n\n case MARKET_SORTING_CONFIG.SortFields.FundingRate: {\n // Funding rate is a number (not string)\n const fundingA = marketA.fundingRate ?? 0;\n const fundingB = marketB.fundingRate ?? 0;\n compareValue = fundingA - fundingB;\n break;\n }\n\n case MARKET_SORTING_CONFIG.SortFields.OpenInterest: {\n // Parse open interest strings (similar to volume)\n const openInterestA = parseVolume(marketA.openInterest);\n const openInterestB = parseVolume(marketB.openInterest);\n compareValue = openInterestA - openInterestB;\n break;\n }\n\n default:\n // Unsupported sort field - maintain current order (compareValue remains 0)\n break;\n }\n\n // Apply sort direction\n return direction === MARKET_SORTING_CONFIG.DefaultDirection\n ? compareValue * -1 // desc (larger first)\n : compareValue; // asc (smaller first)\n });\n\n return sortedMarkets;\n};\n"]}
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createStandaloneInfoClient = void 0;
4
- const hyperliquid_1 = require("@nktkas/hyperliquid");
5
- const perpsConfig_1 = require("../constants/perpsConfig.cjs");
6
- /**
7
- * Creates a standalone InfoClient for lightweight read-only queries.
8
- * Does not require full perps initialization (no wallet, WebSocket, etc.)
9
- *
10
- * Use cases:
11
- * - Discovery queries (checking if perps market exists)
12
- * - Portfolio analytics outside perps context
13
- * - Price feeds without full initialization
14
- *
15
- * @param options - Configuration options
16
- * @param options.isTestnet - Whether to use testnet API endpoint
17
- * @param options.timeout - Request timeout in ms (default: CONNECTION_TIMEOUT_MS)
18
- * @returns InfoClient instance
19
- * @example
20
- * ```typescript
21
- * const infoClient = createStandaloneInfoClient({ isTestnet: false });
22
- * const meta = await infoClient.meta();
23
- * ```
24
- */
25
- const createStandaloneInfoClient = (options) => {
26
- const { isTestnet, timeout = perpsConfig_1.PERPS_CONSTANTS.ConnectionTimeoutMs } = options;
27
- const httpTransport = new hyperliquid_1.HttpTransport({
28
- isTestnet,
29
- timeout,
30
- });
31
- return new hyperliquid_1.InfoClient({ transport: httpTransport });
32
- };
33
- exports.createStandaloneInfoClient = createStandaloneInfoClient;
34
- //# sourceMappingURL=standaloneInfoClient.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"standaloneInfoClient.cjs","sourceRoot":"","sources":["../../src/utils/standaloneInfoClient.ts"],"names":[],"mappings":";;;AAAA,qDAAgE;AAEhE,8DAA2D;AAY3D;;;;;;;;;;;;;;;;;;GAkBG;AACI,MAAM,0BAA0B,GAAG,CACxC,OAAoC,EACxB,EAAE;IACd,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,6BAAe,CAAC,mBAAmB,EAAE,GAAG,OAAO,CAAC;IAE7E,MAAM,aAAa,GAAG,IAAI,2BAAa,CAAC;QACtC,SAAS;QACT,OAAO;KACR,CAAC,CAAC;IAEH,OAAO,IAAI,wBAAU,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC;AACtD,CAAC,CAAC;AAXW,QAAA,0BAA0B,8BAWrC","sourcesContent":["import { HttpTransport, InfoClient } from '@nktkas/hyperliquid';\n\nimport { PERPS_CONSTANTS } from '../constants/perpsConfig';\n\n/**\n * Options for creating a standalone info client.\n */\nexport type StandaloneInfoClientOptions = {\n /** Whether to use testnet API endpoint */\n isTestnet: boolean;\n /** Request timeout in ms (default: CONNECTION_TIMEOUT_MS) */\n timeout?: number;\n};\n\n/**\n * Creates a standalone InfoClient for lightweight read-only queries.\n * Does not require full perps initialization (no wallet, WebSocket, etc.)\n *\n * Use cases:\n * - Discovery queries (checking if perps market exists)\n * - Portfolio analytics outside perps context\n * - Price feeds without full initialization\n *\n * @param options - Configuration options\n * @param options.isTestnet - Whether to use testnet API endpoint\n * @param options.timeout - Request timeout in ms (default: CONNECTION_TIMEOUT_MS)\n * @returns InfoClient instance\n * @example\n * ```typescript\n * const infoClient = createStandaloneInfoClient({ isTestnet: false });\n * const meta = await infoClient.meta();\n * ```\n */\nexport const createStandaloneInfoClient = (\n options: StandaloneInfoClientOptions,\n): InfoClient => {\n const { isTestnet, timeout = PERPS_CONSTANTS.ConnectionTimeoutMs } = options;\n\n const httpTransport = new HttpTransport({\n isTestnet,\n timeout,\n });\n\n return new InfoClient({ transport: httpTransport });\n};\n"]}
@@ -1,31 +0,0 @@
1
- import { InfoClient } from "@nktkas/hyperliquid";
2
- /**
3
- * Options for creating a standalone info client.
4
- */
5
- export type StandaloneInfoClientOptions = {
6
- /** Whether to use testnet API endpoint */
7
- isTestnet: boolean;
8
- /** Request timeout in ms (default: CONNECTION_TIMEOUT_MS) */
9
- timeout?: number;
10
- };
11
- /**
12
- * Creates a standalone InfoClient for lightweight read-only queries.
13
- * Does not require full perps initialization (no wallet, WebSocket, etc.)
14
- *
15
- * Use cases:
16
- * - Discovery queries (checking if perps market exists)
17
- * - Portfolio analytics outside perps context
18
- * - Price feeds without full initialization
19
- *
20
- * @param options - Configuration options
21
- * @param options.isTestnet - Whether to use testnet API endpoint
22
- * @param options.timeout - Request timeout in ms (default: CONNECTION_TIMEOUT_MS)
23
- * @returns InfoClient instance
24
- * @example
25
- * ```typescript
26
- * const infoClient = createStandaloneInfoClient({ isTestnet: false });
27
- * const meta = await infoClient.meta();
28
- * ```
29
- */
30
- export declare const createStandaloneInfoClient: (options: StandaloneInfoClientOptions) => InfoClient;
31
- //# sourceMappingURL=standaloneInfoClient.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"standaloneInfoClient.d.cts","sourceRoot":"","sources":["../../src/utils/standaloneInfoClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAE,4BAA4B;AAIhE;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,0CAA0C;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,0BAA0B,YAC5B,2BAA2B,KACnC,UASF,CAAC"}
@@ -1,31 +0,0 @@
1
- import { InfoClient } from "@nktkas/hyperliquid";
2
- /**
3
- * Options for creating a standalone info client.
4
- */
5
- export type StandaloneInfoClientOptions = {
6
- /** Whether to use testnet API endpoint */
7
- isTestnet: boolean;
8
- /** Request timeout in ms (default: CONNECTION_TIMEOUT_MS) */
9
- timeout?: number;
10
- };
11
- /**
12
- * Creates a standalone InfoClient for lightweight read-only queries.
13
- * Does not require full perps initialization (no wallet, WebSocket, etc.)
14
- *
15
- * Use cases:
16
- * - Discovery queries (checking if perps market exists)
17
- * - Portfolio analytics outside perps context
18
- * - Price feeds without full initialization
19
- *
20
- * @param options - Configuration options
21
- * @param options.isTestnet - Whether to use testnet API endpoint
22
- * @param options.timeout - Request timeout in ms (default: CONNECTION_TIMEOUT_MS)
23
- * @returns InfoClient instance
24
- * @example
25
- * ```typescript
26
- * const infoClient = createStandaloneInfoClient({ isTestnet: false });
27
- * const meta = await infoClient.meta();
28
- * ```
29
- */
30
- export declare const createStandaloneInfoClient: (options: StandaloneInfoClientOptions) => InfoClient;
31
- //# sourceMappingURL=standaloneInfoClient.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"standaloneInfoClient.d.mts","sourceRoot":"","sources":["../../src/utils/standaloneInfoClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAE,4BAA4B;AAIhE;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,0CAA0C;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,0BAA0B,YAC5B,2BAA2B,KACnC,UASF,CAAC"}
@@ -1,30 +0,0 @@
1
- import { HttpTransport, InfoClient } from "@nktkas/hyperliquid";
2
- import { PERPS_CONSTANTS } from "../constants/perpsConfig.mjs";
3
- /**
4
- * Creates a standalone InfoClient for lightweight read-only queries.
5
- * Does not require full perps initialization (no wallet, WebSocket, etc.)
6
- *
7
- * Use cases:
8
- * - Discovery queries (checking if perps market exists)
9
- * - Portfolio analytics outside perps context
10
- * - Price feeds without full initialization
11
- *
12
- * @param options - Configuration options
13
- * @param options.isTestnet - Whether to use testnet API endpoint
14
- * @param options.timeout - Request timeout in ms (default: CONNECTION_TIMEOUT_MS)
15
- * @returns InfoClient instance
16
- * @example
17
- * ```typescript
18
- * const infoClient = createStandaloneInfoClient({ isTestnet: false });
19
- * const meta = await infoClient.meta();
20
- * ```
21
- */
22
- export const createStandaloneInfoClient = (options) => {
23
- const { isTestnet, timeout = PERPS_CONSTANTS.ConnectionTimeoutMs } = options;
24
- const httpTransport = new HttpTransport({
25
- isTestnet,
26
- timeout,
27
- });
28
- return new InfoClient({ transport: httpTransport });
29
- };
30
- //# sourceMappingURL=standaloneInfoClient.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"standaloneInfoClient.mjs","sourceRoot":"","sources":["../../src/utils/standaloneInfoClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,4BAA4B;AAEhE,OAAO,EAAE,eAAe,EAAE,qCAAiC;AAY3D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,OAAoC,EACxB,EAAE;IACd,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,eAAe,CAAC,mBAAmB,EAAE,GAAG,OAAO,CAAC;IAE7E,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC;QACtC,SAAS;QACT,OAAO;KACR,CAAC,CAAC;IAEH,OAAO,IAAI,UAAU,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC;AACtD,CAAC,CAAC","sourcesContent":["import { HttpTransport, InfoClient } from '@nktkas/hyperliquid';\n\nimport { PERPS_CONSTANTS } from '../constants/perpsConfig';\n\n/**\n * Options for creating a standalone info client.\n */\nexport type StandaloneInfoClientOptions = {\n /** Whether to use testnet API endpoint */\n isTestnet: boolean;\n /** Request timeout in ms (default: CONNECTION_TIMEOUT_MS) */\n timeout?: number;\n};\n\n/**\n * Creates a standalone InfoClient for lightweight read-only queries.\n * Does not require full perps initialization (no wallet, WebSocket, etc.)\n *\n * Use cases:\n * - Discovery queries (checking if perps market exists)\n * - Portfolio analytics outside perps context\n * - Price feeds without full initialization\n *\n * @param options - Configuration options\n * @param options.isTestnet - Whether to use testnet API endpoint\n * @param options.timeout - Request timeout in ms (default: CONNECTION_TIMEOUT_MS)\n * @returns InfoClient instance\n * @example\n * ```typescript\n * const infoClient = createStandaloneInfoClient({ isTestnet: false });\n * const meta = await infoClient.meta();\n * ```\n */\nexport const createStandaloneInfoClient = (\n options: StandaloneInfoClientOptions,\n): InfoClient => {\n const { isTestnet, timeout = PERPS_CONSTANTS.ConnectionTimeoutMs } = options;\n\n const httpTransport = new HttpTransport({\n isTestnet,\n timeout,\n });\n\n return new InfoClient({ transport: httpTransport });\n};\n"]}
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseCommaSeparatedString = exports.stripQuotes = void 0;
4
- /**
5
- * Strip surrounding quotes from a string (handles both single and double quotes)
6
- * Use this to clean up values that may have been JSON-encoded with extra quotes
7
- *
8
- * @param str - String to strip quotes from
9
- * @returns String with surrounding quotes removed, or unchanged if no matching quotes
10
- *
11
- * @example
12
- * stripQuotes('"xyz"') // returns "xyz"
13
- * stripQuotes("'abc'") // returns "abc"
14
- * stripQuotes('xyz') // returns "xyz" (unchanged)
15
- */
16
- const stripQuotes = (str) => {
17
- if ((str.startsWith('"') && str.endsWith('"')) ||
18
- (str.startsWith("'") && str.endsWith("'"))) {
19
- return str.slice(1, -1);
20
- }
21
- return str;
22
- };
23
- exports.stripQuotes = stripQuotes;
24
- /**
25
- * Parse comma-separated string into array of trimmed non-empty values
26
- * Commonly used for LaunchDarkly feature flag list values
27
- *
28
- * Note: This function only handles parsing and trimming. If your values may
29
- * contain surrounding quotes (e.g., from LaunchDarkly JSON encoding), apply
30
- * stripQuotes separately: `parseCommaSeparatedString(value).map(stripQuotes)`
31
- *
32
- * @param value - Comma-separated string
33
- * @returns Array of trimmed non-empty strings
34
- *
35
- * @example Basic usage
36
- * parseCommaSeparatedString("xyz:*, abc:TSLA") // returns ["xyz:*", "abc:TSLA"]
37
- *
38
- * @example Empty string
39
- * parseCommaSeparatedString("") // returns []
40
- *
41
- * @example Whitespace handling
42
- * parseCommaSeparatedString(" , , xyz ") // returns ["xyz"]
43
- */
44
- const parseCommaSeparatedString = (value) => value
45
- .split(',')
46
- .map((item) => item.trim())
47
- .filter((item) => item.length > 0);
48
- exports.parseCommaSeparatedString = parseCommaSeparatedString;
49
- //# sourceMappingURL=stringParseUtils.cjs.map