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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (482) hide show
  1. package/CHANGELOG.md +30 -2
  2. package/dist/PerpsController.cjs +3077 -65
  3. package/dist/PerpsController.cjs.map +1 -1
  4. package/dist/PerpsController.d.cts +969 -82
  5. package/dist/PerpsController.d.cts.map +1 -1
  6. package/dist/PerpsController.d.mts +969 -82
  7. package/dist/PerpsController.d.mts.map +1 -1
  8. package/dist/PerpsController.mjs +3073 -62
  9. package/dist/PerpsController.mjs.map +1 -1
  10. package/dist/aggregation/SubscriptionMultiplexer.cjs +441 -0
  11. package/dist/aggregation/SubscriptionMultiplexer.cjs.map +1 -0
  12. package/dist/aggregation/SubscriptionMultiplexer.d.cts +171 -0
  13. package/dist/aggregation/SubscriptionMultiplexer.d.cts.map +1 -0
  14. package/dist/aggregation/SubscriptionMultiplexer.d.mts +171 -0
  15. package/dist/aggregation/SubscriptionMultiplexer.d.mts.map +1 -0
  16. package/dist/aggregation/SubscriptionMultiplexer.mjs +437 -0
  17. package/dist/aggregation/SubscriptionMultiplexer.mjs.map +1 -0
  18. package/dist/aggregation/index.cjs +9 -0
  19. package/dist/aggregation/index.cjs.map +1 -0
  20. package/dist/aggregation/index.d.cts +6 -0
  21. package/dist/aggregation/index.d.cts.map +1 -0
  22. package/dist/aggregation/index.d.mts +6 -0
  23. package/dist/aggregation/index.d.mts.map +1 -0
  24. package/dist/aggregation/index.mjs +5 -0
  25. package/dist/aggregation/index.mjs.map +1 -0
  26. package/dist/constants/chartConfig.cjs +227 -0
  27. package/dist/constants/chartConfig.cjs.map +1 -0
  28. package/dist/constants/chartConfig.d.cts +216 -0
  29. package/dist/constants/chartConfig.d.cts.map +1 -0
  30. package/dist/constants/chartConfig.d.mts +216 -0
  31. package/dist/constants/chartConfig.d.mts.map +1 -0
  32. package/dist/constants/chartConfig.mjs +221 -0
  33. package/dist/constants/chartConfig.mjs.map +1 -0
  34. package/dist/constants/eventNames.cjs +436 -0
  35. package/dist/constants/eventNames.cjs.map +1 -0
  36. package/dist/constants/eventNames.d.cts +387 -0
  37. package/dist/constants/eventNames.d.cts.map +1 -0
  38. package/dist/constants/eventNames.d.mts +387 -0
  39. package/dist/constants/eventNames.d.mts.map +1 -0
  40. package/dist/constants/eventNames.mjs +433 -0
  41. package/dist/constants/eventNames.mjs.map +1 -0
  42. package/dist/constants/hyperLiquidConfig.cjs +380 -0
  43. package/dist/constants/hyperLiquidConfig.cjs.map +1 -0
  44. package/dist/constants/hyperLiquidConfig.d.cts +236 -0
  45. package/dist/constants/hyperLiquidConfig.d.cts.map +1 -0
  46. package/dist/constants/hyperLiquidConfig.d.mts +236 -0
  47. package/dist/constants/hyperLiquidConfig.d.mts.map +1 -0
  48. package/dist/constants/hyperLiquidConfig.mjs +371 -0
  49. package/dist/constants/hyperLiquidConfig.mjs.map +1 -0
  50. package/dist/constants/index.cjs +28 -0
  51. package/dist/constants/index.cjs.map +1 -0
  52. package/dist/constants/index.d.cts +12 -0
  53. package/dist/constants/index.d.cts.map +1 -0
  54. package/dist/constants/index.d.mts +12 -0
  55. package/dist/constants/index.d.mts.map +1 -0
  56. package/dist/constants/index.mjs +12 -0
  57. package/dist/constants/index.mjs.map +1 -0
  58. package/dist/constants/myxConfig.cjs +229 -0
  59. package/dist/constants/myxConfig.cjs.map +1 -0
  60. package/dist/constants/myxConfig.d.cts +106 -0
  61. package/dist/constants/myxConfig.d.cts.map +1 -0
  62. package/dist/constants/myxConfig.d.mts +106 -0
  63. package/dist/constants/myxConfig.d.mts.map +1 -0
  64. package/dist/constants/myxConfig.mjs +219 -0
  65. package/dist/constants/myxConfig.mjs.map +1 -0
  66. package/dist/constants/orderTypes.cjs +31 -0
  67. package/dist/constants/orderTypes.cjs.map +1 -0
  68. package/dist/constants/orderTypes.d.cts +19 -0
  69. package/dist/constants/orderTypes.d.cts.map +1 -0
  70. package/dist/constants/orderTypes.d.mts +19 -0
  71. package/dist/constants/orderTypes.d.mts.map +1 -0
  72. package/dist/constants/orderTypes.mjs +27 -0
  73. package/dist/constants/orderTypes.mjs.map +1 -0
  74. package/dist/constants/performanceMetrics.cjs +63 -0
  75. package/dist/constants/performanceMetrics.cjs.map +1 -0
  76. package/dist/constants/performanceMetrics.d.cts +46 -0
  77. package/dist/constants/performanceMetrics.d.cts.map +1 -0
  78. package/dist/constants/performanceMetrics.d.mts +46 -0
  79. package/dist/constants/performanceMetrics.d.mts.map +1 -0
  80. package/dist/constants/performanceMetrics.mjs +60 -0
  81. package/dist/constants/performanceMetrics.mjs.map +1 -0
  82. package/dist/constants/perpsConfig.cjs +295 -0
  83. package/dist/constants/perpsConfig.cjs.map +1 -0
  84. package/dist/constants/perpsConfig.d.cts +221 -0
  85. package/dist/constants/perpsConfig.d.cts.map +1 -0
  86. package/dist/constants/perpsConfig.d.mts +221 -0
  87. package/dist/constants/perpsConfig.d.mts.map +1 -0
  88. package/dist/constants/perpsConfig.mjs +292 -0
  89. package/dist/constants/perpsConfig.mjs.map +1 -0
  90. package/dist/constants/transactionsHistoryConfig.cjs +19 -0
  91. package/dist/constants/transactionsHistoryConfig.cjs.map +1 -0
  92. package/dist/constants/transactionsHistoryConfig.d.cts +16 -0
  93. package/dist/constants/transactionsHistoryConfig.d.cts.map +1 -0
  94. package/dist/constants/transactionsHistoryConfig.d.mts +16 -0
  95. package/dist/constants/transactionsHistoryConfig.d.mts.map +1 -0
  96. package/dist/constants/transactionsHistoryConfig.mjs +16 -0
  97. package/dist/constants/transactionsHistoryConfig.mjs.map +1 -0
  98. package/dist/index.cjs +63 -1
  99. package/dist/index.cjs.map +1 -1
  100. package/dist/index.d.cts +38 -2
  101. package/dist/index.d.cts.map +1 -1
  102. package/dist/index.d.mts +38 -2
  103. package/dist/index.d.mts.map +1 -1
  104. package/dist/index.mjs +46 -1
  105. package/dist/index.mjs.map +1 -1
  106. package/dist/perpsErrorCodes.cjs +80 -0
  107. package/dist/perpsErrorCodes.cjs.map +1 -0
  108. package/dist/perpsErrorCodes.d.cts +65 -0
  109. package/dist/perpsErrorCodes.d.cts.map +1 -0
  110. package/dist/perpsErrorCodes.d.mts +65 -0
  111. package/dist/perpsErrorCodes.d.mts.map +1 -0
  112. package/dist/perpsErrorCodes.mjs +77 -0
  113. package/dist/perpsErrorCodes.mjs.map +1 -0
  114. package/dist/providers/AggregatedPerpsProvider.cjs +508 -0
  115. package/dist/providers/AggregatedPerpsProvider.cjs.map +1 -0
  116. package/dist/providers/AggregatedPerpsProvider.d.cts +171 -0
  117. package/dist/providers/AggregatedPerpsProvider.d.cts.map +1 -0
  118. package/dist/providers/AggregatedPerpsProvider.d.mts +171 -0
  119. package/dist/providers/AggregatedPerpsProvider.d.mts.map +1 -0
  120. package/dist/providers/AggregatedPerpsProvider.mjs +504 -0
  121. package/dist/providers/AggregatedPerpsProvider.mjs.map +1 -0
  122. package/dist/providers/HyperLiquidProvider.cjs +5679 -0
  123. package/dist/providers/HyperLiquidProvider.cjs.map +1 -0
  124. package/dist/providers/HyperLiquidProvider.d.cts +516 -0
  125. package/dist/providers/HyperLiquidProvider.d.cts.map +1 -0
  126. package/dist/providers/HyperLiquidProvider.d.mts +516 -0
  127. package/dist/providers/HyperLiquidProvider.d.mts.map +1 -0
  128. package/dist/providers/HyperLiquidProvider.mjs +5675 -0
  129. package/dist/providers/HyperLiquidProvider.mjs.map +1 -0
  130. package/dist/providers/MYXProvider.cjs +514 -0
  131. package/dist/providers/MYXProvider.cjs.map +1 -0
  132. package/dist/providers/MYXProvider.d.cts +105 -0
  133. package/dist/providers/MYXProvider.d.cts.map +1 -0
  134. package/dist/providers/MYXProvider.d.mts +105 -0
  135. package/dist/providers/MYXProvider.d.mts.map +1 -0
  136. package/dist/providers/MYXProvider.mjs +510 -0
  137. package/dist/providers/MYXProvider.mjs.map +1 -0
  138. package/dist/routing/ProviderRouter.cjs +154 -0
  139. package/dist/routing/ProviderRouter.cjs.map +1 -0
  140. package/dist/routing/ProviderRouter.d.cts +112 -0
  141. package/dist/routing/ProviderRouter.d.cts.map +1 -0
  142. package/dist/routing/ProviderRouter.d.mts +112 -0
  143. package/dist/routing/ProviderRouter.d.mts.map +1 -0
  144. package/dist/routing/ProviderRouter.mjs +150 -0
  145. package/dist/routing/ProviderRouter.mjs.map +1 -0
  146. package/dist/routing/index.cjs +9 -0
  147. package/dist/routing/index.cjs.map +1 -0
  148. package/dist/routing/index.d.cts +6 -0
  149. package/dist/routing/index.d.cts.map +1 -0
  150. package/dist/routing/index.d.mts +6 -0
  151. package/dist/routing/index.d.mts.map +1 -0
  152. package/dist/routing/index.mjs +5 -0
  153. package/dist/routing/index.mjs.map +1 -0
  154. package/dist/selectors.cjs +166 -0
  155. package/dist/selectors.cjs.map +1 -0
  156. package/dist/selectors.d.cts +362 -0
  157. package/dist/selectors.d.cts.map +1 -0
  158. package/dist/selectors.d.mts +362 -0
  159. package/dist/selectors.d.mts.map +1 -0
  160. package/dist/selectors.mjs +158 -0
  161. package/dist/selectors.mjs.map +1 -0
  162. package/dist/services/AccountService.cjs +324 -0
  163. package/dist/services/AccountService.cjs.map +1 -0
  164. package/dist/services/AccountService.d.cts +56 -0
  165. package/dist/services/AccountService.d.cts.map +1 -0
  166. package/dist/services/AccountService.d.mts +56 -0
  167. package/dist/services/AccountService.d.mts.map +1 -0
  168. package/dist/services/AccountService.mjs +320 -0
  169. package/dist/services/AccountService.mjs.map +1 -0
  170. package/dist/services/DataLakeService.cjs +233 -0
  171. package/dist/services/DataLakeService.cjs.map +1 -0
  172. package/dist/services/DataLakeService.d.cts +51 -0
  173. package/dist/services/DataLakeService.d.cts.map +1 -0
  174. package/dist/services/DataLakeService.d.mts +51 -0
  175. package/dist/services/DataLakeService.d.mts.map +1 -0
  176. package/dist/services/DataLakeService.mjs +229 -0
  177. package/dist/services/DataLakeService.mjs.map +1 -0
  178. package/dist/services/DepositService.cjs +98 -0
  179. package/dist/services/DepositService.cjs.map +1 -0
  180. package/dist/services/DepositService.d.cts +39 -0
  181. package/dist/services/DepositService.d.cts.map +1 -0
  182. package/dist/services/DepositService.d.mts +39 -0
  183. package/dist/services/DepositService.d.mts.map +1 -0
  184. package/dist/services/DepositService.mjs +94 -0
  185. package/dist/services/DepositService.mjs.map +1 -0
  186. package/dist/services/EligibilityService.cjs +173 -0
  187. package/dist/services/EligibilityService.cjs.map +1 -0
  188. package/dist/services/EligibilityService.d.cts +39 -0
  189. package/dist/services/EligibilityService.d.cts.map +1 -0
  190. package/dist/services/EligibilityService.d.mts +39 -0
  191. package/dist/services/EligibilityService.d.mts.map +1 -0
  192. package/dist/services/EligibilityService.mjs +169 -0
  193. package/dist/services/EligibilityService.mjs.map +1 -0
  194. package/dist/services/FeatureFlagConfigurationService.cjs +257 -0
  195. package/dist/services/FeatureFlagConfigurationService.cjs.map +1 -0
  196. package/dist/services/FeatureFlagConfigurationService.d.cts +73 -0
  197. package/dist/services/FeatureFlagConfigurationService.d.cts.map +1 -0
  198. package/dist/services/FeatureFlagConfigurationService.d.mts +73 -0
  199. package/dist/services/FeatureFlagConfigurationService.d.mts.map +1 -0
  200. package/dist/services/FeatureFlagConfigurationService.mjs +253 -0
  201. package/dist/services/FeatureFlagConfigurationService.mjs.map +1 -0
  202. package/dist/services/HyperLiquidClientService.cjs +867 -0
  203. package/dist/services/HyperLiquidClientService.cjs.map +1 -0
  204. package/dist/services/HyperLiquidClientService.d.cts +214 -0
  205. package/dist/services/HyperLiquidClientService.d.cts.map +1 -0
  206. package/dist/services/HyperLiquidClientService.d.mts +214 -0
  207. package/dist/services/HyperLiquidClientService.d.mts.map +1 -0
  208. package/dist/services/HyperLiquidClientService.mjs +862 -0
  209. package/dist/services/HyperLiquidClientService.mjs.map +1 -0
  210. package/dist/services/HyperLiquidSubscriptionService.cjs +2199 -0
  211. package/dist/services/HyperLiquidSubscriptionService.cjs.map +1 -0
  212. package/dist/services/HyperLiquidSubscriptionService.d.cts +187 -0
  213. package/dist/services/HyperLiquidSubscriptionService.d.cts.map +1 -0
  214. package/dist/services/HyperLiquidSubscriptionService.d.mts +187 -0
  215. package/dist/services/HyperLiquidSubscriptionService.d.mts.map +1 -0
  216. package/dist/services/HyperLiquidSubscriptionService.mjs +2195 -0
  217. package/dist/services/HyperLiquidSubscriptionService.mjs.map +1 -0
  218. package/dist/services/HyperLiquidWalletService.cjs +163 -0
  219. package/dist/services/HyperLiquidWalletService.cjs.map +1 -0
  220. package/dist/services/HyperLiquidWalletService.d.cts +78 -0
  221. package/dist/services/HyperLiquidWalletService.d.cts.map +1 -0
  222. package/dist/services/HyperLiquidWalletService.d.mts +78 -0
  223. package/dist/services/HyperLiquidWalletService.d.mts.map +1 -0
  224. package/dist/services/HyperLiquidWalletService.mjs +159 -0
  225. package/dist/services/HyperLiquidWalletService.mjs.map +1 -0
  226. package/dist/services/MYXClientService.cjs +304 -0
  227. package/dist/services/MYXClientService.cjs.map +1 -0
  228. package/dist/services/MYXClientService.d.cts +81 -0
  229. package/dist/services/MYXClientService.d.cts.map +1 -0
  230. package/dist/services/MYXClientService.d.mts +81 -0
  231. package/dist/services/MYXClientService.d.mts.map +1 -0
  232. package/dist/services/MYXClientService.mjs +300 -0
  233. package/dist/services/MYXClientService.mjs.map +1 -0
  234. package/dist/services/MarketDataService.cjs +848 -0
  235. package/dist/services/MarketDataService.cjs.map +1 -0
  236. package/dist/services/MarketDataService.d.cts +291 -0
  237. package/dist/services/MarketDataService.d.cts.map +1 -0
  238. package/dist/services/MarketDataService.d.mts +291 -0
  239. package/dist/services/MarketDataService.d.mts.map +1 -0
  240. package/dist/services/MarketDataService.mjs +844 -0
  241. package/dist/services/MarketDataService.mjs.map +1 -0
  242. package/dist/services/RewardsIntegrationService.cjs +120 -0
  243. package/dist/services/RewardsIntegrationService.cjs.map +1 -0
  244. package/dist/services/RewardsIntegrationService.d.cts +28 -0
  245. package/dist/services/RewardsIntegrationService.d.cts.map +1 -0
  246. package/dist/services/RewardsIntegrationService.d.mts +28 -0
  247. package/dist/services/RewardsIntegrationService.d.mts.map +1 -0
  248. package/dist/services/RewardsIntegrationService.mjs +116 -0
  249. package/dist/services/RewardsIntegrationService.mjs.map +1 -0
  250. package/dist/services/ServiceContext.cjs +3 -0
  251. package/dist/services/ServiceContext.cjs.map +1 -0
  252. package/dist/services/ServiceContext.d.cts +86 -0
  253. package/dist/services/ServiceContext.d.cts.map +1 -0
  254. package/dist/services/ServiceContext.d.mts +86 -0
  255. package/dist/services/ServiceContext.d.mts.map +1 -0
  256. package/dist/services/ServiceContext.mjs +2 -0
  257. package/dist/services/ServiceContext.mjs.map +1 -0
  258. package/dist/services/TradingReadinessCache.cjs +288 -0
  259. package/dist/services/TradingReadinessCache.cjs.map +1 -0
  260. package/dist/services/TradingReadinessCache.d.cts +174 -0
  261. package/dist/services/TradingReadinessCache.d.cts.map +1 -0
  262. package/dist/services/TradingReadinessCache.d.mts +174 -0
  263. package/dist/services/TradingReadinessCache.d.mts.map +1 -0
  264. package/dist/services/TradingReadinessCache.mjs +285 -0
  265. package/dist/services/TradingReadinessCache.mjs.map +1 -0
  266. package/dist/services/TradingService.cjs +1457 -0
  267. package/dist/services/TradingService.cjs.map +1 -0
  268. package/dist/services/TradingService.d.cts +195 -0
  269. package/dist/services/TradingService.d.cts.map +1 -0
  270. package/dist/services/TradingService.d.mts +195 -0
  271. package/dist/services/TradingService.d.mts.map +1 -0
  272. package/dist/services/TradingService.mjs +1453 -0
  273. package/dist/services/TradingService.mjs.map +1 -0
  274. package/dist/types/config.cjs +3 -0
  275. package/dist/types/config.cjs.map +1 -0
  276. package/dist/types/config.d.cts +49 -0
  277. package/dist/types/config.d.cts.map +1 -0
  278. package/dist/types/config.d.mts +49 -0
  279. package/dist/types/config.d.mts.map +1 -0
  280. package/dist/types/config.mjs +2 -0
  281. package/dist/types/config.mjs.map +1 -0
  282. package/dist/types/hyperliquid-types.cjs +3 -0
  283. package/dist/types/hyperliquid-types.cjs.map +1 -0
  284. package/dist/types/hyperliquid-types.d.cts +20 -0
  285. package/dist/types/hyperliquid-types.d.cts.map +1 -0
  286. package/dist/types/hyperliquid-types.d.mts +20 -0
  287. package/dist/types/hyperliquid-types.d.mts.map +1 -0
  288. package/dist/types/hyperliquid-types.mjs +2 -0
  289. package/dist/types/hyperliquid-types.mjs.map +1 -0
  290. package/dist/types/index.cjs +115 -0
  291. package/dist/types/index.cjs.map +1 -0
  292. package/dist/types/index.d.cts +1262 -0
  293. package/dist/types/index.d.cts.map +1 -0
  294. package/dist/types/index.d.mts +1262 -0
  295. package/dist/types/index.d.mts.map +1 -0
  296. package/dist/types/index.mjs +97 -0
  297. package/dist/types/index.mjs.map +1 -0
  298. package/dist/types/messenger.cjs +3 -0
  299. package/dist/types/messenger.cjs.map +1 -0
  300. package/dist/types/messenger.d.cts +27 -0
  301. package/dist/types/messenger.d.cts.map +1 -0
  302. package/dist/types/messenger.d.mts +27 -0
  303. package/dist/types/messenger.d.mts.map +1 -0
  304. package/dist/types/messenger.mjs +2 -0
  305. package/dist/types/messenger.mjs.map +1 -0
  306. package/dist/types/myx-types.cjs +25 -0
  307. package/dist/types/myx-types.cjs.map +1 -0
  308. package/dist/types/myx-types.d.cts +63 -0
  309. package/dist/types/myx-types.d.cts.map +1 -0
  310. package/dist/types/myx-types.d.mts +63 -0
  311. package/dist/types/myx-types.d.mts.map +1 -0
  312. package/dist/types/myx-types.mjs +22 -0
  313. package/dist/types/myx-types.mjs.map +1 -0
  314. package/dist/types/perps-types.cjs +4 -0
  315. package/dist/types/perps-types.cjs.map +1 -0
  316. package/dist/types/perps-types.d.cts +105 -0
  317. package/dist/types/perps-types.d.cts.map +1 -0
  318. package/dist/types/perps-types.d.mts +105 -0
  319. package/dist/types/perps-types.d.mts.map +1 -0
  320. package/dist/types/perps-types.mjs +2 -0
  321. package/dist/types/perps-types.mjs.map +1 -0
  322. package/dist/types/token.cjs +3 -0
  323. package/dist/types/token.cjs.map +1 -0
  324. package/dist/types/token.d.cts +25 -0
  325. package/dist/types/token.d.cts.map +1 -0
  326. package/dist/types/token.d.mts +25 -0
  327. package/dist/types/token.d.mts.map +1 -0
  328. package/dist/types/token.mjs +2 -0
  329. package/dist/types/token.mjs.map +1 -0
  330. package/dist/types/transactionTypes.cjs +28 -0
  331. package/dist/types/transactionTypes.cjs.map +1 -0
  332. package/dist/types/transactionTypes.d.cts +64 -0
  333. package/dist/types/transactionTypes.d.cts.map +1 -0
  334. package/dist/types/transactionTypes.d.mts +64 -0
  335. package/dist/types/transactionTypes.d.mts.map +1 -0
  336. package/dist/types/transactionTypes.mjs +23 -0
  337. package/dist/types/transactionTypes.mjs.map +1 -0
  338. package/dist/utils/accountUtils.cjs +100 -0
  339. package/dist/utils/accountUtils.cjs.map +1 -0
  340. package/dist/utils/accountUtils.d.cts +30 -0
  341. package/dist/utils/accountUtils.d.cts.map +1 -0
  342. package/dist/utils/accountUtils.d.mts +30 -0
  343. package/dist/utils/accountUtils.d.mts.map +1 -0
  344. package/dist/utils/accountUtils.mjs +92 -0
  345. package/dist/utils/accountUtils.mjs.map +1 -0
  346. package/dist/utils/errorUtils.cjs +35 -0
  347. package/dist/utils/errorUtils.cjs.map +1 -0
  348. package/dist/utils/errorUtils.d.cts +15 -0
  349. package/dist/utils/errorUtils.d.cts.map +1 -0
  350. package/dist/utils/errorUtils.d.mts +15 -0
  351. package/dist/utils/errorUtils.d.mts.map +1 -0
  352. package/dist/utils/errorUtils.mjs +31 -0
  353. package/dist/utils/errorUtils.mjs.map +1 -0
  354. package/dist/utils/hyperLiquidAdapter.cjs +331 -0
  355. package/dist/utils/hyperLiquidAdapter.cjs.map +1 -0
  356. package/dist/utils/hyperLiquidAdapter.d.cts +42 -0
  357. package/dist/utils/hyperLiquidAdapter.d.cts.map +1 -0
  358. package/dist/utils/hyperLiquidAdapter.d.mts +42 -0
  359. package/dist/utils/hyperLiquidAdapter.d.mts.map +1 -0
  360. package/dist/utils/hyperLiquidAdapter.mjs +316 -0
  361. package/dist/utils/hyperLiquidAdapter.mjs.map +1 -0
  362. package/dist/utils/hyperLiquidOrderBookProcessor.cjs +83 -0
  363. package/dist/utils/hyperLiquidOrderBookProcessor.cjs.map +1 -0
  364. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts +55 -0
  365. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts.map +1 -0
  366. package/dist/utils/hyperLiquidOrderBookProcessor.d.mts +55 -0
  367. package/dist/utils/hyperLiquidOrderBookProcessor.d.mts.map +1 -0
  368. package/dist/utils/hyperLiquidOrderBookProcessor.mjs +78 -0
  369. package/dist/utils/hyperLiquidOrderBookProcessor.mjs.map +1 -0
  370. package/dist/utils/hyperLiquidValidation.cjs +426 -0
  371. package/dist/utils/hyperLiquidValidation.cjs.map +1 -0
  372. package/dist/utils/hyperLiquidValidation.d.cts +143 -0
  373. package/dist/utils/hyperLiquidValidation.d.cts.map +1 -0
  374. package/dist/utils/hyperLiquidValidation.d.mts +143 -0
  375. package/dist/utils/hyperLiquidValidation.d.mts.map +1 -0
  376. package/dist/utils/hyperLiquidValidation.mjs +413 -0
  377. package/dist/utils/hyperLiquidValidation.mjs.map +1 -0
  378. package/dist/utils/idUtils.cjs +18 -0
  379. package/dist/utils/idUtils.cjs.map +1 -0
  380. package/dist/utils/idUtils.d.cts +6 -0
  381. package/dist/utils/idUtils.d.cts.map +1 -0
  382. package/dist/utils/idUtils.d.mts +6 -0
  383. package/dist/utils/idUtils.d.mts.map +1 -0
  384. package/dist/utils/idUtils.mjs +10 -0
  385. package/dist/utils/idUtils.mjs.map +1 -0
  386. package/dist/utils/index.cjs +59 -0
  387. package/dist/utils/index.cjs.map +1 -0
  388. package/dist/utils/index.d.cts +25 -0
  389. package/dist/utils/index.d.cts.map +1 -0
  390. package/dist/utils/index.d.mts +25 -0
  391. package/dist/utils/index.d.mts.map +1 -0
  392. package/dist/utils/index.mjs +30 -0
  393. package/dist/utils/index.mjs.map +1 -0
  394. package/dist/utils/marketDataTransform.cjs +211 -0
  395. package/dist/utils/marketDataTransform.cjs.map +1 -0
  396. package/dist/utils/marketDataTransform.d.cts +40 -0
  397. package/dist/utils/marketDataTransform.d.cts.map +1 -0
  398. package/dist/utils/marketDataTransform.d.mts +40 -0
  399. package/dist/utils/marketDataTransform.d.mts.map +1 -0
  400. package/dist/utils/marketDataTransform.mjs +205 -0
  401. package/dist/utils/marketDataTransform.mjs.map +1 -0
  402. package/dist/utils/marketUtils.cjs +151 -0
  403. package/dist/utils/marketUtils.cjs.map +1 -0
  404. package/dist/utils/marketUtils.d.cts +30 -0
  405. package/dist/utils/marketUtils.d.cts.map +1 -0
  406. package/dist/utils/marketUtils.d.mts +30 -0
  407. package/dist/utils/marketUtils.d.mts.map +1 -0
  408. package/dist/utils/marketUtils.mjs +138 -0
  409. package/dist/utils/marketUtils.mjs.map +1 -0
  410. package/dist/utils/myxAdapter.cjs +224 -0
  411. package/dist/utils/myxAdapter.cjs.map +1 -0
  412. package/dist/utils/myxAdapter.d.cts +81 -0
  413. package/dist/utils/myxAdapter.d.cts.map +1 -0
  414. package/dist/utils/myxAdapter.d.mts +81 -0
  415. package/dist/utils/myxAdapter.d.mts.map +1 -0
  416. package/dist/utils/myxAdapter.mjs +213 -0
  417. package/dist/utils/myxAdapter.mjs.map +1 -0
  418. package/dist/utils/orderCalculations.cjs +283 -0
  419. package/dist/utils/orderCalculations.cjs.map +1 -0
  420. package/dist/utils/orderCalculations.d.cts +107 -0
  421. package/dist/utils/orderCalculations.d.cts.map +1 -0
  422. package/dist/utils/orderCalculations.d.mts +107 -0
  423. package/dist/utils/orderCalculations.d.mts.map +1 -0
  424. package/dist/utils/orderCalculations.mjs +274 -0
  425. package/dist/utils/orderCalculations.mjs.map +1 -0
  426. package/dist/utils/rewardsUtils.cjs +98 -0
  427. package/dist/utils/rewardsUtils.cjs.map +1 -0
  428. package/dist/utils/rewardsUtils.d.cts +33 -0
  429. package/dist/utils/rewardsUtils.d.cts.map +1 -0
  430. package/dist/utils/rewardsUtils.d.mts +33 -0
  431. package/dist/utils/rewardsUtils.d.mts.map +1 -0
  432. package/dist/utils/rewardsUtils.mjs +92 -0
  433. package/dist/utils/rewardsUtils.mjs.map +1 -0
  434. package/dist/utils/significantFigures.cjs +88 -0
  435. package/dist/utils/significantFigures.cjs.map +1 -0
  436. package/dist/utils/significantFigures.d.cts +25 -0
  437. package/dist/utils/significantFigures.d.cts.map +1 -0
  438. package/dist/utils/significantFigures.d.mts +25 -0
  439. package/dist/utils/significantFigures.d.mts.map +1 -0
  440. package/dist/utils/significantFigures.mjs +82 -0
  441. package/dist/utils/significantFigures.mjs.map +1 -0
  442. package/dist/utils/sortMarkets.cjs +93 -0
  443. package/dist/utils/sortMarkets.cjs.map +1 -0
  444. package/dist/utils/sortMarkets.d.cts +27 -0
  445. package/dist/utils/sortMarkets.d.cts.map +1 -0
  446. package/dist/utils/sortMarkets.d.mts +27 -0
  447. package/dist/utils/sortMarkets.d.mts.map +1 -0
  448. package/dist/utils/sortMarkets.mjs +88 -0
  449. package/dist/utils/sortMarkets.mjs.map +1 -0
  450. package/dist/utils/standaloneInfoClient.cjs +70 -0
  451. package/dist/utils/standaloneInfoClient.cjs.map +1 -0
  452. package/dist/utils/standaloneInfoClient.d.cts +37 -0
  453. package/dist/utils/standaloneInfoClient.d.cts.map +1 -0
  454. package/dist/utils/standaloneInfoClient.d.mts +37 -0
  455. package/dist/utils/standaloneInfoClient.d.mts.map +1 -0
  456. package/dist/utils/standaloneInfoClient.mjs +64 -0
  457. package/dist/utils/standaloneInfoClient.mjs.map +1 -0
  458. package/dist/utils/stringParseUtils.cjs +18 -0
  459. package/dist/utils/stringParseUtils.cjs.map +1 -0
  460. package/dist/utils/stringParseUtils.d.cts +3 -0
  461. package/dist/utils/stringParseUtils.d.cts.map +1 -0
  462. package/dist/utils/stringParseUtils.d.mts +3 -0
  463. package/dist/utils/stringParseUtils.d.mts.map +1 -0
  464. package/dist/utils/stringParseUtils.mjs +13 -0
  465. package/dist/utils/stringParseUtils.mjs.map +1 -0
  466. package/dist/utils/transferData.cjs +33 -0
  467. package/dist/utils/transferData.cjs.map +1 -0
  468. package/dist/utils/transferData.d.cts +9 -0
  469. package/dist/utils/transferData.d.cts.map +1 -0
  470. package/dist/utils/transferData.d.mts +9 -0
  471. package/dist/utils/transferData.d.mts.map +1 -0
  472. package/dist/utils/transferData.mjs +29 -0
  473. package/dist/utils/transferData.mjs.map +1 -0
  474. package/dist/utils/wait.cjs +6 -0
  475. package/dist/utils/wait.cjs.map +1 -0
  476. package/dist/utils/wait.d.cts +2 -0
  477. package/dist/utils/wait.d.cts.map +1 -0
  478. package/dist/utils/wait.d.mts +2 -0
  479. package/dist/utils/wait.d.mts.map +1 -0
  480. package/dist/utils/wait.mjs +2 -0
  481. package/dist/utils/wait.mjs.map +1 -0
  482. package/package.json +16 -2
@@ -1,107 +1,994 @@
1
- import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
2
- import { BaseController } from "@metamask/base-controller";
1
+ import { BaseController, ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
3
2
  import type { Messenger } from "@metamask/messenger";
3
+ import type { Json } from "@metamask/utils";
4
+ import { CandlePeriod } from "./constants/chartConfig.cjs";
5
+ import type { SortOptionId } from "./constants/perpsConfig.cjs";
6
+ import { WebSocketConnectionState } from "./types/index.cjs";
7
+ import type { AccountState, AssetRoute, CancelOrderParams, CancelOrderResult, CancelOrdersParams, CancelOrdersResult, ClosePositionParams, ClosePositionsParams, ClosePositionsResult, DepositWithConfirmationParams, EditOrderParams, FeeCalculationParams, FeeCalculationResult, FlipPositionParams, Funding, GetAccountStateParams, GetAvailableDexsParams, GetFundingParams, GetMarketsParams, GetOrderFillsParams, GetOrdersParams, GetPositionsParams, PerpsProvider, LiquidationPriceParams, LiveDataConfig, MaintenanceMarginParams, MarginResult, MarketInfo, Order, OrderFill, OrderParams, OrderResult, PerpsControllerConfig, PerpsMarketData, Position, SubscribeAccountParams, SubscribeCandlesParams, SubscribeOICapsParams, SubscribeOrderBookParams, SubscribeOrderFillsParams, SubscribeOrdersParams, SubscribePositionsParams, SubscribePricesParams, SwitchProviderResult, ToggleTestnetResult, UpdateMarginParams, UpdatePositionTPSLParams, WithdrawParams, WithdrawResult, GetHistoricalPortfolioParams, HistoricalPortfolioResult, OrderType, PerpsPlatformDependencies, PerpsActiveProviderMode, PerpsProviderType, PerpsSelectedPaymentToken, PerpsRemoteFeatureFlagState } from "./types/index.cjs";
8
+ import type { PerpsControllerAllowedActions, PerpsControllerAllowedEvents } from "./types/messenger.cjs";
9
+ import type { CandleData } from "./types/perps-types.cjs";
10
+ import { LastTransactionResult, TransactionStatus } from "./types/transactionTypes.cjs";
11
+ import type { SortDirection } from "./utils/sortMarkets.cjs";
4
12
  /**
5
- * The name of the {@link PerpsController}, used to namespace the
6
- * controller's actions and events and to namespace the controller's state data
7
- * when composed with other controllers.
13
+ * Minimal payment token stored in PerpsController state.
14
+ * Only required fields for identification, Perps balance detection, and analytics.
8
15
  */
9
- export declare const controllerName = "PerpsController";
16
+ export type SelectedPaymentTokenSnapshot = {
17
+ description?: string;
18
+ address: string;
19
+ chainId: string;
20
+ symbol?: string;
21
+ };
22
+ export { PERPS_ERROR_CODES, type PerpsErrorCode } from "./perpsErrorCodes.cjs";
10
23
  /**
11
- * Describes the shape of the state object for {@link PerpsController}.
24
+ * Initialization state enum for state machine tracking
12
25
  */
13
- export type PerpsControllerState = {};
14
- /**
15
- * Constructs the default {@link PerpsController} state. This allows
16
- * consumers to provide a partial state object when initializing the controller
17
- * and also helps in constructing complete state objects for this controller in
18
- * tests.
19
- *
20
- * @returns The default {@link PerpsController} state.
21
- */
22
- export declare function getDefaultPerpsControllerState(): PerpsControllerState;
23
- /**
24
- * Retrieves the state of the {@link PerpsController}.
25
- */
26
- export type PerpsControllerGetStateAction = ControllerGetStateAction<typeof controllerName, PerpsControllerState>;
26
+ export declare enum InitializationState {
27
+ Uninitialized = "uninitialized",
28
+ Initializing = "initializing",
29
+ Initialized = "initialized",
30
+ Failed = "failed"
31
+ }
27
32
  /**
28
- * Actions that {@link PerpsControllerMessenger} exposes to other consumers.
33
+ * State shape for PerpsController
29
34
  */
30
- export type PerpsControllerActions = PerpsControllerGetStateAction;
35
+ export type PerpsControllerState = {
36
+ activeProvider: PerpsActiveProviderMode;
37
+ isTestnet: boolean;
38
+ initializationState: InitializationState;
39
+ initializationError: string | null;
40
+ initializationAttempts: number;
41
+ accountState: AccountState | null;
42
+ perpsBalances: {
43
+ [provider: string]: {
44
+ totalBalance: string;
45
+ unrealizedPnl: string;
46
+ accountValue1dAgo: string;
47
+ lastUpdated: number;
48
+ };
49
+ };
50
+ depositInProgress: boolean;
51
+ lastDepositTransactionId: string | null;
52
+ lastDepositResult: LastTransactionResult | null;
53
+ withdrawInProgress: boolean;
54
+ lastWithdrawResult: LastTransactionResult | null;
55
+ withdrawalRequests: {
56
+ id: string;
57
+ amount: string;
58
+ asset: string;
59
+ accountAddress: string;
60
+ txHash?: string;
61
+ timestamp: number;
62
+ success: boolean;
63
+ status: TransactionStatus;
64
+ destination?: string;
65
+ source?: string;
66
+ transactionId?: string;
67
+ withdrawalId?: string;
68
+ depositId?: string;
69
+ }[];
70
+ withdrawalProgress: {
71
+ progress: number;
72
+ lastUpdated: number;
73
+ activeWithdrawalId: string | null;
74
+ };
75
+ depositRequests: {
76
+ id: string;
77
+ amount: string;
78
+ asset: string;
79
+ accountAddress: string;
80
+ txHash?: string;
81
+ timestamp: number;
82
+ success: boolean;
83
+ status: TransactionStatus;
84
+ destination?: string;
85
+ source?: string;
86
+ transactionId?: string;
87
+ withdrawalId?: string;
88
+ depositId?: string;
89
+ }[];
90
+ isEligible: boolean;
91
+ isFirstTimeUser: {
92
+ testnet: boolean;
93
+ mainnet: boolean;
94
+ };
95
+ hasPlacedFirstOrder: {
96
+ testnet: boolean;
97
+ mainnet: boolean;
98
+ };
99
+ watchlistMarkets: {
100
+ testnet: string[];
101
+ mainnet: string[];
102
+ };
103
+ tradeConfigurations: {
104
+ testnet: {
105
+ [marketSymbol: string]: {
106
+ leverage?: number;
107
+ orderBookGrouping?: number;
108
+ pendingConfig?: {
109
+ amount?: string;
110
+ leverage?: number;
111
+ takeProfitPrice?: string;
112
+ stopLossPrice?: string;
113
+ limitPrice?: string;
114
+ orderType?: OrderType;
115
+ timestamp: number;
116
+ };
117
+ };
118
+ };
119
+ mainnet: {
120
+ [marketSymbol: string]: {
121
+ leverage?: number;
122
+ orderBookGrouping?: number;
123
+ pendingConfig?: {
124
+ amount?: string;
125
+ leverage?: number;
126
+ takeProfitPrice?: string;
127
+ stopLossPrice?: string;
128
+ limitPrice?: string;
129
+ orderType?: OrderType;
130
+ timestamp: number;
131
+ };
132
+ };
133
+ };
134
+ };
135
+ marketFilterPreferences: {
136
+ optionId: SortOptionId;
137
+ direction: SortDirection;
138
+ };
139
+ lastError: string | null;
140
+ lastUpdateTimestamp: number;
141
+ hip3ConfigVersion: number;
142
+ selectedPaymentToken: Json | null;
143
+ cachedMarketData: PerpsMarketData[] | null;
144
+ cachedMarketDataTimestamp: number;
145
+ cachedPositions: Position[] | null;
146
+ cachedOrders: Order[] | null;
147
+ cachedAccountState: AccountState | null;
148
+ cachedUserDataTimestamp: number;
149
+ cachedUserDataAddress: string | null;
150
+ };
31
151
  /**
32
- * Actions from other messengers that {@link PerpsControllerMessenger} calls.
152
+ * Get default PerpsController state
153
+ *
154
+ * To change the active provider, modify the `activeProvider` value below:
155
+ * - 'hyperliquid': HyperLiquid provider (default, production)
156
+ * - 'aggregated': Multi-provider aggregation mode
157
+ * - 'myx': MYX provider (future implementation)
158
+ *
159
+ * @returns The default perps controller state.
33
160
  */
34
- type AllowedActions = never;
161
+ export declare const getDefaultPerpsControllerState: () => PerpsControllerState;
35
162
  /**
36
- * Published when the state of {@link PerpsController} changes.
163
+ * PerpsController events
37
164
  */
38
- export type PerpsControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, PerpsControllerState>;
165
+ export type PerpsControllerEvents = ControllerStateChangeEvent<'PerpsController', PerpsControllerState>;
39
166
  /**
40
- * Events that {@link PerpsControllerMessenger} exposes to other consumers.
167
+ * PerpsController actions
41
168
  */
42
- export type PerpsControllerEvents = PerpsControllerStateChangeEvent;
169
+ export type PerpsControllerActions = ControllerGetStateAction<'PerpsController', PerpsControllerState> | {
170
+ type: 'PerpsController:placeOrder';
171
+ handler: PerpsController['placeOrder'];
172
+ } | {
173
+ type: 'PerpsController:editOrder';
174
+ handler: PerpsController['editOrder'];
175
+ } | {
176
+ type: 'PerpsController:cancelOrder';
177
+ handler: PerpsController['cancelOrder'];
178
+ } | {
179
+ type: 'PerpsController:cancelOrders';
180
+ handler: PerpsController['cancelOrders'];
181
+ } | {
182
+ type: 'PerpsController:closePosition';
183
+ handler: PerpsController['closePosition'];
184
+ } | {
185
+ type: 'PerpsController:closePositions';
186
+ handler: PerpsController['closePositions'];
187
+ } | {
188
+ type: 'PerpsController:withdraw';
189
+ handler: PerpsController['withdraw'];
190
+ } | {
191
+ type: 'PerpsController:getPositions';
192
+ handler: PerpsController['getPositions'];
193
+ } | {
194
+ type: 'PerpsController:getOrderFills';
195
+ handler: PerpsController['getOrderFills'];
196
+ } | {
197
+ type: 'PerpsController:getOrders';
198
+ handler: PerpsController['getOrders'];
199
+ } | {
200
+ type: 'PerpsController:getOpenOrders';
201
+ handler: PerpsController['getOpenOrders'];
202
+ } | {
203
+ type: 'PerpsController:getFunding';
204
+ handler: PerpsController['getFunding'];
205
+ } | {
206
+ type: 'PerpsController:getAccountState';
207
+ handler: PerpsController['getAccountState'];
208
+ } | {
209
+ type: 'PerpsController:getMarkets';
210
+ handler: PerpsController['getMarkets'];
211
+ } | {
212
+ type: 'PerpsController:refreshEligibility';
213
+ handler: PerpsController['refreshEligibility'];
214
+ } | {
215
+ type: 'PerpsController:toggleTestnet';
216
+ handler: PerpsController['toggleTestnet'];
217
+ } | {
218
+ type: 'PerpsController:disconnect';
219
+ handler: PerpsController['disconnect'];
220
+ } | {
221
+ type: 'PerpsController:calculateFees';
222
+ handler: PerpsController['calculateFees'];
223
+ } | {
224
+ type: 'PerpsController:markTutorialCompleted';
225
+ handler: PerpsController['markTutorialCompleted'];
226
+ } | {
227
+ type: 'PerpsController:markFirstOrderCompleted';
228
+ handler: PerpsController['markFirstOrderCompleted'];
229
+ } | {
230
+ type: 'PerpsController:getHistoricalPortfolio';
231
+ handler: PerpsController['getHistoricalPortfolio'];
232
+ } | {
233
+ type: 'PerpsController:resetFirstTimeUserState';
234
+ handler: PerpsController['resetFirstTimeUserState'];
235
+ } | {
236
+ type: 'PerpsController:clearPendingTransactionRequests';
237
+ handler: PerpsController['clearPendingTransactionRequests'];
238
+ } | {
239
+ type: 'PerpsController:saveTradeConfiguration';
240
+ handler: PerpsController['saveTradeConfiguration'];
241
+ } | {
242
+ type: 'PerpsController:getTradeConfiguration';
243
+ handler: PerpsController['getTradeConfiguration'];
244
+ } | {
245
+ type: 'PerpsController:saveMarketFilterPreferences';
246
+ handler: PerpsController['saveMarketFilterPreferences'];
247
+ } | {
248
+ type: 'PerpsController:getMarketFilterPreferences';
249
+ handler: PerpsController['getMarketFilterPreferences'];
250
+ } | {
251
+ type: 'PerpsController:savePendingTradeConfiguration';
252
+ handler: PerpsController['savePendingTradeConfiguration'];
253
+ } | {
254
+ type: 'PerpsController:getPendingTradeConfiguration';
255
+ handler: PerpsController['getPendingTradeConfiguration'];
256
+ } | {
257
+ type: 'PerpsController:clearPendingTradeConfiguration';
258
+ handler: PerpsController['clearPendingTradeConfiguration'];
259
+ } | {
260
+ type: 'PerpsController:getOrderBookGrouping';
261
+ handler: PerpsController['getOrderBookGrouping'];
262
+ } | {
263
+ type: 'PerpsController:saveOrderBookGrouping';
264
+ handler: PerpsController['saveOrderBookGrouping'];
265
+ } | {
266
+ type: 'PerpsController:setSelectedPaymentToken';
267
+ handler: PerpsController['setSelectedPaymentToken'];
268
+ } | {
269
+ type: 'PerpsController:resetSelectedPaymentToken';
270
+ handler: PerpsController['resetSelectedPaymentToken'];
271
+ };
43
272
  /**
44
- * Events from other messengers that {@link PerpsControllerMessenger} subscribes
45
- * to.
273
+ * PerpsController messenger constraints.
274
+ * Includes both PerpsController's own actions/events and
275
+ * allowed actions/events from external controllers.
46
276
  */
47
- type AllowedEvents = never;
277
+ export type PerpsControllerMessenger = Messenger<'PerpsController', PerpsControllerActions | PerpsControllerAllowedActions, PerpsControllerEvents | PerpsControllerAllowedEvents>;
48
278
  /**
49
- * The messenger restricted to actions and events accessed by
50
- * {@link PerpsController}.
279
+ * PerpsController options
51
280
  */
52
- export type PerpsControllerMessenger = Messenger<typeof controllerName, PerpsControllerActions | AllowedActions, PerpsControllerEvents | AllowedEvents>;
281
+ export type PerpsControllerOptions = {
282
+ messenger: PerpsControllerMessenger;
283
+ state?: Partial<PerpsControllerState>;
284
+ clientConfig?: PerpsControllerConfig;
285
+ /**
286
+ * Platform-specific dependencies (required)
287
+ * Provides logging, metrics, tracing, stream management, and rewards.
288
+ * Cross-controller communication uses the messenger pattern.
289
+ * Must be provided by the platform (mobile/extension) at instantiation time.
290
+ */
291
+ infrastructure: PerpsPlatformDependencies;
292
+ };
293
+ type BlockedRegionList = {
294
+ list: string[];
295
+ source: 'remote' | 'fallback';
296
+ };
53
297
  /**
54
- * `PerpsController` manages perpetual trading functionality in MetaMask.
55
- *
56
- * This controller provides platform-agnostic perps trading capabilities.
57
- *
58
- * @example
298
+ * PerpsController - Protocol-agnostic perpetuals trading controller
59
299
  *
60
- * ``` ts
61
- * import { Messenger } from '@metamask/messenger';
62
- * import type {
63
- * PerpsControllerActions,
64
- * PerpsControllerEvents,
65
- * } from '@metamask/perps-controller';
66
- * import { PerpsController } from '@metamask/perps-controller';
67
- *
68
- * const rootMessenger = new Messenger<
69
- * 'Root',
70
- * PerpsControllerActions,
71
- * PerpsControllerEvents
72
- * >({ namespace: 'Root' });
73
- * const perpsControllerMessenger = new Messenger<
74
- * 'PerpsController',
75
- * PerpsControllerActions,
76
- * PerpsControllerEvents,
77
- * typeof rootMessenger,
78
- * >({
79
- * namespace: 'PerpsController',
80
- * parent: rootMessenger,
81
- * });
82
- * // Instantiate the controller to register its actions on the messenger
83
- * new PerpsController({
84
- * messenger: perpsControllerMessenger,
85
- * });
86
- *
87
- * const perpsControllerState = await rootMessenger.call(
88
- * 'PerpsController:getState',
89
- * );
90
- * ```
300
+ * Provides a unified interface for perpetual futures trading across multiple protocols.
301
+ * Features dual data flow architecture:
302
+ * - Trading actions use Redux for persistence and optimistic updates
303
+ * - Live data uses direct callbacks for maximum performance
91
304
  */
92
- export declare class PerpsController extends BaseController<typeof controllerName, PerpsControllerState, PerpsControllerMessenger> {
305
+ export declare class PerpsController extends BaseController<'PerpsController', PerpsControllerState, PerpsControllerMessenger> {
306
+ #private;
307
+ protected providers: Map<PerpsProviderType, PerpsProvider>;
308
+ protected isInitialized: boolean;
309
+ protected blockedRegionList: BlockedRegionList;
310
+ /**
311
+ * Active provider instance for routing operations.
312
+ * When activeProvider is 'hyperliquid' or 'myx': points to specific provider directly
313
+ * When activeProvider is 'aggregated': points to AggregatedPerpsProvider wrapper
314
+ */
315
+ protected activeProviderInstance: PerpsProvider | null;
316
+ constructor({ messenger, state, clientConfig, infrastructure, }: PerpsControllerOptions);
317
+ /**
318
+ * Test-observable accessor for whether a standalone provider is cached.
319
+ *
320
+ * @returns True if a standalone provider instance exists.
321
+ */
322
+ protected hasStandaloneProvider(): boolean;
323
+ protected setBlockedRegionList(list: string[], source: 'remote' | 'fallback'): void;
324
+ /**
325
+ * Respond to RemoteFeatureFlagController state changes
326
+ * Refreshes user eligibility based on geo-blocked regions defined in remote feature flag.
327
+ * Uses fallback configuration when remote feature flag is undefined.
328
+ * Note: Initial eligibility is set in the constructor if fallback regions are provided.
329
+ *
330
+ * @param remoteFeatureFlagControllerState - State from RemoteFeatureFlagController.
331
+ */
332
+ protected refreshEligibilityOnFeatureFlagChange(remoteFeatureFlagControllerState: PerpsRemoteFeatureFlagState): void;
333
+ /**
334
+ * Initialize the PerpsController providers
335
+ * Must be called before using any other methods
336
+ * Prevents double initialization with promise caching
337
+ *
338
+ * @returns A promise that resolves when the operation completes.
339
+ */
340
+ init(): Promise<void>;
341
+ /**
342
+ * Get the currently active provider.
343
+ * In aggregated mode, returns AggregatedPerpsProvider which routes to underlying providers.
344
+ * In single provider mode, returns HyperLiquidProvider directly.
345
+ *
346
+ * @returns The active provider (aggregated wrapper or direct provider based on mode)
347
+ * @throws Error if provider is not initialized or reinitializing
348
+ */
349
+ getActiveProvider(): PerpsProvider;
350
+ /**
351
+ * Get the currently active provider, returning null if not available
352
+ * Use this method when the caller can gracefully handle a missing provider
353
+ * (e.g., UI components during initialization or reconnection)
354
+ *
355
+ * @returns The active provider, or null if not initialized/reinitializing
356
+ */
357
+ getActiveProviderOrNull(): PerpsProvider | null;
358
+ /**
359
+ * Place a new order
360
+ * Thin delegation to TradingService
361
+ *
362
+ * @param params - The operation parameters.
363
+ * @returns The order result with order ID and status.
364
+ */
365
+ placeOrder(params: OrderParams): Promise<OrderResult>;
366
+ /**
367
+ * Edit an existing order
368
+ * Thin delegation to TradingService
369
+ *
370
+ * @param params - The operation parameters.
371
+ * @returns The updated order result with order ID and status.
372
+ */
373
+ editOrder(params: EditOrderParams): Promise<OrderResult>;
374
+ /**
375
+ * Cancel an existing order
376
+ *
377
+ * @param params - The operation parameters.
378
+ * @returns The cancellation result with status.
379
+ */
380
+ cancelOrder(params: CancelOrderParams): Promise<CancelOrderResult>;
381
+ /**
382
+ * Cancel multiple orders in parallel
383
+ * Batch version of cancelOrder() that cancels multiple orders simultaneously
384
+ *
385
+ * @param params - The operation parameters.
386
+ * @returns The batch cancellation results for each order.
387
+ */
388
+ cancelOrders(params: CancelOrdersParams): Promise<CancelOrdersResult>;
389
+ /**
390
+ * Close a position (partial or full)
391
+ * Thin delegation to TradingService
392
+ *
393
+ * @param params - The operation parameters.
394
+ * @returns The order result from the close position request.
395
+ */
396
+ closePosition(params: ClosePositionParams): Promise<OrderResult>;
397
+ /**
398
+ * Close multiple positions in parallel
399
+ * Batch version of closePosition() that closes multiple positions simultaneously
400
+ *
401
+ * @param params - The operation parameters.
402
+ * @returns The batch close results for each position.
403
+ */
404
+ closePositions(params: ClosePositionsParams): Promise<ClosePositionsResult>;
405
+ /**
406
+ * Update TP/SL for an existing position
407
+ *
408
+ * @param params - The operation parameters.
409
+ * @returns The order result from the TP/SL update.
410
+ */
411
+ updatePositionTPSL(params: UpdatePositionTPSLParams): Promise<OrderResult>;
412
+ /**
413
+ * Update margin for an existing position (add or remove)
414
+ *
415
+ * @param params - The operation parameters.
416
+ * @returns The margin update result.
417
+ */
418
+ updateMargin(params: UpdateMarginParams): Promise<MarginResult>;
419
+ /**
420
+ * Flip position (reverse direction while keeping size and leverage)
421
+ *
422
+ * @param params - The operation parameters.
423
+ * @returns The order result from the position flip.
424
+ */
425
+ flipPosition(params: FlipPositionParams): Promise<OrderResult>;
426
+ /**
427
+ * Simplified deposit method that prepares transaction for confirmation screen
428
+ * No complex state tracking - just sets a loading flag
429
+ *
430
+ * @param params - Parameters for the deposit flow
431
+ * @param params.amount - Optional deposit amount
432
+ * @param params.placeOrder - If true, uses addTransaction instead of submit to avoid navigation
433
+ * @returns An object containing a promise that resolves to the transaction hash.
434
+ */
435
+ depositWithConfirmation(params?: DepositWithConfirmationParams): Promise<{
436
+ result: Promise<string>;
437
+ }>;
438
+ /**
439
+ * Same as depositWithConfirmation - prepares transaction for confirmation screen.
440
+ *
441
+ * @returns A promise that resolves to the string result.
442
+ */
443
+ depositWithOrder(): Promise<{
444
+ result: Promise<string>;
445
+ }>;
446
+ /**
447
+ * Clear the last deposit result after it has been shown to the user
448
+ */
449
+ clearDepositResult(): void;
450
+ clearWithdrawResult(): void;
451
+ /**
452
+ * Update withdrawal request status when it completes
453
+ * This is called when a withdrawal is matched with a completed withdrawal from the API
454
+ *
455
+ * @param withdrawalId - The withdrawal transaction ID.
456
+ * @param status - The current status.
457
+ * @param txHash - The transaction hash.
458
+ */
459
+ updateWithdrawalStatus(withdrawalId: string, status: 'completed' | 'failed', txHash?: string): void;
460
+ /**
461
+ * Update withdrawal progress (persistent across navigation)
462
+ *
463
+ * @param progress - The progress indicator.
464
+ * @param activeWithdrawalId - The active withdrawal ID.
465
+ */
466
+ updateWithdrawalProgress(progress: number, activeWithdrawalId?: string | null): void;
467
+ /**
468
+ * Get current withdrawal progress
469
+ *
470
+ * @returns The withdrawal progress, last update timestamp, and active withdrawal ID.
471
+ */
472
+ getWithdrawalProgress(): {
473
+ progress: number;
474
+ lastUpdated: number;
475
+ activeWithdrawalId: string | null;
476
+ };
477
+ /**
478
+ * Withdraw funds from trading account
479
+ *
480
+ * The withdrawal process varies by provider and may involve:
481
+ * - Direct on-chain transfers
482
+ * - Bridge operations
483
+ * - Multi-step validation processes
484
+ *
485
+ * Check the specific provider documentation for detailed withdrawal flows.
486
+ *
487
+ * @param params Withdrawal parameters
488
+ * @returns WithdrawResult with withdrawal ID and tracking info
489
+ */
490
+ withdraw(params: WithdrawParams): Promise<WithdrawResult>;
491
+ /**
492
+ * Get current positions
493
+ * Thin delegation to MarketDataService
494
+ *
495
+ * For standalone mode, bypasses getActiveProvider() to allow position queries
496
+ * without full perps initialization (e.g., for showing positions on token details page)
497
+ *
498
+ * @param params - The operation parameters.
499
+ * @returns Array of open positions for the active provider.
500
+ */
501
+ getPositions(params?: GetPositionsParams): Promise<Position[]>;
502
+ /**
503
+ * Get historical user fills (trade executions)
504
+ * Thin delegation to MarketDataService
505
+ *
506
+ * @param params - The operation parameters.
507
+ * @returns Array of historical trade executions (fills).
508
+ */
509
+ getOrderFills(params?: GetOrderFillsParams): Promise<OrderFill[]>;
510
+ /**
511
+ * Get historical user orders (order lifecycle)
512
+ * Thin delegation to MarketDataService
513
+ *
514
+ * @param params - The operation parameters.
515
+ * @returns Array of historical orders.
516
+ */
517
+ getOrders(params?: GetOrdersParams): Promise<Order[]>;
518
+ /**
519
+ * Get currently open orders (real-time status)
520
+ * Thin delegation to MarketDataService
521
+ *
522
+ * For standalone mode, bypasses getActiveProvider() to allow open order queries
523
+ * without full perps initialization (e.g., for background preloading)
524
+ *
525
+ * @param params - The operation parameters.
526
+ * @returns A promise that resolves to the result.
527
+ */
528
+ getOpenOrders(params?: GetOrdersParams): Promise<Order[]>;
529
+ /**
530
+ * Get historical user funding history (funding payments)
531
+ * Thin delegation to MarketDataService
532
+ *
533
+ * @param params - The operation parameters.
534
+ * @returns Array of historical funding payments.
535
+ */
536
+ getFunding(params?: GetFundingParams): Promise<Funding[]>;
537
+ /**
538
+ * Get account state (balances, etc.)
539
+ * Thin delegation to MarketDataService
540
+ *
541
+ * For standalone mode, bypasses getActiveProvider() to allow account state queries
542
+ * without full perps initialization (e.g., for checking if user has perps funds)
543
+ *
544
+ * @param params - The operation parameters.
545
+ * @returns A promise that resolves to the result.
546
+ */
547
+ getAccountState(params?: GetAccountStateParams): Promise<AccountState>;
548
+ /**
549
+ * Get historical portfolio data
550
+ * Thin delegation to MarketDataService
551
+ *
552
+ * @param params - The operation parameters.
553
+ * @returns The historical portfolio data points.
554
+ */
555
+ getHistoricalPortfolio(params?: GetHistoricalPortfolioParams): Promise<HistoricalPortfolioResult>;
556
+ /**
557
+ * Get available markets with optional filtering
558
+ * Thin delegation to MarketDataService
559
+ *
560
+ * For standalone mode, bypasses getActiveProvider() to allow market discovery
561
+ * without full perps initialization (e.g., for discovery banners on spot screens)
562
+ *
563
+ * @param params - The operation parameters.
564
+ * @returns Array of available markets matching the filter criteria.
565
+ */
566
+ getMarkets(params?: GetMarketsParams): Promise<MarketInfo[]>;
567
+ /**
568
+ * Get market data with prices (includes price, volume, 24h change)
569
+ *
570
+ * For standalone mode, bypasses getActiveProvider() to allow market data queries
571
+ * without full perps initialization (e.g., for background preloading on app start)
572
+ *
573
+ * @param params - The operation parameters.
574
+ * @param params.standalone - Whether to use standalone mode.
575
+ * @returns A promise that resolves to the market data.
576
+ */
577
+ getMarketDataWithPrices(params?: {
578
+ standalone?: boolean;
579
+ }): Promise<PerpsMarketData[]>;
580
+ /**
581
+ * Start background market data preloading.
582
+ * Fetches market data immediately and refreshes every 5 minutes.
583
+ * Watches for isTestnet and hip3ConfigVersion changes to re-preload.
584
+ */
585
+ startMarketDataPreload(): void;
586
+ /**
587
+ * Stop background market data preloading.
588
+ */
589
+ stopMarketDataPreload(): void;
590
+ /**
591
+ * Get list of available HIP-3 builder-deployed DEXs
592
+ *
593
+ * @param params - Optional parameters for filtering
594
+ * @returns Array of DEX names
595
+ */
596
+ getAvailableDexs(params?: GetAvailableDexsParams): Promise<string[]>;
597
+ /**
598
+ * Fetch historical candle data
599
+ * Thin delegation to MarketDataService
600
+ *
601
+ * @param options - The configuration options.
602
+ * @param options.symbol - The trading pair symbol.
603
+ * @param options.interval - The candle interval period.
604
+ * @param options.limit - Maximum number of items to fetch.
605
+ * @param options.endTime - End timestamp in milliseconds.
606
+ * @returns The historical candle data for the requested symbol and interval.
607
+ */
608
+ fetchHistoricalCandles(options: {
609
+ symbol: string;
610
+ interval: CandlePeriod;
611
+ limit?: number;
612
+ endTime?: number;
613
+ }): Promise<CandleData>;
614
+ /**
615
+ * Calculate liquidation price for a position
616
+ * Uses provider-specific formulas based on protocol rules
617
+ *
618
+ * @param params - The operation parameters.
619
+ * @returns A promise that resolves to the string result.
620
+ */
621
+ calculateLiquidationPrice(params: LiquidationPriceParams): Promise<string>;
622
+ /**
623
+ * Calculate maintenance margin for a specific asset
624
+ * Returns a percentage (e.g., 0.0125 for 1.25%)
625
+ *
626
+ * @param params - The operation parameters.
627
+ * @returns A promise that resolves to the numeric result.
628
+ */
629
+ calculateMaintenanceMargin(params: MaintenanceMarginParams): Promise<number>;
630
+ /**
631
+ * Get maximum leverage allowed for an asset
632
+ *
633
+ * @param asset - The asset identifier.
634
+ * @returns A promise that resolves to the numeric result.
635
+ */
636
+ getMaxLeverage(asset: string): Promise<number>;
637
+ /**
638
+ * Validate order parameters according to protocol-specific rules
639
+ *
640
+ * @param params - The operation parameters.
641
+ * @returns True if the condition is met.
642
+ */
643
+ validateOrder(params: OrderParams): Promise<{
644
+ isValid: boolean;
645
+ error?: string;
646
+ }>;
647
+ /**
648
+ * Validate close position parameters according to protocol-specific rules
649
+ *
650
+ * @param params - The operation parameters.
651
+ * @returns A promise that resolves to the result.
652
+ */
653
+ validateClosePosition(params: ClosePositionParams): Promise<{
654
+ isValid: boolean;
655
+ error?: string;
656
+ }>;
657
+ /**
658
+ * Validate withdrawal parameters according to protocol-specific rules
659
+ *
660
+ * @param params - The operation parameters.
661
+ * @returns True if the condition is met.
662
+ */
663
+ validateWithdrawal(params: WithdrawParams): Promise<{
664
+ isValid: boolean;
665
+ error?: string;
666
+ }>;
667
+ /**
668
+ * Get supported withdrawal routes - returns complete asset and routing information
669
+ *
670
+ * @returns Array of supported asset routes for withdrawals.
671
+ */
672
+ getWithdrawalRoutes(): AssetRoute[];
673
+ /**
674
+ * Toggle between testnet and mainnet
675
+ *
676
+ * @returns The toggle result with success status and current network mode.
677
+ */
678
+ toggleTestnet(): Promise<ToggleTestnetResult>;
679
+ /**
680
+ * Switch to a different provider
681
+ * Uses a full reinit approach: disconnect() → update state → init()
682
+ * This ensures complete state reset including WebSocket connections and caches.
683
+ *
684
+ * @param providerId - The provider identifier.
685
+ * @returns The switch result with success status and active provider.
686
+ */
687
+ switchProvider(providerId: PerpsActiveProviderMode): Promise<SwitchProviderResult>;
688
+ /**
689
+ * Get current network (mainnet/testnet)
690
+ *
691
+ * @returns Either 'mainnet' or 'testnet' based on the current configuration.
692
+ */
693
+ getCurrentNetwork(): 'mainnet' | 'testnet';
694
+ /**
695
+ * Get the current WebSocket connection state from the active provider.
696
+ * Used by the UI to monitor connection health and show notifications.
697
+ *
698
+ * @returns The current WebSocket connection state, or DISCONNECTED if not supported
699
+ */
700
+ getWebSocketConnectionState(): WebSocketConnectionState;
701
+ /**
702
+ * Subscribe to WebSocket connection state changes from the active provider.
703
+ * The listener will be called immediately with the current state and whenever the state changes.
704
+ *
705
+ * @param listener - Callback function that receives the new connection state and reconnection attempt
706
+ * @returns Unsubscribe function to remove the listener, or no-op if not supported
707
+ */
708
+ subscribeToConnectionState(listener: (state: WebSocketConnectionState, reconnectionAttempt: number) => void): () => void;
709
+ /**
710
+ * Manually trigger a WebSocket reconnection attempt.
711
+ * Used by the UI retry button when connection is lost.
712
+ */
713
+ reconnect(): Promise<void>;
714
+ /**
715
+ * Subscribe to live price updates
716
+ *
717
+ * @param params - The operation parameters.
718
+ * @returns A cleanup function to remove the subscription.
719
+ */
720
+ subscribeToPrices(params: SubscribePricesParams): () => void;
721
+ /**
722
+ * Subscribe to live position updates
723
+ *
724
+ * @param params - The operation parameters.
725
+ * @returns A cleanup function to remove the subscription.
726
+ */
727
+ subscribeToPositions(params: SubscribePositionsParams): () => void;
728
+ /**
729
+ * Subscribe to live order fill updates
730
+ *
731
+ * @param params - The operation parameters.
732
+ * @returns A cleanup function to remove the subscription.
733
+ */
734
+ subscribeToOrderFills(params: SubscribeOrderFillsParams): () => void;
735
+ /**
736
+ * Subscribe to live order updates
737
+ *
738
+ * @param params - The operation parameters.
739
+ * @returns A cleanup function to remove the subscription.
740
+ */
741
+ subscribeToOrders(params: SubscribeOrdersParams): () => void;
742
+ /**
743
+ * Subscribe to live account updates.
744
+ * Updates controller state (Redux) when new account data arrives so consumers
745
+ * like usePerpsBalanceTokenFilter (PayWithModal) see the latest balance.
746
+ *
747
+ * @param params - The operation parameters.
748
+ * @returns A cleanup function to remove the subscription.
749
+ */
750
+ subscribeToAccount(params: SubscribeAccountParams): () => void;
751
+ /**
752
+ * Subscribe to full order book updates with multiple depth levels
753
+ * Creates a dedicated L2Book subscription for real-time order book data
754
+ *
755
+ * @param params - The operation parameters.
756
+ * @returns A cleanup function to remove the subscription.
757
+ */
758
+ subscribeToOrderBook(params: SubscribeOrderBookParams): () => void;
759
+ /**
760
+ * Subscribe to live candle updates
761
+ *
762
+ * @param params - The operation parameters.
763
+ * @returns A cleanup function to remove the subscription.
764
+ */
765
+ subscribeToCandles(params: SubscribeCandlesParams): () => void;
766
+ /**
767
+ * Subscribe to open interest cap updates
768
+ * Zero additional network overhead - data comes from existing webData3 subscription
769
+ *
770
+ * @param params - The operation parameters.
771
+ * @returns A cleanup function to remove the subscription.
772
+ */
773
+ subscribeToOICaps(params: SubscribeOICapsParams): () => void;
774
+ /**
775
+ * Configure live data throttling
776
+ *
777
+ * @param config - The configuration object.
778
+ */
779
+ setLiveDataConfig(config: Partial<LiveDataConfig>): void;
780
+ /**
781
+ * Calculate trading fees for the active provider
782
+ * Each provider implements its own fee structure
783
+ *
784
+ * @param params - The operation parameters.
785
+ * @returns The fee calculation result for the trade.
786
+ */
787
+ calculateFees(params: FeeCalculationParams): Promise<FeeCalculationResult>;
788
+ /**
789
+ * Disconnect provider and cleanup subscriptions
790
+ * Call this when navigating away from Perps screens to prevent battery drain
791
+ */
792
+ disconnect(): Promise<void>;
793
+ /**
794
+ * Eligibility (Geo-Blocking)
795
+ */
796
+ /**
797
+ * Fetch geo location
798
+ *
799
+ * Returned in Country or Country-Region format
800
+ * Example: FR, DE, US-MI, CA-ON
801
+ */
802
+ /**
803
+ * Refresh eligibility status
804
+ */
805
+ refreshEligibility(): Promise<void>;
806
+ /**
807
+ * Get block explorer URL for an address or just the base URL
808
+ *
809
+ * @param address - Optional address to append to the base URL
810
+ * @returns Block explorer URL
811
+ */
812
+ getBlockExplorerUrl(address?: string): string;
813
+ /**
814
+ * Check if user is first-time for the current network
815
+ *
816
+ * @returns True if the condition is met.
817
+ */
818
+ isFirstTimeUserOnCurrentNetwork(): boolean;
819
+ /**
820
+ * Mark that the user has completed the tutorial/onboarding
821
+ * This prevents the tutorial from showing again
822
+ */
823
+ markTutorialCompleted(): void;
824
+ markFirstOrderCompleted(): void;
825
+ /**
826
+ * Reset first-time user state for both networks
827
+ * This is useful for testing the tutorial flow
828
+ * Called by Reset Account feature in settings
829
+ */
830
+ resetFirstTimeUserState(): void;
831
+ /**
832
+ * Clear pending/bridging withdrawal and deposit requests
833
+ * This is useful when users want to clear stuck pending indicators
834
+ * Called by Reset Account feature in settings
835
+ */
836
+ clearPendingTransactionRequests(): void;
837
+ /**
838
+ * Get saved trade configuration for a market
839
+ *
840
+ * @param symbol - The trading pair symbol.
841
+ * @returns The resulting string value.
842
+ */
843
+ getTradeConfiguration(symbol: string): {
844
+ leverage?: number;
845
+ } | undefined;
846
+ /**
847
+ * Save trade configuration for a market
848
+ *
849
+ * @param symbol - Market symbol
850
+ * @param leverage - Leverage value
851
+ */
852
+ saveTradeConfiguration(symbol: string, leverage: number): void;
853
+ /**
854
+ * Save pending trade configuration for a market
855
+ * This is a temporary configuration that expires after 5 minutes
856
+ *
857
+ * @param symbol - Market symbol
858
+ * @param config - Pending trade configuration (includes optional selected payment token from Pay row)
859
+ * @param config.amount - The amount value.
860
+ * @param config.leverage - The leverage multiplier.
861
+ * @param config.takeProfitPrice - The take profit price.
862
+ * @param config.stopLossPrice - The stop loss price.
863
+ * @param config.limitPrice - The limit price.
864
+ * @param config.orderType - The order type.
865
+ * @param config.selectedPaymentToken - The selected payment token.
866
+ */
867
+ savePendingTradeConfiguration(symbol: string, config: {
868
+ amount?: string;
869
+ leverage?: number;
870
+ takeProfitPrice?: string;
871
+ stopLossPrice?: string;
872
+ limitPrice?: string;
873
+ orderType?: OrderType;
874
+ /** When user used pay-with-token in PerpsPayRow: minimal token shape to restore selection */
875
+ selectedPaymentToken?: PerpsSelectedPaymentToken | null;
876
+ }): void;
877
+ /**
878
+ * Get pending trade configuration for a market
879
+ * Returns undefined if config doesn't exist or has expired (more than 5 minutes old)
880
+ *
881
+ * @param symbol - Market symbol
882
+ * @returns Pending trade configuration or undefined
883
+ */
884
+ getPendingTradeConfiguration(symbol: string): {
885
+ amount?: string;
886
+ leverage?: number;
887
+ takeProfitPrice?: string;
888
+ stopLossPrice?: string;
889
+ limitPrice?: string;
890
+ orderType?: OrderType;
891
+ selectedPaymentToken?: PerpsSelectedPaymentToken | null;
892
+ } | undefined;
893
+ /**
894
+ * Clear pending trade configuration for a market
895
+ *
896
+ * @param symbol - Market symbol
897
+ */
898
+ clearPendingTradeConfiguration(symbol: string): void;
899
+ /**
900
+ * Get saved market filter preferences
901
+ * Handles backward compatibility with legacy string format
902
+ *
903
+ * @returns The saved sort option ID and direction.
904
+ */
905
+ getMarketFilterPreferences(): {
906
+ optionId: SortOptionId;
907
+ direction: SortDirection;
908
+ };
909
+ /**
910
+ * Save market filter preferences
911
+ *
912
+ * @param optionId - Sort/filter option ID
913
+ * @param direction - Sort direction ('asc' or 'desc')
914
+ */
915
+ saveMarketFilterPreferences(optionId: SortOptionId, direction: SortDirection): void;
916
+ /**
917
+ * Set the selected payment token for the Perps order/deposit flow.
918
+ * Pass null or a token with description PERPS_CONSTANTS.PerpsBalanceTokenDescription to select Perps balance.
919
+ * Only required fields (address, chainId) are stored in state; description and symbol are optional.
920
+ *
921
+ * @param token - The token identifier.
922
+ */
923
+ setSelectedPaymentToken(token: PerpsSelectedPaymentToken | null): void;
924
+ /**
925
+ * Reset the selected payment token to Perps balance (null).
926
+ * Call when leaving the Perps order view so the next visit defaults to Perps balance.
927
+ */
928
+ resetSelectedPaymentToken(): void;
929
+ /**
930
+ * Get saved order book grouping for a market
931
+ *
932
+ * @param symbol - Market symbol
933
+ * @returns The saved grouping value or undefined if not set
934
+ */
935
+ getOrderBookGrouping(symbol: string): number | undefined;
936
+ /**
937
+ * Save order book grouping for a market
938
+ *
939
+ * @param symbol - Market symbol
940
+ * @param grouping - Price grouping value
941
+ */
942
+ saveOrderBookGrouping(symbol: string, grouping: number): void;
943
+ /**
944
+ * Toggle watchlist status for a market
945
+ * Watchlist markets are stored per network (testnet/mainnet)
946
+ *
947
+ * @param symbol - The trading pair symbol.
948
+ */
949
+ toggleWatchlistMarket(symbol: string): void;
950
+ /**
951
+ * Check if a market is in the watchlist on the current network
952
+ *
953
+ * @param symbol - The trading pair symbol.
954
+ * @returns True if the condition is met.
955
+ */
956
+ isWatchlistMarket(symbol: string): boolean;
957
+ /**
958
+ * Get all watchlist markets for the current network
959
+ *
960
+ * @returns The resulting string value.
961
+ */
962
+ getWatchlistMarkets(): string[];
963
+ /**
964
+ * Report order events to data lake API with retry (non-blocking)
965
+ * Thin delegation to DataLakeService
966
+ *
967
+ * @param params - The operation parameters.
968
+ * @param params.action - The order action.
969
+ * @param params.symbol - The trading pair symbol.
970
+ * @param params.slPrice - The stop loss price.
971
+ * @param params.tpPrice - The take profit price.
972
+ * @param params.retryCount - Internal retry counter.
973
+ * @param params._traceId - Internal trace ID.
974
+ * @returns Whether the report was sent successfully, with an optional error message.
975
+ */
976
+ protected reportOrderToDataLake(params: {
977
+ action: 'open' | 'close';
978
+ symbol: string;
979
+ slPrice?: number;
980
+ tpPrice?: number;
981
+ retryCount?: number;
982
+ _traceId?: string;
983
+ }): Promise<{
984
+ success: boolean;
985
+ error?: string;
986
+ }>;
93
987
  /**
94
- * Constructs a new {@link PerpsController}.
988
+ * Check if the controller is currently reinitializing
95
989
  *
96
- * @param args - The arguments to this controller.
97
- * @param args.messenger - The messenger suited for this controller.
98
- * @param args.state - The desired state with which to initialize this
99
- * controller. Missing properties will be filled in with defaults.
990
+ * @returns true if providers are being reinitialized
100
991
  */
101
- constructor({ messenger, state, }: {
102
- messenger: PerpsControllerMessenger;
103
- state?: Partial<PerpsControllerState>;
104
- });
992
+ isCurrentlyReinitializing(): boolean;
105
993
  }
106
- export {};
107
994
  //# sourceMappingURL=PerpsController.d.cts.map