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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (498) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/dist/PerpsController.cjs +2224 -66
  3. package/dist/PerpsController.cjs.map +1 -1
  4. package/dist/PerpsController.d.cts +933 -79
  5. package/dist/PerpsController.d.cts.map +1 -1
  6. package/dist/PerpsController.d.mts +933 -79
  7. package/dist/PerpsController.d.mts.map +1 -1
  8. package/dist/PerpsController.mjs +2221 -64
  9. package/dist/PerpsController.mjs.map +1 -1
  10. package/dist/__mocks__/hyperliquidMock.cjs +68 -0
  11. package/dist/__mocks__/hyperliquidMock.cjs.map +1 -0
  12. package/dist/__mocks__/hyperliquidMock.d.cts +15 -0
  13. package/dist/__mocks__/hyperliquidMock.d.cts.map +1 -0
  14. package/dist/__mocks__/hyperliquidMock.d.mts +15 -0
  15. package/dist/__mocks__/hyperliquidMock.d.mts.map +1 -0
  16. package/dist/__mocks__/hyperliquidMock.mjs +65 -0
  17. package/dist/__mocks__/hyperliquidMock.mjs.map +1 -0
  18. package/dist/__mocks__/providerMocks.cjs +144 -0
  19. package/dist/__mocks__/providerMocks.cjs.map +1 -0
  20. package/dist/__mocks__/providerMocks.d.cts +44 -0
  21. package/dist/__mocks__/providerMocks.d.cts.map +1 -0
  22. package/dist/__mocks__/providerMocks.d.mts +44 -0
  23. package/dist/__mocks__/providerMocks.d.mts.map +1 -0
  24. package/dist/__mocks__/providerMocks.mjs +136 -0
  25. package/dist/__mocks__/providerMocks.mjs.map +1 -0
  26. package/dist/__mocks__/serviceMocks.cjs +187 -0
  27. package/dist/__mocks__/serviceMocks.cjs.map +1 -0
  28. package/dist/__mocks__/serviceMocks.d.cts +58 -0
  29. package/dist/__mocks__/serviceMocks.d.cts.map +1 -0
  30. package/dist/__mocks__/serviceMocks.d.mts +58 -0
  31. package/dist/__mocks__/serviceMocks.d.mts.map +1 -0
  32. package/dist/__mocks__/serviceMocks.mjs +180 -0
  33. package/dist/__mocks__/serviceMocks.mjs.map +1 -0
  34. package/dist/aggregation/SubscriptionMultiplexer.cjs +459 -0
  35. package/dist/aggregation/SubscriptionMultiplexer.cjs.map +1 -0
  36. package/dist/aggregation/SubscriptionMultiplexer.d.cts +222 -0
  37. package/dist/aggregation/SubscriptionMultiplexer.d.cts.map +1 -0
  38. package/dist/aggregation/SubscriptionMultiplexer.d.mts +222 -0
  39. package/dist/aggregation/SubscriptionMultiplexer.d.mts.map +1 -0
  40. package/dist/aggregation/SubscriptionMultiplexer.mjs +455 -0
  41. package/dist/aggregation/SubscriptionMultiplexer.mjs.map +1 -0
  42. package/dist/aggregation/index.cjs +9 -0
  43. package/dist/aggregation/index.cjs.map +1 -0
  44. package/dist/aggregation/index.d.cts +6 -0
  45. package/dist/aggregation/index.d.cts.map +1 -0
  46. package/dist/aggregation/index.d.mts +6 -0
  47. package/dist/aggregation/index.d.mts.map +1 -0
  48. package/dist/aggregation/index.mjs +5 -0
  49. package/dist/aggregation/index.mjs.map +1 -0
  50. package/dist/constants/eventNames.cjs +117 -0
  51. package/dist/constants/eventNames.cjs.map +1 -0
  52. package/dist/constants/eventNames.d.cts +106 -0
  53. package/dist/constants/eventNames.d.cts.map +1 -0
  54. package/dist/constants/eventNames.d.mts +106 -0
  55. package/dist/constants/eventNames.d.mts.map +1 -0
  56. package/dist/constants/eventNames.mjs +114 -0
  57. package/dist/constants/eventNames.mjs.map +1 -0
  58. package/dist/constants/hyperLiquidConfig.cjs +366 -0
  59. package/dist/constants/hyperLiquidConfig.cjs.map +1 -0
  60. package/dist/constants/hyperLiquidConfig.d.cts +276 -0
  61. package/dist/constants/hyperLiquidConfig.d.cts.map +1 -0
  62. package/dist/constants/hyperLiquidConfig.d.mts +276 -0
  63. package/dist/constants/hyperLiquidConfig.d.mts.map +1 -0
  64. package/dist/constants/hyperLiquidConfig.mjs +357 -0
  65. package/dist/constants/hyperLiquidConfig.mjs.map +1 -0
  66. package/dist/constants/index.cjs +23 -0
  67. package/dist/constants/index.cjs.map +1 -0
  68. package/dist/constants/index.d.cts +7 -0
  69. package/dist/constants/index.d.cts.map +1 -0
  70. package/dist/constants/index.d.mts +7 -0
  71. package/dist/constants/index.d.mts.map +1 -0
  72. package/dist/constants/index.mjs +7 -0
  73. package/dist/constants/index.mjs.map +1 -0
  74. package/dist/constants/orderTypes.cjs +31 -0
  75. package/dist/constants/orderTypes.cjs.map +1 -0
  76. package/dist/constants/orderTypes.d.cts +19 -0
  77. package/dist/constants/orderTypes.d.cts.map +1 -0
  78. package/dist/constants/orderTypes.d.mts +19 -0
  79. package/dist/constants/orderTypes.d.mts.map +1 -0
  80. package/dist/constants/orderTypes.mjs +27 -0
  81. package/dist/constants/orderTypes.mjs.map +1 -0
  82. package/dist/constants/performanceMetrics.cjs +61 -0
  83. package/dist/constants/performanceMetrics.cjs.map +1 -0
  84. package/dist/constants/performanceMetrics.d.cts +44 -0
  85. package/dist/constants/performanceMetrics.d.cts.map +1 -0
  86. package/dist/constants/performanceMetrics.d.mts +44 -0
  87. package/dist/constants/performanceMetrics.d.mts.map +1 -0
  88. package/dist/constants/performanceMetrics.mjs +58 -0
  89. package/dist/constants/performanceMetrics.mjs.map +1 -0
  90. package/dist/constants/perpsConfig.cjs +461 -0
  91. package/dist/constants/perpsConfig.cjs.map +1 -0
  92. package/dist/constants/perpsConfig.d.cts +343 -0
  93. package/dist/constants/perpsConfig.d.cts.map +1 -0
  94. package/dist/constants/perpsConfig.d.mts +343 -0
  95. package/dist/constants/perpsConfig.d.mts.map +1 -0
  96. package/dist/constants/perpsConfig.mjs +458 -0
  97. package/dist/constants/perpsConfig.mjs.map +1 -0
  98. package/dist/constants/perpsErrorCodes.cjs +79 -0
  99. package/dist/constants/perpsErrorCodes.cjs.map +1 -0
  100. package/dist/constants/perpsErrorCodes.d.cts +64 -0
  101. package/dist/constants/perpsErrorCodes.d.cts.map +1 -0
  102. package/dist/constants/perpsErrorCodes.d.mts +64 -0
  103. package/dist/constants/perpsErrorCodes.d.mts.map +1 -0
  104. package/dist/constants/perpsErrorCodes.mjs +76 -0
  105. package/dist/constants/perpsErrorCodes.mjs.map +1 -0
  106. package/dist/index.cjs +32 -1
  107. package/dist/index.cjs.map +1 -1
  108. package/dist/index.d.cts +6 -2
  109. package/dist/index.d.cts.map +1 -1
  110. package/dist/index.d.mts +6 -2
  111. package/dist/index.d.mts.map +1 -1
  112. package/dist/index.mjs +9 -1
  113. package/dist/index.mjs.map +1 -1
  114. package/dist/platform-services/HyperLiquidClientService.cjs +857 -0
  115. package/dist/platform-services/HyperLiquidClientService.cjs.map +1 -0
  116. package/dist/platform-services/HyperLiquidClientService.d.cts +263 -0
  117. package/dist/platform-services/HyperLiquidClientService.d.cts.map +1 -0
  118. package/dist/platform-services/HyperLiquidClientService.d.mts +263 -0
  119. package/dist/platform-services/HyperLiquidClientService.d.mts.map +1 -0
  120. package/dist/platform-services/HyperLiquidClientService.mjs +853 -0
  121. package/dist/platform-services/HyperLiquidClientService.mjs.map +1 -0
  122. package/dist/platform-services/HyperLiquidSubscriptionService.cjs +2170 -0
  123. package/dist/platform-services/HyperLiquidSubscriptionService.cjs.map +1 -0
  124. package/dist/platform-services/HyperLiquidSubscriptionService.d.cts +424 -0
  125. package/dist/platform-services/HyperLiquidSubscriptionService.d.cts.map +1 -0
  126. package/dist/platform-services/HyperLiquidSubscriptionService.d.mts +424 -0
  127. package/dist/platform-services/HyperLiquidSubscriptionService.d.mts.map +1 -0
  128. package/dist/platform-services/HyperLiquidSubscriptionService.mjs +2166 -0
  129. package/dist/platform-services/HyperLiquidSubscriptionService.mjs.map +1 -0
  130. package/dist/platform-services/HyperLiquidWalletService.cjs +140 -0
  131. package/dist/platform-services/HyperLiquidWalletService.cjs.map +1 -0
  132. package/dist/platform-services/HyperLiquidWalletService.d.cts +78 -0
  133. package/dist/platform-services/HyperLiquidWalletService.d.cts.map +1 -0
  134. package/dist/platform-services/HyperLiquidWalletService.d.mts +78 -0
  135. package/dist/platform-services/HyperLiquidWalletService.d.mts.map +1 -0
  136. package/dist/platform-services/HyperLiquidWalletService.mjs +136 -0
  137. package/dist/platform-services/HyperLiquidWalletService.mjs.map +1 -0
  138. package/dist/providers/AggregatedPerpsProvider.cjs +777 -0
  139. package/dist/providers/AggregatedPerpsProvider.cjs.map +1 -0
  140. package/dist/providers/AggregatedPerpsProvider.d.cts +466 -0
  141. package/dist/providers/AggregatedPerpsProvider.d.cts.map +1 -0
  142. package/dist/providers/AggregatedPerpsProvider.d.mts +466 -0
  143. package/dist/providers/AggregatedPerpsProvider.d.mts.map +1 -0
  144. package/dist/providers/AggregatedPerpsProvider.mjs +773 -0
  145. package/dist/providers/AggregatedPerpsProvider.mjs.map +1 -0
  146. package/dist/providers/HyperLiquidProvider.cjs +5172 -0
  147. package/dist/providers/HyperLiquidProvider.cjs.map +1 -0
  148. package/dist/providers/HyperLiquidProvider.d.cts +881 -0
  149. package/dist/providers/HyperLiquidProvider.d.cts.map +1 -0
  150. package/dist/providers/HyperLiquidProvider.d.mts +881 -0
  151. package/dist/providers/HyperLiquidProvider.d.mts.map +1 -0
  152. package/dist/providers/HyperLiquidProvider.mjs +5168 -0
  153. package/dist/providers/HyperLiquidProvider.mjs.map +1 -0
  154. package/dist/providers/index.cjs +11 -0
  155. package/dist/providers/index.cjs.map +1 -0
  156. package/dist/providers/index.d.cts +6 -0
  157. package/dist/providers/index.d.cts.map +1 -0
  158. package/dist/providers/index.d.mts +6 -0
  159. package/dist/providers/index.d.mts.map +1 -0
  160. package/dist/providers/index.mjs +6 -0
  161. package/dist/providers/index.mjs.map +1 -0
  162. package/dist/routing/ProviderRouter.cjs +148 -0
  163. package/dist/routing/ProviderRouter.cjs.map +1 -0
  164. package/dist/routing/ProviderRouter.d.cts +124 -0
  165. package/dist/routing/ProviderRouter.d.cts.map +1 -0
  166. package/dist/routing/ProviderRouter.d.mts +124 -0
  167. package/dist/routing/ProviderRouter.d.mts.map +1 -0
  168. package/dist/routing/ProviderRouter.mjs +144 -0
  169. package/dist/routing/ProviderRouter.mjs.map +1 -0
  170. package/dist/routing/index.cjs +9 -0
  171. package/dist/routing/index.cjs.map +1 -0
  172. package/dist/routing/index.d.cts +6 -0
  173. package/dist/routing/index.d.cts.map +1 -0
  174. package/dist/routing/index.d.mts +6 -0
  175. package/dist/routing/index.d.mts.map +1 -0
  176. package/dist/routing/index.mjs +5 -0
  177. package/dist/routing/index.mjs.map +1 -0
  178. package/dist/selectors.cjs +161 -0
  179. package/dist/selectors.cjs.map +1 -0
  180. package/dist/selectors.d.cts +345 -0
  181. package/dist/selectors.d.cts.map +1 -0
  182. package/dist/selectors.d.mts +345 -0
  183. package/dist/selectors.d.mts.map +1 -0
  184. package/dist/selectors.mjs +153 -0
  185. package/dist/selectors.mjs.map +1 -0
  186. package/dist/services/AccountService.cjs +313 -0
  187. package/dist/services/AccountService.cjs.map +1 -0
  188. package/dist/services/AccountService.d.cts +53 -0
  189. package/dist/services/AccountService.d.cts.map +1 -0
  190. package/dist/services/AccountService.d.mts +53 -0
  191. package/dist/services/AccountService.d.mts.map +1 -0
  192. package/dist/services/AccountService.mjs +309 -0
  193. package/dist/services/AccountService.mjs.map +1 -0
  194. package/dist/services/DataLakeService.cjs +219 -0
  195. package/dist/services/DataLakeService.cjs.map +1 -0
  196. package/dist/services/DataLakeService.d.cts +49 -0
  197. package/dist/services/DataLakeService.d.cts.map +1 -0
  198. package/dist/services/DataLakeService.d.mts +49 -0
  199. package/dist/services/DataLakeService.d.mts.map +1 -0
  200. package/dist/services/DataLakeService.mjs +215 -0
  201. package/dist/services/DataLakeService.mjs.map +1 -0
  202. package/dist/services/DepositService.cjs +96 -0
  203. package/dist/services/DepositService.cjs.map +1 -0
  204. package/dist/services/DepositService.d.cts +37 -0
  205. package/dist/services/DepositService.d.cts.map +1 -0
  206. package/dist/services/DepositService.d.mts +37 -0
  207. package/dist/services/DepositService.d.mts.map +1 -0
  208. package/dist/services/DepositService.mjs +92 -0
  209. package/dist/services/DepositService.mjs.map +1 -0
  210. package/dist/services/EligibilityService.cjs +156 -0
  211. package/dist/services/EligibilityService.cjs.map +1 -0
  212. package/dist/services/EligibilityService.d.cts +48 -0
  213. package/dist/services/EligibilityService.d.cts.map +1 -0
  214. package/dist/services/EligibilityService.d.mts +48 -0
  215. package/dist/services/EligibilityService.d.mts.map +1 -0
  216. package/dist/services/EligibilityService.mjs +152 -0
  217. package/dist/services/EligibilityService.mjs.map +1 -0
  218. package/dist/services/FeatureFlagConfigurationService.cjs +258 -0
  219. package/dist/services/FeatureFlagConfigurationService.cjs.map +1 -0
  220. package/dist/services/FeatureFlagConfigurationService.d.cts +100 -0
  221. package/dist/services/FeatureFlagConfigurationService.d.cts.map +1 -0
  222. package/dist/services/FeatureFlagConfigurationService.d.mts +100 -0
  223. package/dist/services/FeatureFlagConfigurationService.d.mts.map +1 -0
  224. package/dist/services/FeatureFlagConfigurationService.mjs +254 -0
  225. package/dist/services/FeatureFlagConfigurationService.mjs.map +1 -0
  226. package/dist/services/MarketDataService.cjs +875 -0
  227. package/dist/services/MarketDataService.cjs.map +1 -0
  228. package/dist/services/MarketDataService.d.cts +289 -0
  229. package/dist/services/MarketDataService.d.cts.map +1 -0
  230. package/dist/services/MarketDataService.d.mts +289 -0
  231. package/dist/services/MarketDataService.d.mts.map +1 -0
  232. package/dist/services/MarketDataService.mjs +871 -0
  233. package/dist/services/MarketDataService.mjs.map +1 -0
  234. package/dist/services/RewardsIntegrationService.cjs +94 -0
  235. package/dist/services/RewardsIntegrationService.cjs.map +1 -0
  236. package/dist/services/RewardsIntegrationService.d.cts +30 -0
  237. package/dist/services/RewardsIntegrationService.d.cts.map +1 -0
  238. package/dist/services/RewardsIntegrationService.d.mts +30 -0
  239. package/dist/services/RewardsIntegrationService.d.mts.map +1 -0
  240. package/dist/services/RewardsIntegrationService.mjs +90 -0
  241. package/dist/services/RewardsIntegrationService.mjs.map +1 -0
  242. package/dist/services/ServiceContext.cjs +3 -0
  243. package/dist/services/ServiceContext.cjs.map +1 -0
  244. package/dist/services/ServiceContext.d.cts +110 -0
  245. package/dist/services/ServiceContext.d.cts.map +1 -0
  246. package/dist/services/ServiceContext.d.mts +110 -0
  247. package/dist/services/ServiceContext.d.mts.map +1 -0
  248. package/dist/services/ServiceContext.mjs +2 -0
  249. package/dist/services/ServiceContext.mjs.map +1 -0
  250. package/dist/services/TradingService.cjs +1481 -0
  251. package/dist/services/TradingService.cjs.map +1 -0
  252. package/dist/services/TradingService.d.cts +308 -0
  253. package/dist/services/TradingService.d.cts.map +1 -0
  254. package/dist/services/TradingService.d.mts +308 -0
  255. package/dist/services/TradingService.d.mts.map +1 -0
  256. package/dist/services/TradingService.mjs +1477 -0
  257. package/dist/services/TradingService.mjs.map +1 -0
  258. package/dist/services/index.cjs +26 -0
  259. package/dist/services/index.cjs.map +1 -0
  260. package/dist/services/index.d.cts +11 -0
  261. package/dist/services/index.d.cts.map +1 -0
  262. package/dist/services/index.d.mts +11 -0
  263. package/dist/services/index.d.mts.map +1 -0
  264. package/dist/services/index.mjs +10 -0
  265. package/dist/services/index.mjs.map +1 -0
  266. package/dist/services/utils.cjs +16 -0
  267. package/dist/services/utils.cjs.map +1 -0
  268. package/dist/services/utils.d.cts +8 -0
  269. package/dist/services/utils.d.cts.map +1 -0
  270. package/dist/services/utils.d.mts +8 -0
  271. package/dist/services/utils.d.mts.map +1 -0
  272. package/dist/services/utils.mjs +12 -0
  273. package/dist/services/utils.mjs.map +1 -0
  274. package/dist/types/chart.cjs +42 -0
  275. package/dist/types/chart.cjs.map +1 -0
  276. package/dist/types/chart.d.cts +62 -0
  277. package/dist/types/chart.d.cts.map +1 -0
  278. package/dist/types/chart.d.mts +62 -0
  279. package/dist/types/chart.d.mts.map +1 -0
  280. package/dist/types/chart.mjs +39 -0
  281. package/dist/types/chart.mjs.map +1 -0
  282. package/dist/types/hyperliquid-types.cjs +3 -0
  283. package/dist/types/hyperliquid-types.cjs.map +1 -0
  284. package/dist/types/hyperliquid-types.d.cts +52 -0
  285. package/dist/types/hyperliquid-types.d.cts.map +1 -0
  286. package/dist/types/hyperliquid-types.d.mts +52 -0
  287. package/dist/types/hyperliquid-types.d.mts.map +1 -0
  288. package/dist/types/hyperliquid-types.mjs +2 -0
  289. package/dist/types/hyperliquid-types.mjs.map +1 -0
  290. package/dist/types/index.cjs +96 -0
  291. package/dist/types/index.cjs.map +1 -0
  292. package/dist/types/index.d.cts +1153 -0
  293. package/dist/types/index.d.cts.map +1 -0
  294. package/dist/types/index.d.mts +1153 -0
  295. package/dist/types/index.d.mts.map +1 -0
  296. package/dist/types/index.mjs +79 -0
  297. package/dist/types/index.mjs.map +1 -0
  298. package/dist/types/transactionTypes.cjs +28 -0
  299. package/dist/types/transactionTypes.cjs.map +1 -0
  300. package/dist/types/transactionTypes.d.cts +64 -0
  301. package/dist/types/transactionTypes.d.cts.map +1 -0
  302. package/dist/types/transactionTypes.d.mts +64 -0
  303. package/dist/types/transactionTypes.d.mts.map +1 -0
  304. package/dist/types/transactionTypes.mjs +23 -0
  305. package/dist/types/transactionTypes.mjs.map +1 -0
  306. package/dist/utils/accountUtils.cjs +65 -0
  307. package/dist/utils/accountUtils.cjs.map +1 -0
  308. package/dist/utils/accountUtils.d.cts +26 -0
  309. package/dist/utils/accountUtils.d.cts.map +1 -0
  310. package/dist/utils/accountUtils.d.mts +26 -0
  311. package/dist/utils/accountUtils.d.mts.map +1 -0
  312. package/dist/utils/accountUtils.mjs +61 -0
  313. package/dist/utils/accountUtils.mjs.map +1 -0
  314. package/dist/utils/amountConversion.cjs +61 -0
  315. package/dist/utils/amountConversion.cjs.map +1 -0
  316. package/dist/utils/amountConversion.d.cts +16 -0
  317. package/dist/utils/amountConversion.d.cts.map +1 -0
  318. package/dist/utils/amountConversion.d.mts +16 -0
  319. package/dist/utils/amountConversion.d.mts.map +1 -0
  320. package/dist/utils/amountConversion.mjs +54 -0
  321. package/dist/utils/amountConversion.mjs.map +1 -0
  322. package/dist/utils/chartUtils.cjs +98 -0
  323. package/dist/utils/chartUtils.cjs.map +1 -0
  324. package/dist/utils/chartUtils.d.cts +14 -0
  325. package/dist/utils/chartUtils.d.cts.map +1 -0
  326. package/dist/utils/chartUtils.d.mts +14 -0
  327. package/dist/utils/chartUtils.d.mts.map +1 -0
  328. package/dist/utils/chartUtils.mjs +94 -0
  329. package/dist/utils/chartUtils.mjs.map +1 -0
  330. package/dist/utils/errorUtils.cjs +22 -0
  331. package/dist/utils/errorUtils.cjs.map +1 -0
  332. package/dist/utils/errorUtils.d.cts +13 -0
  333. package/dist/utils/errorUtils.d.cts.map +1 -0
  334. package/dist/utils/errorUtils.d.mts +13 -0
  335. package/dist/utils/errorUtils.d.mts.map +1 -0
  336. package/dist/utils/errorUtils.mjs +18 -0
  337. package/dist/utils/errorUtils.mjs.map +1 -0
  338. package/dist/utils/formatUtils.cjs +987 -0
  339. package/dist/utils/formatUtils.cjs.map +1 -0
  340. package/dist/utils/formatUtils.d.cts +387 -0
  341. package/dist/utils/formatUtils.d.cts.map +1 -0
  342. package/dist/utils/formatUtils.d.mts +387 -0
  343. package/dist/utils/formatUtils.d.mts.map +1 -0
  344. package/dist/utils/formatUtils.mjs +966 -0
  345. package/dist/utils/formatUtils.mjs.map +1 -0
  346. package/dist/utils/hyperLiquidAdapter.cjs +454 -0
  347. package/dist/utils/hyperLiquidAdapter.cjs.map +1 -0
  348. package/dist/utils/hyperLiquidAdapter.d.cts +158 -0
  349. package/dist/utils/hyperLiquidAdapter.d.cts.map +1 -0
  350. package/dist/utils/hyperLiquidAdapter.d.mts +158 -0
  351. package/dist/utils/hyperLiquidAdapter.d.mts.map +1 -0
  352. package/dist/utils/hyperLiquidAdapter.mjs +439 -0
  353. package/dist/utils/hyperLiquidAdapter.mjs.map +1 -0
  354. package/dist/utils/hyperLiquidOrderBookProcessor.cjs +89 -0
  355. package/dist/utils/hyperLiquidOrderBookProcessor.cjs.map +1 -0
  356. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts +58 -0
  357. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts.map +1 -0
  358. package/dist/utils/hyperLiquidOrderBookProcessor.d.mts +58 -0
  359. package/dist/utils/hyperLiquidOrderBookProcessor.d.mts.map +1 -0
  360. package/dist/utils/hyperLiquidOrderBookProcessor.mjs +84 -0
  361. package/dist/utils/hyperLiquidOrderBookProcessor.mjs.map +1 -0
  362. package/dist/utils/hyperLiquidValidation.cjs +426 -0
  363. package/dist/utils/hyperLiquidValidation.cjs.map +1 -0
  364. package/dist/utils/hyperLiquidValidation.d.cts +143 -0
  365. package/dist/utils/hyperLiquidValidation.d.cts.map +1 -0
  366. package/dist/utils/hyperLiquidValidation.d.mts +143 -0
  367. package/dist/utils/hyperLiquidValidation.d.mts.map +1 -0
  368. package/dist/utils/hyperLiquidValidation.mjs +413 -0
  369. package/dist/utils/hyperLiquidValidation.mjs.map +1 -0
  370. package/dist/utils/idUtils.cjs +50 -0
  371. package/dist/utils/idUtils.cjs.map +1 -0
  372. package/dist/utils/idUtils.d.cts +38 -0
  373. package/dist/utils/idUtils.d.cts.map +1 -0
  374. package/dist/utils/idUtils.d.mts +38 -0
  375. package/dist/utils/idUtils.d.mts.map +1 -0
  376. package/dist/utils/idUtils.mjs +42 -0
  377. package/dist/utils/idUtils.mjs.map +1 -0
  378. package/dist/utils/marginUtils.cjs +137 -0
  379. package/dist/utils/marginUtils.cjs.map +1 -0
  380. package/dist/utils/marginUtils.d.cts +64 -0
  381. package/dist/utils/marginUtils.d.cts.map +1 -0
  382. package/dist/utils/marginUtils.d.mts +64 -0
  383. package/dist/utils/marginUtils.d.mts.map +1 -0
  384. package/dist/utils/marginUtils.mjs +131 -0
  385. package/dist/utils/marginUtils.mjs.map +1 -0
  386. package/dist/utils/marketDataTransform.cjs +227 -0
  387. package/dist/utils/marketDataTransform.cjs.map +1 -0
  388. package/dist/utils/marketDataTransform.d.cts +45 -0
  389. package/dist/utils/marketDataTransform.d.cts.map +1 -0
  390. package/dist/utils/marketDataTransform.d.mts +45 -0
  391. package/dist/utils/marketDataTransform.d.mts.map +1 -0
  392. package/dist/utils/marketDataTransform.mjs +220 -0
  393. package/dist/utils/marketDataTransform.mjs.map +1 -0
  394. package/dist/utils/marketUtils.cjs +420 -0
  395. package/dist/utils/marketUtils.cjs.map +1 -0
  396. package/dist/utils/marketUtils.d.cts +227 -0
  397. package/dist/utils/marketUtils.d.cts.map +1 -0
  398. package/dist/utils/marketUtils.d.mts +227 -0
  399. package/dist/utils/marketUtils.d.mts.map +1 -0
  400. package/dist/utils/marketUtils.mjs +404 -0
  401. package/dist/utils/marketUtils.mjs.map +1 -0
  402. package/dist/utils/orderBookGrouping.cjs +151 -0
  403. package/dist/utils/orderBookGrouping.cjs.map +1 -0
  404. package/dist/utils/orderBookGrouping.d.cts +76 -0
  405. package/dist/utils/orderBookGrouping.d.cts.map +1 -0
  406. package/dist/utils/orderBookGrouping.d.mts +76 -0
  407. package/dist/utils/orderBookGrouping.d.mts.map +1 -0
  408. package/dist/utils/orderBookGrouping.mjs +143 -0
  409. package/dist/utils/orderBookGrouping.mjs.map +1 -0
  410. package/dist/utils/orderCalculations.cjs +283 -0
  411. package/dist/utils/orderCalculations.cjs.map +1 -0
  412. package/dist/utils/orderCalculations.d.cts +107 -0
  413. package/dist/utils/orderCalculations.d.cts.map +1 -0
  414. package/dist/utils/orderCalculations.d.mts +107 -0
  415. package/dist/utils/orderCalculations.d.mts.map +1 -0
  416. package/dist/utils/orderCalculations.mjs +274 -0
  417. package/dist/utils/orderCalculations.mjs.map +1 -0
  418. package/dist/utils/orderUtils.cjs +159 -0
  419. package/dist/utils/orderUtils.cjs.map +1 -0
  420. package/dist/utils/orderUtils.d.cts +66 -0
  421. package/dist/utils/orderUtils.d.cts.map +1 -0
  422. package/dist/utils/orderUtils.d.mts +66 -0
  423. package/dist/utils/orderUtils.d.mts.map +1 -0
  424. package/dist/utils/orderUtils.mjs +151 -0
  425. package/dist/utils/orderUtils.mjs.map +1 -0
  426. package/dist/utils/pnlCalculations.cjs +107 -0
  427. package/dist/utils/pnlCalculations.cjs.map +1 -0
  428. package/dist/utils/pnlCalculations.d.cts +79 -0
  429. package/dist/utils/pnlCalculations.d.cts.map +1 -0
  430. package/dist/utils/pnlCalculations.d.mts +79 -0
  431. package/dist/utils/pnlCalculations.d.mts.map +1 -0
  432. package/dist/utils/pnlCalculations.mjs +97 -0
  433. package/dist/utils/pnlCalculations.mjs.map +1 -0
  434. package/dist/utils/positionCalculations.cjs +176 -0
  435. package/dist/utils/positionCalculations.cjs.map +1 -0
  436. package/dist/utils/positionCalculations.d.cts +85 -0
  437. package/dist/utils/positionCalculations.d.cts.map +1 -0
  438. package/dist/utils/positionCalculations.d.mts +85 -0
  439. package/dist/utils/positionCalculations.d.mts.map +1 -0
  440. package/dist/utils/positionCalculations.mjs +165 -0
  441. package/dist/utils/positionCalculations.mjs.map +1 -0
  442. package/dist/utils/sortMarkets.cjs +88 -0
  443. package/dist/utils/sortMarkets.cjs.map +1 -0
  444. package/dist/utils/sortMarkets.d.cts +21 -0
  445. package/dist/utils/sortMarkets.d.cts.map +1 -0
  446. package/dist/utils/sortMarkets.d.mts +21 -0
  447. package/dist/utils/sortMarkets.d.mts.map +1 -0
  448. package/dist/utils/sortMarkets.mjs +84 -0
  449. package/dist/utils/sortMarkets.mjs.map +1 -0
  450. package/dist/utils/standaloneInfoClient.cjs +34 -0
  451. package/dist/utils/standaloneInfoClient.cjs.map +1 -0
  452. package/dist/utils/standaloneInfoClient.d.cts +31 -0
  453. package/dist/utils/standaloneInfoClient.d.cts.map +1 -0
  454. package/dist/utils/standaloneInfoClient.d.mts +31 -0
  455. package/dist/utils/standaloneInfoClient.d.mts.map +1 -0
  456. package/dist/utils/standaloneInfoClient.mjs +30 -0
  457. package/dist/utils/standaloneInfoClient.mjs.map +1 -0
  458. package/dist/utils/stringParseUtils.cjs +49 -0
  459. package/dist/utils/stringParseUtils.cjs.map +1 -0
  460. package/dist/utils/stringParseUtils.d.cts +35 -0
  461. package/dist/utils/stringParseUtils.d.cts.map +1 -0
  462. package/dist/utils/stringParseUtils.d.mts +35 -0
  463. package/dist/utils/stringParseUtils.d.mts.map +1 -0
  464. package/dist/utils/stringParseUtils.mjs +44 -0
  465. package/dist/utils/stringParseUtils.mjs.map +1 -0
  466. package/dist/utils/time.cjs +37 -0
  467. package/dist/utils/time.cjs.map +1 -0
  468. package/dist/utils/time.d.cts +17 -0
  469. package/dist/utils/time.d.cts.map +1 -0
  470. package/dist/utils/time.d.mts +17 -0
  471. package/dist/utils/time.d.mts.map +1 -0
  472. package/dist/utils/time.mjs +33 -0
  473. package/dist/utils/time.mjs.map +1 -0
  474. package/dist/utils/tpslValidation.cjs +505 -0
  475. package/dist/utils/tpslValidation.cjs.map +1 -0
  476. package/dist/utils/tpslValidation.d.cts +182 -0
  477. package/dist/utils/tpslValidation.d.cts.map +1 -0
  478. package/dist/utils/tpslValidation.d.mts +182 -0
  479. package/dist/utils/tpslValidation.d.mts.map +1 -0
  480. package/dist/utils/tpslValidation.mjs +482 -0
  481. package/dist/utils/tpslValidation.mjs.map +1 -0
  482. package/dist/utils/transactionUtils.cjs +36 -0
  483. package/dist/utils/transactionUtils.cjs.map +1 -0
  484. package/dist/utils/transactionUtils.d.cts +17 -0
  485. package/dist/utils/transactionUtils.d.cts.map +1 -0
  486. package/dist/utils/transactionUtils.d.mts +17 -0
  487. package/dist/utils/transactionUtils.d.mts.map +1 -0
  488. package/dist/utils/transactionUtils.mjs +32 -0
  489. package/dist/utils/transactionUtils.mjs.map +1 -0
  490. package/dist/utils/wait.cjs +12 -0
  491. package/dist/utils/wait.cjs.map +1 -0
  492. package/dist/utils/wait.d.cts +8 -0
  493. package/dist/utils/wait.d.cts.map +1 -0
  494. package/dist/utils/wait.d.mts +8 -0
  495. package/dist/utils/wait.d.mts.map +1 -0
  496. package/dist/utils/wait.mjs +8 -0
  497. package/dist/utils/wait.mjs.map +1 -0
  498. package/package.json +19 -4
@@ -0,0 +1,458 @@
1
+ /**
2
+ * Perps feature constants
3
+ */
4
+ export const PERPS_CONSTANTS = {
5
+ FeatureFlagKey: 'perpsEnabled',
6
+ FeatureName: 'perps', // Constant for Sentry error filtering - enables "feature:perps" dashboard queries
7
+ WebsocketTimeout: 5000, // 5 seconds
8
+ WebsocketCleanupDelay: 1000, // 1 second
9
+ BackgroundDisconnectDelay: 20000, // 20 seconds delay before disconnecting when app is backgrounded or when user exits perps UX
10
+ ConnectionTimeoutMs: 10000, // 10 seconds timeout for connection and position loading states
11
+ DefaultMonitoringTimeoutMs: 10000, // 10 seconds default timeout for data monitoring operations
12
+ // Connection timing constants
13
+ ConnectionGracePeriodMs: 20000, // 20 seconds grace period before actual disconnection (same as BackgroundDisconnectDelay for semantic clarity)
14
+ ConnectionAttemptTimeoutMs: 30000, // 30 seconds timeout for connection attempts to prevent indefinite hanging
15
+ WebsocketPingTimeoutMs: 5000, // 5 seconds timeout for WebSocket health check ping
16
+ ReconnectionCleanupDelayMs: 500, // Platform-agnostic delay to ensure WebSocket is ready
17
+ ReconnectionDelayAndroidMs: 300, // Android-specific reconnection delay for better reliability on slower devices
18
+ ReconnectionDelayIosMs: 100, // iOS-specific reconnection delay for optimal performance
19
+ ReconnectionRetryDelayMs: 5000, // 5 seconds delay between reconnection attempts
20
+ // Connection manager timing constants
21
+ BalanceUpdateThrottleMs: 15000, // Update at most every 15 seconds to reduce state updates in PerpsConnectionManager
22
+ InitialDataDelayMs: 100, // Delay to allow initial data to load after connection establishment
23
+ DefaultAssetPreviewLimit: 5,
24
+ DefaultMaxLeverage: 3, // Default fallback max leverage when market data is unavailable - conservative default
25
+ FallbackPriceDisplay: '$---', // Display when price data is unavailable
26
+ FallbackPercentageDisplay: '--%', // Display when change data is unavailable
27
+ FallbackDataDisplay: '--', // Display when non-price data is unavailable
28
+ ZeroAmountDisplay: '$0', // Display for zero dollar amounts (e.g., no volume)
29
+ ZeroAmountDetailedDisplay: '$0.00', // Display for zero dollar amounts with decimals
30
+ RecentActivityLimit: 3,
31
+ // Historical data fetching constants
32
+ FillsLookbackMs: 90 * 24 * 60 * 60 * 1000, // 3 months in milliseconds - limits REST API fills fetch
33
+ };
34
+ /**
35
+ * Withdrawal-specific constants (protocol-agnostic)
36
+ * Note: Protocol-specific values like estimated time should be defined in each protocol's config
37
+ */
38
+ export const WITHDRAWAL_CONSTANTS = {
39
+ DefaultMinAmount: '1.01', // Default minimum withdrawal amount in USDC
40
+ DefaultFeeAmount: 1, // Default withdrawal fee in USDC
41
+ DefaultFeeToken: 'USDC', // Default fee token
42
+ };
43
+ /**
44
+ * MetaMask fee configuration for Perps trading
45
+ * These fees are protocol-agnostic and apply on top of protocol fees
46
+ */
47
+ export const METAMASK_FEE_CONFIG = {
48
+ // Deposit/withdrawal fees
49
+ DepositFee: 0, // $0 currently
50
+ WithdrawalFee: 0, // $0 currently
51
+ // Future: Fee configuration will be fetched from API based on:
52
+ // - User tier/volume (for MetaMask fee discounts)
53
+ // - Promotional campaigns
54
+ // - Protocol-specific agreements
55
+ // - MetaMask points/rewards integration
56
+ // Note: Trading fees are now handled by each provider's calculateFees()
57
+ // which returns complete fee breakdown including MetaMask fees
58
+ };
59
+ /**
60
+ * Minimum number of aggregators (exchanges) a token must be listed on
61
+ * to be considered trustworthy for showing the Perps Discovery Banner.
62
+ * Native tokens (ETH, BNB, etc.) bypass this check.
63
+ */
64
+ export const PERPS_MIN_AGGREGATORS_FOR_TRUST = 2;
65
+ /**
66
+ * Validation thresholds for UI warnings and checks
67
+ * These values control when warnings are shown to users
68
+ */
69
+ export const VALIDATION_THRESHOLDS = {
70
+ // Leverage threshold for warning users about high leverage
71
+ HighLeverageWarning: 20, // Show warning when leverage > 20x
72
+ // Limit price difference threshold (as decimal, 0.1 = 10%)
73
+ LimitPriceDifferenceWarning: 0.1, // Warn if limit price differs by >10% from current price
74
+ // Price deviation threshold (as decimal, 0.1 = 10%)
75
+ PriceDeviation: 0.1, // Warn if perps price deviates by >10% from spot price
76
+ };
77
+ /**
78
+ * Order slippage configuration
79
+ * Controls default slippage tolerance for different order types
80
+ * Conservative defaults based on HyperLiquid platform interface
81
+ * See: docs/perps/hyperliquid/ORDER-MATCHING-ERRORS.md
82
+ */
83
+ export const ORDER_SLIPPAGE_CONFIG = {
84
+ // Market order slippage (basis points)
85
+ // 300 basis points = 3% = 0.03 decimal
86
+ // Conservative default for measured rollout, prevents most IOC failures
87
+ DefaultMarketSlippageBps: 300,
88
+ // TP/SL order slippage (basis points)
89
+ // 1000 basis points = 10% = 0.10 decimal
90
+ // Aligns with HyperLiquid platform default for triggered orders
91
+ DefaultTpslSlippageBps: 1000,
92
+ // Limit order slippage (basis points)
93
+ // 100 basis points = 1% = 0.01 decimal
94
+ // Kept conservative as limit orders rest on book (not IOC/immediate execution)
95
+ DefaultLimitSlippageBps: 100,
96
+ };
97
+ /**
98
+ * Performance optimization constants
99
+ * These values control debouncing and throttling for better performance
100
+ */
101
+ export const PERFORMANCE_CONFIG = {
102
+ // Price updates debounce delay (milliseconds)
103
+ // Batches rapid WebSocket price updates to reduce re-renders
104
+ PriceUpdateDebounceMs: 1000,
105
+ // Order validation debounce delay (milliseconds)
106
+ // Prevents excessive validation calls during rapid form input changes
107
+ ValidationDebounceMs: 300,
108
+ // Liquidation price debounce delay (milliseconds)
109
+ // Prevents excessive liquidation price calls during rapid form input changes
110
+ LiquidationPriceDebounceMs: 500,
111
+ // Navigation params delay (milliseconds)
112
+ // Required for React Navigation to complete state transitions before setting params
113
+ // This ensures navigation context is available when programmatically selecting tabs
114
+ NavigationParamsDelayMs: 200,
115
+ // Tab control reset delay (milliseconds)
116
+ // Delay to reset programmatic tab control after tab switching to prevent render loops
117
+ TabControlResetDelayMs: 500,
118
+ // Market data cache duration (milliseconds)
119
+ // How long to cache market list data before fetching fresh data
120
+ MarketDataCacheDurationMs: 5 * 60 * 1000, // 5 minutes
121
+ // Asset metadata cache duration (milliseconds)
122
+ // How long to cache asset icon validation results
123
+ AssetMetadataCacheDurationMs: 60 * 60 * 1000, // 1 hour
124
+ // Max leverage cache duration (milliseconds)
125
+ // How long to cache max leverage values per asset (leverage rarely changes)
126
+ MaxLeverageCacheDurationMs: 60 * 60 * 1000, // 1 hour
127
+ // Rewards cache durations (milliseconds)
128
+ // How long to cache fee discount data from rewards API
129
+ FeeDiscountCacheDurationMs: 5 * 60 * 1000, // 5 minutes
130
+ // How long to cache points calculation parameters from rewards API
131
+ PointsCalculationCacheDurationMs: 5 * 60 * 1000, // 5 minutes
132
+ /**
133
+ * Performance logging markers for filtering logs during development and debugging
134
+ * These markers help isolate performance-related logs from general application logs
135
+ * Usage: Use in DevLogger calls to easily filter specific performance areas
136
+ * Impact: Development only (uses DevLogger) - zero production performance cost
137
+ *
138
+ * Examples:
139
+ * - Filter Sentry performance logs: `adb logcat | grep PERPSMARK_SENTRY`
140
+ * - Filter MetaMetrics events: `adb logcat | grep PERPSMARK_METRICS`
141
+ * - Filter WebSocket performance: `adb logcat | grep PERPSMARK_WS`
142
+ * - Filter all Perps performance: `adb logcat | grep PERPSMARK_`
143
+ */
144
+ LoggingMarkers: {
145
+ // Sentry performance measurement logs (screen loads, bottom sheets, API timing)
146
+ SentryPerformance: 'PERPSMARK_SENTRY',
147
+ // MetaMetrics event tracking logs (user interactions, business analytics)
148
+ MetametricsEvents: 'PERPSMARK_METRICS',
149
+ // WebSocket performance logs (connection timing, data flow, reconnections)
150
+ WebsocketPerformance: 'PERPSMARK_SENTRY_WS',
151
+ },
152
+ };
153
+ /**
154
+ * Leverage slider UI configuration
155
+ * Controls the visual and interactive aspects of the leverage slider
156
+ */
157
+ export const LEVERAGE_SLIDER_CONFIG = {
158
+ // Step sizes for tick marks based on max leverage
159
+ TickStepLow: 5, // Step size when max leverage <= 20
160
+ TickStepMedium: 10, // Step size when max leverage <= 50
161
+ TickStepHigh: 20, // Step size when max leverage > 50
162
+ // Thresholds for determining tick step size
163
+ MaxLeverageLowThreshold: 20,
164
+ MaxLeverageMediumThreshold: 50,
165
+ };
166
+ export const TP_SL_CONFIG = {
167
+ UsePositionBoundTpsl: true,
168
+ };
169
+ /**
170
+ * TP/SL View UI configuration
171
+ * Controls the Take Profit / Stop Loss screen behavior and display options
172
+ */
173
+ export const TP_SL_VIEW_CONFIG = {
174
+ // Quick percentage button presets for Take Profit (positive RoE percentages)
175
+ TakeProfitRoePresets: [10, 25, 50, 100], // +10%, +25%, +50%, +100% RoE
176
+ // Quick percentage button presets for Stop Loss (negative RoE percentages)
177
+ StopLossRoePresets: [-5, -10, -25, -50], // -5%, -10%, -25%, -50% RoE
178
+ // WebSocket price update throttle delay (milliseconds)
179
+ // Reduces re-renders by batching price updates in the TP/SL screen
180
+ PriceThrottleMs: 1000,
181
+ // Maximum number of digits allowed in price/percentage input fields
182
+ // Prevents overflow and maintains reasonable input constraints
183
+ MaxInputDigits: 9,
184
+ // Keypad configuration for price inputs
185
+ // USD_PERPS is not a real currency - it's a custom configuration
186
+ // that allows 5 decimal places for crypto prices, overriding the
187
+ // default USD configuration which only allows 2 decimal places
188
+ KeypadCurrencyCode: 'USD_PERPS',
189
+ KeypadDecimals: 5,
190
+ };
191
+ /**
192
+ * Limit price configuration
193
+ * Controls preset percentages and behavior for limit orders
194
+ */
195
+ export const LIMIT_PRICE_CONFIG = {
196
+ // Preset percentage options for quick selection
197
+ PresetPercentages: [1, 2], // Available as both positive and negative
198
+ // Modal opening delay when switching to limit order (milliseconds)
199
+ // Allows order type modal to close smoothly before opening limit price modal
200
+ ModalOpenDelay: 300,
201
+ // Direction-specific preset configurations (Mid/Bid/Ask buttons handled separately)
202
+ LongPresets: [-1, -2], // Buy below market for long orders
203
+ ShortPresets: [1, 2], // Sell above market for short orders
204
+ };
205
+ /**
206
+ * HyperLiquid order limits based on leverage
207
+ * From: https://hyperliquid.gitbook.io/hyperliquid-docs/trading/contract-specifications
208
+ */
209
+ export const HYPERLIQUID_ORDER_LIMITS = {
210
+ // Market orders
211
+ MarketOrderLimits: {
212
+ // $15,000,000 for max leverage >= 25
213
+ HighLeverage: 15000000,
214
+ // $5,000,000 for max leverage in [20, 25)
215
+ MediumHighLeverage: 5000000,
216
+ // $2,000,000 for max leverage in [10, 20)
217
+ MediumLeverage: 2000000,
218
+ // $500,000 for max leverage < 10
219
+ LowLeverage: 500000,
220
+ },
221
+ // Limit orders are 10x market order limits
222
+ LimitOrderMultiplier: 10,
223
+ };
224
+ /**
225
+ * Close position configuration
226
+ * Controls behavior and constants specific to position closing
227
+ */
228
+ export const CLOSE_POSITION_CONFIG = {
229
+ // Decimal places for USD amount input display
230
+ UsdDecimalPlaces: 2,
231
+ // Default close percentage when opening the close position view
232
+ DefaultClosePercentage: 100,
233
+ // Precision for position size calculations to prevent rounding errors
234
+ AmountCalculationPrecision: 6,
235
+ // Throttle delay for real-time price updates during position closing
236
+ PriceThrottleMs: 3000,
237
+ // Fallback decimal places for tokens without metadata
238
+ FallbackTokenDecimals: 18,
239
+ };
240
+ /**
241
+ * Margin adjustment configuration
242
+ * Controls behavior for adding/removing margin from positions
243
+ */
244
+ export const MARGIN_ADJUSTMENT_CONFIG = {
245
+ // Risk thresholds for margin removal warnings
246
+ // Threshold values represent ratio of (price distance to liquidation) / (liquidation price)
247
+ // Values < 1.0 mean price is dangerously close to liquidation
248
+ LiquidationRiskThreshold: 1.2, // 20% buffer before liquidation - triggers danger state
249
+ LiquidationWarningThreshold: 1.5, // 50% buffer before liquidation - triggers warning state
250
+ // Minimum margin adjustment amount (USD)
251
+ // Prevents dust adjustments and ensures meaningful position changes
252
+ MinAdjustmentAmount: 1,
253
+ // Precision for margin calculations
254
+ // Ensures accurate decimal handling in margin/leverage calculations
255
+ CalculationPrecision: 6,
256
+ // Safety buffer for margin removal to account for HyperLiquid's transfer margin requirement
257
+ // HyperLiquid enforces: transfer_margin_required = max(initial_margin_required, 0.1 * total_position_value)
258
+ // See: https://hyperliquid.gitbook.io/hyperliquid-docs/trading/margin-and-pnl
259
+ MarginRemovalSafetyBuffer: 0.1,
260
+ // Fallback max leverage when market data is unavailable
261
+ // Conservative value to prevent over-removal of margin
262
+ // Most HyperLiquid assets support at least 50x leverage
263
+ FallbackMaxLeverage: 50,
264
+ };
265
+ /**
266
+ * Data Lake API configuration
267
+ * Endpoints for reporting perps trading activity for notifications
268
+ */
269
+ export const DATA_LAKE_API_CONFIG = {
270
+ // Order reporting endpoint - only used for mainnet perps trading
271
+ OrdersEndpoint: 'https://perps.api.cx.metamask.io/api/v1/orders',
272
+ };
273
+ /**
274
+ * Funding rate display configuration
275
+ * Controls how funding rates are formatted and displayed across the app
276
+ */
277
+ export const FUNDING_RATE_CONFIG = {
278
+ // Number of decimal places to display for funding rates
279
+ Decimals: 4,
280
+ // Default display value when funding rate is zero or unavailable
281
+ ZeroDisplay: '0.0000%',
282
+ // Multiplier to convert decimal funding rate to percentage
283
+ PercentageMultiplier: 100,
284
+ };
285
+ /**
286
+ * Decimal precision configuration
287
+ * Controls maximum decimal places for price and input validation
288
+ */
289
+ export const DECIMAL_PRECISION_CONFIG = {
290
+ // Maximum decimal places for price input (matches Hyperliquid limit)
291
+ // Used in TP/SL forms, limit price inputs, and price validation
292
+ MaxPriceDecimals: 6,
293
+ // Maximum significant figures allowed by HyperLiquid API
294
+ // Orders with more than 5 significant figures will be rejected
295
+ MaxSignificantFigures: 5,
296
+ // Defensive fallback for size decimals when market data fails to load
297
+ // Real szDecimals should always come from market data API (varies by asset)
298
+ // Using 6 as safe maximum to prevent crashes (covers most assets)
299
+ // NOTE: This is NOT semantically correct - just a defensive measure
300
+ FallbackSizeDecimals: 6,
301
+ };
302
+ /**
303
+ * Development-only configuration for testing and debugging
304
+ * These constants are only active when __DEV__ is true
305
+ */
306
+ export const DEVELOPMENT_CONFIG = {
307
+ // Magic number to simulate fee discount state (20% discount)
308
+ SimulateFeeDiscountAmount: 41,
309
+ // Magic number to simulate rewards error state (set order amount to this value)
310
+ SimulateRewardsErrorAmount: 42,
311
+ // Magic number to simulate rewards loading state
312
+ SimulateRewardsLoadingAmount: 43,
313
+ // Future: Add other development helpers as needed
314
+ };
315
+ /**
316
+ * Home screen configuration
317
+ * Controls carousel limits and display settings for the main Perps home screen
318
+ */
319
+ export const HOME_SCREEN_CONFIG = {
320
+ // Show action buttons (Add Funds / Withdraw) in header instead of fixed footer
321
+ // Can be controlled via feature flag in the future
322
+ ShowHeaderActionButtons: true,
323
+ // Maximum number of items to show in each carousel
324
+ PositionsCarouselLimit: 10,
325
+ OrdersCarouselLimit: 10,
326
+ TrendingMarketsLimit: 5,
327
+ RecentActivityLimit: 3,
328
+ // Carousel display behavior
329
+ CarouselSnapAlignment: 'start',
330
+ CarouselVisibleItems: 1.2, // Show 1 full item + 20% of next
331
+ // Icon sizes for consistent display across sections
332
+ DefaultIconSize: 40, // Default token icon size for cards and rows
333
+ };
334
+ /**
335
+ * Market sorting configuration
336
+ * Controls sorting behavior and presets for the trending markets view
337
+ */
338
+ export const MARKET_SORTING_CONFIG = {
339
+ // Default sort settings
340
+ DefaultSortOptionId: 'volume',
341
+ DefaultDirection: 'desc',
342
+ // Available sort fields (only includes fields supported by PerpsMarketData)
343
+ SortFields: {
344
+ Volume: 'volume',
345
+ PriceChange: 'priceChange',
346
+ OpenInterest: 'openInterest',
347
+ FundingRate: 'fundingRate',
348
+ },
349
+ // Sort button presets for filter chips (simplified buttons without direction)
350
+ SortButtonPresets: [
351
+ { field: 'volume', labelKey: 'perps.sort.volume' },
352
+ { field: 'priceChange', labelKey: 'perps.sort.price_change' },
353
+ { field: 'fundingRate', labelKey: 'perps.sort.funding_rate' },
354
+ ],
355
+ // Sort options for the bottom sheet
356
+ // Only Price Change can be toggled for direction (similar to trending tokens pattern)
357
+ // Other options (volume, open interest, funding rate) use descending sort only
358
+ SortOptions: [
359
+ {
360
+ id: 'volume',
361
+ labelKey: 'perps.sort.volume',
362
+ field: 'volume',
363
+ direction: 'desc',
364
+ },
365
+ {
366
+ id: 'priceChange',
367
+ labelKey: 'perps.sort.price_change',
368
+ field: 'priceChange',
369
+ direction: 'desc',
370
+ },
371
+ {
372
+ id: 'openInterest',
373
+ labelKey: 'perps.sort.open_interest',
374
+ field: 'openInterest',
375
+ direction: 'desc',
376
+ },
377
+ {
378
+ id: 'fundingRate',
379
+ labelKey: 'perps.sort.funding_rate',
380
+ field: 'fundingRate',
381
+ direction: 'desc',
382
+ },
383
+ ],
384
+ };
385
+ /**
386
+ * Learn more card configuration
387
+ * External resources and content for Perps education
388
+ */
389
+ export const LEARN_MORE_CONFIG = {
390
+ ExternalUrl: 'https://metamask.io/perps',
391
+ TitleKey: 'perps.tutorial.card.title',
392
+ DescriptionKey: 'perps.learn_more.description',
393
+ CtaKey: 'perps.learn_more.cta',
394
+ };
395
+ /**
396
+ * Support configuration
397
+ * Contact support button configuration (matches Settings behavior)
398
+ */
399
+ export const SUPPORT_CONFIG = {
400
+ Url: 'https://support.metamask.io',
401
+ TitleKey: 'perps.support.title',
402
+ DescriptionKey: 'perps.support.description',
403
+ };
404
+ /**
405
+ * Feedback survey configuration
406
+ * External survey for collecting user feedback on Perps trading experience
407
+ */
408
+ export const FEEDBACK_CONFIG = {
409
+ Url: 'https://survey.alchemer.com/s3/8649911/MetaMask-Perps-Trading-Feedback',
410
+ TitleKey: 'perps.feedback.title',
411
+ };
412
+ /**
413
+ * Support article URLs
414
+ * Links to specific MetaMask support articles for Perps features
415
+ */
416
+ export const PERPS_SUPPORT_ARTICLES_URLS = {
417
+ AdlUrl: 'https://support.metamask.io/manage-crypto/trade/perps/leverage-and-liquidation/#what-is-auto-deleveraging-adl',
418
+ };
419
+ /**
420
+ * Stop loss prompt banner configuration
421
+ * Controls when and how the stop loss prompt banner is displayed
422
+ * Based on TAT-1693 specifications
423
+ */
424
+ export const STOP_LOSS_PROMPT_CONFIG = {
425
+ // Distance to liquidation threshold (percentage)
426
+ // Shows "Add margin" banner when position is within this % of liquidation
427
+ LiquidationDistanceThreshold: 3,
428
+ // ROE (Return on Equity) threshold (percentage)
429
+ // Shows "Set stop loss" banner when ROE drops below this value
430
+ RoeThreshold: -10,
431
+ // Minimum loss threshold to show ANY banner (percentage)
432
+ // No banner shown until ROE drops below this value
433
+ MinLossThreshold: -10,
434
+ // Debounce duration for ROE threshold (milliseconds)
435
+ // User must have ROE below threshold for this duration before showing banner
436
+ // Prevents banner from appearing during temporary price fluctuations
437
+ RoeDebounceMs: 60000, // 60 seconds
438
+ // Minimum position age before showing any banner (milliseconds)
439
+ // Prevents banner from appearing immediately after opening a position
440
+ PositionMinAgeMs: 60000, // 60 seconds
441
+ // Suggested stop loss ROE percentage
442
+ // When suggesting a stop loss, calculate price at this ROE from entry
443
+ SuggestedStopLossRoe: -50,
444
+ };
445
+ /**
446
+ * Transactions history configuration
447
+ * Controls history display and data fetching parameters
448
+ */
449
+ export const PERPS_TRANSACTIONS_HISTORY_CONSTANTS = {
450
+ /**
451
+ * Default number of days to look back for funding history.
452
+ * HyperLiquid API requires a startTime and returns max 500 records.
453
+ * Using 365 days ensures most users see their complete recent history.
454
+ * Can be increased if users need older funding data.
455
+ */
456
+ DefaultFundingHistoryDays: 365,
457
+ };
458
+ //# sourceMappingURL=perpsConfig.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"perpsConfig.mjs","sourceRoot":"","sources":["../../src/constants/perpsConfig.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,cAAc,EAAE,cAAc;IAC9B,WAAW,EAAE,OAAO,EAAE,kFAAkF;IACxG,gBAAgB,EAAE,IAAI,EAAE,YAAY;IACpC,qBAAqB,EAAE,IAAI,EAAE,WAAW;IACxC,yBAAyB,EAAE,KAAM,EAAE,6FAA6F;IAChI,mBAAmB,EAAE,KAAM,EAAE,gEAAgE;IAC7F,0BAA0B,EAAE,KAAM,EAAE,4DAA4D;IAEhG,8BAA8B;IAC9B,uBAAuB,EAAE,KAAM,EAAE,+GAA+G;IAChJ,0BAA0B,EAAE,KAAM,EAAE,2EAA2E;IAC/G,sBAAsB,EAAE,IAAK,EAAE,oDAAoD;IACnF,0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AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,GAAG,EAAE,wEAAwE;IAC7E,QAAQ,EAAE,sBAAsB;CACxB,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,MAAM,EACJ,+GAA+G;CACzG,CAAC;AAEX;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,iDAAiD;IACjD,0EAA0E;IAC1E,4BAA4B,EAAE,CAAC;IAE/B,gDAAgD;IAChD,+DAA+D;IAC/D,YAAY,EAAE,CAAC,EAAE;IAEjB,yDAAyD;IACzD,mDAAmD;IACnD,gBAAgB,EAAE,CAAC,EAAE;IAErB,qDAAqD;IACrD,6EAA6E;IAC7E,qEAAqE;IACrE,aAAa,EAAE,KAAM,EAAE,aAAa;IAEpC,gEAAgE;IAChE,sEAAsE;IACtE,gBAAgB,EAAE,KAAM,EAAE,aAAa;IAEvC,qCAAqC;IACrC,sEAAsE;IACtE,oBAAoB,EAAE,CAAC,EAAE;CACjB,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG;IAClD;;;;;OAKG;IACH,yBAAyB,EAAE,GAAG;CACtB,CAAC","sourcesContent":["/**\n * Perps feature constants\n */\nexport const PERPS_CONSTANTS = {\n FeatureFlagKey: 'perpsEnabled',\n FeatureName: 'perps', // Constant for Sentry error filtering - enables \"feature:perps\" dashboard queries\n WebsocketTimeout: 5000, // 5 seconds\n WebsocketCleanupDelay: 1000, // 1 second\n BackgroundDisconnectDelay: 20_000, // 20 seconds delay before disconnecting when app is backgrounded or when user exits perps UX\n ConnectionTimeoutMs: 10_000, // 10 seconds timeout for connection and position loading states\n DefaultMonitoringTimeoutMs: 10_000, // 10 seconds default timeout for data monitoring operations\n\n // Connection timing constants\n ConnectionGracePeriodMs: 20_000, // 20 seconds grace period before actual disconnection (same as BackgroundDisconnectDelay for semantic clarity)\n ConnectionAttemptTimeoutMs: 30_000, // 30 seconds timeout for connection attempts to prevent indefinite hanging\n WebsocketPingTimeoutMs: 5_000, // 5 seconds timeout for WebSocket health check ping\n ReconnectionCleanupDelayMs: 500, // Platform-agnostic delay to ensure WebSocket is ready\n ReconnectionDelayAndroidMs: 300, // Android-specific reconnection delay for better reliability on slower devices\n ReconnectionDelayIosMs: 100, // iOS-specific reconnection delay for optimal performance\n ReconnectionRetryDelayMs: 5_000, // 5 seconds delay between reconnection attempts\n\n // Connection manager timing constants\n BalanceUpdateThrottleMs: 15000, // Update at most every 15 seconds to reduce state updates in PerpsConnectionManager\n InitialDataDelayMs: 100, // Delay to allow initial data to load after connection establishment\n\n DefaultAssetPreviewLimit: 5,\n DefaultMaxLeverage: 3 as number, // Default fallback max leverage when market data is unavailable - conservative default\n FallbackPriceDisplay: '$---', // Display when price data is unavailable\n FallbackPercentageDisplay: '--%', // Display when change data is unavailable\n FallbackDataDisplay: '--', // Display when non-price data is unavailable\n ZeroAmountDisplay: '$0', // Display for zero dollar amounts (e.g., no volume)\n ZeroAmountDetailedDisplay: '$0.00', // Display for zero dollar amounts with decimals\n\n RecentActivityLimit: 3,\n\n // Historical data fetching constants\n FillsLookbackMs: 90 * 24 * 60 * 60 * 1000, // 3 months in milliseconds - limits REST API fills fetch\n} as const;\n\n/**\n * Withdrawal-specific constants (protocol-agnostic)\n * Note: Protocol-specific values like estimated time should be defined in each protocol's config\n */\nexport const WITHDRAWAL_CONSTANTS = {\n DefaultMinAmount: '1.01', // Default minimum withdrawal amount in USDC\n DefaultFeeAmount: 1, // Default withdrawal fee in USDC\n DefaultFeeToken: 'USDC', // Default fee token\n} as const;\n\n/**\n * MetaMask fee configuration for Perps trading\n * These fees are protocol-agnostic and apply on top of protocol fees\n */\nexport const METAMASK_FEE_CONFIG = {\n // Deposit/withdrawal fees\n DepositFee: 0, // $0 currently\n WithdrawalFee: 0, // $0 currently\n\n // Future: Fee configuration will be fetched from API based on:\n // - User tier/volume (for MetaMask fee discounts)\n // - Promotional campaigns\n // - Protocol-specific agreements\n // - MetaMask points/rewards integration\n // Note: Trading fees are now handled by each provider's calculateFees()\n // which returns complete fee breakdown including MetaMask fees\n} as const;\n\n/**\n * Minimum number of aggregators (exchanges) a token must be listed on\n * to be considered trustworthy for showing the Perps Discovery Banner.\n * Native tokens (ETH, BNB, etc.) bypass this check.\n */\nexport const PERPS_MIN_AGGREGATORS_FOR_TRUST = 2;\n\n/**\n * Validation thresholds for UI warnings and checks\n * These values control when warnings are shown to users\n */\nexport const VALIDATION_THRESHOLDS = {\n // Leverage threshold for warning users about high leverage\n HighLeverageWarning: 20, // Show warning when leverage > 20x\n\n // Limit price difference threshold (as decimal, 0.1 = 10%)\n LimitPriceDifferenceWarning: 0.1, // Warn if limit price differs by >10% from current price\n\n // Price deviation threshold (as decimal, 0.1 = 10%)\n PriceDeviation: 0.1, // Warn if perps price deviates by >10% from spot price\n} as const;\n\n/**\n * Order slippage configuration\n * Controls default slippage tolerance for different order types\n * Conservative defaults based on HyperLiquid platform interface\n * See: docs/perps/hyperliquid/ORDER-MATCHING-ERRORS.md\n */\nexport const ORDER_SLIPPAGE_CONFIG = {\n // Market order slippage (basis points)\n // 300 basis points = 3% = 0.03 decimal\n // Conservative default for measured rollout, prevents most IOC failures\n DefaultMarketSlippageBps: 300,\n\n // TP/SL order slippage (basis points)\n // 1000 basis points = 10% = 0.10 decimal\n // Aligns with HyperLiquid platform default for triggered orders\n DefaultTpslSlippageBps: 1000,\n\n // Limit order slippage (basis points)\n // 100 basis points = 1% = 0.01 decimal\n // Kept conservative as limit orders rest on book (not IOC/immediate execution)\n DefaultLimitSlippageBps: 100,\n} as const;\n\n/**\n * Performance optimization constants\n * These values control debouncing and throttling for better performance\n */\nexport const PERFORMANCE_CONFIG = {\n // Price updates debounce delay (milliseconds)\n // Batches rapid WebSocket price updates to reduce re-renders\n PriceUpdateDebounceMs: 1000,\n\n // Order validation debounce delay (milliseconds)\n // Prevents excessive validation calls during rapid form input changes\n ValidationDebounceMs: 300,\n\n // Liquidation price debounce delay (milliseconds)\n // Prevents excessive liquidation price calls during rapid form input changes\n LiquidationPriceDebounceMs: 500,\n\n // Navigation params delay (milliseconds)\n // Required for React Navigation to complete state transitions before setting params\n // This ensures navigation context is available when programmatically selecting tabs\n NavigationParamsDelayMs: 200,\n\n // Tab control reset delay (milliseconds)\n // Delay to reset programmatic tab control after tab switching to prevent render loops\n TabControlResetDelayMs: 500,\n\n // Market data cache duration (milliseconds)\n // How long to cache market list data before fetching fresh data\n MarketDataCacheDurationMs: 5 * 60 * 1000, // 5 minutes\n\n // Asset metadata cache duration (milliseconds)\n // How long to cache asset icon validation results\n AssetMetadataCacheDurationMs: 60 * 60 * 1000, // 1 hour\n\n // Max leverage cache duration (milliseconds)\n // How long to cache max leverage values per asset (leverage rarely changes)\n MaxLeverageCacheDurationMs: 60 * 60 * 1000, // 1 hour\n\n // Rewards cache durations (milliseconds)\n // How long to cache fee discount data from rewards API\n FeeDiscountCacheDurationMs: 5 * 60 * 1000, // 5 minutes\n // How long to cache points calculation parameters from rewards API\n PointsCalculationCacheDurationMs: 5 * 60 * 1000, // 5 minutes\n\n /**\n * Performance logging markers for filtering logs during development and debugging\n * These markers help isolate performance-related logs from general application logs\n * Usage: Use in DevLogger calls to easily filter specific performance areas\n * Impact: Development only (uses DevLogger) - zero production performance cost\n *\n * Examples:\n * - Filter Sentry performance logs: `adb logcat | grep PERPSMARK_SENTRY`\n * - Filter MetaMetrics events: `adb logcat | grep PERPSMARK_METRICS`\n * - Filter WebSocket performance: `adb logcat | grep PERPSMARK_WS`\n * - Filter all Perps performance: `adb logcat | grep PERPSMARK_`\n */\n LoggingMarkers: {\n // Sentry performance measurement logs (screen loads, bottom sheets, API timing)\n SentryPerformance: 'PERPSMARK_SENTRY',\n\n // MetaMetrics event tracking logs (user interactions, business analytics)\n MetametricsEvents: 'PERPSMARK_METRICS',\n\n // WebSocket performance logs (connection timing, data flow, reconnections)\n WebsocketPerformance: 'PERPSMARK_SENTRY_WS',\n } as const,\n} as const;\n\n/**\n * Leverage slider UI configuration\n * Controls the visual and interactive aspects of the leverage slider\n */\nexport const LEVERAGE_SLIDER_CONFIG = {\n // Step sizes for tick marks based on max leverage\n TickStepLow: 5, // Step size when max leverage <= 20\n TickStepMedium: 10, // Step size when max leverage <= 50\n TickStepHigh: 20, // Step size when max leverage > 50\n\n // Thresholds for determining tick step size\n MaxLeverageLowThreshold: 20,\n MaxLeverageMediumThreshold: 50,\n} as const;\n\nexport const TP_SL_CONFIG = {\n UsePositionBoundTpsl: true,\n} as const;\n\n/**\n * TP/SL View UI configuration\n * Controls the Take Profit / Stop Loss screen behavior and display options\n */\nexport const TP_SL_VIEW_CONFIG = {\n // Quick percentage button presets for Take Profit (positive RoE percentages)\n TakeProfitRoePresets: [10, 25, 50, 100], // +10%, +25%, +50%, +100% RoE\n\n // Quick percentage button presets for Stop Loss (negative RoE percentages)\n StopLossRoePresets: [-5, -10, -25, -50], // -5%, -10%, -25%, -50% RoE\n\n // WebSocket price update throttle delay (milliseconds)\n // Reduces re-renders by batching price updates in the TP/SL screen\n PriceThrottleMs: 1000,\n\n // Maximum number of digits allowed in price/percentage input fields\n // Prevents overflow and maintains reasonable input constraints\n MaxInputDigits: 9,\n\n // Keypad configuration for price inputs\n // USD_PERPS is not a real currency - it's a custom configuration\n // that allows 5 decimal places for crypto prices, overriding the\n // default USD configuration which only allows 2 decimal places\n KeypadCurrencyCode: 'USD_PERPS' as const,\n KeypadDecimals: 5,\n} as const;\n\n/**\n * Limit price configuration\n * Controls preset percentages and behavior for limit orders\n */\nexport const LIMIT_PRICE_CONFIG = {\n // Preset percentage options for quick selection\n PresetPercentages: [1, 2], // Available as both positive and negative\n\n // Modal opening delay when switching to limit order (milliseconds)\n // Allows order type modal to close smoothly before opening limit price modal\n ModalOpenDelay: 300,\n\n // Direction-specific preset configurations (Mid/Bid/Ask buttons handled separately)\n LongPresets: [-1, -2], // Buy below market for long orders\n ShortPresets: [1, 2], // Sell above market for short orders\n} as const;\n\n/**\n * HyperLiquid order limits based on leverage\n * From: https://hyperliquid.gitbook.io/hyperliquid-docs/trading/contract-specifications\n */\nexport const HYPERLIQUID_ORDER_LIMITS = {\n // Market orders\n MarketOrderLimits: {\n // $15,000,000 for max leverage >= 25\n HighLeverage: 15_000_000,\n // $5,000,000 for max leverage in [20, 25)\n MediumHighLeverage: 5_000_000,\n // $2,000,000 for max leverage in [10, 20)\n MediumLeverage: 2_000_000,\n // $500,000 for max leverage < 10\n LowLeverage: 500_000,\n },\n // Limit orders are 10x market order limits\n LimitOrderMultiplier: 10,\n} as const;\n\n/**\n * Close position configuration\n * Controls behavior and constants specific to position closing\n */\nexport const CLOSE_POSITION_CONFIG = {\n // Decimal places for USD amount input display\n UsdDecimalPlaces: 2,\n\n // Default close percentage when opening the close position view\n DefaultClosePercentage: 100,\n\n // Precision for position size calculations to prevent rounding errors\n AmountCalculationPrecision: 6,\n\n // Throttle delay for real-time price updates during position closing\n PriceThrottleMs: 3000,\n\n // Fallback decimal places for tokens without metadata\n FallbackTokenDecimals: 18,\n} as const;\n\n/**\n * Margin adjustment configuration\n * Controls behavior for adding/removing margin from positions\n */\nexport const MARGIN_ADJUSTMENT_CONFIG = {\n // Risk thresholds for margin removal warnings\n // Threshold values represent ratio of (price distance to liquidation) / (liquidation price)\n // Values < 1.0 mean price is dangerously close to liquidation\n LiquidationRiskThreshold: 1.2, // 20% buffer before liquidation - triggers danger state\n LiquidationWarningThreshold: 1.5, // 50% buffer before liquidation - triggers warning state\n\n // Minimum margin adjustment amount (USD)\n // Prevents dust adjustments and ensures meaningful position changes\n MinAdjustmentAmount: 1,\n\n // Precision for margin calculations\n // Ensures accurate decimal handling in margin/leverage calculations\n CalculationPrecision: 6,\n\n // Safety buffer for margin removal to account for HyperLiquid's transfer margin requirement\n // HyperLiquid enforces: transfer_margin_required = max(initial_margin_required, 0.1 * total_position_value)\n // See: https://hyperliquid.gitbook.io/hyperliquid-docs/trading/margin-and-pnl\n MarginRemovalSafetyBuffer: 0.1,\n\n // Fallback max leverage when market data is unavailable\n // Conservative value to prevent over-removal of margin\n // Most HyperLiquid assets support at least 50x leverage\n FallbackMaxLeverage: 50,\n} as const;\n\n/**\n * Data Lake API configuration\n * Endpoints for reporting perps trading activity for notifications\n */\nexport const DATA_LAKE_API_CONFIG = {\n // Order reporting endpoint - only used for mainnet perps trading\n OrdersEndpoint: 'https://perps.api.cx.metamask.io/api/v1/orders',\n} as const;\n\n/**\n * Funding rate display configuration\n * Controls how funding rates are formatted and displayed across the app\n */\nexport const FUNDING_RATE_CONFIG = {\n // Number of decimal places to display for funding rates\n Decimals: 4,\n // Default display value when funding rate is zero or unavailable\n ZeroDisplay: '0.0000%',\n // Multiplier to convert decimal funding rate to percentage\n PercentageMultiplier: 100,\n} as const;\n\n/**\n * Decimal precision configuration\n * Controls maximum decimal places for price and input validation\n */\nexport const DECIMAL_PRECISION_CONFIG = {\n // Maximum decimal places for price input (matches Hyperliquid limit)\n // Used in TP/SL forms, limit price inputs, and price validation\n MaxPriceDecimals: 6,\n // Maximum significant figures allowed by HyperLiquid API\n // Orders with more than 5 significant figures will be rejected\n MaxSignificantFigures: 5,\n // Defensive fallback for size decimals when market data fails to load\n // Real szDecimals should always come from market data API (varies by asset)\n // Using 6 as safe maximum to prevent crashes (covers most assets)\n // NOTE: This is NOT semantically correct - just a defensive measure\n FallbackSizeDecimals: 6,\n} as const;\n\n/**\n * Development-only configuration for testing and debugging\n * These constants are only active when __DEV__ is true\n */\nexport const DEVELOPMENT_CONFIG = {\n // Magic number to simulate fee discount state (20% discount)\n SimulateFeeDiscountAmount: 41,\n\n // Magic number to simulate rewards error state (set order amount to this value)\n SimulateRewardsErrorAmount: 42,\n\n // Magic number to simulate rewards loading state\n SimulateRewardsLoadingAmount: 43,\n\n // Future: Add other development helpers as needed\n} as const;\n\n/**\n * Home screen configuration\n * Controls carousel limits and display settings for the main Perps home screen\n */\nexport const HOME_SCREEN_CONFIG = {\n // Show action buttons (Add Funds / Withdraw) in header instead of fixed footer\n // Can be controlled via feature flag in the future\n ShowHeaderActionButtons: true,\n\n // Maximum number of items to show in each carousel\n PositionsCarouselLimit: 10,\n OrdersCarouselLimit: 10,\n TrendingMarketsLimit: 5,\n RecentActivityLimit: 3,\n\n // Carousel display behavior\n CarouselSnapAlignment: 'start' as const,\n CarouselVisibleItems: 1.2, // Show 1 full item + 20% of next\n\n // Icon sizes for consistent display across sections\n DefaultIconSize: 40, // Default token icon size for cards and rows\n} as const;\n\n/**\n * Market sorting configuration\n * Controls sorting behavior and presets for the trending markets view\n */\nexport const MARKET_SORTING_CONFIG = {\n // Default sort settings\n DefaultSortOptionId: 'volume' as const,\n DefaultDirection: 'desc' as const,\n\n // Available sort fields (only includes fields supported by PerpsMarketData)\n SortFields: {\n Volume: 'volume',\n PriceChange: 'priceChange',\n OpenInterest: 'openInterest',\n FundingRate: 'fundingRate',\n } as const,\n\n // Sort button presets for filter chips (simplified buttons without direction)\n SortButtonPresets: [\n { field: 'volume', labelKey: 'perps.sort.volume' },\n { field: 'priceChange', labelKey: 'perps.sort.price_change' },\n { field: 'fundingRate', labelKey: 'perps.sort.funding_rate' },\n ] as const,\n\n // Sort options for the bottom sheet\n // Only Price Change can be toggled for direction (similar to trending tokens pattern)\n // Other options (volume, open interest, funding rate) use descending sort only\n SortOptions: [\n {\n id: 'volume',\n labelKey: 'perps.sort.volume',\n field: 'volume',\n direction: 'desc',\n },\n {\n id: 'priceChange',\n labelKey: 'perps.sort.price_change',\n field: 'priceChange',\n direction: 'desc',\n },\n {\n id: 'openInterest',\n labelKey: 'perps.sort.open_interest',\n field: 'openInterest',\n direction: 'desc',\n },\n {\n id: 'fundingRate',\n labelKey: 'perps.sort.funding_rate',\n field: 'fundingRate',\n direction: 'desc',\n },\n ] as const,\n} as const;\n\n/**\n * Type for valid sort option IDs\n * Derived from SORT_OPTIONS to ensure type safety\n * Valid values: 'volume' | 'priceChange' | 'openInterest' | 'fundingRate'\n */\nexport type SortOptionId =\n (typeof MARKET_SORTING_CONFIG.SortOptions)[number]['id'];\n\n/**\n * Type for sort button presets (filter chips)\n * Derived from SORT_BUTTON_PRESETS to ensure type safety\n */\nexport type SortButtonPreset =\n (typeof MARKET_SORTING_CONFIG.SortButtonPresets)[number];\n\n/**\n * Learn more card configuration\n * External resources and content for Perps education\n */\nexport const LEARN_MORE_CONFIG = {\n ExternalUrl: 'https://metamask.io/perps',\n TitleKey: 'perps.tutorial.card.title',\n DescriptionKey: 'perps.learn_more.description',\n CtaKey: 'perps.learn_more.cta',\n} as const;\n\n/**\n * Support configuration\n * Contact support button configuration (matches Settings behavior)\n */\nexport const SUPPORT_CONFIG = {\n Url: 'https://support.metamask.io',\n TitleKey: 'perps.support.title',\n DescriptionKey: 'perps.support.description',\n} as const;\n\n/**\n * Feedback survey configuration\n * External survey for collecting user feedback on Perps trading experience\n */\nexport const FEEDBACK_CONFIG = {\n Url: 'https://survey.alchemer.com/s3/8649911/MetaMask-Perps-Trading-Feedback',\n TitleKey: 'perps.feedback.title',\n} as const;\n\n/**\n * Support article URLs\n * Links to specific MetaMask support articles for Perps features\n */\nexport const PERPS_SUPPORT_ARTICLES_URLS = {\n AdlUrl:\n 'https://support.metamask.io/manage-crypto/trade/perps/leverage-and-liquidation/#what-is-auto-deleveraging-adl',\n} as const;\n\n/**\n * Stop loss prompt banner configuration\n * Controls when and how the stop loss prompt banner is displayed\n * Based on TAT-1693 specifications\n */\nexport const STOP_LOSS_PROMPT_CONFIG = {\n // Distance to liquidation threshold (percentage)\n // Shows \"Add margin\" banner when position is within this % of liquidation\n LiquidationDistanceThreshold: 3,\n\n // ROE (Return on Equity) threshold (percentage)\n // Shows \"Set stop loss\" banner when ROE drops below this value\n RoeThreshold: -10,\n\n // Minimum loss threshold to show ANY banner (percentage)\n // No banner shown until ROE drops below this value\n MinLossThreshold: -10,\n\n // Debounce duration for ROE threshold (milliseconds)\n // User must have ROE below threshold for this duration before showing banner\n // Prevents banner from appearing during temporary price fluctuations\n RoeDebounceMs: 60_000, // 60 seconds\n\n // Minimum position age before showing any banner (milliseconds)\n // Prevents banner from appearing immediately after opening a position\n PositionMinAgeMs: 60_000, // 60 seconds\n\n // Suggested stop loss ROE percentage\n // When suggesting a stop loss, calculate price at this ROE from entry\n SuggestedStopLossRoe: -50,\n} as const;\n\n/**\n * Transactions history configuration\n * Controls history display and data fetching parameters\n */\nexport const PERPS_TRANSACTIONS_HISTORY_CONSTANTS = {\n /**\n * Default number of days to look back for funding history.\n * HyperLiquid API requires a startTime and returns max 500 records.\n * Using 365 days ensures most users see their complete recent history.\n * Can be increased if users need older funding data.\n */\n DefaultFundingHistoryDays: 365,\n} as const;\n"]}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PERPS_ERROR_CODES = void 0;
4
+ /**
5
+ * Error codes for PerpsController
6
+ * These codes are returned to the UI layer for translation
7
+ * Extracted to separate file to avoid circular dependencies with translatePerpsError
8
+ */
9
+ exports.PERPS_ERROR_CODES = {
10
+ CLIENT_NOT_INITIALIZED: 'CLIENT_NOT_INITIALIZED',
11
+ CLIENT_REINITIALIZING: 'CLIENT_REINITIALIZING',
12
+ PROVIDER_NOT_AVAILABLE: 'PROVIDER_NOT_AVAILABLE',
13
+ TOKEN_NOT_SUPPORTED: 'TOKEN_NOT_SUPPORTED',
14
+ BRIDGE_CONTRACT_NOT_FOUND: 'BRIDGE_CONTRACT_NOT_FOUND',
15
+ WITHDRAW_FAILED: 'WITHDRAW_FAILED',
16
+ POSITIONS_FAILED: 'POSITIONS_FAILED',
17
+ ACCOUNT_STATE_FAILED: 'ACCOUNT_STATE_FAILED',
18
+ MARKETS_FAILED: 'MARKETS_FAILED',
19
+ UNKNOWN_ERROR: 'UNKNOWN_ERROR',
20
+ // Provider-agnostic order errors
21
+ ORDER_LEVERAGE_REDUCTION_FAILED: 'ORDER_LEVERAGE_REDUCTION_FAILED',
22
+ // HyperLiquid-specific order errors
23
+ IOC_CANCEL: 'IOC_CANCEL', // Order could not immediately match (insufficient liquidity)
24
+ // Connection errors
25
+ CONNECTION_TIMEOUT: 'CONNECTION_TIMEOUT',
26
+ // Validation errors - withdraw
27
+ WITHDRAW_ASSET_ID_REQUIRED: 'WITHDRAW_ASSET_ID_REQUIRED',
28
+ WITHDRAW_AMOUNT_REQUIRED: 'WITHDRAW_AMOUNT_REQUIRED',
29
+ WITHDRAW_AMOUNT_POSITIVE: 'WITHDRAW_AMOUNT_POSITIVE',
30
+ WITHDRAW_INVALID_DESTINATION: 'WITHDRAW_INVALID_DESTINATION',
31
+ WITHDRAW_ASSET_NOT_SUPPORTED: 'WITHDRAW_ASSET_NOT_SUPPORTED',
32
+ WITHDRAW_INSUFFICIENT_BALANCE: 'WITHDRAW_INSUFFICIENT_BALANCE',
33
+ // Validation errors - deposit
34
+ DEPOSIT_ASSET_ID_REQUIRED: 'DEPOSIT_ASSET_ID_REQUIRED',
35
+ DEPOSIT_AMOUNT_REQUIRED: 'DEPOSIT_AMOUNT_REQUIRED',
36
+ DEPOSIT_AMOUNT_POSITIVE: 'DEPOSIT_AMOUNT_POSITIVE',
37
+ DEPOSIT_MINIMUM_AMOUNT: 'DEPOSIT_MINIMUM_AMOUNT',
38
+ // Validation errors - order
39
+ ORDER_COIN_REQUIRED: 'ORDER_COIN_REQUIRED',
40
+ ORDER_LIMIT_PRICE_REQUIRED: 'ORDER_LIMIT_PRICE_REQUIRED',
41
+ ORDER_PRICE_POSITIVE: 'ORDER_PRICE_POSITIVE',
42
+ ORDER_UNKNOWN_COIN: 'ORDER_UNKNOWN_COIN',
43
+ ORDER_SIZE_POSITIVE: 'ORDER_SIZE_POSITIVE',
44
+ ORDER_PRICE_REQUIRED: 'ORDER_PRICE_REQUIRED',
45
+ ORDER_SIZE_MIN: 'ORDER_SIZE_MIN',
46
+ ORDER_LEVERAGE_INVALID: 'ORDER_LEVERAGE_INVALID',
47
+ ORDER_LEVERAGE_BELOW_POSITION: 'ORDER_LEVERAGE_BELOW_POSITION',
48
+ ORDER_MAX_VALUE_EXCEEDED: 'ORDER_MAX_VALUE_EXCEEDED',
49
+ // HyperLiquid client/service errors
50
+ EXCHANGE_CLIENT_NOT_AVAILABLE: 'EXCHANGE_CLIENT_NOT_AVAILABLE',
51
+ INFO_CLIENT_NOT_AVAILABLE: 'INFO_CLIENT_NOT_AVAILABLE',
52
+ SUBSCRIPTION_CLIENT_NOT_AVAILABLE: 'SUBSCRIPTION_CLIENT_NOT_AVAILABLE',
53
+ // Wallet/account errors
54
+ NO_ACCOUNT_SELECTED: 'NO_ACCOUNT_SELECTED',
55
+ INVALID_ADDRESS_FORMAT: 'INVALID_ADDRESS_FORMAT',
56
+ // Transfer/swap errors
57
+ TRANSFER_FAILED: 'TRANSFER_FAILED',
58
+ SWAP_FAILED: 'SWAP_FAILED',
59
+ SPOT_PAIR_NOT_FOUND: 'SPOT_PAIR_NOT_FOUND',
60
+ PRICE_UNAVAILABLE: 'PRICE_UNAVAILABLE',
61
+ // Batch operation errors
62
+ BATCH_CANCEL_FAILED: 'BATCH_CANCEL_FAILED',
63
+ BATCH_CLOSE_FAILED: 'BATCH_CLOSE_FAILED',
64
+ // Position/margin errors
65
+ INSUFFICIENT_MARGIN: 'INSUFFICIENT_MARGIN',
66
+ INSUFFICIENT_BALANCE: 'INSUFFICIENT_BALANCE',
67
+ REDUCE_ONLY_VIOLATION: 'REDUCE_ONLY_VIOLATION',
68
+ POSITION_WOULD_FLIP: 'POSITION_WOULD_FLIP',
69
+ MARGIN_ADJUSTMENT_FAILED: 'MARGIN_ADJUSTMENT_FAILED',
70
+ TPSL_UPDATE_FAILED: 'TPSL_UPDATE_FAILED',
71
+ // Order execution errors
72
+ ORDER_REJECTED: 'ORDER_REJECTED',
73
+ SLIPPAGE_EXCEEDED: 'SLIPPAGE_EXCEEDED',
74
+ RATE_LIMIT_EXCEEDED: 'RATE_LIMIT_EXCEEDED',
75
+ // Network/service errors
76
+ SERVICE_UNAVAILABLE: 'SERVICE_UNAVAILABLE',
77
+ NETWORK_ERROR: 'NETWORK_ERROR',
78
+ };
79
+ //# sourceMappingURL=perpsErrorCodes.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"perpsErrorCodes.cjs","sourceRoot":"","sources":["../../src/constants/perpsErrorCodes.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,iBAAiB,GAAG;IAC/B,sBAAsB,EAAE,wBAAwB;IAChD,qBAAqB,EAAE,uBAAuB;IAC9C,sBAAsB,EAAE,wBAAwB;IAChD,mBAAmB,EAAE,qBAAqB;IAC1C,yBAAyB,EAAE,2BAA2B;IACtD,eAAe,EAAE,iBAAiB;IAClC,gBAAgB,EAAE,kBAAkB;IACpC,oBAAoB,EAAE,sBAAsB;IAC5C,cAAc,EAAE,gBAAgB;IAChC,aAAa,EAAE,eAAe;IAC9B,iCAAiC;IACjC,+BAA+B,EAAE,iCAAiC;IAClE,oCAAoC;IACpC,UAAU,EAAE,YAAY,EAAE,6DAA6D;IACvF,oBAAoB;IACpB,kBAAkB,EAAE,oBAAoB;IACxC,+BAA+B;IAC/B,0BAA0B,EAAE,4BAA4B;IACxD,wBAAwB,EAAE,0BAA0B;IACpD,wBAAwB,EAAE,0BAA0B;IACpD,4BAA4B,EAAE,8BAA8B;IAC5D,4BAA4B,EAAE,8BAA8B;IAC5D,6BAA6B,EAAE,+BAA+B;IAC9D,8BAA8B;IAC9B,yBAAyB,EAAE,2BAA2B;IACtD,uBAAuB,EAAE,yBAAyB;IAClD,uBAAuB,EAAE,yBAAyB;IAClD,sBAAsB,EAAE,wBAAwB;IAChD,4BAA4B;IAC5B,mBAAmB,EAAE,qBAAqB;IAC1C,0BAA0B,EAAE,4BAA4B;IACxD,oBAAoB,EAAE,sBAAsB;IAC5C,kBAAkB,EAAE,oBAAoB;IACxC,mBAAmB,EAAE,qBAAqB;IAC1C,oBAAoB,EAAE,sBAAsB;IAC5C,cAAc,EAAE,gBAAgB;IAChC,sBAAsB,EAAE,wBAAwB;IAChD,6BAA6B,EAAE,+BAA+B;IAC9D,wBAAwB,EAAE,0BAA0B;IACpD,oCAAoC;IACpC,6BAA6B,EAAE,+BAA+B;IAC9D,yBAAyB,EAAE,2BAA2B;IACtD,iCAAiC,EAAE,mCAAmC;IACtE,wBAAwB;IACxB,mBAAmB,EAAE,qBAAqB;IAC1C,sBAAsB,EAAE,wBAAwB;IAChD,uBAAuB;IACvB,eAAe,EAAE,iBAAiB;IAClC,WAAW,EAAE,aAAa;IAC1B,mBAAmB,EAAE,qBAAqB;IAC1C,iBAAiB,EAAE,mBAAmB;IACtC,yBAAyB;IACzB,mBAAmB,EAAE,qBAAqB;IAC1C,kBAAkB,EAAE,oBAAoB;IACxC,yBAAyB;IACzB,mBAAmB,EAAE,qBAAqB;IAC1C,oBAAoB,EAAE,sBAAsB;IAC5C,qBAAqB,EAAE,uBAAuB;IAC9C,mBAAmB,EAAE,qBAAqB;IAC1C,wBAAwB,EAAE,0BAA0B;IACpD,kBAAkB,EAAE,oBAAoB;IACxC,yBAAyB;IACzB,cAAc,EAAE,gBAAgB;IAChC,iBAAiB,EAAE,mBAAmB;IACtC,mBAAmB,EAAE,qBAAqB;IAC1C,yBAAyB;IACzB,mBAAmB,EAAE,qBAAqB;IAC1C,aAAa,EAAE,eAAe;CACtB,CAAC","sourcesContent":["/**\n * Error codes for PerpsController\n * These codes are returned to the UI layer for translation\n * Extracted to separate file to avoid circular dependencies with translatePerpsError\n */\nexport const PERPS_ERROR_CODES = {\n CLIENT_NOT_INITIALIZED: 'CLIENT_NOT_INITIALIZED',\n CLIENT_REINITIALIZING: 'CLIENT_REINITIALIZING',\n PROVIDER_NOT_AVAILABLE: 'PROVIDER_NOT_AVAILABLE',\n TOKEN_NOT_SUPPORTED: 'TOKEN_NOT_SUPPORTED',\n BRIDGE_CONTRACT_NOT_FOUND: 'BRIDGE_CONTRACT_NOT_FOUND',\n WITHDRAW_FAILED: 'WITHDRAW_FAILED',\n POSITIONS_FAILED: 'POSITIONS_FAILED',\n ACCOUNT_STATE_FAILED: 'ACCOUNT_STATE_FAILED',\n MARKETS_FAILED: 'MARKETS_FAILED',\n UNKNOWN_ERROR: 'UNKNOWN_ERROR',\n // Provider-agnostic order errors\n ORDER_LEVERAGE_REDUCTION_FAILED: 'ORDER_LEVERAGE_REDUCTION_FAILED',\n // HyperLiquid-specific order errors\n IOC_CANCEL: 'IOC_CANCEL', // Order could not immediately match (insufficient liquidity)\n // Connection errors\n CONNECTION_TIMEOUT: 'CONNECTION_TIMEOUT',\n // Validation errors - withdraw\n WITHDRAW_ASSET_ID_REQUIRED: 'WITHDRAW_ASSET_ID_REQUIRED',\n WITHDRAW_AMOUNT_REQUIRED: 'WITHDRAW_AMOUNT_REQUIRED',\n WITHDRAW_AMOUNT_POSITIVE: 'WITHDRAW_AMOUNT_POSITIVE',\n WITHDRAW_INVALID_DESTINATION: 'WITHDRAW_INVALID_DESTINATION',\n WITHDRAW_ASSET_NOT_SUPPORTED: 'WITHDRAW_ASSET_NOT_SUPPORTED',\n WITHDRAW_INSUFFICIENT_BALANCE: 'WITHDRAW_INSUFFICIENT_BALANCE',\n // Validation errors - deposit\n DEPOSIT_ASSET_ID_REQUIRED: 'DEPOSIT_ASSET_ID_REQUIRED',\n DEPOSIT_AMOUNT_REQUIRED: 'DEPOSIT_AMOUNT_REQUIRED',\n DEPOSIT_AMOUNT_POSITIVE: 'DEPOSIT_AMOUNT_POSITIVE',\n DEPOSIT_MINIMUM_AMOUNT: 'DEPOSIT_MINIMUM_AMOUNT',\n // Validation errors - order\n ORDER_COIN_REQUIRED: 'ORDER_COIN_REQUIRED',\n ORDER_LIMIT_PRICE_REQUIRED: 'ORDER_LIMIT_PRICE_REQUIRED',\n ORDER_PRICE_POSITIVE: 'ORDER_PRICE_POSITIVE',\n ORDER_UNKNOWN_COIN: 'ORDER_UNKNOWN_COIN',\n ORDER_SIZE_POSITIVE: 'ORDER_SIZE_POSITIVE',\n ORDER_PRICE_REQUIRED: 'ORDER_PRICE_REQUIRED',\n ORDER_SIZE_MIN: 'ORDER_SIZE_MIN',\n ORDER_LEVERAGE_INVALID: 'ORDER_LEVERAGE_INVALID',\n ORDER_LEVERAGE_BELOW_POSITION: 'ORDER_LEVERAGE_BELOW_POSITION',\n ORDER_MAX_VALUE_EXCEEDED: 'ORDER_MAX_VALUE_EXCEEDED',\n // HyperLiquid client/service errors\n EXCHANGE_CLIENT_NOT_AVAILABLE: 'EXCHANGE_CLIENT_NOT_AVAILABLE',\n INFO_CLIENT_NOT_AVAILABLE: 'INFO_CLIENT_NOT_AVAILABLE',\n SUBSCRIPTION_CLIENT_NOT_AVAILABLE: 'SUBSCRIPTION_CLIENT_NOT_AVAILABLE',\n // Wallet/account errors\n NO_ACCOUNT_SELECTED: 'NO_ACCOUNT_SELECTED',\n INVALID_ADDRESS_FORMAT: 'INVALID_ADDRESS_FORMAT',\n // Transfer/swap errors\n TRANSFER_FAILED: 'TRANSFER_FAILED',\n SWAP_FAILED: 'SWAP_FAILED',\n SPOT_PAIR_NOT_FOUND: 'SPOT_PAIR_NOT_FOUND',\n PRICE_UNAVAILABLE: 'PRICE_UNAVAILABLE',\n // Batch operation errors\n BATCH_CANCEL_FAILED: 'BATCH_CANCEL_FAILED',\n BATCH_CLOSE_FAILED: 'BATCH_CLOSE_FAILED',\n // Position/margin errors\n INSUFFICIENT_MARGIN: 'INSUFFICIENT_MARGIN',\n INSUFFICIENT_BALANCE: 'INSUFFICIENT_BALANCE',\n REDUCE_ONLY_VIOLATION: 'REDUCE_ONLY_VIOLATION',\n POSITION_WOULD_FLIP: 'POSITION_WOULD_FLIP',\n MARGIN_ADJUSTMENT_FAILED: 'MARGIN_ADJUSTMENT_FAILED',\n TPSL_UPDATE_FAILED: 'TPSL_UPDATE_FAILED',\n // Order execution errors\n ORDER_REJECTED: 'ORDER_REJECTED',\n SLIPPAGE_EXCEEDED: 'SLIPPAGE_EXCEEDED',\n RATE_LIMIT_EXCEEDED: 'RATE_LIMIT_EXCEEDED',\n // Network/service errors\n SERVICE_UNAVAILABLE: 'SERVICE_UNAVAILABLE',\n NETWORK_ERROR: 'NETWORK_ERROR',\n} as const;\n\nexport type PerpsErrorCode =\n (typeof PERPS_ERROR_CODES)[keyof typeof PERPS_ERROR_CODES];\n"]}