@metamask-previews/perps-controller 0.0.0-preview-b0148922a → 0.0.0-preview-ee1fa5d01
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.
- package/CHANGELOG.md +0 -25
- package/dist/PerpsController.cjs +65 -3077
- package/dist/PerpsController.cjs.map +1 -1
- package/dist/PerpsController.d.cts +82 -969
- package/dist/PerpsController.d.cts.map +1 -1
- package/dist/PerpsController.d.mts +82 -969
- package/dist/PerpsController.d.mts.map +1 -1
- package/dist/PerpsController.mjs +62 -3073
- package/dist/PerpsController.mjs.map +1 -1
- package/dist/index.cjs +1 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -38
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -38
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -46
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -16
- package/dist/aggregation/SubscriptionMultiplexer.cjs +0 -441
- package/dist/aggregation/SubscriptionMultiplexer.cjs.map +0 -1
- package/dist/aggregation/SubscriptionMultiplexer.d.cts +0 -171
- package/dist/aggregation/SubscriptionMultiplexer.d.cts.map +0 -1
- package/dist/aggregation/SubscriptionMultiplexer.d.mts +0 -171
- package/dist/aggregation/SubscriptionMultiplexer.d.mts.map +0 -1
- package/dist/aggregation/SubscriptionMultiplexer.mjs +0 -437
- package/dist/aggregation/SubscriptionMultiplexer.mjs.map +0 -1
- package/dist/aggregation/index.cjs +0 -9
- package/dist/aggregation/index.cjs.map +0 -1
- package/dist/aggregation/index.d.cts +0 -6
- package/dist/aggregation/index.d.cts.map +0 -1
- package/dist/aggregation/index.d.mts +0 -6
- package/dist/aggregation/index.d.mts.map +0 -1
- package/dist/aggregation/index.mjs +0 -5
- package/dist/aggregation/index.mjs.map +0 -1
- package/dist/constants/chartConfig.cjs +0 -227
- package/dist/constants/chartConfig.cjs.map +0 -1
- package/dist/constants/chartConfig.d.cts +0 -216
- package/dist/constants/chartConfig.d.cts.map +0 -1
- package/dist/constants/chartConfig.d.mts +0 -216
- package/dist/constants/chartConfig.d.mts.map +0 -1
- package/dist/constants/chartConfig.mjs +0 -221
- package/dist/constants/chartConfig.mjs.map +0 -1
- package/dist/constants/eventNames.cjs +0 -436
- package/dist/constants/eventNames.cjs.map +0 -1
- package/dist/constants/eventNames.d.cts +0 -387
- package/dist/constants/eventNames.d.cts.map +0 -1
- package/dist/constants/eventNames.d.mts +0 -387
- package/dist/constants/eventNames.d.mts.map +0 -1
- package/dist/constants/eventNames.mjs +0 -433
- package/dist/constants/eventNames.mjs.map +0 -1
- package/dist/constants/hyperLiquidConfig.cjs +0 -380
- package/dist/constants/hyperLiquidConfig.cjs.map +0 -1
- package/dist/constants/hyperLiquidConfig.d.cts +0 -236
- package/dist/constants/hyperLiquidConfig.d.cts.map +0 -1
- package/dist/constants/hyperLiquidConfig.d.mts +0 -236
- package/dist/constants/hyperLiquidConfig.d.mts.map +0 -1
- package/dist/constants/hyperLiquidConfig.mjs +0 -371
- package/dist/constants/hyperLiquidConfig.mjs.map +0 -1
- package/dist/constants/index.cjs +0 -28
- package/dist/constants/index.cjs.map +0 -1
- package/dist/constants/index.d.cts +0 -12
- package/dist/constants/index.d.cts.map +0 -1
- package/dist/constants/index.d.mts +0 -12
- package/dist/constants/index.d.mts.map +0 -1
- package/dist/constants/index.mjs +0 -12
- package/dist/constants/index.mjs.map +0 -1
- package/dist/constants/myxConfig.cjs +0 -229
- package/dist/constants/myxConfig.cjs.map +0 -1
- package/dist/constants/myxConfig.d.cts +0 -106
- package/dist/constants/myxConfig.d.cts.map +0 -1
- package/dist/constants/myxConfig.d.mts +0 -106
- package/dist/constants/myxConfig.d.mts.map +0 -1
- package/dist/constants/myxConfig.mjs +0 -219
- package/dist/constants/myxConfig.mjs.map +0 -1
- package/dist/constants/orderTypes.cjs +0 -31
- package/dist/constants/orderTypes.cjs.map +0 -1
- package/dist/constants/orderTypes.d.cts +0 -19
- package/dist/constants/orderTypes.d.cts.map +0 -1
- package/dist/constants/orderTypes.d.mts +0 -19
- package/dist/constants/orderTypes.d.mts.map +0 -1
- package/dist/constants/orderTypes.mjs +0 -27
- package/dist/constants/orderTypes.mjs.map +0 -1
- package/dist/constants/performanceMetrics.cjs +0 -63
- package/dist/constants/performanceMetrics.cjs.map +0 -1
- package/dist/constants/performanceMetrics.d.cts +0 -46
- package/dist/constants/performanceMetrics.d.cts.map +0 -1
- package/dist/constants/performanceMetrics.d.mts +0 -46
- package/dist/constants/performanceMetrics.d.mts.map +0 -1
- package/dist/constants/performanceMetrics.mjs +0 -60
- package/dist/constants/performanceMetrics.mjs.map +0 -1
- package/dist/constants/perpsConfig.cjs +0 -295
- package/dist/constants/perpsConfig.cjs.map +0 -1
- package/dist/constants/perpsConfig.d.cts +0 -221
- package/dist/constants/perpsConfig.d.cts.map +0 -1
- package/dist/constants/perpsConfig.d.mts +0 -221
- package/dist/constants/perpsConfig.d.mts.map +0 -1
- package/dist/constants/perpsConfig.mjs +0 -292
- package/dist/constants/perpsConfig.mjs.map +0 -1
- package/dist/constants/transactionsHistoryConfig.cjs +0 -19
- package/dist/constants/transactionsHistoryConfig.cjs.map +0 -1
- package/dist/constants/transactionsHistoryConfig.d.cts +0 -16
- package/dist/constants/transactionsHistoryConfig.d.cts.map +0 -1
- package/dist/constants/transactionsHistoryConfig.d.mts +0 -16
- package/dist/constants/transactionsHistoryConfig.d.mts.map +0 -1
- package/dist/constants/transactionsHistoryConfig.mjs +0 -16
- package/dist/constants/transactionsHistoryConfig.mjs.map +0 -1
- package/dist/perpsErrorCodes.cjs +0 -80
- package/dist/perpsErrorCodes.cjs.map +0 -1
- package/dist/perpsErrorCodes.d.cts +0 -65
- package/dist/perpsErrorCodes.d.cts.map +0 -1
- package/dist/perpsErrorCodes.d.mts +0 -65
- package/dist/perpsErrorCodes.d.mts.map +0 -1
- package/dist/perpsErrorCodes.mjs +0 -77
- package/dist/perpsErrorCodes.mjs.map +0 -1
- package/dist/providers/AggregatedPerpsProvider.cjs +0 -508
- package/dist/providers/AggregatedPerpsProvider.cjs.map +0 -1
- package/dist/providers/AggregatedPerpsProvider.d.cts +0 -171
- package/dist/providers/AggregatedPerpsProvider.d.cts.map +0 -1
- package/dist/providers/AggregatedPerpsProvider.d.mts +0 -171
- package/dist/providers/AggregatedPerpsProvider.d.mts.map +0 -1
- package/dist/providers/AggregatedPerpsProvider.mjs +0 -504
- package/dist/providers/AggregatedPerpsProvider.mjs.map +0 -1
- package/dist/providers/HyperLiquidProvider.cjs +0 -5679
- package/dist/providers/HyperLiquidProvider.cjs.map +0 -1
- package/dist/providers/HyperLiquidProvider.d.cts +0 -516
- package/dist/providers/HyperLiquidProvider.d.cts.map +0 -1
- package/dist/providers/HyperLiquidProvider.d.mts +0 -516
- package/dist/providers/HyperLiquidProvider.d.mts.map +0 -1
- package/dist/providers/HyperLiquidProvider.mjs +0 -5675
- package/dist/providers/HyperLiquidProvider.mjs.map +0 -1
- package/dist/providers/MYXProvider.cjs +0 -514
- package/dist/providers/MYXProvider.cjs.map +0 -1
- package/dist/providers/MYXProvider.d.cts +0 -105
- package/dist/providers/MYXProvider.d.cts.map +0 -1
- package/dist/providers/MYXProvider.d.mts +0 -105
- package/dist/providers/MYXProvider.d.mts.map +0 -1
- package/dist/providers/MYXProvider.mjs +0 -510
- package/dist/providers/MYXProvider.mjs.map +0 -1
- package/dist/routing/ProviderRouter.cjs +0 -154
- package/dist/routing/ProviderRouter.cjs.map +0 -1
- package/dist/routing/ProviderRouter.d.cts +0 -112
- package/dist/routing/ProviderRouter.d.cts.map +0 -1
- package/dist/routing/ProviderRouter.d.mts +0 -112
- package/dist/routing/ProviderRouter.d.mts.map +0 -1
- package/dist/routing/ProviderRouter.mjs +0 -150
- package/dist/routing/ProviderRouter.mjs.map +0 -1
- package/dist/routing/index.cjs +0 -9
- package/dist/routing/index.cjs.map +0 -1
- package/dist/routing/index.d.cts +0 -6
- package/dist/routing/index.d.cts.map +0 -1
- package/dist/routing/index.d.mts +0 -6
- package/dist/routing/index.d.mts.map +0 -1
- package/dist/routing/index.mjs +0 -5
- package/dist/routing/index.mjs.map +0 -1
- package/dist/selectors.cjs +0 -166
- package/dist/selectors.cjs.map +0 -1
- package/dist/selectors.d.cts +0 -362
- package/dist/selectors.d.cts.map +0 -1
- package/dist/selectors.d.mts +0 -362
- package/dist/selectors.d.mts.map +0 -1
- package/dist/selectors.mjs +0 -158
- package/dist/selectors.mjs.map +0 -1
- package/dist/services/AccountService.cjs +0 -324
- package/dist/services/AccountService.cjs.map +0 -1
- package/dist/services/AccountService.d.cts +0 -56
- package/dist/services/AccountService.d.cts.map +0 -1
- package/dist/services/AccountService.d.mts +0 -56
- package/dist/services/AccountService.d.mts.map +0 -1
- package/dist/services/AccountService.mjs +0 -320
- package/dist/services/AccountService.mjs.map +0 -1
- package/dist/services/DataLakeService.cjs +0 -233
- package/dist/services/DataLakeService.cjs.map +0 -1
- package/dist/services/DataLakeService.d.cts +0 -51
- package/dist/services/DataLakeService.d.cts.map +0 -1
- package/dist/services/DataLakeService.d.mts +0 -51
- package/dist/services/DataLakeService.d.mts.map +0 -1
- package/dist/services/DataLakeService.mjs +0 -229
- package/dist/services/DataLakeService.mjs.map +0 -1
- package/dist/services/DepositService.cjs +0 -98
- package/dist/services/DepositService.cjs.map +0 -1
- package/dist/services/DepositService.d.cts +0 -39
- package/dist/services/DepositService.d.cts.map +0 -1
- package/dist/services/DepositService.d.mts +0 -39
- package/dist/services/DepositService.d.mts.map +0 -1
- package/dist/services/DepositService.mjs +0 -94
- package/dist/services/DepositService.mjs.map +0 -1
- package/dist/services/EligibilityService.cjs +0 -173
- package/dist/services/EligibilityService.cjs.map +0 -1
- package/dist/services/EligibilityService.d.cts +0 -39
- package/dist/services/EligibilityService.d.cts.map +0 -1
- package/dist/services/EligibilityService.d.mts +0 -39
- package/dist/services/EligibilityService.d.mts.map +0 -1
- package/dist/services/EligibilityService.mjs +0 -169
- package/dist/services/EligibilityService.mjs.map +0 -1
- package/dist/services/FeatureFlagConfigurationService.cjs +0 -257
- package/dist/services/FeatureFlagConfigurationService.cjs.map +0 -1
- package/dist/services/FeatureFlagConfigurationService.d.cts +0 -73
- package/dist/services/FeatureFlagConfigurationService.d.cts.map +0 -1
- package/dist/services/FeatureFlagConfigurationService.d.mts +0 -73
- package/dist/services/FeatureFlagConfigurationService.d.mts.map +0 -1
- package/dist/services/FeatureFlagConfigurationService.mjs +0 -253
- package/dist/services/FeatureFlagConfigurationService.mjs.map +0 -1
- package/dist/services/HyperLiquidClientService.cjs +0 -867
- package/dist/services/HyperLiquidClientService.cjs.map +0 -1
- package/dist/services/HyperLiquidClientService.d.cts +0 -214
- package/dist/services/HyperLiquidClientService.d.cts.map +0 -1
- package/dist/services/HyperLiquidClientService.d.mts +0 -214
- package/dist/services/HyperLiquidClientService.d.mts.map +0 -1
- package/dist/services/HyperLiquidClientService.mjs +0 -862
- package/dist/services/HyperLiquidClientService.mjs.map +0 -1
- package/dist/services/HyperLiquidSubscriptionService.cjs +0 -2199
- package/dist/services/HyperLiquidSubscriptionService.cjs.map +0 -1
- package/dist/services/HyperLiquidSubscriptionService.d.cts +0 -187
- package/dist/services/HyperLiquidSubscriptionService.d.cts.map +0 -1
- package/dist/services/HyperLiquidSubscriptionService.d.mts +0 -187
- package/dist/services/HyperLiquidSubscriptionService.d.mts.map +0 -1
- package/dist/services/HyperLiquidSubscriptionService.mjs +0 -2195
- package/dist/services/HyperLiquidSubscriptionService.mjs.map +0 -1
- package/dist/services/HyperLiquidWalletService.cjs +0 -163
- package/dist/services/HyperLiquidWalletService.cjs.map +0 -1
- package/dist/services/HyperLiquidWalletService.d.cts +0 -78
- package/dist/services/HyperLiquidWalletService.d.cts.map +0 -1
- package/dist/services/HyperLiquidWalletService.d.mts +0 -78
- package/dist/services/HyperLiquidWalletService.d.mts.map +0 -1
- package/dist/services/HyperLiquidWalletService.mjs +0 -159
- package/dist/services/HyperLiquidWalletService.mjs.map +0 -1
- package/dist/services/MYXClientService.cjs +0 -304
- package/dist/services/MYXClientService.cjs.map +0 -1
- package/dist/services/MYXClientService.d.cts +0 -81
- package/dist/services/MYXClientService.d.cts.map +0 -1
- package/dist/services/MYXClientService.d.mts +0 -81
- package/dist/services/MYXClientService.d.mts.map +0 -1
- package/dist/services/MYXClientService.mjs +0 -300
- package/dist/services/MYXClientService.mjs.map +0 -1
- package/dist/services/MarketDataService.cjs +0 -848
- package/dist/services/MarketDataService.cjs.map +0 -1
- package/dist/services/MarketDataService.d.cts +0 -291
- package/dist/services/MarketDataService.d.cts.map +0 -1
- package/dist/services/MarketDataService.d.mts +0 -291
- package/dist/services/MarketDataService.d.mts.map +0 -1
- package/dist/services/MarketDataService.mjs +0 -844
- package/dist/services/MarketDataService.mjs.map +0 -1
- package/dist/services/RewardsIntegrationService.cjs +0 -120
- package/dist/services/RewardsIntegrationService.cjs.map +0 -1
- package/dist/services/RewardsIntegrationService.d.cts +0 -28
- package/dist/services/RewardsIntegrationService.d.cts.map +0 -1
- package/dist/services/RewardsIntegrationService.d.mts +0 -28
- package/dist/services/RewardsIntegrationService.d.mts.map +0 -1
- package/dist/services/RewardsIntegrationService.mjs +0 -116
- package/dist/services/RewardsIntegrationService.mjs.map +0 -1
- package/dist/services/ServiceContext.cjs +0 -3
- package/dist/services/ServiceContext.cjs.map +0 -1
- package/dist/services/ServiceContext.d.cts +0 -86
- package/dist/services/ServiceContext.d.cts.map +0 -1
- package/dist/services/ServiceContext.d.mts +0 -86
- package/dist/services/ServiceContext.d.mts.map +0 -1
- package/dist/services/ServiceContext.mjs +0 -2
- package/dist/services/ServiceContext.mjs.map +0 -1
- package/dist/services/TradingReadinessCache.cjs +0 -288
- package/dist/services/TradingReadinessCache.cjs.map +0 -1
- package/dist/services/TradingReadinessCache.d.cts +0 -174
- package/dist/services/TradingReadinessCache.d.cts.map +0 -1
- package/dist/services/TradingReadinessCache.d.mts +0 -174
- package/dist/services/TradingReadinessCache.d.mts.map +0 -1
- package/dist/services/TradingReadinessCache.mjs +0 -285
- package/dist/services/TradingReadinessCache.mjs.map +0 -1
- package/dist/services/TradingService.cjs +0 -1457
- package/dist/services/TradingService.cjs.map +0 -1
- package/dist/services/TradingService.d.cts +0 -195
- package/dist/services/TradingService.d.cts.map +0 -1
- package/dist/services/TradingService.d.mts +0 -195
- package/dist/services/TradingService.d.mts.map +0 -1
- package/dist/services/TradingService.mjs +0 -1453
- package/dist/services/TradingService.mjs.map +0 -1
- package/dist/types/config.cjs +0 -3
- package/dist/types/config.cjs.map +0 -1
- package/dist/types/config.d.cts +0 -49
- package/dist/types/config.d.cts.map +0 -1
- package/dist/types/config.d.mts +0 -49
- package/dist/types/config.d.mts.map +0 -1
- package/dist/types/config.mjs +0 -2
- package/dist/types/config.mjs.map +0 -1
- package/dist/types/hyperliquid-types.cjs +0 -3
- package/dist/types/hyperliquid-types.cjs.map +0 -1
- package/dist/types/hyperliquid-types.d.cts +0 -20
- package/dist/types/hyperliquid-types.d.cts.map +0 -1
- package/dist/types/hyperliquid-types.d.mts +0 -20
- package/dist/types/hyperliquid-types.d.mts.map +0 -1
- package/dist/types/hyperliquid-types.mjs +0 -2
- package/dist/types/hyperliquid-types.mjs.map +0 -1
- package/dist/types/index.cjs +0 -115
- package/dist/types/index.cjs.map +0 -1
- package/dist/types/index.d.cts +0 -1262
- package/dist/types/index.d.cts.map +0 -1
- package/dist/types/index.d.mts +0 -1262
- package/dist/types/index.d.mts.map +0 -1
- package/dist/types/index.mjs +0 -97
- package/dist/types/index.mjs.map +0 -1
- package/dist/types/messenger.cjs +0 -3
- package/dist/types/messenger.cjs.map +0 -1
- package/dist/types/messenger.d.cts +0 -27
- package/dist/types/messenger.d.cts.map +0 -1
- package/dist/types/messenger.d.mts +0 -27
- package/dist/types/messenger.d.mts.map +0 -1
- package/dist/types/messenger.mjs +0 -2
- package/dist/types/messenger.mjs.map +0 -1
- package/dist/types/myx-types.cjs +0 -25
- package/dist/types/myx-types.cjs.map +0 -1
- package/dist/types/myx-types.d.cts +0 -63
- package/dist/types/myx-types.d.cts.map +0 -1
- package/dist/types/myx-types.d.mts +0 -63
- package/dist/types/myx-types.d.mts.map +0 -1
- package/dist/types/myx-types.mjs +0 -22
- package/dist/types/myx-types.mjs.map +0 -1
- package/dist/types/perps-types.cjs +0 -4
- package/dist/types/perps-types.cjs.map +0 -1
- package/dist/types/perps-types.d.cts +0 -105
- package/dist/types/perps-types.d.cts.map +0 -1
- package/dist/types/perps-types.d.mts +0 -105
- package/dist/types/perps-types.d.mts.map +0 -1
- package/dist/types/perps-types.mjs +0 -2
- package/dist/types/perps-types.mjs.map +0 -1
- package/dist/types/token.cjs +0 -3
- package/dist/types/token.cjs.map +0 -1
- package/dist/types/token.d.cts +0 -25
- package/dist/types/token.d.cts.map +0 -1
- package/dist/types/token.d.mts +0 -25
- package/dist/types/token.d.mts.map +0 -1
- package/dist/types/token.mjs +0 -2
- package/dist/types/token.mjs.map +0 -1
- package/dist/types/transactionTypes.cjs +0 -28
- package/dist/types/transactionTypes.cjs.map +0 -1
- package/dist/types/transactionTypes.d.cts +0 -64
- package/dist/types/transactionTypes.d.cts.map +0 -1
- package/dist/types/transactionTypes.d.mts +0 -64
- package/dist/types/transactionTypes.d.mts.map +0 -1
- package/dist/types/transactionTypes.mjs +0 -23
- package/dist/types/transactionTypes.mjs.map +0 -1
- package/dist/utils/accountUtils.cjs +0 -100
- package/dist/utils/accountUtils.cjs.map +0 -1
- package/dist/utils/accountUtils.d.cts +0 -30
- package/dist/utils/accountUtils.d.cts.map +0 -1
- package/dist/utils/accountUtils.d.mts +0 -30
- package/dist/utils/accountUtils.d.mts.map +0 -1
- package/dist/utils/accountUtils.mjs +0 -92
- package/dist/utils/accountUtils.mjs.map +0 -1
- package/dist/utils/errorUtils.cjs +0 -35
- package/dist/utils/errorUtils.cjs.map +0 -1
- package/dist/utils/errorUtils.d.cts +0 -15
- package/dist/utils/errorUtils.d.cts.map +0 -1
- package/dist/utils/errorUtils.d.mts +0 -15
- package/dist/utils/errorUtils.d.mts.map +0 -1
- package/dist/utils/errorUtils.mjs +0 -31
- package/dist/utils/errorUtils.mjs.map +0 -1
- package/dist/utils/hyperLiquidAdapter.cjs +0 -331
- package/dist/utils/hyperLiquidAdapter.cjs.map +0 -1
- package/dist/utils/hyperLiquidAdapter.d.cts +0 -42
- package/dist/utils/hyperLiquidAdapter.d.cts.map +0 -1
- package/dist/utils/hyperLiquidAdapter.d.mts +0 -42
- package/dist/utils/hyperLiquidAdapter.d.mts.map +0 -1
- package/dist/utils/hyperLiquidAdapter.mjs +0 -316
- package/dist/utils/hyperLiquidAdapter.mjs.map +0 -1
- package/dist/utils/hyperLiquidOrderBookProcessor.cjs +0 -83
- package/dist/utils/hyperLiquidOrderBookProcessor.cjs.map +0 -1
- package/dist/utils/hyperLiquidOrderBookProcessor.d.cts +0 -55
- package/dist/utils/hyperLiquidOrderBookProcessor.d.cts.map +0 -1
- package/dist/utils/hyperLiquidOrderBookProcessor.d.mts +0 -55
- package/dist/utils/hyperLiquidOrderBookProcessor.d.mts.map +0 -1
- package/dist/utils/hyperLiquidOrderBookProcessor.mjs +0 -78
- package/dist/utils/hyperLiquidOrderBookProcessor.mjs.map +0 -1
- package/dist/utils/hyperLiquidValidation.cjs +0 -426
- package/dist/utils/hyperLiquidValidation.cjs.map +0 -1
- package/dist/utils/hyperLiquidValidation.d.cts +0 -143
- package/dist/utils/hyperLiquidValidation.d.cts.map +0 -1
- package/dist/utils/hyperLiquidValidation.d.mts +0 -143
- package/dist/utils/hyperLiquidValidation.d.mts.map +0 -1
- package/dist/utils/hyperLiquidValidation.mjs +0 -413
- package/dist/utils/hyperLiquidValidation.mjs.map +0 -1
- package/dist/utils/idUtils.cjs +0 -18
- package/dist/utils/idUtils.cjs.map +0 -1
- package/dist/utils/idUtils.d.cts +0 -6
- package/dist/utils/idUtils.d.cts.map +0 -1
- package/dist/utils/idUtils.d.mts +0 -6
- package/dist/utils/idUtils.d.mts.map +0 -1
- package/dist/utils/idUtils.mjs +0 -10
- package/dist/utils/idUtils.mjs.map +0 -1
- package/dist/utils/index.cjs +0 -59
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.d.cts +0 -25
- package/dist/utils/index.d.cts.map +0 -1
- package/dist/utils/index.d.mts +0 -25
- package/dist/utils/index.d.mts.map +0 -1
- package/dist/utils/index.mjs +0 -30
- package/dist/utils/index.mjs.map +0 -1
- package/dist/utils/marketDataTransform.cjs +0 -211
- package/dist/utils/marketDataTransform.cjs.map +0 -1
- package/dist/utils/marketDataTransform.d.cts +0 -40
- package/dist/utils/marketDataTransform.d.cts.map +0 -1
- package/dist/utils/marketDataTransform.d.mts +0 -40
- package/dist/utils/marketDataTransform.d.mts.map +0 -1
- package/dist/utils/marketDataTransform.mjs +0 -205
- package/dist/utils/marketDataTransform.mjs.map +0 -1
- package/dist/utils/marketUtils.cjs +0 -151
- package/dist/utils/marketUtils.cjs.map +0 -1
- package/dist/utils/marketUtils.d.cts +0 -30
- package/dist/utils/marketUtils.d.cts.map +0 -1
- package/dist/utils/marketUtils.d.mts +0 -30
- package/dist/utils/marketUtils.d.mts.map +0 -1
- package/dist/utils/marketUtils.mjs +0 -138
- package/dist/utils/marketUtils.mjs.map +0 -1
- package/dist/utils/myxAdapter.cjs +0 -224
- package/dist/utils/myxAdapter.cjs.map +0 -1
- package/dist/utils/myxAdapter.d.cts +0 -81
- package/dist/utils/myxAdapter.d.cts.map +0 -1
- package/dist/utils/myxAdapter.d.mts +0 -81
- package/dist/utils/myxAdapter.d.mts.map +0 -1
- package/dist/utils/myxAdapter.mjs +0 -213
- package/dist/utils/myxAdapter.mjs.map +0 -1
- package/dist/utils/orderCalculations.cjs +0 -283
- package/dist/utils/orderCalculations.cjs.map +0 -1
- package/dist/utils/orderCalculations.d.cts +0 -107
- package/dist/utils/orderCalculations.d.cts.map +0 -1
- package/dist/utils/orderCalculations.d.mts +0 -107
- package/dist/utils/orderCalculations.d.mts.map +0 -1
- package/dist/utils/orderCalculations.mjs +0 -274
- package/dist/utils/orderCalculations.mjs.map +0 -1
- package/dist/utils/rewardsUtils.cjs +0 -98
- package/dist/utils/rewardsUtils.cjs.map +0 -1
- package/dist/utils/rewardsUtils.d.cts +0 -33
- package/dist/utils/rewardsUtils.d.cts.map +0 -1
- package/dist/utils/rewardsUtils.d.mts +0 -33
- package/dist/utils/rewardsUtils.d.mts.map +0 -1
- package/dist/utils/rewardsUtils.mjs +0 -92
- package/dist/utils/rewardsUtils.mjs.map +0 -1
- package/dist/utils/significantFigures.cjs +0 -88
- package/dist/utils/significantFigures.cjs.map +0 -1
- package/dist/utils/significantFigures.d.cts +0 -25
- package/dist/utils/significantFigures.d.cts.map +0 -1
- package/dist/utils/significantFigures.d.mts +0 -25
- package/dist/utils/significantFigures.d.mts.map +0 -1
- package/dist/utils/significantFigures.mjs +0 -82
- package/dist/utils/significantFigures.mjs.map +0 -1
- package/dist/utils/sortMarkets.cjs +0 -93
- package/dist/utils/sortMarkets.cjs.map +0 -1
- package/dist/utils/sortMarkets.d.cts +0 -27
- package/dist/utils/sortMarkets.d.cts.map +0 -1
- package/dist/utils/sortMarkets.d.mts +0 -27
- package/dist/utils/sortMarkets.d.mts.map +0 -1
- package/dist/utils/sortMarkets.mjs +0 -88
- package/dist/utils/sortMarkets.mjs.map +0 -1
- package/dist/utils/standaloneInfoClient.cjs +0 -70
- package/dist/utils/standaloneInfoClient.cjs.map +0 -1
- package/dist/utils/standaloneInfoClient.d.cts +0 -37
- package/dist/utils/standaloneInfoClient.d.cts.map +0 -1
- package/dist/utils/standaloneInfoClient.d.mts +0 -37
- package/dist/utils/standaloneInfoClient.d.mts.map +0 -1
- package/dist/utils/standaloneInfoClient.mjs +0 -64
- package/dist/utils/standaloneInfoClient.mjs.map +0 -1
- package/dist/utils/stringParseUtils.cjs +0 -18
- package/dist/utils/stringParseUtils.cjs.map +0 -1
- package/dist/utils/stringParseUtils.d.cts +0 -3
- package/dist/utils/stringParseUtils.d.cts.map +0 -1
- package/dist/utils/stringParseUtils.d.mts +0 -3
- package/dist/utils/stringParseUtils.d.mts.map +0 -1
- package/dist/utils/stringParseUtils.mjs +0 -13
- package/dist/utils/stringParseUtils.mjs.map +0 -1
- package/dist/utils/transferData.cjs +0 -33
- package/dist/utils/transferData.cjs.map +0 -1
- package/dist/utils/transferData.d.cts +0 -9
- package/dist/utils/transferData.d.cts.map +0 -1
- package/dist/utils/transferData.d.mts +0 -9
- package/dist/utils/transferData.d.mts.map +0 -1
- package/dist/utils/transferData.mjs +0 -29
- package/dist/utils/transferData.mjs.map +0 -1
- package/dist/utils/wait.cjs +0 -6
- package/dist/utils/wait.cjs.map +0 -1
- package/dist/utils/wait.d.cts +0 -2
- package/dist/utils/wait.d.cts.map +0 -1
- package/dist/utils/wait.d.mts +0 -2
- package/dist/utils/wait.d.mts.map +0 -1
- package/dist/utils/wait.mjs +0 -2
- package/dist/utils/wait.mjs.map +0 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAQA,yDAG2B;AAFzB,kHAAA,eAAe,OAAA;AACf,iIAAA,8BAA8B,OAAA","sourcesContent":["export type {\n PerpsControllerState,\n PerpsControllerGetStateAction,\n PerpsControllerActions,\n PerpsControllerStateChangeEvent,\n PerpsControllerEvents,\n PerpsControllerMessenger,\n} from './PerpsController';\nexport {\n PerpsController,\n getDefaultPerpsControllerState,\n} from './PerpsController';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,39 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* This module provides a unified interface for perpetual futures trading
|
|
5
|
-
* across multiple protocols with high-performance real-time data handling.
|
|
6
|
-
*
|
|
7
|
-
* Key Features:
|
|
8
|
-
* - Protocol abstraction (HyperLiquid first, extensible to GMX, dYdX, etc.)
|
|
9
|
-
* - Dual data flow: Redux for persistence, direct callbacks for live data
|
|
10
|
-
* - MetaMask native integration with BaseController pattern
|
|
11
|
-
* - Mobile-optimized with throttling and performance considerations
|
|
12
|
-
*
|
|
13
|
-
* Usage:
|
|
14
|
-
* ```typescript
|
|
15
|
-
* import { usePerpsController } from './controllers';
|
|
16
|
-
*
|
|
17
|
-
* const { placeOrder, getPositions } = usePerpsController();
|
|
18
|
-
* // Live prices hooks removed with Live Market Prices component
|
|
19
|
-
*
|
|
20
|
-
* // Place a market order
|
|
21
|
-
* await placeOrder({
|
|
22
|
-
* coin: 'ETH',
|
|
23
|
-
* is_buy: true,
|
|
24
|
-
* sz: '0.1',
|
|
25
|
-
* order_type: 'market'
|
|
26
|
-
* });
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export { PerpsController, getDefaultPerpsControllerState, InitializationState, } from "./PerpsController.cjs";
|
|
30
|
-
export type { PerpsControllerState, PerpsControllerOptions, PerpsControllerMessenger, PerpsControllerActions, PerpsControllerEvents, } from "./PerpsController.cjs";
|
|
31
|
-
export { HyperLiquidProvider } from "./providers/HyperLiquidProvider.cjs";
|
|
32
|
-
export * from "./types/index.cjs";
|
|
33
|
-
export * from "./constants/index.cjs";
|
|
34
|
-
export * from "./utils/index.cjs";
|
|
35
|
-
export * from "./perpsErrorCodes.cjs";
|
|
36
|
-
export * from "./selectors.cjs";
|
|
37
|
-
export { TradingReadinessCache } from "./services/TradingReadinessCache.cjs";
|
|
38
|
-
export type { ServiceContext } from "./services/ServiceContext.cjs";
|
|
1
|
+
export type { PerpsControllerState, PerpsControllerGetStateAction, PerpsControllerActions, PerpsControllerStateChangeEvent, PerpsControllerEvents, PerpsControllerMessenger, } from "./PerpsController.cjs";
|
|
2
|
+
export { PerpsController, getDefaultPerpsControllerState, } from "./PerpsController.cjs";
|
|
39
3
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,oBAAoB,EACpB,6BAA6B,EAC7B,sBAAsB,EACtB,+BAA+B,EAC/B,qBAAqB,EACrB,wBAAwB,GACzB,8BAA0B;AAC3B,OAAO,EACL,eAAe,EACf,8BAA8B,GAC/B,8BAA0B"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,39 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* This module provides a unified interface for perpetual futures trading
|
|
5
|
-
* across multiple protocols with high-performance real-time data handling.
|
|
6
|
-
*
|
|
7
|
-
* Key Features:
|
|
8
|
-
* - Protocol abstraction (HyperLiquid first, extensible to GMX, dYdX, etc.)
|
|
9
|
-
* - Dual data flow: Redux for persistence, direct callbacks for live data
|
|
10
|
-
* - MetaMask native integration with BaseController pattern
|
|
11
|
-
* - Mobile-optimized with throttling and performance considerations
|
|
12
|
-
*
|
|
13
|
-
* Usage:
|
|
14
|
-
* ```typescript
|
|
15
|
-
* import { usePerpsController } from './controllers';
|
|
16
|
-
*
|
|
17
|
-
* const { placeOrder, getPositions } = usePerpsController();
|
|
18
|
-
* // Live prices hooks removed with Live Market Prices component
|
|
19
|
-
*
|
|
20
|
-
* // Place a market order
|
|
21
|
-
* await placeOrder({
|
|
22
|
-
* coin: 'ETH',
|
|
23
|
-
* is_buy: true,
|
|
24
|
-
* sz: '0.1',
|
|
25
|
-
* order_type: 'market'
|
|
26
|
-
* });
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export { PerpsController, getDefaultPerpsControllerState, InitializationState, } from "./PerpsController.mjs";
|
|
30
|
-
export type { PerpsControllerState, PerpsControllerOptions, PerpsControllerMessenger, PerpsControllerActions, PerpsControllerEvents, } from "./PerpsController.mjs";
|
|
31
|
-
export { HyperLiquidProvider } from "./providers/HyperLiquidProvider.mjs";
|
|
32
|
-
export * from "./types/index.mjs";
|
|
33
|
-
export * from "./constants/index.mjs";
|
|
34
|
-
export * from "./utils/index.mjs";
|
|
35
|
-
export * from "./perpsErrorCodes.mjs";
|
|
36
|
-
export * from "./selectors.mjs";
|
|
37
|
-
export { TradingReadinessCache } from "./services/TradingReadinessCache.mjs";
|
|
38
|
-
export type { ServiceContext } from "./services/ServiceContext.mjs";
|
|
1
|
+
export type { PerpsControllerState, PerpsControllerGetStateAction, PerpsControllerActions, PerpsControllerStateChangeEvent, PerpsControllerEvents, PerpsControllerMessenger, } from "./PerpsController.mjs";
|
|
2
|
+
export { PerpsController, getDefaultPerpsControllerState, } from "./PerpsController.mjs";
|
|
39
3
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,oBAAoB,EACpB,6BAA6B,EAC7B,sBAAsB,EACtB,+BAA+B,EAC/B,qBAAqB,EACrB,wBAAwB,GACzB,8BAA0B;AAC3B,OAAO,EACL,eAAe,EACf,8BAA8B,GAC/B,8BAA0B"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,47 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* PerpsController - Protocol-agnostic perpetuals trading controller
|
|
3
|
-
*
|
|
4
|
-
* This module provides a unified interface for perpetual futures trading
|
|
5
|
-
* across multiple protocols with high-performance real-time data handling.
|
|
6
|
-
*
|
|
7
|
-
* Key Features:
|
|
8
|
-
* - Protocol abstraction (HyperLiquid first, extensible to GMX, dYdX, etc.)
|
|
9
|
-
* - Dual data flow: Redux for persistence, direct callbacks for live data
|
|
10
|
-
* - MetaMask native integration with BaseController pattern
|
|
11
|
-
* - Mobile-optimized with throttling and performance considerations
|
|
12
|
-
*
|
|
13
|
-
* Usage:
|
|
14
|
-
* ```typescript
|
|
15
|
-
* import { usePerpsController } from './controllers';
|
|
16
|
-
*
|
|
17
|
-
* const { placeOrder, getPositions } = usePerpsController();
|
|
18
|
-
* // Live prices hooks removed with Live Market Prices component
|
|
19
|
-
*
|
|
20
|
-
* // Place a market order
|
|
21
|
-
* await placeOrder({
|
|
22
|
-
* coin: 'ETH',
|
|
23
|
-
* is_buy: true,
|
|
24
|
-
* sz: '0.1',
|
|
25
|
-
* order_type: 'market'
|
|
26
|
-
* });
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
// Core controller and types
|
|
30
|
-
export { PerpsController, getDefaultPerpsControllerState, InitializationState } from "./PerpsController.mjs";
|
|
31
|
-
// Provider interfaces and implementations
|
|
32
|
-
export { HyperLiquidProvider } from "./providers/HyperLiquidProvider.mjs";
|
|
33
|
-
// All type definitions
|
|
34
|
-
export * from "./types/index.mjs";
|
|
35
|
-
// All constants
|
|
36
|
-
export * from "./constants/index.mjs";
|
|
37
|
-
// All utilities
|
|
38
|
-
export * from "./utils/index.mjs";
|
|
39
|
-
// Error codes
|
|
40
|
-
export * from "./perpsErrorCodes.mjs";
|
|
41
|
-
// Selectors
|
|
42
|
-
export * from "./selectors.mjs";
|
|
43
|
-
// Services (only externally consumed items)
|
|
44
|
-
export { TradingReadinessCache } from "./services/TradingReadinessCache.mjs";
|
|
45
|
-
// Removed with Live Market Prices component:
|
|
46
|
-
// - usePerpsPrices
|
|
1
|
+
export { PerpsController, getDefaultPerpsControllerState } from "./PerpsController.mjs";
|
|
47
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,eAAe,EACf,8BAA8B,EAC/B,8BAA0B","sourcesContent":["export type {\n PerpsControllerState,\n PerpsControllerGetStateAction,\n PerpsControllerActions,\n PerpsControllerStateChangeEvent,\n PerpsControllerEvents,\n PerpsControllerMessenger,\n} from './PerpsController';\nexport {\n PerpsController,\n getDefaultPerpsControllerState,\n} from './PerpsController';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/perps-controller",
|
|
3
|
-
"version": "0.0.0-preview-
|
|
3
|
+
"version": "0.0.0-preview-ee1fa5d01",
|
|
4
4
|
"description": "Controller for perpetual trading functionality in MetaMask",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -47,29 +47,15 @@
|
|
|
47
47
|
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@metamask/abi-utils": "^2.0.3",
|
|
51
50
|
"@metamask/base-controller": "^9.0.0",
|
|
52
51
|
"@metamask/controller-utils": "^11.19.0",
|
|
53
52
|
"@metamask/messenger": "^0.3.0",
|
|
54
|
-
"@metamask/utils": "^11.9.0"
|
|
55
|
-
"@myx-trade/sdk": "^0.1.265",
|
|
56
|
-
"@nktkas/hyperliquid": "^0.30.2",
|
|
57
|
-
"bignumber.js": "^9.1.2",
|
|
58
|
-
"reselect": "^5.1.1",
|
|
59
|
-
"uuid": "^8.3.2"
|
|
53
|
+
"@metamask/utils": "^11.9.0"
|
|
60
54
|
},
|
|
61
55
|
"devDependencies": {
|
|
62
|
-
"@metamask/account-tree-controller": "^4.1.1",
|
|
63
56
|
"@metamask/auto-changelog": "^3.4.4",
|
|
64
|
-
"@metamask/keyring-controller": "^25.1.0",
|
|
65
|
-
"@metamask/keyring-internal-api": "^10.0.0",
|
|
66
|
-
"@metamask/network-controller": "^30.0.0",
|
|
67
|
-
"@metamask/profile-sync-controller": "^27.1.0",
|
|
68
|
-
"@metamask/remote-feature-flag-controller": "^4.1.0",
|
|
69
|
-
"@metamask/transaction-controller": "^62.19.0",
|
|
70
57
|
"@ts-bridge/cli": "^0.6.4",
|
|
71
58
|
"@types/jest": "^29.5.14",
|
|
72
|
-
"@types/uuid": "^8.3.0",
|
|
73
59
|
"deepmerge": "^4.2.2",
|
|
74
60
|
"jest": "^29.7.0",
|
|
75
61
|
"ts-jest": "^29.2.5",
|
|
@@ -1,441 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* SubscriptionMultiplexer - Manages WebSocket subscriptions across multiple providers
|
|
4
|
-
*
|
|
5
|
-
* Responsibilities:
|
|
6
|
-
* - Manage subscriptions to multiple providers simultaneously
|
|
7
|
-
* - Tag all updates with providerId so UI can differentiate sources
|
|
8
|
-
* - Support aggregation modes: 'merge' (all prices) or 'best_price' (best price per symbol)
|
|
9
|
-
* - Cache latest updates per provider per symbol for aggregation
|
|
10
|
-
*/
|
|
11
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
-
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");
|
|
15
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
-
};
|
|
17
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
-
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");
|
|
20
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
-
};
|
|
22
|
-
var _SubscriptionMultiplexer_instances, _SubscriptionMultiplexer_logger, _SubscriptionMultiplexer_priceCache, _SubscriptionMultiplexer_positionCache, _SubscriptionMultiplexer_orderCache, _SubscriptionMultiplexer_accountCache, _SubscriptionMultiplexer_aggregatePrices, _SubscriptionMultiplexer_findBestPrice, _SubscriptionMultiplexer_aggregatePositions, _SubscriptionMultiplexer_aggregateOrders;
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.SubscriptionMultiplexer = void 0;
|
|
25
|
-
const perpsConfig_1 = require("../constants/perpsConfig.cjs");
|
|
26
|
-
const errorUtils_1 = require("../utils/errorUtils.cjs");
|
|
27
|
-
/**
|
|
28
|
-
* SubscriptionMultiplexer manages real-time data subscriptions across
|
|
29
|
-
* multiple perps providers.
|
|
30
|
-
*
|
|
31
|
-
* Key features:
|
|
32
|
-
* - Subscribes to all providers simultaneously
|
|
33
|
-
* - Tags all updates with source providerId
|
|
34
|
-
* - Caches latest values for aggregation
|
|
35
|
-
* - Supports different aggregation modes for prices
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```typescript
|
|
39
|
-
* const mux = new SubscriptionMultiplexer();
|
|
40
|
-
*
|
|
41
|
-
* const unsubscribe = mux.subscribeToPrices({
|
|
42
|
-
* symbols: ['BTC', 'ETH'],
|
|
43
|
-
* providers: [
|
|
44
|
-
* ['hyperliquid', hlProvider],
|
|
45
|
-
* ['myx', myxProvider],
|
|
46
|
-
* ],
|
|
47
|
-
* callback: (prices) => {
|
|
48
|
-
* // prices have providerId injected
|
|
49
|
-
* prices.forEach(p => console.log(`${p.providerId}: ${p.symbol} = ${p.price}`));
|
|
50
|
-
* },
|
|
51
|
-
* aggregationMode: 'merge',
|
|
52
|
-
* });
|
|
53
|
-
*
|
|
54
|
-
* // Later: clean up
|
|
55
|
-
* unsubscribe();
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
class SubscriptionMultiplexer {
|
|
59
|
-
/**
|
|
60
|
-
* Create a new SubscriptionMultiplexer.
|
|
61
|
-
*
|
|
62
|
-
* @param options - Optional configuration including logger for error reporting
|
|
63
|
-
*/
|
|
64
|
-
constructor(options) {
|
|
65
|
-
_SubscriptionMultiplexer_instances.add(this);
|
|
66
|
-
/**
|
|
67
|
-
* Optional logger for error reporting
|
|
68
|
-
*/
|
|
69
|
-
_SubscriptionMultiplexer_logger.set(this, void 0);
|
|
70
|
-
/**
|
|
71
|
-
* Cache of latest prices per symbol per provider
|
|
72
|
-
* Map<symbol, Map<providerId, PriceUpdate>>
|
|
73
|
-
*/
|
|
74
|
-
_SubscriptionMultiplexer_priceCache.set(this, new Map());
|
|
75
|
-
/**
|
|
76
|
-
* Cache of latest positions per provider
|
|
77
|
-
* Map<providerId, Position[]>
|
|
78
|
-
*/
|
|
79
|
-
_SubscriptionMultiplexer_positionCache.set(this, new Map());
|
|
80
|
-
/**
|
|
81
|
-
* Cache of latest orders per provider
|
|
82
|
-
* Map<providerId, Order[]>
|
|
83
|
-
*/
|
|
84
|
-
_SubscriptionMultiplexer_orderCache.set(this, new Map());
|
|
85
|
-
/**
|
|
86
|
-
* Cache of latest account state per provider
|
|
87
|
-
* Map<providerId, AccountState>
|
|
88
|
-
*/
|
|
89
|
-
_SubscriptionMultiplexer_accountCache.set(this, new Map());
|
|
90
|
-
__classPrivateFieldSet(this, _SubscriptionMultiplexer_logger, options?.logger, "f");
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Subscribe to price updates from multiple providers.
|
|
94
|
-
*
|
|
95
|
-
* @param params - Subscription parameters
|
|
96
|
-
* @returns Unsubscribe function
|
|
97
|
-
*/
|
|
98
|
-
subscribeToPrices(params) {
|
|
99
|
-
const { symbols, providers, callback, aggregationMode = 'merge', throttleMs, includeOrderBook, includeMarketData, } = params;
|
|
100
|
-
const unsubscribers = [];
|
|
101
|
-
// Subscribe to each provider with defensive error handling
|
|
102
|
-
for (const [providerId, provider] of providers) {
|
|
103
|
-
try {
|
|
104
|
-
const subscribeParams = {
|
|
105
|
-
symbols,
|
|
106
|
-
callback: (updates) => {
|
|
107
|
-
// Tag and cache each update
|
|
108
|
-
updates.forEach((update) => {
|
|
109
|
-
const taggedUpdate = { ...update, providerId };
|
|
110
|
-
// Initialize symbol cache if needed
|
|
111
|
-
if (!__classPrivateFieldGet(this, _SubscriptionMultiplexer_priceCache, "f").has(update.symbol)) {
|
|
112
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_priceCache, "f").set(update.symbol, new Map());
|
|
113
|
-
}
|
|
114
|
-
const symbolCache = __classPrivateFieldGet(this, _SubscriptionMultiplexer_priceCache, "f").get(update.symbol);
|
|
115
|
-
if (symbolCache) {
|
|
116
|
-
symbolCache.set(providerId, taggedUpdate);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
// Aggregate and emit based on mode
|
|
120
|
-
const aggregated = __classPrivateFieldGet(this, _SubscriptionMultiplexer_instances, "m", _SubscriptionMultiplexer_aggregatePrices).call(this, symbols, aggregationMode);
|
|
121
|
-
callback(aggregated);
|
|
122
|
-
},
|
|
123
|
-
throttleMs,
|
|
124
|
-
includeOrderBook,
|
|
125
|
-
includeMarketData,
|
|
126
|
-
};
|
|
127
|
-
const unsub = provider.subscribeToPrices(subscribeParams);
|
|
128
|
-
unsubscribers.push(unsub);
|
|
129
|
-
}
|
|
130
|
-
catch (error) {
|
|
131
|
-
// Log to Sentry before cleanup
|
|
132
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_logger, "f")?.error((0, errorUtils_1.ensureError)(error, 'SubscriptionMultiplexer.subscribeToPrices'), {
|
|
133
|
-
tags: {
|
|
134
|
-
feature: perpsConfig_1.PERPS_CONSTANTS.FeatureName,
|
|
135
|
-
provider: providerId,
|
|
136
|
-
method: 'subscribeToPrices',
|
|
137
|
-
},
|
|
138
|
-
context: {
|
|
139
|
-
name: 'SubscriptionMultiplexer',
|
|
140
|
-
data: { subscribedCount: unsubscribers.length },
|
|
141
|
-
},
|
|
142
|
-
});
|
|
143
|
-
// Clean up any subscriptions created before the failure
|
|
144
|
-
unsubscribers.forEach((unsub) => unsub());
|
|
145
|
-
throw error;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
// Return combined unsubscribe function
|
|
149
|
-
return () => {
|
|
150
|
-
unsubscribers.forEach((unsub) => unsub());
|
|
151
|
-
// Optionally clear cache for these symbols
|
|
152
|
-
symbols.forEach((symbol) => {
|
|
153
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_priceCache, "f").delete(symbol);
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Subscribe to position updates from multiple providers.
|
|
159
|
-
*
|
|
160
|
-
* @param params - Subscription parameters
|
|
161
|
-
* @returns Unsubscribe function
|
|
162
|
-
*/
|
|
163
|
-
subscribeToPositions(params) {
|
|
164
|
-
const { providers, callback } = params;
|
|
165
|
-
const unsubscribers = [];
|
|
166
|
-
for (const [providerId, provider] of providers) {
|
|
167
|
-
try {
|
|
168
|
-
const subscribeParams = {
|
|
169
|
-
callback: (positions) => {
|
|
170
|
-
// Tag positions with providerId and cache
|
|
171
|
-
const taggedPositions = positions.map((pos) => ({
|
|
172
|
-
...pos,
|
|
173
|
-
providerId,
|
|
174
|
-
}));
|
|
175
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_positionCache, "f").set(providerId, taggedPositions);
|
|
176
|
-
// Emit aggregated positions from all providers
|
|
177
|
-
const allPositions = __classPrivateFieldGet(this, _SubscriptionMultiplexer_instances, "m", _SubscriptionMultiplexer_aggregatePositions).call(this);
|
|
178
|
-
callback(allPositions);
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
const unsub = provider.subscribeToPositions(subscribeParams);
|
|
182
|
-
unsubscribers.push(unsub);
|
|
183
|
-
}
|
|
184
|
-
catch (error) {
|
|
185
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_logger, "f")?.error((0, errorUtils_1.ensureError)(error, 'SubscriptionMultiplexer.subscribeToPositions'), {
|
|
186
|
-
tags: {
|
|
187
|
-
feature: perpsConfig_1.PERPS_CONSTANTS.FeatureName,
|
|
188
|
-
provider: providerId,
|
|
189
|
-
method: 'subscribeToPositions',
|
|
190
|
-
},
|
|
191
|
-
context: {
|
|
192
|
-
name: 'SubscriptionMultiplexer',
|
|
193
|
-
data: { subscribedCount: unsubscribers.length },
|
|
194
|
-
},
|
|
195
|
-
});
|
|
196
|
-
unsubscribers.forEach((unsub) => unsub());
|
|
197
|
-
throw error;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return () => {
|
|
201
|
-
unsubscribers.forEach((unsub) => unsub());
|
|
202
|
-
// Clear position cache for these providers
|
|
203
|
-
providers.forEach(([providerId]) => {
|
|
204
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_positionCache, "f").delete(providerId);
|
|
205
|
-
});
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Subscribe to order fill updates from multiple providers.
|
|
210
|
-
*
|
|
211
|
-
* @param params - Subscription parameters
|
|
212
|
-
* @returns Unsubscribe function
|
|
213
|
-
*/
|
|
214
|
-
subscribeToOrderFills(params) {
|
|
215
|
-
const { providers, callback } = params;
|
|
216
|
-
const unsubscribers = [];
|
|
217
|
-
for (const [providerId, provider] of providers) {
|
|
218
|
-
try {
|
|
219
|
-
const subscribeParams = {
|
|
220
|
-
callback: (fills, isSnapshot) => {
|
|
221
|
-
// Tag fills with providerId
|
|
222
|
-
const taggedFills = fills.map((fill) => ({
|
|
223
|
-
...fill,
|
|
224
|
-
providerId,
|
|
225
|
-
}));
|
|
226
|
-
// For fills, we don't aggregate - emit immediately with tags
|
|
227
|
-
callback(taggedFills, isSnapshot);
|
|
228
|
-
},
|
|
229
|
-
};
|
|
230
|
-
const unsub = provider.subscribeToOrderFills(subscribeParams);
|
|
231
|
-
unsubscribers.push(unsub);
|
|
232
|
-
}
|
|
233
|
-
catch (error) {
|
|
234
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_logger, "f")?.error((0, errorUtils_1.ensureError)(error, 'SubscriptionMultiplexer.subscribeToOrderFills'), {
|
|
235
|
-
tags: {
|
|
236
|
-
feature: perpsConfig_1.PERPS_CONSTANTS.FeatureName,
|
|
237
|
-
provider: providerId,
|
|
238
|
-
method: 'subscribeToOrderFills',
|
|
239
|
-
},
|
|
240
|
-
context: {
|
|
241
|
-
name: 'SubscriptionMultiplexer',
|
|
242
|
-
data: { subscribedCount: unsubscribers.length },
|
|
243
|
-
},
|
|
244
|
-
});
|
|
245
|
-
unsubscribers.forEach((unsub) => unsub());
|
|
246
|
-
throw error;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
return () => {
|
|
250
|
-
unsubscribers.forEach((unsub) => unsub());
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Subscribe to order updates from multiple providers.
|
|
255
|
-
*
|
|
256
|
-
* @param params - Subscription parameters
|
|
257
|
-
* @returns Unsubscribe function
|
|
258
|
-
*/
|
|
259
|
-
subscribeToOrders(params) {
|
|
260
|
-
const { providers, callback } = params;
|
|
261
|
-
const unsubscribers = [];
|
|
262
|
-
for (const [providerId, provider] of providers) {
|
|
263
|
-
try {
|
|
264
|
-
const subscribeParams = {
|
|
265
|
-
callback: (orders) => {
|
|
266
|
-
// Tag orders with providerId and cache
|
|
267
|
-
const taggedOrders = orders.map((order) => ({
|
|
268
|
-
...order,
|
|
269
|
-
providerId,
|
|
270
|
-
}));
|
|
271
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_orderCache, "f").set(providerId, taggedOrders);
|
|
272
|
-
// Emit aggregated orders from all providers
|
|
273
|
-
const allOrders = __classPrivateFieldGet(this, _SubscriptionMultiplexer_instances, "m", _SubscriptionMultiplexer_aggregateOrders).call(this);
|
|
274
|
-
callback(allOrders);
|
|
275
|
-
},
|
|
276
|
-
};
|
|
277
|
-
const unsub = provider.subscribeToOrders(subscribeParams);
|
|
278
|
-
unsubscribers.push(unsub);
|
|
279
|
-
}
|
|
280
|
-
catch (error) {
|
|
281
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_logger, "f")?.error((0, errorUtils_1.ensureError)(error, 'SubscriptionMultiplexer.subscribeToOrders'), {
|
|
282
|
-
tags: {
|
|
283
|
-
feature: perpsConfig_1.PERPS_CONSTANTS.FeatureName,
|
|
284
|
-
provider: providerId,
|
|
285
|
-
method: 'subscribeToOrders',
|
|
286
|
-
},
|
|
287
|
-
context: {
|
|
288
|
-
name: 'SubscriptionMultiplexer',
|
|
289
|
-
data: { subscribedCount: unsubscribers.length },
|
|
290
|
-
},
|
|
291
|
-
});
|
|
292
|
-
unsubscribers.forEach((unsub) => unsub());
|
|
293
|
-
throw error;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
return () => {
|
|
297
|
-
unsubscribers.forEach((unsub) => unsub());
|
|
298
|
-
providers.forEach(([providerId]) => {
|
|
299
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_orderCache, "f").delete(providerId);
|
|
300
|
-
});
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Subscribe to account updates from multiple providers.
|
|
305
|
-
*
|
|
306
|
-
* @param params - Subscription parameters
|
|
307
|
-
* @returns Unsubscribe function
|
|
308
|
-
*/
|
|
309
|
-
subscribeToAccount(params) {
|
|
310
|
-
const { providers, callback } = params;
|
|
311
|
-
const unsubscribers = [];
|
|
312
|
-
for (const [providerId, provider] of providers) {
|
|
313
|
-
try {
|
|
314
|
-
const subscribeParams = {
|
|
315
|
-
callback: (account) => {
|
|
316
|
-
if (account === null) {
|
|
317
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_accountCache, "f").delete(providerId);
|
|
318
|
-
}
|
|
319
|
-
else {
|
|
320
|
-
// Tag account with providerId and cache
|
|
321
|
-
const taggedAccount = {
|
|
322
|
-
...account,
|
|
323
|
-
providerId,
|
|
324
|
-
};
|
|
325
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_accountCache, "f").set(providerId, taggedAccount);
|
|
326
|
-
}
|
|
327
|
-
// Emit all cached account states
|
|
328
|
-
const allAccounts = Array.from(__classPrivateFieldGet(this, _SubscriptionMultiplexer_accountCache, "f").values());
|
|
329
|
-
callback(allAccounts);
|
|
330
|
-
},
|
|
331
|
-
};
|
|
332
|
-
const unsub = provider.subscribeToAccount(subscribeParams);
|
|
333
|
-
unsubscribers.push(unsub);
|
|
334
|
-
}
|
|
335
|
-
catch (error) {
|
|
336
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_logger, "f")?.error((0, errorUtils_1.ensureError)(error, 'SubscriptionMultiplexer.subscribeToAccount'), {
|
|
337
|
-
tags: {
|
|
338
|
-
feature: perpsConfig_1.PERPS_CONSTANTS.FeatureName,
|
|
339
|
-
provider: providerId,
|
|
340
|
-
method: 'subscribeToAccount',
|
|
341
|
-
},
|
|
342
|
-
context: {
|
|
343
|
-
name: 'SubscriptionMultiplexer',
|
|
344
|
-
data: { subscribedCount: unsubscribers.length },
|
|
345
|
-
},
|
|
346
|
-
});
|
|
347
|
-
unsubscribers.forEach((unsub) => unsub());
|
|
348
|
-
throw error;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
return () => {
|
|
352
|
-
unsubscribers.forEach((unsub) => unsub());
|
|
353
|
-
providers.forEach(([providerId]) => {
|
|
354
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_accountCache, "f").delete(providerId);
|
|
355
|
-
});
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* Clear all cached data.
|
|
360
|
-
*/
|
|
361
|
-
clearCache() {
|
|
362
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_priceCache, "f").clear();
|
|
363
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_positionCache, "f").clear();
|
|
364
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_orderCache, "f").clear();
|
|
365
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_accountCache, "f").clear();
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* Get cached price for a symbol from a specific provider.
|
|
369
|
-
*
|
|
370
|
-
* @param symbol - Market symbol
|
|
371
|
-
* @param providerId - Provider ID
|
|
372
|
-
* @returns Cached price update or undefined
|
|
373
|
-
*/
|
|
374
|
-
getCachedPrice(symbol, providerId) {
|
|
375
|
-
return __classPrivateFieldGet(this, _SubscriptionMultiplexer_priceCache, "f").get(symbol)?.get(providerId);
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* Get all cached prices for a symbol.
|
|
379
|
-
*
|
|
380
|
-
* @param symbol - Market symbol
|
|
381
|
-
* @returns Map of provider ID to price update
|
|
382
|
-
*/
|
|
383
|
-
getAllCachedPricesForSymbol(symbol) {
|
|
384
|
-
return __classPrivateFieldGet(this, _SubscriptionMultiplexer_priceCache, "f").get(symbol);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
exports.SubscriptionMultiplexer = SubscriptionMultiplexer;
|
|
388
|
-
_SubscriptionMultiplexer_logger = new WeakMap(), _SubscriptionMultiplexer_priceCache = new WeakMap(), _SubscriptionMultiplexer_positionCache = new WeakMap(), _SubscriptionMultiplexer_orderCache = new WeakMap(), _SubscriptionMultiplexer_accountCache = new WeakMap(), _SubscriptionMultiplexer_instances = new WeakSet(), _SubscriptionMultiplexer_aggregatePrices = function _SubscriptionMultiplexer_aggregatePrices(symbols, mode) {
|
|
389
|
-
const result = [];
|
|
390
|
-
symbols.forEach((symbol) => {
|
|
391
|
-
const providerPrices = __classPrivateFieldGet(this, _SubscriptionMultiplexer_priceCache, "f").get(symbol);
|
|
392
|
-
if (!providerPrices || providerPrices.size === 0) {
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
if (mode === 'merge') {
|
|
396
|
-
// Return all prices (one per provider)
|
|
397
|
-
providerPrices.forEach((price) => {
|
|
398
|
-
result.push(price);
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
else {
|
|
402
|
-
// 'best_price': Return the best price across providers
|
|
403
|
-
const best = __classPrivateFieldGet(this, _SubscriptionMultiplexer_instances, "m", _SubscriptionMultiplexer_findBestPrice).call(this, providerPrices);
|
|
404
|
-
if (best) {
|
|
405
|
-
result.push(best);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
return result;
|
|
410
|
-
}, _SubscriptionMultiplexer_findBestPrice = function _SubscriptionMultiplexer_findBestPrice(providerPrices) {
|
|
411
|
-
let bestPrice;
|
|
412
|
-
let smallestSpread = Infinity;
|
|
413
|
-
providerPrices.forEach((price) => {
|
|
414
|
-
if (price.spread === undefined) {
|
|
415
|
-
// No spread info - just use the first one
|
|
416
|
-
bestPrice ?? (bestPrice = price);
|
|
417
|
-
}
|
|
418
|
-
else {
|
|
419
|
-
// If spread is available, use it to determine best
|
|
420
|
-
const spreadValue = parseFloat(price.spread);
|
|
421
|
-
if (!isNaN(spreadValue) && spreadValue < smallestSpread) {
|
|
422
|
-
smallestSpread = spreadValue;
|
|
423
|
-
bestPrice = price;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
return bestPrice;
|
|
428
|
-
}, _SubscriptionMultiplexer_aggregatePositions = function _SubscriptionMultiplexer_aggregatePositions() {
|
|
429
|
-
const allPositions = [];
|
|
430
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_positionCache, "f").forEach((positions) => {
|
|
431
|
-
allPositions.push(...positions);
|
|
432
|
-
});
|
|
433
|
-
return allPositions;
|
|
434
|
-
}, _SubscriptionMultiplexer_aggregateOrders = function _SubscriptionMultiplexer_aggregateOrders() {
|
|
435
|
-
const allOrders = [];
|
|
436
|
-
__classPrivateFieldGet(this, _SubscriptionMultiplexer_orderCache, "f").forEach((orders) => {
|
|
437
|
-
allOrders.push(...orders);
|
|
438
|
-
});
|
|
439
|
-
return allOrders;
|
|
440
|
-
};
|
|
441
|
-
//# sourceMappingURL=SubscriptionMultiplexer.cjs.map
|