@metamask-previews/perps-controller 16.1.0-preview-abca9bcea → 17.0.0-preview-0a30e47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (891) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/README.md +17 -0
  3. package/dist/PerpsController-method-action-types.d.ts +1235 -0
  4. package/dist/PerpsController-method-action-types.d.ts.map +1 -0
  5. package/dist/PerpsController-method-action-types.js +6 -0
  6. package/dist/PerpsController-method-action-types.js.map +1 -0
  7. package/dist/PerpsController.d.ts +1313 -0
  8. package/dist/PerpsController.d.ts.map +1 -0
  9. package/dist/PerpsController.js +5331 -0
  10. package/dist/PerpsController.js.map +1 -0
  11. package/dist/aggregation/SubscriptionMultiplexer.d.ts +171 -0
  12. package/dist/aggregation/SubscriptionMultiplexer.d.ts.map +1 -0
  13. package/dist/aggregation/SubscriptionMultiplexer.js +451 -0
  14. package/dist/aggregation/SubscriptionMultiplexer.js.map +1 -0
  15. package/dist/aggregation/index.d.ts +6 -0
  16. package/dist/aggregation/index.d.ts.map +1 -0
  17. package/dist/aggregation/index.js +5 -0
  18. package/dist/aggregation/index.js.map +1 -0
  19. package/dist/constants/chartConfig.d.ts +228 -0
  20. package/dist/constants/chartConfig.d.ts.map +1 -0
  21. package/dist/constants/chartConfig.js +233 -0
  22. package/dist/constants/chartConfig.js.map +1 -0
  23. package/dist/constants/eventNames.d.ts +565 -0
  24. package/dist/constants/eventNames.d.ts.map +1 -0
  25. package/dist/constants/eventNames.js +657 -0
  26. package/dist/constants/eventNames.js.map +1 -0
  27. package/dist/constants/hyperLiquidConfig.d.ts +280 -0
  28. package/dist/constants/hyperLiquidConfig.d.ts.map +1 -0
  29. package/dist/constants/hyperLiquidConfig.js +596 -0
  30. package/dist/constants/hyperLiquidConfig.js.map +1 -0
  31. package/dist/constants/index.d.ts +12 -0
  32. package/dist/constants/index.d.ts.map +1 -0
  33. package/dist/constants/index.js +12 -0
  34. package/dist/constants/index.js.map +1 -0
  35. package/dist/constants/lighterConfig.d.ts +204 -0
  36. package/dist/constants/lighterConfig.d.ts.map +1 -0
  37. package/dist/constants/lighterConfig.js +317 -0
  38. package/dist/constants/lighterConfig.js.map +1 -0
  39. package/dist/constants/orderTypes.d.ts +19 -0
  40. package/dist/constants/orderTypes.d.ts.map +1 -0
  41. package/dist/constants/orderTypes.js +27 -0
  42. package/dist/constants/orderTypes.js.map +1 -0
  43. package/dist/constants/performanceMetrics.d.ts +46 -0
  44. package/dist/constants/performanceMetrics.d.ts.map +1 -0
  45. package/dist/constants/performanceMetrics.js +60 -0
  46. package/dist/constants/performanceMetrics.js.map +1 -0
  47. package/dist/constants/perpsConfig.d.ts +480 -0
  48. package/dist/constants/perpsConfig.d.ts.map +1 -0
  49. package/dist/constants/perpsConfig.js +555 -0
  50. package/dist/constants/perpsConfig.js.map +1 -0
  51. package/dist/constants/transactionsHistoryConfig.d.ts +35 -0
  52. package/dist/constants/transactionsHistoryConfig.d.ts.map +1 -0
  53. package/dist/constants/transactionsHistoryConfig.js +35 -0
  54. package/dist/constants/transactionsHistoryConfig.js.map +1 -0
  55. package/dist/index.d.ts +95 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +80 -0
  58. package/dist/index.js.map +1 -0
  59. package/dist/perpsErrorCodes.d.ts +113 -0
  60. package/dist/perpsErrorCodes.d.ts.map +1 -0
  61. package/dist/perpsErrorCodes.js +133 -0
  62. package/dist/perpsErrorCodes.js.map +1 -0
  63. package/dist/providers/AggregatedPerpsProvider.d.ts +277 -0
  64. package/dist/providers/AggregatedPerpsProvider.d.ts.map +1 -0
  65. package/dist/providers/AggregatedPerpsProvider.js +827 -0
  66. package/dist/providers/AggregatedPerpsProvider.js.map +1 -0
  67. package/dist/providers/HyperLiquidProvider.d.ts +656 -0
  68. package/dist/providers/HyperLiquidProvider.d.ts.map +1 -0
  69. package/dist/providers/HyperLiquidProvider.js +11308 -0
  70. package/dist/providers/HyperLiquidProvider.js.map +1 -0
  71. package/dist/providers/LighterProvider.d.ts +179 -0
  72. package/dist/providers/LighterProvider.d.ts.map +1 -0
  73. package/dist/providers/LighterProvider.js +6599 -0
  74. package/dist/providers/LighterProvider.js.map +1 -0
  75. package/dist/routing/ProviderRouter.d.ts +112 -0
  76. package/dist/routing/ProviderRouter.d.ts.map +1 -0
  77. package/dist/routing/ProviderRouter.js +137 -0
  78. package/dist/routing/ProviderRouter.js.map +1 -0
  79. package/dist/routing/index.d.ts +6 -0
  80. package/dist/routing/index.d.ts.map +1 -0
  81. package/dist/routing/index.js +5 -0
  82. package/dist/routing/index.js.map +1 -0
  83. package/dist/selectors.d.ts +336 -0
  84. package/dist/selectors.d.ts.map +1 -0
  85. package/dist/selectors.js +249 -0
  86. package/dist/selectors.js.map +1 -0
  87. package/dist/services/AccountService.d.ts +56 -0
  88. package/dist/services/AccountService.d.ts.map +1 -0
  89. package/dist/services/AccountService.js +307 -0
  90. package/dist/services/AccountService.js.map +1 -0
  91. package/dist/services/AggregatedOrderBookConnection.d.ts +106 -0
  92. package/dist/services/AggregatedOrderBookConnection.d.ts.map +1 -0
  93. package/dist/services/AggregatedOrderBookConnection.js +388 -0
  94. package/dist/services/AggregatedOrderBookConnection.js.map +1 -0
  95. package/dist/services/DataLakeService.d.ts +51 -0
  96. package/dist/services/DataLakeService.d.ts.map +1 -0
  97. package/dist/services/DataLakeService.js +215 -0
  98. package/dist/services/DataLakeService.js.map +1 -0
  99. package/dist/services/DepositService.d.ts +39 -0
  100. package/dist/services/DepositService.d.ts.map +1 -0
  101. package/dist/services/DepositService.js +88 -0
  102. package/dist/services/DepositService.js.map +1 -0
  103. package/dist/services/DexDiscoveryCacheManager.d.ts +52 -0
  104. package/dist/services/DexDiscoveryCacheManager.d.ts.map +1 -0
  105. package/dist/services/DexDiscoveryCacheManager.js +130 -0
  106. package/dist/services/DexDiscoveryCacheManager.js.map +1 -0
  107. package/dist/services/EligibilityService.d.ts +28 -0
  108. package/dist/services/EligibilityService.d.ts.map +1 -0
  109. package/dist/services/EligibilityService.js +61 -0
  110. package/dist/services/EligibilityService.js.map +1 -0
  111. package/dist/services/FeatureFlagConfigurationService.d.ts +73 -0
  112. package/dist/services/FeatureFlagConfigurationService.d.ts.map +1 -0
  113. package/dist/services/FeatureFlagConfigurationService.js +266 -0
  114. package/dist/services/FeatureFlagConfigurationService.js.map +1 -0
  115. package/dist/services/HyperLiquidClientService.d.ts +252 -0
  116. package/dist/services/HyperLiquidClientService.d.ts.map +1 -0
  117. package/dist/services/HyperLiquidClientService.js +1152 -0
  118. package/dist/services/HyperLiquidClientService.js.map +1 -0
  119. package/dist/services/HyperLiquidSubscriptionService.d.ts +265 -0
  120. package/dist/services/HyperLiquidSubscriptionService.d.ts.map +1 -0
  121. package/dist/services/HyperLiquidSubscriptionService.js +3874 -0
  122. package/dist/services/HyperLiquidSubscriptionService.js.map +1 -0
  123. package/dist/services/HyperLiquidWalletService.d.ts +84 -0
  124. package/dist/services/HyperLiquidWalletService.d.ts.map +1 -0
  125. package/dist/services/HyperLiquidWalletService.js +168 -0
  126. package/dist/services/HyperLiquidWalletService.js.map +1 -0
  127. package/dist/services/LighterClientService.d.ts +200 -0
  128. package/dist/services/LighterClientService.d.ts.map +1 -0
  129. package/dist/services/LighterClientService.js +634 -0
  130. package/dist/services/LighterClientService.js.map +1 -0
  131. package/dist/services/LighterWalletService.d.ts +51 -0
  132. package/dist/services/LighterWalletService.d.ts.map +1 -0
  133. package/dist/services/LighterWalletService.js +92 -0
  134. package/dist/services/LighterWalletService.js.map +1 -0
  135. package/dist/services/MarketDataService.d.ts +350 -0
  136. package/dist/services/MarketDataService.d.ts.map +1 -0
  137. package/dist/services/MarketDataService.js +1165 -0
  138. package/dist/services/MarketDataService.js.map +1 -0
  139. package/dist/services/RewardsIntegrationService.d.ts +84 -0
  140. package/dist/services/RewardsIntegrationService.d.ts.map +1 -0
  141. package/dist/services/RewardsIntegrationService.js +380 -0
  142. package/dist/services/RewardsIntegrationService.js.map +1 -0
  143. package/dist/services/ServiceContext.d.ts +102 -0
  144. package/dist/services/ServiceContext.d.ts.map +1 -0
  145. package/dist/services/ServiceContext.js +2 -0
  146. package/dist/services/ServiceContext.js.map +1 -0
  147. package/dist/services/TerminalMarketService.d.ts +45 -0
  148. package/dist/services/TerminalMarketService.d.ts.map +1 -0
  149. package/dist/services/TerminalMarketService.js +640 -0
  150. package/dist/services/TerminalMarketService.js.map +1 -0
  151. package/dist/services/TradingReadinessCache.d.ts +204 -0
  152. package/dist/services/TradingReadinessCache.d.ts.map +1 -0
  153. package/dist/services/TradingReadinessCache.js +313 -0
  154. package/dist/services/TradingReadinessCache.js.map +1 -0
  155. package/dist/services/TradingService.d.ts +201 -0
  156. package/dist/services/TradingService.d.ts.map +1 -0
  157. package/dist/services/TradingService.js +1967 -0
  158. package/dist/services/TradingService.js.map +1 -0
  159. package/dist/types/config.d.ts +49 -0
  160. package/dist/types/config.d.ts.map +1 -0
  161. package/dist/types/config.js +2 -0
  162. package/dist/types/config.js.map +1 -0
  163. package/dist/types/hyperliquid-types.d.ts +67 -0
  164. package/dist/types/hyperliquid-types.d.ts.map +1 -0
  165. package/dist/types/hyperliquid-types.js +41 -0
  166. package/dist/types/hyperliquid-types.js.map +1 -0
  167. package/dist/types/index.d.ts +2192 -0
  168. package/dist/types/index.d.ts.map +1 -0
  169. package/dist/types/index.js +133 -0
  170. package/dist/types/index.js.map +1 -0
  171. package/dist/types/lighter-types.d.ts +772 -0
  172. package/dist/types/lighter-types.d.ts.map +1 -0
  173. package/dist/types/lighter-types.js +10 -0
  174. package/dist/types/lighter-types.js.map +1 -0
  175. package/dist/types/messenger.d.ts +30 -0
  176. package/dist/types/messenger.d.ts.map +1 -0
  177. package/dist/types/messenger.js +2 -0
  178. package/dist/types/messenger.js.map +1 -0
  179. package/dist/types/perps-types.d.ts +184 -0
  180. package/dist/types/perps-types.d.ts.map +1 -0
  181. package/dist/types/perps-types.js +2 -0
  182. package/dist/types/perps-types.js.map +1 -0
  183. package/dist/types/token.d.ts +25 -0
  184. package/dist/types/token.d.ts.map +1 -0
  185. package/dist/types/token.js +2 -0
  186. package/dist/types/token.js.map +1 -0
  187. package/dist/types/transactionTypes.d.ts +60 -0
  188. package/dist/types/transactionTypes.d.ts.map +1 -0
  189. package/dist/types/transactionTypes.js +24 -0
  190. package/dist/types/transactionTypes.js.map +1 -0
  191. package/dist/utils/accountUtils.d.ts +72 -0
  192. package/dist/utils/accountUtils.d.ts.map +1 -0
  193. package/dist/utils/accountUtils.js +223 -0
  194. package/dist/utils/accountUtils.js.map +1 -0
  195. package/dist/utils/capabilitySymbols.d.ts +15 -0
  196. package/dist/utils/capabilitySymbols.d.ts.map +1 -0
  197. package/dist/utils/capabilitySymbols.js +21 -0
  198. package/dist/utils/capabilitySymbols.js.map +1 -0
  199. package/dist/utils/coalescePerpsRestRequest.d.ts +32 -0
  200. package/dist/utils/coalescePerpsRestRequest.d.ts.map +1 -0
  201. package/dist/utils/coalescePerpsRestRequest.js +66 -0
  202. package/dist/utils/coalescePerpsRestRequest.js.map +1 -0
  203. package/dist/utils/errorUtils.d.ts +50 -0
  204. package/dist/utils/errorUtils.d.ts.map +1 -0
  205. package/dist/utils/errorUtils.js +96 -0
  206. package/dist/utils/errorUtils.js.map +1 -0
  207. package/dist/utils/hyperLiquidAbstraction.d.ts +11 -0
  208. package/dist/utils/hyperLiquidAbstraction.d.ts.map +1 -0
  209. package/dist/utils/hyperLiquidAbstraction.js +19 -0
  210. package/dist/utils/hyperLiquidAbstraction.js.map +1 -0
  211. package/dist/utils/hyperLiquidAdapter.d.ts +77 -0
  212. package/dist/utils/hyperLiquidAdapter.d.ts.map +1 -0
  213. package/dist/utils/hyperLiquidAdapter.js +495 -0
  214. package/dist/utils/hyperLiquidAdapter.js.map +1 -0
  215. package/dist/utils/hyperLiquidOrderBookProcessor.d.ts +55 -0
  216. package/dist/utils/hyperLiquidOrderBookProcessor.d.ts.map +1 -0
  217. package/dist/utils/hyperLiquidOrderBookProcessor.js +78 -0
  218. package/dist/utils/hyperLiquidOrderBookProcessor.js.map +1 -0
  219. package/dist/utils/hyperLiquidPositionPreview.d.ts +124 -0
  220. package/dist/utils/hyperLiquidPositionPreview.d.ts.map +1 -0
  221. package/dist/utils/hyperLiquidPositionPreview.js +347 -0
  222. package/dist/utils/hyperLiquidPositionPreview.js.map +1 -0
  223. package/dist/utils/hyperLiquidValidation.d.ts +192 -0
  224. package/dist/utils/hyperLiquidValidation.d.ts.map +1 -0
  225. package/dist/utils/hyperLiquidValidation.js +786 -0
  226. package/dist/utils/hyperLiquidValidation.js.map +1 -0
  227. package/dist/utils/idUtils.d.ts +6 -0
  228. package/dist/utils/idUtils.d.ts.map +1 -0
  229. package/dist/utils/idUtils.js +10 -0
  230. package/dist/utils/idUtils.js.map +1 -0
  231. package/dist/utils/index.d.ts +29 -0
  232. package/dist/utils/index.d.ts.map +1 -0
  233. package/dist/utils/index.js +34 -0
  234. package/dist/utils/index.js.map +1 -0
  235. package/dist/utils/lighterAdapter.d.ts +117 -0
  236. package/dist/utils/lighterAdapter.d.ts.map +1 -0
  237. package/dist/utils/lighterAdapter.js +562 -0
  238. package/dist/utils/lighterAdapter.js.map +1 -0
  239. package/dist/utils/marketDataTransform.d.ts +71 -0
  240. package/dist/utils/marketDataTransform.d.ts.map +1 -0
  241. package/dist/utils/marketDataTransform.js +243 -0
  242. package/dist/utils/marketDataTransform.js.map +1 -0
  243. package/dist/utils/marketSearch.d.ts +48 -0
  244. package/dist/utils/marketSearch.d.ts.map +1 -0
  245. package/dist/utils/marketSearch.js +106 -0
  246. package/dist/utils/marketSearch.js.map +1 -0
  247. package/dist/utils/marketUtils.d.ts +73 -0
  248. package/dist/utils/marketUtils.d.ts.map +1 -0
  249. package/dist/utils/marketUtils.js +248 -0
  250. package/dist/utils/marketUtils.js.map +1 -0
  251. package/dist/utils/orderCalculations.d.ts +306 -0
  252. package/dist/utils/orderCalculations.d.ts.map +1 -0
  253. package/dist/utils/orderCalculations.js +833 -0
  254. package/dist/utils/orderCalculations.js.map +1 -0
  255. package/dist/utils/orderTypes.d.ts +166 -0
  256. package/dist/utils/orderTypes.d.ts.map +1 -0
  257. package/dist/utils/orderTypes.js +287 -0
  258. package/dist/utils/orderTypes.js.map +1 -0
  259. package/dist/utils/perpsConnectionAttemptContext.d.ts +7 -0
  260. package/dist/utils/perpsConnectionAttemptContext.d.ts.map +1 -0
  261. package/dist/utils/perpsConnectionAttemptContext.js +15 -0
  262. package/dist/utils/perpsConnectionAttemptContext.js.map +1 -0
  263. package/dist/utils/perpsDiskPersistence.d.ts +112 -0
  264. package/dist/utils/perpsDiskPersistence.d.ts.map +1 -0
  265. package/dist/utils/perpsDiskPersistence.js +251 -0
  266. package/dist/utils/perpsDiskPersistence.js.map +1 -0
  267. package/dist/utils/perpsFormatters.d.ts +204 -0
  268. package/dist/utils/perpsFormatters.d.ts.map +1 -0
  269. package/dist/utils/perpsFormatters.js +500 -0
  270. package/dist/utils/perpsFormatters.js.map +1 -0
  271. package/dist/utils/rewardsUtils.d.ts +33 -0
  272. package/dist/utils/rewardsUtils.d.ts.map +1 -0
  273. package/dist/utils/rewardsUtils.js +92 -0
  274. package/dist/utils/rewardsUtils.js.map +1 -0
  275. package/dist/utils/significantFigures.d.ts +25 -0
  276. package/dist/utils/significantFigures.d.ts.map +1 -0
  277. package/dist/utils/significantFigures.js +82 -0
  278. package/dist/utils/significantFigures.js.map +1 -0
  279. package/dist/utils/sortMarkets.d.ts +25 -0
  280. package/dist/utils/sortMarkets.d.ts.map +1 -0
  281. package/dist/utils/sortMarkets.js +88 -0
  282. package/dist/utils/sortMarkets.js.map +1 -0
  283. package/dist/utils/standaloneInfoClient.d.ts +37 -0
  284. package/dist/utils/standaloneInfoClient.d.ts.map +1 -0
  285. package/dist/utils/standaloneInfoClient.js +64 -0
  286. package/dist/utils/standaloneInfoClient.js.map +1 -0
  287. package/dist/utils/stringParseUtils.d.ts +11 -0
  288. package/dist/utils/stringParseUtils.d.ts.map +1 -0
  289. package/dist/utils/stringParseUtils.js +28 -0
  290. package/dist/utils/stringParseUtils.js.map +1 -0
  291. package/dist/utils/transferData.d.ts +9 -0
  292. package/dist/utils/transferData.d.ts.map +1 -0
  293. package/dist/utils/transferData.js +29 -0
  294. package/dist/utils/transferData.js.map +1 -0
  295. package/dist/utils/wait.d.ts +2 -0
  296. package/dist/utils/wait.d.ts.map +1 -0
  297. package/dist/utils/wait.js +2 -0
  298. package/dist/utils/wait.js.map +1 -0
  299. package/package.json +33 -61
  300. package/dist/PerpsController-method-action-types.cjs +0 -7
  301. package/dist/PerpsController-method-action-types.cjs.map +0 -1
  302. package/dist/PerpsController-method-action-types.d.cts +0 -1235
  303. package/dist/PerpsController-method-action-types.d.cts.map +0 -1
  304. package/dist/PerpsController-method-action-types.d.mts +0 -1235
  305. package/dist/PerpsController-method-action-types.d.mts.map +0 -1
  306. package/dist/PerpsController-method-action-types.mjs +0 -6
  307. package/dist/PerpsController-method-action-types.mjs.map +0 -1
  308. package/dist/PerpsController.cjs +0 -5154
  309. package/dist/PerpsController.cjs.map +0 -1
  310. package/dist/PerpsController.d.cts +0 -1313
  311. package/dist/PerpsController.d.cts.map +0 -1
  312. package/dist/PerpsController.d.mts +0 -1313
  313. package/dist/PerpsController.d.mts.map +0 -1
  314. package/dist/PerpsController.mjs +0 -5142
  315. package/dist/PerpsController.mjs.map +0 -1
  316. package/dist/aggregation/SubscriptionMultiplexer.cjs +0 -441
  317. package/dist/aggregation/SubscriptionMultiplexer.cjs.map +0 -1
  318. package/dist/aggregation/SubscriptionMultiplexer.d.cts +0 -171
  319. package/dist/aggregation/SubscriptionMultiplexer.d.cts.map +0 -1
  320. package/dist/aggregation/SubscriptionMultiplexer.d.mts +0 -171
  321. package/dist/aggregation/SubscriptionMultiplexer.d.mts.map +0 -1
  322. package/dist/aggregation/SubscriptionMultiplexer.mjs +0 -437
  323. package/dist/aggregation/SubscriptionMultiplexer.mjs.map +0 -1
  324. package/dist/aggregation/index.cjs +0 -9
  325. package/dist/aggregation/index.cjs.map +0 -1
  326. package/dist/aggregation/index.d.cts +0 -6
  327. package/dist/aggregation/index.d.cts.map +0 -1
  328. package/dist/aggregation/index.d.mts +0 -6
  329. package/dist/aggregation/index.d.mts.map +0 -1
  330. package/dist/aggregation/index.mjs +0 -5
  331. package/dist/aggregation/index.mjs.map +0 -1
  332. package/dist/constants/chartConfig.cjs +0 -239
  333. package/dist/constants/chartConfig.cjs.map +0 -1
  334. package/dist/constants/chartConfig.d.cts +0 -228
  335. package/dist/constants/chartConfig.d.cts.map +0 -1
  336. package/dist/constants/chartConfig.d.mts +0 -228
  337. package/dist/constants/chartConfig.d.mts.map +0 -1
  338. package/dist/constants/chartConfig.mjs +0 -233
  339. package/dist/constants/chartConfig.mjs.map +0 -1
  340. package/dist/constants/eventNames.cjs +0 -660
  341. package/dist/constants/eventNames.cjs.map +0 -1
  342. package/dist/constants/eventNames.d.cts +0 -565
  343. package/dist/constants/eventNames.d.cts.map +0 -1
  344. package/dist/constants/eventNames.d.mts +0 -565
  345. package/dist/constants/eventNames.d.mts.map +0 -1
  346. package/dist/constants/eventNames.mjs +0 -657
  347. package/dist/constants/eventNames.mjs.map +0 -1
  348. package/dist/constants/hyperLiquidConfig.cjs +0 -607
  349. package/dist/constants/hyperLiquidConfig.cjs.map +0 -1
  350. package/dist/constants/hyperLiquidConfig.d.cts +0 -280
  351. package/dist/constants/hyperLiquidConfig.d.cts.map +0 -1
  352. package/dist/constants/hyperLiquidConfig.d.mts +0 -280
  353. package/dist/constants/hyperLiquidConfig.d.mts.map +0 -1
  354. package/dist/constants/hyperLiquidConfig.mjs +0 -596
  355. package/dist/constants/hyperLiquidConfig.mjs.map +0 -1
  356. package/dist/constants/index.cjs +0 -28
  357. package/dist/constants/index.cjs.map +0 -1
  358. package/dist/constants/index.d.cts +0 -12
  359. package/dist/constants/index.d.cts.map +0 -1
  360. package/dist/constants/index.d.mts +0 -12
  361. package/dist/constants/index.d.mts.map +0 -1
  362. package/dist/constants/index.mjs +0 -12
  363. package/dist/constants/index.mjs.map +0 -1
  364. package/dist/constants/lighterConfig.cjs +0 -328
  365. package/dist/constants/lighterConfig.cjs.map +0 -1
  366. package/dist/constants/lighterConfig.d.cts +0 -204
  367. package/dist/constants/lighterConfig.d.cts.map +0 -1
  368. package/dist/constants/lighterConfig.d.mts +0 -204
  369. package/dist/constants/lighterConfig.d.mts.map +0 -1
  370. package/dist/constants/lighterConfig.mjs +0 -317
  371. package/dist/constants/lighterConfig.mjs.map +0 -1
  372. package/dist/constants/orderTypes.cjs +0 -31
  373. package/dist/constants/orderTypes.cjs.map +0 -1
  374. package/dist/constants/orderTypes.d.cts +0 -19
  375. package/dist/constants/orderTypes.d.cts.map +0 -1
  376. package/dist/constants/orderTypes.d.mts +0 -19
  377. package/dist/constants/orderTypes.d.mts.map +0 -1
  378. package/dist/constants/orderTypes.mjs +0 -27
  379. package/dist/constants/orderTypes.mjs.map +0 -1
  380. package/dist/constants/performanceMetrics.cjs +0 -63
  381. package/dist/constants/performanceMetrics.cjs.map +0 -1
  382. package/dist/constants/performanceMetrics.d.cts +0 -46
  383. package/dist/constants/performanceMetrics.d.cts.map +0 -1
  384. package/dist/constants/performanceMetrics.d.mts +0 -46
  385. package/dist/constants/performanceMetrics.d.mts.map +0 -1
  386. package/dist/constants/performanceMetrics.mjs +0 -60
  387. package/dist/constants/performanceMetrics.mjs.map +0 -1
  388. package/dist/constants/perpsConfig.cjs +0 -560
  389. package/dist/constants/perpsConfig.cjs.map +0 -1
  390. package/dist/constants/perpsConfig.d.cts +0 -480
  391. package/dist/constants/perpsConfig.d.cts.map +0 -1
  392. package/dist/constants/perpsConfig.d.mts +0 -480
  393. package/dist/constants/perpsConfig.d.mts.map +0 -1
  394. package/dist/constants/perpsConfig.mjs +0 -555
  395. package/dist/constants/perpsConfig.mjs.map +0 -1
  396. package/dist/constants/transactionsHistoryConfig.cjs +0 -38
  397. package/dist/constants/transactionsHistoryConfig.cjs.map +0 -1
  398. package/dist/constants/transactionsHistoryConfig.d.cts +0 -35
  399. package/dist/constants/transactionsHistoryConfig.d.cts.map +0 -1
  400. package/dist/constants/transactionsHistoryConfig.d.mts +0 -35
  401. package/dist/constants/transactionsHistoryConfig.d.mts.map +0 -1
  402. package/dist/constants/transactionsHistoryConfig.mjs +0 -35
  403. package/dist/constants/transactionsHistoryConfig.mjs.map +0 -1
  404. package/dist/index.cjs +0 -334
  405. package/dist/index.cjs.map +0 -1
  406. package/dist/index.d.cts +0 -95
  407. package/dist/index.d.cts.map +0 -1
  408. package/dist/index.d.mts +0 -95
  409. package/dist/index.d.mts.map +0 -1
  410. package/dist/index.mjs +0 -80
  411. package/dist/index.mjs.map +0 -1
  412. package/dist/perpsErrorCodes.cjs +0 -128
  413. package/dist/perpsErrorCodes.cjs.map +0 -1
  414. package/dist/perpsErrorCodes.d.cts +0 -105
  415. package/dist/perpsErrorCodes.d.cts.map +0 -1
  416. package/dist/perpsErrorCodes.d.mts +0 -105
  417. package/dist/perpsErrorCodes.d.mts.map +0 -1
  418. package/dist/perpsErrorCodes.mjs +0 -125
  419. package/dist/perpsErrorCodes.mjs.map +0 -1
  420. package/dist/providers/AggregatedPerpsProvider.cjs +0 -810
  421. package/dist/providers/AggregatedPerpsProvider.cjs.map +0 -1
  422. package/dist/providers/AggregatedPerpsProvider.d.cts +0 -277
  423. package/dist/providers/AggregatedPerpsProvider.d.cts.map +0 -1
  424. package/dist/providers/AggregatedPerpsProvider.d.mts +0 -277
  425. package/dist/providers/AggregatedPerpsProvider.d.mts.map +0 -1
  426. package/dist/providers/AggregatedPerpsProvider.mjs +0 -805
  427. package/dist/providers/AggregatedPerpsProvider.mjs.map +0 -1
  428. package/dist/providers/HyperLiquidProvider.cjs +0 -10963
  429. package/dist/providers/HyperLiquidProvider.cjs.map +0 -1
  430. package/dist/providers/HyperLiquidProvider.d.cts +0 -656
  431. package/dist/providers/HyperLiquidProvider.d.cts.map +0 -1
  432. package/dist/providers/HyperLiquidProvider.d.mts +0 -656
  433. package/dist/providers/HyperLiquidProvider.d.mts.map +0 -1
  434. package/dist/providers/HyperLiquidProvider.mjs +0 -10959
  435. package/dist/providers/HyperLiquidProvider.mjs.map +0 -1
  436. package/dist/providers/LighterProvider.cjs +0 -6575
  437. package/dist/providers/LighterProvider.cjs.map +0 -1
  438. package/dist/providers/LighterProvider.d.cts +0 -179
  439. package/dist/providers/LighterProvider.d.cts.map +0 -1
  440. package/dist/providers/LighterProvider.d.mts +0 -179
  441. package/dist/providers/LighterProvider.d.mts.map +0 -1
  442. package/dist/providers/LighterProvider.mjs +0 -6571
  443. package/dist/providers/LighterProvider.mjs.map +0 -1
  444. package/dist/routing/ProviderRouter.cjs +0 -154
  445. package/dist/routing/ProviderRouter.cjs.map +0 -1
  446. package/dist/routing/ProviderRouter.d.cts +0 -112
  447. package/dist/routing/ProviderRouter.d.cts.map +0 -1
  448. package/dist/routing/ProviderRouter.d.mts +0 -112
  449. package/dist/routing/ProviderRouter.d.mts.map +0 -1
  450. package/dist/routing/ProviderRouter.mjs +0 -150
  451. package/dist/routing/ProviderRouter.mjs.map +0 -1
  452. package/dist/routing/index.cjs +0 -9
  453. package/dist/routing/index.cjs.map +0 -1
  454. package/dist/routing/index.d.cts +0 -6
  455. package/dist/routing/index.d.cts.map +0 -1
  456. package/dist/routing/index.d.mts +0 -6
  457. package/dist/routing/index.d.mts.map +0 -1
  458. package/dist/routing/index.mjs +0 -5
  459. package/dist/routing/index.mjs.map +0 -1
  460. package/dist/selectors.cjs +0 -264
  461. package/dist/selectors.cjs.map +0 -1
  462. package/dist/selectors.d.cts +0 -336
  463. package/dist/selectors.d.cts.map +0 -1
  464. package/dist/selectors.d.mts +0 -336
  465. package/dist/selectors.d.mts.map +0 -1
  466. package/dist/selectors.mjs +0 -249
  467. package/dist/selectors.mjs.map +0 -1
  468. package/dist/services/AccountService.cjs +0 -324
  469. package/dist/services/AccountService.cjs.map +0 -1
  470. package/dist/services/AccountService.d.cts +0 -56
  471. package/dist/services/AccountService.d.cts.map +0 -1
  472. package/dist/services/AccountService.d.mts +0 -56
  473. package/dist/services/AccountService.d.mts.map +0 -1
  474. package/dist/services/AccountService.mjs +0 -320
  475. package/dist/services/AccountService.mjs.map +0 -1
  476. package/dist/services/AggregatedOrderBookConnection.cjs +0 -405
  477. package/dist/services/AggregatedOrderBookConnection.cjs.map +0 -1
  478. package/dist/services/AggregatedOrderBookConnection.d.cts +0 -106
  479. package/dist/services/AggregatedOrderBookConnection.d.cts.map +0 -1
  480. package/dist/services/AggregatedOrderBookConnection.d.mts +0 -106
  481. package/dist/services/AggregatedOrderBookConnection.d.mts.map +0 -1
  482. package/dist/services/AggregatedOrderBookConnection.mjs +0 -400
  483. package/dist/services/AggregatedOrderBookConnection.mjs.map +0 -1
  484. package/dist/services/DataLakeService.cjs +0 -233
  485. package/dist/services/DataLakeService.cjs.map +0 -1
  486. package/dist/services/DataLakeService.d.cts +0 -51
  487. package/dist/services/DataLakeService.d.cts.map +0 -1
  488. package/dist/services/DataLakeService.d.mts +0 -51
  489. package/dist/services/DataLakeService.d.mts.map +0 -1
  490. package/dist/services/DataLakeService.mjs +0 -229
  491. package/dist/services/DataLakeService.mjs.map +0 -1
  492. package/dist/services/DepositService.cjs +0 -105
  493. package/dist/services/DepositService.cjs.map +0 -1
  494. package/dist/services/DepositService.d.cts +0 -39
  495. package/dist/services/DepositService.d.cts.map +0 -1
  496. package/dist/services/DepositService.d.mts +0 -39
  497. package/dist/services/DepositService.d.mts.map +0 -1
  498. package/dist/services/DepositService.mjs +0 -101
  499. package/dist/services/DepositService.mjs.map +0 -1
  500. package/dist/services/DexDiscoveryCacheManager.cjs +0 -147
  501. package/dist/services/DexDiscoveryCacheManager.cjs.map +0 -1
  502. package/dist/services/DexDiscoveryCacheManager.d.cts +0 -52
  503. package/dist/services/DexDiscoveryCacheManager.d.cts.map +0 -1
  504. package/dist/services/DexDiscoveryCacheManager.d.mts +0 -52
  505. package/dist/services/DexDiscoveryCacheManager.d.mts.map +0 -1
  506. package/dist/services/DexDiscoveryCacheManager.mjs +0 -143
  507. package/dist/services/DexDiscoveryCacheManager.mjs.map +0 -1
  508. package/dist/services/EligibilityService.cjs +0 -78
  509. package/dist/services/EligibilityService.cjs.map +0 -1
  510. package/dist/services/EligibilityService.d.cts +0 -28
  511. package/dist/services/EligibilityService.d.cts.map +0 -1
  512. package/dist/services/EligibilityService.d.mts +0 -28
  513. package/dist/services/EligibilityService.d.mts.map +0 -1
  514. package/dist/services/EligibilityService.mjs +0 -74
  515. package/dist/services/EligibilityService.mjs.map +0 -1
  516. package/dist/services/FeatureFlagConfigurationService.cjs +0 -257
  517. package/dist/services/FeatureFlagConfigurationService.cjs.map +0 -1
  518. package/dist/services/FeatureFlagConfigurationService.d.cts +0 -73
  519. package/dist/services/FeatureFlagConfigurationService.d.cts.map +0 -1
  520. package/dist/services/FeatureFlagConfigurationService.d.mts +0 -73
  521. package/dist/services/FeatureFlagConfigurationService.d.mts.map +0 -1
  522. package/dist/services/FeatureFlagConfigurationService.mjs +0 -253
  523. package/dist/services/FeatureFlagConfigurationService.mjs.map +0 -1
  524. package/dist/services/HyperLiquidClientService.cjs +0 -1114
  525. package/dist/services/HyperLiquidClientService.cjs.map +0 -1
  526. package/dist/services/HyperLiquidClientService.d.cts +0 -252
  527. package/dist/services/HyperLiquidClientService.d.cts.map +0 -1
  528. package/dist/services/HyperLiquidClientService.d.mts +0 -252
  529. package/dist/services/HyperLiquidClientService.d.mts.map +0 -1
  530. package/dist/services/HyperLiquidClientService.mjs +0 -1109
  531. package/dist/services/HyperLiquidClientService.mjs.map +0 -1
  532. package/dist/services/HyperLiquidSubscriptionService.cjs +0 -3594
  533. package/dist/services/HyperLiquidSubscriptionService.cjs.map +0 -1
  534. package/dist/services/HyperLiquidSubscriptionService.d.cts +0 -265
  535. package/dist/services/HyperLiquidSubscriptionService.d.cts.map +0 -1
  536. package/dist/services/HyperLiquidSubscriptionService.d.mts +0 -265
  537. package/dist/services/HyperLiquidSubscriptionService.d.mts.map +0 -1
  538. package/dist/services/HyperLiquidSubscriptionService.mjs +0 -3590
  539. package/dist/services/HyperLiquidSubscriptionService.mjs.map +0 -1
  540. package/dist/services/HyperLiquidWalletService.cjs +0 -186
  541. package/dist/services/HyperLiquidWalletService.cjs.map +0 -1
  542. package/dist/services/HyperLiquidWalletService.d.cts +0 -84
  543. package/dist/services/HyperLiquidWalletService.d.cts.map +0 -1
  544. package/dist/services/HyperLiquidWalletService.d.mts +0 -84
  545. package/dist/services/HyperLiquidWalletService.d.mts.map +0 -1
  546. package/dist/services/HyperLiquidWalletService.mjs +0 -182
  547. package/dist/services/HyperLiquidWalletService.mjs.map +0 -1
  548. package/dist/services/LighterClientService.cjs +0 -643
  549. package/dist/services/LighterClientService.cjs.map +0 -1
  550. package/dist/services/LighterClientService.d.cts +0 -200
  551. package/dist/services/LighterClientService.d.cts.map +0 -1
  552. package/dist/services/LighterClientService.d.mts +0 -200
  553. package/dist/services/LighterClientService.d.mts.map +0 -1
  554. package/dist/services/LighterClientService.mjs +0 -637
  555. package/dist/services/LighterClientService.mjs.map +0 -1
  556. package/dist/services/LighterWalletService.cjs +0 -109
  557. package/dist/services/LighterWalletService.cjs.map +0 -1
  558. package/dist/services/LighterWalletService.d.cts +0 -51
  559. package/dist/services/LighterWalletService.d.cts.map +0 -1
  560. package/dist/services/LighterWalletService.d.mts +0 -51
  561. package/dist/services/LighterWalletService.d.mts.map +0 -1
  562. package/dist/services/LighterWalletService.mjs +0 -105
  563. package/dist/services/LighterWalletService.mjs.map +0 -1
  564. package/dist/services/MarketDataService.cjs +0 -1171
  565. package/dist/services/MarketDataService.cjs.map +0 -1
  566. package/dist/services/MarketDataService.d.cts +0 -350
  567. package/dist/services/MarketDataService.d.cts.map +0 -1
  568. package/dist/services/MarketDataService.d.mts +0 -350
  569. package/dist/services/MarketDataService.d.mts.map +0 -1
  570. package/dist/services/MarketDataService.mjs +0 -1167
  571. package/dist/services/MarketDataService.mjs.map +0 -1
  572. package/dist/services/RewardsIntegrationService.cjs +0 -391
  573. package/dist/services/RewardsIntegrationService.cjs.map +0 -1
  574. package/dist/services/RewardsIntegrationService.d.cts +0 -84
  575. package/dist/services/RewardsIntegrationService.d.cts.map +0 -1
  576. package/dist/services/RewardsIntegrationService.d.mts +0 -84
  577. package/dist/services/RewardsIntegrationService.d.mts.map +0 -1
  578. package/dist/services/RewardsIntegrationService.mjs +0 -387
  579. package/dist/services/RewardsIntegrationService.mjs.map +0 -1
  580. package/dist/services/ServiceContext.cjs +0 -3
  581. package/dist/services/ServiceContext.cjs.map +0 -1
  582. package/dist/services/ServiceContext.d.cts +0 -102
  583. package/dist/services/ServiceContext.d.cts.map +0 -1
  584. package/dist/services/ServiceContext.d.mts +0 -102
  585. package/dist/services/ServiceContext.d.mts.map +0 -1
  586. package/dist/services/ServiceContext.mjs +0 -2
  587. package/dist/services/ServiceContext.mjs.map +0 -1
  588. package/dist/services/TerminalMarketService.cjs +0 -623
  589. package/dist/services/TerminalMarketService.cjs.map +0 -1
  590. package/dist/services/TerminalMarketService.d.cts +0 -45
  591. package/dist/services/TerminalMarketService.d.cts.map +0 -1
  592. package/dist/services/TerminalMarketService.d.mts +0 -45
  593. package/dist/services/TerminalMarketService.d.mts.map +0 -1
  594. package/dist/services/TerminalMarketService.mjs +0 -619
  595. package/dist/services/TerminalMarketService.mjs.map +0 -1
  596. package/dist/services/TradingReadinessCache.cjs +0 -329
  597. package/dist/services/TradingReadinessCache.cjs.map +0 -1
  598. package/dist/services/TradingReadinessCache.d.cts +0 -204
  599. package/dist/services/TradingReadinessCache.d.cts.map +0 -1
  600. package/dist/services/TradingReadinessCache.d.mts +0 -204
  601. package/dist/services/TradingReadinessCache.d.mts.map +0 -1
  602. package/dist/services/TradingReadinessCache.mjs +0 -326
  603. package/dist/services/TradingReadinessCache.mjs.map +0 -1
  604. package/dist/services/TradingService.cjs +0 -1895
  605. package/dist/services/TradingService.cjs.map +0 -1
  606. package/dist/services/TradingService.d.cts +0 -201
  607. package/dist/services/TradingService.d.cts.map +0 -1
  608. package/dist/services/TradingService.d.mts +0 -201
  609. package/dist/services/TradingService.d.mts.map +0 -1
  610. package/dist/services/TradingService.mjs +0 -1891
  611. package/dist/services/TradingService.mjs.map +0 -1
  612. package/dist/types/config.cjs +0 -3
  613. package/dist/types/config.cjs.map +0 -1
  614. package/dist/types/config.d.cts +0 -49
  615. package/dist/types/config.d.cts.map +0 -1
  616. package/dist/types/config.d.mts +0 -49
  617. package/dist/types/config.d.mts.map +0 -1
  618. package/dist/types/config.mjs +0 -2
  619. package/dist/types/config.mjs.map +0 -1
  620. package/dist/types/hyperliquid-types.cjs +0 -45
  621. package/dist/types/hyperliquid-types.cjs.map +0 -1
  622. package/dist/types/hyperliquid-types.d.cts +0 -67
  623. package/dist/types/hyperliquid-types.d.cts.map +0 -1
  624. package/dist/types/hyperliquid-types.d.mts +0 -67
  625. package/dist/types/hyperliquid-types.d.mts.map +0 -1
  626. package/dist/types/hyperliquid-types.mjs +0 -41
  627. package/dist/types/hyperliquid-types.mjs.map +0 -1
  628. package/dist/types/index.cjs +0 -151
  629. package/dist/types/index.cjs.map +0 -1
  630. package/dist/types/index.d.cts +0 -2183
  631. package/dist/types/index.d.cts.map +0 -1
  632. package/dist/types/index.d.mts +0 -2183
  633. package/dist/types/index.d.mts.map +0 -1
  634. package/dist/types/index.mjs +0 -133
  635. package/dist/types/index.mjs.map +0 -1
  636. package/dist/types/lighter-types.cjs +0 -11
  637. package/dist/types/lighter-types.cjs.map +0 -1
  638. package/dist/types/lighter-types.d.cts +0 -763
  639. package/dist/types/lighter-types.d.cts.map +0 -1
  640. package/dist/types/lighter-types.d.mts +0 -763
  641. package/dist/types/lighter-types.d.mts.map +0 -1
  642. package/dist/types/lighter-types.mjs +0 -10
  643. package/dist/types/lighter-types.mjs.map +0 -1
  644. package/dist/types/messenger.cjs +0 -3
  645. package/dist/types/messenger.cjs.map +0 -1
  646. package/dist/types/messenger.d.cts +0 -30
  647. package/dist/types/messenger.d.cts.map +0 -1
  648. package/dist/types/messenger.d.mts +0 -30
  649. package/dist/types/messenger.d.mts.map +0 -1
  650. package/dist/types/messenger.mjs +0 -2
  651. package/dist/types/messenger.mjs.map +0 -1
  652. package/dist/types/perps-types.cjs +0 -7
  653. package/dist/types/perps-types.cjs.map +0 -1
  654. package/dist/types/perps-types.d.cts +0 -184
  655. package/dist/types/perps-types.d.cts.map +0 -1
  656. package/dist/types/perps-types.d.mts +0 -184
  657. package/dist/types/perps-types.d.mts.map +0 -1
  658. package/dist/types/perps-types.mjs +0 -5
  659. package/dist/types/perps-types.mjs.map +0 -1
  660. package/dist/types/token.cjs +0 -3
  661. package/dist/types/token.cjs.map +0 -1
  662. package/dist/types/token.d.cts +0 -25
  663. package/dist/types/token.d.cts.map +0 -1
  664. package/dist/types/token.d.mts +0 -25
  665. package/dist/types/token.d.mts.map +0 -1
  666. package/dist/types/token.mjs +0 -2
  667. package/dist/types/token.mjs.map +0 -1
  668. package/dist/types/transactionTypes.cjs +0 -29
  669. package/dist/types/transactionTypes.cjs.map +0 -1
  670. package/dist/types/transactionTypes.d.cts +0 -60
  671. package/dist/types/transactionTypes.d.cts.map +0 -1
  672. package/dist/types/transactionTypes.d.mts +0 -60
  673. package/dist/types/transactionTypes.d.mts.map +0 -1
  674. package/dist/types/transactionTypes.mjs +0 -24
  675. package/dist/types/transactionTypes.mjs.map +0 -1
  676. package/dist/utils/accountUtils.cjs +0 -236
  677. package/dist/utils/accountUtils.cjs.map +0 -1
  678. package/dist/utils/accountUtils.d.cts +0 -72
  679. package/dist/utils/accountUtils.d.cts.map +0 -1
  680. package/dist/utils/accountUtils.d.mts +0 -72
  681. package/dist/utils/accountUtils.d.mts.map +0 -1
  682. package/dist/utils/accountUtils.mjs +0 -223
  683. package/dist/utils/accountUtils.mjs.map +0 -1
  684. package/dist/utils/capabilitySymbols.cjs +0 -25
  685. package/dist/utils/capabilitySymbols.cjs.map +0 -1
  686. package/dist/utils/capabilitySymbols.d.cts +0 -15
  687. package/dist/utils/capabilitySymbols.d.cts.map +0 -1
  688. package/dist/utils/capabilitySymbols.d.mts +0 -15
  689. package/dist/utils/capabilitySymbols.d.mts.map +0 -1
  690. package/dist/utils/capabilitySymbols.mjs +0 -21
  691. package/dist/utils/capabilitySymbols.mjs.map +0 -1
  692. package/dist/utils/coalescePerpsRestRequest.cjs +0 -71
  693. package/dist/utils/coalescePerpsRestRequest.cjs.map +0 -1
  694. package/dist/utils/coalescePerpsRestRequest.d.cts +0 -32
  695. package/dist/utils/coalescePerpsRestRequest.d.cts.map +0 -1
  696. package/dist/utils/coalescePerpsRestRequest.d.mts +0 -32
  697. package/dist/utils/coalescePerpsRestRequest.d.mts.map +0 -1
  698. package/dist/utils/coalescePerpsRestRequest.mjs +0 -66
  699. package/dist/utils/coalescePerpsRestRequest.mjs.map +0 -1
  700. package/dist/utils/errorUtils.cjs +0 -104
  701. package/dist/utils/errorUtils.cjs.map +0 -1
  702. package/dist/utils/errorUtils.d.cts +0 -50
  703. package/dist/utils/errorUtils.d.cts.map +0 -1
  704. package/dist/utils/errorUtils.d.mts +0 -50
  705. package/dist/utils/errorUtils.d.mts.map +0 -1
  706. package/dist/utils/errorUtils.mjs +0 -96
  707. package/dist/utils/errorUtils.mjs.map +0 -1
  708. package/dist/utils/hyperLiquidAbstraction.cjs +0 -23
  709. package/dist/utils/hyperLiquidAbstraction.cjs.map +0 -1
  710. package/dist/utils/hyperLiquidAbstraction.d.cts +0 -11
  711. package/dist/utils/hyperLiquidAbstraction.d.cts.map +0 -1
  712. package/dist/utils/hyperLiquidAbstraction.d.mts +0 -11
  713. package/dist/utils/hyperLiquidAbstraction.d.mts.map +0 -1
  714. package/dist/utils/hyperLiquidAbstraction.mjs +0 -19
  715. package/dist/utils/hyperLiquidAbstraction.mjs.map +0 -1
  716. package/dist/utils/hyperLiquidAdapter.cjs +0 -512
  717. package/dist/utils/hyperLiquidAdapter.cjs.map +0 -1
  718. package/dist/utils/hyperLiquidAdapter.d.cts +0 -77
  719. package/dist/utils/hyperLiquidAdapter.d.cts.map +0 -1
  720. package/dist/utils/hyperLiquidAdapter.d.mts +0 -77
  721. package/dist/utils/hyperLiquidAdapter.d.mts.map +0 -1
  722. package/dist/utils/hyperLiquidAdapter.mjs +0 -494
  723. package/dist/utils/hyperLiquidAdapter.mjs.map +0 -1
  724. package/dist/utils/hyperLiquidOrderBookProcessor.cjs +0 -83
  725. package/dist/utils/hyperLiquidOrderBookProcessor.cjs.map +0 -1
  726. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts +0 -55
  727. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts.map +0 -1
  728. package/dist/utils/hyperLiquidOrderBookProcessor.d.mts +0 -55
  729. package/dist/utils/hyperLiquidOrderBookProcessor.d.mts.map +0 -1
  730. package/dist/utils/hyperLiquidOrderBookProcessor.mjs +0 -78
  731. package/dist/utils/hyperLiquidOrderBookProcessor.mjs.map +0 -1
  732. package/dist/utils/hyperLiquidPositionPreview.cjs +0 -355
  733. package/dist/utils/hyperLiquidPositionPreview.cjs.map +0 -1
  734. package/dist/utils/hyperLiquidPositionPreview.d.cts +0 -124
  735. package/dist/utils/hyperLiquidPositionPreview.d.cts.map +0 -1
  736. package/dist/utils/hyperLiquidPositionPreview.d.mts +0 -124
  737. package/dist/utils/hyperLiquidPositionPreview.d.mts.map +0 -1
  738. package/dist/utils/hyperLiquidPositionPreview.mjs +0 -347
  739. package/dist/utils/hyperLiquidPositionPreview.mjs.map +0 -1
  740. package/dist/utils/hyperLiquidValidation.cjs +0 -799
  741. package/dist/utils/hyperLiquidValidation.cjs.map +0 -1
  742. package/dist/utils/hyperLiquidValidation.d.cts +0 -192
  743. package/dist/utils/hyperLiquidValidation.d.cts.map +0 -1
  744. package/dist/utils/hyperLiquidValidation.d.mts +0 -192
  745. package/dist/utils/hyperLiquidValidation.d.mts.map +0 -1
  746. package/dist/utils/hyperLiquidValidation.mjs +0 -786
  747. package/dist/utils/hyperLiquidValidation.mjs.map +0 -1
  748. package/dist/utils/idUtils.cjs +0 -18
  749. package/dist/utils/idUtils.cjs.map +0 -1
  750. package/dist/utils/idUtils.d.cts +0 -6
  751. package/dist/utils/idUtils.d.cts.map +0 -1
  752. package/dist/utils/idUtils.d.mts +0 -6
  753. package/dist/utils/idUtils.d.mts.map +0 -1
  754. package/dist/utils/idUtils.mjs +0 -10
  755. package/dist/utils/idUtils.mjs.map +0 -1
  756. package/dist/utils/index.cjs +0 -66
  757. package/dist/utils/index.cjs.map +0 -1
  758. package/dist/utils/index.d.cts +0 -29
  759. package/dist/utils/index.d.cts.map +0 -1
  760. package/dist/utils/index.d.mts +0 -29
  761. package/dist/utils/index.d.mts.map +0 -1
  762. package/dist/utils/index.mjs +0 -34
  763. package/dist/utils/index.mjs.map +0 -1
  764. package/dist/utils/lighterAdapter.cjs +0 -575
  765. package/dist/utils/lighterAdapter.cjs.map +0 -1
  766. package/dist/utils/lighterAdapter.d.cts +0 -117
  767. package/dist/utils/lighterAdapter.d.cts.map +0 -1
  768. package/dist/utils/lighterAdapter.d.mts +0 -117
  769. package/dist/utils/lighterAdapter.d.mts.map +0 -1
  770. package/dist/utils/lighterAdapter.mjs +0 -562
  771. package/dist/utils/lighterAdapter.mjs.map +0 -1
  772. package/dist/utils/marketDataTransform.cjs +0 -250
  773. package/dist/utils/marketDataTransform.cjs.map +0 -1
  774. package/dist/utils/marketDataTransform.d.cts +0 -71
  775. package/dist/utils/marketDataTransform.d.cts.map +0 -1
  776. package/dist/utils/marketDataTransform.d.mts +0 -71
  777. package/dist/utils/marketDataTransform.d.mts.map +0 -1
  778. package/dist/utils/marketDataTransform.mjs +0 -243
  779. package/dist/utils/marketDataTransform.mjs.map +0 -1
  780. package/dist/utils/marketSearch.cjs +0 -111
  781. package/dist/utils/marketSearch.cjs.map +0 -1
  782. package/dist/utils/marketSearch.d.cts +0 -48
  783. package/dist/utils/marketSearch.d.cts.map +0 -1
  784. package/dist/utils/marketSearch.d.mts +0 -48
  785. package/dist/utils/marketSearch.d.mts.map +0 -1
  786. package/dist/utils/marketSearch.mjs +0 -106
  787. package/dist/utils/marketSearch.mjs.map +0 -1
  788. package/dist/utils/marketUtils.cjs +0 -266
  789. package/dist/utils/marketUtils.cjs.map +0 -1
  790. package/dist/utils/marketUtils.d.cts +0 -73
  791. package/dist/utils/marketUtils.d.cts.map +0 -1
  792. package/dist/utils/marketUtils.d.mts +0 -73
  793. package/dist/utils/marketUtils.d.mts.map +0 -1
  794. package/dist/utils/marketUtils.mjs +0 -248
  795. package/dist/utils/marketUtils.mjs.map +0 -1
  796. package/dist/utils/orderCalculations.cjs +0 -849
  797. package/dist/utils/orderCalculations.cjs.map +0 -1
  798. package/dist/utils/orderCalculations.d.cts +0 -306
  799. package/dist/utils/orderCalculations.d.cts.map +0 -1
  800. package/dist/utils/orderCalculations.d.mts +0 -306
  801. package/dist/utils/orderCalculations.d.mts.map +0 -1
  802. package/dist/utils/orderCalculations.mjs +0 -833
  803. package/dist/utils/orderCalculations.mjs.map +0 -1
  804. package/dist/utils/orderTypes.cjs +0 -301
  805. package/dist/utils/orderTypes.cjs.map +0 -1
  806. package/dist/utils/orderTypes.d.cts +0 -166
  807. package/dist/utils/orderTypes.d.cts.map +0 -1
  808. package/dist/utils/orderTypes.d.mts +0 -166
  809. package/dist/utils/orderTypes.d.mts.map +0 -1
  810. package/dist/utils/orderTypes.mjs +0 -287
  811. package/dist/utils/orderTypes.mjs.map +0 -1
  812. package/dist/utils/perpsConnectionAttemptContext.cjs +0 -20
  813. package/dist/utils/perpsConnectionAttemptContext.cjs.map +0 -1
  814. package/dist/utils/perpsConnectionAttemptContext.d.cts +0 -7
  815. package/dist/utils/perpsConnectionAttemptContext.d.cts.map +0 -1
  816. package/dist/utils/perpsConnectionAttemptContext.d.mts +0 -7
  817. package/dist/utils/perpsConnectionAttemptContext.d.mts.map +0 -1
  818. package/dist/utils/perpsConnectionAttemptContext.mjs +0 -15
  819. package/dist/utils/perpsConnectionAttemptContext.mjs.map +0 -1
  820. package/dist/utils/perpsDiskPersistence.cjs +0 -259
  821. package/dist/utils/perpsDiskPersistence.cjs.map +0 -1
  822. package/dist/utils/perpsDiskPersistence.d.cts +0 -112
  823. package/dist/utils/perpsDiskPersistence.d.cts.map +0 -1
  824. package/dist/utils/perpsDiskPersistence.d.mts +0 -112
  825. package/dist/utils/perpsDiskPersistence.d.mts.map +0 -1
  826. package/dist/utils/perpsDiskPersistence.mjs +0 -251
  827. package/dist/utils/perpsDiskPersistence.mjs.map +0 -1
  828. package/dist/utils/perpsFormatters.cjs +0 -509
  829. package/dist/utils/perpsFormatters.cjs.map +0 -1
  830. package/dist/utils/perpsFormatters.d.cts +0 -204
  831. package/dist/utils/perpsFormatters.d.cts.map +0 -1
  832. package/dist/utils/perpsFormatters.d.mts +0 -204
  833. package/dist/utils/perpsFormatters.d.mts.map +0 -1
  834. package/dist/utils/perpsFormatters.mjs +0 -500
  835. package/dist/utils/perpsFormatters.mjs.map +0 -1
  836. package/dist/utils/rewardsUtils.cjs +0 -98
  837. package/dist/utils/rewardsUtils.cjs.map +0 -1
  838. package/dist/utils/rewardsUtils.d.cts +0 -33
  839. package/dist/utils/rewardsUtils.d.cts.map +0 -1
  840. package/dist/utils/rewardsUtils.d.mts +0 -33
  841. package/dist/utils/rewardsUtils.d.mts.map +0 -1
  842. package/dist/utils/rewardsUtils.mjs +0 -92
  843. package/dist/utils/rewardsUtils.mjs.map +0 -1
  844. package/dist/utils/significantFigures.cjs +0 -88
  845. package/dist/utils/significantFigures.cjs.map +0 -1
  846. package/dist/utils/significantFigures.d.cts +0 -25
  847. package/dist/utils/significantFigures.d.cts.map +0 -1
  848. package/dist/utils/significantFigures.d.mts +0 -25
  849. package/dist/utils/significantFigures.d.mts.map +0 -1
  850. package/dist/utils/significantFigures.mjs +0 -82
  851. package/dist/utils/significantFigures.mjs.map +0 -1
  852. package/dist/utils/sortMarkets.cjs +0 -93
  853. package/dist/utils/sortMarkets.cjs.map +0 -1
  854. package/dist/utils/sortMarkets.d.cts +0 -25
  855. package/dist/utils/sortMarkets.d.cts.map +0 -1
  856. package/dist/utils/sortMarkets.d.mts +0 -25
  857. package/dist/utils/sortMarkets.d.mts.map +0 -1
  858. package/dist/utils/sortMarkets.mjs +0 -88
  859. package/dist/utils/sortMarkets.mjs.map +0 -1
  860. package/dist/utils/standaloneInfoClient.cjs +0 -70
  861. package/dist/utils/standaloneInfoClient.cjs.map +0 -1
  862. package/dist/utils/standaloneInfoClient.d.cts +0 -37
  863. package/dist/utils/standaloneInfoClient.d.cts.map +0 -1
  864. package/dist/utils/standaloneInfoClient.d.mts +0 -37
  865. package/dist/utils/standaloneInfoClient.d.mts.map +0 -1
  866. package/dist/utils/standaloneInfoClient.mjs +0 -64
  867. package/dist/utils/standaloneInfoClient.mjs.map +0 -1
  868. package/dist/utils/stringParseUtils.cjs +0 -34
  869. package/dist/utils/stringParseUtils.cjs.map +0 -1
  870. package/dist/utils/stringParseUtils.d.cts +0 -11
  871. package/dist/utils/stringParseUtils.d.cts.map +0 -1
  872. package/dist/utils/stringParseUtils.d.mts +0 -11
  873. package/dist/utils/stringParseUtils.d.mts.map +0 -1
  874. package/dist/utils/stringParseUtils.mjs +0 -28
  875. package/dist/utils/stringParseUtils.mjs.map +0 -1
  876. package/dist/utils/transferData.cjs +0 -33
  877. package/dist/utils/transferData.cjs.map +0 -1
  878. package/dist/utils/transferData.d.cts +0 -9
  879. package/dist/utils/transferData.d.cts.map +0 -1
  880. package/dist/utils/transferData.d.mts +0 -9
  881. package/dist/utils/transferData.d.mts.map +0 -1
  882. package/dist/utils/transferData.mjs +0 -29
  883. package/dist/utils/transferData.mjs.map +0 -1
  884. package/dist/utils/wait.cjs +0 -6
  885. package/dist/utils/wait.cjs.map +0 -1
  886. package/dist/utils/wait.d.cts +0 -2
  887. package/dist/utils/wait.d.cts.map +0 -1
  888. package/dist/utils/wait.d.mts +0 -2
  889. package/dist/utils/wait.d.mts.map +0 -1
  890. package/dist/utils/wait.mjs +0 -2
  891. package/dist/utils/wait.mjs.map +0 -1
@@ -0,0 +1,2192 @@
1
+ import type { CaipAccountId, CaipChainId, CaipAssetId, Hex } from '@metamask/utils';
2
+ import type { CandlePeriod, TimeDuration } from '../constants/chartConfig.js';
3
+ import type { CHASE_ORDER_STATUS } from '../constants/perpsConfig.js';
4
+ import type { LighterSignerBridge } from './lighter-types.js';
5
+ import type { CandleData, OrderType, StrategyOrderType, TpslLinkage, TriggerDirection, TriggerOrderType } from './perps-types.js';
6
+ /**
7
+ * Connection states for WebSocket management.
8
+ * Defined inline to avoid importing from Mobile-only services.
9
+ * Must stay in sync with HyperLiquidClientService.WebSocketConnectionState.
10
+ */
11
+ export declare enum WebSocketConnectionState {
12
+ Disconnected = "disconnected",
13
+ Connecting = "connecting",
14
+ Connected = "connected",
15
+ Disconnecting = "disconnecting"
16
+ }
17
+ /** Provider-agnostic raw ledger update. Fields match the common shape across providers. */
18
+ export type RawLedgerUpdate = {
19
+ hash: string;
20
+ time: number;
21
+ delta: {
22
+ type: string;
23
+ usdc?: string;
24
+ coin?: string;
25
+ };
26
+ };
27
+ export type UserHistoryItem = {
28
+ id: string;
29
+ timestamp: number;
30
+ type: 'deposit' | 'withdrawal';
31
+ amount: string;
32
+ asset: string;
33
+ txHash: string;
34
+ status: 'completed' | 'failed' | 'pending';
35
+ details: {
36
+ source: string;
37
+ bridgeContract?: string;
38
+ recipient?: string;
39
+ blockNumber?: string;
40
+ chainId?: string;
41
+ synthetic?: boolean;
42
+ };
43
+ };
44
+ export type GetUserHistoryParams = {
45
+ startTime?: number;
46
+ endTime?: number;
47
+ accountId?: CaipAccountId;
48
+ };
49
+ export type TradeConfiguration = {
50
+ leverage?: number;
51
+ pendingConfig?: {
52
+ amount?: string;
53
+ leverage?: number;
54
+ takeProfitPrice?: string;
55
+ stopLossPrice?: string;
56
+ limitPrice?: string;
57
+ orderType?: OrderType;
58
+ reduceOnly?: boolean;
59
+ timestamp: number;
60
+ };
61
+ };
62
+ export declare enum MarketCategory {
63
+ CryptoCurrency = "crypto",
64
+ Stock = "stock",
65
+ PreIpo = "pre-ipo",
66
+ Index = "index",
67
+ Etf = "etf",
68
+ Commodity = "commodity",
69
+ Forex = "forex"
70
+ }
71
+ export type MarketType = `${MarketCategory}`;
72
+ /**
73
+ * Metadata extracted from Terminal API for a single asset.
74
+ * Used downstream to enrich PerpsMarketData with name, keywords, tags, etc.
75
+ */
76
+ export type TerminalAssetMetadata = {
77
+ name?: string;
78
+ description?: string;
79
+ keywords?: string[];
80
+ tags?: string[];
81
+ categories?: string[];
82
+ marketType?: MarketType;
83
+ /**
84
+ * Epoch ms when this market was listed on the Terminal backend.
85
+ * Normalized from the raw API value (number or ISO string).
86
+ */
87
+ listedAt?: number;
88
+ };
89
+ export type MarketTypeFilter = 'all' | 'crypto' | 'stock' | 'pre-ipo' | 'index' | 'etf' | 'commodity' | 'forex' | 'new';
90
+ /**
91
+ * Ordered list of the 7 data-model market categories for UI pills.
92
+ * Does not include the 'all' or 'new' sentinel values — those are applied
93
+ * via dedicated UI controls, not the category pills.
94
+ * Kept in sync with {@link MarketTypeFilter} via `satisfies`.
95
+ */
96
+ export declare const MARKET_CATEGORIES: ["crypto", "stock", "pre-ipo", "index", "etf", "commodity", "forex"];
97
+ export type InputMethod = 'default' | 'slider' | 'keypad' | 'percentage' | 'max';
98
+ export type TradeAction = 'create_position' | 'increase_exposure' | 'flip_long_to_short' | 'flip_short_to_long';
99
+ export type TrackingData = {
100
+ totalFee: number;
101
+ marketPrice: number;
102
+ metamaskFee?: number;
103
+ metamaskFeeRate?: number;
104
+ feeDiscountPercentage?: number;
105
+ estimatedPoints?: number;
106
+ marginUsed?: number;
107
+ inputMethod?: InputMethod;
108
+ tradeAction?: TradeAction;
109
+ receivedAmount?: number;
110
+ realizedPnl?: number;
111
+ source?: string;
112
+ chartLibrary?: string;
113
+ entryPoint?: string;
114
+ discoverySource?: string;
115
+ perpDiscoverySource?: string;
116
+ hlFeeRate?: number;
117
+ tradeWithToken?: boolean;
118
+ mmPayTokenSelected?: string;
119
+ mmPayNetworkSelected?: string;
120
+ vipTier?: number;
121
+ vipDiscount?: number;
122
+ abTests?: Record<string, string>;
123
+ };
124
+ export type TPSLTrackingData = {
125
+ direction: 'long' | 'short';
126
+ /**
127
+ * @deprecated Source of the TP/SL update (e.g., 'tp_sl_view', 'position_card').
128
+ * Prefer `entryPoint` / `discoverySource` / `perpDiscoverySource` for risk-event
129
+ * attribution; `source` is retained for backward compatibility.
130
+ */
131
+ source: string;
132
+ positionSize: number;
133
+ takeProfitPercentage?: number;
134
+ stopLossPercentage?: number;
135
+ isEditingExistingPosition?: boolean;
136
+ entryPrice?: number;
137
+ entryPoint?: string;
138
+ discoverySource?: string;
139
+ perpDiscoverySource?: string;
140
+ };
141
+ /** Collateral mode requested for a new order. */
142
+ export type MarginMode = 'isolated' | 'cross';
143
+ export type OrderParams = {
144
+ symbol: string;
145
+ isBuy: boolean;
146
+ size: string;
147
+ orderType: OrderType;
148
+ price?: string;
149
+ reduceOnly?: boolean;
150
+ isFullClose?: boolean;
151
+ timeInForce?: 'GTC' | 'IOC' | 'ALO';
152
+ usdAmount?: string;
153
+ priceAtCalculation?: number;
154
+ maxSlippageBps?: number;
155
+ /**
156
+ * @deprecated Use `maxSlippageBps` instead. Retained for one release so that
157
+ * existing publisher consumers (extension, core) that still pass slippage as
158
+ * a decimal (e.g. 0.03 for 3%) continue to work; the provider normalizes the
159
+ * value to basis points when `maxSlippageBps` is absent.
160
+ */
161
+ slippage?: number;
162
+ triggerPrice?: string;
163
+ twapDuration?: number;
164
+ twapRandomize?: boolean;
165
+ scaleMinPrice?: string;
166
+ scaleMaxPrice?: string;
167
+ scaleNumOrders?: number;
168
+ /**
169
+ * How the ladder's size is weighted across its rungs. Rung weights ramp
170
+ * linearly from 1 at `scaleMinPrice` to this value at `scaleMaxPrice`, in that
171
+ * direction for both sides — a short does not flip it. Above 1 puts more size
172
+ * at `scaleMaxPrice`, below 1 at `scaleMinPrice`. Omitted or exactly 1 spreads
173
+ * the size evenly. Any finite value above 0 is accepted as given; see
174
+ * `splitScaleSizes` for how the sizes are allocated.
175
+ */
176
+ scaleSkew?: number;
177
+ chaseIntervalMs?: number;
178
+ chaseMaxDurationMs?: number;
179
+ chaseMaxRepricings?: number;
180
+ chaseMaxDistanceBps?: number;
181
+ takeProfitPrice?: string;
182
+ stopLossPrice?: string;
183
+ takeProfitSize?: string;
184
+ stopLossSize?: string;
185
+ clientOrderId?: string;
186
+ /**
187
+ * How an attached TP/SL is linked: to this order (`order`), to the resulting
188
+ * position (`position`), or absent (`none`). Defaults to `none` without TP/SL
189
+ * and `order` with TP/SL. Takes precedence over the deprecated `grouping`.
190
+ */
191
+ tpslLinkage?: TpslLinkage;
192
+ /**
193
+ * @deprecated Use `tpslLinkage`. This field carries HyperLiquid's own grouping
194
+ * vocabulary; it is honoured for existing callers but a provider-agnostic
195
+ * placement should not depend on protocol wording.
196
+ */
197
+ grouping?: 'na' | 'normalTpsl' | 'positionTpsl';
198
+ currentPrice?: number;
199
+ leverage?: number;
200
+ /**
201
+ * Explicit collateral mode. Requires leverage. HyperLiquid validates market
202
+ * support and refuses mode changes with an open position or resting order.
203
+ * Omit to retain the existing isolated-leverage behavior.
204
+ */
205
+ marginMode?: MarginMode;
206
+ existingPositionLeverage?: number;
207
+ trackingData?: TrackingData;
208
+ providerId?: PerpsProviderType;
209
+ };
210
+ export type ScaleOrderChild = {
211
+ state: 'resting' | 'filled';
212
+ orderId: string;
213
+ } | {
214
+ state: 'waitingForFill' | 'waitingForTrigger';
215
+ orderId?: never;
216
+ };
217
+ export type OrderResult = {
218
+ success?: boolean;
219
+ /**
220
+ * What names the placement afterwards.
221
+ *
222
+ * For an ordinary placement this is the exchange's order ID. For a *strategy*
223
+ * placement it is a handle instead — a venue TWAP id, or a client-generated
224
+ * scale-group or chase-session id — which is what `CancelOrderParams` takes
225
+ * together with the matching `orderType` and `providerId`. Scale and chase
226
+ * handles are held in the provider session that created them. Scale handles
227
+ * are also encoded in each rung's venue client-order ID, so an open-order
228
+ * read can recover the group after reconnect. Chase handles cannot be
229
+ * recovered because every replacement receives a new exchange order ID.
230
+ * The individual exchange IDs a strategy expanded into are in
231
+ * `childOrderIds`.
232
+ */
233
+ orderId?: string;
234
+ error?: string;
235
+ filledSize?: string;
236
+ submittedSize?: string;
237
+ acceptedSize?: string;
238
+ averagePrice?: string;
239
+ weightedAverageLimitPrice?: string;
240
+ acceptedChildren?: ScaleOrderChild[];
241
+ childOrderIds?: string[];
242
+ providerId?: PerpsProviderType;
243
+ /**
244
+ * Structured record of venue state that was ALREADY committed before the
245
+ * placement failed — e.g. a leverage change that landed before the order
246
+ * was rejected. Present only on failure results where such state exists;
247
+ * callers must not treat the failure as "nothing happened".
248
+ */
249
+ partialState?: {
250
+ /** Leverage (in x) the venue already applied for this symbol. */
251
+ leverageUpdated?: number;
252
+ };
253
+ };
254
+ /**
255
+ * A TP/SL protection change that could not be safely completed
256
+ * automatically and requires an explicit new protection intent from the
257
+ * user. Surfaced by providers with durable settlement state (Lighter).
258
+ */
259
+ export type PerpsPendingManualRecovery = {
260
+ symbol: string;
261
+ /** Durable identity (address:accountIndex:apiKey:symbol). */
262
+ settlementKey: string;
263
+ recordedAt: number;
264
+ /** Human-readable cause of the parked state. */
265
+ reason: string;
266
+ /** Whether the interrupted operation replaced or removed protection. */
267
+ priorIntent: 'replace' | 'remove';
268
+ /** Venue order ids still on the books when the state was parked. */
269
+ survivingOrderIds: string[];
270
+ /** What the user should do to resolve the state. */
271
+ actionNeeded: string;
272
+ };
273
+ /**
274
+ * A previously ambiguous dispatch whose outcome was later resolved.
275
+ * Writes stay blocked until each outcome is explicitly acknowledged via
276
+ * `acknowledgeRecoveredDispatch` (after the caller refreshes venue
277
+ * state) — except `failed`, which is retry-safe and non-blocking.
278
+ */
279
+ export type PerpsRecoveredDispatch = {
280
+ /** Stable id for selective acknowledgment. */
281
+ recoveryId: string;
282
+ /** Venue transaction type of the dispatch. */
283
+ kind: number;
284
+ /** Human-readable operation intent. */
285
+ intent: string;
286
+ txHash: string | null;
287
+ outcome: 'succeeded' | 'failed' | 'unknown';
288
+ /** How the outcome was determined (e.g. `tx-status:2`, `rest-advance`). */
289
+ evidence: string;
290
+ };
291
+ export type ChaseOrderStatus = (typeof CHASE_ORDER_STATUS)[keyof typeof CHASE_ORDER_STATUS];
292
+ export type TwapOrderStatus = 'active' | 'completed' | 'completed_underfilled' | 'canceled' | 'failed';
293
+ export type TwapOrderFill = {
294
+ fillId: string;
295
+ orderId: string;
296
+ side: 'buy' | 'sell';
297
+ price: string;
298
+ size: string;
299
+ fee: string;
300
+ feeToken: string;
301
+ builderFee?: string;
302
+ timestamp: number;
303
+ transactionHash: string;
304
+ };
305
+ /** Current and terminal state of one venue-native TWAP schedule. */
306
+ export type TwapOrder = {
307
+ orderId: string;
308
+ symbol: string;
309
+ side: 'buy' | 'sell';
310
+ size: string;
311
+ executedSize: string;
312
+ remainingSize: string;
313
+ executedNotional: string;
314
+ averagePrice?: string;
315
+ fillProgressBps: number;
316
+ timeProgressBps: number;
317
+ elapsedTimeMilliseconds: number;
318
+ durationMinutes: number;
319
+ randomize: boolean;
320
+ reduceOnly: boolean;
321
+ status: TwapOrderStatus;
322
+ startedAt: number;
323
+ lastUpdated: number;
324
+ error?: string;
325
+ fills: TwapOrderFill[];
326
+ providerId?: PerpsProviderType;
327
+ };
328
+ /**
329
+ * Client-visible state of one emulated Chase placement.
330
+ *
331
+ * The handle remains stable while the exchange child ID and resting price can
332
+ * change on every reprice. Terminal sessions are retained until provider
333
+ * teardown so clients can observe why chasing stopped and then reconcile the
334
+ * surviving child through the ordinary orders stream.
335
+ */
336
+ export type ChaseOrder = {
337
+ handle: string;
338
+ symbol: string;
339
+ side: 'buy' | 'sell';
340
+ originalSize: string;
341
+ remainingSize: string;
342
+ arrivalPrice: string;
343
+ restingPrice: string;
344
+ restingOrderId: string | null;
345
+ /** Adverse distance of the resting child from arrival, rounded to whole bps. */
346
+ distanceChasedBps: number;
347
+ /**
348
+ * Optional adverse-touch stop, strictly between 0 and 10,000 bps.
349
+ * The resting child may sit just inside this boundary after price-grid rounding.
350
+ */
351
+ maxDistanceBps?: number;
352
+ repricings: number;
353
+ startedAt: number;
354
+ status: ChaseOrderStatus;
355
+ providerId?: PerpsProviderType;
356
+ };
357
+ /** Lifecycle signal emitted when a Chase reaches its configured distance. */
358
+ export type ChaseOrderMaxDistanceReached = {
359
+ handle: string;
360
+ symbol: string;
361
+ side: 'buy' | 'sell';
362
+ restingOrderId: string | null;
363
+ restingPrice: string;
364
+ maxDistanceBps: number;
365
+ timestamp: number;
366
+ providerId: PerpsProviderType;
367
+ };
368
+ export type Position = {
369
+ symbol: string;
370
+ size: string;
371
+ entryPrice: string;
372
+ positionValue: string;
373
+ unrealizedPnl: string;
374
+ marginUsed: string;
375
+ leverage: {
376
+ type: 'isolated' | 'cross';
377
+ value: number;
378
+ rawUsd?: string;
379
+ };
380
+ liquidationPrice: string | null;
381
+ maxLeverage: number;
382
+ returnOnEquity: string;
383
+ cumulativeFunding: {
384
+ allTime: string;
385
+ sinceOpen: string;
386
+ sinceChange: string;
387
+ };
388
+ /**
389
+ * Take profit price (if set).
390
+ *
391
+ * Summary field, resolved for the common case a client renders: when
392
+ * `takeProfitOrders` holds exactly one order this is that order's trigger
393
+ * price, whether or not it covers the whole position. With two or more orders
394
+ * no single price describes them, so this falls back to the position-bound
395
+ * trigger — clients render `takeProfitCount` there instead.
396
+ *
397
+ * It may also reflect a TP/SL child of a *pending* order on this market, which
398
+ * `takeProfitOrders` and `takeProfitCount` deliberately exclude because such a
399
+ * child protects that order rather than the position. A position can therefore
400
+ * report a price here with an empty array and a count of `0`. Prefer
401
+ * `takeProfitOrders` for anything that must be exact.
402
+ */
403
+ takeProfitPrice?: string;
404
+ /**
405
+ * Stop loss price (if set). Same caveat as `takeProfitPrice`.
406
+ */
407
+ stopLossPrice?: string;
408
+ takeProfitCount: number;
409
+ stopLossCount: number;
410
+ takeProfitOrders?: PositionTriggerOrder[];
411
+ stopLossOrders?: PositionTriggerOrder[];
412
+ providerId?: PerpsProviderType;
413
+ };
414
+ /**
415
+ * A trigger order attached to a position, as surfaced in position state.
416
+ * Provider-agnostic: protocols map their own trigger representation onto this.
417
+ */
418
+ export type PositionTriggerOrder = {
419
+ orderId: string;
420
+ direction: TriggerDirection;
421
+ orderType?: TriggerOrderType;
422
+ triggerPrice: string;
423
+ size: string;
424
+ isPartial: boolean;
425
+ reduceOnly: boolean;
426
+ };
427
+ export type AccountState = {
428
+ /**
429
+ * Total USD equity on this venue — collateral + unrealized PnL. Live MTM.
430
+ * HL: crossMarginSummary.accountValue + spot(USDC) − spot.hold
431
+ */
432
+ totalBalance: string;
433
+ /**
434
+ * Max USD that can immediately collateralize a new position on this venue,
435
+ * with no internal transfer required.
436
+ * HL Unified: withdrawable + freeSpotUSDC
437
+ * HL Standard: withdrawable
438
+ */
439
+ spendableBalance: string;
440
+ /**
441
+ * Max USD that can leave this venue to the user's external wallet.
442
+ * UI reads this value without branching on provider; the provider
443
+ * contract guarantees HL's own abstraction (Unified) or the direct
444
+ * perps-clearinghouse (Standard) is what actually settles the
445
+ * withdraw — no client-side spot→perps sweep is performed.
446
+ * HL Unified: withdrawable + freeSpotUSDC (USDC only; `freeSpotUSDC = spot.total - spot.hold`, and HL withdraw3 draws from the unified ledger server-side)
447
+ * HL Standard: withdrawable (perps-clearinghouse only; spot is a separate ledger)
448
+ */
449
+ withdrawableBalance: string;
450
+ marginUsed: string;
451
+ unrealizedPnl: string;
452
+ returnOnEquity: string;
453
+ /**
454
+ * Per-sub-account balance breakdown (protocol-specific, optional)
455
+ * Maps sub-account identifier to its balance details.
456
+ *
457
+ * Protocol examples:
458
+ * - HyperLiquid HIP-3: '' or 'main' (main DEX), 'xyz' (HIP-3 builder DEX)
459
+ * - dYdX: Sub-account numbers (e.g., '0', '1', '2')
460
+ * - Other protocols: Vault IDs, pool IDs, margin account IDs, etc.
461
+ *
462
+ * Key: Sub-account identifier (protocol-specific string)
463
+ * Value: Balance details for that sub-account
464
+ */
465
+ subAccountBreakdown?: Record<string, {
466
+ spendableBalance: string;
467
+ withdrawableBalance: string;
468
+ totalBalance: string;
469
+ }>;
470
+ providerId?: PerpsProviderType;
471
+ };
472
+ export type ClosePositionParams = {
473
+ symbol: string;
474
+ size?: string;
475
+ /**
476
+ * Close order type (default: market). Only `market` and `limit` are meaningful
477
+ * here: `ClosePositionParams` carries no trigger price, so a trigger-based
478
+ * close is not expressible and would be rejected during placement.
479
+ *
480
+ * Strategy placements are excluded at the type level rather than left to a
481
+ * runtime rejection, because this type cannot carry any of the fields they
482
+ * require and `closePosition` has no path that executes them. Derived with
483
+ * `Exclude` on purpose: it shrinks as `StrategyOrderType` grows, so a strategy
484
+ * added later is refused here automatically.
485
+ */
486
+ orderType?: Exclude<OrderType, StrategyOrderType>;
487
+ price?: string;
488
+ currentPrice?: number;
489
+ usdAmount?: string;
490
+ priceAtCalculation?: number;
491
+ maxSlippageBps?: number;
492
+ trackingData?: TrackingData;
493
+ providerId?: PerpsProviderType;
494
+ /**
495
+ * Optional caller snapshot for diagnostics.
496
+ *
497
+ * The provider always resolves the position from the current DEX WebSocket
498
+ * slice or an HTTP read. It never uses this snapshot for order size or side.
499
+ * If neither authoritative source answers, the close fails with
500
+ * `PROVIDER_NOT_AVAILABLE`.
501
+ */
502
+ position?: Position;
503
+ };
504
+ export type ClosePositionsParams = {
505
+ symbols?: string[];
506
+ closeAll?: boolean;
507
+ };
508
+ export type ClosePositionsResult = {
509
+ success: boolean;
510
+ successCount: number;
511
+ failureCount: number;
512
+ /**
513
+ * Batch-level operation error.
514
+ *
515
+ * Set when the close fails as a whole: snapshot/preparation errors with no
516
+ * per-position outcomes, or a thrown batch submission that also fills
517
+ * `results` with per-position failures.
518
+ */
519
+ error?: string;
520
+ results: {
521
+ symbol: string;
522
+ success: boolean;
523
+ error?: string;
524
+ }[];
525
+ };
526
+ export type UpdateMarginParams = {
527
+ symbol: string;
528
+ amount: string;
529
+ providerId?: PerpsProviderType;
530
+ };
531
+ export type MarginResult = {
532
+ success: boolean;
533
+ error?: string;
534
+ };
535
+ export type FlipPositionParams = {
536
+ symbol: string;
537
+ position: Position;
538
+ trackingData?: TrackingData;
539
+ };
540
+ export type InitializeResult = {
541
+ success: boolean;
542
+ error?: string;
543
+ chainId?: string;
544
+ };
545
+ export type ReadyToTradeResult = {
546
+ ready: boolean;
547
+ error?: string;
548
+ walletConnected?: boolean;
549
+ networkSupported?: boolean;
550
+ authenticatedAddress?: string;
551
+ };
552
+ export type DisconnectResult = {
553
+ success: boolean;
554
+ error?: string;
555
+ };
556
+ export type MarketInfo = {
557
+ name: string;
558
+ szDecimals: number;
559
+ maxLeverage: number;
560
+ marginTableId: number;
561
+ marginMode?: 'strictIsolated' | 'noCross';
562
+ onlyIsolated?: true;
563
+ isDelisted?: true;
564
+ minimumOrderSize?: number;
565
+ providerId?: PerpsProviderType;
566
+ };
567
+ /**
568
+ * Market data with prices for UI display
569
+ * Protocol-agnostic interface for market information with formatted values
570
+ */
571
+ export type PerpsMarketData = {
572
+ /**
573
+ * Token symbol (e.g., 'BTC', 'ETH')
574
+ */
575
+ symbol: string;
576
+ /**
577
+ * Full token name (e.g., 'Bitcoin', 'Ethereum')
578
+ */
579
+ name: string;
580
+ /**
581
+ * Human-readable asset description from Terminal API metadata, when available
582
+ * (e.g., 'The leading smart contract platform. Home to DeFi, NFTs...').
583
+ * Only populated when using the Terminal API backend and the asset has one.
584
+ */
585
+ description?: string;
586
+ /**
587
+ * Maximum leverage available as formatted string (e.g., '40x', '25x')
588
+ */
589
+ maxLeverage: string;
590
+ /**
591
+ * Current price as formatted string (e.g., '$50,000.00')
592
+ */
593
+ price: string;
594
+ /**
595
+ * 24h price change as formatted string (e.g., '+$1,250.00', '-$850.50')
596
+ */
597
+ change24h: string;
598
+ /**
599
+ * 24h price change percentage as formatted string (e.g., '+2.5%', '-1.8%')
600
+ */
601
+ change24hPercent: string;
602
+ /**
603
+ * Trading volume as formatted string (e.g., '$1.2B', '$850M')
604
+ */
605
+ volume: string;
606
+ /**
607
+ * Open interest as formatted string (e.g., '$24.5M', '$1.2B')
608
+ */
609
+ openInterest?: string;
610
+ /**
611
+ * Next funding time in milliseconds since epoch (optional, market-specific)
612
+ */
613
+ nextFundingTime?: number;
614
+ /**
615
+ * Funding interval in hours (optional, market-specific)
616
+ */
617
+ fundingIntervalHours?: number;
618
+ /**
619
+ * Current funding rate as decimal (optional, from predictedFundings API)
620
+ */
621
+ fundingRate?: number;
622
+ /**
623
+ * Market source DEX identifier (HIP-3 support)
624
+ * - null or undefined: Main validator DEX
625
+ * - "xyz", "abc", etc: HIP-3 builder-deployed DEX
626
+ */
627
+ marketSource?: string | null;
628
+ /**
629
+ * Market asset type classification (optional)
630
+ * - crypto: Cryptocurrency (default for most markets)
631
+ * - stock: Individual stocks (HIP-3)
632
+ * - pre-ipo: Pre-IPO assets (HIP-3)
633
+ * - index: Market indices (HIP-3)
634
+ * - etf: Exchange-traded funds (HIP-3)
635
+ * - commodity: Commodity markets (HIP-3)
636
+ * - forex: Foreign exchange pairs (HIP-3)
637
+ */
638
+ marketType?: MarketType;
639
+ /**
640
+ * Whether this is a HIP-3 market (has DEX prefix like xyz:, flx:)
641
+ * Used to distinguish between crypto (isHip3=false) and non-crypto markets
642
+ */
643
+ isHip3?: boolean;
644
+ /**
645
+ * Whether this is a new/uncategorized market (HIP-3 markets not yet in explicit mapping)
646
+ * Used for the "New" filter tab
647
+ */
648
+ isNewMarket?: boolean;
649
+ /**
650
+ * Multi-provider: which provider this market data comes from (injected by aggregator)
651
+ */
652
+ providerId?: PerpsProviderType;
653
+ /**
654
+ * Indicates this market snapshot came from the last known good cache after live fetch failure.
655
+ */
656
+ isStale?: boolean;
657
+ /** Identifies an atomic Terminal summary whose price/change use mark semantics. */
658
+ dataSource?: 'terminal-global-snapshot-mark';
659
+ /** Source-bounded expiry for an atomic Terminal summary. */
660
+ sourceExpiresAt?: number;
661
+ /**
662
+ * Searchable keywords from Terminal API metadata (e.g., ['defi', 'layer-1'])
663
+ */
664
+ keywords?: string[];
665
+ /**
666
+ * Taxonomy tags from Terminal API metadata (e.g., ['top-100', 'gaming'])
667
+ */
668
+ tags?: string[];
669
+ /**
670
+ * Market categories from Terminal API metadata (e.g., ['crypto', 'meme'])
671
+ */
672
+ categories?: string[];
673
+ /** Timestamped hourly price points supplied by the atomic Terminal snapshot. */
674
+ trend?: [timestampMs: number, price: string][];
675
+ /**
676
+ * Epoch ms when this market was listed on the Terminal backend.
677
+ * Sourced from the Terminal API `listedAt` field.
678
+ * Clients can use this to surface recently added markets (e.g. markets listed within the last 30 days).
679
+ */
680
+ listedAt?: number;
681
+ };
682
+ export type ToggleTestnetResult = {
683
+ success: boolean;
684
+ isTestnet: boolean;
685
+ error?: string;
686
+ };
687
+ export type AssetRoute = {
688
+ assetId: CaipAssetId;
689
+ chainId: CaipChainId;
690
+ contractAddress: Hex;
691
+ constraints?: {
692
+ minAmount?: string;
693
+ maxAmount?: string;
694
+ estimatedTime?: string;
695
+ estimatedMinutes?: number;
696
+ fees?: {
697
+ fixed?: number;
698
+ percentage?: number;
699
+ token?: string;
700
+ };
701
+ };
702
+ };
703
+ export type SwitchProviderResult = {
704
+ success: boolean;
705
+ providerId: PerpsActiveProviderMode;
706
+ error?: string;
707
+ };
708
+ export type CancelOrderParams = {
709
+ orderId: string;
710
+ symbol: string;
711
+ /**
712
+ * Placement type of what is being cancelled. Only the strategy types
713
+ * (`twap`, `scale`, `chase`) change anything: each is cancelled through its
714
+ * own path — the venue's TWAP cancel endpoint, a batch cancel of the ladder's
715
+ * children, or stopping the chase session and cancelling its live order.
716
+ * Omit it (or pass an ordinary order type) to cancel a single resting order,
717
+ * which is what every existing caller does.
718
+ */
719
+ orderType?: OrderType;
720
+ providerId?: PerpsProviderType;
721
+ trackingData?: TrackingData;
722
+ };
723
+ export type CancelOrderResult = {
724
+ success: boolean;
725
+ /**
726
+ * What was cancelled, named the same way it was placed: an exchange order ID
727
+ * for an ordinary cancel, and the strategy handle — TWAP id, scale group, or
728
+ * chase session — when `CancelOrderParams.orderType` named one. Scale and
729
+ * chase handles can only be cancelled during the provider session that
730
+ * created them; TWAP IDs are venue-owned.
731
+ */
732
+ orderId?: string;
733
+ error?: string;
734
+ providerId?: PerpsProviderType;
735
+ };
736
+ export type BatchCancelOrdersParams = {
737
+ orderId: string;
738
+ symbol: string;
739
+ }[];
740
+ export type CancelOrdersParams = {
741
+ symbols?: string[];
742
+ orderIds?: string[];
743
+ cancelAll?: boolean;
744
+ };
745
+ export type CancelOrdersResult = {
746
+ success: boolean;
747
+ successCount: number;
748
+ failureCount: number;
749
+ results: {
750
+ orderId: string;
751
+ symbol: string;
752
+ success: boolean;
753
+ error?: string;
754
+ }[];
755
+ };
756
+ export type EditOrderParams = {
757
+ orderId: string | number;
758
+ newOrder: OrderParams;
759
+ };
760
+ export type DepositParams = {
761
+ amount: string;
762
+ assetId: CaipAssetId;
763
+ fromChainId?: CaipChainId;
764
+ toChainId?: CaipChainId;
765
+ recipient?: Hex;
766
+ };
767
+ /** Params for depositWithConfirmation: prepares transaction for confirmation screen */
768
+ export type DepositWithConfirmationParams = {
769
+ /** Optional deposit amount (display/tracking; actual amount comes from prepared transaction) */
770
+ amount?: string;
771
+ /** If true, uses addTransaction instead of submit to avoid navigation (e.g. deposit + place order flow) */
772
+ placeOrder?: boolean;
773
+ };
774
+ export type DepositResult = {
775
+ success: boolean;
776
+ txHash?: string;
777
+ error?: string;
778
+ };
779
+ export type DepositStatus = 'idle' | 'preparing' | 'swapping' | 'bridging' | 'depositing' | 'success' | 'error';
780
+ export type DepositFlowType = 'direct' | 'swap' | 'bridge' | 'swap_bridge';
781
+ export type DepositStepInfo = {
782
+ totalSteps: number;
783
+ currentStep: number;
784
+ stepNames: string[];
785
+ stepTxHashes?: string[];
786
+ };
787
+ export type WithdrawParams = {
788
+ amount: string;
789
+ destination?: Hex;
790
+ assetId?: CaipAssetId;
791
+ providerId?: PerpsProviderType;
792
+ };
793
+ export type WithdrawResult = {
794
+ success: boolean;
795
+ txHash?: string;
796
+ error?: string;
797
+ withdrawalId?: string;
798
+ estimatedArrivalTime?: number;
799
+ };
800
+ export type TransferBetweenDexsParams = {
801
+ sourceDex: string;
802
+ destinationDex: string;
803
+ amount: string;
804
+ };
805
+ export type TransferBetweenDexsResult = {
806
+ success: boolean;
807
+ txHash?: string;
808
+ error?: string;
809
+ };
810
+ export type GetHistoricalPortfolioParams = {
811
+ accountId?: CaipAccountId;
812
+ };
813
+ export type HistoricalPortfolioResult = {
814
+ accountValue1dAgo: string;
815
+ timestamp: number;
816
+ };
817
+ export type LiveDataConfig = {
818
+ priceThrottleMs?: number;
819
+ positionThrottleMs?: number;
820
+ maxUpdatesPerSecond?: number;
821
+ };
822
+ export type PerpsControllerConfig = {
823
+ /**
824
+ * Fallback blocked regions to use when RemoteFeatureFlagController fails to fetch.
825
+ * The fallback is set by default if defined and replaced with remote block list once available.
826
+ */
827
+ fallbackBlockedRegions?: string[];
828
+ /**
829
+ * Fallback HIP-3 equity perps master switch to use when RemoteFeatureFlagController fails to fetch.
830
+ * Controls whether HIP-3 (builder-deployed) DEXs are enabled.
831
+ * The fallback is set by default if defined and replaced with remote feature flag once available.
832
+ */
833
+ fallbackHip3Enabled?: boolean;
834
+ /**
835
+ * Fallback HIP-3 market allowlist to use when RemoteFeatureFlagController fails to fetch.
836
+ * Empty array = enable all markets (discovery mode), non-empty = allowlist specific markets.
837
+ * Supports wildcards: "xyz:*" (all xyz markets), "xyz" (shorthand for "xyz:*"), "BTC" (main DEX market).
838
+ * Only applies when HIP-3 is enabled.
839
+ * The fallback is set by default if defined and replaced with remote feature flag once available.
840
+ */
841
+ fallbackHip3AllowlistMarkets?: string[];
842
+ /**
843
+ * Fallback HIP-3 market blocklist to use when RemoteFeatureFlagController fails to fetch.
844
+ * Empty array = no blocking, non-empty = block specific markets.
845
+ * Supports wildcards: "xyz:*" (block all xyz markets), "xyz" (shorthand for "xyz:*"), "BTC" (block main DEX market).
846
+ * Always applied regardless of HIP-3 enabled state.
847
+ * The fallback is set by default if defined and replaced with remote feature flag once available.
848
+ */
849
+ fallbackHip3BlocklistMarkets?: string[];
850
+ /**
851
+ * Override for the maximum allowed deviation of a market's price from its oracle
852
+ * (reference) price before it is reported as untradable (`PriceUpdate.isTradable`),
853
+ * as a decimal fraction (e.g. `0.95` = 95%). Protocol-agnostic: each provider applies
854
+ * its own default when omitted (HyperLiquid uses
855
+ * `HYPERLIQUID_CONFIG.OraclePriceDeviationLimit`, `0.95`). Lets a client tune the
856
+ * threshold without a package release.
857
+ */
858
+ fallbackPriceDeviationLimit?: number;
859
+ /**
860
+ * Per-provider credentials and configuration.
861
+ * Nested by provider name so each provider's settings are self-contained
862
+ * and new protocols can be added without polluting the top-level config.
863
+ * Passed from the init file where `process.env.X` is babel-transformed at build time.
864
+ */
865
+ providerCredentials?: PerpsProviderCredentials;
866
+ };
867
+ export type HyperLiquidCredentials = {
868
+ /** Builder fee wallet address for testnet. Empty/omitted = uses BUILDER_FEE_CONFIG default. */
869
+ builderAddressTestnet?: string;
870
+ /** Builder fee wallet address for mainnet. Empty/omitted = uses BUILDER_FEE_CONFIG default. */
871
+ builderAddressMainnet?: string;
872
+ /** Dedicated subscription waiver builder for testnet. */
873
+ subscriptionBuilderAddressTestnet?: string;
874
+ /** Dedicated subscription waiver builder for mainnet. */
875
+ subscriptionBuilderAddressMainnet?: string;
876
+ };
877
+ export type LighterCredentials = {
878
+ /** Whether Lighter provider is enabled via local env var. */
879
+ enabled?: boolean;
880
+ /** Lighter account index override (testnet tooling). */
881
+ accountIndexTestnet?: number;
882
+ accountIndexMainnet?: number;
883
+ /** API key slot to register/use (defaults to LIGHTER_DEFAULT_API_KEY_INDEX). */
884
+ apiKeyIndex?: number;
885
+ /**
886
+ * Client-owned Lighter signer. The client creates and persists the venue
887
+ * key behind this bridge; Core receives only signing results and public
888
+ * registration data, matching the injected-wallet boundary used by
889
+ * HyperLiquid.
890
+ *
891
+ * Mobile uses an off-screen WebView bridge; headless clients may use an
892
+ * in-process WASM bridge.
893
+ * Optional — without it the Lighter provider is read-only. Lives on the
894
+ * Lighter credentials bag, not PerpsPlatformDependencies, so the shared
895
+ * platform surface stays venue-agnostic.
896
+ */
897
+ signerBridge?: LighterSignerBridge;
898
+ };
899
+ export type PerpsProviderCredentials = {
900
+ hyperliquid?: HyperLiquidCredentials;
901
+ lighter?: LighterCredentials;
902
+ };
903
+ export type PriceUpdate = {
904
+ symbol: string;
905
+ price: string;
906
+ timestamp: number;
907
+ percentChange24h?: string;
908
+ bestBid?: string;
909
+ bestAsk?: string;
910
+ spread?: string;
911
+ markPrice?: string;
912
+ funding?: number;
913
+ openInterest?: number;
914
+ volume24h?: number;
915
+ /**
916
+ * Whether the market is currently tradable. Defaults to `true`.
917
+ *
918
+ * Some markets — most often HIP-3 builder-deployed ones — become temporarily
919
+ * untradable when their market price drifts too far from the oracle price, in which
920
+ * case the protocol rejects orders (HyperLiquid: "Order price cannot be more than 95%
921
+ * away from the reference price"). Clients use this to proactively show a "trading
922
+ * unavailable" warning instead of letting the order fail on submission.
923
+ *
924
+ * Computed per provider/protocol from that protocol's own rules. It is `false` only
925
+ * when a provider determines the market is currently untradable; a provider that has no
926
+ * such rule, or cannot assess tradability yet (e.g. before the oracle price is cached),
927
+ * reports `true`. The value is always a concrete boolean — never `undefined`.
928
+ */
929
+ isTradable: boolean;
930
+ providerId?: PerpsProviderType;
931
+ };
932
+ export type OrderFill = {
933
+ orderId: string;
934
+ symbol: string;
935
+ side: string;
936
+ size: string;
937
+ price: string;
938
+ pnl: string;
939
+ direction: string;
940
+ fee: string;
941
+ feeToken: string;
942
+ timestamp: number;
943
+ startPosition?: string;
944
+ success?: boolean;
945
+ liquidation?: {
946
+ liquidatedUser: string;
947
+ markPx: string;
948
+ method: string;
949
+ };
950
+ orderType?: 'take_profit' | 'stop_loss' | 'liquidation' | 'regular';
951
+ detailedOrderType?: string;
952
+ providerId?: PerpsProviderType;
953
+ };
954
+ export type CheckEligibilityParams = {
955
+ blockedRegions: string[];
956
+ geoLocation: string;
957
+ };
958
+ export type GetPositionsParams = {
959
+ accountId?: CaipAccountId;
960
+ includeHistory?: boolean;
961
+ skipCache?: boolean;
962
+ standalone?: boolean;
963
+ userAddress?: string;
964
+ };
965
+ export type GetAccountStateParams = {
966
+ accountId?: CaipAccountId;
967
+ source?: string;
968
+ standalone?: boolean;
969
+ userAddress?: string;
970
+ };
971
+ export type GetUserDataSnapshotParams = {
972
+ userAddress: string;
973
+ identity: {
974
+ provider: 'hyperliquid';
975
+ network: 'mainnet' | 'testnet';
976
+ hip3ConfigVersion: number;
977
+ dexes: string[];
978
+ };
979
+ };
980
+ export type PerpsUserDataSnapshot = {
981
+ positions: Position[];
982
+ orders: Order[];
983
+ accountState: AccountState;
984
+ identity: GetUserDataSnapshotParams['identity'] & {
985
+ address: string;
986
+ };
987
+ };
988
+ export type GetOrderFillsParams = {
989
+ accountId?: CaipAccountId;
990
+ user?: Hex;
991
+ startTime?: number;
992
+ endTime?: number;
993
+ limit?: number;
994
+ aggregateByTime?: boolean;
995
+ };
996
+ /**
997
+ * Parameters for getOrFetchFills - optimized cache-first fill retrieval.
998
+ * Subset of GetOrderFillsParams for cache filtering.
999
+ */
1000
+ export type GetOrFetchFillsParams = {
1001
+ startTime?: number;
1002
+ symbol?: string;
1003
+ };
1004
+ export type GetOrdersParams = {
1005
+ accountId?: CaipAccountId;
1006
+ startTime?: number;
1007
+ endTime?: number;
1008
+ limit?: number;
1009
+ offset?: number;
1010
+ skipCache?: boolean;
1011
+ standalone?: boolean;
1012
+ userAddress?: string;
1013
+ };
1014
+ /**
1015
+ * Options for cache-aware provider read calls (getOrders, getOrderFills, etc.).
1016
+ * Provider-agnostic: providers without inner caches can ignore; providers that
1017
+ * cache at the service layer (e.g. HyperLiquid) must honor forceRefresh.
1018
+ */
1019
+ export type PerpsReadOptions = {
1020
+ /** Bypass any provider-internal cache. Used for user-initiated refresh (pull-to-refresh). */
1021
+ forceRefresh?: boolean;
1022
+ };
1023
+ export type GetFundingParams = {
1024
+ accountId?: CaipAccountId;
1025
+ startTime?: number;
1026
+ endTime?: number;
1027
+ limit?: number;
1028
+ offset?: number;
1029
+ };
1030
+ export type GetSupportedPathsParams = {
1031
+ isTestnet?: boolean;
1032
+ assetId?: CaipAssetId;
1033
+ symbol?: string;
1034
+ chainId?: CaipChainId;
1035
+ };
1036
+ /** Placeholder for future filter/pagination params (e.g., validated, chain). Empty today so the API signature is stable. */
1037
+ export type GetAvailableDexsParams = Record<string, never>;
1038
+ /** Field to sort markets by. */
1039
+ export type SortField = 'volume' | 'priceChange' | 'fundingRate' | 'openInterest';
1040
+ /** Direction for market sorting. */
1041
+ export type SortDirection = 'asc' | 'desc';
1042
+ export type GetMarketsParams = {
1043
+ symbols?: string[];
1044
+ dex?: string;
1045
+ skipFilters?: boolean;
1046
+ standalone?: boolean;
1047
+ useTerminalApi?: boolean;
1048
+ };
1049
+ /**
1050
+ * Parameters for {@link PerpsController.getMarketDataWithPrices}.
1051
+ * Extends the base market-fetch params with optional category filtering,
1052
+ * sorting, and pagination that are applied as post-processing.
1053
+ */
1054
+ export type GetMarketDataWithPricesParams = {
1055
+ standalone?: boolean;
1056
+ categories?: MarketTypeFilter[];
1057
+ excludeSymbols?: string[];
1058
+ sortBy?: SortField;
1059
+ direction?: SortDirection;
1060
+ limit?: number;
1061
+ useTerminalApi?: boolean;
1062
+ };
1063
+ export type SubscribePricesParams = {
1064
+ symbols: string[];
1065
+ callback: (prices: PriceUpdate[]) => void;
1066
+ throttleMs?: number;
1067
+ includeOrderBook?: boolean;
1068
+ includeMarketData?: boolean;
1069
+ };
1070
+ export type SubscribePositionsParams = {
1071
+ callback: (positions: Position[]) => void;
1072
+ accountId?: CaipAccountId;
1073
+ includeHistory?: boolean;
1074
+ };
1075
+ export type SubscribeOrderFillsParams = {
1076
+ callback: (fills: OrderFill[], isSnapshot?: boolean) => void;
1077
+ accountId?: CaipAccountId;
1078
+ since?: number;
1079
+ };
1080
+ export type SubscribeOrdersParams = {
1081
+ callback: (orders: Order[]) => void;
1082
+ accountId?: CaipAccountId;
1083
+ includeHistory?: boolean;
1084
+ };
1085
+ export type SubscribeTwapOrdersParams = {
1086
+ /**
1087
+ * Receives current and terminal TWAP schedules, newest first — the same
1088
+ * shape `getTwapOrders()` returns, so a client can swap a poll for this
1089
+ * subscription without reshaping its state.
1090
+ *
1091
+ * Retention differs from the REST read on purpose: every active schedule is
1092
+ * always delivered, while terminal ones are bounded to the most recent 100
1093
+ * so a long-lived stream cannot accumulate an account's entire history.
1094
+ * Callers needing older terminal schedules should still read
1095
+ * `getTwapOrders()`.
1096
+ *
1097
+ * `isSnapshot` marks the venue's initial full set; later invocations carry
1098
+ * the merged result of a delta.
1099
+ */
1100
+ callback: (twapOrders: TwapOrder[], isSnapshot?: boolean) => void;
1101
+ accountId?: CaipAccountId;
1102
+ };
1103
+ export type SubscribeAccountParams = {
1104
+ callback: (account: AccountState | null) => void;
1105
+ accountId?: CaipAccountId;
1106
+ };
1107
+ export type SubscribeOICapsParams = {
1108
+ callback: (caps: string[]) => void;
1109
+ accountId?: CaipAccountId;
1110
+ };
1111
+ export type SubscribeCandlesParams = {
1112
+ symbol: string;
1113
+ interval: CandlePeriod;
1114
+ duration?: TimeDuration;
1115
+ callback: (data: CandleData) => void;
1116
+ onError?: (error: Error) => void;
1117
+ };
1118
+ /**
1119
+ * Single price level in the order book
1120
+ */
1121
+ export type OrderBookLevel = {
1122
+ /** Price at this level */
1123
+ price: string;
1124
+ /** Size at this level (in base asset) */
1125
+ size: string;
1126
+ /** Cumulative size up to and including this level */
1127
+ total: string;
1128
+ /** Notional value in USD */
1129
+ notional: string;
1130
+ /** Cumulative notional up to and including this level */
1131
+ totalNotional: string;
1132
+ };
1133
+ /**
1134
+ * Full order book data with multiple price levels
1135
+ */
1136
+ export type OrderBookData = {
1137
+ /** Bid levels (buy orders) - highest price first */
1138
+ bids: OrderBookLevel[];
1139
+ /** Ask levels (sell orders) - lowest price first */
1140
+ asks: OrderBookLevel[];
1141
+ /** Spread between best bid and best ask */
1142
+ spread: string;
1143
+ /** Spread as a percentage of mid price */
1144
+ spreadPercentage: string;
1145
+ /** Mid price (average of best bid and best ask) */
1146
+ midPrice: string;
1147
+ /** Timestamp of last update */
1148
+ lastUpdated: number;
1149
+ /** Maximum total size across all levels (for scaling depth bars) */
1150
+ maxTotal: string;
1151
+ };
1152
+ export type SubscribeOrderBookParams = {
1153
+ /** Symbol to subscribe to (e.g., 'BTC', 'ETH') */
1154
+ symbol: string;
1155
+ /** Number of levels to return per side (default: 10) */
1156
+ levels?: number;
1157
+ /** Price aggregation significant figures (2-5, default: 5). Higher = finer granularity */
1158
+ nSigFigs?: 2 | 3 | 4 | 5;
1159
+ /** Mantissa for aggregation when nSigFigs is 5 (2 or 5). Controls finest price increments */
1160
+ mantissa?: 2 | 5;
1161
+ /**
1162
+ * Enable fast order book updates (5 levels @ ~0.5 s cadence).
1163
+ * When omitted, Hyperliquid uses the default cadence (20 levels @ ~2 s).
1164
+ * Note: with `fast: true` the widget receives at most 5 levels per side
1165
+ * regardless of the `levels` setting.
1166
+ */
1167
+ fast?: boolean;
1168
+ /** Callback function receiving order book updates */
1169
+ callback: (orderBook: OrderBookData) => void;
1170
+ /** Callback for errors */
1171
+ onError?: (error: Error) => void;
1172
+ };
1173
+ export type LiquidationPriceParams = {
1174
+ entryPrice: number;
1175
+ leverage: number;
1176
+ direction: 'long' | 'short';
1177
+ positionSize?: number;
1178
+ marginType?: 'isolated' | 'cross';
1179
+ asset?: string;
1180
+ /** Provider that owns the position when calculations are aggregated. */
1181
+ providerId?: PerpsProviderType;
1182
+ };
1183
+ /**
1184
+ * Live position fields required to project a modify. Clients may pass a full
1185
+ * {@link Position}; extra fields are ignored.
1186
+ */
1187
+ export type PositionModifyPreviewSource = Pick<Position, 'symbol' | 'size' | 'marginUsed' | 'liquidationPrice' | 'entryPrice' | 'leverage' | 'positionValue' | 'maxLeverage' | 'providerId'>;
1188
+ /**
1189
+ * Proposed order plus the live position it would modify.
1190
+ *
1191
+ * Isolated-margin previews apply `leverage` to the *whole* resulting
1192
+ * position, matching `updateLeverage` before placement. Cross-margin
1193
+ * positions are not projected.
1194
+ */
1195
+ export type PositionModifyPreviewParams = {
1196
+ position: PositionModifyPreviewSource;
1197
+ /** Proposed order direction. */
1198
+ direction: 'long' | 'short';
1199
+ /** Proposed order size in token units. */
1200
+ size: string;
1201
+ /**
1202
+ * Expected fill price for a marketable order, or the resting limit price.
1203
+ * Increases and flips require a positive price; a reduce does not.
1204
+ * Scale, TWAP, and chase orders should pass the expected fill size and price;
1205
+ * this preview models a single fill.
1206
+ */
1207
+ price: string;
1208
+ /**
1209
+ * Isolated leverage the provider will set on the asset before placing.
1210
+ * Applied to the entire resulting position, not only the added size.
1211
+ */
1212
+ leverage: number;
1213
+ reduceOnly?: boolean;
1214
+ /**
1215
+ * Estimated trading fees in USD. Deducted from isolated margin on
1216
+ * increases and flips. Omit or pass 0 when unknown.
1217
+ */
1218
+ feeAmountUsd?: number;
1219
+ /**
1220
+ * Explicit venue route. Aggregated providers use this, then
1221
+ * `position.providerId`, then the default provider.
1222
+ */
1223
+ providerId?: PerpsProviderType;
1224
+ };
1225
+ /**
1226
+ * Independently available numeric projection. Margin can be known when
1227
+ * liquidation cannot (missing maintenance-tier data, or no liquidation risk).
1228
+ */
1229
+ export type PositionPreviewValue = {
1230
+ available: true;
1231
+ value: number;
1232
+ } | {
1233
+ available: false;
1234
+ };
1235
+ export type PositionModifyPreviewKind = 'increase' | 'decrease' | 'flip';
1236
+ export type PositionModifyPreviewCurrent = {
1237
+ margin: PositionPreviewValue;
1238
+ liquidationPrice: PositionPreviewValue;
1239
+ };
1240
+ export type PositionModifyPreviewOpen = {
1241
+ status: 'open';
1242
+ kind: PositionModifyPreviewKind;
1243
+ current: PositionModifyPreviewCurrent;
1244
+ resulting: {
1245
+ direction: 'long' | 'short';
1246
+ /** Resulting token size; always > 0 for `open`. */
1247
+ size: number;
1248
+ entryPrice: number;
1249
+ /**
1250
+ * Isolated leverage from mark notional / remaining margin, matching
1251
+ * HyperLiquid's displayed leverage rather than entry notional / margin.
1252
+ */
1253
+ leverage: number;
1254
+ margin: PositionPreviewValue;
1255
+ liquidationPrice: PositionPreviewValue;
1256
+ };
1257
+ };
1258
+ export type PositionModifyPreviewFullClose = {
1259
+ status: 'full_close';
1260
+ current: PositionModifyPreviewCurrent;
1261
+ /** Direction of the position being closed. */
1262
+ resultingDirection: 'long' | 'short';
1263
+ };
1264
+ export type PositionModifyPreviewUnsupported = {
1265
+ status: 'unsupported';
1266
+ reason: 'cross_margin' | 'provider';
1267
+ };
1268
+ export type PositionModifyPreviewNone = {
1269
+ status: 'none';
1270
+ };
1271
+ /**
1272
+ * Read-only post-trade position projection.
1273
+ *
1274
+ * Discriminated on `status` so a non-modifying result cannot carry a
1275
+ * flip/full-close kind, and a full close cannot report a remaining size.
1276
+ */
1277
+ export type PositionModifyPreviewResult = PositionModifyPreviewNone | PositionModifyPreviewUnsupported | PositionModifyPreviewFullClose | PositionModifyPreviewOpen;
1278
+ export type MaintenanceMarginParams = {
1279
+ asset: string;
1280
+ positionSize?: number;
1281
+ /** Provider that owns the position when calculations are aggregated. */
1282
+ providerId?: PerpsProviderType;
1283
+ };
1284
+ /**
1285
+ * Context used to resolve the provider that owns order capabilities.
1286
+ * `symbol` allows providers to narrow capabilities per market, while
1287
+ * `providerId` follows the same explicit-over-default routing as placement.
1288
+ */
1289
+ export type GetOrderCapabilitiesParams = {
1290
+ /** Provider-specific market identifier, including any routing prefix. */
1291
+ symbol: string;
1292
+ providerId?: PerpsProviderType;
1293
+ };
1294
+ /** Inputs for a provider-normalized Scale price ladder preview. */
1295
+ export type GetScalePriceLadderParams = {
1296
+ /** Market symbol, including its provider route when applicable. */
1297
+ symbol: string;
1298
+ /** Lowest raw price in the ladder. */
1299
+ minPrice: number;
1300
+ /** Highest raw price in the ladder. */
1301
+ maxPrice: number;
1302
+ /** Number of ladder rungs. */
1303
+ count: number;
1304
+ /** Optional explicit route; omitted uses the active/default provider. */
1305
+ providerId?: PerpsProviderType;
1306
+ };
1307
+ /** Provider-owned strategy capabilities for the selected market route. */
1308
+ export type DirectProviderOrderCapabilitiesUnavailableReason = 'provider_unavailable' | 'invalid_symbol' | 'market_not_found' | 'strategy_market_unsupported';
1309
+ export type RoutedOrderCapabilitiesUnavailableReason = 'provider_not_found' | 'provider_not_routable' | 'not_implemented';
1310
+ export type OrderCapabilitiesUnavailableReason = DirectProviderOrderCapabilitiesUnavailableReason | RoutedOrderCapabilitiesUnavailableReason;
1311
+ type ReadyPerpsOrderCapabilities = Readonly<{
1312
+ status: 'ready';
1313
+ providerId: PerpsProviderType;
1314
+ supportedStrategies: readonly StrategyOrderType[];
1315
+ }>;
1316
+ export type DirectProviderOrderCapabilities = ReadyPerpsOrderCapabilities | Readonly<{
1317
+ status: 'unavailable';
1318
+ providerId?: PerpsProviderType;
1319
+ reason: DirectProviderOrderCapabilitiesUnavailableReason;
1320
+ }>;
1321
+ export type PerpsOrderCapabilities = ReadyPerpsOrderCapabilities | Readonly<{
1322
+ status: 'unavailable';
1323
+ providerId?: PerpsProviderType;
1324
+ reason: OrderCapabilitiesUnavailableReason;
1325
+ }>;
1326
+ /** Reasons a direct provider cannot produce a Scale price ladder. */
1327
+ export type DirectProviderScalePriceLadderUnavailableReason = Exclude<DirectProviderOrderCapabilitiesUnavailableReason, 'strategy_market_unsupported'>;
1328
+ /** Reasons a provider-routed Scale price ladder cannot be produced. */
1329
+ export type ScalePriceLadderUnavailableReason = DirectProviderScalePriceLadderUnavailableReason | RoutedOrderCapabilitiesUnavailableReason;
1330
+ /** Result of provider-routed Scale price normalization. */
1331
+ export type PerpsScalePriceLadder = Readonly<{
1332
+ status: 'ready';
1333
+ providerId: PerpsProviderType;
1334
+ prices: readonly string[];
1335
+ }> | Readonly<{
1336
+ status: 'unavailable';
1337
+ providerId?: PerpsProviderType;
1338
+ reason: ScalePriceLadderUnavailableReason;
1339
+ }>;
1340
+ export type FeeCalculationParams = {
1341
+ orderType: OrderType;
1342
+ isMaker?: boolean;
1343
+ amount?: string;
1344
+ symbol: string;
1345
+ providerId?: PerpsProviderType;
1346
+ };
1347
+ export type FeeCalculationResult = {
1348
+ feeRate?: number;
1349
+ feeAmount?: number;
1350
+ protocolFeeRate?: number;
1351
+ protocolFeeAmount?: number;
1352
+ metamaskFeeRate?: number;
1353
+ metamaskFeeAmount?: number;
1354
+ breakdown?: {
1355
+ baseFeeRate: number;
1356
+ volumeTier?: string;
1357
+ volumeDiscount?: number;
1358
+ stakingDiscount?: number;
1359
+ };
1360
+ /**
1361
+ * Read-only subscription fee-waiver preview, sourced from the same cached
1362
+ * benefits snapshot the fee resolver uses. Present only when the controller
1363
+ * has a subscription source wired; the quoted rates above are not adjusted
1364
+ * from it, so surfacing this never mutates the cap or the cache.
1365
+ */
1366
+ subscription?: PerpsSubscriptionFeeWaiverStatus;
1367
+ };
1368
+ /**
1369
+ * Usage state of the perps fee waiver on a subscription benefits snapshot.
1370
+ */
1371
+ export type PerpsSubscriptionUsage = 'available' | 'exhausted';
1372
+ /**
1373
+ * Subscription benefits as returned by `GET /v1/profiles/{profileId}/benefits`.
1374
+ *
1375
+ * The perps controller never performs this request itself — the client owns the
1376
+ * Profile JWT and injects the read through
1377
+ * {@link PerpsPlatformDependencies.subscription}. Only the fields the perps fee
1378
+ * waiver depends on are modelled here.
1379
+ */
1380
+ export type PerpsSubscriptionBenefits = {
1381
+ /** Subscription status; only `active` can pass the eligibility gate. */
1382
+ status: string;
1383
+ /** Perps fee waiver entitlement and its remaining allowance. */
1384
+ perpsFeeWaiver?: {
1385
+ /** Whether the plan entitles this profile to the perps fee waiver. */
1386
+ entitled: boolean;
1387
+ /** Backend usage state; only `available` can pass the eligibility gate. */
1388
+ usage?: PerpsSubscriptionUsage;
1389
+ /**
1390
+ * Set by the backend once the notional cap is crossed. Honored on the next
1391
+ * cache refresh — there is no client-held reservation to release.
1392
+ */
1393
+ exhausted?: boolean;
1394
+ /** Notional (USD) still covered by the waiver, for fee previews. */
1395
+ remainingNotionalUsd?: number;
1396
+ };
1397
+ };
1398
+ /**
1399
+ * Why the subscription fee waiver did or did not apply, plus the remaining
1400
+ * allowance for fee previews. Derived purely from the cached benefits snapshot.
1401
+ */
1402
+ export type PerpsSubscriptionFeeWaiverStatus = {
1403
+ /** True only when every condition of the eligibility gate passed. */
1404
+ eligible: boolean;
1405
+ /**
1406
+ * Gate outcome:
1407
+ * - `eligible` — every condition passed
1408
+ * - `no-source` — no subscription dependency is wired
1409
+ * - `not-hydrated` — nothing cached yet; a refresh was kicked off
1410
+ * - `stale` — the cached snapshot is past the hard-stale ceiling
1411
+ * - `no-subscription` — the read succeeded but reported no subscription at
1412
+ * all (signed out, or no profile)
1413
+ * - `inactive` — subscription status is not `active`
1414
+ * - `not-entitled` — the plan does not include the perps fee waiver
1415
+ * - `exhausted` — the backend reported the notional cap as spent
1416
+ */
1417
+ reason: 'eligible' | 'no-source' | 'not-hydrated' | 'stale' | 'no-subscription' | 'inactive' | 'not-entitled' | 'exhausted';
1418
+ /** Notional (USD) still covered by the waiver, when the backend reports it. */
1419
+ remainingNotionalUsd?: number;
1420
+ };
1421
+ /**
1422
+ * Fee source that won the unified resolver.
1423
+ *
1424
+ * `rewards` covers both VIP and season discounts: `RewardsController` already
1425
+ * returns the better of the two as a single discount, so the perps controller
1426
+ * treats them as one source rather than re-deriving the split.
1427
+ */
1428
+ export type PerpsFeeSource = 'default' | 'rewards' | 'subscription';
1429
+ /**
1430
+ * Outcome of the unified fee resolver.
1431
+ */
1432
+ export type PerpsFeeResolution = {
1433
+ /** Winning MetaMask builder fee, in basis points (lowest across sources). */
1434
+ feeBips: number;
1435
+ /**
1436
+ * Winning fee expressed as a discount off the default builder fee, in basis
1437
+ * points — the unit providers consume. `undefined` when no source resolved
1438
+ * (e.g. rewards state has not hydrated and no subscription waiver applies),
1439
+ * so callers do not treat it as a definitive "no discount" answer.
1440
+ */
1441
+ discountBips: number | undefined;
1442
+ /** Source that produced the winning fee. */
1443
+ source: PerpsFeeSource;
1444
+ /** Subscription gate outcome, always populated for observability. */
1445
+ subscription: PerpsSubscriptionFeeWaiverStatus;
1446
+ };
1447
+ export type UpdatePositionTPSLParams = {
1448
+ symbol: string;
1449
+ takeProfitPrice?: string;
1450
+ stopLossPrice?: string;
1451
+ takeProfitSize?: string;
1452
+ stopLossSize?: string;
1453
+ trackingData?: TPSLTrackingData;
1454
+ providerId?: PerpsProviderType;
1455
+ /**
1456
+ * Optional caller snapshot for diagnostics.
1457
+ *
1458
+ * The provider always resolves the position from the current DEX WebSocket
1459
+ * slice or an HTTP read. It never uses this snapshot for trigger size or side.
1460
+ * If neither authoritative source answers, the update fails with
1461
+ * `PROVIDER_NOT_AVAILABLE`.
1462
+ */
1463
+ position?: Position;
1464
+ };
1465
+ export type Order = {
1466
+ orderId: string;
1467
+ symbol: string;
1468
+ side: 'buy' | 'sell';
1469
+ orderType: OrderType;
1470
+ size: string;
1471
+ originalSize: string;
1472
+ price: string;
1473
+ filledSize: string;
1474
+ remainingSize: string;
1475
+ status: 'open' | 'filled' | 'canceled' | 'rejected' | 'triggered' | 'queued';
1476
+ timestamp: number;
1477
+ lastUpdated?: number;
1478
+ takeProfitPrice?: string;
1479
+ stopLossPrice?: string;
1480
+ stopLossOrderId?: string;
1481
+ takeProfitOrderId?: string;
1482
+ detailedOrderType?: string;
1483
+ isTrigger?: boolean;
1484
+ triggerOrderType?: TriggerOrderType;
1485
+ reduceOnly?: boolean;
1486
+ isPositionTpsl?: boolean;
1487
+ parentOrderId?: string;
1488
+ isSynthetic?: boolean;
1489
+ triggerPrice?: string;
1490
+ strategyGroupId?: string;
1491
+ providerId?: PerpsProviderType;
1492
+ };
1493
+ export type Funding = {
1494
+ symbol: string;
1495
+ amountUsd: string;
1496
+ rate?: string;
1497
+ timestamp: number;
1498
+ transactionHash?: string;
1499
+ };
1500
+ export type PerpsProvider = {
1501
+ readonly protocolId: string;
1502
+ /** Whether this provider routes individual requests by `providerId`. */
1503
+ readonly routesOrdersByProviderId?: boolean;
1504
+ /**
1505
+ * Return strategy capabilities for the provider/market route. Providers may
1506
+ * omit this hook; the controller then reports capabilities as unavailable.
1507
+ */
1508
+ getOrderCapabilities?(params: GetOrderCapabilitiesParams): Promise<PerpsOrderCapabilities>;
1509
+ /**
1510
+ * Normalize a Scale ladder using the selected provider's venue rules.
1511
+ *
1512
+ * @param params - Market, ladder bounds, count, and optional provider route.
1513
+ * @returns Provider-normalized prices or a typed unavailable result.
1514
+ * @throws When the provider cannot normalize the requested ladder.
1515
+ */
1516
+ getScalePriceLadder?(params: GetScalePriceLadderParams): Promise<PerpsScalePriceLadder>;
1517
+ getDepositRoutes(params?: GetSupportedPathsParams): AssetRoute[];
1518
+ getWithdrawalRoutes(params?: GetSupportedPathsParams): AssetRoute[];
1519
+ placeOrder(params: OrderParams): Promise<OrderResult>;
1520
+ editOrder(params: EditOrderParams): Promise<OrderResult>;
1521
+ cancelOrder(params: CancelOrderParams): Promise<CancelOrderResult>;
1522
+ cancelOrders?(params: BatchCancelOrdersParams): Promise<CancelOrdersResult>;
1523
+ getTwapOrders?(): Promise<TwapOrder[]>;
1524
+ /**
1525
+ * Stream TWAP lifecycle updates. Optional: providers without a native TWAP
1526
+ * push channel omit it, and clients fall back to polling `getTwapOrders`.
1527
+ */
1528
+ subscribeToTwapOrders?(params: SubscribeTwapOrdersParams): () => void;
1529
+ getChaseOrders?(): Promise<ChaseOrder[]>;
1530
+ suspendChaseOrders?(): Promise<ChaseOrder[]>;
1531
+ closePosition(params: ClosePositionParams): Promise<OrderResult>;
1532
+ closePositions?(params: ClosePositionsParams): Promise<ClosePositionsResult>;
1533
+ updatePositionTPSL(params: UpdatePositionTPSLParams): Promise<OrderResult>;
1534
+ updateMargin(params: UpdateMarginParams): Promise<MarginResult>;
1535
+ getPendingManualRecoveries?(): Promise<PerpsPendingManualRecovery[]>;
1536
+ getRecoveredDispatches?(): Promise<PerpsRecoveredDispatch[]>;
1537
+ acknowledgeRecoveredDispatch?(recoveryId: string): Promise<void>;
1538
+ getPositions(params?: GetPositionsParams): Promise<Position[]>;
1539
+ getAccountState(params?: GetAccountStateParams): Promise<AccountState>;
1540
+ getUserDataSnapshot?(params: GetUserDataSnapshotParams): Promise<PerpsUserDataSnapshot>;
1541
+ getMarkets(params?: GetMarketsParams): Promise<MarketInfo[]>;
1542
+ getMarketDataWithPrices(): Promise<PerpsMarketData[]>;
1543
+ withdraw(params: WithdrawParams): Promise<WithdrawResult>;
1544
+ validateDeposit(params: DepositParams): Promise<{
1545
+ isValid: boolean;
1546
+ error?: string;
1547
+ }>;
1548
+ validateOrder(params: OrderParams): Promise<{
1549
+ isValid: boolean;
1550
+ error?: string;
1551
+ }>;
1552
+ validateClosePosition(params: ClosePositionParams): Promise<{
1553
+ isValid: boolean;
1554
+ error?: string;
1555
+ }>;
1556
+ validateWithdrawal(params: WithdrawParams): Promise<{
1557
+ isValid: boolean;
1558
+ error?: string;
1559
+ }>;
1560
+ /**
1561
+ * Historical trade fills - actual executed trades with exact prices and fees.
1562
+ * Purpose: Track what actually happened when orders were executed.
1563
+ * Example: Market long 1 ETH @ $50,000 → OrderFill with exact execution price and fees
1564
+ */
1565
+ getOrderFills(params?: GetOrderFillsParams, options?: PerpsReadOptions): Promise<OrderFill[]>;
1566
+ /**
1567
+ * Get fills using WebSocket cache first, falling back to REST API.
1568
+ * OPTIMIZATION: Uses cached fills when available (0 API weight), only calls REST on cache miss.
1569
+ * Purpose: Prevent 429 errors during rapid market switching by reusing cached fills.
1570
+ *
1571
+ * @param params - Optional filter parameters (startTime, symbol)
1572
+ */
1573
+ getOrFetchFills(params?: GetOrFetchFillsParams): Promise<OrderFill[]>;
1574
+ /**
1575
+ * Get historical portfolio data
1576
+ * Purpose: Retrieve account value from previous periods for PnL tracking
1577
+ * Example: Get account value from yesterday to calculate 24h percentage change
1578
+ *
1579
+ * @param params - Optional parameters for historical portfolio retrieval
1580
+ */
1581
+ getHistoricalPortfolio(params?: GetHistoricalPortfolioParams): Promise<HistoricalPortfolioResult>;
1582
+ /**
1583
+ * Historical order lifecycle - order placement, modifications, and status changes.
1584
+ * Purpose: Track the complete journey of orders from request to completion.
1585
+ * Example: Limit buy 1 ETH @ $48,000 → Order with status 'open' → 'filled' when executed
1586
+ */
1587
+ getOrders(params?: GetOrdersParams, options?: PerpsReadOptions): Promise<Order[]>;
1588
+ /**
1589
+ * Currently active open orders (real-time status).
1590
+ * Purpose: Show orders that are currently open/pending execution (not historical states).
1591
+ * Different from getOrders() which returns complete historical order lifecycle.
1592
+ * Example: Shows only orders that are actually open right now in the exchange.
1593
+ */
1594
+ getOpenOrders(params?: GetOrdersParams): Promise<Order[]>;
1595
+ /**
1596
+ * Historical funding payments - periodic costs/rewards for holding positions.
1597
+ * Purpose: Track ongoing expenses and income from position maintenance.
1598
+ * Example: Holding long ETH position → Funding payment of -$5.00 (you pay the funding)
1599
+ */
1600
+ getFunding(params?: GetFundingParams, options?: PerpsReadOptions): Promise<Funding[]>;
1601
+ /**
1602
+ * Get user non-funding ledger updates (deposits, transfers, withdrawals)
1603
+ */
1604
+ getUserNonFundingLedgerUpdates(params?: {
1605
+ accountId?: string;
1606
+ startTime?: number;
1607
+ endTime?: number;
1608
+ }): Promise<RawLedgerUpdate[]>;
1609
+ /**
1610
+ * Resolve the provider's currently active account identifier.
1611
+ * Used by the REST coalesce layer so cached payloads are account-scoped
1612
+ * even when callers omit params.accountId (the common hook path) — prevents
1613
+ * one account's data from being served after an account switch within
1614
+ * the coalesce TTL window.
1615
+ */
1616
+ getCurrentAccountId(): Promise<CaipAccountId>;
1617
+ /**
1618
+ * Get user history (deposits, withdrawals, transfers)
1619
+ */
1620
+ getUserHistory(params?: {
1621
+ accountId?: CaipAccountId;
1622
+ startTime?: number;
1623
+ endTime?: number;
1624
+ }): Promise<UserHistoryItem[]>;
1625
+ calculateLiquidationPrice(params: LiquidationPriceParams): Promise<string>;
1626
+ calculateMaintenanceMargin(params: MaintenanceMarginParams): Promise<number>;
1627
+ getMaxLeverage(asset: string, providerId?: PerpsProviderType): Promise<number>;
1628
+ calculateFees(params: FeeCalculationParams): Promise<FeeCalculationResult>;
1629
+ /**
1630
+ * Read-only projection of the position that would remain after the proposed
1631
+ * order. Isolated-margin venues apply selected leverage to the whole
1632
+ * resulting position and use the maintenance tier at liquidation notional.
1633
+ * Cross-margin returns `{ status: 'unsupported', reason: 'cross_margin' }`.
1634
+ */
1635
+ previewPositionModify(params: PositionModifyPreviewParams): Promise<PositionModifyPreviewResult>;
1636
+ subscribeToPrices(params: SubscribePricesParams): () => void;
1637
+ subscribeToPositions(params: SubscribePositionsParams): () => void;
1638
+ subscribeToOrderFills(params: SubscribeOrderFillsParams): () => void;
1639
+ subscribeToOrders(params: SubscribeOrdersParams): () => void;
1640
+ subscribeToAccount(params: SubscribeAccountParams): () => void;
1641
+ subscribeToOICaps(params: SubscribeOICapsParams): () => void;
1642
+ subscribeToCandles(params: SubscribeCandlesParams): () => void;
1643
+ subscribeToOrderBook(params: SubscribeOrderBookParams): () => void;
1644
+ setLiveDataConfig(config: Partial<LiveDataConfig>): void;
1645
+ toggleTestnet(): Promise<ToggleTestnetResult>;
1646
+ initialize(): Promise<InitializeResult>;
1647
+ isReadyToTrade(): Promise<ReadyToTradeResult>;
1648
+ disconnect(): Promise<DisconnectResult>;
1649
+ ping(timeoutMs?: number): Promise<void>;
1650
+ getWebSocketConnectionState?(): WebSocketConnectionState;
1651
+ subscribeToConnectionState?(listener: (state: WebSocketConnectionState, reconnectionAttempt: number) => void): () => void;
1652
+ reconnect?(): Promise<void>;
1653
+ getBlockExplorerUrl(address?: string): string;
1654
+ setUserFeeDiscount?(discountBips: number | undefined): void;
1655
+ setUserFeeResolution?(resolution: PerpsFeeResolution | undefined): void;
1656
+ /** Approve the dedicated subscription builder outside order submission. */
1657
+ approveSubscriptionBuilderFee?(): Promise<boolean>;
1658
+ /**
1659
+ * Get list of available HIP-3 builder-deployed DEXs
1660
+ *
1661
+ * @param params - Optional parameters (reserved for future filters/pagination)
1662
+ * @returns Array of DEX names (empty string '' represents main DEX)
1663
+ */
1664
+ getAvailableDexs?(params?: GetAvailableDexsParams): Promise<string[]>;
1665
+ /**
1666
+ * Fetch historical OHLCV candle data for a symbol.
1667
+ * Optional: only providers that support historical candles need to implement this.
1668
+ */
1669
+ fetchHistoricalCandles?(options: {
1670
+ symbol: string;
1671
+ interval: CandlePeriod;
1672
+ limit?: number;
1673
+ endTime?: number;
1674
+ }): Promise<CandleData>;
1675
+ };
1676
+ /**
1677
+ * Provider identifier type for multi-provider support.
1678
+ * Add new providers here as they are implemented.
1679
+ */
1680
+ export type PerpsProviderType = 'hyperliquid' | 'lighter';
1681
+ /**
1682
+ * Active provider mode for PerpsController state.
1683
+ * - Direct providers: 'hyperliquid', 'lighter'
1684
+ * - 'aggregated': Multi-provider aggregation mode
1685
+ */
1686
+ export type PerpsActiveProviderMode = PerpsProviderType | 'aggregated';
1687
+ /**
1688
+ * Aggregation mode for read operations.
1689
+ * - 'all': Aggregate data from all registered providers
1690
+ * - 'active': Only aggregate from providers with active connections
1691
+ * - 'specific': Aggregate from a specific subset of providers
1692
+ */
1693
+ export type AggregationMode = 'all' | 'active' | 'specific';
1694
+ /**
1695
+ * Routing strategy for write operations.
1696
+ * Phase 1 only supports 'default_provider' - advanced strategies deferred to Phase 3.
1697
+ */
1698
+ export type RoutingStrategy = 'default_provider';
1699
+ /**
1700
+ * Configuration for AggregatedPerpsProvider
1701
+ */
1702
+ export type AggregatedProviderConfig = {
1703
+ /** Map of provider ID to provider instance */
1704
+ providers: Map<PerpsProviderType, PerpsProvider>;
1705
+ /** Default provider for write operations when providerId not specified */
1706
+ defaultProvider: PerpsProviderType;
1707
+ /** Aggregation mode for read operations (default: 'all') */
1708
+ aggregationMode?: AggregationMode;
1709
+ /** Platform dependencies for logging, metrics, etc. */
1710
+ infrastructure: PerpsPlatformDependencies;
1711
+ };
1712
+ /**
1713
+ * Provider-specific error with context for multi-provider error handling
1714
+ */
1715
+ export type ProviderError = {
1716
+ /** Which provider the error originated from */
1717
+ providerId: PerpsProviderType;
1718
+ /** Human-readable error message */
1719
+ message: string;
1720
+ /** Original error object if available */
1721
+ originalError?: Error;
1722
+ /** Whether the operation can be retried */
1723
+ isRetryable?: boolean;
1724
+ };
1725
+ /**
1726
+ * Aggregated account state combining data from multiple providers
1727
+ */
1728
+ export type AggregatedAccountState = {
1729
+ /** Combined totals across all providers */
1730
+ total: AccountState;
1731
+ /** Per-provider breakdown */
1732
+ byProvider: Map<PerpsProviderType, AccountState>;
1733
+ };
1734
+ /**
1735
+ * Injectable logger interface for error reporting.
1736
+ * Allows core package to be platform-agnostic (mobile: Sentry, extension: different impl)
1737
+ */
1738
+ export type PerpsLogger = {
1739
+ error(error: Error, options?: {
1740
+ tags?: Record<string, string | number>;
1741
+ context?: {
1742
+ name: string;
1743
+ data: Record<string, unknown>;
1744
+ };
1745
+ extras?: Record<string, unknown>;
1746
+ }): void;
1747
+ };
1748
+ /**
1749
+ * Analytics events specific to Perps feature.
1750
+ * These are the actual event names sent to analytics backend.
1751
+ * Values must match the corresponding MetaMetricsEvents values in mobile for compatibility.
1752
+ *
1753
+ * When migrating to core monorepo, this enum travels with PerpsController.
1754
+ */
1755
+ export declare enum PerpsAnalyticsEvent {
1756
+ WithdrawalTransaction = "Perp Withdrawal Transaction",
1757
+ TradeTransaction = "Perp Trade Transaction",
1758
+ PositionCloseTransaction = "Perp Position Close Transaction",
1759
+ OrderCancelTransaction = "Perp Order Cancel Transaction",
1760
+ ScreenViewed = "Perp Screen Viewed",
1761
+ UiInteraction = "Perp UI Interaction",
1762
+ RiskManagement = "Perp Risk Management",
1763
+ PerpsError = "Perp Error",
1764
+ AccountSetup = "Perp Account Setup",
1765
+ TransactionConsidered = "Perp Transaction Considered",
1766
+ TradeQuoteReceived = "Perp Trade Quote Received",
1767
+ SearchQuery = "Perp Search Query",
1768
+ SearchResultTapped = "Perp Search Result Tapped",
1769
+ SearchAbandoned = "Perp Search Abandoned"
1770
+ }
1771
+ /**
1772
+ * UTM / discovery attribution context for Perps analytics.
1773
+ *
1774
+ * Held transiently in-memory by PerpsController (never persisted in state) and
1775
+ * merged into analytics event properties so client-originated UTM attribution
1776
+ * can be propagated onto core-emitted transaction events.
1777
+ */
1778
+ export type PerpsAttributionContext = {
1779
+ utmSource?: string;
1780
+ utmMedium?: string;
1781
+ utmCampaign?: string;
1782
+ utmContent?: string;
1783
+ utmTerm?: string;
1784
+ };
1785
+ /**
1786
+ * Perps-specific trace names. These must match TraceName enum values in mobile.
1787
+ * When in core monorepo, this defines the valid trace names for Perps operations.
1788
+ */
1789
+ export type PerpsTraceName = 'Perps Open Position' | 'Perps Close Position' | 'Perps Deposit' | 'Perps Withdraw' | 'Perps Place Order' | 'Perps Edit Order' | 'Perps Cancel Order' | 'Perps Update TP/SL' | 'Perps Update Margin' | 'Perps Flip Position' | 'Perps Market Data Update' | 'Perps Order View' | 'Perps Tab View' | 'Perps Market List View' | 'Perps Position Details View' | 'Perps Adjust Margin View' | 'Perps Order Details View' | 'Perps Order Book View' | 'Perps Flip Position Sheet' | 'Perps Transactions View' | 'Perps Order Fills Fetch' | 'Perps Orders Fetch' | 'Perps Funding Fetch' | 'Perps Get Positions' | 'Perps Get Account State' | 'Perps Get Historical Portfolio' | 'Perps Get Markets' | 'Perps Get Market Data With Prices' | 'Perps Fetch Historical Candles' | 'Perps WebSocket Connected' | 'Perps WebSocket Disconnected' | 'Perps WebSocket First Positions' | 'Perps WebSocket First Orders' | 'Perps WebSocket First Account' | 'Perps Data Lake Report' | 'Perps Rewards API Call' | 'Perps Close Position View' | 'Perps Withdraw View' | 'Perps Connection Establishment' | 'Perps Account Switch Reconnection' | 'Perps Market Data Preload' | 'Perps User Data Preload';
1790
+ /**
1791
+ * Perps trace name constants. Values match TraceName enum in mobile.
1792
+ * When in core, these ARE the source of truth - mobile will re-export from core.
1793
+ */
1794
+ export declare const PerpsTraceNames: {
1795
+ readonly PlaceOrder: 'Perps Place Order';
1796
+ readonly EditOrder: 'Perps Edit Order';
1797
+ readonly CancelOrder: 'Perps Cancel Order';
1798
+ readonly ClosePosition: 'Perps Close Position';
1799
+ readonly UpdateTpsl: 'Perps Update TP/SL';
1800
+ readonly UpdateMargin: 'Perps Update Margin';
1801
+ readonly FlipPosition: 'Perps Flip Position';
1802
+ readonly Withdraw: 'Perps Withdraw';
1803
+ readonly Deposit: 'Perps Deposit';
1804
+ readonly GetPositions: 'Perps Get Positions';
1805
+ readonly GetAccountState: 'Perps Get Account State';
1806
+ readonly GetMarkets: 'Perps Get Markets';
1807
+ readonly GetMarketDataWithPrices: 'Perps Get Market Data With Prices';
1808
+ readonly OrderFillsFetch: 'Perps Order Fills Fetch';
1809
+ readonly OrdersFetch: 'Perps Orders Fetch';
1810
+ readonly FundingFetch: 'Perps Funding Fetch';
1811
+ readonly GetHistoricalPortfolio: 'Perps Get Historical Portfolio';
1812
+ readonly FetchHistoricalCandles: 'Perps Fetch Historical Candles';
1813
+ readonly DataLakeReport: 'Perps Data Lake Report';
1814
+ readonly WebsocketConnected: 'Perps WebSocket Connected';
1815
+ readonly WebsocketDisconnected: 'Perps WebSocket Disconnected';
1816
+ readonly WebsocketFirstPositions: 'Perps WebSocket First Positions';
1817
+ readonly WebsocketFirstOrders: 'Perps WebSocket First Orders';
1818
+ readonly WebsocketFirstAccount: 'Perps WebSocket First Account';
1819
+ readonly RewardsApiCall: 'Perps Rewards API Call';
1820
+ readonly ConnectionEstablishment: 'Perps Connection Establishment';
1821
+ readonly AccountSwitchReconnection: 'Perps Account Switch Reconnection';
1822
+ readonly MarketDataPreload: 'Perps Market Data Preload';
1823
+ readonly UserDataPreload: 'Perps User Data Preload';
1824
+ };
1825
+ /**
1826
+ * Perps trace operation constants. Values match TraceOperation enum in mobile.
1827
+ * These categorize traces by type of operation for Sentry/observability filtering.
1828
+ */
1829
+ export declare const PerpsTraceOperations: {
1830
+ readonly Operation: 'perps.operation';
1831
+ readonly OrderSubmission: 'perps.order_submission';
1832
+ readonly PositionManagement: 'perps.position_management';
1833
+ readonly MarketData: 'perps.market_data';
1834
+ };
1835
+ /**
1836
+ * Values allowed in trace data/tags. Matches Sentry's TraceValue type.
1837
+ */
1838
+ export type PerpsTraceValue = string | number | boolean;
1839
+ /**
1840
+ * Properties allowed in analytics events. More constrained than unknown.
1841
+ * Named PerpsAnalyticsProperties to avoid conflict with PERPS_EVENT_PROPERTY
1842
+ * constant object from eventNames.ts (which contains property key names).
1843
+ */
1844
+ export type PerpsAnalyticsProperties = Record<string, string | number | boolean | Record<string, string> | null | undefined>;
1845
+ /**
1846
+ * Injectable metrics interface for analytics.
1847
+ * Allows core package to work with different analytics backends.
1848
+ */
1849
+ export type PerpsMetrics = {
1850
+ isEnabled(): boolean;
1851
+ /**
1852
+ * Track a Perps-specific analytics event with properties.
1853
+ * This abstracts away the MetricsEventBuilder pattern used in mobile.
1854
+ *
1855
+ * @param event - The Perps analytics event type (enum with actual event name values)
1856
+ * @param properties - Type-safe key-value properties to attach to the event
1857
+ */
1858
+ trackPerpsEvent(event: PerpsAnalyticsEvent, properties: PerpsAnalyticsProperties): void;
1859
+ };
1860
+ /**
1861
+ * Injectable debug logger for development logging.
1862
+ * Only logs in development mode.
1863
+ * Accepts `unknown` to allow logging error objects from catch blocks.
1864
+ */
1865
+ export type PerpsDebugLogger = {
1866
+ log(...args: unknown[]): void;
1867
+ };
1868
+ /**
1869
+ * Injectable stream manager interface for pause/resume during critical operations.
1870
+ *
1871
+ * WHY THIS IS NEEDED:
1872
+ * PerpsStreamManager is a React-based mobile-specific singleton that:
1873
+ * - Uses React Context for subscription management
1874
+ * - Uses react-native-performance for tracing
1875
+ * - Directly accesses Engine.context (mobile singleton pattern)
1876
+ * - Manages WebSocket connections with throttling/caching
1877
+ *
1878
+ * PerpsController only needs pause/resume during critical operations (withStreamPause method)
1879
+ * to prevent stale UI updates during batch operations. The minimal interface allows:
1880
+ * - Mobile: Wrap existing singleton (streamManager[channel].pause())
1881
+ * - Extension: Implement with whatever streaming solution they use
1882
+ */
1883
+ /**
1884
+ * Injectable stream manager interface for pause/resume during critical operations.
1885
+ *
1886
+ * WHY THIS IS NEEDED:
1887
+ * PerpsStreamManager is a React-based mobile-specific singleton that:
1888
+ * - Uses React Context for subscription management
1889
+ * - Uses react-native-performance for tracing
1890
+ * - Directly accesses Engine.context (mobile singleton pattern)
1891
+ * - Manages WebSocket connections with throttling/caching
1892
+ *
1893
+ * PerpsController only needs pause/resume during critical operations (withStreamPause method)
1894
+ * to prevent stale UI updates during batch operations. The minimal interface allows:
1895
+ * - Mobile: Wrap existing singleton (streamManager[channel].pause())
1896
+ * - Extension: Implement with whatever streaming solution they use
1897
+ */
1898
+ export type PerpsStreamManager = {
1899
+ pauseChannel(channel: string): void;
1900
+ resumeChannel(channel: string): void;
1901
+ clearAllChannels(): void;
1902
+ };
1903
+ /**
1904
+ * Injectable performance monitor interface.
1905
+ * Wraps react-native-performance or browser Performance API.
1906
+ */
1907
+ export type PerpsPerformance = {
1908
+ now(): number;
1909
+ /**
1910
+ * Optional platform hook invoked once after constructor disk hydration.
1911
+ * Receives `performance.now()` — not a Sentry write.
1912
+ */
1913
+ onControllerConstructed?: (monotonicMs: number) => void;
1914
+ };
1915
+ type PerpsSetMeasurement = ((name: string, value: number, unit: string) => void) & ((name: string, value: number, unit: string, id: string) => void);
1916
+ /**
1917
+ * Injectable tracer interface for Sentry/observability tracing.
1918
+ * Services use this to create spans and measure operation durations.
1919
+ *
1920
+ * Note: trace() returns void because services use name/id pairs to identify traces.
1921
+ * The actual span management is handled internally by the platform adapter.
1922
+ */
1923
+ export type PerpsTracer = {
1924
+ trace(params: {
1925
+ name: PerpsTraceName;
1926
+ id: string;
1927
+ op: string;
1928
+ tags?: Record<string, PerpsTraceValue>;
1929
+ data?: Record<string, PerpsTraceValue>;
1930
+ }): void;
1931
+ endTrace(params: {
1932
+ name: PerpsTraceName;
1933
+ id: string;
1934
+ data?: Record<string, PerpsTraceValue>;
1935
+ }): void;
1936
+ setMeasurement: PerpsSetMeasurement;
1937
+ addBreadcrumb(breadcrumb: {
1938
+ category: string;
1939
+ message: string;
1940
+ level: 'fatal' | 'error' | 'warning' | 'log' | 'info' | 'debug';
1941
+ data?: Record<string, unknown>;
1942
+ }): void;
1943
+ };
1944
+ /**
1945
+ * Minimal typed-message params passed to keyring for EIP-712 signing.
1946
+ * Structurally matches KeyringController's TypedMessageParams.
1947
+ */
1948
+ export type PerpsTypedMessageParams = {
1949
+ from: string;
1950
+ data: unknown;
1951
+ };
1952
+ /**
1953
+ * Minimal transaction params passed to TransactionController.addTransaction.
1954
+ * Only the fields PerpsController actually sets.
1955
+ */
1956
+ export type PerpsTransactionParams = {
1957
+ from: string;
1958
+ to?: string;
1959
+ value?: string;
1960
+ data?: string;
1961
+ gas?: string;
1962
+ };
1963
+ /**
1964
+ * Options passed to TransactionController.addTransaction.
1965
+ */
1966
+ export type PerpsAddTransactionOptions = {
1967
+ networkClientId: string;
1968
+ origin?: string;
1969
+ type?: string;
1970
+ skipInitialGasEstimate?: boolean;
1971
+ };
1972
+ /**
1973
+ * Minimal account shape read from AccountTreeController.
1974
+ * Only the fields PerpsController and its services actually use.
1975
+ */
1976
+ export type PerpsInternalAccount = {
1977
+ address: string;
1978
+ type: string;
1979
+ id: string;
1980
+ };
1981
+ /**
1982
+ * Minimal remote feature flag state shape.
1983
+ * Only the remoteFeatureFlags record is needed by PerpsController.
1984
+ */
1985
+ export type PerpsRemoteFeatureFlagState = {
1986
+ remoteFeatureFlags: Record<string, unknown>;
1987
+ };
1988
+ /**
1989
+ * Injectable interface for the Terminal-market service.
1990
+ *
1991
+ * `MarketDataService` programs against this contract so the concrete
1992
+ * `TerminalMarketService` class (which lives in `services/`) never leaks
1993
+ * into the types barrel — callers can supply any implementation that
1994
+ * satisfies the shape (production, stub, mock, etc.).
1995
+ */
1996
+ export type PerpsTerminalMarketService = {
1997
+ fetchMarkets(): Promise<{
1998
+ markets: MarketInfo[];
1999
+ metadata: Map<string, TerminalAssetMetadata>;
2000
+ }>;
2001
+ clearCache(): void;
2002
+ logError(error: unknown, method: string): void;
2003
+ fetchGlobalSnapshot?(request: PerpsGlobalSnapshotRequest): Promise<PerpsGlobalSnapshotResult>;
2004
+ };
2005
+ /** Exact identity a client expects from an atomic global Perps snapshot. */
2006
+ export type PerpsGlobalSnapshotRequest = {
2007
+ provider: 'hyperliquid';
2008
+ network: 'mainnet' | 'testnet';
2009
+ enabledDexes: string[];
2010
+ };
2011
+ /** Validated snapshot data and its source-bounded expiry. */
2012
+ export type PerpsGlobalSnapshotResult = {
2013
+ markets: PerpsMarketData[];
2014
+ expiresAt: number;
2015
+ };
2016
+ /**
2017
+ * Platform dependencies for PerpsController and services.
2018
+ *
2019
+ * Architecture:
2020
+ * - Observability: logger, debugLogger, metrics, performance, tracer
2021
+ * - Platform: streamManager (mobile/extension specific)
2022
+ * - Cache: cache invalidation for standalone queries
2023
+ * - Rewards: delegated rewards interaction (DI — no RewardsController in Core yet)
2024
+ *
2025
+ * Cross-controller communication uses the messenger pattern (messenger.call).
2026
+ * Only rewards remains as DI because RewardsController is not yet in Core.
2027
+ */
2028
+ export type PerpsPlatformDependencies = {
2029
+ logger: PerpsLogger;
2030
+ debugLogger: PerpsDebugLogger;
2031
+ metrics: PerpsMetrics;
2032
+ performance: PerpsPerformance;
2033
+ tracer: PerpsTracer;
2034
+ streamManager: PerpsStreamManager;
2035
+ featureFlags: {
2036
+ /**
2037
+ * Validate a version-gated feature flag against current app version.
2038
+ * Returns true if flag is enabled AND app meets minimum version,
2039
+ * false if flag is disabled, or undefined if flag is misconfigured/overridden.
2040
+ *
2041
+ * Platform-specific because it uses react-native-device-info (mobile)
2042
+ * or browser APIs (extension) to get the app version.
2043
+ */
2044
+ validateVersionGated(flag: VersionGatedFeatureFlag): boolean | undefined;
2045
+ };
2046
+ marketDataFormatters: MarketDataFormatters;
2047
+ cacheInvalidator: PerpsCacheInvalidator;
2048
+ diskCache: {
2049
+ getItem(key: string): Promise<string | null>;
2050
+ getItemSync?(key: string): string | null;
2051
+ setItem(key: string, value: string): Promise<void>;
2052
+ removeItem(key: string): Promise<void>;
2053
+ };
2054
+ terminalApi?: {
2055
+ /** Full endpoint URL for the legacy perpetuals market-data endpoint. */
2056
+ marketDataUrl?: string;
2057
+ /** Full endpoint URL for the schema-v2 atomic global Perps snapshot. */
2058
+ globalSnapshotUrl?: string;
2059
+ };
2060
+ /** @deprecated Use `terminalApi.marketDataUrl`. */
2061
+ terminalApiUrl?: string;
2062
+ /**
2063
+ * Optional Terminal-market service instance for fetching structured market
2064
+ * metadata from the MetaMask Terminal API.
2065
+ *
2066
+ * When provided, `MarketDataService` uses this service to attempt the
2067
+ * Terminal API path before falling back to the provider.
2068
+ * Clients that do not use the Terminal API can omit this field.
2069
+ */
2070
+ terminalMarketService?: PerpsTerminalMarketService;
2071
+ rewards: {
2072
+ /**
2073
+ * Get fee discount for an account from the RewardsController.
2074
+ * Returns discount in basis points (e.g., 6500 = 65% discount), or null
2075
+ * when subscription state hasn't hydrated yet — callers should skip
2076
+ * caching null results and retry on the next fee calculation.
2077
+ *
2078
+ * Pass the perps MetaMask builder base fee in bips so the rewards
2079
+ * controller can convert an absolute VIP fee into a discount fraction.
2080
+ */
2081
+ getPerpsDiscountForAccount(caipAccountId: `${string}:${string}:${string}`, baseFeeBips: number): Promise<number | null>;
2082
+ };
2083
+ /**
2084
+ * Optional subscription source for the unified fee resolver.
2085
+ *
2086
+ * The client owns the Profile JWT, so it performs
2087
+ * `GET /v1/profiles/{profileId}/benefits` and hands the perps controller the
2088
+ * parsed body. The controller caches the result stale-while-revalidate and
2089
+ * never awaits this call on the order-signing path.
2090
+ *
2091
+ * Omit it entirely on clients that do not ship the subscription waiver; the
2092
+ * resolver then falls back to the rewards and default sources.
2093
+ */
2094
+ subscription?: {
2095
+ /**
2096
+ * Read the current profile's subscription benefits.
2097
+ * Resolve `null` when there is no subscription to report (signed out, no
2098
+ * profile). Rejections are tolerated: the resolver keeps the previous
2099
+ * snapshot and never grants the waiver from a failed read.
2100
+ */
2101
+ getPerpsBenefits(): Promise<PerpsSubscriptionBenefits | null>;
2102
+ };
2103
+ };
2104
+ /**
2105
+ * Cache types that can be invalidated.
2106
+ * Used by standalone query caches (e.g., usePerpsPositionForAsset).
2107
+ */
2108
+ export type PerpsCacheType = 'positions' | 'accountState' | 'markets';
2109
+ /**
2110
+ * Parameters for invalidating a specific cache type.
2111
+ */
2112
+ export type InvalidateCacheParams = {
2113
+ /** The type of cache to invalidate */
2114
+ cacheType: PerpsCacheType;
2115
+ };
2116
+ /**
2117
+ * Cache invalidation interface for standalone query caches.
2118
+ * Allows services to signal when data has changed without depending on
2119
+ * mobile-specific implementations.
2120
+ */
2121
+ export type PerpsCacheInvalidator = {
2122
+ /**
2123
+ * Invalidate a specific cache type.
2124
+ * Notifies all subscribers that cached data is stale.
2125
+ */
2126
+ invalidate(params: InvalidateCacheParams): void;
2127
+ /**
2128
+ * Invalidate all cache types.
2129
+ */
2130
+ invalidateAll(): void;
2131
+ };
2132
+ /**
2133
+ * Injectable formatters for market data transformation.
2134
+ * Decouples marketDataTransform from mobile-specific intl/formatUtils imports.
2135
+ *
2136
+ * Range configs are opaque (unknown[]) because the concrete type
2137
+ * (FiatRangeConfig on mobile) is platform-specific. The formatter
2138
+ * implementation casts internally.
2139
+ */
2140
+ export type MarketDataFormatters = {
2141
+ /** Format a number as a USD volume string (e.g., '$1.2B', '$850M') */
2142
+ formatVolume(value: number): string;
2143
+ /** Format a number as a USD fiat string with adaptive precision */
2144
+ formatPerpsFiat(value: number, options?: {
2145
+ ranges?: unknown[];
2146
+ }): string;
2147
+ /** Format a number as a percentage string (e.g., '2.50%', '-1.80%') */
2148
+ formatPercentage(percent: number): string;
2149
+ /** Universal price ranges for formatting (opaque to portable code) */
2150
+ priceRangesUniversal: unknown[];
2151
+ };
2152
+ /**
2153
+ * Minimal payment token for deposit flow.
2154
+ * Only the fields actually used by PerpsController are included.
2155
+ * Replaces the mobile-only AssetType (which extends TokenI and uses ImageSourcePropType).
2156
+ */
2157
+ export type PaymentToken = {
2158
+ description?: string;
2159
+ address: string;
2160
+ chainId?: string;
2161
+ symbol?: string;
2162
+ };
2163
+ /**
2164
+ * Selected pay-with token shape used in PerpsController state, pending trade config,
2165
+ * selectors, and UI hooks. Use this type everywhere this shape is needed.
2166
+ */
2167
+ export type PerpsSelectedPaymentToken = {
2168
+ description?: string;
2169
+ address: string;
2170
+ chainId: string;
2171
+ symbol?: string;
2172
+ };
2173
+ /**
2174
+ * Structure for a version-gated feature flag from LaunchDarkly.
2175
+ * Portable: no platform-specific imports.
2176
+ */
2177
+ export type VersionGatedFeatureFlag = {
2178
+ enabled: boolean;
2179
+ minimumVersion: string;
2180
+ };
2181
+ /**
2182
+ * Type guard for VersionGatedFeatureFlag.
2183
+ * Pure logic, no platform dependencies.
2184
+ *
2185
+ * @param value - The value to check.
2186
+ * @returns True if the value is a VersionGatedFeatureFlag.
2187
+ */
2188
+ export declare function isVersionGatedFeatureFlag(value: unknown): value is VersionGatedFeatureFlag;
2189
+ export type * from './perps-types.js';
2190
+ export * from './transactionTypes.js';
2191
+ export type { AssetPosition, SpotBalance, PerpsUniverse, PerpsAssetCtx, PredictedFunding, FrontendOrder, SDKOrderParams, ClearinghouseStateResponse, SpotClearinghouseStateResponse, MetaResponse, FrontendOpenOrdersResponse, AllMidsResponse, MetaAndAssetCtxsResponse, PredictedFundingsResponse, SpotMetaResponse, } from './hyperliquid-types.js';
2192
+ //# sourceMappingURL=index.d.ts.map