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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (498) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/dist/PerpsController.cjs +2224 -66
  3. package/dist/PerpsController.cjs.map +1 -1
  4. package/dist/PerpsController.d.cts +933 -79
  5. package/dist/PerpsController.d.cts.map +1 -1
  6. package/dist/PerpsController.d.mts +933 -79
  7. package/dist/PerpsController.d.mts.map +1 -1
  8. package/dist/PerpsController.mjs +2221 -64
  9. package/dist/PerpsController.mjs.map +1 -1
  10. package/dist/__mocks__/hyperliquidMock.cjs +68 -0
  11. package/dist/__mocks__/hyperliquidMock.cjs.map +1 -0
  12. package/dist/__mocks__/hyperliquidMock.d.cts +15 -0
  13. package/dist/__mocks__/hyperliquidMock.d.cts.map +1 -0
  14. package/dist/__mocks__/hyperliquidMock.d.mts +15 -0
  15. package/dist/__mocks__/hyperliquidMock.d.mts.map +1 -0
  16. package/dist/__mocks__/hyperliquidMock.mjs +65 -0
  17. package/dist/__mocks__/hyperliquidMock.mjs.map +1 -0
  18. package/dist/__mocks__/providerMocks.cjs +144 -0
  19. package/dist/__mocks__/providerMocks.cjs.map +1 -0
  20. package/dist/__mocks__/providerMocks.d.cts +44 -0
  21. package/dist/__mocks__/providerMocks.d.cts.map +1 -0
  22. package/dist/__mocks__/providerMocks.d.mts +44 -0
  23. package/dist/__mocks__/providerMocks.d.mts.map +1 -0
  24. package/dist/__mocks__/providerMocks.mjs +136 -0
  25. package/dist/__mocks__/providerMocks.mjs.map +1 -0
  26. package/dist/__mocks__/serviceMocks.cjs +187 -0
  27. package/dist/__mocks__/serviceMocks.cjs.map +1 -0
  28. package/dist/__mocks__/serviceMocks.d.cts +58 -0
  29. package/dist/__mocks__/serviceMocks.d.cts.map +1 -0
  30. package/dist/__mocks__/serviceMocks.d.mts +58 -0
  31. package/dist/__mocks__/serviceMocks.d.mts.map +1 -0
  32. package/dist/__mocks__/serviceMocks.mjs +180 -0
  33. package/dist/__mocks__/serviceMocks.mjs.map +1 -0
  34. package/dist/aggregation/SubscriptionMultiplexer.cjs +459 -0
  35. package/dist/aggregation/SubscriptionMultiplexer.cjs.map +1 -0
  36. package/dist/aggregation/SubscriptionMultiplexer.d.cts +222 -0
  37. package/dist/aggregation/SubscriptionMultiplexer.d.cts.map +1 -0
  38. package/dist/aggregation/SubscriptionMultiplexer.d.mts +222 -0
  39. package/dist/aggregation/SubscriptionMultiplexer.d.mts.map +1 -0
  40. package/dist/aggregation/SubscriptionMultiplexer.mjs +455 -0
  41. package/dist/aggregation/SubscriptionMultiplexer.mjs.map +1 -0
  42. package/dist/aggregation/index.cjs +9 -0
  43. package/dist/aggregation/index.cjs.map +1 -0
  44. package/dist/aggregation/index.d.cts +6 -0
  45. package/dist/aggregation/index.d.cts.map +1 -0
  46. package/dist/aggregation/index.d.mts +6 -0
  47. package/dist/aggregation/index.d.mts.map +1 -0
  48. package/dist/aggregation/index.mjs +5 -0
  49. package/dist/aggregation/index.mjs.map +1 -0
  50. package/dist/constants/eventNames.cjs +117 -0
  51. package/dist/constants/eventNames.cjs.map +1 -0
  52. package/dist/constants/eventNames.d.cts +106 -0
  53. package/dist/constants/eventNames.d.cts.map +1 -0
  54. package/dist/constants/eventNames.d.mts +106 -0
  55. package/dist/constants/eventNames.d.mts.map +1 -0
  56. package/dist/constants/eventNames.mjs +114 -0
  57. package/dist/constants/eventNames.mjs.map +1 -0
  58. package/dist/constants/hyperLiquidConfig.cjs +366 -0
  59. package/dist/constants/hyperLiquidConfig.cjs.map +1 -0
  60. package/dist/constants/hyperLiquidConfig.d.cts +276 -0
  61. package/dist/constants/hyperLiquidConfig.d.cts.map +1 -0
  62. package/dist/constants/hyperLiquidConfig.d.mts +276 -0
  63. package/dist/constants/hyperLiquidConfig.d.mts.map +1 -0
  64. package/dist/constants/hyperLiquidConfig.mjs +357 -0
  65. package/dist/constants/hyperLiquidConfig.mjs.map +1 -0
  66. package/dist/constants/index.cjs +23 -0
  67. package/dist/constants/index.cjs.map +1 -0
  68. package/dist/constants/index.d.cts +7 -0
  69. package/dist/constants/index.d.cts.map +1 -0
  70. package/dist/constants/index.d.mts +7 -0
  71. package/dist/constants/index.d.mts.map +1 -0
  72. package/dist/constants/index.mjs +7 -0
  73. package/dist/constants/index.mjs.map +1 -0
  74. package/dist/constants/orderTypes.cjs +31 -0
  75. package/dist/constants/orderTypes.cjs.map +1 -0
  76. package/dist/constants/orderTypes.d.cts +19 -0
  77. package/dist/constants/orderTypes.d.cts.map +1 -0
  78. package/dist/constants/orderTypes.d.mts +19 -0
  79. package/dist/constants/orderTypes.d.mts.map +1 -0
  80. package/dist/constants/orderTypes.mjs +27 -0
  81. package/dist/constants/orderTypes.mjs.map +1 -0
  82. package/dist/constants/performanceMetrics.cjs +61 -0
  83. package/dist/constants/performanceMetrics.cjs.map +1 -0
  84. package/dist/constants/performanceMetrics.d.cts +44 -0
  85. package/dist/constants/performanceMetrics.d.cts.map +1 -0
  86. package/dist/constants/performanceMetrics.d.mts +44 -0
  87. package/dist/constants/performanceMetrics.d.mts.map +1 -0
  88. package/dist/constants/performanceMetrics.mjs +58 -0
  89. package/dist/constants/performanceMetrics.mjs.map +1 -0
  90. package/dist/constants/perpsConfig.cjs +461 -0
  91. package/dist/constants/perpsConfig.cjs.map +1 -0
  92. package/dist/constants/perpsConfig.d.cts +343 -0
  93. package/dist/constants/perpsConfig.d.cts.map +1 -0
  94. package/dist/constants/perpsConfig.d.mts +343 -0
  95. package/dist/constants/perpsConfig.d.mts.map +1 -0
  96. package/dist/constants/perpsConfig.mjs +458 -0
  97. package/dist/constants/perpsConfig.mjs.map +1 -0
  98. package/dist/constants/perpsErrorCodes.cjs +79 -0
  99. package/dist/constants/perpsErrorCodes.cjs.map +1 -0
  100. package/dist/constants/perpsErrorCodes.d.cts +64 -0
  101. package/dist/constants/perpsErrorCodes.d.cts.map +1 -0
  102. package/dist/constants/perpsErrorCodes.d.mts +64 -0
  103. package/dist/constants/perpsErrorCodes.d.mts.map +1 -0
  104. package/dist/constants/perpsErrorCodes.mjs +76 -0
  105. package/dist/constants/perpsErrorCodes.mjs.map +1 -0
  106. package/dist/index.cjs +32 -1
  107. package/dist/index.cjs.map +1 -1
  108. package/dist/index.d.cts +6 -2
  109. package/dist/index.d.cts.map +1 -1
  110. package/dist/index.d.mts +6 -2
  111. package/dist/index.d.mts.map +1 -1
  112. package/dist/index.mjs +9 -1
  113. package/dist/index.mjs.map +1 -1
  114. package/dist/platform-services/HyperLiquidClientService.cjs +857 -0
  115. package/dist/platform-services/HyperLiquidClientService.cjs.map +1 -0
  116. package/dist/platform-services/HyperLiquidClientService.d.cts +263 -0
  117. package/dist/platform-services/HyperLiquidClientService.d.cts.map +1 -0
  118. package/dist/platform-services/HyperLiquidClientService.d.mts +263 -0
  119. package/dist/platform-services/HyperLiquidClientService.d.mts.map +1 -0
  120. package/dist/platform-services/HyperLiquidClientService.mjs +853 -0
  121. package/dist/platform-services/HyperLiquidClientService.mjs.map +1 -0
  122. package/dist/platform-services/HyperLiquidSubscriptionService.cjs +2170 -0
  123. package/dist/platform-services/HyperLiquidSubscriptionService.cjs.map +1 -0
  124. package/dist/platform-services/HyperLiquidSubscriptionService.d.cts +424 -0
  125. package/dist/platform-services/HyperLiquidSubscriptionService.d.cts.map +1 -0
  126. package/dist/platform-services/HyperLiquidSubscriptionService.d.mts +424 -0
  127. package/dist/platform-services/HyperLiquidSubscriptionService.d.mts.map +1 -0
  128. package/dist/platform-services/HyperLiquidSubscriptionService.mjs +2166 -0
  129. package/dist/platform-services/HyperLiquidSubscriptionService.mjs.map +1 -0
  130. package/dist/platform-services/HyperLiquidWalletService.cjs +140 -0
  131. package/dist/platform-services/HyperLiquidWalletService.cjs.map +1 -0
  132. package/dist/platform-services/HyperLiquidWalletService.d.cts +78 -0
  133. package/dist/platform-services/HyperLiquidWalletService.d.cts.map +1 -0
  134. package/dist/platform-services/HyperLiquidWalletService.d.mts +78 -0
  135. package/dist/platform-services/HyperLiquidWalletService.d.mts.map +1 -0
  136. package/dist/platform-services/HyperLiquidWalletService.mjs +136 -0
  137. package/dist/platform-services/HyperLiquidWalletService.mjs.map +1 -0
  138. package/dist/providers/AggregatedPerpsProvider.cjs +777 -0
  139. package/dist/providers/AggregatedPerpsProvider.cjs.map +1 -0
  140. package/dist/providers/AggregatedPerpsProvider.d.cts +466 -0
  141. package/dist/providers/AggregatedPerpsProvider.d.cts.map +1 -0
  142. package/dist/providers/AggregatedPerpsProvider.d.mts +466 -0
  143. package/dist/providers/AggregatedPerpsProvider.d.mts.map +1 -0
  144. package/dist/providers/AggregatedPerpsProvider.mjs +773 -0
  145. package/dist/providers/AggregatedPerpsProvider.mjs.map +1 -0
  146. package/dist/providers/HyperLiquidProvider.cjs +5172 -0
  147. package/dist/providers/HyperLiquidProvider.cjs.map +1 -0
  148. package/dist/providers/HyperLiquidProvider.d.cts +881 -0
  149. package/dist/providers/HyperLiquidProvider.d.cts.map +1 -0
  150. package/dist/providers/HyperLiquidProvider.d.mts +881 -0
  151. package/dist/providers/HyperLiquidProvider.d.mts.map +1 -0
  152. package/dist/providers/HyperLiquidProvider.mjs +5168 -0
  153. package/dist/providers/HyperLiquidProvider.mjs.map +1 -0
  154. package/dist/providers/index.cjs +11 -0
  155. package/dist/providers/index.cjs.map +1 -0
  156. package/dist/providers/index.d.cts +6 -0
  157. package/dist/providers/index.d.cts.map +1 -0
  158. package/dist/providers/index.d.mts +6 -0
  159. package/dist/providers/index.d.mts.map +1 -0
  160. package/dist/providers/index.mjs +6 -0
  161. package/dist/providers/index.mjs.map +1 -0
  162. package/dist/routing/ProviderRouter.cjs +148 -0
  163. package/dist/routing/ProviderRouter.cjs.map +1 -0
  164. package/dist/routing/ProviderRouter.d.cts +124 -0
  165. package/dist/routing/ProviderRouter.d.cts.map +1 -0
  166. package/dist/routing/ProviderRouter.d.mts +124 -0
  167. package/dist/routing/ProviderRouter.d.mts.map +1 -0
  168. package/dist/routing/ProviderRouter.mjs +144 -0
  169. package/dist/routing/ProviderRouter.mjs.map +1 -0
  170. package/dist/routing/index.cjs +9 -0
  171. package/dist/routing/index.cjs.map +1 -0
  172. package/dist/routing/index.d.cts +6 -0
  173. package/dist/routing/index.d.cts.map +1 -0
  174. package/dist/routing/index.d.mts +6 -0
  175. package/dist/routing/index.d.mts.map +1 -0
  176. package/dist/routing/index.mjs +5 -0
  177. package/dist/routing/index.mjs.map +1 -0
  178. package/dist/selectors.cjs +161 -0
  179. package/dist/selectors.cjs.map +1 -0
  180. package/dist/selectors.d.cts +345 -0
  181. package/dist/selectors.d.cts.map +1 -0
  182. package/dist/selectors.d.mts +345 -0
  183. package/dist/selectors.d.mts.map +1 -0
  184. package/dist/selectors.mjs +153 -0
  185. package/dist/selectors.mjs.map +1 -0
  186. package/dist/services/AccountService.cjs +313 -0
  187. package/dist/services/AccountService.cjs.map +1 -0
  188. package/dist/services/AccountService.d.cts +53 -0
  189. package/dist/services/AccountService.d.cts.map +1 -0
  190. package/dist/services/AccountService.d.mts +53 -0
  191. package/dist/services/AccountService.d.mts.map +1 -0
  192. package/dist/services/AccountService.mjs +309 -0
  193. package/dist/services/AccountService.mjs.map +1 -0
  194. package/dist/services/DataLakeService.cjs +219 -0
  195. package/dist/services/DataLakeService.cjs.map +1 -0
  196. package/dist/services/DataLakeService.d.cts +49 -0
  197. package/dist/services/DataLakeService.d.cts.map +1 -0
  198. package/dist/services/DataLakeService.d.mts +49 -0
  199. package/dist/services/DataLakeService.d.mts.map +1 -0
  200. package/dist/services/DataLakeService.mjs +215 -0
  201. package/dist/services/DataLakeService.mjs.map +1 -0
  202. package/dist/services/DepositService.cjs +96 -0
  203. package/dist/services/DepositService.cjs.map +1 -0
  204. package/dist/services/DepositService.d.cts +37 -0
  205. package/dist/services/DepositService.d.cts.map +1 -0
  206. package/dist/services/DepositService.d.mts +37 -0
  207. package/dist/services/DepositService.d.mts.map +1 -0
  208. package/dist/services/DepositService.mjs +92 -0
  209. package/dist/services/DepositService.mjs.map +1 -0
  210. package/dist/services/EligibilityService.cjs +156 -0
  211. package/dist/services/EligibilityService.cjs.map +1 -0
  212. package/dist/services/EligibilityService.d.cts +48 -0
  213. package/dist/services/EligibilityService.d.cts.map +1 -0
  214. package/dist/services/EligibilityService.d.mts +48 -0
  215. package/dist/services/EligibilityService.d.mts.map +1 -0
  216. package/dist/services/EligibilityService.mjs +152 -0
  217. package/dist/services/EligibilityService.mjs.map +1 -0
  218. package/dist/services/FeatureFlagConfigurationService.cjs +258 -0
  219. package/dist/services/FeatureFlagConfigurationService.cjs.map +1 -0
  220. package/dist/services/FeatureFlagConfigurationService.d.cts +100 -0
  221. package/dist/services/FeatureFlagConfigurationService.d.cts.map +1 -0
  222. package/dist/services/FeatureFlagConfigurationService.d.mts +100 -0
  223. package/dist/services/FeatureFlagConfigurationService.d.mts.map +1 -0
  224. package/dist/services/FeatureFlagConfigurationService.mjs +254 -0
  225. package/dist/services/FeatureFlagConfigurationService.mjs.map +1 -0
  226. package/dist/services/MarketDataService.cjs +875 -0
  227. package/dist/services/MarketDataService.cjs.map +1 -0
  228. package/dist/services/MarketDataService.d.cts +289 -0
  229. package/dist/services/MarketDataService.d.cts.map +1 -0
  230. package/dist/services/MarketDataService.d.mts +289 -0
  231. package/dist/services/MarketDataService.d.mts.map +1 -0
  232. package/dist/services/MarketDataService.mjs +871 -0
  233. package/dist/services/MarketDataService.mjs.map +1 -0
  234. package/dist/services/RewardsIntegrationService.cjs +94 -0
  235. package/dist/services/RewardsIntegrationService.cjs.map +1 -0
  236. package/dist/services/RewardsIntegrationService.d.cts +30 -0
  237. package/dist/services/RewardsIntegrationService.d.cts.map +1 -0
  238. package/dist/services/RewardsIntegrationService.d.mts +30 -0
  239. package/dist/services/RewardsIntegrationService.d.mts.map +1 -0
  240. package/dist/services/RewardsIntegrationService.mjs +90 -0
  241. package/dist/services/RewardsIntegrationService.mjs.map +1 -0
  242. package/dist/services/ServiceContext.cjs +3 -0
  243. package/dist/services/ServiceContext.cjs.map +1 -0
  244. package/dist/services/ServiceContext.d.cts +110 -0
  245. package/dist/services/ServiceContext.d.cts.map +1 -0
  246. package/dist/services/ServiceContext.d.mts +110 -0
  247. package/dist/services/ServiceContext.d.mts.map +1 -0
  248. package/dist/services/ServiceContext.mjs +2 -0
  249. package/dist/services/ServiceContext.mjs.map +1 -0
  250. package/dist/services/TradingService.cjs +1481 -0
  251. package/dist/services/TradingService.cjs.map +1 -0
  252. package/dist/services/TradingService.d.cts +308 -0
  253. package/dist/services/TradingService.d.cts.map +1 -0
  254. package/dist/services/TradingService.d.mts +308 -0
  255. package/dist/services/TradingService.d.mts.map +1 -0
  256. package/dist/services/TradingService.mjs +1477 -0
  257. package/dist/services/TradingService.mjs.map +1 -0
  258. package/dist/services/index.cjs +26 -0
  259. package/dist/services/index.cjs.map +1 -0
  260. package/dist/services/index.d.cts +11 -0
  261. package/dist/services/index.d.cts.map +1 -0
  262. package/dist/services/index.d.mts +11 -0
  263. package/dist/services/index.d.mts.map +1 -0
  264. package/dist/services/index.mjs +10 -0
  265. package/dist/services/index.mjs.map +1 -0
  266. package/dist/services/utils.cjs +16 -0
  267. package/dist/services/utils.cjs.map +1 -0
  268. package/dist/services/utils.d.cts +8 -0
  269. package/dist/services/utils.d.cts.map +1 -0
  270. package/dist/services/utils.d.mts +8 -0
  271. package/dist/services/utils.d.mts.map +1 -0
  272. package/dist/services/utils.mjs +12 -0
  273. package/dist/services/utils.mjs.map +1 -0
  274. package/dist/types/chart.cjs +42 -0
  275. package/dist/types/chart.cjs.map +1 -0
  276. package/dist/types/chart.d.cts +62 -0
  277. package/dist/types/chart.d.cts.map +1 -0
  278. package/dist/types/chart.d.mts +62 -0
  279. package/dist/types/chart.d.mts.map +1 -0
  280. package/dist/types/chart.mjs +39 -0
  281. package/dist/types/chart.mjs.map +1 -0
  282. package/dist/types/hyperliquid-types.cjs +3 -0
  283. package/dist/types/hyperliquid-types.cjs.map +1 -0
  284. package/dist/types/hyperliquid-types.d.cts +52 -0
  285. package/dist/types/hyperliquid-types.d.cts.map +1 -0
  286. package/dist/types/hyperliquid-types.d.mts +52 -0
  287. package/dist/types/hyperliquid-types.d.mts.map +1 -0
  288. package/dist/types/hyperliquid-types.mjs +2 -0
  289. package/dist/types/hyperliquid-types.mjs.map +1 -0
  290. package/dist/types/index.cjs +96 -0
  291. package/dist/types/index.cjs.map +1 -0
  292. package/dist/types/index.d.cts +1153 -0
  293. package/dist/types/index.d.cts.map +1 -0
  294. package/dist/types/index.d.mts +1153 -0
  295. package/dist/types/index.d.mts.map +1 -0
  296. package/dist/types/index.mjs +79 -0
  297. package/dist/types/index.mjs.map +1 -0
  298. package/dist/types/transactionTypes.cjs +28 -0
  299. package/dist/types/transactionTypes.cjs.map +1 -0
  300. package/dist/types/transactionTypes.d.cts +64 -0
  301. package/dist/types/transactionTypes.d.cts.map +1 -0
  302. package/dist/types/transactionTypes.d.mts +64 -0
  303. package/dist/types/transactionTypes.d.mts.map +1 -0
  304. package/dist/types/transactionTypes.mjs +23 -0
  305. package/dist/types/transactionTypes.mjs.map +1 -0
  306. package/dist/utils/accountUtils.cjs +65 -0
  307. package/dist/utils/accountUtils.cjs.map +1 -0
  308. package/dist/utils/accountUtils.d.cts +26 -0
  309. package/dist/utils/accountUtils.d.cts.map +1 -0
  310. package/dist/utils/accountUtils.d.mts +26 -0
  311. package/dist/utils/accountUtils.d.mts.map +1 -0
  312. package/dist/utils/accountUtils.mjs +61 -0
  313. package/dist/utils/accountUtils.mjs.map +1 -0
  314. package/dist/utils/amountConversion.cjs +61 -0
  315. package/dist/utils/amountConversion.cjs.map +1 -0
  316. package/dist/utils/amountConversion.d.cts +16 -0
  317. package/dist/utils/amountConversion.d.cts.map +1 -0
  318. package/dist/utils/amountConversion.d.mts +16 -0
  319. package/dist/utils/amountConversion.d.mts.map +1 -0
  320. package/dist/utils/amountConversion.mjs +54 -0
  321. package/dist/utils/amountConversion.mjs.map +1 -0
  322. package/dist/utils/chartUtils.cjs +98 -0
  323. package/dist/utils/chartUtils.cjs.map +1 -0
  324. package/dist/utils/chartUtils.d.cts +14 -0
  325. package/dist/utils/chartUtils.d.cts.map +1 -0
  326. package/dist/utils/chartUtils.d.mts +14 -0
  327. package/dist/utils/chartUtils.d.mts.map +1 -0
  328. package/dist/utils/chartUtils.mjs +94 -0
  329. package/dist/utils/chartUtils.mjs.map +1 -0
  330. package/dist/utils/errorUtils.cjs +22 -0
  331. package/dist/utils/errorUtils.cjs.map +1 -0
  332. package/dist/utils/errorUtils.d.cts +13 -0
  333. package/dist/utils/errorUtils.d.cts.map +1 -0
  334. package/dist/utils/errorUtils.d.mts +13 -0
  335. package/dist/utils/errorUtils.d.mts.map +1 -0
  336. package/dist/utils/errorUtils.mjs +18 -0
  337. package/dist/utils/errorUtils.mjs.map +1 -0
  338. package/dist/utils/formatUtils.cjs +987 -0
  339. package/dist/utils/formatUtils.cjs.map +1 -0
  340. package/dist/utils/formatUtils.d.cts +387 -0
  341. package/dist/utils/formatUtils.d.cts.map +1 -0
  342. package/dist/utils/formatUtils.d.mts +387 -0
  343. package/dist/utils/formatUtils.d.mts.map +1 -0
  344. package/dist/utils/formatUtils.mjs +966 -0
  345. package/dist/utils/formatUtils.mjs.map +1 -0
  346. package/dist/utils/hyperLiquidAdapter.cjs +454 -0
  347. package/dist/utils/hyperLiquidAdapter.cjs.map +1 -0
  348. package/dist/utils/hyperLiquidAdapter.d.cts +158 -0
  349. package/dist/utils/hyperLiquidAdapter.d.cts.map +1 -0
  350. package/dist/utils/hyperLiquidAdapter.d.mts +158 -0
  351. package/dist/utils/hyperLiquidAdapter.d.mts.map +1 -0
  352. package/dist/utils/hyperLiquidAdapter.mjs +439 -0
  353. package/dist/utils/hyperLiquidAdapter.mjs.map +1 -0
  354. package/dist/utils/hyperLiquidOrderBookProcessor.cjs +89 -0
  355. package/dist/utils/hyperLiquidOrderBookProcessor.cjs.map +1 -0
  356. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts +58 -0
  357. package/dist/utils/hyperLiquidOrderBookProcessor.d.cts.map +1 -0
  358. package/dist/utils/hyperLiquidOrderBookProcessor.d.mts +58 -0
  359. package/dist/utils/hyperLiquidOrderBookProcessor.d.mts.map +1 -0
  360. package/dist/utils/hyperLiquidOrderBookProcessor.mjs +84 -0
  361. package/dist/utils/hyperLiquidOrderBookProcessor.mjs.map +1 -0
  362. package/dist/utils/hyperLiquidValidation.cjs +426 -0
  363. package/dist/utils/hyperLiquidValidation.cjs.map +1 -0
  364. package/dist/utils/hyperLiquidValidation.d.cts +143 -0
  365. package/dist/utils/hyperLiquidValidation.d.cts.map +1 -0
  366. package/dist/utils/hyperLiquidValidation.d.mts +143 -0
  367. package/dist/utils/hyperLiquidValidation.d.mts.map +1 -0
  368. package/dist/utils/hyperLiquidValidation.mjs +413 -0
  369. package/dist/utils/hyperLiquidValidation.mjs.map +1 -0
  370. package/dist/utils/idUtils.cjs +50 -0
  371. package/dist/utils/idUtils.cjs.map +1 -0
  372. package/dist/utils/idUtils.d.cts +38 -0
  373. package/dist/utils/idUtils.d.cts.map +1 -0
  374. package/dist/utils/idUtils.d.mts +38 -0
  375. package/dist/utils/idUtils.d.mts.map +1 -0
  376. package/dist/utils/idUtils.mjs +42 -0
  377. package/dist/utils/idUtils.mjs.map +1 -0
  378. package/dist/utils/marginUtils.cjs +137 -0
  379. package/dist/utils/marginUtils.cjs.map +1 -0
  380. package/dist/utils/marginUtils.d.cts +64 -0
  381. package/dist/utils/marginUtils.d.cts.map +1 -0
  382. package/dist/utils/marginUtils.d.mts +64 -0
  383. package/dist/utils/marginUtils.d.mts.map +1 -0
  384. package/dist/utils/marginUtils.mjs +131 -0
  385. package/dist/utils/marginUtils.mjs.map +1 -0
  386. package/dist/utils/marketDataTransform.cjs +227 -0
  387. package/dist/utils/marketDataTransform.cjs.map +1 -0
  388. package/dist/utils/marketDataTransform.d.cts +45 -0
  389. package/dist/utils/marketDataTransform.d.cts.map +1 -0
  390. package/dist/utils/marketDataTransform.d.mts +45 -0
  391. package/dist/utils/marketDataTransform.d.mts.map +1 -0
  392. package/dist/utils/marketDataTransform.mjs +220 -0
  393. package/dist/utils/marketDataTransform.mjs.map +1 -0
  394. package/dist/utils/marketUtils.cjs +420 -0
  395. package/dist/utils/marketUtils.cjs.map +1 -0
  396. package/dist/utils/marketUtils.d.cts +227 -0
  397. package/dist/utils/marketUtils.d.cts.map +1 -0
  398. package/dist/utils/marketUtils.d.mts +227 -0
  399. package/dist/utils/marketUtils.d.mts.map +1 -0
  400. package/dist/utils/marketUtils.mjs +404 -0
  401. package/dist/utils/marketUtils.mjs.map +1 -0
  402. package/dist/utils/orderBookGrouping.cjs +151 -0
  403. package/dist/utils/orderBookGrouping.cjs.map +1 -0
  404. package/dist/utils/orderBookGrouping.d.cts +76 -0
  405. package/dist/utils/orderBookGrouping.d.cts.map +1 -0
  406. package/dist/utils/orderBookGrouping.d.mts +76 -0
  407. package/dist/utils/orderBookGrouping.d.mts.map +1 -0
  408. package/dist/utils/orderBookGrouping.mjs +143 -0
  409. package/dist/utils/orderBookGrouping.mjs.map +1 -0
  410. package/dist/utils/orderCalculations.cjs +283 -0
  411. package/dist/utils/orderCalculations.cjs.map +1 -0
  412. package/dist/utils/orderCalculations.d.cts +107 -0
  413. package/dist/utils/orderCalculations.d.cts.map +1 -0
  414. package/dist/utils/orderCalculations.d.mts +107 -0
  415. package/dist/utils/orderCalculations.d.mts.map +1 -0
  416. package/dist/utils/orderCalculations.mjs +274 -0
  417. package/dist/utils/orderCalculations.mjs.map +1 -0
  418. package/dist/utils/orderUtils.cjs +159 -0
  419. package/dist/utils/orderUtils.cjs.map +1 -0
  420. package/dist/utils/orderUtils.d.cts +66 -0
  421. package/dist/utils/orderUtils.d.cts.map +1 -0
  422. package/dist/utils/orderUtils.d.mts +66 -0
  423. package/dist/utils/orderUtils.d.mts.map +1 -0
  424. package/dist/utils/orderUtils.mjs +151 -0
  425. package/dist/utils/orderUtils.mjs.map +1 -0
  426. package/dist/utils/pnlCalculations.cjs +107 -0
  427. package/dist/utils/pnlCalculations.cjs.map +1 -0
  428. package/dist/utils/pnlCalculations.d.cts +79 -0
  429. package/dist/utils/pnlCalculations.d.cts.map +1 -0
  430. package/dist/utils/pnlCalculations.d.mts +79 -0
  431. package/dist/utils/pnlCalculations.d.mts.map +1 -0
  432. package/dist/utils/pnlCalculations.mjs +97 -0
  433. package/dist/utils/pnlCalculations.mjs.map +1 -0
  434. package/dist/utils/positionCalculations.cjs +176 -0
  435. package/dist/utils/positionCalculations.cjs.map +1 -0
  436. package/dist/utils/positionCalculations.d.cts +85 -0
  437. package/dist/utils/positionCalculations.d.cts.map +1 -0
  438. package/dist/utils/positionCalculations.d.mts +85 -0
  439. package/dist/utils/positionCalculations.d.mts.map +1 -0
  440. package/dist/utils/positionCalculations.mjs +165 -0
  441. package/dist/utils/positionCalculations.mjs.map +1 -0
  442. package/dist/utils/sortMarkets.cjs +88 -0
  443. package/dist/utils/sortMarkets.cjs.map +1 -0
  444. package/dist/utils/sortMarkets.d.cts +21 -0
  445. package/dist/utils/sortMarkets.d.cts.map +1 -0
  446. package/dist/utils/sortMarkets.d.mts +21 -0
  447. package/dist/utils/sortMarkets.d.mts.map +1 -0
  448. package/dist/utils/sortMarkets.mjs +84 -0
  449. package/dist/utils/sortMarkets.mjs.map +1 -0
  450. package/dist/utils/standaloneInfoClient.cjs +34 -0
  451. package/dist/utils/standaloneInfoClient.cjs.map +1 -0
  452. package/dist/utils/standaloneInfoClient.d.cts +31 -0
  453. package/dist/utils/standaloneInfoClient.d.cts.map +1 -0
  454. package/dist/utils/standaloneInfoClient.d.mts +31 -0
  455. package/dist/utils/standaloneInfoClient.d.mts.map +1 -0
  456. package/dist/utils/standaloneInfoClient.mjs +30 -0
  457. package/dist/utils/standaloneInfoClient.mjs.map +1 -0
  458. package/dist/utils/stringParseUtils.cjs +49 -0
  459. package/dist/utils/stringParseUtils.cjs.map +1 -0
  460. package/dist/utils/stringParseUtils.d.cts +35 -0
  461. package/dist/utils/stringParseUtils.d.cts.map +1 -0
  462. package/dist/utils/stringParseUtils.d.mts +35 -0
  463. package/dist/utils/stringParseUtils.d.mts.map +1 -0
  464. package/dist/utils/stringParseUtils.mjs +44 -0
  465. package/dist/utils/stringParseUtils.mjs.map +1 -0
  466. package/dist/utils/time.cjs +37 -0
  467. package/dist/utils/time.cjs.map +1 -0
  468. package/dist/utils/time.d.cts +17 -0
  469. package/dist/utils/time.d.cts.map +1 -0
  470. package/dist/utils/time.d.mts +17 -0
  471. package/dist/utils/time.d.mts.map +1 -0
  472. package/dist/utils/time.mjs +33 -0
  473. package/dist/utils/time.mjs.map +1 -0
  474. package/dist/utils/tpslValidation.cjs +505 -0
  475. package/dist/utils/tpslValidation.cjs.map +1 -0
  476. package/dist/utils/tpslValidation.d.cts +182 -0
  477. package/dist/utils/tpslValidation.d.cts.map +1 -0
  478. package/dist/utils/tpslValidation.d.mts +182 -0
  479. package/dist/utils/tpslValidation.d.mts.map +1 -0
  480. package/dist/utils/tpslValidation.mjs +482 -0
  481. package/dist/utils/tpslValidation.mjs.map +1 -0
  482. package/dist/utils/transactionUtils.cjs +36 -0
  483. package/dist/utils/transactionUtils.cjs.map +1 -0
  484. package/dist/utils/transactionUtils.d.cts +17 -0
  485. package/dist/utils/transactionUtils.d.cts.map +1 -0
  486. package/dist/utils/transactionUtils.d.mts +17 -0
  487. package/dist/utils/transactionUtils.d.mts.map +1 -0
  488. package/dist/utils/transactionUtils.mjs +32 -0
  489. package/dist/utils/transactionUtils.mjs.map +1 -0
  490. package/dist/utils/wait.cjs +12 -0
  491. package/dist/utils/wait.cjs.map +1 -0
  492. package/dist/utils/wait.d.cts +8 -0
  493. package/dist/utils/wait.d.cts.map +1 -0
  494. package/dist/utils/wait.d.mts +8 -0
  495. package/dist/utils/wait.d.mts.map +1 -0
  496. package/dist/utils/wait.mjs +8 -0
  497. package/dist/utils/wait.mjs.map +1 -0
  498. package/package.json +19 -4
@@ -0,0 +1,254 @@
1
+ /* eslint-disable id-denylist, no-restricted-syntax, no-negated-condition */
2
+ // TODO: Fix ESLint errors in this file - tracked for Phase 5 cleanup
3
+ import { hasProperty } from "@metamask/utils";
4
+ import { parseCommaSeparatedString, stripQuotes } from "../utils/stringParseUtils.mjs";
5
+ /**
6
+ * Check if a value is a valid version gated feature flag.
7
+ *
8
+ * @param flag - The value to check
9
+ * @returns True if the value has a boolean 'value' property
10
+ */
11
+ function isVersionGatedFeatureFlag(flag) {
12
+ return (typeof flag === 'object' &&
13
+ flag !== null &&
14
+ 'value' in flag &&
15
+ typeof flag.value === 'boolean');
16
+ }
17
+ /**
18
+ * Extract the boolean value from a version gated feature flag.
19
+ *
20
+ * @param flag - The version gated feature flag
21
+ * @returns The boolean value or undefined if invalid
22
+ */
23
+ function validatedVersionGatedFeatureFlag(flag) {
24
+ return flag.value;
25
+ }
26
+ /**
27
+ * FeatureFlagConfigurationService
28
+ *
29
+ * Handles HIP-3 configuration and geo-blocking configuration from remote feature flags.
30
+ * Implements "sticky remote" pattern: once remote config is loaded, never downgrade to fallback.
31
+ * Orchestrates validation, change detection, and version management for feature flag updates.
32
+ *
33
+ * Responsibilities:
34
+ * - Remote feature flag validation and parsing
35
+ * - HIP-3 configuration management (equity, allowlist, blocklist)
36
+ * - Geo-blocking configuration from remote flags
37
+ * - Change detection and version management
38
+ * - "Sticky remote" pattern enforcement (never downgrade)
39
+ *
40
+ * Instance-based service with constructor injection of platform dependencies.
41
+ */
42
+ export class FeatureFlagConfigurationService {
43
+ /**
44
+ * Create a new FeatureFlagConfigurationService instance.
45
+ *
46
+ * @param deps - Platform dependencies for logging, metrics, etc.
47
+ */
48
+ constructor(deps) {
49
+ this.deps = deps;
50
+ }
51
+ /**
52
+ * Validate and parse market list from remote feature flags.
53
+ * Handles both string (comma-separated) and array formats from LaunchDarkly.
54
+ *
55
+ * @param remoteValue - The raw value from remote feature flags
56
+ * @param fieldName - The name of the field for logging
57
+ * @param currentValue - The current value to use as fallback
58
+ * @returns The validated market list or undefined if validation fails
59
+ */
60
+ validateMarketList(remoteValue, fieldName, currentValue) {
61
+ this.deps.debugLogger.log(`PerpsController: HIP-3 ${fieldName} validation`, {
62
+ remoteValue,
63
+ type: typeof remoteValue,
64
+ isArray: Array.isArray(remoteValue),
65
+ });
66
+ // LaunchDarkly returns comma-separated strings for list values
67
+ // Values may have literal quotes (e.g., '"xyz"') due to JSON encoding quirks
68
+ if (typeof remoteValue === 'string') {
69
+ const parsed = parseCommaSeparatedString(remoteValue).map(stripQuotes);
70
+ if (parsed.length > 0) {
71
+ this.deps.debugLogger.log(`PerpsController: HIP-3 ${fieldName} validated from string`, { validatedMarkets: parsed });
72
+ return parsed;
73
+ }
74
+ this.deps.debugLogger.log(`PerpsController: HIP-3 ${fieldName} string was empty after parsing`, { fallbackValue: currentValue });
75
+ return undefined;
76
+ }
77
+ // Fallback: Validate array of non-empty strings
78
+ if (Array.isArray(remoteValue) &&
79
+ remoteValue.every((item) => typeof item === 'string' && item.length > 0)) {
80
+ const validatedMarkets = remoteValue
81
+ .map((market) => stripQuotes(market.trim()))
82
+ .filter((market) => market.length > 0);
83
+ this.deps.debugLogger.log(`PerpsController: HIP-3 ${fieldName} validated from array`, { validatedMarkets });
84
+ return validatedMarkets;
85
+ }
86
+ this.deps.debugLogger.log(`PerpsController: HIP-3 ${fieldName} validation FAILED - falling back to local config`, {
87
+ reason: Array.isArray(remoteValue)
88
+ ? 'Array contains non-string or empty values'
89
+ : 'Invalid type (expected string or array)',
90
+ fallbackValue: currentValue,
91
+ });
92
+ return undefined;
93
+ }
94
+ /**
95
+ * Check if arrays have different values (order-independent comparison).
96
+ *
97
+ * @param a - First array
98
+ * @param b - Second array
99
+ * @returns True if arrays have different values
100
+ */
101
+ arraysHaveDifferentValues(a, b) {
102
+ return (JSON.stringify([...a].sort((itemA, itemB) => itemA.localeCompare(itemB))) !==
103
+ JSON.stringify([...b].sort((itemA, itemB) => itemA.localeCompare(itemB))));
104
+ }
105
+ /**
106
+ * Refresh HIP-3 configuration when remote feature flags change.
107
+ * This method extracts HIP-3 settings from remote flags, validates them,
108
+ * and updates internal state if they differ from current values.
109
+ * When config changes, increments hip3ConfigVersion to trigger ConnectionManager reconnection.
110
+ *
111
+ * Follows the "sticky remote" pattern: once remote config is loaded, never downgrade to fallback.
112
+ *
113
+ * @param options - Configuration object
114
+ * @param options.remoteFeatureFlagControllerState - State from RemoteFeatureFlagController
115
+ * @param options.context - ServiceContext providing state access callbacks
116
+ */
117
+ refreshHip3Config(options) {
118
+ const { remoteFeatureFlagControllerState, context } = options;
119
+ if (!context.getHip3Config ||
120
+ !context.setHip3Config ||
121
+ !context.incrementHip3ConfigVersion) {
122
+ throw new Error('Required HIP-3 callbacks not available in ServiceContext');
123
+ }
124
+ const remoteFlags = remoteFeatureFlagControllerState.remoteFeatureFlags;
125
+ const currentConfig = context.getHip3Config();
126
+ // Extract and validate remote HIP-3 equity enabled flag
127
+ const equityFlag = remoteFlags?.perpsHip3Enabled;
128
+ // Use type guard to validate before calling - validatedVersionGatedFeatureFlag also
129
+ // handles invalid flags internally, but proper typing requires the guard
130
+ const validatedEquity = isVersionGatedFeatureFlag(equityFlag)
131
+ ? validatedVersionGatedFeatureFlag(equityFlag)
132
+ : undefined;
133
+ this.deps.debugLogger.log('PerpsController: HIP-3 equity flag validation', {
134
+ equityFlag,
135
+ validatedEquity,
136
+ willUse: validatedEquity !== undefined ? 'remote' : 'fallback',
137
+ });
138
+ // Extract and validate remote HIP-3 market lists
139
+ const validatedAllowlistMarkets = hasProperty(remoteFlags, 'perpsHip3AllowlistMarkets')
140
+ ? this.validateMarketList(remoteFlags.perpsHip3AllowlistMarkets, 'allowlistMarkets', currentConfig.allowlistMarkets)
141
+ : undefined;
142
+ const validatedBlocklistMarkets = hasProperty(remoteFlags, 'perpsHip3BlocklistMarkets')
143
+ ? this.validateMarketList(remoteFlags.perpsHip3BlocklistMarkets, 'blocklistMarkets', currentConfig.blocklistMarkets)
144
+ : undefined;
145
+ // Detect changes (only if we have valid remote values)
146
+ const equityChanged = validatedEquity !== undefined &&
147
+ validatedEquity !== currentConfig.enabled;
148
+ const allowlistMarketsChanged = validatedAllowlistMarkets !== undefined &&
149
+ this.arraysHaveDifferentValues(validatedAllowlistMarkets, currentConfig.allowlistMarkets);
150
+ const blocklistMarketsChanged = validatedBlocklistMarkets !== undefined &&
151
+ this.arraysHaveDifferentValues(validatedBlocklistMarkets, currentConfig.blocklistMarkets);
152
+ if (equityChanged || allowlistMarketsChanged || blocklistMarketsChanged) {
153
+ this.deps.debugLogger.log('PerpsController: HIP-3 config changed via remote feature flags', {
154
+ equityChanged,
155
+ allowlistMarketsChanged,
156
+ blocklistMarketsChanged,
157
+ oldEquity: currentConfig.enabled,
158
+ newEquity: validatedEquity,
159
+ oldAllowlistMarkets: currentConfig.allowlistMarkets,
160
+ newAllowlistMarkets: validatedAllowlistMarkets,
161
+ oldBlocklistMarkets: currentConfig.blocklistMarkets,
162
+ newBlocklistMarkets: validatedBlocklistMarkets,
163
+ source: 'remote',
164
+ });
165
+ // Update internal state (sticky remote - never downgrade)
166
+ context.setHip3Config({
167
+ enabled: validatedEquity,
168
+ allowlistMarkets: validatedAllowlistMarkets
169
+ ? [...validatedAllowlistMarkets]
170
+ : undefined,
171
+ blocklistMarkets: validatedBlocklistMarkets
172
+ ? [...validatedBlocklistMarkets]
173
+ : undefined,
174
+ source: 'remote',
175
+ });
176
+ // Increment version to trigger ConnectionManager reconnection and cache clearing
177
+ const newVersion = context.incrementHip3ConfigVersion();
178
+ this.deps.debugLogger.log('PerpsController: Incremented hip3ConfigVersion to trigger reconnection', {
179
+ newVersion,
180
+ newHip3Enabled: validatedEquity ?? currentConfig.enabled,
181
+ newHip3AllowlistMarkets: validatedAllowlistMarkets ?? currentConfig.allowlistMarkets,
182
+ newHip3BlocklistMarkets: validatedBlocklistMarkets ?? currentConfig.blocklistMarkets,
183
+ });
184
+ // Note: ConnectionManager will handle:
185
+ // 1. Detecting hip3ConfigVersion change via Redux monitoring
186
+ // 2. Clearing all StreamManager caches
187
+ // 3. Calling reconnectWithNewContext() -> initializeProviders()
188
+ // 4. Provider reinitialization will read the new HIP-3 config below
189
+ }
190
+ }
191
+ /**
192
+ * Respond to RemoteFeatureFlagController state changes.
193
+ * Refreshes user eligibility based on geo-blocked regions defined in remote feature flag.
194
+ * Uses fallback configuration when remote feature flag is undefined.
195
+ * Note: Initial eligibility is set in the constructor if fallback regions are provided.
196
+ *
197
+ * @param options - Configuration object
198
+ * @param options.remoteFeatureFlagControllerState - State from RemoteFeatureFlagController
199
+ * @param options.context - ServiceContext providing callbacks
200
+ */
201
+ refreshEligibility(options) {
202
+ const { remoteFeatureFlagControllerState, context } = options;
203
+ const perpsGeoBlockedRegionsFeatureFlag =
204
+ // NOTE: Do not use perpsPerpTradingGeoBlockedCountries as it is deprecated.
205
+ remoteFeatureFlagControllerState.remoteFeatureFlags
206
+ ?.perpsPerpTradingGeoBlockedCountriesV2;
207
+ const remoteBlockedRegions = perpsGeoBlockedRegionsFeatureFlag?.blockedRegions;
208
+ if (Array.isArray(remoteBlockedRegions)) {
209
+ this.setBlockedRegions({
210
+ list: remoteBlockedRegions,
211
+ source: 'remote',
212
+ context,
213
+ });
214
+ }
215
+ // Also check for HIP-3 config changes
216
+ this.refreshHip3Config({ remoteFeatureFlagControllerState, context });
217
+ }
218
+ /**
219
+ * Set blocked region list with "never downgrade" pattern enforcement.
220
+ * Updates the blocked region list and triggers eligibility refresh.
221
+ * Implements "sticky remote": once remote regions are set, never downgrade to fallback.
222
+ *
223
+ * @param options - Configuration object
224
+ * @param options.list - Array of blocked region codes
225
+ * @param options.source - Source of the list ('remote' or 'fallback')
226
+ * @param options.context - ServiceContext providing callbacks
227
+ */
228
+ setBlockedRegions(options) {
229
+ const { list, source, context } = options;
230
+ if (!context.getBlockedRegionList ||
231
+ !context.setBlockedRegionList ||
232
+ !context.refreshEligibility) {
233
+ throw new Error('Required blocked region callbacks not available in ServiceContext');
234
+ }
235
+ const currentList = context.getBlockedRegionList();
236
+ // Never downgrade from remote to fallback
237
+ if (source === 'fallback' && currentList.source === 'remote') {
238
+ return;
239
+ }
240
+ if (Array.isArray(list)) {
241
+ context.setBlockedRegionList(list, source);
242
+ }
243
+ context.refreshEligibility().catch((err) => {
244
+ const error = err instanceof Error ? err : new Error(String(err));
245
+ this.deps.logger.error(error, {
246
+ context: {
247
+ name: 'FeatureFlagConfigurationService.setBlockedRegions',
248
+ data: { source },
249
+ },
250
+ });
251
+ });
252
+ }
253
+ }
254
+ //# sourceMappingURL=FeatureFlagConfigurationService.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeatureFlagConfigurationService.mjs","sourceRoot":"","sources":["../../src/services/FeatureFlagConfigurationService.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,qEAAqE;AACrE,OAAO,EAAE,WAAW,EAAE,wBAAwB;AAI9C,OAAO,EACL,yBAAyB,EACzB,WAAW,EACZ,sCAAkC;AAkBnC;;;;;GAKG;AACH,SAAS,yBAAyB,CAChC,IAAa;IAEb,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,OAAO,IAAI,IAAI;QACf,OAAQ,IAAgC,CAAC,KAAK,KAAK,SAAS,CAC7D,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,gCAAgC,CACvC,IAA6B;IAE7B,OAAO,IAAI,CAAC,KAAK,CAAC;AACpB,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,+BAA+B;IAG1C;;;;OAIG;IACH,YAAY,IAA+B;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;;;;;;OAQG;IACK,kBAAkB,CACxB,WAAoB,EACpB,SAAiB,EACjB,YAAsB;QAEtB,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CACvB,0BAA0B,SAAS,aAAa,EAChD;YACE,WAAW;YACX,IAAI,E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,EAAE,MAAM,EAAE;iBACjB;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["/* eslint-disable id-denylist, no-restricted-syntax, no-negated-condition */\n// TODO: Fix ESLint errors in this file - tracked for Phase 5 cleanup\nimport { hasProperty } from '@metamask/utils';\n\nimport type { ServiceContext } from './ServiceContext';\nimport type { PerpsPlatformDependencies } from '../types';\nimport {\n parseCommaSeparatedString,\n stripQuotes,\n} from '../utils/stringParseUtils';\n\n/**\n * Remote feature flags state shape for perps-related flags.\n * This is a minimal type definition to avoid direct dependency on\n * RemoteFeatureFlagController which can cause build issues.\n */\ntype RemoteFeatureFlagState = {\n remoteFeatureFlags: Record<string, unknown>;\n};\n\n/**\n * Version gated feature flag structure for validating remote flags.\n */\ntype VersionGatedFeatureFlag = {\n value?: boolean;\n};\n\n/**\n * Check if a value is a valid version gated feature flag.\n *\n * @param flag - The value to check\n * @returns True if the value has a boolean 'value' property\n */\nfunction isVersionGatedFeatureFlag(\n flag: unknown,\n): flag is VersionGatedFeatureFlag {\n return (\n typeof flag === 'object' &&\n flag !== null &&\n 'value' in flag &&\n typeof (flag as VersionGatedFeatureFlag).value === 'boolean'\n );\n}\n\n/**\n * Extract the boolean value from a version gated feature flag.\n *\n * @param flag - The version gated feature flag\n * @returns The boolean value or undefined if invalid\n */\nfunction validatedVersionGatedFeatureFlag(\n flag: VersionGatedFeatureFlag,\n): boolean | undefined {\n return flag.value;\n}\n\n/**\n * FeatureFlagConfigurationService\n *\n * Handles HIP-3 configuration and geo-blocking configuration from remote feature flags.\n * Implements \"sticky remote\" pattern: once remote config is loaded, never downgrade to fallback.\n * Orchestrates validation, change detection, and version management for feature flag updates.\n *\n * Responsibilities:\n * - Remote feature flag validation and parsing\n * - HIP-3 configuration management (equity, allowlist, blocklist)\n * - Geo-blocking configuration from remote flags\n * - Change detection and version management\n * - \"Sticky remote\" pattern enforcement (never downgrade)\n *\n * Instance-based service with constructor injection of platform dependencies.\n */\nexport class FeatureFlagConfigurationService {\n private readonly deps: PerpsPlatformDependencies;\n\n /**\n * Create a new FeatureFlagConfigurationService instance.\n *\n * @param deps - Platform dependencies for logging, metrics, etc.\n */\n constructor(deps: PerpsPlatformDependencies) {\n this.deps = deps;\n }\n\n /**\n * Validate and parse market list from remote feature flags.\n * Handles both string (comma-separated) and array formats from LaunchDarkly.\n *\n * @param remoteValue - The raw value from remote feature flags\n * @param fieldName - The name of the field for logging\n * @param currentValue - The current value to use as fallback\n * @returns The validated market list or undefined if validation fails\n */\n private validateMarketList(\n remoteValue: unknown,\n fieldName: string,\n currentValue: string[],\n ): string[] | undefined {\n this.deps.debugLogger.log(\n `PerpsController: HIP-3 ${fieldName} validation`,\n {\n remoteValue,\n type: typeof remoteValue,\n isArray: Array.isArray(remoteValue),\n },\n );\n\n // LaunchDarkly returns comma-separated strings for list values\n // Values may have literal quotes (e.g., '\"xyz\"') due to JSON encoding quirks\n if (typeof remoteValue === 'string') {\n const parsed = parseCommaSeparatedString(remoteValue).map(stripQuotes);\n\n if (parsed.length > 0) {\n this.deps.debugLogger.log(\n `PerpsController: HIP-3 ${fieldName} validated from string`,\n { validatedMarkets: parsed },\n );\n return parsed;\n }\n\n this.deps.debugLogger.log(\n `PerpsController: HIP-3 ${fieldName} string was empty after parsing`,\n { fallbackValue: currentValue },\n );\n return undefined;\n }\n\n // Fallback: Validate array of non-empty strings\n if (\n Array.isArray(remoteValue) &&\n remoteValue.every((item) => typeof item === 'string' && item.length > 0)\n ) {\n const validatedMarkets = (remoteValue as string[])\n .map((market) => stripQuotes(market.trim()))\n .filter((market) => market.length > 0);\n\n this.deps.debugLogger.log(\n `PerpsController: HIP-3 ${fieldName} validated from array`,\n { validatedMarkets },\n );\n return validatedMarkets;\n }\n\n this.deps.debugLogger.log(\n `PerpsController: HIP-3 ${fieldName} validation FAILED - falling back to local config`,\n {\n reason: Array.isArray(remoteValue)\n ? 'Array contains non-string or empty values'\n : 'Invalid type (expected string or array)',\n fallbackValue: currentValue,\n },\n );\n return undefined;\n }\n\n /**\n * Check if arrays have different values (order-independent comparison).\n *\n * @param a - First array\n * @param b - Second array\n * @returns True if arrays have different values\n */\n private arraysHaveDifferentValues(a: string[], b: string[]): boolean {\n return (\n JSON.stringify(\n [...a].sort((itemA, itemB) => itemA.localeCompare(itemB)),\n ) !==\n JSON.stringify([...b].sort((itemA, itemB) => itemA.localeCompare(itemB)))\n );\n }\n\n /**\n * Refresh HIP-3 configuration when remote feature flags change.\n * This method extracts HIP-3 settings from remote flags, validates them,\n * and updates internal state if they differ from current values.\n * When config changes, increments hip3ConfigVersion to trigger ConnectionManager reconnection.\n *\n * Follows the \"sticky remote\" pattern: once remote config is loaded, never downgrade to fallback.\n *\n * @param options - Configuration object\n * @param options.remoteFeatureFlagControllerState - State from RemoteFeatureFlagController\n * @param options.context - ServiceContext providing state access callbacks\n */\n refreshHip3Config(options: {\n remoteFeatureFlagControllerState: RemoteFeatureFlagState;\n context: ServiceContext;\n }): void {\n const { remoteFeatureFlagControllerState, context } = options;\n\n if (\n !context.getHip3Config ||\n !context.setHip3Config ||\n !context.incrementHip3ConfigVersion\n ) {\n throw new Error(\n 'Required HIP-3 callbacks not available in ServiceContext',\n );\n }\n\n const remoteFlags = remoteFeatureFlagControllerState.remoteFeatureFlags;\n const currentConfig = context.getHip3Config();\n\n // Extract and validate remote HIP-3 equity enabled flag\n const equityFlag = remoteFlags?.perpsHip3Enabled;\n // Use type guard to validate before calling - validatedVersionGatedFeatureFlag also\n // handles invalid flags internally, but proper typing requires the guard\n const validatedEquity = isVersionGatedFeatureFlag(equityFlag)\n ? validatedVersionGatedFeatureFlag(equityFlag)\n : undefined;\n\n this.deps.debugLogger.log('PerpsController: HIP-3 equity flag validation', {\n equityFlag,\n validatedEquity,\n willUse: validatedEquity !== undefined ? 'remote' : 'fallback',\n });\n\n // Extract and validate remote HIP-3 market lists\n const validatedAllowlistMarkets = hasProperty(\n remoteFlags,\n 'perpsHip3AllowlistMarkets',\n )\n ? this.validateMarketList(\n remoteFlags.perpsHip3AllowlistMarkets,\n 'allowlistMarkets',\n currentConfig.allowlistMarkets,\n )\n : undefined;\n\n const validatedBlocklistMarkets = hasProperty(\n remoteFlags,\n 'perpsHip3BlocklistMarkets',\n )\n ? this.validateMarketList(\n remoteFlags.perpsHip3BlocklistMarkets,\n 'blocklistMarkets',\n currentConfig.blocklistMarkets,\n )\n : undefined;\n\n // Detect changes (only if we have valid remote values)\n const equityChanged =\n validatedEquity !== undefined &&\n validatedEquity !== currentConfig.enabled;\n const allowlistMarketsChanged =\n validatedAllowlistMarkets !== undefined &&\n this.arraysHaveDifferentValues(\n validatedAllowlistMarkets,\n currentConfig.allowlistMarkets,\n );\n const blocklistMarketsChanged =\n validatedBlocklistMarkets !== undefined &&\n this.arraysHaveDifferentValues(\n validatedBlocklistMarkets,\n currentConfig.blocklistMarkets,\n );\n\n if (equityChanged || allowlistMarketsChanged || blocklistMarketsChanged) {\n this.deps.debugLogger.log(\n 'PerpsController: HIP-3 config changed via remote feature flags',\n {\n equityChanged,\n allowlistMarketsChanged,\n blocklistMarketsChanged,\n oldEquity: currentConfig.enabled,\n newEquity: validatedEquity,\n oldAllowlistMarkets: currentConfig.allowlistMarkets,\n newAllowlistMarkets: validatedAllowlistMarkets,\n oldBlocklistMarkets: currentConfig.blocklistMarkets,\n newBlocklistMarkets: validatedBlocklistMarkets,\n source: 'remote',\n },\n );\n\n // Update internal state (sticky remote - never downgrade)\n context.setHip3Config({\n enabled: validatedEquity,\n allowlistMarkets: validatedAllowlistMarkets\n ? [...validatedAllowlistMarkets]\n : undefined,\n blocklistMarkets: validatedBlocklistMarkets\n ? [...validatedBlocklistMarkets]\n : undefined,\n source: 'remote',\n });\n\n // Increment version to trigger ConnectionManager reconnection and cache clearing\n const newVersion = context.incrementHip3ConfigVersion();\n\n this.deps.debugLogger.log(\n 'PerpsController: Incremented hip3ConfigVersion to trigger reconnection',\n {\n newVersion,\n newHip3Enabled: validatedEquity ?? currentConfig.enabled,\n newHip3AllowlistMarkets:\n validatedAllowlistMarkets ?? currentConfig.allowlistMarkets,\n newHip3BlocklistMarkets:\n validatedBlocklistMarkets ?? currentConfig.blocklistMarkets,\n },\n );\n\n // Note: ConnectionManager will handle:\n // 1. Detecting hip3ConfigVersion change via Redux monitoring\n // 2. Clearing all StreamManager caches\n // 3. Calling reconnectWithNewContext() -> initializeProviders()\n // 4. Provider reinitialization will read the new HIP-3 config below\n }\n }\n\n /**\n * Respond to RemoteFeatureFlagController state changes.\n * Refreshes user eligibility based on geo-blocked regions defined in remote feature flag.\n * Uses fallback configuration when remote feature flag is undefined.\n * Note: Initial eligibility is set in the constructor if fallback regions are provided.\n *\n * @param options - Configuration object\n * @param options.remoteFeatureFlagControllerState - State from RemoteFeatureFlagController\n * @param options.context - ServiceContext providing callbacks\n */\n refreshEligibility(options: {\n remoteFeatureFlagControllerState: RemoteFeatureFlagState;\n context: ServiceContext;\n }): void {\n const { remoteFeatureFlagControllerState, context } = options;\n\n const perpsGeoBlockedRegionsFeatureFlag =\n // NOTE: Do not use perpsPerpTradingGeoBlockedCountries as it is deprecated.\n remoteFeatureFlagControllerState.remoteFeatureFlags\n ?.perpsPerpTradingGeoBlockedCountriesV2;\n\n const remoteBlockedRegions = (\n perpsGeoBlockedRegionsFeatureFlag as { blockedRegions?: string[] }\n )?.blockedRegions;\n\n if (Array.isArray(remoteBlockedRegions)) {\n this.setBlockedRegions({\n list: remoteBlockedRegions,\n source: 'remote',\n context,\n });\n }\n\n // Also check for HIP-3 config changes\n this.refreshHip3Config({ remoteFeatureFlagControllerState, context });\n }\n\n /**\n * Set blocked region list with \"never downgrade\" pattern enforcement.\n * Updates the blocked region list and triggers eligibility refresh.\n * Implements \"sticky remote\": once remote regions are set, never downgrade to fallback.\n *\n * @param options - Configuration object\n * @param options.list - Array of blocked region codes\n * @param options.source - Source of the list ('remote' or 'fallback')\n * @param options.context - ServiceContext providing callbacks\n */\n setBlockedRegions(options: {\n list: string[];\n source: 'remote' | 'fallback';\n context: ServiceContext;\n }): void {\n const { list, source, context } = options;\n\n if (\n !context.getBlockedRegionList ||\n !context.setBlockedRegionList ||\n !context.refreshEligibility\n ) {\n throw new Error(\n 'Required blocked region callbacks not available in ServiceContext',\n );\n }\n\n const currentList = context.getBlockedRegionList();\n\n // Never downgrade from remote to fallback\n if (source === 'fallback' && currentList.source === 'remote') {\n return;\n }\n\n if (Array.isArray(list)) {\n context.setBlockedRegionList(list, source);\n }\n\n context.refreshEligibility().catch((err) => {\n const error = err instanceof Error ? err : new Error(String(err));\n this.deps.logger.error(error, {\n context: {\n name: 'FeatureFlagConfigurationService.setBlockedRegions',\n data: { source },\n },\n });\n });\n }\n}\n"]}