@metamask-previews/perps-controller 0.0.0-preview-685dbf46b → 1.0.0-preview-bc00f2c

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 (482) hide show
  1. package/CHANGELOG.md +30 -2
  2. package/dist/PerpsController.cjs +3077 -65
  3. package/dist/PerpsController.cjs.map +1 -1
  4. package/dist/PerpsController.d.cts +969 -82
  5. package/dist/PerpsController.d.cts.map +1 -1
  6. package/dist/PerpsController.d.mts +969 -82
  7. package/dist/PerpsController.d.mts.map +1 -1
  8. package/dist/PerpsController.mjs +3073 -62
  9. package/dist/PerpsController.mjs.map +1 -1
  10. package/dist/aggregation/SubscriptionMultiplexer.cjs +441 -0
  11. package/dist/aggregation/SubscriptionMultiplexer.cjs.map +1 -0
  12. package/dist/aggregation/SubscriptionMultiplexer.d.cts +171 -0
  13. package/dist/aggregation/SubscriptionMultiplexer.d.cts.map +1 -0
  14. package/dist/aggregation/SubscriptionMultiplexer.d.mts +171 -0
  15. package/dist/aggregation/SubscriptionMultiplexer.d.mts.map +1 -0
  16. package/dist/aggregation/SubscriptionMultiplexer.mjs +437 -0
  17. package/dist/aggregation/SubscriptionMultiplexer.mjs.map +1 -0
  18. package/dist/aggregation/index.cjs +9 -0
  19. package/dist/aggregation/index.cjs.map +1 -0
  20. package/dist/aggregation/index.d.cts +6 -0
  21. package/dist/aggregation/index.d.cts.map +1 -0
  22. package/dist/aggregation/index.d.mts +6 -0
  23. package/dist/aggregation/index.d.mts.map +1 -0
  24. package/dist/aggregation/index.mjs +5 -0
  25. package/dist/aggregation/index.mjs.map +1 -0
  26. package/dist/constants/chartConfig.cjs +227 -0
  27. package/dist/constants/chartConfig.cjs.map +1 -0
  28. package/dist/constants/chartConfig.d.cts +216 -0
  29. package/dist/constants/chartConfig.d.cts.map +1 -0
  30. package/dist/constants/chartConfig.d.mts +216 -0
  31. package/dist/constants/chartConfig.d.mts.map +1 -0
  32. package/dist/constants/chartConfig.mjs +221 -0
  33. package/dist/constants/chartConfig.mjs.map +1 -0
  34. package/dist/constants/eventNames.cjs +436 -0
  35. package/dist/constants/eventNames.cjs.map +1 -0
  36. package/dist/constants/eventNames.d.cts +387 -0
  37. package/dist/constants/eventNames.d.cts.map +1 -0
  38. package/dist/constants/eventNames.d.mts +387 -0
  39. package/dist/constants/eventNames.d.mts.map +1 -0
  40. package/dist/constants/eventNames.mjs +433 -0
  41. package/dist/constants/eventNames.mjs.map +1 -0
  42. package/dist/constants/hyperLiquidConfig.cjs +380 -0
  43. package/dist/constants/hyperLiquidConfig.cjs.map +1 -0
  44. package/dist/constants/hyperLiquidConfig.d.cts +236 -0
  45. package/dist/constants/hyperLiquidConfig.d.cts.map +1 -0
  46. package/dist/constants/hyperLiquidConfig.d.mts +236 -0
  47. package/dist/constants/hyperLiquidConfig.d.mts.map +1 -0
  48. package/dist/constants/hyperLiquidConfig.mjs +371 -0
  49. package/dist/constants/hyperLiquidConfig.mjs.map +1 -0
  50. package/dist/constants/index.cjs +28 -0
  51. package/dist/constants/index.cjs.map +1 -0
  52. package/dist/constants/index.d.cts +12 -0
  53. package/dist/constants/index.d.cts.map +1 -0
  54. package/dist/constants/index.d.mts +12 -0
  55. package/dist/constants/index.d.mts.map +1 -0
  56. package/dist/constants/index.mjs +12 -0
  57. package/dist/constants/index.mjs.map +1 -0
  58. package/dist/constants/myxConfig.cjs +229 -0
  59. package/dist/constants/myxConfig.cjs.map +1 -0
  60. package/dist/constants/myxConfig.d.cts +106 -0
  61. package/dist/constants/myxConfig.d.cts.map +1 -0
  62. package/dist/constants/myxConfig.d.mts +106 -0
  63. package/dist/constants/myxConfig.d.mts.map +1 -0
  64. package/dist/constants/myxConfig.mjs +219 -0
  65. package/dist/constants/myxConfig.mjs.map +1 -0
  66. package/dist/constants/orderTypes.cjs +31 -0
  67. package/dist/constants/orderTypes.cjs.map +1 -0
  68. package/dist/constants/orderTypes.d.cts +19 -0
  69. package/dist/constants/orderTypes.d.cts.map +1 -0
  70. package/dist/constants/orderTypes.d.mts +19 -0
  71. package/dist/constants/orderTypes.d.mts.map +1 -0
  72. package/dist/constants/orderTypes.mjs +27 -0
  73. package/dist/constants/orderTypes.mjs.map +1 -0
  74. package/dist/constants/performanceMetrics.cjs +63 -0
  75. package/dist/constants/performanceMetrics.cjs.map +1 -0
  76. package/dist/constants/performanceMetrics.d.cts +46 -0
  77. package/dist/constants/performanceMetrics.d.cts.map +1 -0
  78. package/dist/constants/performanceMetrics.d.mts +46 -0
  79. package/dist/constants/performanceMetrics.d.mts.map +1 -0
  80. package/dist/constants/performanceMetrics.mjs +60 -0
  81. package/dist/constants/performanceMetrics.mjs.map +1 -0
  82. package/dist/constants/perpsConfig.cjs +295 -0
  83. package/dist/constants/perpsConfig.cjs.map +1 -0
  84. package/dist/constants/perpsConfig.d.cts +221 -0
  85. package/dist/constants/perpsConfig.d.cts.map +1 -0
  86. package/dist/constants/perpsConfig.d.mts +221 -0
  87. package/dist/constants/perpsConfig.d.mts.map +1 -0
  88. package/dist/constants/perpsConfig.mjs +292 -0
  89. package/dist/constants/perpsConfig.mjs.map +1 -0
  90. package/dist/constants/transactionsHistoryConfig.cjs +19 -0
  91. package/dist/constants/transactionsHistoryConfig.cjs.map +1 -0
  92. package/dist/constants/transactionsHistoryConfig.d.cts +16 -0
  93. package/dist/constants/transactionsHistoryConfig.d.cts.map +1 -0
  94. package/dist/constants/transactionsHistoryConfig.d.mts +16 -0
  95. package/dist/constants/transactionsHistoryConfig.d.mts.map +1 -0
  96. package/dist/constants/transactionsHistoryConfig.mjs +16 -0
  97. package/dist/constants/transactionsHistoryConfig.mjs.map +1 -0
  98. package/dist/index.cjs +63 -1
  99. package/dist/index.cjs.map +1 -1
  100. package/dist/index.d.cts +38 -2
  101. package/dist/index.d.cts.map +1 -1
  102. package/dist/index.d.mts +38 -2
  103. package/dist/index.d.mts.map +1 -1
  104. package/dist/index.mjs +46 -1
  105. package/dist/index.mjs.map +1 -1
  106. package/dist/perpsErrorCodes.cjs +80 -0
  107. package/dist/perpsErrorCodes.cjs.map +1 -0
  108. package/dist/perpsErrorCodes.d.cts +65 -0
  109. package/dist/perpsErrorCodes.d.cts.map +1 -0
  110. package/dist/perpsErrorCodes.d.mts +65 -0
  111. package/dist/perpsErrorCodes.d.mts.map +1 -0
  112. package/dist/perpsErrorCodes.mjs +77 -0
  113. package/dist/perpsErrorCodes.mjs.map +1 -0
  114. package/dist/providers/AggregatedPerpsProvider.cjs +508 -0
  115. package/dist/providers/AggregatedPerpsProvider.cjs.map +1 -0
  116. package/dist/providers/AggregatedPerpsProvider.d.cts +171 -0
  117. package/dist/providers/AggregatedPerpsProvider.d.cts.map +1 -0
  118. package/dist/providers/AggregatedPerpsProvider.d.mts +171 -0
  119. package/dist/providers/AggregatedPerpsProvider.d.mts.map +1 -0
  120. package/dist/providers/AggregatedPerpsProvider.mjs +504 -0
  121. package/dist/providers/AggregatedPerpsProvider.mjs.map +1 -0
  122. package/dist/providers/HyperLiquidProvider.cjs +5679 -0
  123. package/dist/providers/HyperLiquidProvider.cjs.map +1 -0
  124. package/dist/providers/HyperLiquidProvider.d.cts +516 -0
  125. package/dist/providers/HyperLiquidProvider.d.cts.map +1 -0
  126. package/dist/providers/HyperLiquidProvider.d.mts +516 -0
  127. package/dist/providers/HyperLiquidProvider.d.mts.map +1 -0
  128. package/dist/providers/HyperLiquidProvider.mjs +5675 -0
  129. package/dist/providers/HyperLiquidProvider.mjs.map +1 -0
  130. package/dist/providers/MYXProvider.cjs +514 -0
  131. package/dist/providers/MYXProvider.cjs.map +1 -0
  132. package/dist/providers/MYXProvider.d.cts +105 -0
  133. package/dist/providers/MYXProvider.d.cts.map +1 -0
  134. package/dist/providers/MYXProvider.d.mts +105 -0
  135. package/dist/providers/MYXProvider.d.mts.map +1 -0
  136. package/dist/providers/MYXProvider.mjs +510 -0
  137. package/dist/providers/MYXProvider.mjs.map +1 -0
  138. package/dist/routing/ProviderRouter.cjs +154 -0
  139. package/dist/routing/ProviderRouter.cjs.map +1 -0
  140. package/dist/routing/ProviderRouter.d.cts +112 -0
  141. package/dist/routing/ProviderRouter.d.cts.map +1 -0
  142. package/dist/routing/ProviderRouter.d.mts +112 -0
  143. package/dist/routing/ProviderRouter.d.mts.map +1 -0
  144. package/dist/routing/ProviderRouter.mjs +150 -0
  145. package/dist/routing/ProviderRouter.mjs.map +1 -0
  146. package/dist/routing/index.cjs +9 -0
  147. package/dist/routing/index.cjs.map +1 -0
  148. package/dist/routing/index.d.cts +6 -0
  149. package/dist/routing/index.d.cts.map +1 -0
  150. package/dist/routing/index.d.mts +6 -0
  151. package/dist/routing/index.d.mts.map +1 -0
  152. package/dist/routing/index.mjs +5 -0
  153. package/dist/routing/index.mjs.map +1 -0
  154. package/dist/selectors.cjs +166 -0
  155. package/dist/selectors.cjs.map +1 -0
  156. package/dist/selectors.d.cts +362 -0
  157. package/dist/selectors.d.cts.map +1 -0
  158. package/dist/selectors.d.mts +362 -0
  159. package/dist/selectors.d.mts.map +1 -0
  160. package/dist/selectors.mjs +158 -0
  161. package/dist/selectors.mjs.map +1 -0
  162. package/dist/services/AccountService.cjs +324 -0
  163. package/dist/services/AccountService.cjs.map +1 -0
  164. package/dist/services/AccountService.d.cts +56 -0
  165. package/dist/services/AccountService.d.cts.map +1 -0
  166. package/dist/services/AccountService.d.mts +56 -0
  167. package/dist/services/AccountService.d.mts.map +1 -0
  168. package/dist/services/AccountService.mjs +320 -0
  169. package/dist/services/AccountService.mjs.map +1 -0
  170. package/dist/services/DataLakeService.cjs +233 -0
  171. package/dist/services/DataLakeService.cjs.map +1 -0
  172. package/dist/services/DataLakeService.d.cts +51 -0
  173. package/dist/services/DataLakeService.d.cts.map +1 -0
  174. package/dist/services/DataLakeService.d.mts +51 -0
  175. package/dist/services/DataLakeService.d.mts.map +1 -0
  176. package/dist/services/DataLakeService.mjs +229 -0
  177. package/dist/services/DataLakeService.mjs.map +1 -0
  178. package/dist/services/DepositService.cjs +98 -0
  179. package/dist/services/DepositService.cjs.map +1 -0
  180. package/dist/services/DepositService.d.cts +39 -0
  181. package/dist/services/DepositService.d.cts.map +1 -0
  182. package/dist/services/DepositService.d.mts +39 -0
  183. package/dist/services/DepositService.d.mts.map +1 -0
  184. package/dist/services/DepositService.mjs +94 -0
  185. package/dist/services/DepositService.mjs.map +1 -0
  186. package/dist/services/EligibilityService.cjs +173 -0
  187. package/dist/services/EligibilityService.cjs.map +1 -0
  188. package/dist/services/EligibilityService.d.cts +39 -0
  189. package/dist/services/EligibilityService.d.cts.map +1 -0
  190. package/dist/services/EligibilityService.d.mts +39 -0
  191. package/dist/services/EligibilityService.d.mts.map +1 -0
  192. package/dist/services/EligibilityService.mjs +169 -0
  193. package/dist/services/EligibilityService.mjs.map +1 -0
  194. package/dist/services/FeatureFlagConfigurationService.cjs +257 -0
  195. package/dist/services/FeatureFlagConfigurationService.cjs.map +1 -0
  196. package/dist/services/FeatureFlagConfigurationService.d.cts +73 -0
  197. package/dist/services/FeatureFlagConfigurationService.d.cts.map +1 -0
  198. package/dist/services/FeatureFlagConfigurationService.d.mts +73 -0
  199. package/dist/services/FeatureFlagConfigurationService.d.mts.map +1 -0
  200. package/dist/services/FeatureFlagConfigurationService.mjs +253 -0
  201. package/dist/services/FeatureFlagConfigurationService.mjs.map +1 -0
  202. package/dist/services/HyperLiquidClientService.cjs +867 -0
  203. package/dist/services/HyperLiquidClientService.cjs.map +1 -0
  204. package/dist/services/HyperLiquidClientService.d.cts +214 -0
  205. package/dist/services/HyperLiquidClientService.d.cts.map +1 -0
  206. package/dist/services/HyperLiquidClientService.d.mts +214 -0
  207. package/dist/services/HyperLiquidClientService.d.mts.map +1 -0
  208. package/dist/services/HyperLiquidClientService.mjs +862 -0
  209. package/dist/services/HyperLiquidClientService.mjs.map +1 -0
  210. package/dist/services/HyperLiquidSubscriptionService.cjs +2199 -0
  211. package/dist/services/HyperLiquidSubscriptionService.cjs.map +1 -0
  212. package/dist/services/HyperLiquidSubscriptionService.d.cts +187 -0
  213. package/dist/services/HyperLiquidSubscriptionService.d.cts.map +1 -0
  214. package/dist/services/HyperLiquidSubscriptionService.d.mts +187 -0
  215. package/dist/services/HyperLiquidSubscriptionService.d.mts.map +1 -0
  216. package/dist/services/HyperLiquidSubscriptionService.mjs +2195 -0
  217. package/dist/services/HyperLiquidSubscriptionService.mjs.map +1 -0
  218. package/dist/services/HyperLiquidWalletService.cjs +163 -0
  219. package/dist/services/HyperLiquidWalletService.cjs.map +1 -0
  220. package/dist/services/HyperLiquidWalletService.d.cts +78 -0
  221. package/dist/services/HyperLiquidWalletService.d.cts.map +1 -0
  222. package/dist/services/HyperLiquidWalletService.d.mts +78 -0
  223. package/dist/services/HyperLiquidWalletService.d.mts.map +1 -0
  224. package/dist/services/HyperLiquidWalletService.mjs +159 -0
  225. package/dist/services/HyperLiquidWalletService.mjs.map +1 -0
  226. package/dist/services/MYXClientService.cjs +304 -0
  227. package/dist/services/MYXClientService.cjs.map +1 -0
  228. package/dist/services/MYXClientService.d.cts +81 -0
  229. package/dist/services/MYXClientService.d.cts.map +1 -0
  230. package/dist/services/MYXClientService.d.mts +81 -0
  231. package/dist/services/MYXClientService.d.mts.map +1 -0
  232. package/dist/services/MYXClientService.mjs +300 -0
  233. package/dist/services/MYXClientService.mjs.map +1 -0
  234. package/dist/services/MarketDataService.cjs +848 -0
  235. package/dist/services/MarketDataService.cjs.map +1 -0
  236. package/dist/services/MarketDataService.d.cts +291 -0
  237. package/dist/services/MarketDataService.d.cts.map +1 -0
  238. package/dist/services/MarketDataService.d.mts +291 -0
  239. package/dist/services/MarketDataService.d.mts.map +1 -0
  240. package/dist/services/MarketDataService.mjs +844 -0
  241. package/dist/services/MarketDataService.mjs.map +1 -0
  242. package/dist/services/RewardsIntegrationService.cjs +120 -0
  243. package/dist/services/RewardsIntegrationService.cjs.map +1 -0
  244. package/dist/services/RewardsIntegrationService.d.cts +28 -0
  245. package/dist/services/RewardsIntegrationService.d.cts.map +1 -0
  246. package/dist/services/RewardsIntegrationService.d.mts +28 -0
  247. package/dist/services/RewardsIntegrationService.d.mts.map +1 -0
  248. package/dist/services/RewardsIntegrationService.mjs +116 -0
  249. package/dist/services/RewardsIntegrationService.mjs.map +1 -0
  250. package/dist/services/ServiceContext.cjs +3 -0
  251. package/dist/services/ServiceContext.cjs.map +1 -0
  252. package/dist/services/ServiceContext.d.cts +86 -0
  253. package/dist/services/ServiceContext.d.cts.map +1 -0
  254. package/dist/services/ServiceContext.d.mts +86 -0
  255. package/dist/services/ServiceContext.d.mts.map +1 -0
  256. package/dist/services/ServiceContext.mjs +2 -0
  257. package/dist/services/ServiceContext.mjs.map +1 -0
  258. package/dist/services/TradingReadinessCache.cjs +288 -0
  259. package/dist/services/TradingReadinessCache.cjs.map +1 -0
  260. package/dist/services/TradingReadinessCache.d.cts +174 -0
  261. package/dist/services/TradingReadinessCache.d.cts.map +1 -0
  262. package/dist/services/TradingReadinessCache.d.mts +174 -0
  263. package/dist/services/TradingReadinessCache.d.mts.map +1 -0
  264. package/dist/services/TradingReadinessCache.mjs +285 -0
  265. package/dist/services/TradingReadinessCache.mjs.map +1 -0
  266. package/dist/services/TradingService.cjs +1457 -0
  267. package/dist/services/TradingService.cjs.map +1 -0
  268. package/dist/services/TradingService.d.cts +195 -0
  269. package/dist/services/TradingService.d.cts.map +1 -0
  270. package/dist/services/TradingService.d.mts +195 -0
  271. package/dist/services/TradingService.d.mts.map +1 -0
  272. package/dist/services/TradingService.mjs +1453 -0
  273. package/dist/services/TradingService.mjs.map +1 -0
  274. package/dist/types/config.cjs +3 -0
  275. package/dist/types/config.cjs.map +1 -0
  276. package/dist/types/config.d.cts +49 -0
  277. package/dist/types/config.d.cts.map +1 -0
  278. package/dist/types/config.d.mts +49 -0
  279. package/dist/types/config.d.mts.map +1 -0
  280. package/dist/types/config.mjs +2 -0
  281. package/dist/types/config.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 +20 -0
  285. package/dist/types/hyperliquid-types.d.cts.map +1 -0
  286. package/dist/types/hyperliquid-types.d.mts +20 -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 +115 -0
  291. package/dist/types/index.cjs.map +1 -0
  292. package/dist/types/index.d.cts +1262 -0
  293. package/dist/types/index.d.cts.map +1 -0
  294. package/dist/types/index.d.mts +1262 -0
  295. package/dist/types/index.d.mts.map +1 -0
  296. package/dist/types/index.mjs +97 -0
  297. package/dist/types/index.mjs.map +1 -0
  298. package/dist/types/messenger.cjs +3 -0
  299. package/dist/types/messenger.cjs.map +1 -0
  300. package/dist/types/messenger.d.cts +27 -0
  301. package/dist/types/messenger.d.cts.map +1 -0
  302. package/dist/types/messenger.d.mts +27 -0
  303. package/dist/types/messenger.d.mts.map +1 -0
  304. package/dist/types/messenger.mjs +2 -0
  305. package/dist/types/messenger.mjs.map +1 -0
  306. package/dist/types/myx-types.cjs +25 -0
  307. package/dist/types/myx-types.cjs.map +1 -0
  308. package/dist/types/myx-types.d.cts +63 -0
  309. package/dist/types/myx-types.d.cts.map +1 -0
  310. package/dist/types/myx-types.d.mts +63 -0
  311. package/dist/types/myx-types.d.mts.map +1 -0
  312. package/dist/types/myx-types.mjs +22 -0
  313. package/dist/types/myx-types.mjs.map +1 -0
  314. package/dist/types/perps-types.cjs +4 -0
  315. package/dist/types/perps-types.cjs.map +1 -0
  316. package/dist/types/perps-types.d.cts +105 -0
  317. package/dist/types/perps-types.d.cts.map +1 -0
  318. package/dist/types/perps-types.d.mts +105 -0
  319. package/dist/types/perps-types.d.mts.map +1 -0
  320. package/dist/types/perps-types.mjs +2 -0
  321. package/dist/types/perps-types.mjs.map +1 -0
  322. package/dist/types/token.cjs +3 -0
  323. package/dist/types/token.cjs.map +1 -0
  324. package/dist/types/token.d.cts +25 -0
  325. package/dist/types/token.d.cts.map +1 -0
  326. package/dist/types/token.d.mts +25 -0
  327. package/dist/types/token.d.mts.map +1 -0
  328. package/dist/types/token.mjs +2 -0
  329. package/dist/types/token.mjs.map +1 -0
  330. package/dist/types/transactionTypes.cjs +28 -0
  331. package/dist/types/transactionTypes.cjs.map +1 -0
  332. package/dist/types/transactionTypes.d.cts +64 -0
  333. package/dist/types/transactionTypes.d.cts.map +1 -0
  334. package/dist/types/transactionTypes.d.mts +64 -0
  335. package/dist/types/transactionTypes.d.mts.map +1 -0
  336. package/dist/types/transactionTypes.mjs +23 -0
  337. package/dist/types/transactionTypes.mjs.map +1 -0
  338. package/dist/utils/accountUtils.cjs +100 -0
  339. package/dist/utils/accountUtils.cjs.map +1 -0
  340. package/dist/utils/accountUtils.d.cts +30 -0
  341. package/dist/utils/accountUtils.d.cts.map +1 -0
  342. package/dist/utils/accountUtils.d.mts +30 -0
  343. package/dist/utils/accountUtils.d.mts.map +1 -0
  344. package/dist/utils/accountUtils.mjs +92 -0
  345. package/dist/utils/accountUtils.mjs.map +1 -0
  346. package/dist/utils/errorUtils.cjs +35 -0
  347. package/dist/utils/errorUtils.cjs.map +1 -0
  348. package/dist/utils/errorUtils.d.cts +15 -0
  349. package/dist/utils/errorUtils.d.cts.map +1 -0
  350. package/dist/utils/errorUtils.d.mts +15 -0
  351. package/dist/utils/errorUtils.d.mts.map +1 -0
  352. package/dist/utils/errorUtils.mjs +31 -0
  353. package/dist/utils/errorUtils.mjs.map +1 -0
  354. package/dist/utils/hyperLiquidAdapter.cjs +331 -0
  355. package/dist/utils/hyperLiquidAdapter.cjs.map +1 -0
  356. package/dist/utils/hyperLiquidAdapter.d.cts +42 -0
  357. package/dist/utils/hyperLiquidAdapter.d.cts.map +1 -0
  358. package/dist/utils/hyperLiquidAdapter.d.mts +42 -0
  359. package/dist/utils/hyperLiquidAdapter.d.mts.map +1 -0
  360. package/dist/utils/hyperLiquidAdapter.mjs +316 -0
  361. package/dist/utils/hyperLiquidAdapter.mjs.map +1 -0
  362. package/dist/utils/hyperLiquidOrderBookProcessor.cjs +83 -0
  363. package/dist/utils/hyperLiquidOrderBookProcessor.cjs.map +1 -0
  364. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts +55 -0
  365. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts.map +1 -0
  366. package/dist/utils/hyperLiquidOrderBookProcessor.d.mts +55 -0
  367. package/dist/utils/hyperLiquidOrderBookProcessor.d.mts.map +1 -0
  368. package/dist/utils/hyperLiquidOrderBookProcessor.mjs +78 -0
  369. package/dist/utils/hyperLiquidOrderBookProcessor.mjs.map +1 -0
  370. package/dist/utils/hyperLiquidValidation.cjs +426 -0
  371. package/dist/utils/hyperLiquidValidation.cjs.map +1 -0
  372. package/dist/utils/hyperLiquidValidation.d.cts +143 -0
  373. package/dist/utils/hyperLiquidValidation.d.cts.map +1 -0
  374. package/dist/utils/hyperLiquidValidation.d.mts +143 -0
  375. package/dist/utils/hyperLiquidValidation.d.mts.map +1 -0
  376. package/dist/utils/hyperLiquidValidation.mjs +413 -0
  377. package/dist/utils/hyperLiquidValidation.mjs.map +1 -0
  378. package/dist/utils/idUtils.cjs +18 -0
  379. package/dist/utils/idUtils.cjs.map +1 -0
  380. package/dist/utils/idUtils.d.cts +6 -0
  381. package/dist/utils/idUtils.d.cts.map +1 -0
  382. package/dist/utils/idUtils.d.mts +6 -0
  383. package/dist/utils/idUtils.d.mts.map +1 -0
  384. package/dist/utils/idUtils.mjs +10 -0
  385. package/dist/utils/idUtils.mjs.map +1 -0
  386. package/dist/utils/index.cjs +59 -0
  387. package/dist/utils/index.cjs.map +1 -0
  388. package/dist/utils/index.d.cts +25 -0
  389. package/dist/utils/index.d.cts.map +1 -0
  390. package/dist/utils/index.d.mts +25 -0
  391. package/dist/utils/index.d.mts.map +1 -0
  392. package/dist/utils/index.mjs +30 -0
  393. package/dist/utils/index.mjs.map +1 -0
  394. package/dist/utils/marketDataTransform.cjs +211 -0
  395. package/dist/utils/marketDataTransform.cjs.map +1 -0
  396. package/dist/utils/marketDataTransform.d.cts +40 -0
  397. package/dist/utils/marketDataTransform.d.cts.map +1 -0
  398. package/dist/utils/marketDataTransform.d.mts +40 -0
  399. package/dist/utils/marketDataTransform.d.mts.map +1 -0
  400. package/dist/utils/marketDataTransform.mjs +205 -0
  401. package/dist/utils/marketDataTransform.mjs.map +1 -0
  402. package/dist/utils/marketUtils.cjs +151 -0
  403. package/dist/utils/marketUtils.cjs.map +1 -0
  404. package/dist/utils/marketUtils.d.cts +30 -0
  405. package/dist/utils/marketUtils.d.cts.map +1 -0
  406. package/dist/utils/marketUtils.d.mts +30 -0
  407. package/dist/utils/marketUtils.d.mts.map +1 -0
  408. package/dist/utils/marketUtils.mjs +138 -0
  409. package/dist/utils/marketUtils.mjs.map +1 -0
  410. package/dist/utils/myxAdapter.cjs +224 -0
  411. package/dist/utils/myxAdapter.cjs.map +1 -0
  412. package/dist/utils/myxAdapter.d.cts +81 -0
  413. package/dist/utils/myxAdapter.d.cts.map +1 -0
  414. package/dist/utils/myxAdapter.d.mts +81 -0
  415. package/dist/utils/myxAdapter.d.mts.map +1 -0
  416. package/dist/utils/myxAdapter.mjs +213 -0
  417. package/dist/utils/myxAdapter.mjs.map +1 -0
  418. package/dist/utils/orderCalculations.cjs +283 -0
  419. package/dist/utils/orderCalculations.cjs.map +1 -0
  420. package/dist/utils/orderCalculations.d.cts +107 -0
  421. package/dist/utils/orderCalculations.d.cts.map +1 -0
  422. package/dist/utils/orderCalculations.d.mts +107 -0
  423. package/dist/utils/orderCalculations.d.mts.map +1 -0
  424. package/dist/utils/orderCalculations.mjs +274 -0
  425. package/dist/utils/orderCalculations.mjs.map +1 -0
  426. package/dist/utils/rewardsUtils.cjs +98 -0
  427. package/dist/utils/rewardsUtils.cjs.map +1 -0
  428. package/dist/utils/rewardsUtils.d.cts +33 -0
  429. package/dist/utils/rewardsUtils.d.cts.map +1 -0
  430. package/dist/utils/rewardsUtils.d.mts +33 -0
  431. package/dist/utils/rewardsUtils.d.mts.map +1 -0
  432. package/dist/utils/rewardsUtils.mjs +92 -0
  433. package/dist/utils/rewardsUtils.mjs.map +1 -0
  434. package/dist/utils/significantFigures.cjs +88 -0
  435. package/dist/utils/significantFigures.cjs.map +1 -0
  436. package/dist/utils/significantFigures.d.cts +25 -0
  437. package/dist/utils/significantFigures.d.cts.map +1 -0
  438. package/dist/utils/significantFigures.d.mts +25 -0
  439. package/dist/utils/significantFigures.d.mts.map +1 -0
  440. package/dist/utils/significantFigures.mjs +82 -0
  441. package/dist/utils/significantFigures.mjs.map +1 -0
  442. package/dist/utils/sortMarkets.cjs +93 -0
  443. package/dist/utils/sortMarkets.cjs.map +1 -0
  444. package/dist/utils/sortMarkets.d.cts +27 -0
  445. package/dist/utils/sortMarkets.d.cts.map +1 -0
  446. package/dist/utils/sortMarkets.d.mts +27 -0
  447. package/dist/utils/sortMarkets.d.mts.map +1 -0
  448. package/dist/utils/sortMarkets.mjs +88 -0
  449. package/dist/utils/sortMarkets.mjs.map +1 -0
  450. package/dist/utils/standaloneInfoClient.cjs +70 -0
  451. package/dist/utils/standaloneInfoClient.cjs.map +1 -0
  452. package/dist/utils/standaloneInfoClient.d.cts +37 -0
  453. package/dist/utils/standaloneInfoClient.d.cts.map +1 -0
  454. package/dist/utils/standaloneInfoClient.d.mts +37 -0
  455. package/dist/utils/standaloneInfoClient.d.mts.map +1 -0
  456. package/dist/utils/standaloneInfoClient.mjs +64 -0
  457. package/dist/utils/standaloneInfoClient.mjs.map +1 -0
  458. package/dist/utils/stringParseUtils.cjs +18 -0
  459. package/dist/utils/stringParseUtils.cjs.map +1 -0
  460. package/dist/utils/stringParseUtils.d.cts +3 -0
  461. package/dist/utils/stringParseUtils.d.cts.map +1 -0
  462. package/dist/utils/stringParseUtils.d.mts +3 -0
  463. package/dist/utils/stringParseUtils.d.mts.map +1 -0
  464. package/dist/utils/stringParseUtils.mjs +13 -0
  465. package/dist/utils/stringParseUtils.mjs.map +1 -0
  466. package/dist/utils/transferData.cjs +33 -0
  467. package/dist/utils/transferData.cjs.map +1 -0
  468. package/dist/utils/transferData.d.cts +9 -0
  469. package/dist/utils/transferData.d.cts.map +1 -0
  470. package/dist/utils/transferData.d.mts +9 -0
  471. package/dist/utils/transferData.d.mts.map +1 -0
  472. package/dist/utils/transferData.mjs +29 -0
  473. package/dist/utils/transferData.mjs.map +1 -0
  474. package/dist/utils/wait.cjs +6 -0
  475. package/dist/utils/wait.cjs.map +1 -0
  476. package/dist/utils/wait.d.cts +2 -0
  477. package/dist/utils/wait.d.cts.map +1 -0
  478. package/dist/utils/wait.d.mts +2 -0
  479. package/dist/utils/wait.d.mts.map +1 -0
  480. package/dist/utils/wait.mjs +2 -0
  481. package/dist/utils/wait.mjs.map +1 -0
  482. package/package.json +16 -2
@@ -0,0 +1,413 @@
1
+ import { isValidHexAddress } from "@metamask/utils";
2
+ import { HYPERLIQUID_ASSET_CONFIGS, getSupportedAssets, TRADING_DEFAULTS } from "../constants/hyperLiquidConfig.mjs";
3
+ import { HYPERLIQUID_ORDER_LIMITS } from "../constants/perpsConfig.mjs";
4
+ import { PERPS_ERROR_CODES } from "../perpsErrorCodes.mjs";
5
+ /**
6
+ * Validation utilities for HyperLiquid operations
7
+ */
8
+ /**
9
+ * Create standardized error response.
10
+ *
11
+ * @param error - The error that occurred
12
+ * @param defaultResponse - The default response object to use as template
13
+ * @returns The error response with success=false and error message
14
+ */
15
+ export function createErrorResult(error, defaultResponse) {
16
+ return {
17
+ ...defaultResponse,
18
+ success: false,
19
+ error: error instanceof Error ? error.message : PERPS_ERROR_CODES.UNKNOWN_ERROR,
20
+ };
21
+ }
22
+ /**
23
+ * Validate withdrawal parameters.
24
+ *
25
+ * @param params - Withdrawal parameters to validate
26
+ * @param params.assetId - The CAIP asset ID to withdraw
27
+ * @param params.amount - Amount to withdraw as string
28
+ * @param params.destination - Optional destination hex address
29
+ * @param debugLogger - Optional debug logger for detailed logging
30
+ * @returns Validation result with isValid flag and optional error message
31
+ */
32
+ export function validateWithdrawalParams(params, debugLogger) {
33
+ debugLogger?.log('validateWithdrawalParams: Starting validation', {
34
+ params,
35
+ hasAssetId: Boolean(params.assetId),
36
+ hasAmount: Boolean(params.amount),
37
+ hasDestination: Boolean(params.destination),
38
+ });
39
+ // Validate required parameters
40
+ if (!params.assetId) {
41
+ debugLogger?.log('validateWithdrawalParams: Missing assetId', {
42
+ error: PERPS_ERROR_CODES.WITHDRAW_ASSET_ID_REQUIRED,
43
+ params,
44
+ });
45
+ return {
46
+ isValid: false,
47
+ error: PERPS_ERROR_CODES.WITHDRAW_ASSET_ID_REQUIRED,
48
+ };
49
+ }
50
+ // Validate amount
51
+ if (!params.amount) {
52
+ debugLogger?.log('validateWithdrawalParams: Missing amount', {
53
+ error: PERPS_ERROR_CODES.WITHDRAW_AMOUNT_REQUIRED,
54
+ params,
55
+ });
56
+ return {
57
+ isValid: false,
58
+ error: PERPS_ERROR_CODES.WITHDRAW_AMOUNT_REQUIRED,
59
+ };
60
+ }
61
+ const amount = parseFloat(params.amount);
62
+ if (isNaN(amount) || amount <= 0) {
63
+ debugLogger?.log('validateWithdrawalParams: Invalid amount', {
64
+ error: PERPS_ERROR_CODES.WITHDRAW_AMOUNT_POSITIVE,
65
+ amount: params.amount,
66
+ parsedAmount: amount,
67
+ isNaN: isNaN(amount),
68
+ });
69
+ return {
70
+ isValid: false,
71
+ error: PERPS_ERROR_CODES.WITHDRAW_AMOUNT_POSITIVE,
72
+ };
73
+ }
74
+ // Validate destination address if provided
75
+ if (params.destination && !isValidHexAddress(params.destination)) {
76
+ debugLogger?.log('validateWithdrawalParams: Invalid destination address', {
77
+ error: PERPS_ERROR_CODES.WITHDRAW_INVALID_DESTINATION,
78
+ destination: params.destination,
79
+ isValidHex: isValidHexAddress(params.destination),
80
+ });
81
+ return {
82
+ isValid: false,
83
+ error: PERPS_ERROR_CODES.WITHDRAW_INVALID_DESTINATION,
84
+ };
85
+ }
86
+ debugLogger?.log('validateWithdrawalParams: All validations passed', {
87
+ assetId: params.assetId,
88
+ amount: params.amount,
89
+ destination: params.destination ?? 'will use user wallet',
90
+ });
91
+ return { isValid: true };
92
+ }
93
+ /**
94
+ * Validate deposit parameters.
95
+ *
96
+ * @param params - Deposit parameters to validate
97
+ * @param params.assetId - The CAIP asset ID to deposit
98
+ * @param params.amount - Amount to deposit as string
99
+ * @param params.isTestnet - Whether this is a testnet deposit
100
+ * @param debugLogger - Optional debug logger for detailed logging
101
+ * @returns Validation result with isValid flag and optional error message
102
+ */
103
+ export function validateDepositParams(params, debugLogger) {
104
+ debugLogger?.log('validateDepositParams: Starting validation', {
105
+ params,
106
+ hasAssetId: Boolean(params.assetId),
107
+ hasAmount: Boolean(params.amount),
108
+ isTestnet: params.isTestnet,
109
+ });
110
+ // Validate required parameters
111
+ if (!params.assetId) {
112
+ debugLogger?.log('validateDepositParams: Missing assetId', {
113
+ error: PERPS_ERROR_CODES.DEPOSIT_ASSET_ID_REQUIRED,
114
+ params,
115
+ });
116
+ return {
117
+ isValid: false,
118
+ error: PERPS_ERROR_CODES.DEPOSIT_ASSET_ID_REQUIRED,
119
+ };
120
+ }
121
+ // Validate amount
122
+ if (!params.amount) {
123
+ debugLogger?.log('validateDepositParams: Missing amount', {
124
+ error: PERPS_ERROR_CODES.DEPOSIT_AMOUNT_REQUIRED,
125
+ params,
126
+ });
127
+ return {
128
+ isValid: false,
129
+ error: PERPS_ERROR_CODES.DEPOSIT_AMOUNT_REQUIRED,
130
+ };
131
+ }
132
+ const amount = parseFloat(params.amount);
133
+ if (isNaN(amount) || amount <= 0) {
134
+ debugLogger?.log('validateDepositParams: Invalid amount', {
135
+ error: PERPS_ERROR_CODES.DEPOSIT_AMOUNT_POSITIVE,
136
+ amount: params.amount,
137
+ parsedAmount: amount,
138
+ isNaN: isNaN(amount),
139
+ });
140
+ return {
141
+ isValid: false,
142
+ error: PERPS_ERROR_CODES.DEPOSIT_AMOUNT_POSITIVE,
143
+ };
144
+ }
145
+ // Check minimum deposit amount
146
+ const minimumAmount = params.isTestnet
147
+ ? TRADING_DEFAULTS.amount.testnet
148
+ : TRADING_DEFAULTS.amount.mainnet;
149
+ debugLogger?.log('validateDepositParams: Checking minimum amount', {
150
+ amount,
151
+ minimumAmount,
152
+ isTestnet: params.isTestnet,
153
+ network: params.isTestnet ? 'testnet' : 'mainnet',
154
+ });
155
+ if (amount < minimumAmount) {
156
+ debugLogger?.log('validateDepositParams: Below minimum deposit', {
157
+ error: PERPS_ERROR_CODES.DEPOSIT_MINIMUM_AMOUNT,
158
+ amount,
159
+ minimumAmount,
160
+ difference: minimumAmount - amount,
161
+ });
162
+ return {
163
+ isValid: false,
164
+ error: PERPS_ERROR_CODES.DEPOSIT_MINIMUM_AMOUNT,
165
+ };
166
+ }
167
+ debugLogger?.log('validateDepositParams: All validations passed', {
168
+ assetId: params.assetId,
169
+ amount: params.amount,
170
+ parsedAmount: amount,
171
+ minimumAmount,
172
+ isTestnet: params.isTestnet,
173
+ });
174
+ return { isValid: true };
175
+ }
176
+ /**
177
+ * Validate asset support for withdrawals using AssetRoute arrays.
178
+ *
179
+ * @param assetId - The CAIP asset ID to validate
180
+ * @param supportedRoutes - Array of supported asset routes
181
+ * @param debugLogger - Optional debug logger for detailed logging
182
+ * @returns Validation result with isValid flag and optional error message
183
+ */
184
+ export function validateAssetSupport(assetId, supportedRoutes, debugLogger) {
185
+ debugLogger?.log('validateAssetSupport: Checking asset support', {
186
+ assetId,
187
+ supportedRoutesCount: supportedRoutes.length,
188
+ });
189
+ const supportedAssetIds = supportedRoutes.map((route) => route.assetId);
190
+ // Check if asset is supported
191
+ const isSupported = supportedAssetIds.includes(assetId);
192
+ if (!isSupported) {
193
+ // Also check case-insensitive match for contract addresses
194
+ const isSupportedCaseInsensitive = supportedAssetIds.some((supportedId) => supportedId.toLowerCase() === assetId.toLowerCase());
195
+ if (!isSupportedCaseInsensitive) {
196
+ debugLogger?.log('validateAssetSupport: Asset not supported', {
197
+ error: PERPS_ERROR_CODES.WITHDRAW_ASSET_NOT_SUPPORTED,
198
+ assetId,
199
+ supportedAssetIds,
200
+ checkedCaseInsensitive: true,
201
+ });
202
+ return {
203
+ isValid: false,
204
+ error: PERPS_ERROR_CODES.WITHDRAW_ASSET_NOT_SUPPORTED,
205
+ };
206
+ }
207
+ debugLogger?.log('⚠️ validateAssetSupport: Asset supported with case mismatch', {
208
+ providedAssetId: assetId,
209
+ matchedAssetId: supportedAssetIds.find((id) => id.toLowerCase() === assetId.toLowerCase()),
210
+ });
211
+ }
212
+ debugLogger?.log('validateAssetSupport: Asset is supported', {
213
+ assetId,
214
+ });
215
+ return { isValid: true };
216
+ }
217
+ /**
218
+ * Validate balance against withdrawal amount.
219
+ *
220
+ * @param withdrawAmount - The amount to withdraw
221
+ * @param availableBalance - The available balance
222
+ * @param debugLogger - Optional debug logger for detailed logging
223
+ * @returns Validation result with isValid flag and optional error message
224
+ */
225
+ export function validateBalance(withdrawAmount, availableBalance, debugLogger) {
226
+ debugLogger?.log('validateBalance: Checking balance sufficiency', {
227
+ withdrawAmount,
228
+ availableBalance,
229
+ difference: availableBalance - withdrawAmount,
230
+ });
231
+ if (withdrawAmount > availableBalance) {
232
+ const shortfall = withdrawAmount - availableBalance;
233
+ debugLogger?.log('validateBalance: Insufficient balance', {
234
+ error: PERPS_ERROR_CODES.WITHDRAW_INSUFFICIENT_BALANCE,
235
+ withdrawAmount,
236
+ availableBalance,
237
+ shortfall,
238
+ percentageOfAvailable: `${((withdrawAmount / availableBalance) * 100).toFixed(2)}%`,
239
+ });
240
+ return {
241
+ isValid: false,
242
+ error: PERPS_ERROR_CODES.WITHDRAW_INSUFFICIENT_BALANCE,
243
+ };
244
+ }
245
+ const remainingBalance = availableBalance - withdrawAmount;
246
+ debugLogger?.log('validateBalance: Balance is sufficient', {
247
+ withdrawAmount,
248
+ availableBalance,
249
+ remainingBalance,
250
+ percentageUsed: `${((withdrawAmount / availableBalance) * 100).toFixed(2)}%`,
251
+ });
252
+ return { isValid: true };
253
+ }
254
+ /**
255
+ * Apply filters to asset paths with comprehensive logging.
256
+ *
257
+ * @param assets - Array of CAIP asset IDs to filter
258
+ * @param params - Filter parameters including chainId, symbol, and assetId
259
+ * @param debugLogger - Optional debug logger for detailed logging
260
+ * @returns Filtered array of CAIP asset IDs
261
+ */
262
+ export function applyPathFilters(assets, params, debugLogger) {
263
+ if (!params) {
264
+ debugLogger?.log('HyperLiquid: applyPathFilters - no params, returning all assets', { assets });
265
+ return assets;
266
+ }
267
+ let filtered = assets;
268
+ debugLogger?.log('HyperLiquid: applyPathFilters - starting filter', {
269
+ initialAssets: assets,
270
+ filterParams: params,
271
+ });
272
+ if (params.chainId) {
273
+ const before = filtered;
274
+ filtered = filtered.filter((asset) => asset.startsWith(params.chainId));
275
+ debugLogger?.log('HyperLiquid: applyPathFilters - chainId filter', {
276
+ chainId: params.chainId,
277
+ before,
278
+ after: filtered,
279
+ });
280
+ }
281
+ if (params.symbol && params.symbol in HYPERLIQUID_ASSET_CONFIGS) {
282
+ const config = HYPERLIQUID_ASSET_CONFIGS[params.symbol];
283
+ const isTestnet = params.isTestnet ?? false;
284
+ const selectedAsset = isTestnet ? config.testnet : config.mainnet;
285
+ const before = filtered;
286
+ filtered = [selectedAsset];
287
+ debugLogger?.log('HyperLiquid: applyPathFilters - symbol filter', {
288
+ symbol: params.symbol,
289
+ isTestnet,
290
+ config,
291
+ selectedAsset,
292
+ before,
293
+ after: filtered,
294
+ });
295
+ }
296
+ if (params.assetId) {
297
+ const before = filtered;
298
+ // Use case-insensitive comparison for asset ID matching to handle address case differences
299
+ filtered = filtered.filter((asset) => asset.toLowerCase() === params.assetId?.toLowerCase());
300
+ debugLogger?.log('HyperLiquid: applyPathFilters - assetId filter', {
301
+ assetId: params.assetId,
302
+ before,
303
+ after: filtered,
304
+ exactMatch: before.includes(params.assetId),
305
+ caseInsensitiveMatch: before.some((asset) => asset.toLowerCase() === params.assetId?.toLowerCase()),
306
+ });
307
+ }
308
+ debugLogger?.log('HyperLiquid: applyPathFilters - final result', {
309
+ initialAssets: assets,
310
+ finalFiltered: filtered,
311
+ filterParams: params,
312
+ });
313
+ return filtered;
314
+ }
315
+ /**
316
+ * Get supported deposit/withdrawal paths with filtering.
317
+ *
318
+ * @param params - Filter parameters including isTestnet, chainId, symbol
319
+ * @param debugLogger - Optional debug logger for detailed logging
320
+ * @returns Array of supported CAIP asset IDs
321
+ */
322
+ export function getSupportedPaths(params, debugLogger) {
323
+ const isTestnet = params?.isTestnet ?? false;
324
+ const assets = getSupportedAssets(isTestnet);
325
+ const filteredAssets = applyPathFilters(assets, params, debugLogger);
326
+ debugLogger?.log('HyperLiquid: getSupportedPaths', {
327
+ isTestnet,
328
+ requestedParams: params,
329
+ allAssets: assets,
330
+ filteredAssets,
331
+ returnType: 'CaipAssetId[]',
332
+ example: filteredAssets[0],
333
+ });
334
+ return filteredAssets;
335
+ }
336
+ /**
337
+ * Get maximum order value based on leverage and order type.
338
+ * Based on HyperLiquid contract specifications.
339
+ *
340
+ * @param maxLeverage - The maximum leverage for the market
341
+ * @param orderType - The order type (market or limit)
342
+ * @returns Maximum order value in USD
343
+ */
344
+ export function getMaxOrderValue(maxLeverage, orderType) {
345
+ let marketLimit;
346
+ if (maxLeverage >= 25) {
347
+ marketLimit = HYPERLIQUID_ORDER_LIMITS.MarketOrderLimits.HighLeverage;
348
+ }
349
+ else if (maxLeverage >= 20) {
350
+ marketLimit = HYPERLIQUID_ORDER_LIMITS.MarketOrderLimits.MediumHighLeverage;
351
+ }
352
+ else if (maxLeverage >= 10) {
353
+ marketLimit = HYPERLIQUID_ORDER_LIMITS.MarketOrderLimits.MediumLeverage;
354
+ }
355
+ else {
356
+ marketLimit = HYPERLIQUID_ORDER_LIMITS.MarketOrderLimits.LowLeverage;
357
+ }
358
+ return orderType === 'limit'
359
+ ? marketLimit * HYPERLIQUID_ORDER_LIMITS.LimitOrderMultiplier
360
+ : marketLimit;
361
+ }
362
+ /**
363
+ * Validate order parameters.
364
+ * Basic validation - checks required fields are present.
365
+ * Amount validation (size/USD) is handled by validateOrder.
366
+ *
367
+ * @param params - Order parameters to validate
368
+ * @param params.coin - The trading pair coin symbol
369
+ * @param params.size - The order size as string
370
+ * @param params.price - The order price as string
371
+ * @param params.orderType - The order type (market or limit)
372
+ * @returns Validation result with isValid flag and optional error message
373
+ */
374
+ export function validateOrderParams(params) {
375
+ if (!params.coin) {
376
+ return {
377
+ isValid: false,
378
+ error: PERPS_ERROR_CODES.ORDER_COIN_REQUIRED,
379
+ };
380
+ }
381
+ // Note: Size validation removed - validateOrder handles amount validation using USD as source of truth
382
+ // Require price for limit orders
383
+ if (params.orderType === 'limit' && !params.price) {
384
+ return {
385
+ isValid: false,
386
+ error: PERPS_ERROR_CODES.ORDER_LIMIT_PRICE_REQUIRED,
387
+ };
388
+ }
389
+ if (params.price && parseFloat(params.price) <= 0) {
390
+ return {
391
+ isValid: false,
392
+ error: PERPS_ERROR_CODES.ORDER_PRICE_POSITIVE,
393
+ };
394
+ }
395
+ return { isValid: true };
396
+ }
397
+ /**
398
+ * Validate coin exists in asset mapping.
399
+ *
400
+ * @param coin - The coin symbol to validate
401
+ * @param coinToAssetId - Map of coin symbols to asset IDs
402
+ * @returns Validation result with isValid flag and optional error message
403
+ */
404
+ export function validateCoinExists(coin, coinToAssetId) {
405
+ if (!coinToAssetId.has(coin)) {
406
+ return {
407
+ isValid: false,
408
+ error: PERPS_ERROR_CODES.ORDER_UNKNOWN_COIN,
409
+ };
410
+ }
411
+ return { isValid: true };
412
+ }
413
+ //# sourceMappingURL=hyperLiquidValidation.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hyperLiquidValidation.mjs","sourceRoot":"","sources":["../../src/utils/hyperLiquidValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,wBAAwB;AAGpD,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,gBAAgB,EACjB,2CAAuC;AACxC,OAAO,EAAE,wBAAwB,EAAE,qCAAiC;AACpE,OAAO,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;IAED,OAAO,SAAS,KAAK,OAAO;QAC1B,CAAC,CAAC,WAAW,GAAG,wBAAwB,CAAC,oBAAoB;QAC7D,CAAC,CAAC,WAAW,CAAC;AAClB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAKnC;IACC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACjB,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,iBAAiB,CAAC,mBAAmB;SAC7C,CAAC;IACJ,CAAC;IAED,uGAAuG;IAEvG,iCAAiC;IACjC,IAAI,MAAM,CAAC,SAAS,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClD,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,iBAAiB,CAAC,0BAA0B;SACpD,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,KAAK,IAAI,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAClD,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,iBAAiB,CAAC,oBAAoB;SAC9C,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAY,EACZ,aAAkC;IAElC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,iBAAiB,CAAC,kBAAkB;SAC5C,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC","sourcesContent":["import { isValidHexAddress } from '@metamask/utils';\nimport type { CaipAssetId, Hex } from '@metamask/utils';\n\nimport {\n HYPERLIQUID_ASSET_CONFIGS,\n getSupportedAssets,\n TRADING_DEFAULTS,\n} from '../constants/hyperLiquidConfig';\nimport { HYPERLIQUID_ORDER_LIMITS } from '../constants/perpsConfig';\nimport { PERPS_ERROR_CODES } from '../perpsErrorCodes';\nimport type { GetSupportedPathsParams, PerpsDebugLogger } from '../types';\n\n/**\n * Optional debug logger for validation functions.\n * When provided, enables detailed logging for debugging.\n * When omitted, validation runs silently.\n */\nexport type ValidationDebugLogger = PerpsDebugLogger | undefined;\n\n/**\n * Validation utilities for HyperLiquid operations\n */\n\n/**\n * Create standardized error response.\n *\n * @param error - The error that occurred\n * @param defaultResponse - The default response object to use as template\n * @returns The error response with success=false and error message\n */\nexport function createErrorResult<\n TValue extends { success: boolean; error?: string },\n>(error: unknown, defaultResponse: TValue): TValue {\n return {\n ...defaultResponse,\n success: false,\n error:\n error instanceof Error ? error.message : PERPS_ERROR_CODES.UNKNOWN_ERROR,\n };\n}\n\n/**\n * Validate withdrawal parameters.\n *\n * @param params - Withdrawal parameters to validate\n * @param params.assetId - The CAIP asset ID to withdraw\n * @param params.amount - Amount to withdraw as string\n * @param params.destination - Optional destination hex address\n * @param debugLogger - Optional debug logger for detailed logging\n * @returns Validation result with isValid flag and optional error message\n */\nexport function validateWithdrawalParams(\n params: {\n assetId?: CaipAssetId;\n amount?: string;\n destination?: Hex;\n },\n debugLogger?: ValidationDebugLogger,\n): { isValid: boolean; error?: string } {\n debugLogger?.log('validateWithdrawalParams: Starting validation', {\n params,\n hasAssetId: Boolean(params.assetId),\n hasAmount: Boolean(params.amount),\n hasDestination: Boolean(params.destination),\n });\n\n // Validate required parameters\n if (!params.assetId) {\n debugLogger?.log('validateWithdrawalParams: Missing assetId', {\n error: PERPS_ERROR_CODES.WITHDRAW_ASSET_ID_REQUIRED,\n params,\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.WITHDRAW_ASSET_ID_REQUIRED,\n };\n }\n\n // Validate amount\n if (!params.amount) {\n debugLogger?.log('validateWithdrawalParams: Missing amount', {\n error: PERPS_ERROR_CODES.WITHDRAW_AMOUNT_REQUIRED,\n params,\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.WITHDRAW_AMOUNT_REQUIRED,\n };\n }\n\n const amount = parseFloat(params.amount);\n if (isNaN(amount) || amount <= 0) {\n debugLogger?.log('validateWithdrawalParams: Invalid amount', {\n error: PERPS_ERROR_CODES.WITHDRAW_AMOUNT_POSITIVE,\n amount: params.amount,\n parsedAmount: amount,\n isNaN: isNaN(amount),\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.WITHDRAW_AMOUNT_POSITIVE,\n };\n }\n\n // Validate destination address if provided\n if (params.destination && !isValidHexAddress(params.destination)) {\n debugLogger?.log('validateWithdrawalParams: Invalid destination address', {\n error: PERPS_ERROR_CODES.WITHDRAW_INVALID_DESTINATION,\n destination: params.destination,\n isValidHex: isValidHexAddress(params.destination),\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.WITHDRAW_INVALID_DESTINATION,\n };\n }\n\n debugLogger?.log('validateWithdrawalParams: All validations passed', {\n assetId: params.assetId,\n amount: params.amount,\n destination: params.destination ?? 'will use user wallet',\n });\n\n return { isValid: true };\n}\n\n/**\n * Validate deposit parameters.\n *\n * @param params - Deposit parameters to validate\n * @param params.assetId - The CAIP asset ID to deposit\n * @param params.amount - Amount to deposit as string\n * @param params.isTestnet - Whether this is a testnet deposit\n * @param debugLogger - Optional debug logger for detailed logging\n * @returns Validation result with isValid flag and optional error message\n */\nexport function validateDepositParams(\n params: {\n assetId?: CaipAssetId;\n amount?: string;\n isTestnet?: boolean;\n },\n debugLogger?: ValidationDebugLogger,\n): { isValid: boolean; error?: string } {\n debugLogger?.log('validateDepositParams: Starting validation', {\n params,\n hasAssetId: Boolean(params.assetId),\n hasAmount: Boolean(params.amount),\n isTestnet: params.isTestnet,\n });\n\n // Validate required parameters\n if (!params.assetId) {\n debugLogger?.log('validateDepositParams: Missing assetId', {\n error: PERPS_ERROR_CODES.DEPOSIT_ASSET_ID_REQUIRED,\n params,\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.DEPOSIT_ASSET_ID_REQUIRED,\n };\n }\n\n // Validate amount\n if (!params.amount) {\n debugLogger?.log('validateDepositParams: Missing amount', {\n error: PERPS_ERROR_CODES.DEPOSIT_AMOUNT_REQUIRED,\n params,\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.DEPOSIT_AMOUNT_REQUIRED,\n };\n }\n\n const amount = parseFloat(params.amount);\n if (isNaN(amount) || amount <= 0) {\n debugLogger?.log('validateDepositParams: Invalid amount', {\n error: PERPS_ERROR_CODES.DEPOSIT_AMOUNT_POSITIVE,\n amount: params.amount,\n parsedAmount: amount,\n isNaN: isNaN(amount),\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.DEPOSIT_AMOUNT_POSITIVE,\n };\n }\n\n // Check minimum deposit amount\n const minimumAmount = params.isTestnet\n ? TRADING_DEFAULTS.amount.testnet\n : TRADING_DEFAULTS.amount.mainnet;\n\n debugLogger?.log('validateDepositParams: Checking minimum amount', {\n amount,\n minimumAmount,\n isTestnet: params.isTestnet,\n network: params.isTestnet ? 'testnet' : 'mainnet',\n });\n\n if (amount < minimumAmount) {\n debugLogger?.log('validateDepositParams: Below minimum deposit', {\n error: PERPS_ERROR_CODES.DEPOSIT_MINIMUM_AMOUNT,\n amount,\n minimumAmount,\n difference: minimumAmount - amount,\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.DEPOSIT_MINIMUM_AMOUNT,\n };\n }\n\n debugLogger?.log('validateDepositParams: All validations passed', {\n assetId: params.assetId,\n amount: params.amount,\n parsedAmount: amount,\n minimumAmount,\n isTestnet: params.isTestnet,\n });\n\n return { isValid: true };\n}\n\n/**\n * Validate asset support for withdrawals using AssetRoute arrays.\n *\n * @param assetId - The CAIP asset ID to validate\n * @param supportedRoutes - Array of supported asset routes\n * @param debugLogger - Optional debug logger for detailed logging\n * @returns Validation result with isValid flag and optional error message\n */\nexport function validateAssetSupport(\n assetId: CaipAssetId,\n supportedRoutes: { assetId: CaipAssetId }[],\n debugLogger?: ValidationDebugLogger,\n): { isValid: boolean; error?: string } {\n debugLogger?.log('validateAssetSupport: Checking asset support', {\n assetId,\n supportedRoutesCount: supportedRoutes.length,\n });\n\n const supportedAssetIds = supportedRoutes.map((route) => route.assetId);\n\n // Check if asset is supported\n const isSupported = supportedAssetIds.includes(assetId);\n\n if (!isSupported) {\n // Also check case-insensitive match for contract addresses\n const isSupportedCaseInsensitive = supportedAssetIds.some(\n (supportedId) => supportedId.toLowerCase() === assetId.toLowerCase(),\n );\n\n if (!isSupportedCaseInsensitive) {\n debugLogger?.log('validateAssetSupport: Asset not supported', {\n error: PERPS_ERROR_CODES.WITHDRAW_ASSET_NOT_SUPPORTED,\n assetId,\n supportedAssetIds,\n checkedCaseInsensitive: true,\n });\n\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.WITHDRAW_ASSET_NOT_SUPPORTED,\n };\n }\n\n debugLogger?.log(\n '⚠️ validateAssetSupport: Asset supported with case mismatch',\n {\n providedAssetId: assetId,\n matchedAssetId: supportedAssetIds.find(\n (id) => id.toLowerCase() === assetId.toLowerCase(),\n ),\n },\n );\n }\n\n debugLogger?.log('validateAssetSupport: Asset is supported', {\n assetId,\n });\n\n return { isValid: true };\n}\n\n/**\n * Validate balance against withdrawal amount.\n *\n * @param withdrawAmount - The amount to withdraw\n * @param availableBalance - The available balance\n * @param debugLogger - Optional debug logger for detailed logging\n * @returns Validation result with isValid flag and optional error message\n */\nexport function validateBalance(\n withdrawAmount: number,\n availableBalance: number,\n debugLogger?: ValidationDebugLogger,\n): { isValid: boolean; error?: string } {\n debugLogger?.log('validateBalance: Checking balance sufficiency', {\n withdrawAmount,\n availableBalance,\n difference: availableBalance - withdrawAmount,\n });\n\n if (withdrawAmount > availableBalance) {\n const shortfall = withdrawAmount - availableBalance;\n\n debugLogger?.log('validateBalance: Insufficient balance', {\n error: PERPS_ERROR_CODES.WITHDRAW_INSUFFICIENT_BALANCE,\n withdrawAmount,\n availableBalance,\n shortfall,\n percentageOfAvailable: `${((withdrawAmount / availableBalance) * 100).toFixed(2)}%`,\n });\n\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.WITHDRAW_INSUFFICIENT_BALANCE,\n };\n }\n\n const remainingBalance = availableBalance - withdrawAmount;\n debugLogger?.log('validateBalance: Balance is sufficient', {\n withdrawAmount,\n availableBalance,\n remainingBalance,\n percentageUsed: `${((withdrawAmount / availableBalance) * 100).toFixed(2)}%`,\n });\n\n return { isValid: true };\n}\n\n/**\n * Apply filters to asset paths with comprehensive logging.\n *\n * @param assets - Array of CAIP asset IDs to filter\n * @param params - Filter parameters including chainId, symbol, and assetId\n * @param debugLogger - Optional debug logger for detailed logging\n * @returns Filtered array of CAIP asset IDs\n */\nexport function applyPathFilters(\n assets: CaipAssetId[],\n params?: GetSupportedPathsParams,\n debugLogger?: ValidationDebugLogger,\n): CaipAssetId[] {\n if (!params) {\n debugLogger?.log(\n 'HyperLiquid: applyPathFilters - no params, returning all assets',\n { assets },\n );\n return assets;\n }\n\n let filtered = assets;\n\n debugLogger?.log('HyperLiquid: applyPathFilters - starting filter', {\n initialAssets: assets,\n filterParams: params,\n });\n\n if (params.chainId) {\n const before = filtered;\n filtered = filtered.filter((asset) =>\n asset.startsWith(params.chainId as string),\n );\n debugLogger?.log('HyperLiquid: applyPathFilters - chainId filter', {\n chainId: params.chainId,\n before,\n after: filtered,\n });\n }\n\n if (params.symbol && params.symbol in HYPERLIQUID_ASSET_CONFIGS) {\n const config =\n HYPERLIQUID_ASSET_CONFIGS[\n params.symbol as keyof typeof HYPERLIQUID_ASSET_CONFIGS\n ];\n const isTestnet = params.isTestnet ?? false;\n const selectedAsset = isTestnet ? config.testnet : config.mainnet;\n const before = filtered;\n filtered = [selectedAsset];\n debugLogger?.log('HyperLiquid: applyPathFilters - symbol filter', {\n symbol: params.symbol,\n isTestnet,\n config,\n selectedAsset,\n before,\n after: filtered,\n });\n }\n\n if (params.assetId) {\n const before = filtered;\n // Use case-insensitive comparison for asset ID matching to handle address case differences\n filtered = filtered.filter(\n (asset) => asset.toLowerCase() === params.assetId?.toLowerCase(),\n );\n debugLogger?.log('HyperLiquid: applyPathFilters - assetId filter', {\n assetId: params.assetId,\n before,\n after: filtered,\n exactMatch: before.includes(params.assetId),\n caseInsensitiveMatch: before.some(\n (asset) => asset.toLowerCase() === params.assetId?.toLowerCase(),\n ),\n });\n }\n\n debugLogger?.log('HyperLiquid: applyPathFilters - final result', {\n initialAssets: assets,\n finalFiltered: filtered,\n filterParams: params,\n });\n\n return filtered;\n}\n\n/**\n * Get supported deposit/withdrawal paths with filtering.\n *\n * @param params - Filter parameters including isTestnet, chainId, symbol\n * @param debugLogger - Optional debug logger for detailed logging\n * @returns Array of supported CAIP asset IDs\n */\nexport function getSupportedPaths(\n params?: GetSupportedPathsParams,\n debugLogger?: ValidationDebugLogger,\n): CaipAssetId[] {\n const isTestnet = params?.isTestnet ?? false;\n const assets = getSupportedAssets(isTestnet);\n const filteredAssets = applyPathFilters(assets, params, debugLogger);\n\n debugLogger?.log('HyperLiquid: getSupportedPaths', {\n isTestnet,\n requestedParams: params,\n allAssets: assets,\n filteredAssets,\n returnType: 'CaipAssetId[]',\n example: filteredAssets[0],\n });\n\n return filteredAssets;\n}\n\n/**\n * Get maximum order value based on leverage and order type.\n * Based on HyperLiquid contract specifications.\n *\n * @param maxLeverage - The maximum leverage for the market\n * @param orderType - The order type (market or limit)\n * @returns Maximum order value in USD\n */\nexport function getMaxOrderValue(\n maxLeverage: number,\n orderType: 'market' | 'limit',\n): number {\n let marketLimit: number;\n\n if (maxLeverage >= 25) {\n marketLimit = HYPERLIQUID_ORDER_LIMITS.MarketOrderLimits.HighLeverage;\n } else if (maxLeverage >= 20) {\n marketLimit = HYPERLIQUID_ORDER_LIMITS.MarketOrderLimits.MediumHighLeverage;\n } else if (maxLeverage >= 10) {\n marketLimit = HYPERLIQUID_ORDER_LIMITS.MarketOrderLimits.MediumLeverage;\n } else {\n marketLimit = HYPERLIQUID_ORDER_LIMITS.MarketOrderLimits.LowLeverage;\n }\n\n return orderType === 'limit'\n ? marketLimit * HYPERLIQUID_ORDER_LIMITS.LimitOrderMultiplier\n : marketLimit;\n}\n\n/**\n * Validate order parameters.\n * Basic validation - checks required fields are present.\n * Amount validation (size/USD) is handled by validateOrder.\n *\n * @param params - Order parameters to validate\n * @param params.coin - The trading pair coin symbol\n * @param params.size - The order size as string\n * @param params.price - The order price as string\n * @param params.orderType - The order type (market or limit)\n * @returns Validation result with isValid flag and optional error message\n */\nexport function validateOrderParams(params: {\n coin?: string;\n size?: string;\n price?: string;\n orderType?: 'market' | 'limit';\n}): { isValid: boolean; error?: string } {\n if (!params.coin) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_COIN_REQUIRED,\n };\n }\n\n // Note: Size validation removed - validateOrder handles amount validation using USD as source of truth\n\n // Require price for limit orders\n if (params.orderType === 'limit' && !params.price) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_LIMIT_PRICE_REQUIRED,\n };\n }\n\n if (params.price && parseFloat(params.price) <= 0) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_PRICE_POSITIVE,\n };\n }\n\n return { isValid: true };\n}\n\n/**\n * Validate coin exists in asset mapping.\n *\n * @param coin - The coin symbol to validate\n * @param coinToAssetId - Map of coin symbols to asset IDs\n * @returns Validation result with isValid flag and optional error message\n */\nexport function validateCoinExists(\n coin: string,\n coinToAssetId: Map<string, number>,\n): { isValid: boolean; error?: string } {\n if (!coinToAssetId.has(coin)) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_UNKNOWN_COIN,\n };\n }\n\n return { isValid: true };\n}\n"]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateTransactionId = exports.generateOrderId = exports.generateWithdrawalId = exports.generateDepositId = exports.generatePerpsId = void 0;
4
+ const uuid_1 = require("uuid");
5
+ const generatePerpsId = (prefix) => {
6
+ const id = (0, uuid_1.v4)();
7
+ return prefix ? `${prefix}-${id}` : id;
8
+ };
9
+ exports.generatePerpsId = generatePerpsId;
10
+ const generateDepositId = () => (0, exports.generatePerpsId)('deposit');
11
+ exports.generateDepositId = generateDepositId;
12
+ const generateWithdrawalId = () => (0, exports.generatePerpsId)('withdrawal');
13
+ exports.generateWithdrawalId = generateWithdrawalId;
14
+ const generateOrderId = () => (0, exports.generatePerpsId)('order');
15
+ exports.generateOrderId = generateOrderId;
16
+ const generateTransactionId = () => (0, exports.generatePerpsId)('transaction');
17
+ exports.generateTransactionId = generateTransactionId;
18
+ //# sourceMappingURL=idUtils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idUtils.cjs","sourceRoot":"","sources":["../../src/utils/idUtils.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AAE7B,MAAM,eAAe,GAAG,CAAC,MAAe,EAAU,EAAE;IACzD,MAAM,EAAE,GAAG,IAAA,SAAM,GAAE,CAAC;IACpB,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACzC,CAAC,CAAC;AAHW,QAAA,eAAe,mBAG1B;AAEK,MAAM,iBAAiB,GAAG,GAAW,EAAE,CAAC,IAAA,uBAAe,EAAC,SAAS,CAAC,CAAC;AAA7D,QAAA,iBAAiB,qBAA4C;AACnE,MAAM,oBAAoB,GAAG,GAAW,EAAE,CAAC,IAAA,uBAAe,EAAC,YAAY,CAAC,CAAC;AAAnE,QAAA,oBAAoB,wBAA+C;AACzE,MAAM,eAAe,GAAG,GAAW,EAAE,CAAC,IAAA,uBAAe,EAAC,OAAO,CAAC,CAAC;AAAzD,QAAA,eAAe,mBAA0C;AAC/D,MAAM,qBAAqB,GAAG,GAAW,EAAE,CAChD,IAAA,uBAAe,EAAC,aAAa,CAAC,CAAC;AADpB,QAAA,qBAAqB,yBACD","sourcesContent":["import { v4 as uuidv4 } from 'uuid';\n\nexport const generatePerpsId = (prefix?: string): string => {\n const id = uuidv4();\n return prefix ? `${prefix}-${id}` : id;\n};\n\nexport const generateDepositId = (): string => generatePerpsId('deposit');\nexport const generateWithdrawalId = (): string => generatePerpsId('withdrawal');\nexport const generateOrderId = (): string => generatePerpsId('order');\nexport const generateTransactionId = (): string =>\n generatePerpsId('transaction');\n"]}
@@ -0,0 +1,6 @@
1
+ export declare const generatePerpsId: (prefix?: string) => string;
2
+ export declare const generateDepositId: () => string;
3
+ export declare const generateWithdrawalId: () => string;
4
+ export declare const generateOrderId: () => string;
5
+ export declare const generateTransactionId: () => string;
6
+ //# sourceMappingURL=idUtils.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idUtils.d.cts","sourceRoot":"","sources":["../../src/utils/idUtils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,YAAa,MAAM,KAAG,MAGjD,CAAC;AAEF,eAAO,MAAM,iBAAiB,QAAO,MAAoC,CAAC;AAC1E,eAAO,MAAM,oBAAoB,QAAO,MAAuC,CAAC;AAChF,eAAO,MAAM,eAAe,QAAO,MAAkC,CAAC;AACtE,eAAO,MAAM,qBAAqB,QAAO,MACT,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const generatePerpsId: (prefix?: string) => string;
2
+ export declare const generateDepositId: () => string;
3
+ export declare const generateWithdrawalId: () => string;
4
+ export declare const generateOrderId: () => string;
5
+ export declare const generateTransactionId: () => string;
6
+ //# sourceMappingURL=idUtils.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idUtils.d.mts","sourceRoot":"","sources":["../../src/utils/idUtils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,YAAa,MAAM,KAAG,MAGjD,CAAC;AAEF,eAAO,MAAM,iBAAiB,QAAO,MAAoC,CAAC;AAC1E,eAAO,MAAM,oBAAoB,QAAO,MAAuC,CAAC;AAChF,eAAO,MAAM,eAAe,QAAO,MAAkC,CAAC;AACtE,eAAO,MAAM,qBAAqB,QAAO,MACT,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { v4 as uuidv4 } from "uuid";
2
+ export const generatePerpsId = (prefix) => {
3
+ const id = uuidv4();
4
+ return prefix ? `${prefix}-${id}` : id;
5
+ };
6
+ export const generateDepositId = () => generatePerpsId('deposit');
7
+ export const generateWithdrawalId = () => generatePerpsId('withdrawal');
8
+ export const generateOrderId = () => generatePerpsId('order');
9
+ export const generateTransactionId = () => generatePerpsId('transaction');
10
+ //# sourceMappingURL=idUtils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idUtils.mjs","sourceRoot":"","sources":["../../src/utils/idUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,aAAa;AAEpC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAe,EAAU,EAAE;IACzD,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IACpB,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACzC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAW,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;AAC1E,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAW,EAAE,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;AAChF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAW,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AACtE,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAW,EAAE,CAChD,eAAe,CAAC,aAAa,CAAC,CAAC","sourcesContent":["import { v4 as uuidv4 } from 'uuid';\n\nexport const generatePerpsId = (prefix?: string): string => {\n const id = uuidv4();\n return prefix ? `${prefix}-${id}` : id;\n};\n\nexport const generateDepositId = (): string => generatePerpsId('deposit');\nexport const generateWithdrawalId = (): string => generatePerpsId('withdrawal');\nexport const generateOrderId = (): string => generatePerpsId('order');\nexport const generateTransactionId = (): string =>\n generatePerpsId('transaction');\n"]}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.getEnvironment = exports.adaptHyperLiquidLedgerUpdateToUserHistoryItem = exports.parseAssetName = exports.calculateHip3AssetId = exports.formatHyperLiquidSize = exports.formatHyperLiquidPrice = exports.buildAssetMapping = exports.adaptAccountStateFromSDK = exports.adaptMarketFromSDK = exports.adaptOrderFromSDK = exports.adaptPositionFromSDK = exports.adaptOrderToSDK = void 0;
18
+ /**
19
+ * Barrel re-export for all portable utilities in controllers/utils/
20
+ *
21
+ * Note: hyperLiquidAdapter and orderCalculations both export calculatePositionSize.
22
+ * We use selective exports to avoid the name collision.
23
+ */
24
+ __exportStar(require("./accountUtils.cjs"), exports);
25
+ __exportStar(require("./errorUtils.cjs"), exports);
26
+ // hyperLiquidAdapter: selective export to avoid calculatePositionSize clash with orderCalculations
27
+ var hyperLiquidAdapter_1 = require("./hyperLiquidAdapter.cjs");
28
+ Object.defineProperty(exports, "adaptOrderToSDK", { enumerable: true, get: function () { return hyperLiquidAdapter_1.adaptOrderToSDK; } });
29
+ Object.defineProperty(exports, "adaptPositionFromSDK", { enumerable: true, get: function () { return hyperLiquidAdapter_1.adaptPositionFromSDK; } });
30
+ Object.defineProperty(exports, "adaptOrderFromSDK", { enumerable: true, get: function () { return hyperLiquidAdapter_1.adaptOrderFromSDK; } });
31
+ Object.defineProperty(exports, "adaptMarketFromSDK", { enumerable: true, get: function () { return hyperLiquidAdapter_1.adaptMarketFromSDK; } });
32
+ Object.defineProperty(exports, "adaptAccountStateFromSDK", { enumerable: true, get: function () { return hyperLiquidAdapter_1.adaptAccountStateFromSDK; } });
33
+ Object.defineProperty(exports, "buildAssetMapping", { enumerable: true, get: function () { return hyperLiquidAdapter_1.buildAssetMapping; } });
34
+ Object.defineProperty(exports, "formatHyperLiquidPrice", { enumerable: true, get: function () { return hyperLiquidAdapter_1.formatHyperLiquidPrice; } });
35
+ Object.defineProperty(exports, "formatHyperLiquidSize", { enumerable: true, get: function () { return hyperLiquidAdapter_1.formatHyperLiquidSize; } });
36
+ Object.defineProperty(exports, "calculateHip3AssetId", { enumerable: true, get: function () { return hyperLiquidAdapter_1.calculateHip3AssetId; } });
37
+ Object.defineProperty(exports, "parseAssetName", { enumerable: true, get: function () { return hyperLiquidAdapter_1.parseAssetName; } });
38
+ Object.defineProperty(exports, "adaptHyperLiquidLedgerUpdateToUserHistoryItem", { enumerable: true, get: function () { return hyperLiquidAdapter_1.adaptHyperLiquidLedgerUpdateToUserHistoryItem; } });
39
+ __exportStar(require("./hyperLiquidOrderBookProcessor.cjs"), exports);
40
+ __exportStar(require("./hyperLiquidValidation.cjs"), exports);
41
+ __exportStar(require("./idUtils.cjs"), exports);
42
+ __exportStar(require("./marketDataTransform.cjs"), exports);
43
+ __exportStar(require("./myxAdapter.cjs"), exports);
44
+ __exportStar(require("./marketUtils.cjs"), exports);
45
+ __exportStar(require("./orderCalculations.cjs"), exports);
46
+ __exportStar(require("./rewardsUtils.cjs"), exports);
47
+ __exportStar(require("./significantFigures.cjs"), exports);
48
+ __exportStar(require("./sortMarkets.cjs"), exports);
49
+ __exportStar(require("./standaloneInfoClient.cjs"), exports);
50
+ __exportStar(require("./stringParseUtils.cjs"), exports);
51
+ __exportStar(require("./transferData.cjs"), exports);
52
+ __exportStar(require("./wait.cjs"), exports);
53
+ // Inline from former utils.ts (getEnvironment was previously at perps/utils.ts root)
54
+ const getEnvironment = () => {
55
+ const env = globalThis.process?.env?.NODE_ENV ?? 'production';
56
+ return env === 'production' ? 'PROD' : 'DEV';
57
+ };
58
+ exports.getEnvironment = getEnvironment;
59
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;GAKG;AACH,qDAA+B;AAC/B,mDAA6B;AAC7B,mGAAmG;AACnG,+DAY8B;AAX5B,qHAAA,eAAe,OAAA;AACf,0HAAA,oBAAoB,OAAA;AACpB,uHAAA,iBAAiB,OAAA;AACjB,wHAAA,kBAAkB,OAAA;AAClB,8HAAA,wBAAwB,OAAA;AACxB,uHAAA,iBAAiB,OAAA;AACjB,4HAAA,sBAAsB,OAAA;AACtB,2HAAA,qBAAqB,OAAA;AACrB,0HAAA,oBAAoB,OAAA;AACpB,oHAAA,cAAc,OAAA;AACd,mJAAA,6CAA6C,OAAA;AAE/C,sEAAgD;AAChD,8DAAwC;AACxC,gDAA0B;AAC1B,4DAAsC;AACtC,mDAA6B;AAC7B,oDAA8B;AAC9B,0DAAoC;AACpC,qDAA+B;AAC/B,2DAAqC;AACrC,oDAA8B;AAC9B,6DAAuC;AACvC,yDAAmC;AACnC,qDAA+B;AAC/B,6CAAuB;AAEvB,qFAAqF;AAC9E,MAAM,cAAc,GAAG,GAAmB,EAAE;IACjD,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,IAAI,YAAY,CAAC;IAC9D,OAAO,GAAG,KAAK,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;AAC/C,CAAC,CAAC;AAHW,QAAA,cAAc,kBAGzB","sourcesContent":["/**\n * Barrel re-export for all portable utilities in controllers/utils/\n *\n * Note: hyperLiquidAdapter and orderCalculations both export calculatePositionSize.\n * We use selective exports to avoid the name collision.\n */\nexport * from './accountUtils';\nexport * from './errorUtils';\n// hyperLiquidAdapter: selective export to avoid calculatePositionSize clash with orderCalculations\nexport {\n adaptOrderToSDK,\n adaptPositionFromSDK,\n adaptOrderFromSDK,\n adaptMarketFromSDK,\n adaptAccountStateFromSDK,\n buildAssetMapping,\n formatHyperLiquidPrice,\n formatHyperLiquidSize,\n calculateHip3AssetId,\n parseAssetName,\n adaptHyperLiquidLedgerUpdateToUserHistoryItem,\n} from './hyperLiquidAdapter';\nexport * from './hyperLiquidOrderBookProcessor';\nexport * from './hyperLiquidValidation';\nexport * from './idUtils';\nexport * from './marketDataTransform';\nexport * from './myxAdapter';\nexport * from './marketUtils';\nexport * from './orderCalculations';\nexport * from './rewardsUtils';\nexport * from './significantFigures';\nexport * from './sortMarkets';\nexport * from './standaloneInfoClient';\nexport * from './stringParseUtils';\nexport * from './transferData';\nexport * from './wait';\n\n// Inline from former utils.ts (getEnvironment was previously at perps/utils.ts root)\nexport const getEnvironment = (): 'DEV' | 'PROD' => {\n const env = globalThis.process?.env?.NODE_ENV ?? 'production';\n return env === 'production' ? 'PROD' : 'DEV';\n};\n"]}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Barrel re-export for all portable utilities in controllers/utils/
3
+ *
4
+ * Note: hyperLiquidAdapter and orderCalculations both export calculatePositionSize.
5
+ * We use selective exports to avoid the name collision.
6
+ */
7
+ export * from "./accountUtils.cjs";
8
+ export * from "./errorUtils.cjs";
9
+ export { adaptOrderToSDK, adaptPositionFromSDK, adaptOrderFromSDK, adaptMarketFromSDK, adaptAccountStateFromSDK, buildAssetMapping, formatHyperLiquidPrice, formatHyperLiquidSize, calculateHip3AssetId, parseAssetName, adaptHyperLiquidLedgerUpdateToUserHistoryItem, } from "./hyperLiquidAdapter.cjs";
10
+ export * from "./hyperLiquidOrderBookProcessor.cjs";
11
+ export * from "./hyperLiquidValidation.cjs";
12
+ export * from "./idUtils.cjs";
13
+ export * from "./marketDataTransform.cjs";
14
+ export * from "./myxAdapter.cjs";
15
+ export * from "./marketUtils.cjs";
16
+ export * from "./orderCalculations.cjs";
17
+ export * from "./rewardsUtils.cjs";
18
+ export * from "./significantFigures.cjs";
19
+ export * from "./sortMarkets.cjs";
20
+ export * from "./standaloneInfoClient.cjs";
21
+ export * from "./stringParseUtils.cjs";
22
+ export * from "./transferData.cjs";
23
+ export * from "./wait.cjs";
24
+ export declare const getEnvironment: () => 'DEV' | 'PROD';
25
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,mCAA+B;AAC/B,iCAA6B;AAE7B,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,6CAA6C,GAC9C,iCAA6B;AAC9B,oDAAgD;AAChD,4CAAwC;AACxC,8BAA0B;AAC1B,0CAAsC;AACtC,iCAA6B;AAC7B,kCAA8B;AAC9B,wCAAoC;AACpC,mCAA+B;AAC/B,yCAAqC;AACrC,kCAA8B;AAC9B,2CAAuC;AACvC,uCAAmC;AACnC,mCAA+B;AAC/B,2BAAuB;AAGvB,eAAO,MAAM,cAAc,QAAO,KAAK,GAAG,MAGzC,CAAC"}