@metamask-previews/perps-controller 13.1.0-preview-8c2a2eeb2 → 13.1.0-preview-4f4c98e

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 (716) hide show
  1. package/CHANGELOG.md +4 -1
  2. package/dist/{PerpsController-method-action-types.d.mts → PerpsController-method-action-types.d.ts} +2 -2
  3. package/dist/PerpsController-method-action-types.d.ts.map +1 -0
  4. package/dist/{PerpsController-method-action-types.mjs → PerpsController-method-action-types.js} +1 -1
  5. package/dist/PerpsController-method-action-types.js.map +1 -0
  6. package/dist/{PerpsController.d.mts → PerpsController.d.ts} +17 -17
  7. package/dist/PerpsController.d.ts.map +1 -0
  8. package/dist/{PerpsController.mjs → PerpsController.js} +33 -31
  9. package/dist/PerpsController.js.map +1 -0
  10. package/dist/aggregation/{SubscriptionMultiplexer.d.cts → SubscriptionMultiplexer.d.ts} +2 -2
  11. package/dist/aggregation/SubscriptionMultiplexer.d.ts.map +1 -0
  12. package/dist/aggregation/{SubscriptionMultiplexer.mjs → SubscriptionMultiplexer.js} +3 -3
  13. package/dist/aggregation/SubscriptionMultiplexer.js.map +1 -0
  14. package/dist/aggregation/index.d.ts +6 -0
  15. package/dist/aggregation/index.d.ts.map +1 -0
  16. package/dist/aggregation/index.js +5 -0
  17. package/dist/aggregation/index.js.map +1 -0
  18. package/dist/constants/{chartConfig.d.mts → chartConfig.d.ts} +34 -34
  19. package/dist/constants/chartConfig.d.ts.map +1 -0
  20. package/dist/constants/{chartConfig.mjs → chartConfig.js} +1 -1
  21. package/dist/constants/chartConfig.js.map +1 -0
  22. package/dist/constants/eventNames.d.ts +555 -0
  23. package/dist/constants/eventNames.d.ts.map +1 -0
  24. package/dist/constants/{eventNames.mjs → eventNames.js} +1 -1
  25. package/dist/constants/eventNames.js.map +1 -0
  26. package/dist/constants/{hyperLiquidConfig.d.cts → hyperLiquidConfig.d.ts} +12 -12
  27. package/dist/constants/hyperLiquidConfig.d.ts.map +1 -0
  28. package/dist/constants/{hyperLiquidConfig.mjs → hyperLiquidConfig.js} +4 -4
  29. package/dist/constants/hyperLiquidConfig.js.map +1 -0
  30. package/dist/constants/index.d.ts +12 -0
  31. package/dist/constants/index.d.ts.map +1 -0
  32. package/dist/constants/index.js +12 -0
  33. package/dist/constants/index.js.map +1 -0
  34. package/dist/constants/{myxConfig.d.mts → myxConfig.d.ts} +9 -8
  35. package/dist/constants/myxConfig.d.ts.map +1 -0
  36. package/dist/constants/{myxConfig.mjs → myxConfig.js} +2 -2
  37. package/dist/constants/myxConfig.js.map +1 -0
  38. package/dist/constants/{orderTypes.d.cts → orderTypes.d.ts} +7 -7
  39. package/dist/constants/orderTypes.d.ts.map +1 -0
  40. package/dist/constants/{orderTypes.mjs → orderTypes.js} +1 -1
  41. package/dist/constants/orderTypes.js.map +1 -0
  42. package/dist/constants/{performanceMetrics.d.cts → performanceMetrics.d.ts} +1 -1
  43. package/dist/constants/performanceMetrics.d.ts.map +1 -0
  44. package/dist/constants/{performanceMetrics.mjs → performanceMetrics.js} +1 -1
  45. package/dist/constants/performanceMetrics.js.map +1 -0
  46. package/dist/constants/{perpsConfig.d.mts → perpsConfig.d.ts} +56 -56
  47. package/dist/constants/perpsConfig.d.ts.map +1 -0
  48. package/dist/constants/{perpsConfig.mjs → perpsConfig.js} +1 -1
  49. package/dist/constants/perpsConfig.js.map +1 -0
  50. package/dist/constants/{transactionsHistoryConfig.d.cts → transactionsHistoryConfig.d.ts} +1 -1
  51. package/dist/constants/transactionsHistoryConfig.d.ts.map +1 -0
  52. package/dist/constants/{transactionsHistoryConfig.mjs → transactionsHistoryConfig.js} +1 -1
  53. package/dist/constants/transactionsHistoryConfig.js.map +1 -0
  54. package/dist/{index.d.mts → index.d.ts} +64 -64
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/{index.mjs → index.js} +41 -41
  57. package/dist/index.js.map +1 -0
  58. package/dist/perpsErrorCodes.d.ts +104 -0
  59. package/dist/perpsErrorCodes.d.ts.map +1 -0
  60. package/dist/{perpsErrorCodes.mjs → perpsErrorCodes.js} +1 -1
  61. package/dist/perpsErrorCodes.js.map +1 -0
  62. package/dist/providers/{AggregatedPerpsProvider.d.cts → AggregatedPerpsProvider.d.ts} +5 -5
  63. package/dist/providers/AggregatedPerpsProvider.d.ts.map +1 -0
  64. package/dist/providers/{AggregatedPerpsProvider.mjs → AggregatedPerpsProvider.js} +5 -5
  65. package/dist/providers/AggregatedPerpsProvider.js.map +1 -0
  66. package/dist/providers/{HyperLiquidProvider.d.mts → HyperLiquidProvider.d.ts} +7 -7
  67. package/dist/providers/HyperLiquidProvider.d.ts.map +1 -0
  68. package/dist/providers/{HyperLiquidProvider.mjs → HyperLiquidProvider.js} +48 -50
  69. package/dist/providers/HyperLiquidProvider.js.map +1 -0
  70. package/dist/routing/{ProviderRouter.d.mts → ProviderRouter.d.ts} +2 -2
  71. package/dist/routing/ProviderRouter.d.ts.map +1 -0
  72. package/dist/routing/{ProviderRouter.mjs → ProviderRouter.js} +1 -1
  73. package/dist/routing/ProviderRouter.js.map +1 -0
  74. package/dist/routing/index.d.ts +6 -0
  75. package/dist/routing/index.d.ts.map +1 -0
  76. package/dist/routing/index.js +5 -0
  77. package/dist/routing/index.js.map +1 -0
  78. package/dist/{selectors.d.mts → selectors.d.ts} +97 -97
  79. package/dist/selectors.d.ts.map +1 -0
  80. package/dist/{selectors.mjs → selectors.js} +4 -4
  81. package/dist/selectors.js.map +1 -0
  82. package/dist/services/{AccountService.d.cts → AccountService.d.ts} +4 -4
  83. package/dist/services/AccountService.d.ts.map +1 -0
  84. package/dist/services/{AccountService.mjs → AccountService.js} +9 -9
  85. package/dist/services/AccountService.js.map +1 -0
  86. package/dist/services/{AggregatedOrderBookConnection.d.cts → AggregatedOrderBookConnection.d.ts} +2 -2
  87. package/dist/services/AggregatedOrderBookConnection.d.ts.map +1 -0
  88. package/dist/services/{AggregatedOrderBookConnection.mjs → AggregatedOrderBookConnection.js} +3 -3
  89. package/dist/services/AggregatedOrderBookConnection.js.map +1 -0
  90. package/dist/services/{DataLakeService.d.cts → DataLakeService.d.ts} +4 -4
  91. package/dist/services/DataLakeService.d.ts.map +1 -0
  92. package/dist/services/{DataLakeService.mjs → DataLakeService.js} +7 -7
  93. package/dist/services/DataLakeService.js.map +1 -0
  94. package/dist/services/{DepositService.d.cts → DepositService.d.ts} +4 -4
  95. package/dist/services/DepositService.d.ts.map +1 -0
  96. package/dist/services/{DepositService.mjs → DepositService.js} +7 -7
  97. package/dist/services/DepositService.js.map +1 -0
  98. package/dist/services/{DexDiscoveryCacheManager.d.cts → DexDiscoveryCacheManager.d.ts} +2 -2
  99. package/dist/services/DexDiscoveryCacheManager.d.ts.map +1 -0
  100. package/dist/services/{DexDiscoveryCacheManager.mjs → DexDiscoveryCacheManager.js} +2 -2
  101. package/dist/services/DexDiscoveryCacheManager.js.map +1 -0
  102. package/dist/services/{EligibilityService.d.cts → EligibilityService.d.ts} +2 -2
  103. package/dist/services/EligibilityService.d.ts.map +1 -0
  104. package/dist/services/{EligibilityService.mjs → EligibilityService.js} +3 -3
  105. package/dist/services/EligibilityService.js.map +1 -0
  106. package/dist/services/{FeatureFlagConfigurationService.d.cts → FeatureFlagConfigurationService.d.ts} +3 -3
  107. package/dist/services/FeatureFlagConfigurationService.d.ts.map +1 -0
  108. package/dist/services/{FeatureFlagConfigurationService.mjs → FeatureFlagConfigurationService.js} +7 -7
  109. package/dist/services/FeatureFlagConfigurationService.js.map +1 -0
  110. package/dist/services/{HyperLiquidClientService.d.cts → HyperLiquidClientService.d.ts} +10 -10
  111. package/dist/services/HyperLiquidClientService.d.ts.map +1 -0
  112. package/dist/services/{HyperLiquidClientService.mjs → HyperLiquidClientService.js} +11 -11
  113. package/dist/services/HyperLiquidClientService.js.map +1 -0
  114. package/dist/services/{HyperLiquidSubscriptionService.d.cts → HyperLiquidSubscriptionService.d.ts} +6 -6
  115. package/dist/services/HyperLiquidSubscriptionService.d.ts.map +1 -0
  116. package/dist/services/{HyperLiquidSubscriptionService.mjs → HyperLiquidSubscriptionService.js} +12 -12
  117. package/dist/services/HyperLiquidSubscriptionService.js.map +1 -0
  118. package/dist/services/{HyperLiquidWalletService.d.cts → HyperLiquidWalletService.d.ts} +4 -4
  119. package/dist/services/HyperLiquidWalletService.d.ts.map +1 -0
  120. package/dist/services/{HyperLiquidWalletService.mjs → HyperLiquidWalletService.js} +5 -5
  121. package/dist/services/HyperLiquidWalletService.js.map +1 -0
  122. package/dist/services/{MarketDataService.d.cts → MarketDataService.d.ts} +5 -5
  123. package/dist/services/MarketDataService.d.ts.map +1 -0
  124. package/dist/services/{MarketDataService.mjs → MarketDataService.js} +9 -9
  125. package/dist/services/MarketDataService.js.map +1 -0
  126. package/dist/services/{RewardsIntegrationService.d.cts → RewardsIntegrationService.d.ts} +3 -3
  127. package/dist/services/RewardsIntegrationService.d.ts.map +1 -0
  128. package/dist/services/{RewardsIntegrationService.mjs → RewardsIntegrationService.js} +6 -6
  129. package/dist/services/RewardsIntegrationService.js.map +1 -0
  130. package/dist/services/{ServiceContext.d.cts → ServiceContext.d.ts} +3 -3
  131. package/dist/services/ServiceContext.d.ts.map +1 -0
  132. package/dist/services/ServiceContext.js +2 -0
  133. package/dist/services/ServiceContext.js.map +1 -0
  134. package/dist/services/{TerminalMarketService.d.cts → TerminalMarketService.d.ts} +2 -2
  135. package/dist/services/TerminalMarketService.d.ts.map +1 -0
  136. package/dist/services/{TerminalMarketService.mjs → TerminalMarketService.js} +9 -9
  137. package/dist/services/TerminalMarketService.js.map +1 -0
  138. package/dist/services/{TradingReadinessCache.d.mts → TradingReadinessCache.d.ts} +1 -1
  139. package/dist/services/TradingReadinessCache.d.ts.map +1 -0
  140. package/dist/services/{TradingReadinessCache.mjs → TradingReadinessCache.js} +1 -1
  141. package/dist/services/TradingReadinessCache.js.map +1 -0
  142. package/dist/services/{TradingService.d.cts → TradingService.d.ts} +4 -4
  143. package/dist/services/TradingService.d.ts.map +1 -0
  144. package/dist/services/{TradingService.mjs → TradingService.js} +10 -10
  145. package/dist/services/TradingService.js.map +1 -0
  146. package/dist/types/{config.d.cts → config.d.ts} +2 -2
  147. package/dist/types/config.d.ts.map +1 -0
  148. package/dist/types/config.js +2 -0
  149. package/dist/types/config.js.map +1 -0
  150. package/dist/types/{hyperliquid-types.d.cts → hyperliquid-types.d.ts} +6 -6
  151. package/dist/types/hyperliquid-types.d.ts.map +1 -0
  152. package/dist/types/{hyperliquid-types.mjs → hyperliquid-types.js} +1 -1
  153. package/dist/types/hyperliquid-types.js.map +1 -0
  154. package/dist/types/{index.d.cts → index.d.ts} +41 -41
  155. package/dist/types/index.d.ts.map +1 -0
  156. package/dist/types/{index.mjs → index.js} +3 -3
  157. package/dist/types/index.js.map +1 -0
  158. package/dist/types/{messenger.d.mts → messenger.d.ts} +11 -11
  159. package/dist/types/messenger.d.ts.map +1 -0
  160. package/dist/types/messenger.js +2 -0
  161. package/dist/types/messenger.js.map +1 -0
  162. package/dist/types/{myx-types.d.mts → myx-types.d.ts} +16 -16
  163. package/dist/types/myx-types.d.ts.map +1 -0
  164. package/dist/types/{myx-types.mjs → myx-types.js} +3 -3
  165. package/dist/types/myx-types.js.map +1 -0
  166. package/dist/types/{perps-types.d.cts → perps-types.d.ts} +4 -4
  167. package/dist/types/perps-types.d.ts.map +1 -0
  168. package/dist/types/perps-types.js +2 -0
  169. package/dist/types/perps-types.js.map +1 -0
  170. package/dist/types/{token.d.cts → token.d.ts} +2 -2
  171. package/dist/types/token.d.ts.map +1 -0
  172. package/dist/types/token.js +2 -0
  173. package/dist/types/token.js.map +1 -0
  174. package/dist/types/{transactionTypes.d.cts → transactionTypes.d.ts} +1 -1
  175. package/dist/types/transactionTypes.d.ts.map +1 -0
  176. package/dist/types/{transactionTypes.mjs → transactionTypes.js} +2 -2
  177. package/dist/types/transactionTypes.js.map +1 -0
  178. package/dist/utils/{accountUtils.d.cts → accountUtils.d.ts} +4 -4
  179. package/dist/utils/accountUtils.d.ts.map +1 -0
  180. package/dist/utils/{accountUtils.mjs → accountUtils.js} +2 -2
  181. package/dist/utils/accountUtils.js.map +1 -0
  182. package/dist/utils/{capabilitySymbols.d.mts → capabilitySymbols.d.ts} +1 -1
  183. package/dist/utils/capabilitySymbols.d.ts.map +1 -0
  184. package/dist/utils/{capabilitySymbols.mjs → capabilitySymbols.js} +1 -1
  185. package/dist/utils/capabilitySymbols.js.map +1 -0
  186. package/dist/utils/{coalescePerpsRestRequest.d.cts → coalescePerpsRestRequest.d.ts} +1 -1
  187. package/dist/utils/coalescePerpsRestRequest.d.ts.map +1 -0
  188. package/dist/utils/{coalescePerpsRestRequest.mjs → coalescePerpsRestRequest.js} +2 -2
  189. package/dist/utils/coalescePerpsRestRequest.js.map +1 -0
  190. package/dist/utils/{errorUtils.d.mts → errorUtils.d.ts} +1 -1
  191. package/dist/utils/errorUtils.d.ts.map +1 -0
  192. package/dist/utils/{errorUtils.mjs → errorUtils.js} +3 -3
  193. package/dist/utils/errorUtils.js.map +1 -0
  194. package/dist/utils/{hyperLiquidAbstraction.d.cts → hyperLiquidAbstraction.d.ts} +2 -2
  195. package/dist/utils/hyperLiquidAbstraction.d.ts.map +1 -0
  196. package/dist/utils/{hyperLiquidAbstraction.mjs → hyperLiquidAbstraction.js} +1 -1
  197. package/dist/utils/hyperLiquidAbstraction.js.map +1 -0
  198. package/dist/utils/{hyperLiquidAdapter.d.cts → hyperLiquidAdapter.d.ts} +4 -4
  199. package/dist/utils/hyperLiquidAdapter.d.ts.map +1 -0
  200. package/dist/utils/{hyperLiquidAdapter.mjs → hyperLiquidAdapter.js} +9 -9
  201. package/dist/utils/hyperLiquidAdapter.js.map +1 -0
  202. package/dist/utils/{hyperLiquidOrderBookProcessor.d.mts → hyperLiquidOrderBookProcessor.d.ts} +3 -3
  203. package/dist/utils/hyperLiquidOrderBookProcessor.d.ts.map +1 -0
  204. package/dist/utils/{hyperLiquidOrderBookProcessor.mjs → hyperLiquidOrderBookProcessor.js} +1 -1
  205. package/dist/utils/hyperLiquidOrderBookProcessor.js.map +1 -0
  206. package/dist/utils/{hyperLiquidValidation.d.cts → hyperLiquidValidation.d.ts} +4 -4
  207. package/dist/utils/hyperLiquidValidation.d.ts.map +1 -0
  208. package/dist/utils/{hyperLiquidValidation.mjs → hyperLiquidValidation.js} +6 -6
  209. package/dist/utils/hyperLiquidValidation.js.map +1 -0
  210. package/dist/utils/{idUtils.d.cts → idUtils.d.ts} +1 -1
  211. package/dist/utils/idUtils.d.ts.map +1 -0
  212. package/dist/utils/{idUtils.mjs → idUtils.js} +2 -2
  213. package/dist/utils/idUtils.js.map +1 -0
  214. package/dist/utils/index.d.ts +28 -0
  215. package/dist/utils/index.d.ts.map +1 -0
  216. package/dist/utils/{index.mjs → index.js} +21 -21
  217. package/dist/utils/index.js.map +1 -0
  218. package/dist/utils/{marketDataTransform.d.cts → marketDataTransform.d.ts} +3 -3
  219. package/dist/utils/marketDataTransform.d.ts.map +1 -0
  220. package/dist/utils/{marketDataTransform.mjs → marketDataTransform.js} +5 -5
  221. package/dist/utils/marketDataTransform.js.map +1 -0
  222. package/dist/utils/{marketSearch.d.cts → marketSearch.d.ts} +2 -2
  223. package/dist/utils/marketSearch.d.ts.map +1 -0
  224. package/dist/utils/{marketSearch.mjs → marketSearch.js} +1 -1
  225. package/dist/utils/marketSearch.js.map +1 -0
  226. package/dist/utils/{marketUtils.d.cts → marketUtils.d.ts} +3 -3
  227. package/dist/utils/marketUtils.d.ts.map +1 -0
  228. package/dist/utils/{marketUtils.mjs → marketUtils.js} +2 -2
  229. package/dist/utils/marketUtils.js.map +1 -0
  230. package/dist/utils/{myxAdapter.d.cts → myxAdapter.d.ts} +3 -3
  231. package/dist/utils/myxAdapter.d.ts.map +1 -0
  232. package/dist/utils/{myxAdapter.mjs → myxAdapter.js} +3 -3
  233. package/dist/utils/myxAdapter.js.map +1 -0
  234. package/dist/utils/{orderCalculations.d.cts → orderCalculations.d.ts} +4 -4
  235. package/dist/utils/orderCalculations.d.ts.map +1 -0
  236. package/dist/utils/{orderCalculations.mjs → orderCalculations.js} +6 -6
  237. package/dist/utils/orderCalculations.js.map +1 -0
  238. package/dist/utils/{orderTypes.d.mts → orderTypes.d.ts} +3 -3
  239. package/dist/utils/orderTypes.d.ts.map +1 -0
  240. package/dist/utils/{orderTypes.mjs → orderTypes.js} +1 -1
  241. package/dist/utils/orderTypes.js.map +1 -0
  242. package/dist/utils/{perpsConnectionAttemptContext.d.mts → perpsConnectionAttemptContext.d.ts} +1 -1
  243. package/dist/utils/perpsConnectionAttemptContext.d.ts.map +1 -0
  244. package/dist/utils/{perpsConnectionAttemptContext.mjs → perpsConnectionAttemptContext.js} +1 -1
  245. package/dist/utils/perpsConnectionAttemptContext.js.map +1 -0
  246. package/dist/utils/{perpsDiskPersistence.d.cts → perpsDiskPersistence.d.ts} +2 -2
  247. package/dist/utils/perpsDiskPersistence.d.ts.map +1 -0
  248. package/dist/utils/{perpsDiskPersistence.mjs → perpsDiskPersistence.js} +2 -2
  249. package/dist/utils/perpsDiskPersistence.js.map +1 -0
  250. package/dist/utils/{perpsFormatters.d.cts → perpsFormatters.d.ts} +1 -1
  251. package/dist/utils/perpsFormatters.d.ts.map +1 -0
  252. package/dist/utils/{perpsFormatters.mjs → perpsFormatters.js} +2 -2
  253. package/dist/utils/perpsFormatters.js.map +1 -0
  254. package/dist/utils/{rewardsUtils.d.cts → rewardsUtils.d.ts} +4 -4
  255. package/dist/utils/rewardsUtils.d.ts.map +1 -0
  256. package/dist/utils/{rewardsUtils.mjs → rewardsUtils.js} +4 -4
  257. package/dist/utils/rewardsUtils.js.map +1 -0
  258. package/dist/utils/{significantFigures.d.cts → significantFigures.d.ts} +1 -1
  259. package/dist/utils/significantFigures.d.ts.map +1 -0
  260. package/dist/utils/{significantFigures.mjs → significantFigures.js} +2 -2
  261. package/dist/utils/significantFigures.js.map +1 -0
  262. package/dist/utils/{sortMarkets.d.cts → sortMarkets.d.ts} +2 -2
  263. package/dist/utils/sortMarkets.d.ts.map +1 -0
  264. package/dist/utils/{sortMarkets.mjs → sortMarkets.js} +2 -2
  265. package/dist/utils/sortMarkets.js.map +1 -0
  266. package/dist/utils/{standaloneInfoClient.d.cts → standaloneInfoClient.d.ts} +3 -3
  267. package/dist/utils/standaloneInfoClient.d.ts.map +1 -0
  268. package/dist/utils/{standaloneInfoClient.mjs → standaloneInfoClient.js} +3 -3
  269. package/dist/utils/standaloneInfoClient.js.map +1 -0
  270. package/dist/utils/{stringParseUtils.d.cts → stringParseUtils.d.ts} +1 -1
  271. package/dist/utils/stringParseUtils.d.ts.map +1 -0
  272. package/dist/utils/{stringParseUtils.mjs → stringParseUtils.js} +1 -1
  273. package/dist/utils/stringParseUtils.js.map +1 -0
  274. package/dist/utils/{transferData.d.cts → transferData.d.ts} +1 -1
  275. package/dist/utils/transferData.d.ts.map +1 -0
  276. package/dist/utils/{transferData.mjs → transferData.js} +3 -3
  277. package/dist/utils/transferData.js.map +1 -0
  278. package/dist/utils/{wait.d.cts → wait.d.ts} +1 -1
  279. package/dist/utils/wait.d.ts.map +1 -0
  280. package/dist/utils/{wait.mjs → wait.js} +1 -1
  281. package/dist/utils/wait.js.map +1 -0
  282. package/package.json +20 -48
  283. package/dist/PerpsController-method-action-types.cjs +0 -7
  284. package/dist/PerpsController-method-action-types.cjs.map +0 -1
  285. package/dist/PerpsController-method-action-types.d.cts +0 -1163
  286. package/dist/PerpsController-method-action-types.d.cts.map +0 -1
  287. package/dist/PerpsController-method-action-types.d.mts.map +0 -1
  288. package/dist/PerpsController-method-action-types.mjs.map +0 -1
  289. package/dist/PerpsController.cjs +0 -5063
  290. package/dist/PerpsController.cjs.map +0 -1
  291. package/dist/PerpsController.d.cts +0 -1274
  292. package/dist/PerpsController.d.cts.map +0 -1
  293. package/dist/PerpsController.d.mts.map +0 -1
  294. package/dist/PerpsController.mjs.map +0 -1
  295. package/dist/aggregation/SubscriptionMultiplexer.cjs +0 -441
  296. package/dist/aggregation/SubscriptionMultiplexer.cjs.map +0 -1
  297. package/dist/aggregation/SubscriptionMultiplexer.d.cts.map +0 -1
  298. package/dist/aggregation/SubscriptionMultiplexer.d.mts +0 -171
  299. package/dist/aggregation/SubscriptionMultiplexer.d.mts.map +0 -1
  300. package/dist/aggregation/SubscriptionMultiplexer.mjs.map +0 -1
  301. package/dist/aggregation/index.cjs +0 -9
  302. package/dist/aggregation/index.cjs.map +0 -1
  303. package/dist/aggregation/index.d.cts +0 -6
  304. package/dist/aggregation/index.d.cts.map +0 -1
  305. package/dist/aggregation/index.d.mts +0 -6
  306. package/dist/aggregation/index.d.mts.map +0 -1
  307. package/dist/aggregation/index.mjs +0 -5
  308. package/dist/aggregation/index.mjs.map +0 -1
  309. package/dist/constants/chartConfig.cjs +0 -239
  310. package/dist/constants/chartConfig.cjs.map +0 -1
  311. package/dist/constants/chartConfig.d.cts +0 -228
  312. package/dist/constants/chartConfig.d.cts.map +0 -1
  313. package/dist/constants/chartConfig.d.mts.map +0 -1
  314. package/dist/constants/chartConfig.mjs.map +0 -1
  315. package/dist/constants/eventNames.cjs +0 -650
  316. package/dist/constants/eventNames.cjs.map +0 -1
  317. package/dist/constants/eventNames.d.cts +0 -555
  318. package/dist/constants/eventNames.d.cts.map +0 -1
  319. package/dist/constants/eventNames.d.mts +0 -555
  320. package/dist/constants/eventNames.d.mts.map +0 -1
  321. package/dist/constants/eventNames.mjs.map +0 -1
  322. package/dist/constants/hyperLiquidConfig.cjs +0 -607
  323. package/dist/constants/hyperLiquidConfig.cjs.map +0 -1
  324. package/dist/constants/hyperLiquidConfig.d.cts.map +0 -1
  325. package/dist/constants/hyperLiquidConfig.d.mts +0 -280
  326. package/dist/constants/hyperLiquidConfig.d.mts.map +0 -1
  327. package/dist/constants/hyperLiquidConfig.mjs.map +0 -1
  328. package/dist/constants/index.cjs +0 -28
  329. package/dist/constants/index.cjs.map +0 -1
  330. package/dist/constants/index.d.cts +0 -12
  331. package/dist/constants/index.d.cts.map +0 -1
  332. package/dist/constants/index.d.mts +0 -12
  333. package/dist/constants/index.d.mts.map +0 -1
  334. package/dist/constants/index.mjs +0 -12
  335. package/dist/constants/index.mjs.map +0 -1
  336. package/dist/constants/myxConfig.cjs +0 -253
  337. package/dist/constants/myxConfig.cjs.map +0 -1
  338. package/dist/constants/myxConfig.d.cts +0 -145
  339. package/dist/constants/myxConfig.d.cts.map +0 -1
  340. package/dist/constants/myxConfig.d.mts.map +0 -1
  341. package/dist/constants/myxConfig.mjs.map +0 -1
  342. package/dist/constants/orderTypes.cjs +0 -31
  343. package/dist/constants/orderTypes.cjs.map +0 -1
  344. package/dist/constants/orderTypes.d.cts.map +0 -1
  345. package/dist/constants/orderTypes.d.mts +0 -19
  346. package/dist/constants/orderTypes.d.mts.map +0 -1
  347. package/dist/constants/orderTypes.mjs.map +0 -1
  348. package/dist/constants/performanceMetrics.cjs +0 -63
  349. package/dist/constants/performanceMetrics.cjs.map +0 -1
  350. package/dist/constants/performanceMetrics.d.cts.map +0 -1
  351. package/dist/constants/performanceMetrics.d.mts +0 -46
  352. package/dist/constants/performanceMetrics.d.mts.map +0 -1
  353. package/dist/constants/performanceMetrics.mjs.map +0 -1
  354. package/dist/constants/perpsConfig.cjs +0 -553
  355. package/dist/constants/perpsConfig.cjs.map +0 -1
  356. package/dist/constants/perpsConfig.d.cts +0 -474
  357. package/dist/constants/perpsConfig.d.cts.map +0 -1
  358. package/dist/constants/perpsConfig.d.mts.map +0 -1
  359. package/dist/constants/perpsConfig.mjs.map +0 -1
  360. package/dist/constants/transactionsHistoryConfig.cjs +0 -38
  361. package/dist/constants/transactionsHistoryConfig.cjs.map +0 -1
  362. package/dist/constants/transactionsHistoryConfig.d.cts.map +0 -1
  363. package/dist/constants/transactionsHistoryConfig.d.mts +0 -35
  364. package/dist/constants/transactionsHistoryConfig.d.mts.map +0 -1
  365. package/dist/constants/transactionsHistoryConfig.mjs.map +0 -1
  366. package/dist/index.cjs +0 -344
  367. package/dist/index.cjs.map +0 -1
  368. package/dist/index.d.cts +0 -92
  369. package/dist/index.d.cts.map +0 -1
  370. package/dist/index.d.mts.map +0 -1
  371. package/dist/index.mjs.map +0 -1
  372. package/dist/perpsErrorCodes.cjs +0 -127
  373. package/dist/perpsErrorCodes.cjs.map +0 -1
  374. package/dist/perpsErrorCodes.d.cts +0 -104
  375. package/dist/perpsErrorCodes.d.cts.map +0 -1
  376. package/dist/perpsErrorCodes.d.mts +0 -104
  377. package/dist/perpsErrorCodes.d.mts.map +0 -1
  378. package/dist/perpsErrorCodes.mjs.map +0 -1
  379. package/dist/providers/AggregatedPerpsProvider.cjs +0 -689
  380. package/dist/providers/AggregatedPerpsProvider.cjs.map +0 -1
  381. package/dist/providers/AggregatedPerpsProvider.d.cts.map +0 -1
  382. package/dist/providers/AggregatedPerpsProvider.d.mts +0 -232
  383. package/dist/providers/AggregatedPerpsProvider.d.mts.map +0 -1
  384. package/dist/providers/AggregatedPerpsProvider.mjs.map +0 -1
  385. package/dist/providers/HyperLiquidProvider.cjs +0 -10416
  386. package/dist/providers/HyperLiquidProvider.cjs.map +0 -1
  387. package/dist/providers/HyperLiquidProvider.d.cts +0 -625
  388. package/dist/providers/HyperLiquidProvider.d.cts.map +0 -1
  389. package/dist/providers/HyperLiquidProvider.d.mts.map +0 -1
  390. package/dist/providers/HyperLiquidProvider.mjs.map +0 -1
  391. package/dist/routing/ProviderRouter.cjs +0 -154
  392. package/dist/routing/ProviderRouter.cjs.map +0 -1
  393. package/dist/routing/ProviderRouter.d.cts +0 -112
  394. package/dist/routing/ProviderRouter.d.cts.map +0 -1
  395. package/dist/routing/ProviderRouter.d.mts.map +0 -1
  396. package/dist/routing/ProviderRouter.mjs.map +0 -1
  397. package/dist/routing/index.cjs +0 -9
  398. package/dist/routing/index.cjs.map +0 -1
  399. package/dist/routing/index.d.cts +0 -6
  400. package/dist/routing/index.d.cts.map +0 -1
  401. package/dist/routing/index.d.mts +0 -6
  402. package/dist/routing/index.d.mts.map +0 -1
  403. package/dist/routing/index.mjs +0 -5
  404. package/dist/routing/index.mjs.map +0 -1
  405. package/dist/selectors.cjs +0 -264
  406. package/dist/selectors.cjs.map +0 -1
  407. package/dist/selectors.d.cts +0 -336
  408. package/dist/selectors.d.cts.map +0 -1
  409. package/dist/selectors.d.mts.map +0 -1
  410. package/dist/selectors.mjs.map +0 -1
  411. package/dist/services/AccountService.cjs +0 -324
  412. package/dist/services/AccountService.cjs.map +0 -1
  413. package/dist/services/AccountService.d.cts.map +0 -1
  414. package/dist/services/AccountService.d.mts +0 -56
  415. package/dist/services/AccountService.d.mts.map +0 -1
  416. package/dist/services/AccountService.mjs.map +0 -1
  417. package/dist/services/AggregatedOrderBookConnection.cjs +0 -405
  418. package/dist/services/AggregatedOrderBookConnection.cjs.map +0 -1
  419. package/dist/services/AggregatedOrderBookConnection.d.cts.map +0 -1
  420. package/dist/services/AggregatedOrderBookConnection.d.mts +0 -106
  421. package/dist/services/AggregatedOrderBookConnection.d.mts.map +0 -1
  422. package/dist/services/AggregatedOrderBookConnection.mjs.map +0 -1
  423. package/dist/services/DataLakeService.cjs +0 -233
  424. package/dist/services/DataLakeService.cjs.map +0 -1
  425. package/dist/services/DataLakeService.d.cts.map +0 -1
  426. package/dist/services/DataLakeService.d.mts +0 -51
  427. package/dist/services/DataLakeService.d.mts.map +0 -1
  428. package/dist/services/DataLakeService.mjs.map +0 -1
  429. package/dist/services/DepositService.cjs +0 -99
  430. package/dist/services/DepositService.cjs.map +0 -1
  431. package/dist/services/DepositService.d.cts.map +0 -1
  432. package/dist/services/DepositService.d.mts +0 -39
  433. package/dist/services/DepositService.d.mts.map +0 -1
  434. package/dist/services/DepositService.mjs.map +0 -1
  435. package/dist/services/DexDiscoveryCacheManager.cjs +0 -147
  436. package/dist/services/DexDiscoveryCacheManager.cjs.map +0 -1
  437. package/dist/services/DexDiscoveryCacheManager.d.cts.map +0 -1
  438. package/dist/services/DexDiscoveryCacheManager.d.mts +0 -52
  439. package/dist/services/DexDiscoveryCacheManager.d.mts.map +0 -1
  440. package/dist/services/DexDiscoveryCacheManager.mjs.map +0 -1
  441. package/dist/services/EligibilityService.cjs +0 -78
  442. package/dist/services/EligibilityService.cjs.map +0 -1
  443. package/dist/services/EligibilityService.d.cts.map +0 -1
  444. package/dist/services/EligibilityService.d.mts +0 -28
  445. package/dist/services/EligibilityService.d.mts.map +0 -1
  446. package/dist/services/EligibilityService.mjs.map +0 -1
  447. package/dist/services/FeatureFlagConfigurationService.cjs +0 -257
  448. package/dist/services/FeatureFlagConfigurationService.cjs.map +0 -1
  449. package/dist/services/FeatureFlagConfigurationService.d.cts.map +0 -1
  450. package/dist/services/FeatureFlagConfigurationService.d.mts +0 -73
  451. package/dist/services/FeatureFlagConfigurationService.d.mts.map +0 -1
  452. package/dist/services/FeatureFlagConfigurationService.mjs.map +0 -1
  453. package/dist/services/HyperLiquidClientService.cjs +0 -1045
  454. package/dist/services/HyperLiquidClientService.cjs.map +0 -1
  455. package/dist/services/HyperLiquidClientService.d.cts.map +0 -1
  456. package/dist/services/HyperLiquidClientService.d.mts +0 -239
  457. package/dist/services/HyperLiquidClientService.d.mts.map +0 -1
  458. package/dist/services/HyperLiquidClientService.mjs.map +0 -1
  459. package/dist/services/HyperLiquidSubscriptionService.cjs +0 -3196
  460. package/dist/services/HyperLiquidSubscriptionService.cjs.map +0 -1
  461. package/dist/services/HyperLiquidSubscriptionService.d.cts.map +0 -1
  462. package/dist/services/HyperLiquidSubscriptionService.d.mts +0 -227
  463. package/dist/services/HyperLiquidSubscriptionService.d.mts.map +0 -1
  464. package/dist/services/HyperLiquidSubscriptionService.mjs.map +0 -1
  465. package/dist/services/HyperLiquidWalletService.cjs +0 -186
  466. package/dist/services/HyperLiquidWalletService.cjs.map +0 -1
  467. package/dist/services/HyperLiquidWalletService.d.cts.map +0 -1
  468. package/dist/services/HyperLiquidWalletService.d.mts +0 -84
  469. package/dist/services/HyperLiquidWalletService.d.mts.map +0 -1
  470. package/dist/services/HyperLiquidWalletService.mjs.map +0 -1
  471. package/dist/services/MarketDataService.cjs +0 -1138
  472. package/dist/services/MarketDataService.cjs.map +0 -1
  473. package/dist/services/MarketDataService.d.cts.map +0 -1
  474. package/dist/services/MarketDataService.d.mts +0 -334
  475. package/dist/services/MarketDataService.d.mts.map +0 -1
  476. package/dist/services/MarketDataService.mjs.map +0 -1
  477. package/dist/services/RewardsIntegrationService.cjs +0 -391
  478. package/dist/services/RewardsIntegrationService.cjs.map +0 -1
  479. package/dist/services/RewardsIntegrationService.d.cts.map +0 -1
  480. package/dist/services/RewardsIntegrationService.d.mts +0 -84
  481. package/dist/services/RewardsIntegrationService.d.mts.map +0 -1
  482. package/dist/services/RewardsIntegrationService.mjs.map +0 -1
  483. package/dist/services/ServiceContext.cjs +0 -3
  484. package/dist/services/ServiceContext.cjs.map +0 -1
  485. package/dist/services/ServiceContext.d.cts.map +0 -1
  486. package/dist/services/ServiceContext.d.mts +0 -102
  487. package/dist/services/ServiceContext.d.mts.map +0 -1
  488. package/dist/services/ServiceContext.mjs +0 -2
  489. package/dist/services/ServiceContext.mjs.map +0 -1
  490. package/dist/services/TerminalMarketService.cjs +0 -623
  491. package/dist/services/TerminalMarketService.cjs.map +0 -1
  492. package/dist/services/TerminalMarketService.d.cts.map +0 -1
  493. package/dist/services/TerminalMarketService.d.mts +0 -45
  494. package/dist/services/TerminalMarketService.d.mts.map +0 -1
  495. package/dist/services/TerminalMarketService.mjs.map +0 -1
  496. package/dist/services/TradingReadinessCache.cjs +0 -329
  497. package/dist/services/TradingReadinessCache.cjs.map +0 -1
  498. package/dist/services/TradingReadinessCache.d.cts +0 -204
  499. package/dist/services/TradingReadinessCache.d.cts.map +0 -1
  500. package/dist/services/TradingReadinessCache.d.mts.map +0 -1
  501. package/dist/services/TradingReadinessCache.mjs.map +0 -1
  502. package/dist/services/TradingService.cjs +0 -1865
  503. package/dist/services/TradingService.cjs.map +0 -1
  504. package/dist/services/TradingService.d.cts.map +0 -1
  505. package/dist/services/TradingService.d.mts +0 -201
  506. package/dist/services/TradingService.d.mts.map +0 -1
  507. package/dist/services/TradingService.mjs.map +0 -1
  508. package/dist/types/config.cjs +0 -3
  509. package/dist/types/config.cjs.map +0 -1
  510. package/dist/types/config.d.cts.map +0 -1
  511. package/dist/types/config.d.mts +0 -49
  512. package/dist/types/config.d.mts.map +0 -1
  513. package/dist/types/config.mjs +0 -2
  514. package/dist/types/config.mjs.map +0 -1
  515. package/dist/types/hyperliquid-types.cjs +0 -45
  516. package/dist/types/hyperliquid-types.cjs.map +0 -1
  517. package/dist/types/hyperliquid-types.d.cts.map +0 -1
  518. package/dist/types/hyperliquid-types.d.mts +0 -67
  519. package/dist/types/hyperliquid-types.d.mts.map +0 -1
  520. package/dist/types/hyperliquid-types.mjs.map +0 -1
  521. package/dist/types/index.cjs +0 -151
  522. package/dist/types/index.cjs.map +0 -1
  523. package/dist/types/index.d.cts.map +0 -1
  524. package/dist/types/index.d.mts +0 -1951
  525. package/dist/types/index.d.mts.map +0 -1
  526. package/dist/types/index.mjs.map +0 -1
  527. package/dist/types/messenger.cjs +0 -3
  528. package/dist/types/messenger.cjs.map +0 -1
  529. package/dist/types/messenger.d.cts +0 -30
  530. package/dist/types/messenger.d.cts.map +0 -1
  531. package/dist/types/messenger.d.mts.map +0 -1
  532. package/dist/types/messenger.mjs +0 -2
  533. package/dist/types/messenger.mjs.map +0 -1
  534. package/dist/types/myx-types.cjs +0 -41
  535. package/dist/types/myx-types.cjs.map +0 -1
  536. package/dist/types/myx-types.d.cts +0 -94
  537. package/dist/types/myx-types.d.cts.map +0 -1
  538. package/dist/types/myx-types.d.mts.map +0 -1
  539. package/dist/types/myx-types.mjs.map +0 -1
  540. package/dist/types/perps-types.cjs +0 -7
  541. package/dist/types/perps-types.cjs.map +0 -1
  542. package/dist/types/perps-types.d.cts.map +0 -1
  543. package/dist/types/perps-types.d.mts +0 -184
  544. package/dist/types/perps-types.d.mts.map +0 -1
  545. package/dist/types/perps-types.mjs +0 -5
  546. package/dist/types/perps-types.mjs.map +0 -1
  547. package/dist/types/token.cjs +0 -3
  548. package/dist/types/token.cjs.map +0 -1
  549. package/dist/types/token.d.cts.map +0 -1
  550. package/dist/types/token.d.mts +0 -25
  551. package/dist/types/token.d.mts.map +0 -1
  552. package/dist/types/token.mjs +0 -2
  553. package/dist/types/token.mjs.map +0 -1
  554. package/dist/types/transactionTypes.cjs +0 -29
  555. package/dist/types/transactionTypes.cjs.map +0 -1
  556. package/dist/types/transactionTypes.d.cts.map +0 -1
  557. package/dist/types/transactionTypes.d.mts +0 -60
  558. package/dist/types/transactionTypes.d.mts.map +0 -1
  559. package/dist/types/transactionTypes.mjs.map +0 -1
  560. package/dist/utils/accountUtils.cjs +0 -236
  561. package/dist/utils/accountUtils.cjs.map +0 -1
  562. package/dist/utils/accountUtils.d.cts.map +0 -1
  563. package/dist/utils/accountUtils.d.mts +0 -72
  564. package/dist/utils/accountUtils.d.mts.map +0 -1
  565. package/dist/utils/accountUtils.mjs.map +0 -1
  566. package/dist/utils/capabilitySymbols.cjs +0 -25
  567. package/dist/utils/capabilitySymbols.cjs.map +0 -1
  568. package/dist/utils/capabilitySymbols.d.cts +0 -15
  569. package/dist/utils/capabilitySymbols.d.cts.map +0 -1
  570. package/dist/utils/capabilitySymbols.d.mts.map +0 -1
  571. package/dist/utils/capabilitySymbols.mjs.map +0 -1
  572. package/dist/utils/coalescePerpsRestRequest.cjs +0 -71
  573. package/dist/utils/coalescePerpsRestRequest.cjs.map +0 -1
  574. package/dist/utils/coalescePerpsRestRequest.d.cts.map +0 -1
  575. package/dist/utils/coalescePerpsRestRequest.d.mts +0 -32
  576. package/dist/utils/coalescePerpsRestRequest.d.mts.map +0 -1
  577. package/dist/utils/coalescePerpsRestRequest.mjs.map +0 -1
  578. package/dist/utils/errorUtils.cjs +0 -104
  579. package/dist/utils/errorUtils.cjs.map +0 -1
  580. package/dist/utils/errorUtils.d.cts +0 -50
  581. package/dist/utils/errorUtils.d.cts.map +0 -1
  582. package/dist/utils/errorUtils.d.mts.map +0 -1
  583. package/dist/utils/errorUtils.mjs.map +0 -1
  584. package/dist/utils/hyperLiquidAbstraction.cjs +0 -23
  585. package/dist/utils/hyperLiquidAbstraction.cjs.map +0 -1
  586. package/dist/utils/hyperLiquidAbstraction.d.cts.map +0 -1
  587. package/dist/utils/hyperLiquidAbstraction.d.mts +0 -11
  588. package/dist/utils/hyperLiquidAbstraction.d.mts.map +0 -1
  589. package/dist/utils/hyperLiquidAbstraction.mjs.map +0 -1
  590. package/dist/utils/hyperLiquidAdapter.cjs +0 -512
  591. package/dist/utils/hyperLiquidAdapter.cjs.map +0 -1
  592. package/dist/utils/hyperLiquidAdapter.d.cts.map +0 -1
  593. package/dist/utils/hyperLiquidAdapter.d.mts +0 -77
  594. package/dist/utils/hyperLiquidAdapter.d.mts.map +0 -1
  595. package/dist/utils/hyperLiquidAdapter.mjs.map +0 -1
  596. package/dist/utils/hyperLiquidOrderBookProcessor.cjs +0 -83
  597. package/dist/utils/hyperLiquidOrderBookProcessor.cjs.map +0 -1
  598. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts +0 -55
  599. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts.map +0 -1
  600. package/dist/utils/hyperLiquidOrderBookProcessor.d.mts.map +0 -1
  601. package/dist/utils/hyperLiquidOrderBookProcessor.mjs.map +0 -1
  602. package/dist/utils/hyperLiquidValidation.cjs +0 -799
  603. package/dist/utils/hyperLiquidValidation.cjs.map +0 -1
  604. package/dist/utils/hyperLiquidValidation.d.cts.map +0 -1
  605. package/dist/utils/hyperLiquidValidation.d.mts +0 -192
  606. package/dist/utils/hyperLiquidValidation.d.mts.map +0 -1
  607. package/dist/utils/hyperLiquidValidation.mjs.map +0 -1
  608. package/dist/utils/idUtils.cjs +0 -18
  609. package/dist/utils/idUtils.cjs.map +0 -1
  610. package/dist/utils/idUtils.d.cts.map +0 -1
  611. package/dist/utils/idUtils.d.mts +0 -6
  612. package/dist/utils/idUtils.d.mts.map +0 -1
  613. package/dist/utils/idUtils.mjs.map +0 -1
  614. package/dist/utils/index.cjs +0 -65
  615. package/dist/utils/index.cjs.map +0 -1
  616. package/dist/utils/index.d.cts +0 -28
  617. package/dist/utils/index.d.cts.map +0 -1
  618. package/dist/utils/index.d.mts +0 -28
  619. package/dist/utils/index.d.mts.map +0 -1
  620. package/dist/utils/index.mjs.map +0 -1
  621. package/dist/utils/marketDataTransform.cjs +0 -250
  622. package/dist/utils/marketDataTransform.cjs.map +0 -1
  623. package/dist/utils/marketDataTransform.d.cts.map +0 -1
  624. package/dist/utils/marketDataTransform.d.mts +0 -71
  625. package/dist/utils/marketDataTransform.d.mts.map +0 -1
  626. package/dist/utils/marketDataTransform.mjs.map +0 -1
  627. package/dist/utils/marketSearch.cjs +0 -111
  628. package/dist/utils/marketSearch.cjs.map +0 -1
  629. package/dist/utils/marketSearch.d.cts.map +0 -1
  630. package/dist/utils/marketSearch.d.mts +0 -48
  631. package/dist/utils/marketSearch.d.mts.map +0 -1
  632. package/dist/utils/marketSearch.mjs.map +0 -1
  633. package/dist/utils/marketUtils.cjs +0 -266
  634. package/dist/utils/marketUtils.cjs.map +0 -1
  635. package/dist/utils/marketUtils.d.cts.map +0 -1
  636. package/dist/utils/marketUtils.d.mts +0 -73
  637. package/dist/utils/marketUtils.d.mts.map +0 -1
  638. package/dist/utils/marketUtils.mjs.map +0 -1
  639. package/dist/utils/myxAdapter.cjs +0 -569
  640. package/dist/utils/myxAdapter.cjs.map +0 -1
  641. package/dist/utils/myxAdapter.d.cts.map +0 -1
  642. package/dist/utils/myxAdapter.d.mts +0 -168
  643. package/dist/utils/myxAdapter.d.mts.map +0 -1
  644. package/dist/utils/myxAdapter.mjs.map +0 -1
  645. package/dist/utils/orderCalculations.cjs +0 -823
  646. package/dist/utils/orderCalculations.cjs.map +0 -1
  647. package/dist/utils/orderCalculations.d.cts.map +0 -1
  648. package/dist/utils/orderCalculations.d.mts +0 -298
  649. package/dist/utils/orderCalculations.d.mts.map +0 -1
  650. package/dist/utils/orderCalculations.mjs.map +0 -1
  651. package/dist/utils/orderTypes.cjs +0 -301
  652. package/dist/utils/orderTypes.cjs.map +0 -1
  653. package/dist/utils/orderTypes.d.cts +0 -166
  654. package/dist/utils/orderTypes.d.cts.map +0 -1
  655. package/dist/utils/orderTypes.d.mts.map +0 -1
  656. package/dist/utils/orderTypes.mjs.map +0 -1
  657. package/dist/utils/perpsConnectionAttemptContext.cjs +0 -20
  658. package/dist/utils/perpsConnectionAttemptContext.cjs.map +0 -1
  659. package/dist/utils/perpsConnectionAttemptContext.d.cts +0 -7
  660. package/dist/utils/perpsConnectionAttemptContext.d.cts.map +0 -1
  661. package/dist/utils/perpsConnectionAttemptContext.d.mts.map +0 -1
  662. package/dist/utils/perpsConnectionAttemptContext.mjs.map +0 -1
  663. package/dist/utils/perpsDiskPersistence.cjs +0 -259
  664. package/dist/utils/perpsDiskPersistence.cjs.map +0 -1
  665. package/dist/utils/perpsDiskPersistence.d.cts.map +0 -1
  666. package/dist/utils/perpsDiskPersistence.d.mts +0 -112
  667. package/dist/utils/perpsDiskPersistence.d.mts.map +0 -1
  668. package/dist/utils/perpsDiskPersistence.mjs.map +0 -1
  669. package/dist/utils/perpsFormatters.cjs +0 -509
  670. package/dist/utils/perpsFormatters.cjs.map +0 -1
  671. package/dist/utils/perpsFormatters.d.cts.map +0 -1
  672. package/dist/utils/perpsFormatters.d.mts +0 -204
  673. package/dist/utils/perpsFormatters.d.mts.map +0 -1
  674. package/dist/utils/perpsFormatters.mjs.map +0 -1
  675. package/dist/utils/rewardsUtils.cjs +0 -98
  676. package/dist/utils/rewardsUtils.cjs.map +0 -1
  677. package/dist/utils/rewardsUtils.d.cts.map +0 -1
  678. package/dist/utils/rewardsUtils.d.mts +0 -33
  679. package/dist/utils/rewardsUtils.d.mts.map +0 -1
  680. package/dist/utils/rewardsUtils.mjs.map +0 -1
  681. package/dist/utils/significantFigures.cjs +0 -88
  682. package/dist/utils/significantFigures.cjs.map +0 -1
  683. package/dist/utils/significantFigures.d.cts.map +0 -1
  684. package/dist/utils/significantFigures.d.mts +0 -25
  685. package/dist/utils/significantFigures.d.mts.map +0 -1
  686. package/dist/utils/significantFigures.mjs.map +0 -1
  687. package/dist/utils/sortMarkets.cjs +0 -93
  688. package/dist/utils/sortMarkets.cjs.map +0 -1
  689. package/dist/utils/sortMarkets.d.cts.map +0 -1
  690. package/dist/utils/sortMarkets.d.mts +0 -25
  691. package/dist/utils/sortMarkets.d.mts.map +0 -1
  692. package/dist/utils/sortMarkets.mjs.map +0 -1
  693. package/dist/utils/standaloneInfoClient.cjs +0 -70
  694. package/dist/utils/standaloneInfoClient.cjs.map +0 -1
  695. package/dist/utils/standaloneInfoClient.d.cts.map +0 -1
  696. package/dist/utils/standaloneInfoClient.d.mts +0 -37
  697. package/dist/utils/standaloneInfoClient.d.mts.map +0 -1
  698. package/dist/utils/standaloneInfoClient.mjs.map +0 -1
  699. package/dist/utils/stringParseUtils.cjs +0 -34
  700. package/dist/utils/stringParseUtils.cjs.map +0 -1
  701. package/dist/utils/stringParseUtils.d.cts.map +0 -1
  702. package/dist/utils/stringParseUtils.d.mts +0 -11
  703. package/dist/utils/stringParseUtils.d.mts.map +0 -1
  704. package/dist/utils/stringParseUtils.mjs.map +0 -1
  705. package/dist/utils/transferData.cjs +0 -33
  706. package/dist/utils/transferData.cjs.map +0 -1
  707. package/dist/utils/transferData.d.cts.map +0 -1
  708. package/dist/utils/transferData.d.mts +0 -9
  709. package/dist/utils/transferData.d.mts.map +0 -1
  710. package/dist/utils/transferData.mjs.map +0 -1
  711. package/dist/utils/wait.cjs +0 -6
  712. package/dist/utils/wait.cjs.map +0 -1
  713. package/dist/utils/wait.d.cts.map +0 -1
  714. package/dist/utils/wait.d.mts +0 -2
  715. package/dist/utils/wait.d.mts.map +0 -1
  716. package/dist/utils/wait.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"MarketDataService.mjs","sourceRoot":"","sources":["../../src/services/MarketDataService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,EAAE,IAAI,M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AAG,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;YACnD,GAAG,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS,IAAI;gBACpC,WAAW,EAAE,IAAI,CAAC,WAAW;aAC9B,CAAC;YACF,GAAG,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC;YACrE,GAAG,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC/D,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;YACnD,GAAG,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC;YACrE,GAAG,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;SAChE,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { v4 as uuidv4 } from 'uuid';\n\nimport type { CandlePeriod } from '../constants/chartConfig.js';\nimport { PerpsMeasurementName } from '../constants/performanceMetrics.js';\nimport { PERPS_CONSTANTS } from '../constants/perpsConfig.js';\nimport { PERPS_ERROR_CODES } from '../perpsErrorCodes.js';\nimport { PerpsTraceNames, PerpsTraceOperations } from '../types/index.js';\nimport type {\n PerpsProvider,\n Position,\n GetPositionsParams,\n AccountState,\n GetAccountStateParams,\n HistoricalPortfolioResult,\n GetHistoricalPortfolioParams,\n OrderFill,\n GetOrderFillsParams,\n Funding,\n GetFundingParams,\n Order,\n GetOrdersParams,\n MarketInfo,\n GetMarketDataWithPricesParams,\n GetMarketsParams,\n GetAvailableDexsParams,\n LiquidationPriceParams,\n MaintenanceMarginParams,\n FeeCalculationParams,\n FeeCalculationResult,\n OrderParams,\n ClosePositionParams,\n AssetRoute,\n PerpsPlatformDependencies,\n PerpsMarketData,\n TerminalAssetMetadata,\n} from '../types/index.js';\nimport type { CandleData } from '../types/perps-types.js';\nimport { coalescePerpsRestRequest } from '../utils/coalescePerpsRestRequest.js';\nimport { ensureError, isAbortError } from '../utils/errorUtils.js';\nimport { applyMarketFilters } from '../utils/marketUtils.js';\nimport type { ServiceContext } from './ServiceContext.js';\n\n/**\n * MarketDataService\n *\n * Handles all read-only data-fetching operations for the Perps controller.\n * This service is stateless and delegates to the provider.\n * The controller is responsible for tracing and state management.\n *\n * Instance-based service with constructor injection of platform dependencies.\n */\nexport class MarketDataService {\n readonly #deps: PerpsPlatformDependencies;\n\n /**\n * Create a new MarketDataService instance\n *\n * @param deps - Platform dependencies for logging, metrics, etc.\n */\n constructor(deps: PerpsPlatformDependencies) {\n this.#deps = deps;\n }\n\n /**\n * Get current positions\n * Handles full orchestration: tracing, error logging, state management, and provider delegation\n *\n * @param options - The configuration options.\n * @param options.provider - The perps provider instance.\n * @param options.params - The operation parameters.\n * @param options.context - The service context for dependencies.\n * @returns The result of the operation.\n */\n async getPositions(options: {\n provider: PerpsProvider;\n params?: GetPositionsParams;\n context: ServiceContext;\n }): Promise<Position[]> {\n const { provider, params, context } = options;\n const traceId = uuidv4();\n let traceData: { success: boolean; error?: string } | undefined;\n\n try {\n this.#deps.tracer.trace({\n name: PerpsTraceNames.GetPositions,\n id: traceId,\n op: PerpsTraceOperations.Operation,\n tags: {\n provider: context.tracingContext.provider,\n isTestnet: String(context.tracingContext.isTestnet),\n },\n });\n\n const positions = await provider.getPositions(params);\n\n // Update state on success (if stateManager is provided)\n if (context.stateManager) {\n context.stateManager.update((state) => {\n state.lastUpdateTimestamp = Date.now();\n state.lastError = null;\n });\n }\n\n traceData = { success: true };\n return positions;\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : PERPS_ERROR_CODES.POSITIONS_FAILED;\n\n // Update error state (if stateManager is provided)\n if (context.stateManager) {\n context.stateManager.update((state) => {\n state.lastError = errorMessage;\n state.lastUpdateTimestamp = Date.now();\n });\n }\n\n traceData = {\n success: false,\n error: errorMessage,\n };\n\n throw error;\n } finally {\n this.#deps.tracer.endTrace({\n name: PerpsTraceNames.GetPositions,\n id: traceId,\n data: traceData,\n });\n }\n }\n\n /**\n * Get order fills for a specific user or order\n * Handles full orchestration: tracing, error logging, and provider delegation\n *\n * @param options - The configuration options.\n * @param options.provider - The perps provider instance.\n * @param options.params - The operation parameters.\n * @param options.context - The service context for dependencies.\n * @param options.forceRefresh - Bypass the request-coalesce cache end-to-end\n * (user-initiated refresh).\n * @returns The result of the operation.\n */\n async getOrderFills(options: {\n provider: PerpsProvider;\n params?: GetOrderFillsParams;\n context: ServiceContext;\n /**\n * Bypass the request-coalesce cache. Use for user-initiated refresh\n * (pull-to-refresh, polling tick) so the fetch runs fresh.\n */\n forceRefresh?: boolean;\n }): Promise<OrderFill[]> {\n const { provider, params, context, forceRefresh } = options;\n const traceId = uuidv4();\n let traceData: { success: boolean; error?: string } | undefined;\n\n try {\n this.#deps.tracer.trace({\n name: PerpsTraceNames.OrderFillsFetch,\n id: traceId,\n op: PerpsTraceOperations.Operation,\n tags: {\n provider: context.tracingContext.provider,\n isTestnet: String(context.tracingContext.isTestnet),\n },\n });\n\n // Pagination / explicit end-window callers bypass the shared cache so\n // their specific page never collides with the default \"recent fills\"\n // bucket. Day-granular startTime bucket prevents a ~90d caller from\n // sharing payloads with an all-history caller.\n const isPaginated =\n params?.limit !== undefined || params?.endTime !== undefined;\n\n if (isPaginated) {\n const result = await provider.getOrderFills(params, { forceRefresh });\n traceData = { success: true };\n return result;\n }\n\n // Non-paginated: resolve the caller's account so the cache key is\n // account-scoped. Without this, callers that omit params.accountId\n // (the common hook path) would collide on a shared \"default\" bucket —\n // after an account switch, account B could receive account A's\n // still-fresh payload until the TTL expired. Pin the resolved id onto\n // the forwarded params so the provider cannot re-resolve to a different\n // account between our resolve() and its fetch (TOCTOU guard).\n const resolvedAccountId =\n params?.accountId ?? (await provider.getCurrentAccountId());\n const pinnedParams: GetOrderFillsParams = {\n ...params,\n accountId: resolvedAccountId,\n };\n const result = await coalescePerpsRestRequest(\n [\n context.tracingContext.provider,\n context.tracingContext.isTestnet ? 'testnet' : 'mainnet',\n 'getOrderFills',\n resolvedAccountId,\n params?.aggregateByTime === true ? 'agg' : 'raw',\n params?.startTime === undefined\n ? 'unbounded'\n : `s${Math.floor(params.startTime / 86_400_000)}`,\n ].join('|'),\n () => provider.getOrderFills(pinnedParams, { forceRefresh }),\n { forceRefresh },\n );\n\n traceData = { success: true };\n return result;\n } catch (error) {\n this.#deps.logger.error(\n ensureError(error, 'MarketDataService.getOrderFills'),\n {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n provider: context.tracingContext.provider,\n network: context.tracingContext.isTestnet ? 'testnet' : 'mainnet',\n },\n context: {\n name: context.errorContext.controller,\n data: {\n method: context.errorContext.method,\n params,\n },\n },\n },\n );\n\n traceData = {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n };\n throw error;\n } finally {\n this.#deps.tracer.endTrace({\n name: PerpsTraceNames.OrderFillsFetch,\n id: traceId,\n data: traceData,\n });\n }\n }\n\n /**\n * Get historical user orders (order lifecycle)\n * Handles full orchestration: tracing, error logging, and provider delegation\n *\n * @param options - The configuration options.\n * @param options.provider - The perps provider instance.\n * @param options.params - The operation parameters.\n * @param options.context - The service context for dependencies.\n * @param options.forceRefresh - Bypass the request-coalesce cache end-to-end\n * (user-initiated refresh).\n * @returns The result of the operation.\n */\n async getOrders(options: {\n provider: PerpsProvider;\n params?: GetOrdersParams;\n context: ServiceContext;\n /**\n * Bypass the request-coalesce cache. Use for user-initiated refresh.\n */\n forceRefresh?: boolean;\n }): Promise<Order[]> {\n const { provider, params, context, forceRefresh } = options;\n const traceId = uuidv4();\n let traceData: { success: boolean; error?: string } | undefined;\n\n try {\n this.#deps.tracer.trace({\n name: PerpsTraceNames.OrdersFetch,\n id: traceId,\n op: PerpsTraceOperations.Operation,\n tags: {\n provider: context.tracingContext.provider,\n isTestnet: String(context.tracingContext.isTestnet),\n },\n });\n\n const isPaginated =\n params?.limit !== undefined ||\n params?.offset !== undefined ||\n params?.endTime !== undefined;\n\n if (isPaginated) {\n const result = await provider.getOrders(params, { forceRefresh });\n traceData = { success: true };\n return result;\n }\n\n // Non-paginated: resolve the caller's account so the cache key is\n // account-scoped (see getOrderFills for rationale). Pin the resolved\n // id onto the forwarded params so the provider cannot re-resolve to a\n // different account between our resolve() and its fetch.\n const resolvedAccountId =\n params?.accountId ?? (await provider.getCurrentAccountId());\n const pinnedParams: GetOrdersParams = {\n ...params,\n accountId: resolvedAccountId,\n };\n const result = await coalescePerpsRestRequest(\n [\n context.tracingContext.provider,\n context.tracingContext.isTestnet ? 'testnet' : 'mainnet',\n 'getOrders',\n resolvedAccountId,\n ].join('|'),\n () => provider.getOrders(pinnedParams, { forceRefresh }),\n { forceRefresh },\n );\n\n traceData = { success: true };\n return result;\n } catch (error) {\n this.#deps.logger.error(\n ensureError(error, 'MarketDataService.getOrders'),\n {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n provider: context.tracingContext.provider,\n network: context.tracingContext.isTestnet ? 'testnet' : 'mainnet',\n },\n context: {\n name: context.errorContext.controller,\n data: {\n method: context.errorContext.method,\n params,\n },\n },\n },\n );\n\n traceData = {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n };\n throw error;\n } finally {\n this.#deps.tracer.endTrace({\n name: PerpsTraceNames.OrdersFetch,\n id: traceId,\n data: traceData,\n });\n }\n }\n\n /**\n * Get current open orders\n * Handles full orchestration: tracing, error logging, performance measurement, and provider delegation\n *\n * @param options - The configuration options.\n * @param options.provider - The perps provider instance.\n * @param options.params - The operation parameters.\n * @param options.context - The service context for dependencies.\n * @returns The result of the operation.\n */\n async getOpenOrders(options: {\n provider: PerpsProvider;\n params?: GetOrdersParams;\n context: ServiceContext;\n }): Promise<Order[]> {\n const { provider, params, context } = options;\n const traceId = uuidv4();\n const startTime = this.#deps.performance.now();\n let traceData: { success: boolean; error?: string } | undefined;\n\n try {\n this.#deps.tracer.trace({\n name: PerpsTraceNames.OrdersFetch,\n id: traceId,\n op: PerpsTraceOperations.Operation,\n tags: {\n provider: context.tracingContext.provider,\n isTestnet: String(context.tracingContext.isTestnet),\n },\n });\n\n const result = await provider.getOpenOrders(params);\n\n const completionDuration = this.#deps.performance.now() - startTime;\n this.#deps.tracer.setMeasurement(\n PerpsMeasurementName.PerpsGetOpenOrdersOperation,\n completionDuration,\n 'millisecond',\n );\n\n traceData = { success: true };\n return result;\n } catch (error) {\n this.#deps.logger.error(\n ensureError(error, 'MarketDataService.getOpenOrders'),\n {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n provider: context.tracingContext.provider,\n network: context.tracingContext.isTestnet ? 'testnet' : 'mainnet',\n },\n context: {\n name: context.errorContext.controller,\n data: {\n method: context.errorContext.method,\n params,\n },\n },\n },\n );\n\n traceData = {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n };\n throw error;\n } finally {\n this.#deps.tracer.endTrace({\n name: PerpsTraceNames.OrdersFetch,\n id: traceId,\n data: traceData,\n });\n }\n }\n\n /**\n * Get funding rates\n * Handles full orchestration: tracing, error logging, and provider delegation\n *\n * @param options - The configuration options.\n * @param options.provider - The perps provider instance.\n * @param options.params - The operation parameters.\n * @param options.context - The service context for dependencies.\n * @param options.forceRefresh - Bypass the request-coalesce cache end-to-end\n * (user-initiated refresh).\n * @returns The result of the operation.\n */\n async getFunding(options: {\n provider: PerpsProvider;\n params?: GetFundingParams;\n context: ServiceContext;\n /**\n * Bypass the request-coalesce cache. Use for user-initiated refresh.\n */\n forceRefresh?: boolean;\n }): Promise<Funding[]> {\n const { provider, params, context, forceRefresh } = options;\n const traceId = uuidv4();\n let traceData: { success: boolean; error?: string } | undefined;\n\n try {\n this.#deps.tracer.trace({\n name: PerpsTraceNames.FundingFetch,\n id: traceId,\n op: PerpsTraceOperations.Operation,\n tags: {\n provider: context.tracingContext.provider,\n isTestnet: String(context.tracingContext.isTestnet),\n },\n });\n\n const isPaginated =\n params?.limit !== undefined ||\n params?.offset !== undefined ||\n params?.startTime !== undefined ||\n params?.endTime !== undefined;\n\n if (isPaginated) {\n const result = await provider.getFunding(params, { forceRefresh });\n traceData = { success: true };\n return result;\n }\n\n // Non-paginated: resolve the caller's account so the cache key is\n // account-scoped (see getOrderFills for rationale). Pin the resolved\n // id onto the forwarded params so the provider cannot re-resolve to a\n // different account between our resolve() and its fetch.\n const resolvedAccountId =\n params?.accountId ?? (await provider.getCurrentAccountId());\n const pinnedParams: GetFundingParams = {\n ...params,\n accountId: resolvedAccountId,\n };\n const result = await coalescePerpsRestRequest(\n [\n context.tracingContext.provider,\n context.tracingContext.isTestnet ? 'testnet' : 'mainnet',\n 'getFunding',\n resolvedAccountId,\n ].join('|'),\n () => provider.getFunding(pinnedParams, { forceRefresh }),\n { forceRefresh },\n );\n\n traceData = { success: true };\n return result;\n } catch (error) {\n this.#deps.logger.error(\n ensureError(error, 'MarketDataService.getFunding'),\n {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n provider: context.tracingContext.provider,\n network: context.tracingContext.isTestnet ? 'testnet' : 'mainnet',\n },\n context: {\n name: context.errorContext.controller,\n data: {\n method: context.errorContext.method,\n params,\n },\n },\n },\n );\n\n traceData = {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n };\n throw error;\n } finally {\n this.#deps.tracer.endTrace({\n name: PerpsTraceNames.FundingFetch,\n id: traceId,\n data: traceData,\n });\n }\n }\n\n /**\n * Get account state\n * Handles full orchestration: tracing, error logging, state management, and provider delegation\n *\n * @param options - The configuration options.\n * @param options.provider - The perps provider instance.\n * @param options.params - The operation parameters.\n * @param options.context - The service context for dependencies.\n * @returns The result of the operation.\n */\n async getAccountState(options: {\n provider: PerpsProvider;\n params?: GetAccountStateParams;\n context: ServiceContext;\n }): Promise<AccountState> {\n const { provider, params, context } = options;\n const traceId = uuidv4();\n let traceData: { success: boolean; error?: string } | undefined;\n\n try {\n this.#deps.tracer.trace({\n name: PerpsTraceNames.GetAccountState,\n id: traceId,\n op: PerpsTraceOperations.Operation,\n tags: {\n provider: context.tracingContext.provider,\n isTestnet: String(context.tracingContext.isTestnet),\n source: params?.source ?? 'unknown',\n },\n });\n\n const accountState = await provider.getAccountState(params);\n\n // Safety check for accountState\n if (!accountState) {\n const error = new Error(\n 'Failed to get account state: received null/undefined response',\n );\n\n this.#deps.logger.error(\n ensureError(error, 'MarketDataService.getAccountState'),\n {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n provider: context.tracingContext.provider,\n network: context.tracingContext.isTestnet ? 'testnet' : 'mainnet',\n },\n context: {\n name: context.errorContext.controller,\n data: {\n method: context.errorContext.method,\n operation: 'nullAccountStateCheck',\n },\n },\n },\n );\n\n throw error;\n }\n\n // Update state on success (if stateManager is provided)\n if (context.stateManager) {\n context.stateManager.update((state) => {\n state.accountState = accountState;\n state.lastUpdateTimestamp = Date.now();\n state.lastError = null;\n });\n }\n\n traceData = { success: true };\n return accountState;\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'Account state fetch failed';\n\n // Update error state (if stateManager is provided)\n if (context.stateManager) {\n context.stateManager.update((state) => {\n state.lastError = errorMessage;\n state.lastUpdateTimestamp = Date.now();\n });\n }\n\n traceData = {\n success: false,\n error: errorMessage,\n };\n\n throw error;\n } finally {\n this.#deps.tracer.endTrace({\n name: PerpsTraceNames.GetAccountState,\n id: traceId,\n data: traceData,\n });\n }\n }\n\n /**\n * Get historical portfolio data\n * Handles full orchestration: tracing, error logging, state management, and provider delegation\n *\n * @param options - The configuration options.\n * @param options.provider - The perps provider instance.\n * @param options.params - The operation parameters.\n * @param options.context - The service context for dependencies.\n * @returns The result of the operation.\n */\n async getHistoricalPortfolio(options: {\n provider: PerpsProvider;\n params?: GetHistoricalPortfolioParams;\n context: ServiceContext;\n }): Promise<HistoricalPortfolioResult> {\n const { provider, params, context } = options;\n const traceId = uuidv4();\n let traceData: { success: boolean; error?: string } | undefined;\n\n try {\n this.#deps.tracer.trace({\n name: PerpsTraceNames.GetHistoricalPortfolio,\n id: traceId,\n op: PerpsTraceOperations.Operation,\n tags: {\n provider: context.tracingContext.provider,\n isTestnet: String(context.tracingContext.isTestnet),\n },\n });\n\n if (!provider.getHistoricalPortfolio) {\n throw new Error('Historical portfolio not supported by provider');\n }\n\n const result = await provider.getHistoricalPortfolio(params);\n\n traceData = { success: true };\n return result;\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : 'Failed to get historical portfolio';\n\n this.#deps.logger.error(\n ensureError(error, 'MarketDataService.getHistoricalPortfolio'),\n {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n provider: context.tracingContext.provider,\n network: context.tracingContext.isTestnet ? 'testnet' : 'mainnet',\n },\n context: {\n name: context.errorContext.controller,\n data: {\n method: context.errorContext.method,\n params,\n },\n },\n },\n );\n\n // Update error state (if stateManager is provided)\n if (context.stateManager) {\n context.stateManager.update((state) => {\n state.lastError = errorMessage;\n state.lastUpdateTimestamp = Date.now();\n });\n }\n\n traceData = {\n success: false,\n error: errorMessage,\n };\n\n throw error;\n } finally {\n this.#deps.tracer.endTrace({\n name: PerpsTraceNames.GetHistoricalPortfolio,\n id: traceId,\n data: traceData,\n });\n }\n }\n\n /**\n * Get available markets\n * Handles full orchestration: tracing, error logging, state management, and provider delegation.\n * When `useTerminalApi` is true, attempts the Terminal API first; on failure or empty\n * response, falls back silently to the HyperLiquid provider path.\n *\n * @param options - The configuration options.\n * @param options.provider - The perps provider instance.\n * @param options.params - The operation parameters.\n * @param options.context - The service context for dependencies.\n * @param options.isMarketAllowed - Optional filter callback applied to\n * Terminal API results so that allowlist/blocklist rules from the provider\n * layer are enforced even when the provider is bypassed. Skipped when\n * `params.skipFilters` is true.\n * @returns The result of the operation.\n */\n async getMarkets(options: {\n provider: PerpsProvider;\n params?: GetMarketsParams;\n context: ServiceContext;\n isMarketAllowed?: (symbol: string) => boolean;\n }): Promise<MarketInfo[]> {\n const { provider, params, context, isMarketAllowed } = options;\n const useTerminalApi = params?.useTerminalApi;\n const traceId = uuidv4();\n let traceData: { success: boolean; error?: string } | undefined;\n\n try {\n this.#deps.tracer.trace({\n name: PerpsTraceNames.GetMarkets,\n id: traceId,\n op: PerpsTraceOperations.Operation,\n tags: {\n provider: context.tracingContext.provider,\n isTestnet: String(context.tracingContext.isTestnet),\n ...(params?.symbols && {\n symbolCount: String(params.symbols.length),\n }),\n ...(params?.dex !== undefined && { dex: params.dex }),\n ...(useTerminalApi !== undefined && {\n useTerminalApi: String(useTerminalApi),\n }),\n },\n });\n\n // Terminal API path: attempt first when flag is enabled\n if (useTerminalApi && this.#deps.terminalMarketService) {\n try {\n const { markets: terminalMarkets } =\n await this.#deps.terminalMarketService.fetchMarkets();\n if (terminalMarkets.length > 0) {\n let filtered = terminalMarkets;\n\n // Apply allowlist/blocklist filtering (same as provider path)\n if (!params?.skipFilters && isMarketAllowed) {\n filtered = filtered.filter((market) =>\n isMarketAllowed(market.name),\n );\n }\n\n // Filter by specific DEX when requested\n if (params?.dex !== undefined) {\n const dexPrefix = params.dex ? `${params.dex}:` : '';\n filtered = filtered.filter((market) =>\n dexPrefix\n ? market.name.startsWith(dexPrefix)\n : !market.name.includes(':'),\n );\n }\n\n // Filter by symbols when requested\n if (params?.symbols?.length) {\n filtered = filtered.filter((market) =>\n (params.symbols as string[]).some(\n (sym) => market.name.toLowerCase() === sym.toLowerCase(),\n ),\n );\n }\n\n // Fall back to provider when a constrained query (symbols or dex)\n // yields no matches — Terminal partial coverage should not hide\n // valid provider-backed markets.\n const isConstrainedQuery =\n (params?.symbols?.length ?? 0) > 0 || params?.dex !== undefined;\n if (filtered.length === 0 && isConstrainedQuery) {\n // Let execution continue to the provider path below.\n } else {\n if (context.stateManager) {\n context.stateManager.update((state) => {\n state.lastError = null;\n state.lastUpdateTimestamp = Date.now();\n });\n }\n traceData = { success: true };\n return filtered;\n }\n }\n } catch (terminalError) {\n this.#deps.terminalMarketService.logError(\n terminalError,\n 'getMarkets',\n );\n }\n }\n\n const markets = await provider.getMarkets(params);\n\n if (context.stateManager) {\n context.stateManager.update((state) => {\n state.lastError = null;\n state.lastUpdateTimestamp = Date.now();\n });\n }\n\n traceData = { success: true };\n return markets;\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : PERPS_ERROR_CODES.MARKETS_FAILED;\n\n this.#deps.logger.error(\n ensureError(error, 'MarketDataService.getMarkets'),\n {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n provider: context.tracingContext.provider,\n network: context.tracingContext.isTestnet ? 'testnet' : 'mainnet',\n },\n context: {\n name: context.errorContext.controller,\n data: {\n method: context.errorContext.method,\n params,\n },\n },\n },\n );\n\n if (context.stateManager) {\n context.stateManager.update((state) => {\n state.lastError = errorMessage;\n state.lastUpdateTimestamp = Date.now();\n });\n }\n\n traceData = {\n success: false,\n error: errorMessage,\n };\n\n throw error;\n } finally {\n this.#deps.tracer.endTrace({\n name: PerpsTraceNames.GetMarkets,\n id: traceId,\n data: traceData,\n });\n }\n }\n\n /**\n * Get market data with prices (includes price, volume, 24h change).\n * Applies optional category filtering, sorting, and limit after fetching.\n * An explicitly configured global snapshot is the preferred complete source.\n * `useTerminalApi` controls only legacy metadata enrichment of provider data.\n *\n * @param options - The configuration options.\n * @param options.provider - The perps provider instance.\n * @param options.params - Optional filter/sort/limit params.\n * @param options.context - The service context for dependencies.\n * @returns The result of the operation.\n */\n async getMarketDataWithPrices(options: {\n provider: PerpsProvider;\n params?: GetMarketDataWithPricesParams;\n context: ServiceContext;\n }): Promise<PerpsMarketData[]> {\n const { provider, params, context } = options;\n const { globalSnapshot } = context;\n const useTerminalApi = params?.useTerminalApi;\n const traceId = uuidv4();\n let traceData: { success: boolean; error?: string } | undefined;\n\n try {\n this.#deps.tracer.trace({\n name: PerpsTraceNames.GetMarketDataWithPrices,\n id: traceId,\n op: PerpsTraceOperations.Operation,\n tags: {\n provider: context.tracingContext.provider,\n isTestnet: String(context.tracingContext.isTestnet),\n ...(params?.categories && {\n categoryCount: String(params.categories.length),\n }),\n ...(useTerminalApi !== undefined && {\n useTerminalApi: String(useTerminalApi),\n }),\n },\n });\n\n // Prefer a separately configured atomic snapshot only for an exact,\n // still-current provider/network/DEX identity. A rejected snapshot has\n // one lexical fallback to the provider below and is not followed by a\n // second legacy Terminal request.\n let snapshotAttempted = false;\n if (\n globalSnapshot &&\n this.#deps.terminalMarketService?.fetchGlobalSnapshot\n ) {\n snapshotAttempted = true;\n if (!globalSnapshot.isCurrent()) {\n throw new Error('Terminal global snapshot context changed');\n }\n try {\n const snapshot =\n await this.#deps.terminalMarketService.fetchGlobalSnapshot(\n globalSnapshot.request,\n );\n if (!globalSnapshot.isCurrent()) {\n throw new Error('Terminal global snapshot context changed');\n }\n if (Date.now() >= snapshot.expiresAt) {\n throw new Error('Terminal global snapshot expired');\n }\n if (snapshot.markets.length > 0) {\n traceData = { success: true };\n const allowedMarkets = snapshot.markets.filter((market) =>\n globalSnapshot.isMarketAllowed(market.symbol),\n );\n return applyMarketFilters(allowedMarkets, params);\n }\n } catch (snapshotError) {\n if (!globalSnapshot.isCurrent()) {\n throw new Error('Terminal global snapshot context changed');\n }\n this.#deps.terminalMarketService.logError(\n snapshotError,\n 'getMarketDataWithPrices.globalSnapshot',\n );\n }\n }\n\n // Fetch Terminal API metadata before provider data when enabled.\n // Terminal metadata enriches the provider result (name, keywords, tags,\n // categories) but never replaces live pricing / funding data.\n let terminalMetadata: Map<string, TerminalAssetMetadata> | undefined;\n if (\n !snapshotAttempted &&\n useTerminalApi &&\n this.#deps.terminalMarketService\n ) {\n try {\n const result = await this.#deps.terminalMarketService.fetchMarkets();\n if (result.metadata.size > 0) {\n terminalMetadata = result.metadata;\n }\n } catch (terminalError) {\n this.#deps.terminalMarketService.logError(\n terminalError,\n 'getMarketDataWithPrices',\n );\n }\n }\n\n const markets = await provider.getMarketDataWithPrices();\n if (snapshotAttempted && globalSnapshot && !globalSnapshot.isCurrent()) {\n throw new Error('Terminal global snapshot context changed');\n }\n\n // Enrich with terminal metadata when available\n const enriched = terminalMetadata\n ? this.#enrichWithTerminalMetadata(markets, terminalMetadata)\n : markets;\n\n const filtered = applyMarketFilters(enriched, params);\n\n traceData = { success: true };\n return filtered;\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : PERPS_ERROR_CODES.MARKETS_FAILED;\n\n this.#deps.logger.error(\n ensureError(error, 'MarketDataService.getMarketDataWithPrices'),\n {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n provider: context.tracingContext.provider,\n network: context.tracingContext.isTestnet ? 'testnet' : 'mainnet',\n },\n context: {\n name: context.errorContext.controller,\n data: {\n method: context.errorContext.method,\n params,\n },\n },\n },\n );\n\n traceData = {\n success: false,\n error: errorMessage,\n };\n\n throw error;\n } finally {\n this.#deps.tracer.endTrace({\n name: PerpsTraceNames.GetMarketDataWithPrices,\n id: traceId,\n data: traceData,\n });\n }\n }\n\n /**\n * Get available DEXs (HIP-3 support required)\n *\n * @param options - The configuration options.\n * @param options.provider - The perps provider instance.\n * @param options.params - The operation parameters.\n * @param options.context - The service context for dependencies.\n * @returns The result of the operation.\n */\n async getAvailableDexs(options: {\n provider: PerpsProvider;\n params?: GetAvailableDexsParams;\n context: ServiceContext;\n }): Promise<string[]> {\n const { provider, params } = options;\n\n try {\n if (!provider.getAvailableDexs) {\n throw new Error('Provider does not support HIP-3 DEXs');\n }\n\n return await provider.getAvailableDexs(params);\n } catch (error) {\n this.#deps.logger.error(\n ensureError(error, 'MarketDataService.getAvailableDexs'),\n {\n context: {\n name: 'MarketDataService.getAvailableDexs',\n data: { params },\n },\n },\n );\n throw error;\n }\n }\n\n /**\n * Fetch historical candle data for charting\n * Handles full orchestration: tracing, error logging, state management, and provider delegation\n *\n * @param options - The configuration options.\n * @param options.provider - The perps provider instance.\n * @param options.symbol - The trading pair symbol.\n * @param options.interval - The candle interval period.\n * @param options.limit - Maximum number of items to fetch.\n * @param options.endTime - End timestamp in milliseconds.\n * @param options.context - The service context for dependencies.\n * @returns The result of the operation.\n */\n async fetchHistoricalCandles(options: {\n provider: PerpsProvider;\n symbol: string;\n interval: CandlePeriod;\n limit?: number;\n endTime?: number;\n context: ServiceContext;\n }): Promise<CandleData> {\n const {\n provider,\n symbol,\n interval,\n limit = 100,\n endTime,\n context,\n } = options;\n const traceId = uuidv4();\n let traceData: { success: boolean; error?: string } | undefined;\n\n try {\n this.#deps.tracer.trace({\n name: PerpsTraceNames.FetchHistoricalCandles,\n id: traceId,\n op: PerpsTraceOperations.Operation,\n tags: {\n provider: context.tracingContext.provider,\n isTestnet: String(context.tracingContext.isTestnet),\n symbol,\n interval,\n },\n });\n\n if (!provider.fetchHistoricalCandles) {\n throw new Error('Historical candles not supported by provider');\n }\n\n const result = await provider.fetchHistoricalCandles({\n symbol,\n interval,\n limit,\n endTime,\n });\n\n traceData = { success: true };\n return result;\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : 'Failed to fetch historical candles';\n\n // Expected cancellation — skip Sentry and state updates\n if (!isAbortError(error)) {\n this.#deps.logger.error(\n ensureError(error, 'MarketDataService.fetchHistoricalCandles'),\n {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n provider: context.tracingContext.provider,\n network: context.tracingContext.isTestnet ? 'testnet' : 'mainnet',\n },\n context: {\n name: context.errorContext.controller,\n data: {\n method: context.errorContext.method,\n symbol,\n interval,\n limit,\n endTime,\n },\n },\n },\n );\n\n // Update error state (if stateManager is provided)\n if (context.stateManager) {\n context.stateManager.update((state) => {\n state.lastError = errorMessage;\n state.lastUpdateTimestamp = Date.now();\n });\n }\n }\n\n traceData = {\n success: false,\n error: errorMessage,\n };\n\n throw error;\n } finally {\n this.#deps.tracer.endTrace({\n name: PerpsTraceNames.FetchHistoricalCandles,\n id: traceId,\n data: traceData,\n });\n }\n }\n\n /**\n * Calculate liquidation price for a position\n *\n * @param options - The configuration options.\n * @param options.provider - The perps provider instance.\n * @param options.params - The operation parameters.\n * @param options.context - The service context for dependencies.\n * @returns The result of the operation.\n */\n async calculateLiquidationPrice(options: {\n provider: PerpsProvider;\n params: LiquidationPriceParams;\n context: ServiceContext;\n }): Promise<string> {\n const { provider, params } = options;\n\n try {\n return await provider.calculateLiquidationPrice(params);\n } catch (error) {\n this.#deps.logger.error(\n ensureError(error, 'MarketDataService.calculateLiquidationPrice'),\n {\n context: {\n name: 'MarketDataService.calculateLiquidationPrice',\n data: { params },\n },\n },\n );\n throw error;\n }\n }\n\n /**\n * Calculate maintenance margin for a position\n *\n * @param options - The configuration options.\n * @param options.provider - The perps provider instance.\n * @param options.params - The operation parameters.\n * @param options.context - The service context for dependencies.\n * @returns The result of the operation.\n */\n async calculateMaintenanceMargin(options: {\n provider: PerpsProvider;\n params: MaintenanceMarginParams;\n context: ServiceContext;\n }): Promise<number> {\n const { provider, params } = options;\n\n try {\n return await provider.calculateMaintenanceMargin(params);\n } catch (error) {\n this.#deps.logger.error(\n ensureError(error, 'MarketDataService.calculateMaintenanceMargin'),\n {\n context: {\n name: 'MarketDataService.calculateMaintenanceMargin',\n data: { params },\n },\n },\n );\n throw error;\n }\n }\n\n /**\n * Get maximum leverage for an asset\n *\n * @param options - The configuration options.\n * @param options.provider - The perps provider instance.\n * @param options.asset - The asset identifier.\n * @param options.context - The service context for dependencies.\n * @returns The result of the operation.\n */\n async getMaxLeverage(options: {\n provider: PerpsProvider;\n asset: string;\n context: ServiceContext;\n }): Promise<number> {\n const { provider, asset } = options;\n\n try {\n return await provider.getMaxLeverage(asset);\n } catch (error) {\n this.#deps.logger.error(\n ensureError(error, 'MarketDataService.getMaxLeverage'),\n {\n context: {\n name: 'MarketDataService.getMaxLeverage',\n data: { asset },\n },\n },\n );\n throw error;\n }\n }\n\n /**\n * Calculate fees for an order\n *\n * @param options - The configuration options.\n * @param options.provider - The perps provider instance.\n * @param options.params - The operation parameters.\n * @param options.context - The service context for dependencies.\n * @returns The result of the operation.\n */\n async calculateFees(options: {\n provider: PerpsProvider;\n params: FeeCalculationParams;\n context: ServiceContext;\n }): Promise<FeeCalculationResult> {\n const { provider, params, context } = options;\n\n try {\n const fees = await provider.calculateFees(params);\n\n // Read-only preview of the same cached benefits snapshot the fee resolver\n // reads. The quoted rates are left untouched: surfacing eligibility and\n // the remaining notional must not mutate the cap or the cache.\n return context.subscriptionFeeWaiver\n ? { ...fees, subscription: context.subscriptionFeeWaiver }\n : fees;\n } catch (error) {\n this.#deps.logger.error(\n ensureError(error, 'MarketDataService.calculateFees'),\n {\n context: {\n name: 'MarketDataService.calculateFees',\n data: { params },\n },\n },\n );\n throw error;\n }\n }\n\n /**\n * Validate an order before placement\n *\n * @param options - The configuration options.\n * @param options.provider - The perps provider instance.\n * @param options.params - The operation parameters.\n * @param options.context - The service context for dependencies.\n * @returns The result of the operation.\n */\n async validateOrder(options: {\n provider: PerpsProvider;\n params: OrderParams;\n context: ServiceContext;\n }): Promise<{ isValid: boolean; error?: string }> {\n const { provider, params } = options;\n\n try {\n return await provider.validateOrder(params);\n } catch (error) {\n this.#deps.logger.error(\n ensureError(error, 'MarketDataService.validateOrder'),\n {\n context: {\n name: 'MarketDataService.validateOrder',\n data: { params },\n },\n },\n );\n throw error;\n }\n }\n\n /**\n * Validate a position close request\n *\n * @param options - The configuration options.\n * @param options.provider - The perps provider instance.\n * @param options.params - The operation parameters.\n * @param options.context - The service context for dependencies.\n * @returns The result of the operation.\n */\n async validateClosePosition(options: {\n provider: PerpsProvider;\n params: ClosePositionParams;\n context: ServiceContext;\n }): Promise<{ isValid: boolean; error?: string }> {\n const { provider, params } = options;\n\n try {\n return await provider.validateClosePosition(params);\n } catch (error) {\n this.#deps.logger.error(\n ensureError(error, 'MarketDataService.validateClosePosition'),\n {\n context: {\n name: 'MarketDataService.validateClosePosition',\n data: { params },\n },\n },\n );\n throw error;\n }\n }\n\n /**\n * Get supported withdrawal routes (synchronous)\n * Note: This method doesn't log errors to avoid needing context for a synchronous getter\n *\n * @param options - The configuration options.\n * @param options.provider - The perps provider instance.\n * @returns The result of the operation.\n */\n getWithdrawalRoutes(options: { provider: PerpsProvider }): AssetRoute[] {\n const { provider } = options;\n\n try {\n return provider.getWithdrawalRoutes();\n } catch {\n // Silent fail - withdrawal routes are not critical\n return [];\n }\n }\n\n /**\n * Get block explorer URL (synchronous)\n *\n * @param options - The configuration options.\n * @param options.provider - The perps provider instance.\n * @param options.address - The wallet address.\n * @returns The result of the operation.\n */\n getBlockExplorerUrl(options: {\n provider: PerpsProvider;\n address?: string;\n }): string {\n const { provider, address } = options;\n return provider.getBlockExplorerUrl(address);\n }\n\n /**\n * Merge Terminal API metadata into provider-sourced PerpsMarketData.\n * For each market, if the terminal metadata map contains an entry for its\n * symbol, override name/description/marketType and attach\n * keywords/tags/categories. Unmatched markets keep their provider-sourced\n * values.\n *\n * @param markets - Markets from the provider.\n * @param metadata - Per-symbol metadata from the Terminal API.\n * @returns Enriched market data array.\n */\n #enrichWithTerminalMetadata(\n markets: PerpsMarketData[],\n metadata: Map<string, TerminalAssetMetadata>,\n ): PerpsMarketData[] {\n return markets.map((market) => {\n const meta = metadata.get(market.symbol);\n if (!meta) {\n return market;\n }\n\n return {\n ...market,\n ...(meta.name !== undefined && { name: meta.name }),\n ...(meta.description !== undefined && {\n description: meta.description,\n }),\n ...(meta.marketType !== undefined && { marketType: meta.marketType }),\n ...(meta.keywords !== undefined && { keywords: meta.keywords }),\n ...(meta.tags !== undefined && { tags: meta.tags }),\n ...(meta.categories !== undefined && { categories: meta.categories }),\n ...(meta.listedAt !== undefined && { listedAt: meta.listedAt }),\n };\n });\n }\n}\n"]}
@@ -1,391 +0,0 @@
1
- "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _RewardsIntegrationService_instances, _RewardsIntegrationService_deps, _RewardsIntegrationService_messenger, _RewardsIntegrationService_benefitsSnapshot, _RewardsIntegrationService_lastAttemptAt, _RewardsIntegrationService_benefitsRefresh, _RewardsIntegrationService_benefitsEpoch, _RewardsIntegrationService_getChainIdForNetwork, _RewardsIntegrationService_readSubscriptionBenefits, _RewardsIntegrationService_calculateRewardsDiscount;
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.RewardsIntegrationService = void 0;
16
- const hyperLiquidConfig_js_1 = require("../constants/hyperLiquidConfig.cjs");
17
- const perpsConfig_js_1 = require("../constants/perpsConfig.cjs");
18
- const accountUtils_js_1 = require("../utils/accountUtils.cjs");
19
- const errorUtils_js_1 = require("../utils/errorUtils.cjs");
20
- const rewardsUtils_js_1 = require("../utils/rewardsUtils.cjs");
21
- /**
22
- * Default MetaMask builder fee, in basis points.
23
- * This is the fee every user pays when no cheaper source applies.
24
- */
25
- const DEFAULT_FEE_BIPS = hyperLiquidConfig_js_1.BUILDER_FEE_CONFIG.MaxFeeDecimal * hyperLiquidConfig_js_1.BASIS_POINTS_DIVISOR;
26
- /**
27
- * RewardsIntegrationService
28
- *
29
- * Owns the unified perps fee resolver: it considers every fee source and
30
- * returns the lowest fee, expressed as the discount bips providers consume.
31
- *
32
- * Sources, all in fee basis points (lowest wins):
33
- * - `default` — {@link BUILDER_FEE_CONFIG}, the fee with no reductions.
34
- * - `rewards` — VIP and season, collapsed into one discount by
35
- * `RewardsController` (`rewards.getPerpsDiscountForAccount`), so this service
36
- * does not re-derive the VIP/season split.
37
- * - `subscription` — `0` bips, but only when the eligibility gate passes on a
38
- * cached read of the profile's benefits.
39
- *
40
- * On a tie the cheaper-to-explain source wins, in the order
41
- * `subscription` > `rewards` > `default`.
42
- *
43
- * The benefits cache is stale-while-revalidate: fee resolution is a pure read
44
- * of the cached snapshot, while preview and lifecycle callers refresh it
45
- * explicitly. Nothing is reserved or committed client-side, so backend
46
- * exhaustion needs no release logic — the next refresh simply stops passing
47
- * the gate.
48
- *
49
- * Instance-based service with constructor injection of platform dependencies.
50
- */
51
- class RewardsIntegrationService {
52
- /**
53
- * Create a new RewardsIntegrationService instance
54
- *
55
- * @param deps - Platform dependencies for logging, metrics, etc.
56
- * @param messenger - Controller messenger for cross-controller communication.
57
- */
58
- constructor(deps, messenger) {
59
- _RewardsIntegrationService_instances.add(this);
60
- _RewardsIntegrationService_deps.set(this, void 0);
61
- _RewardsIntegrationService_messenger.set(this, void 0);
62
- /** Last successful benefits read, or undefined before the first one. */
63
- _RewardsIntegrationService_benefitsSnapshot.set(this, void 0);
64
- /**
65
- * When the last benefits read finished, successful or not.
66
- *
67
- * Separate from `#benefitsSnapshot.fetchedAt`, which only advances on
68
- * success: a failing read must still throttle the next preview refresh,
69
- * otherwise an outage turns every fee preview into a new request.
70
- */
71
- _RewardsIntegrationService_lastAttemptAt.set(this, void 0);
72
- /** In-flight refresh, deduped so only one runs at a time. */
73
- _RewardsIntegrationService_benefitsRefresh.set(this, void 0);
74
- /**
75
- * Identity generation for the cached benefits.
76
- *
77
- * Bumped by {@link invalidateSubscriptionBenefits}; a read that resolves
78
- * against a superseded epoch is discarded rather than written back, so a
79
- * refresh issued for the previous profile cannot repopulate the cache after
80
- * a sign-out or profile switch.
81
- */
82
- _RewardsIntegrationService_benefitsEpoch.set(this, 0);
83
- __classPrivateFieldSet(this, _RewardsIntegrationService_deps, deps, "f");
84
- __classPrivateFieldSet(this, _RewardsIntegrationService_messenger, messenger, "f");
85
- }
86
- /**
87
- * Calculate user fee discount from the unified fee resolver.
88
- * Returns discount in basis points (e.g., 6500 = 65% discount)
89
- *
90
- * @returns The fee discount in basis points, or undefined if no source resolved.
91
- */
92
- async calculateUserFeeDiscount() {
93
- const resolution = await this.resolveFee();
94
- return resolution.discountBips;
95
- }
96
- /**
97
- * Resolve the MetaMask builder fee across every source and return the lowest.
98
- *
99
- * Never throws and never starts a subscription benefits read: a failing or
100
- * unresolved cached source simply drops out of the comparison, so the worst
101
- * case is the default fee rather than an error or an over-granted waiver.
102
- *
103
- * @returns The winning fee, its source, and the subscription gate outcome.
104
- */
105
- async resolveFee() {
106
- const rewardsDiscountBips = await __classPrivateFieldGet(this, _RewardsIntegrationService_instances, "m", _RewardsIntegrationService_calculateRewardsDiscount).call(this);
107
- // Pure cache read: subscription benefits must never start a network request
108
- // while an order is being prepared for signing.
109
- const subscription = this.getSubscriptionFeeWaiverStatus();
110
- let feeBips = DEFAULT_FEE_BIPS;
111
- let source = 'default';
112
- if (rewardsDiscountBips !== undefined) {
113
- const rewardsFeeBips = DEFAULT_FEE_BIPS * (1 - rewardsDiscountBips / hyperLiquidConfig_js_1.BASIS_POINTS_DIVISOR);
114
- // `<=` so an equal rewards fee still reports the rewards source, keeping
115
- // a resolved 0% discount distinguishable from an unresolved one.
116
- if (rewardsFeeBips <= feeBips) {
117
- feeBips = rewardsFeeBips;
118
- source = 'rewards';
119
- }
120
- }
121
- // Nothing can undercut a waived fee, so the gate passing always wins.
122
- if (subscription.eligible) {
123
- feeBips = 0;
124
- source = 'subscription';
125
- }
126
- const discountBips = source === 'default'
127
- ? undefined
128
- : Math.round((1 - feeBips / DEFAULT_FEE_BIPS) * hyperLiquidConfig_js_1.BASIS_POINTS_DIVISOR);
129
- __classPrivateFieldGet(this, _RewardsIntegrationService_deps, "f").debugLogger.log('RewardsIntegrationService: Fee resolved', {
130
- source,
131
- feeBips,
132
- discountBips,
133
- defaultFeeBips: DEFAULT_FEE_BIPS,
134
- rewardsDiscountBips,
135
- subscriptionEligible: subscription.eligible,
136
- subscriptionReason: subscription.reason,
137
- });
138
- return { feeBips, discountBips, source, subscription };
139
- }
140
- /**
141
- * Read the subscription fee-waiver gate from the cached benefits snapshot.
142
- *
143
- * Synchronous and side-effect free. The returned value always comes from
144
- * what is already cached; preview and lifecycle callers own hydration.
145
- *
146
- * @returns Whether the waiver applies, why, and the remaining notional.
147
- */
148
- getSubscriptionFeeWaiverStatus() {
149
- if (!__classPrivateFieldGet(this, _RewardsIntegrationService_deps, "f").subscription) {
150
- return { eligible: false, reason: 'no-source' };
151
- }
152
- const now = Date.now();
153
- const snapshot = __classPrivateFieldGet(this, _RewardsIntegrationService_benefitsSnapshot, "f");
154
- const age = snapshot ? now - snapshot.fetchedAt : Infinity;
155
- if (!snapshot) {
156
- return { eligible: false, reason: 'not-hydrated' };
157
- }
158
- if (age > perpsConfig_js_1.SUBSCRIPTION_BENEFITS_CACHE.MaxStaleMs) {
159
- // Past the ceiling we cannot tell whether the cap is still available, so
160
- // fall back to the next-lowest source rather than over-granting.
161
- return { eligible: false, reason: 'stale' };
162
- }
163
- return evaluateFeeWaiverGate(snapshot.benefits);
164
- }
165
- /**
166
- * Refresh the cached subscription benefits snapshot.
167
- *
168
- * Deduped: concurrent callers share the in-flight request. Rejections are
169
- * logged and swallowed, leaving the previous snapshot in place. Preview and
170
- * lifecycle callers invoke this outside order submission.
171
- *
172
- * @returns A promise that settles when the refresh completes.
173
- */
174
- async refreshSubscriptionBenefits() {
175
- const source = __classPrivateFieldGet(this, _RewardsIntegrationService_deps, "f").subscription;
176
- if (!source) {
177
- return;
178
- }
179
- if (__classPrivateFieldGet(this, _RewardsIntegrationService_benefitsRefresh, "f")) {
180
- await __classPrivateFieldGet(this, _RewardsIntegrationService_benefitsRefresh, "f");
181
- return;
182
- }
183
- const now = Date.now();
184
- const snapshotAge = __classPrivateFieldGet(this, _RewardsIntegrationService_benefitsSnapshot, "f")
185
- ? now - __classPrivateFieldGet(this, _RewardsIntegrationService_benefitsSnapshot, "f").fetchedAt
186
- : Infinity;
187
- const sinceAttempt = __classPrivateFieldGet(this, _RewardsIntegrationService_lastAttemptAt, "f") === undefined ? Infinity : now - __classPrivateFieldGet(this, _RewardsIntegrationService_lastAttemptAt, "f");
188
- if (snapshotAge < perpsConfig_js_1.SUBSCRIPTION_BENEFITS_CACHE.FreshMs ||
189
- sinceAttempt < perpsConfig_js_1.SUBSCRIPTION_BENEFITS_CACHE.FreshMs) {
190
- return;
191
- }
192
- const refresh = __classPrivateFieldGet(this, _RewardsIntegrationService_instances, "m", _RewardsIntegrationService_readSubscriptionBenefits).call(this, source);
193
- __classPrivateFieldSet(this, _RewardsIntegrationService_benefitsRefresh, refresh, "f");
194
- // `finally` always defers, so this never clears the handle we just set.
195
- refresh
196
- .finally(() => {
197
- if (__classPrivateFieldGet(this, _RewardsIntegrationService_benefitsRefresh, "f") === refresh) {
198
- __classPrivateFieldSet(this, _RewardsIntegrationService_benefitsRefresh, undefined, "f");
199
- }
200
- })
201
- .catch(() => undefined);
202
- await refresh;
203
- }
204
- /**
205
- * Drop the cached benefits snapshot.
206
- *
207
- * Call this when the identity behind the benefits changes — sign-out, or a
208
- * profile switch — since the snapshot carries no profile identity of its own
209
- * and would otherwise keep answering for the previous profile until the next
210
- * successful refresh. The next status read reports `not-hydrated`, so the
211
- * waiver is withheld until a preview or lifecycle caller hydrates it.
212
- */
213
- invalidateSubscriptionBenefits() {
214
- __classPrivateFieldSet(this, _RewardsIntegrationService_benefitsSnapshot, undefined, "f");
215
- __classPrivateFieldSet(this, _RewardsIntegrationService_lastAttemptAt, undefined, "f");
216
- // Fence any in-flight read: it was issued for the previous identity, so its
217
- // result must not repopulate the cache after this point.
218
- __classPrivateFieldSet(this, _RewardsIntegrationService_benefitsEpoch, __classPrivateFieldGet(this, _RewardsIntegrationService_benefitsEpoch, "f") + 1, "f");
219
- // Drop the dedupe handle too. The fenced read can only be discarded, so
220
- // leaving it in place would make the next refresh await it instead of
221
- // fetching for the new identity. Its `finally` guard compares against the
222
- // current handle, so it will not clear whatever replaces it here.
223
- __classPrivateFieldSet(this, _RewardsIntegrationService_benefitsRefresh, undefined, "f");
224
- __classPrivateFieldGet(this, _RewardsIntegrationService_deps, "f").debugLogger.log('RewardsIntegrationService: Subscription benefits cache invalidated');
225
- }
226
- }
227
- exports.RewardsIntegrationService = RewardsIntegrationService;
228
- _RewardsIntegrationService_deps = new WeakMap(), _RewardsIntegrationService_messenger = new WeakMap(), _RewardsIntegrationService_benefitsSnapshot = new WeakMap(), _RewardsIntegrationService_lastAttemptAt = new WeakMap(), _RewardsIntegrationService_benefitsRefresh = new WeakMap(), _RewardsIntegrationService_benefitsEpoch = new WeakMap(), _RewardsIntegrationService_instances = new WeakSet(), _RewardsIntegrationService_getChainIdForNetwork = function _RewardsIntegrationService_getChainIdForNetwork(networkClientId) {
229
- try {
230
- const networkClient = __classPrivateFieldGet(this, _RewardsIntegrationService_messenger, "f").call('NetworkController:getNetworkClientById', networkClientId);
231
- return networkClient.configuration.chainId;
232
- }
233
- catch {
234
- // Network client may not exist
235
- return undefined;
236
- }
237
- }, _RewardsIntegrationService_readSubscriptionBenefits =
238
- /**
239
- * Perform one benefits read and store it, keeping the previous snapshot on
240
- * error. Never rejects, so callers cannot produce an unhandled rejection.
241
- *
242
- * @param source - The injected subscription benefits source.
243
- */
244
- async function _RewardsIntegrationService_readSubscriptionBenefits(source) {
245
- const epoch = __classPrivateFieldGet(this, _RewardsIntegrationService_benefitsEpoch, "f");
246
- try {
247
- const benefits = await source.getPerpsBenefits();
248
- if (epoch !== __classPrivateFieldGet(this, _RewardsIntegrationService_benefitsEpoch, "f")) {
249
- // Invalidated while this read was in flight: it belongs to a previous
250
- // identity, so discarding it is the only safe outcome.
251
- __classPrivateFieldGet(this, _RewardsIntegrationService_deps, "f").debugLogger.log('RewardsIntegrationService: Discarding benefits read from a previous identity');
252
- return;
253
- }
254
- __classPrivateFieldSet(this, _RewardsIntegrationService_benefitsSnapshot, { benefits, fetchedAt: Date.now() }, "f");
255
- __classPrivateFieldGet(this, _RewardsIntegrationService_deps, "f").debugLogger.log('RewardsIntegrationService: Subscription benefits refreshed', {
256
- status: benefits?.status,
257
- entitled: benefits?.perpsFeeWaiver?.entitled,
258
- usage: benefits?.perpsFeeWaiver?.usage,
259
- exhausted: benefits?.perpsFeeWaiver?.exhausted,
260
- });
261
- }
262
- catch (error) {
263
- // Keep the previous snapshot: an unreachable benefits endpoint must not
264
- // erase a valid cache, and it must never grant the waiver either.
265
- __classPrivateFieldGet(this, _RewardsIntegrationService_deps, "f").logger.error((0, errorUtils_js_1.ensureError)(error, 'RewardsIntegrationService.refreshSubscriptionBenefits'), {
266
- tags: { feature: perpsConfig_js_1.PERPS_CONSTANTS.FeatureName },
267
- context: {
268
- name: 'RewardsIntegrationService.refreshSubscriptionBenefits',
269
- data: {},
270
- },
271
- });
272
- }
273
- finally {
274
- // Recorded on failure too — this is what throttles the retry loop. Not
275
- // recorded for a fenced read: that attempt belongs to a previous
276
- // identity, and letting it throttle would delay the new identity's first
277
- // fetch by a whole freshness window.
278
- if (epoch === __classPrivateFieldGet(this, _RewardsIntegrationService_benefitsEpoch, "f")) {
279
- __classPrivateFieldSet(this, _RewardsIntegrationService_lastAttemptAt, Date.now(), "f");
280
- }
281
- }
282
- }, _RewardsIntegrationService_calculateRewardsDiscount =
283
- /**
284
- * Resolve the rewards (VIP + season) discount for the selected account.
285
- *
286
- * @returns The discount in basis points, or undefined when unavailable.
287
- */
288
- async function _RewardsIntegrationService_calculateRewardsDiscount() {
289
- try {
290
- const evmAccount = (0, accountUtils_js_1.getSelectedEvmAccountFromMessenger)(__classPrivateFieldGet(this, _RewardsIntegrationService_messenger, "f"));
291
- if (!evmAccount) {
292
- __classPrivateFieldGet(this, _RewardsIntegrationService_deps, "f").debugLogger.log('RewardsIntegrationService: No EVM account found for fee discount');
293
- return undefined;
294
- }
295
- // Get the chain ID via DI network controller
296
- const networkState = __classPrivateFieldGet(this, _RewardsIntegrationService_messenger, "f").call('NetworkController:getState');
297
- const { selectedNetworkClientId } = networkState;
298
- const chainId = __classPrivateFieldGet(this, _RewardsIntegrationService_instances, "m", _RewardsIntegrationService_getChainIdForNetwork).call(this, selectedNetworkClientId);
299
- if (!chainId) {
300
- __classPrivateFieldGet(this, _RewardsIntegrationService_deps, "f").logger.error(new Error('Chain ID not found for fee discount calculation'), {
301
- tags: { feature: perpsConfig_js_1.PERPS_CONSTANTS.FeatureName },
302
- context: {
303
- name: 'RewardsIntegrationService.calculateUserFeeDiscount',
304
- data: {
305
- selectedNetworkClientId,
306
- },
307
- },
308
- });
309
- return undefined;
310
- }
311
- // Use pure utility function for CAIP formatting (pass logger for error reporting)
312
- const caipAccountId = (0, rewardsUtils_js_1.formatAccountToCaipAccountId)(evmAccount.address, chainId, __classPrivateFieldGet(this, _RewardsIntegrationService_deps, "f").logger);
313
- if (!caipAccountId) {
314
- __classPrivateFieldGet(this, _RewardsIntegrationService_deps, "f").logger.error(new Error('Failed to format CAIP account ID for fee discount'), {
315
- tags: { feature: perpsConfig_js_1.PERPS_CONSTANTS.FeatureName },
316
- context: {
317
- name: 'RewardsIntegrationService.calculateUserFeeDiscount',
318
- data: {
319
- address: evmAccount.address,
320
- chainId,
321
- selectedNetworkClientId,
322
- },
323
- },
324
- });
325
- return undefined;
326
- }
327
- // Use rewards via DI (no RewardsController in Core yet).
328
- // The rewards controller needs the perps MetaMask builder base fee in
329
- // bips to convert an absolute VIP fee into a discount fraction.
330
- const discountBips = await __classPrivateFieldGet(this, _RewardsIntegrationService_deps, "f").rewards.getPerpsDiscountForAccount(caipAccountId, DEFAULT_FEE_BIPS);
331
- // null = subscription state not hydrated yet; surface as undefined so
332
- // callers don't treat it as a definitive "no discount" answer.
333
- if (discountBips === null) {
334
- __classPrivateFieldGet(this, _RewardsIntegrationService_deps, "f").debugLogger.log('RewardsIntegrationService: Fee discount unavailable (subscription state not hydrated)', { address: evmAccount.address, caipAccountId });
335
- return undefined;
336
- }
337
- __classPrivateFieldGet(this, _RewardsIntegrationService_deps, "f").debugLogger.log('RewardsIntegrationService: Fee discount calculated', {
338
- address: evmAccount.address,
339
- caipAccountId,
340
- discountBips,
341
- discountPercentage: discountBips / 100,
342
- });
343
- return discountBips;
344
- }
345
- catch (error) {
346
- __classPrivateFieldGet(this, _RewardsIntegrationService_deps, "f").logger.error((0, errorUtils_js_1.ensureError)(error, 'RewardsIntegrationService.calculateUserFeeDiscount'), {
347
- tags: { feature: perpsConfig_js_1.PERPS_CONSTANTS.FeatureName },
348
- context: {
349
- name: 'RewardsIntegrationService.calculateUserFeeDiscount',
350
- data: {},
351
- },
352
- });
353
- return undefined;
354
- }
355
- };
356
- /**
357
- * Evaluate the perps fee-waiver eligibility gate against a benefits snapshot.
358
- *
359
- * The gate is `status=active` AND `perpsFeeWaiver` entitled AND
360
- * `usage=available`. A backend `exhausted` flag (or an `exhausted` usage) fails
361
- * the gate on its own; anything short of an affirmative `available` is treated
362
- * as not entitled, because the waiver is only granted on positive evidence.
363
- * A `null` payload means there is no subscription at all, which is reported
364
- * separately from a subscription that exists but is not active.
365
- *
366
- * @param benefits - The cached benefits payload, or null when there is none.
367
- * @returns The gate outcome plus the remaining notional when reported.
368
- */
369
- function evaluateFeeWaiverGate(benefits) {
370
- const waiver = benefits?.perpsFeeWaiver;
371
- const { remainingNotionalUsd } = waiver ?? {};
372
- // `null` is the DI contract's "nothing to report" (signed out, no profile),
373
- // which is distinct from a subscription that exists but is not active.
374
- if (benefits === null) {
375
- return { eligible: false, reason: 'no-subscription' };
376
- }
377
- if (benefits.status !== 'active') {
378
- return { eligible: false, reason: 'inactive', remainingNotionalUsd };
379
- }
380
- if (waiver?.entitled !== true) {
381
- return { eligible: false, reason: 'not-entitled', remainingNotionalUsd };
382
- }
383
- if (waiver.exhausted === true || waiver.usage === 'exhausted') {
384
- return { eligible: false, reason: 'exhausted', remainingNotionalUsd };
385
- }
386
- if (waiver.usage !== 'available') {
387
- return { eligible: false, reason: 'not-entitled', remainingNotionalUsd };
388
- }
389
- return { eligible: true, reason: 'eligible', remainingNotionalUsd };
390
- }
391
- //# sourceMappingURL=RewardsIntegrationService.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RewardsIntegrationService.cjs","sourceRoot":"","sources":["../../src/services/RewardsIntegrationService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6EAG2C;AAC3C,iEAGqC;AASrC,+DAA8E;AAC9E,2DAAqD;AACrD,+DAAwE;AAExE;;;GAGG;AACH,MAAM,gBAAgB,GACpB,yCAAkB,CAAC,aAAa,GAAG,2CAAoB,CAAC;AAU1D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,yBAAyB;IA8BpC;;;;;OAKG;IACH,YACE,IAA+B,EAC/B,SAAuC;;QArChC,kDAAiC;QAEjC,uDAAyC;QAElD,wEAAwE;QACxE,8DAAgD;QAEhD;;;;;;WAMG;QACH,2DAAmC;QAEnC,6DAA6D;QAC7D,6DAA4C;QAE5C;;;;;;;WAOG;QACH,mDAAiB,CAAC,EAAC;QAYjB,uBAAA,IAAI,mCAAS,IAAI,MAAA,CAAC;QAClB,uBAAA,IAAI,wCAAc,SAAS,MAAA,CAAC;IAC9B,CAAC;IAqBD;;;;;OAKG;IACH,KAAK,CAAC,wBAAwB;QAC5B,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QAC3C,OAAO,UAAU,CAAC,YAAY,CAAC;IACjC,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,UAAU;QACd,MAAM,mBAAmB,GAAG,MAAM,uBAAA,IAAI,iGAA0B,MAA9B,IAAI,CAA4B,CAAC;QACnE,4EAA4E;QAC5E,gDAAgD;QAChD,MAAM,YAAY,GAAG,IAAI,CAAC,8BAA8B,EA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9C,4EAA4E;IAC5E,uEAAuE;IACvE,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC;IACxD,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC;IACvE,CAAC;IAED,IAAI,MAAM,EAAE,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC9B,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,oBAAoB,EAAE,CAAC;IAC3E,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,KAAK,IAAI,IAAI,MAAM,CAAC,KAAK,KAAK,WAAW,EAAE,CAAC;QAC9D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC;IACxE,CAAC;IAED,IAAI,MAAM,CAAC,KAAK,KAAK,WAAW,EAAE,CAAC;QACjC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,oBAAoB,EAAE,CAAC;IAC3E,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC;AACtE,CAAC","sourcesContent":["import {\n BASIS_POINTS_DIVISOR,\n BUILDER_FEE_CONFIG,\n} from '../constants/hyperLiquidConfig.js';\nimport {\n PERPS_CONSTANTS,\n SUBSCRIPTION_BENEFITS_CACHE,\n} from '../constants/perpsConfig.js';\nimport type {\n PerpsFeeResolution,\n PerpsFeeSource,\n PerpsPlatformDependencies,\n PerpsSubscriptionBenefits,\n PerpsSubscriptionFeeWaiverStatus,\n} from '../types/index.js';\nimport type { PerpsControllerMessengerBase } from '../types/messenger.js';\nimport { getSelectedEvmAccountFromMessenger } from '../utils/accountUtils.js';\nimport { ensureError } from '../utils/errorUtils.js';\nimport { formatAccountToCaipAccountId } from '../utils/rewardsUtils.js';\n\n/**\n * Default MetaMask builder fee, in basis points.\n * This is the fee every user pays when no cheaper source applies.\n */\nconst DEFAULT_FEE_BIPS =\n BUILDER_FEE_CONFIG.MaxFeeDecimal * BASIS_POINTS_DIVISOR;\n\n/**\n * Cached subscription benefits plus the time they were read.\n */\ntype BenefitsSnapshot = {\n benefits: PerpsSubscriptionBenefits | null;\n fetchedAt: number;\n};\n\n/**\n * RewardsIntegrationService\n *\n * Owns the unified perps fee resolver: it considers every fee source and\n * returns the lowest fee, expressed as the discount bips providers consume.\n *\n * Sources, all in fee basis points (lowest wins):\n * - `default` — {@link BUILDER_FEE_CONFIG}, the fee with no reductions.\n * - `rewards` — VIP and season, collapsed into one discount by\n * `RewardsController` (`rewards.getPerpsDiscountForAccount`), so this service\n * does not re-derive the VIP/season split.\n * - `subscription` — `0` bips, but only when the eligibility gate passes on a\n * cached read of the profile's benefits.\n *\n * On a tie the cheaper-to-explain source wins, in the order\n * `subscription` > `rewards` > `default`.\n *\n * The benefits cache is stale-while-revalidate: fee resolution is a pure read\n * of the cached snapshot, while preview and lifecycle callers refresh it\n * explicitly. Nothing is reserved or committed client-side, so backend\n * exhaustion needs no release logic — the next refresh simply stops passing\n * the gate.\n *\n * Instance-based service with constructor injection of platform dependencies.\n */\nexport class RewardsIntegrationService {\n readonly #deps: PerpsPlatformDependencies;\n\n readonly #messenger: PerpsControllerMessengerBase;\n\n /** Last successful benefits read, or undefined before the first one. */\n #benefitsSnapshot: BenefitsSnapshot | undefined;\n\n /**\n * When the last benefits read finished, successful or not.\n *\n * Separate from `#benefitsSnapshot.fetchedAt`, which only advances on\n * success: a failing read must still throttle the next preview refresh,\n * otherwise an outage turns every fee preview into a new request.\n */\n #lastAttemptAt: number | undefined;\n\n /** In-flight refresh, deduped so only one runs at a time. */\n #benefitsRefresh: Promise<void> | undefined;\n\n /**\n * Identity generation for the cached benefits.\n *\n * Bumped by {@link invalidateSubscriptionBenefits}; a read that resolves\n * against a superseded epoch is discarded rather than written back, so a\n * refresh issued for the previous profile cannot repopulate the cache after\n * a sign-out or profile switch.\n */\n #benefitsEpoch = 0;\n\n /**\n * Create a new RewardsIntegrationService instance\n *\n * @param deps - Platform dependencies for logging, metrics, etc.\n * @param messenger - Controller messenger for cross-controller communication.\n */\n constructor(\n deps: PerpsPlatformDependencies,\n messenger: PerpsControllerMessengerBase,\n ) {\n this.#deps = deps;\n this.#messenger = messenger;\n }\n\n /**\n * Get chain ID for a network client via DI network controller\n *\n * @param networkClientId - The network client identifier to look up.\n * @returns The chain ID string, or undefined if the network client is not found.\n */\n #getChainIdForNetwork(networkClientId: string): string | undefined {\n try {\n const networkClient = this.#messenger.call(\n 'NetworkController:getNetworkClientById',\n networkClientId,\n );\n return networkClient.configuration.chainId;\n } catch {\n // Network client may not exist\n return undefined;\n }\n }\n\n /**\n * Calculate user fee discount from the unified fee resolver.\n * Returns discount in basis points (e.g., 6500 = 65% discount)\n *\n * @returns The fee discount in basis points, or undefined if no source resolved.\n */\n async calculateUserFeeDiscount(): Promise<number | undefined> {\n const resolution = await this.resolveFee();\n return resolution.discountBips;\n }\n\n /**\n * Resolve the MetaMask builder fee across every source and return the lowest.\n *\n * Never throws and never starts a subscription benefits read: a failing or\n * unresolved cached source simply drops out of the comparison, so the worst\n * case is the default fee rather than an error or an over-granted waiver.\n *\n * @returns The winning fee, its source, and the subscription gate outcome.\n */\n async resolveFee(): Promise<PerpsFeeResolution> {\n const rewardsDiscountBips = await this.#calculateRewardsDiscount();\n // Pure cache read: subscription benefits must never start a network request\n // while an order is being prepared for signing.\n const subscription = this.getSubscriptionFeeWaiverStatus();\n\n let feeBips = DEFAULT_FEE_BIPS;\n let source: PerpsFeeSource = 'default';\n\n if (rewardsDiscountBips !== undefined) {\n const rewardsFeeBips =\n DEFAULT_FEE_BIPS * (1 - rewardsDiscountBips / BASIS_POINTS_DIVISOR);\n // `<=` so an equal rewards fee still reports the rewards source, keeping\n // a resolved 0% discount distinguishable from an unresolved one.\n if (rewardsFeeBips <= feeBips) {\n feeBips = rewardsFeeBips;\n source = 'rewards';\n }\n }\n\n // Nothing can undercut a waived fee, so the gate passing always wins.\n if (subscription.eligible) {\n feeBips = 0;\n source = 'subscription';\n }\n\n const discountBips =\n source === 'default'\n ? undefined\n : Math.round((1 - feeBips / DEFAULT_FEE_BIPS) * BASIS_POINTS_DIVISOR);\n\n this.#deps.debugLogger.log('RewardsIntegrationService: Fee resolved', {\n source,\n feeBips,\n discountBips,\n defaultFeeBips: DEFAULT_FEE_BIPS,\n rewardsDiscountBips,\n subscriptionEligible: subscription.eligible,\n subscriptionReason: subscription.reason,\n });\n\n return { feeBips, discountBips, source, subscription };\n }\n\n /**\n * Read the subscription fee-waiver gate from the cached benefits snapshot.\n *\n * Synchronous and side-effect free. The returned value always comes from\n * what is already cached; preview and lifecycle callers own hydration.\n *\n * @returns Whether the waiver applies, why, and the remaining notional.\n */\n getSubscriptionFeeWaiverStatus(): PerpsSubscriptionFeeWaiverStatus {\n if (!this.#deps.subscription) {\n return { eligible: false, reason: 'no-source' };\n }\n\n const now = Date.now();\n const snapshot = this.#benefitsSnapshot;\n const age = snapshot ? now - snapshot.fetchedAt : Infinity;\n if (!snapshot) {\n return { eligible: false, reason: 'not-hydrated' };\n }\n\n if (age > SUBSCRIPTION_BENEFITS_CACHE.MaxStaleMs) {\n // Past the ceiling we cannot tell whether the cap is still available, so\n // fall back to the next-lowest source rather than over-granting.\n return { eligible: false, reason: 'stale' };\n }\n\n return evaluateFeeWaiverGate(snapshot.benefits);\n }\n\n /**\n * Refresh the cached subscription benefits snapshot.\n *\n * Deduped: concurrent callers share the in-flight request. Rejections are\n * logged and swallowed, leaving the previous snapshot in place. Preview and\n * lifecycle callers invoke this outside order submission.\n *\n * @returns A promise that settles when the refresh completes.\n */\n async refreshSubscriptionBenefits(): Promise<void> {\n const source = this.#deps.subscription;\n if (!source) {\n return;\n }\n\n if (this.#benefitsRefresh) {\n await this.#benefitsRefresh;\n return;\n }\n\n const now = Date.now();\n const snapshotAge = this.#benefitsSnapshot\n ? now - this.#benefitsSnapshot.fetchedAt\n : Infinity;\n const sinceAttempt =\n this.#lastAttemptAt === undefined ? Infinity : now - this.#lastAttemptAt;\n if (\n snapshotAge < SUBSCRIPTION_BENEFITS_CACHE.FreshMs ||\n sinceAttempt < SUBSCRIPTION_BENEFITS_CACHE.FreshMs\n ) {\n return;\n }\n\n const refresh = this.#readSubscriptionBenefits(source);\n this.#benefitsRefresh = refresh;\n // `finally` always defers, so this never clears the handle we just set.\n refresh\n .finally(() => {\n if (this.#benefitsRefresh === refresh) {\n this.#benefitsRefresh = undefined;\n }\n })\n .catch(() => undefined);\n\n await refresh;\n }\n\n /**\n * Drop the cached benefits snapshot.\n *\n * Call this when the identity behind the benefits changes — sign-out, or a\n * profile switch — since the snapshot carries no profile identity of its own\n * and would otherwise keep answering for the previous profile until the next\n * successful refresh. The next status read reports `not-hydrated`, so the\n * waiver is withheld until a preview or lifecycle caller hydrates it.\n */\n invalidateSubscriptionBenefits(): void {\n this.#benefitsSnapshot = undefined;\n this.#lastAttemptAt = undefined;\n // Fence any in-flight read: it was issued for the previous identity, so its\n // result must not repopulate the cache after this point.\n this.#benefitsEpoch += 1;\n // Drop the dedupe handle too. The fenced read can only be discarded, so\n // leaving it in place would make the next refresh await it instead of\n // fetching for the new identity. Its `finally` guard compares against the\n // current handle, so it will not clear whatever replaces it here.\n this.#benefitsRefresh = undefined;\n\n this.#deps.debugLogger.log(\n 'RewardsIntegrationService: Subscription benefits cache invalidated',\n );\n }\n\n /**\n * Perform one benefits read and store it, keeping the previous snapshot on\n * error. Never rejects, so callers cannot produce an unhandled rejection.\n *\n * @param source - The injected subscription benefits source.\n */\n async #readSubscriptionBenefits(\n source: NonNullable<PerpsPlatformDependencies['subscription']>,\n ): Promise<void> {\n const epoch = this.#benefitsEpoch;\n\n try {\n const benefits = await source.getPerpsBenefits();\n\n if (epoch !== this.#benefitsEpoch) {\n // Invalidated while this read was in flight: it belongs to a previous\n // identity, so discarding it is the only safe outcome.\n this.#deps.debugLogger.log(\n 'RewardsIntegrationService: Discarding benefits read from a previous identity',\n );\n return;\n }\n\n this.#benefitsSnapshot = { benefits, fetchedAt: Date.now() };\n\n this.#deps.debugLogger.log(\n 'RewardsIntegrationService: Subscription benefits refreshed',\n {\n status: benefits?.status,\n entitled: benefits?.perpsFeeWaiver?.entitled,\n usage: benefits?.perpsFeeWaiver?.usage,\n exhausted: benefits?.perpsFeeWaiver?.exhausted,\n },\n );\n } catch (error) {\n // Keep the previous snapshot: an unreachable benefits endpoint must not\n // erase a valid cache, and it must never grant the waiver either.\n this.#deps.logger.error(\n ensureError(\n error,\n 'RewardsIntegrationService.refreshSubscriptionBenefits',\n ),\n {\n tags: { feature: PERPS_CONSTANTS.FeatureName },\n context: {\n name: 'RewardsIntegrationService.refreshSubscriptionBenefits',\n data: {},\n },\n },\n );\n } finally {\n // Recorded on failure too — this is what throttles the retry loop. Not\n // recorded for a fenced read: that attempt belongs to a previous\n // identity, and letting it throttle would delay the new identity's first\n // fetch by a whole freshness window.\n if (epoch === this.#benefitsEpoch) {\n this.#lastAttemptAt = Date.now();\n }\n }\n }\n\n /**\n * Resolve the rewards (VIP + season) discount for the selected account.\n *\n * @returns The discount in basis points, or undefined when unavailable.\n */\n async #calculateRewardsDiscount(): Promise<number | undefined> {\n try {\n const evmAccount = getSelectedEvmAccountFromMessenger(this.#messenger);\n\n if (!evmAccount) {\n this.#deps.debugLogger.log(\n 'RewardsIntegrationService: No EVM account found for fee discount',\n );\n return undefined;\n }\n\n // Get the chain ID via DI network controller\n const networkState = this.#messenger.call('NetworkController:getState');\n const { selectedNetworkClientId } = networkState;\n const chainId = this.#getChainIdForNetwork(selectedNetworkClientId);\n\n if (!chainId) {\n this.#deps.logger.error(\n new Error('Chain ID not found for fee discount calculation'),\n {\n tags: { feature: PERPS_CONSTANTS.FeatureName },\n context: {\n name: 'RewardsIntegrationService.calculateUserFeeDiscount',\n data: {\n selectedNetworkClientId,\n },\n },\n },\n );\n return undefined;\n }\n\n // Use pure utility function for CAIP formatting (pass logger for error reporting)\n const caipAccountId = formatAccountToCaipAccountId(\n evmAccount.address,\n chainId,\n this.#deps.logger,\n );\n\n if (!caipAccountId) {\n this.#deps.logger.error(\n new Error('Failed to format CAIP account ID for fee discount'),\n {\n tags: { feature: PERPS_CONSTANTS.FeatureName },\n context: {\n name: 'RewardsIntegrationService.calculateUserFeeDiscount',\n data: {\n address: evmAccount.address,\n chainId,\n selectedNetworkClientId,\n },\n },\n },\n );\n return undefined;\n }\n\n // Use rewards via DI (no RewardsController in Core yet).\n // The rewards controller needs the perps MetaMask builder base fee in\n // bips to convert an absolute VIP fee into a discount fraction.\n const discountBips = await this.#deps.rewards.getPerpsDiscountForAccount(\n caipAccountId,\n DEFAULT_FEE_BIPS,\n );\n\n // null = subscription state not hydrated yet; surface as undefined so\n // callers don't treat it as a definitive \"no discount\" answer.\n if (discountBips === null) {\n this.#deps.debugLogger.log(\n 'RewardsIntegrationService: Fee discount unavailable (subscription state not hydrated)',\n { address: evmAccount.address, caipAccountId },\n );\n return undefined;\n }\n\n this.#deps.debugLogger.log(\n 'RewardsIntegrationService: Fee discount calculated',\n {\n address: evmAccount.address,\n caipAccountId,\n discountBips,\n discountPercentage: discountBips / 100,\n },\n );\n\n return discountBips;\n } catch (error) {\n this.#deps.logger.error(\n ensureError(\n error,\n 'RewardsIntegrationService.calculateUserFeeDiscount',\n ),\n {\n tags: { feature: PERPS_CONSTANTS.FeatureName },\n context: {\n name: 'RewardsIntegrationService.calculateUserFeeDiscount',\n data: {},\n },\n },\n );\n return undefined;\n }\n }\n}\n\n/**\n * Evaluate the perps fee-waiver eligibility gate against a benefits snapshot.\n *\n * The gate is `status=active` AND `perpsFeeWaiver` entitled AND\n * `usage=available`. A backend `exhausted` flag (or an `exhausted` usage) fails\n * the gate on its own; anything short of an affirmative `available` is treated\n * as not entitled, because the waiver is only granted on positive evidence.\n * A `null` payload means there is no subscription at all, which is reported\n * separately from a subscription that exists but is not active.\n *\n * @param benefits - The cached benefits payload, or null when there is none.\n * @returns The gate outcome plus the remaining notional when reported.\n */\nfunction evaluateFeeWaiverGate(\n benefits: PerpsSubscriptionBenefits | null,\n): PerpsSubscriptionFeeWaiverStatus {\n const waiver = benefits?.perpsFeeWaiver;\n const { remainingNotionalUsd } = waiver ?? {};\n\n // `null` is the DI contract's \"nothing to report\" (signed out, no profile),\n // which is distinct from a subscription that exists but is not active.\n if (benefits === null) {\n return { eligible: false, reason: 'no-subscription' };\n }\n\n if (benefits.status !== 'active') {\n return { eligible: false, reason: 'inactive', remainingNotionalUsd };\n }\n\n if (waiver?.entitled !== true) {\n return { eligible: false, reason: 'not-entitled', remainingNotionalUsd };\n }\n\n if (waiver.exhausted === true || waiver.usage === 'exhausted') {\n return { eligible: false, reason: 'exhausted', remainingNotionalUsd };\n }\n\n if (waiver.usage !== 'available') {\n return { eligible: false, reason: 'not-entitled', remainingNotionalUsd };\n }\n\n return { eligible: true, reason: 'eligible', remainingNotionalUsd };\n}\n"]}