@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
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import type { AssetCtxsWsEvent } from "@nktkas/hyperliquid";
|
|
2
|
+
import type { HyperLiquidClientService } from "./HyperLiquidClientService.mjs";
|
|
3
|
+
import type { HyperLiquidWalletService } from "./HyperLiquidWalletService.mjs";
|
|
4
|
+
import type { Position, Order, SubscribePricesParams, SubscribePositionsParams, SubscribeOrderFillsParams, SubscribeOrdersParams, SubscribeAccountParams, SubscribeOICapsParams, SubscribeOrderBookParams, PerpsPlatformDependencies } from "../types/index.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* Service for managing HyperLiquid WebSocket subscriptions
|
|
7
|
+
* Implements singleton subscription architecture with reference counting
|
|
8
|
+
*/
|
|
9
|
+
export declare class HyperLiquidSubscriptionService {
|
|
10
|
+
private readonly clientService;
|
|
11
|
+
private readonly walletService;
|
|
12
|
+
private hip3Enabled;
|
|
13
|
+
private enabledDexs;
|
|
14
|
+
private allowlistMarkets;
|
|
15
|
+
private blocklistMarkets;
|
|
16
|
+
private discoveredDexNames;
|
|
17
|
+
private dexDiscoveryPromise;
|
|
18
|
+
private dexDiscoveryResolver;
|
|
19
|
+
private expectedDexs;
|
|
20
|
+
private initializedDexs;
|
|
21
|
+
private readonly priceSubscribers;
|
|
22
|
+
private readonly positionSubscribers;
|
|
23
|
+
private readonly orderFillSubscribers;
|
|
24
|
+
private readonly orderSubscribers;
|
|
25
|
+
private readonly accountSubscribers;
|
|
26
|
+
private readonly marketDataSubscribers;
|
|
27
|
+
private readonly orderBookSubscribers;
|
|
28
|
+
private globalAllMidsSubscription?;
|
|
29
|
+
private globalAllMidsPromise?;
|
|
30
|
+
private readonly globalActiveAssetSubscriptions;
|
|
31
|
+
private readonly globalBboSubscriptions;
|
|
32
|
+
private readonly orderFillSubscriptions;
|
|
33
|
+
private readonly symbolSubscriberCounts;
|
|
34
|
+
private readonly dexSubscriberCounts;
|
|
35
|
+
private readonly webData3Subscriptions;
|
|
36
|
+
private webData3SubscriptionPromise?;
|
|
37
|
+
private positionSubscriberCount;
|
|
38
|
+
private orderSubscriberCount;
|
|
39
|
+
private accountSubscriberCount;
|
|
40
|
+
private oiCapSubscriberCount;
|
|
41
|
+
private readonly dexPositionsCache;
|
|
42
|
+
private readonly dexOrdersCache;
|
|
43
|
+
private readonly dexAccountCache;
|
|
44
|
+
private cachedPositions;
|
|
45
|
+
private cachedOrders;
|
|
46
|
+
private cachedAccount;
|
|
47
|
+
private ordersCacheInitialized;
|
|
48
|
+
private positionsCacheInitialized;
|
|
49
|
+
private readonly oiCapSubscribers;
|
|
50
|
+
private cachedOICaps;
|
|
51
|
+
private cachedOICapsHash;
|
|
52
|
+
private oiCapsCacheInitialized;
|
|
53
|
+
private cachedPriceData;
|
|
54
|
+
private readonly assetCtxsSubscriptions;
|
|
55
|
+
private readonly dexAssetCtxsCache;
|
|
56
|
+
private readonly assetCtxsSubscriptionPromises;
|
|
57
|
+
private readonly clearinghouseStateSubscriptions;
|
|
58
|
+
private readonly openOrdersSubscriptions;
|
|
59
|
+
private readonly dexMetaCache;
|
|
60
|
+
private readonly orderBookCache;
|
|
61
|
+
private readonly marketDataCache;
|
|
62
|
+
private readonly deps;
|
|
63
|
+
private cachedPositionsHash;
|
|
64
|
+
private cachedOrdersHash;
|
|
65
|
+
private cachedAccountHash;
|
|
66
|
+
constructor(clientService: HyperLiquidClientService, walletService: HyperLiquidWalletService, platformDependencies: PerpsPlatformDependencies, hip3Enabled?: boolean, enabledDexs?: string[], allowlistMarkets?: string[], blocklistMarkets?: string[]);
|
|
67
|
+
/**
|
|
68
|
+
* Get error context for logging with searchable tags and context.
|
|
69
|
+
* Enables Sentry dashboard filtering by feature, provider, and network.
|
|
70
|
+
*
|
|
71
|
+
* @param method - The method name where the error occurred
|
|
72
|
+
* @param extra - Optional additional context fields (merged into searchable context.data)
|
|
73
|
+
* @returns Error options with tags (searchable) and context (searchable)
|
|
74
|
+
*/
|
|
75
|
+
private getErrorContext;
|
|
76
|
+
/**
|
|
77
|
+
* Check if a DEX is enabled in our configuration
|
|
78
|
+
* Used to filter webData3 callback data to only process DEXs we care about
|
|
79
|
+
*
|
|
80
|
+
* @param dex - DEX name (null for main DEX, string for HIP-3)
|
|
81
|
+
* @returns true if this DEX should be processed
|
|
82
|
+
*/
|
|
83
|
+
private isDexEnabled;
|
|
84
|
+
/**
|
|
85
|
+
* Populate DEX meta cache with pre-fetched meta data
|
|
86
|
+
* Called by Provider after buildAssetMapping to share cached meta,
|
|
87
|
+
* avoiding redundant metaAndAssetCtxs/meta API calls during subscription setup
|
|
88
|
+
*
|
|
89
|
+
* @param dex - DEX key ('' for main DEX, 'xyz'/'flx'/etc for HIP-3)
|
|
90
|
+
* @param meta - Meta response containing universe data
|
|
91
|
+
* @param meta.universe
|
|
92
|
+
*/
|
|
93
|
+
setDexMetaCache(dex: string, meta: {
|
|
94
|
+
universe: {
|
|
95
|
+
name: string;
|
|
96
|
+
szDecimals: number;
|
|
97
|
+
maxLeverage: number;
|
|
98
|
+
}[];
|
|
99
|
+
}): void;
|
|
100
|
+
/**
|
|
101
|
+
* Cache asset contexts for a specific DEX from API response
|
|
102
|
+
* This allows buildAssetMapping() to populate cache for getMarketDataWithPrices() to use
|
|
103
|
+
*
|
|
104
|
+
* @param dex - DEX name ('' for main perps)
|
|
105
|
+
* @param assetCtxs - Asset contexts from metaAndAssetCtxs response
|
|
106
|
+
*/
|
|
107
|
+
setDexAssetCtxsCache(dex: string, assetCtxs: AssetCtxsWsEvent['ctxs']): void;
|
|
108
|
+
/**
|
|
109
|
+
* Get cached assetCtxs for a DEX
|
|
110
|
+
* Returns the cached asset contexts from WebSocket subscription if available
|
|
111
|
+
*
|
|
112
|
+
* @param dex - DEX key ('' for main DEX, 'xyz'/'flx'/etc for HIP-3)
|
|
113
|
+
* @returns Array of asset contexts or undefined if not cached
|
|
114
|
+
*/
|
|
115
|
+
getDexAssetCtxsCache(dex: string): AssetCtxsWsEvent['ctxs'] | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* Wait for DEX discovery to complete (with timeout)
|
|
118
|
+
* Used when HIP-3 is enabled but enabledDexs hasn't been populated yet.
|
|
119
|
+
* This allows subscriptions to wait for DEX discovery before creating per-DEX subscriptions.
|
|
120
|
+
*
|
|
121
|
+
* @param timeoutMs - Timeout in milliseconds (default: 5000)
|
|
122
|
+
*/
|
|
123
|
+
private waitForDexDiscovery;
|
|
124
|
+
/**
|
|
125
|
+
* Update feature flags for HIP-3 support
|
|
126
|
+
* Called when provider configuration changes at runtime
|
|
127
|
+
* Note: Market filtering is NOT applied in subscription service - only in Provider
|
|
128
|
+
*
|
|
129
|
+
* @param hip3Enabled - Whether HIP-3 is enabled
|
|
130
|
+
* @param enabledDexs - List of enabled DEX identifiers
|
|
131
|
+
* @param allowlistMarkets - List of allowed markets
|
|
132
|
+
* @param blocklistMarkets - List of blocked markets
|
|
133
|
+
*/
|
|
134
|
+
updateFeatureFlags(hip3Enabled: boolean, enabledDexs: string[], allowlistMarkets: string[], blocklistMarkets: string[]): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Fast hash function for change detection
|
|
137
|
+
* Uses string concatenation of key fields instead of JSON.stringify()
|
|
138
|
+
* Performance: ~100x faster than JSON.stringify() for typical objects
|
|
139
|
+
* Tracks structural changes (coin, size, entryPrice, leverage, TP/SL prices/counts)
|
|
140
|
+
* and value changes (unrealizedPnl, returnOnEquity) for live P&L updates
|
|
141
|
+
*
|
|
142
|
+
* @param positions - Positions to hash
|
|
143
|
+
* @returns Hash string
|
|
144
|
+
*/
|
|
145
|
+
private hashPositions;
|
|
146
|
+
/**
|
|
147
|
+
* Fast hash function for orders
|
|
148
|
+
*
|
|
149
|
+
* @param orders - Orders to hash
|
|
150
|
+
* @returns Hash string
|
|
151
|
+
*/
|
|
152
|
+
private hashOrders;
|
|
153
|
+
/**
|
|
154
|
+
* Fast hash function for account state
|
|
155
|
+
*
|
|
156
|
+
* @param account - Account state to hash
|
|
157
|
+
* @returns Hash string
|
|
158
|
+
*/
|
|
159
|
+
private hashAccountState;
|
|
160
|
+
/**
|
|
161
|
+
* Extract TP/SL from orders and optionally convert raw SDK orders to Order format.
|
|
162
|
+
* DRY helper used by both webData2 and clearinghouseState callbacks.
|
|
163
|
+
*
|
|
164
|
+
* @param orders - Raw SDK orders from WebSocket event
|
|
165
|
+
* @param positions - Current positions for TP/SL matching
|
|
166
|
+
* @param cachedProcessedOrders - Optional pre-processed orders (skips conversion if provided)
|
|
167
|
+
* @returns Maps for TP/SL prices and counts, plus processed Order array
|
|
168
|
+
*/
|
|
169
|
+
private extractTPSLFromOrders;
|
|
170
|
+
/**
|
|
171
|
+
* Merge TP/SL data into positions
|
|
172
|
+
* DRY helper used by both webData2 and clearinghouseState callbacks
|
|
173
|
+
*
|
|
174
|
+
* @param positions - Base positions without TP/SL
|
|
175
|
+
* @param tpslMap - Map of coin -> TP/SL prices
|
|
176
|
+
* @param tpslCountMap - Map of coin -> TP/SL counts
|
|
177
|
+
* @returns Positions enhanced with TP/SL data
|
|
178
|
+
*/
|
|
179
|
+
private mergeTPSLIntoPositions;
|
|
180
|
+
/**
|
|
181
|
+
* Aggregate account states from all cached DEXs
|
|
182
|
+
* Sums balances and creates per-DEX breakdown for multi-DEX portfolio view
|
|
183
|
+
*
|
|
184
|
+
* @returns Aggregated account state with dexBreakdown field
|
|
185
|
+
*/
|
|
186
|
+
private aggregateAccountStates;
|
|
187
|
+
/**
|
|
188
|
+
* Subscribe to live price updates with singleton subscription architecture
|
|
189
|
+
* Uses allMids for fast price updates and predictedFundings for accurate funding rates
|
|
190
|
+
*
|
|
191
|
+
* @param params - Subscription parameters
|
|
192
|
+
* @returns Cleanup function
|
|
193
|
+
*/
|
|
194
|
+
subscribeToPrices(params: SubscribePricesParams): Promise<() => void>;
|
|
195
|
+
/**
|
|
196
|
+
* Ensure shared webData3 subscription is active (singleton pattern with multi-DEX support)
|
|
197
|
+
* webData3 provides data for all DEXs (main + HIP-3) in a single subscription
|
|
198
|
+
*
|
|
199
|
+
* @param accountId - Optional account ID
|
|
200
|
+
*/
|
|
201
|
+
private ensureSharedWebData3Subscription;
|
|
202
|
+
/**
|
|
203
|
+
* Create WebSocket subscription for user data (positions, orders, account)
|
|
204
|
+
* - Uses webData2 when HIP-3 disabled (main DEX only)
|
|
205
|
+
* - Uses webData3 when HIP-3 enabled (main + HIP-3 DEXs)
|
|
206
|
+
*
|
|
207
|
+
* webData2 provides data for main DEX only
|
|
208
|
+
* webData3 provides perpDexStates[] array containing data for all DEXs:
|
|
209
|
+
* - Index 0: Main DEX (dexName = '')
|
|
210
|
+
* - Index 1+: HIP-3 DEXs in order of enabledDexs array
|
|
211
|
+
*
|
|
212
|
+
* @param accountId - Optional account ID
|
|
213
|
+
*/
|
|
214
|
+
private createUserDataSubscription;
|
|
215
|
+
/**
|
|
216
|
+
* Ensure clearinghouseState subscription exists for a DEX
|
|
217
|
+
*
|
|
218
|
+
* @param userAddress - User address
|
|
219
|
+
* @param dexName - DEX name ('' for main)
|
|
220
|
+
*/
|
|
221
|
+
private ensureClearinghouseStateSubscription;
|
|
222
|
+
/**
|
|
223
|
+
* Ensure openOrders subscription exists for a DEX
|
|
224
|
+
*
|
|
225
|
+
* @param userAddress - User address
|
|
226
|
+
* @param dexName - DEX name ('' for main)
|
|
227
|
+
*/
|
|
228
|
+
private ensureOpenOrdersSubscription;
|
|
229
|
+
/**
|
|
230
|
+
* Aggregate data from all DEX caches and notify subscribers if data changed
|
|
231
|
+
* Used by both webData3 callback and fallback subscription callbacks
|
|
232
|
+
*/
|
|
233
|
+
private aggregateAndNotifySubscribers;
|
|
234
|
+
/**
|
|
235
|
+
* Clean up webData3 subscription when no longer needed
|
|
236
|
+
*/
|
|
237
|
+
private cleanupSharedWebData3ISubscription;
|
|
238
|
+
/**
|
|
239
|
+
* Subscribe to live position updates with TP/SL data
|
|
240
|
+
*
|
|
241
|
+
* @param params - Subscription parameters
|
|
242
|
+
* @returns Cleanup function
|
|
243
|
+
*/
|
|
244
|
+
subscribeToPositions(params: SubscribePositionsParams): () => void;
|
|
245
|
+
/**
|
|
246
|
+
* Subscribe to open interest cap updates
|
|
247
|
+
* OI caps are extracted from webData2 subscription (zero additional overhead)
|
|
248
|
+
*
|
|
249
|
+
* @param params - Subscription parameters
|
|
250
|
+
* @returns Cleanup function
|
|
251
|
+
*/
|
|
252
|
+
subscribeToOICaps(params: SubscribeOICapsParams): () => void;
|
|
253
|
+
/**
|
|
254
|
+
* Check if OI caps cache has been initialized
|
|
255
|
+
* Useful for preventing UI flashing before first data arrives
|
|
256
|
+
*
|
|
257
|
+
* @returns True if cache is initialized
|
|
258
|
+
*/
|
|
259
|
+
isOICapsCacheInitialized(): boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Subscribe to live order fill updates
|
|
262
|
+
* Shares subscriptions per accountId to avoid duplicate WebSocket connections
|
|
263
|
+
*
|
|
264
|
+
* @param params - Subscription parameters
|
|
265
|
+
* @returns Cleanup function
|
|
266
|
+
*/
|
|
267
|
+
subscribeToOrderFills(params: SubscribeOrderFillsParams): () => void;
|
|
268
|
+
/**
|
|
269
|
+
* Ensure order fill subscription is active for the given accountId
|
|
270
|
+
* Shares subscription across all callbacks for the same accountId
|
|
271
|
+
*
|
|
272
|
+
* @param accountId - Optional account ID
|
|
273
|
+
*/
|
|
274
|
+
private ensureOrderFillISubscription;
|
|
275
|
+
/**
|
|
276
|
+
* Subscribe to live order updates
|
|
277
|
+
* Uses the shared webData2 subscription to avoid duplicate connections
|
|
278
|
+
*
|
|
279
|
+
* @param params - Subscription parameters
|
|
280
|
+
* @returns Cleanup function
|
|
281
|
+
*/
|
|
282
|
+
subscribeToOrders(params: SubscribeOrdersParams): () => void;
|
|
283
|
+
/**
|
|
284
|
+
* Subscribe to live account updates
|
|
285
|
+
* Uses the shared webData2 subscription to avoid duplicate connections
|
|
286
|
+
*
|
|
287
|
+
* @param params - Subscription parameters
|
|
288
|
+
* @returns Cleanup function
|
|
289
|
+
*/
|
|
290
|
+
subscribeToAccount(params: SubscribeAccountParams): () => void;
|
|
291
|
+
/**
|
|
292
|
+
* Check if orders cache has been initialized from WebSocket
|
|
293
|
+
*
|
|
294
|
+
* @returns true if WebSocket has sent at least one update, false otherwise
|
|
295
|
+
*/
|
|
296
|
+
isOrdersCacheInitialized(): boolean;
|
|
297
|
+
/**
|
|
298
|
+
* Check if positions cache has been initialized from WebSocket
|
|
299
|
+
*
|
|
300
|
+
* @returns true if WebSocket has sent at least one update, false otherwise
|
|
301
|
+
*/
|
|
302
|
+
isPositionsCacheInitialized(): boolean;
|
|
303
|
+
/**
|
|
304
|
+
* Get cached positions from WebSocket subscription
|
|
305
|
+
*
|
|
306
|
+
* @returns Cached positions array, or null if not initialized
|
|
307
|
+
*/
|
|
308
|
+
getCachedPositions(): Position[] | null;
|
|
309
|
+
/**
|
|
310
|
+
* Get cached orders from WebSocket subscription
|
|
311
|
+
*
|
|
312
|
+
* @returns Cached orders array, or null if not initialized
|
|
313
|
+
*/
|
|
314
|
+
getCachedOrders(): Order[] | null;
|
|
315
|
+
/**
|
|
316
|
+
* Create subscription with common error handling
|
|
317
|
+
*
|
|
318
|
+
* @param subscribers - Subscriber collection
|
|
319
|
+
* @param callback - Callback to add
|
|
320
|
+
* @param key - Optional key for Map-based collections
|
|
321
|
+
* @returns Unsubscribe function
|
|
322
|
+
*/
|
|
323
|
+
private createSubscription;
|
|
324
|
+
/**
|
|
325
|
+
* Helper function to create consolidated price updates with 24h change calculation
|
|
326
|
+
*
|
|
327
|
+
* @param symbol - Asset symbol
|
|
328
|
+
* @param price - Current price
|
|
329
|
+
* @returns Price update object
|
|
330
|
+
*/
|
|
331
|
+
private createPriceUpdate;
|
|
332
|
+
/**
|
|
333
|
+
* Ensure global allMids subscription is active (singleton pattern)
|
|
334
|
+
*/
|
|
335
|
+
private ensureGlobalAllMidsSubscription;
|
|
336
|
+
/**
|
|
337
|
+
* Ensure activeAssetCtx subscription for specific symbol (with reference counting)
|
|
338
|
+
*
|
|
339
|
+
* @param symbol - Asset symbol
|
|
340
|
+
*/
|
|
341
|
+
private ensureActiveAssetSubscription;
|
|
342
|
+
/**
|
|
343
|
+
* Cleanup activeAssetCtx subscription when no longer needed
|
|
344
|
+
*
|
|
345
|
+
* @param symbol - Asset symbol
|
|
346
|
+
*/
|
|
347
|
+
private cleanupActiveAssetSubscription;
|
|
348
|
+
/**
|
|
349
|
+
* Ensure assetCtxs subscription for specific DEX (HIP-3 support)
|
|
350
|
+
* Uses WebSocket instead of REST polling for market data
|
|
351
|
+
* Implements reference counting to track active subscribers per DEX
|
|
352
|
+
*
|
|
353
|
+
* @param dex - DEX identifier ('' for main)
|
|
354
|
+
*/
|
|
355
|
+
private ensureAssetCtxsSubscription;
|
|
356
|
+
/**
|
|
357
|
+
* Create assetCtxs subscription for specific DEX
|
|
358
|
+
* Provides real-time market data for all assets on the DEX
|
|
359
|
+
*
|
|
360
|
+
* Performance: Uses cached meta from dexMetaCache (populated by metaAndAssetCtxs)
|
|
361
|
+
* to avoid redundant meta() API calls during subscription setup
|
|
362
|
+
*
|
|
363
|
+
* @param dex - DEX identifier ('' for main)
|
|
364
|
+
*/
|
|
365
|
+
private createAssetCtxsSubscription;
|
|
366
|
+
/**
|
|
367
|
+
* Cleanup assetCtxs subscription for specific DEX with reference counting
|
|
368
|
+
* Only unsubscribes when the last subscriber for this DEX is removed
|
|
369
|
+
*
|
|
370
|
+
* @param dex - DEX identifier ('' for main)
|
|
371
|
+
*/
|
|
372
|
+
private cleanupAssetCtxsSubscription;
|
|
373
|
+
/**
|
|
374
|
+
* Ensure BBO subscription for specific symbol (singleton)
|
|
375
|
+
*
|
|
376
|
+
* BBO provides best bid/ask without being affected by L2Book aggregation parameters,
|
|
377
|
+
* keeping spread consistent across order book grouping selections (matches Hyperliquid UI).
|
|
378
|
+
*
|
|
379
|
+
* @param symbol - Asset symbol
|
|
380
|
+
*/
|
|
381
|
+
private ensureBboSubscription;
|
|
382
|
+
/**
|
|
383
|
+
* Cleanup BBO subscription when no longer needed
|
|
384
|
+
*
|
|
385
|
+
* @param symbol - Asset symbol
|
|
386
|
+
*/
|
|
387
|
+
private cleanupBboSubscription;
|
|
388
|
+
/**
|
|
389
|
+
* Subscribe to full order book updates with multiple depth levels
|
|
390
|
+
* Creates a dedicated L2Book subscription for the requested symbol
|
|
391
|
+
* and processes data into OrderBookData format for UI consumption
|
|
392
|
+
*
|
|
393
|
+
* @param params - Subscription parameters
|
|
394
|
+
* @returns Cleanup function to unsubscribe
|
|
395
|
+
*/
|
|
396
|
+
subscribeToOrderBook(params: SubscribeOrderBookParams): () => void;
|
|
397
|
+
/**
|
|
398
|
+
* Process raw L2Book data into OrderBookData format
|
|
399
|
+
* Calculates cumulative totals, notional values, and spread metrics
|
|
400
|
+
*
|
|
401
|
+
* @param data - Raw L2Book response from WebSocket
|
|
402
|
+
* @param levels - Number of levels to return per side
|
|
403
|
+
* @returns Processed OrderBookData
|
|
404
|
+
*/
|
|
405
|
+
private processOrderBookData;
|
|
406
|
+
/**
|
|
407
|
+
* Notify all price subscribers with their requested symbols from cache
|
|
408
|
+
* Optimized to batch updates per subscriber
|
|
409
|
+
*/
|
|
410
|
+
private notifyAllPriceSubscribers;
|
|
411
|
+
/**
|
|
412
|
+
* Restore all active subscriptions after WebSocket reconnection
|
|
413
|
+
* Re-establishes WebSocket subscriptions for all active subscribers
|
|
414
|
+
*
|
|
415
|
+
* IMPORTANT: This method verifies transport readiness before attempting
|
|
416
|
+
* any subscriptions to prevent "subscribe error: undefined" errors.
|
|
417
|
+
*/
|
|
418
|
+
restoreSubscriptions(): Promise<void>;
|
|
419
|
+
/**
|
|
420
|
+
* Clear all subscriptions and cached data (multi-DEX support)
|
|
421
|
+
*/
|
|
422
|
+
clearAll(): void;
|
|
423
|
+
}
|
|
424
|
+
//# sourceMappingURL=HyperLiquidSubscriptionService.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HyperLiquidSubscriptionService.d.mts","sourceRoot":"","sources":["../../src/platform-services/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