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