@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 @@
|
|
|
1
|
+
{"version":3,"file":"HyperLiquidClientService.mjs","sourceRoot":"","sources":["../../src/platform-services/HyperLiquidClientService.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EACL,cAAc,EACd,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EACnB,4BAA4B;AAE7B,OAAO,EAAE,4BAA4B,EAAE,2CAAuC;AAE9E,OAAO,EAAE,eAAe,EAAE,qCAAiC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,yCAAqC;AAMjE,OAAO,EAAE,oBAAoB,EAAE,gCAA4B;AAE3D;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAClC,CAAC;AAQD;;GAEG;AACH,MAAM,CAAN,IAAY,wBAKX;AALD,WAAY,wBAAwB;IAClC,yDAA6B,CAAA;IAC7B,qDAAyB,CAAA;IACzB,mDAAuB,CAAA;IACvB,2DAA+B,CAAA;AACjC,CAAC,EALW,wBAAwB,KAAxB,wBAAwB,QAKnC;AAED;;GAEG;AACH,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAErC;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IA4CnC;;;;;;OAMG;IACH,YACE,IAA+B,EAC/B,UAAmC,EAAE;;QApDvC,2DAAiC;QAEjC,uDAAyB,CAAC,gCAAgC;QAE1D,2DAA6B,CAAC,4BAA4B;QAE1D,+DAEG;QAEH,wDAAkC;QAElC,0DAA+B;QAE/B,sDAAoB;QAEpB,oDACE,wBAAwB,CAAC,YAAY,EAAC;QAExC,yDAA8C,IAAI,EAAC;QAEnD,oFAAoF;QACpF,wDAAwD,IAAI,EAAC;QAE7D,gEAA2C;QAE3C,+BAA+B;QAC/B,wDA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wB,CAAC,YAAY,CAAC,CAAC;YACnE,OAAO;QACT,CAAC;QAED,uDAAuD;QACvD,2EAA2E;QAC3E,uBAAA,IAAI,sDAA6B,UAAU,CAAC,GAAG,EAAE;YAC/C,uBAAA,IAAI,sDAA6B,IAAI,MAAA,CAAC,CAAC,kCAAkC;YACzE,2DAA2D;YAC3D,mDAAmD;YACnD,4FAA4F;YAC5F,IACE,CAAC,uBAAA,IAAI,iDAAiB,KAAK,wBAAwB,CAAC,UAAU;gBAC5D,uBAAA,IAAI,iDAAiB,KAAK,wBAAwB,CAAC,YAAY,CAAC;gBAClE,CAAC,uBAAA,IAAI,sDAAsB;gBAC3B,CAAC,uBAAA,IAAI,gDAAgB,EACrB,CAAC;gBACD,uBAAA,IAAI,2FAAsB,MAA1B,IAAI,CAAwB,CAAC,KAAK,CAAC,GAAG,EAAE;oBACtC,wDAAwD;gBAC1D,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,EAAE,eAAe,CAAC,wBAAwB,CAAC,MAAA,CAAC;IAC/C,CAAC;AACH,CAAC","sourcesContent":["import type { Hex } from '@metamask/utils';\nimport {\n ExchangeClient,\n HttpTransport,\n InfoClient,\n SubscriptionClient,\n WebSocketTransport,\n} from '@nktkas/hyperliquid';\n\nimport { HYPERLIQUID_TRANSPORT_CONFIG } from '../constants/hyperLiquidConfig';\nimport type { HyperLiquidNetwork } from '../constants/hyperLiquidConfig';\nimport { PERPS_CONSTANTS } from '../constants/perpsConfig';\nimport { PERPS_ERROR_CODES } from '../constants/perpsErrorCodes';\nimport type {\n SubscribeCandlesParams,\n PerpsPlatformDependencies,\n} from '../types';\nimport type { CandleData, CandlePeriod } from '../types/chart';\nimport { calculateCandleCount } from '../utils/chartUtils';\n\n/**\n * Ensures we have a proper Error object for logging.\n * Converts unknown/string errors to proper Error instances.\n *\n * @param error - The caught error (could be Error, string, or unknown)\n * @returns A proper Error instance\n */\nfunction ensureError(error: unknown): Error {\n if (error instanceof Error) {\n return error;\n }\n return new Error(String(error));\n}\n\n/**\n * Valid time intervals for historical candle data\n * Uses CandlePeriod enum for type safety\n */\nexport type ValidCandleInterval = CandlePeriod;\n\n/**\n * Connection states for WebSocket management\n */\nexport enum WebSocketConnectionState {\n Disconnected = 'disconnected',\n Connecting = 'connecting',\n Connected = 'connected',\n Disconnecting = 'disconnecting',\n}\n\n/**\n * Maximum number of reconnection attempts before giving up\n */\nconst MAX_RECONNECTION_ATTEMPTS = 10;\n\n/**\n * Service for managing HyperLiquid SDK clients\n * Handles initialization, transport creation, and client lifecycle\n */\nexport class HyperLiquidClientService {\n #exchangeClient?: ExchangeClient;\n\n #infoClient?: InfoClient; // WebSocket transport (default)\n\n #infoClientHttp?: InfoClient; // HTTP transport (fallback)\n\n #subscriptionClient?: SubscriptionClient<{\n transport: WebSocketTransport;\n }>;\n\n #wsTransport?: WebSocketTransport;\n\n #httpTransport?: HttpTransport;\n\n #isTestnet: boolean;\n\n #connectionState: WebSocketConnectionState =\n WebSocketConnectionState.Disconnected;\n\n #disconnectionPromise: Promise<void> | null = null;\n\n // Callback for SDK terminate event (fired when all reconnection attempts exhausted)\n #onTerminateCallback: ((error: Error) => void) | null = null;\n\n #onReconnectCallback?: () => Promise<void>;\n\n // Reconnection attempt counter\n #reconnectionAttempt = 0;\n\n // Connection state change listeners for event-based notifications\n readonly #connectionStateListeners: Set<\n (state: WebSocketConnectionState, reconnectionAttempt: number) => void\n > = new Set();\n\n // Timeout reference for reconnection retry, tracked to enable cancellation on disconnect\n #reconnectionRetryTimeout: ReturnType<typeof setTimeout> | null = null;\n\n // Platform dependencies for logging\n readonly #deps: PerpsPlatformDependencies;\n\n // Flag to prevent concurrent reconnection attempts\n #isReconnecting = false;\n\n /**\n * Creates a new HyperLiquidClientService instance.\n *\n * @param deps - Platform dependencies for logging\n * @param options - Configuration options\n * @param options.isTestnet - Whether to use testnet mode\n */\n constructor(\n deps: PerpsPlatformDependencies,\n options: { isTestnet?: boolean } = {},\n ) {\n this.#deps = deps;\n this.#isTestnet = options.isTestnet ?? false;\n }\n\n /**\n * Initialize all HyperLiquid SDK clients\n *\n * IMPORTANT: This method awaits transport.ready() to ensure the WebSocket is\n * in OPEN state before marking initialization complete. This prevents race\n * conditions where subscriptions are attempted before the WebSocket handshake\n * completes (which would cause \"subscribe error: undefined\" errors).\n *\n * @param wallet - Wallet adapter with signTypedData capability\n * @param wallet.address - The wallet address\n * @param wallet.signTypedData - Function to sign typed data\n * @param wallet.getChainId - Optional function to get chain ID\n */\n public async initialize(wallet: {\n address?: Hex;\n signTypedData: (params: {\n domain: {\n name: string;\n version: string;\n chainId: number;\n verifyingContract: Hex;\n };\n types: {\n [key: string]: { name: string; type: string }[];\n };\n primaryType: string;\n message: Record<string, unknown>;\n }) => Promise<Hex>;\n getChainId?: () => Promise<number>;\n }): Promise<void> {\n try {\n this.#updateConnectionState(WebSocketConnectionState.Connecting);\n this.#createTransports();\n\n // Ensure transports are created\n if (!this.#httpTransport || !this.#wsTransport) {\n throw new Error('Failed to create transports');\n }\n\n // Wallet adapter implements AbstractViemJsonRpcAccount interface with signTypedData method\n // ExchangeClient uses HTTP transport for write operations (orders, approvals, etc.)\n\n this.#exchangeClient = new ExchangeClient({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n wallet: wallet as any,\n transport: this.#httpTransport,\n });\n\n // InfoClient with WebSocket transport (default) - multiplexed requests over single connection\n this.#infoClient = new InfoClient({ transport: this.#wsTransport });\n\n // InfoClient with HTTP transport (fallback) - for specific calls if WebSocket has issues\n this.#infoClientHttp = new InfoClient({ transport: this.#httpTransport });\n\n // SubscriptionClient uses WebSocket transport for real-time pub/sub (price feeds, position updates)\n this.#subscriptionClient = new SubscriptionClient({\n transport: this.#wsTransport,\n });\n\n // Wait for WebSocket to actually be ready before setting CONNECTED\n // This ensures we have a real connection, not just client objects\n await this.#wsTransport.ready();\n\n this.#updateConnectionState(WebSocketConnectionState.Connected);\n\n this.#deps.debugLogger.log('HyperLiquid SDK clients initialized', {\n testnet: this.#isTestnet,\n timestamp: new Date().toISOString(),\n connectionState: this.#connectionState,\n note: 'Using WebSocket for InfoClient (default), HTTP fallback available',\n });\n } catch (error) {\n // Cleanup on failure to prevent leaks and ensure isInitialized() returns false\n // Clear clients first, then transports\n this.#subscriptionClient = undefined;\n this.#infoClient = undefined;\n this.#infoClientHttp = undefined;\n this.#exchangeClient = undefined;\n\n // Close WebSocket transport to release resources and event listeners\n if (this.#wsTransport) {\n try {\n await this.#wsTransport.close();\n } catch {\n // Ignore cleanup errors\n }\n this.#wsTransport = undefined;\n }\n this.#httpTransport = undefined;\n\n const errorInstance = ensureError(error);\n this.#updateConnectionState(WebSocketConnectionState.Disconnected);\n\n // Log to Sentry: initialization failure blocks all Perps functionality\n this.#deps.logger.error(errorInstance, {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n service: 'HyperLiquidClientService',\n network: this.#isTestnet ? 'testnet' : 'mainnet',\n },\n context: {\n name: 'sdk_initialization',\n data: {\n operation: 'initialize',\n isTestnet: this.#isTestnet,\n },\n },\n });\n\n throw error;\n }\n }\n\n /**\n * Create HTTP and WebSocket transports\n * - HTTP for InfoClient and ExchangeClient (request/response operations)\n * - WebSocket for SubscriptionClient (real-time pub/sub)\n *\n * Both transports use SDK's built-in endpoint resolution via isTestnet flag\n *\n * @returns The created WebSocket transport\n */\n #createTransports(): WebSocketTransport {\n // Prevent duplicate transport creation and listener accumulation\n // This guards against re-entry if initialize() is called multiple times\n // (e.g., after a failed initialization attempt that didn't properly clean up)\n if (this.#wsTransport && this.#httpTransport) {\n this.#deps.debugLogger.log(\n 'HyperLiquid: Transports already exist, skipping creation',\n );\n return this.#wsTransport;\n }\n\n this.#deps.debugLogger.log('HyperLiquid: Creating transports', {\n isTestnet: this.#isTestnet,\n timestamp: new Date().toISOString(),\n note: 'SDK will auto-select endpoints based on isTestnet flag',\n });\n\n // HTTP transport for request/response operations (InfoClient, ExchangeClient)\n // SDK automatically selects: mainnet (https://api.hyperliquid.xyz) or testnet (https://api.hyperliquid-testnet.xyz)\n this.#httpTransport = new HttpTransport({\n isTestnet: this.#isTestnet,\n timeout: HYPERLIQUID_TRANSPORT_CONFIG.timeout,\n });\n\n // WebSocket transport for real-time subscriptions (SubscriptionClient)\n // SDK automatically selects: mainnet (wss://api.hyperliquid.xyz/ws) or testnet (wss://api.hyperliquid-testnet.xyz/ws)\n this.#wsTransport = new WebSocketTransport({\n isTestnet: this.#isTestnet,\n ...HYPERLIQUID_TRANSPORT_CONFIG,\n reconnect: {\n ...HYPERLIQUID_TRANSPORT_CONFIG.reconnect,\n // Use globalThis.WebSocket for cross-platform compatibility (Node.js and browser)\n\n WebSocket: globalThis.WebSocket,\n },\n });\n\n // Listen for WebSocket termination (fired when SDK exhausts all reconnection attempts)\n this.#wsTransport.socket.addEventListener('terminate', (event: Event) => {\n const customEvent = event as CustomEvent;\n this.#deps.debugLogger.log('HyperLiquid: WebSocket terminated', {\n reason: customEvent.detail?.code,\n timestamp: new Date().toISOString(),\n });\n\n this.#updateConnectionState(WebSocketConnectionState.Disconnected);\n\n if (this.#onTerminateCallback) {\n const terminateError =\n customEvent.detail instanceof Error\n ? customEvent.detail\n : new Error(\n `WebSocket terminated: ${customEvent.detail?.code ?? 'unknown'}`,\n );\n this.#onTerminateCallback(terminateError);\n }\n });\n\n return this.#wsTransport;\n }\n\n /**\n * Toggle testnet mode and reinitialize clients\n *\n * @param wallet - Wallet adapter with signTypedData capability\n * @param wallet.address - The wallet address\n * @param wallet.signTypedData - Function to sign typed data\n * @param wallet.getChainId - Optional function to get chain ID\n * @returns The new network mode\n */\n public async toggleTestnet(wallet: {\n address?: Hex;\n signTypedData: (params: {\n domain: {\n name: string;\n version: string;\n chainId: number;\n verifyingContract: Hex;\n };\n types: {\n [key: string]: { name: string; type: string }[];\n };\n primaryType: string;\n message: Record<string, unknown>;\n }) => Promise<Hex>;\n getChainId?: () => Promise<number>;\n }): Promise<HyperLiquidNetwork> {\n this.#isTestnet = !this.#isTestnet;\n await this.initialize(wallet);\n return this.#isTestnet ? 'testnet' : 'mainnet';\n }\n\n /**\n * Check if clients are properly initialized\n *\n * @returns True if all clients are initialized\n */\n public isInitialized(): boolean {\n return Boolean(\n this.#exchangeClient &&\n this.#infoClient &&\n this.#infoClientHttp &&\n this.#subscriptionClient,\n );\n }\n\n /**\n * Ensure clients are initialized, throw if not\n */\n public ensureInitialized(): void {\n if (!this.isInitialized()) {\n throw new Error(PERPS_ERROR_CODES.CLIENT_NOT_INITIALIZED);\n }\n }\n\n /**\n * Recreate subscription client if needed (for reconnection scenarios)\n *\n * @param wallet - Wallet adapter with signTypedData capability\n * @param wallet.address - The wallet address\n * @param wallet.signTypedData - Function to sign typed data\n * @param wallet.getChainId - Optional function to get chain ID\n */\n public async ensureSubscriptionClient(wallet: {\n address?: Hex;\n signTypedData: (params: {\n domain: {\n name: string;\n version: string;\n chainId: number;\n verifyingContract: Hex;\n };\n types: {\n [key: string]: { name: string; type: string }[];\n };\n primaryType: string;\n message: Record<string, unknown>;\n }) => Promise<Hex>;\n getChainId?: () => Promise<number>;\n }): Promise<void> {\n if (!this.#subscriptionClient) {\n this.#deps.debugLogger.log(\n 'HyperLiquid: Recreating subscription client after disconnect',\n );\n await this.initialize(wallet);\n }\n }\n\n /**\n * Get the exchange client\n *\n * @returns The exchange client\n */\n public getExchangeClient(): ExchangeClient {\n this.ensureInitialized();\n if (!this.#exchangeClient) {\n throw new Error(PERPS_ERROR_CODES.EXCHANGE_CLIENT_NOT_AVAILABLE);\n }\n return this.#exchangeClient;\n }\n\n /**\n * Get the info client\n *\n * @param options - Options for client selection\n * @param options.useHttp - Force HTTP transport instead of WebSocket (default: false)\n * @returns InfoClient instance with the selected transport\n */\n public getInfoClient(options?: { useHttp?: boolean }): InfoClient {\n this.ensureInitialized();\n\n if (options?.useHttp) {\n if (!this.#infoClientHttp) {\n throw new Error(PERPS_ERROR_CODES.INFO_CLIENT_NOT_AVAILABLE);\n }\n return this.#infoClientHttp;\n }\n\n if (!this.#infoClient) {\n throw new Error(PERPS_ERROR_CODES.INFO_CLIENT_NOT_AVAILABLE);\n }\n return this.#infoClient;\n }\n\n /**\n * Get the subscription client\n *\n * @returns The subscription client or undefined if not initialized\n */\n public getSubscriptionClient():\n | SubscriptionClient<{ transport: WebSocketTransport }>\n | undefined {\n if (!this.#subscriptionClient) {\n this.#deps.debugLogger.log('SubscriptionClient not initialized');\n return undefined;\n }\n return this.#subscriptionClient;\n }\n\n /**\n * Ensures the WebSocket transport is in OPEN state and ready for subscriptions.\n * This MUST be called before any subscription operations to prevent race conditions.\n *\n * The SDK's `transport.ready()` method:\n * - Returns immediately if WebSocket is already in OPEN state\n * - Waits for the \"open\" event if WebSocket is in CONNECTING state\n * - Supports AbortSignal for timeout/cancellation\n *\n * @param timeoutMs - Maximum time to wait for transport ready (default 5000ms)\n * @throws Error if transport not ready within timeout or subscription client unavailable\n */\n public async ensureTransportReady(timeoutMs: number = 5000): Promise<void> {\n const subscriptionClient = this.getSubscriptionClient();\n if (!subscriptionClient) {\n throw new Error('Subscription client not initialized');\n }\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), timeoutMs);\n\n try {\n await subscriptionClient.config_.transport.ready(controller.signal);\n } catch (error) {\n if (controller.signal.aborted) {\n throw new Error(\n `WebSocket transport ready timeout after ${timeoutMs}ms`,\n );\n }\n throw error;\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n /**\n * Get current network state\n *\n * @returns The current network ('mainnet' or 'testnet')\n */\n public getNetwork(): HyperLiquidNetwork {\n return this.#isTestnet ? 'testnet' : 'mainnet';\n }\n\n /**\n * Check if running on testnet\n *\n * @returns True if running on testnet\n */\n public isTestnetMode(): boolean {\n return this.#isTestnet;\n }\n\n /**\n * Update testnet mode\n *\n * @param testnet - Whether to use testnet\n */\n public setTestnetMode(testnet: boolean): void {\n this.#isTestnet = testnet;\n }\n\n /**\n * Fetch historical candle data using the HyperLiquid SDK\n *\n * @param symbol - The asset symbol (e.g., \"BTC\", \"ETH\")\n * @param interval - The interval (e.g., \"1m\", \"5m\", \"15m\", \"30m\", \"1h\", \"2h\", \"4h\", \"8h\", \"12h\", \"1d\", \"3d\", \"1w\", \"1M\")\n * @param limit - Number of candles to fetch (default: 100)\n * @param endTime - End timestamp in milliseconds (default: now). Used for fetching historical data before a specific time.\n * @returns Promise resolving to CandleData or null\n */\n public async fetchHistoricalCandles(\n symbol: string,\n interval: ValidCandleInterval,\n limit: number = 100,\n endTime?: number,\n ): Promise<CandleData | null> {\n this.ensureInitialized();\n\n try {\n // Calculate start and end times based on interval and limit\n const now = endTime ?? Date.now();\n const intervalMs = this.#getIntervalMilliseconds(interval);\n const startTime = now - limit * intervalMs;\n\n // Use the SDK's InfoClient to fetch candle data\n // HyperLiquid SDK uses 'coin' terminology\n const infoClient = this.getInfoClient();\n const data = await infoClient.candleSnapshot({\n coin: symbol, // Map to HyperLiquid SDK's 'coin' parameter\n interval,\n startTime,\n endTime: now,\n });\n\n // Transform API response to match expected format\n if (Array.isArray(data) && data.length > 0) {\n const candles = data.map((candle) => ({\n time: candle.t, // open time\n open: candle.o.toString(),\n high: candle.h.toString(),\n low: candle.l.toString(),\n close: candle.c.toString(),\n volume: candle.v.toString(),\n }));\n\n return {\n symbol,\n interval,\n candles,\n };\n }\n\n return {\n symbol,\n interval,\n candles: [],\n };\n } catch (error) {\n const errorInstance = ensureError(error);\n\n // Log to Sentry: prevents initial chart data load\n this.#deps.logger.error(errorInstance, {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n service: 'HyperLiquidClientService',\n network: this.#isTestnet ? 'testnet' : 'mainnet',\n },\n context: {\n name: 'historical_candles_api',\n data: {\n operation: 'fetchHistoricalCandles',\n symbol,\n interval,\n limit,\n hasEndTime: endTime !== undefined,\n },\n },\n });\n\n throw error;\n }\n }\n\n /**\n * Subscribe to candle updates via WebSocket\n *\n * @param params - Subscription parameters\n * @param params.symbol - The asset symbol (e.g., \"BTC\", \"ETH\")\n * @param params.interval - The interval (e.g., \"1m\", \"5m\", \"15m\", etc.)\n * @param params.duration - Optional time duration for calculating initial fetch size\n * @param params.callback - Function called with updated candle data\n * @param params.onError - Optional function called if subscription initialization fails\n * @returns Cleanup function to unsubscribe\n */\n public subscribeToCandles({\n symbol,\n interval,\n duration,\n callback,\n onError,\n }: SubscribeCandlesParams): () => void {\n this.ensureInitialized();\n\n const subscriptionClient = this.getSubscriptionClient();\n if (!subscriptionClient) {\n throw new Error(PERPS_ERROR_CODES.SUBSCRIPTION_CLIENT_NOT_AVAILABLE);\n }\n\n let currentCandleData: CandleData | null = null;\n let wsUnsubscribe: (() => void) | null = null;\n let isUnsubscribed = false;\n\n // Calculate initial fetch size dynamically based on duration and interval\n // Match main branch behavior: up to 500 candles initially\n const initialLimit = duration\n ? Math.min(calculateCandleCount(duration, interval), 500)\n : 100; // Default to 100 if no duration provided\n\n // Helper to handle candle event updates\n const handleCandleEvent = (candleEvent: {\n t: number;\n o: string;\n h: string;\n l: string;\n c: string;\n v: string;\n }): void => {\n // Don't process events if already unsubscribed\n if (isUnsubscribed) {\n return;\n }\n\n // Transform SDK CandleEvent to our Candle format\n const newCandle = {\n time: candleEvent.t,\n open: candleEvent.o.toString(),\n high: candleEvent.h.toString(),\n low: candleEvent.l.toString(),\n close: candleEvent.c.toString(),\n volume: candleEvent.v.toString(),\n };\n\n if (currentCandleData) {\n // Check if this is an update to the last candle or a new candle\n const { candles } = currentCandleData;\n const lastCandle = candles[candles.length - 1];\n\n if (lastCandle && lastCandle.time === newCandle.time) {\n // Update existing candle (live candle update)\n currentCandleData = {\n ...currentCandleData,\n candles: [...candles.slice(0, -1), newCandle],\n };\n } else {\n // New candle (completed candle)\n currentCandleData = {\n ...currentCandleData,\n candles: [...candles, newCandle],\n };\n }\n } else {\n currentCandleData = {\n symbol,\n interval,\n candles: [newCandle],\n };\n }\n\n callback(currentCandleData);\n };\n\n // Helper to handle subscription setup\n const setupSubscription = async (): Promise<void> => {\n try {\n // 1. Fetch initial historical data\n const initialData = await this.fetchHistoricalCandles(\n symbol,\n interval,\n initialLimit,\n );\n\n // Don't proceed if already unsubscribed\n if (isUnsubscribed) {\n return;\n }\n\n currentCandleData = initialData;\n if (currentCandleData) {\n callback(currentCandleData);\n }\n\n // 2. Subscribe to WebSocket for new candles\n const sub = await subscriptionClient.candle(\n { coin: symbol, interval },\n handleCandleEvent,\n );\n\n wsUnsubscribe = (): void => {\n sub.unsubscribe().catch(() => {\n // Ignore unsubscribe errors\n });\n };\n\n // If already unsubscribed while waiting, clean up immediately\n if (isUnsubscribed && wsUnsubscribe) {\n wsUnsubscribe();\n wsUnsubscribe = null;\n }\n } catch (error) {\n const errorInstance = ensureError(error);\n\n // Log to Sentry\n this.#deps.logger.error(errorInstance, {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n service: 'HyperLiquidClientService',\n network: this.#isTestnet ? 'testnet' : 'mainnet',\n },\n context: {\n name: 'candle_subscription',\n data: {\n operation: 'subscribeToCandles',\n symbol,\n interval,\n initialLimit,\n },\n },\n });\n\n // Notify caller of error\n onError?.(errorInstance);\n }\n };\n\n // Start the subscription setup (fire and forget with proper error handling)\n setupSubscription().catch(() => {\n // Errors are already handled in setupSubscription\n });\n\n // Return cleanup function\n return () => {\n isUnsubscribed = true;\n if (wsUnsubscribe) {\n wsUnsubscribe();\n wsUnsubscribe = null;\n }\n };\n }\n\n /**\n * Convert interval string to milliseconds\n *\n * @param interval - The candle period\n * @returns Interval duration in milliseconds\n */\n #getIntervalMilliseconds(interval: CandlePeriod): number {\n const intervalMap: Record<string, number> = {\n '1m': 1 * 60 * 1000,\n '3m': 3 * 60 * 1000,\n '5m': 5 * 60 * 1000,\n '15m': 15 * 60 * 1000,\n '30m': 30 * 60 * 1000,\n '1h': 60 * 60 * 1000,\n '2h': 2 * 60 * 60 * 1000,\n '4h': 4 * 60 * 60 * 1000,\n '8h': 8 * 60 * 60 * 1000,\n '12h': 12 * 60 * 60 * 1000,\n '1d': 24 * 60 * 60 * 1000,\n '3d': 3 * 24 * 60 * 60 * 1000,\n '1w': 7 * 24 * 60 * 60 * 1000,\n '1M': 30 * 24 * 60 * 60 * 1000, // Approximate\n };\n\n return intervalMap[interval] ?? 60 * 60 * 1000; // Default to 1 hour\n }\n\n /**\n * Disconnect and cleanup all clients\n *\n * @returns Promise that resolves when disconnection is complete\n */\n public async disconnect(): Promise<void> {\n // Return existing promise if already disconnecting\n if (this.#disconnectionPromise) {\n await this.#disconnectionPromise;\n return;\n }\n\n // If already disconnected, return immediately\n if (this.#connectionState === WebSocketConnectionState.Disconnected) {\n return;\n }\n\n // Create and store the disconnection promise\n this.#disconnectionPromise = this.#performDisconnection();\n\n try {\n await this.#disconnectionPromise;\n } finally {\n this.#disconnectionPromise = null;\n }\n }\n\n /**\n * Perform the actual disconnection\n */\n async #performDisconnection(): Promise<void> {\n try {\n this.#updateConnectionState(WebSocketConnectionState.Disconnecting);\n\n this.#deps.debugLogger.log('HyperLiquid: Disconnecting SDK clients', {\n isTestnet: this.#isTestnet,\n timestamp: new Date().toISOString(),\n connectionState: this.#connectionState,\n });\n\n // Clear callbacks\n this.#onReconnectCallback = undefined;\n this.#onTerminateCallback = null;\n\n // Cancel any pending reconnection retry timeout\n if (this.#reconnectionRetryTimeout) {\n clearTimeout(this.#reconnectionRetryTimeout);\n this.#reconnectionRetryTimeout = null;\n }\n\n // Clear connection state listeners to prevent stale callbacks\n this.#connectionStateListeners.clear();\n\n // Reset reconnection flag to allow future manual retries\n // This prevents a race condition where disconnecting during an active\n // reconnection attempt could leave the flag stuck, blocking subsequent retries\n this.#isReconnecting = false;\n\n // Close WebSocket transport only (HTTP is stateless)\n if (this.#wsTransport) {\n try {\n await this.#wsTransport.close();\n this.#deps.debugLogger.log(\n 'HyperLiquid: Closed WebSocket transport',\n {\n timestamp: new Date().toISOString(),\n },\n );\n } catch (error) {\n this.#deps.logger.error(ensureError(error), {\n context: {\n name: 'HyperLiquidClientService.performDisconnection',\n data: { action: 'close_transport' },\n },\n });\n }\n }\n\n // Clear client references\n this.#subscriptionClient = undefined;\n this.#exchangeClient = undefined;\n this.#infoClient = undefined;\n this.#infoClientHttp = undefined;\n this.#wsTransport = undefined;\n this.#httpTransport = undefined;\n\n this.#updateConnectionState(WebSocketConnectionState.Disconnected);\n\n this.#deps.debugLogger.log(\n 'HyperLiquid: SDK clients fully disconnected',\n {\n timestamp: new Date().toISOString(),\n connectionState: this.#connectionState,\n },\n );\n } catch (error) {\n this.#updateConnectionState(WebSocketConnectionState.Disconnected);\n this.#deps.logger.error(ensureError(error), {\n context: {\n name: 'HyperLiquidClientService.performDisconnection',\n data: { action: 'outer_catch' },\n },\n });\n throw error;\n }\n }\n\n /**\n * Get current WebSocket connection state\n *\n * @returns The current connection state\n */\n public getConnectionState(): WebSocketConnectionState {\n return this.#connectionState;\n }\n\n /**\n * Check if WebSocket is fully disconnected\n *\n * @returns True if disconnected\n */\n public isDisconnected(): boolean {\n return this.#connectionState === WebSocketConnectionState.Disconnected;\n }\n\n /**\n * Set callback to be invoked when reconnection is needed\n * This allows the service to notify external components (like PerpsConnectionManager)\n * when a connection drop is detected\n *\n * @param callback - Callback to invoke on reconnection\n */\n public setOnReconnectCallback(callback: () => Promise<void>): void {\n this.#onReconnectCallback = callback;\n }\n\n /**\n * Set callback for WebSocket termination events\n * Called when the SDK exhausts all reconnection attempts\n *\n * @param callback - Callback to invoke on termination\n */\n public setOnTerminateCallback(\n callback: ((error: Error) => void) | null,\n ): void {\n this.#onTerminateCallback = callback;\n }\n\n /**\n * Subscribe to connection state changes.\n * The listener will be called immediately with the current state and whenever the state changes.\n *\n * @param listener - Callback function that receives the new connection state and reconnection attempt\n * @returns Unsubscribe function to remove the listener\n */\n public subscribeToConnectionState(\n listener: (\n state: WebSocketConnectionState,\n reconnectionAttempt: number,\n ) => void,\n ): () => void {\n this.#connectionStateListeners.add(listener);\n\n // Immediately notify with current state\n // Wrap in try-catch to match notifyConnectionStateListeners behavior\n // This ensures the unsubscribe function is always returned even if listener throws\n try {\n listener(this.#connectionState, this.#reconnectionAttempt);\n } catch {\n // Ignore errors in listeners to prevent breaking subscription mechanism\n // If listener throws, it will be removed when unsubscribe is called\n }\n\n // Return unsubscribe function\n return () => {\n this.#connectionStateListeners.delete(listener);\n };\n }\n\n /**\n * Update connection state and notify all listeners\n * Always notifies if state changes OR if we're in CONNECTING state (to update attempt count)\n *\n * @param newState - The new connection state\n */\n #updateConnectionState(newState: WebSocketConnectionState): void {\n const previousState = this.#connectionState;\n const stateChanged = previousState !== newState;\n const isReconnectionAttempt =\n newState === WebSocketConnectionState.Connecting &&\n this.#reconnectionAttempt > 0;\n\n this.#connectionState = newState;\n\n // Reset reconnection attempt counter when successfully connected\n if (newState === WebSocketConnectionState.Connected) {\n this.#reconnectionAttempt = 0;\n }\n\n // Notify if state changed OR if this is a reconnection attempt (to update attempt count)\n if (stateChanged || isReconnectionAttempt) {\n this.#notifyConnectionStateListeners();\n }\n }\n\n /**\n * Notify all connection state listeners of the current state\n */\n #notifyConnectionStateListeners(): void {\n this.#connectionStateListeners.forEach((listener) => {\n try {\n listener(this.#connectionState, this.#reconnectionAttempt);\n } catch {\n // Ignore errors in listeners to prevent breaking other listeners\n }\n });\n }\n\n /**\n * Manually trigger a reconnection attempt.\n * This is exposed for UI retry buttons when user wants to force reconnection.\n * Resets the reconnection attempt counter to allow retrying after max attempts.\n *\n * @returns Promise that resolves when reconnection attempt is complete\n */\n public async reconnect(): Promise<void> {\n this.#deps.debugLogger.log(\n '[HyperLiquidClientService] reconnect() called',\n {\n previousAttempt: this.#reconnectionAttempt,\n currentState: this.#connectionState,\n },\n );\n // Reset attempt counter when user manually triggers retry\n this.#reconnectionAttempt = 0;\n await this.#handleConnectionDrop();\n this.#deps.debugLogger.log(\n '[HyperLiquidClientService] reconnect() completed',\n {\n newState: this.#connectionState,\n },\n );\n }\n\n /**\n * Handle detected connection drop\n * Recreates WebSocket transport and notifies callback to restore subscriptions\n * Will give up after MAX_RECONNECTION_ATTEMPTS and mark status as disconnected\n */\n async #handleConnectionDrop(): Promise<void> {\n // Prevent multiple simultaneous reconnection attempts\n if (this.#isReconnecting) {\n return;\n }\n\n this.#isReconnecting = true;\n\n // Increment reconnection attempt counter\n this.#reconnectionAttempt += 1;\n\n // Check if we've exceeded max retry attempts\n if (this.#reconnectionAttempt > MAX_RECONNECTION_ATTEMPTS) {\n this.#isReconnecting = false;\n this.#updateConnectionState(WebSocketConnectionState.Disconnected);\n return;\n }\n\n try {\n this.#updateConnectionState(WebSocketConnectionState.Connecting);\n\n // Close existing WebSocket transport and clear references\n // so createTransports() will create fresh ones\n if (this.#wsTransport) {\n try {\n await this.#wsTransport.close();\n } catch {\n // Ignore errors during close - transport may already be dead\n }\n }\n this.#wsTransport = undefined;\n this.#httpTransport = undefined;\n\n // Recreate WebSocket transport - returns the new transport for type safety\n const newWsTransport = this.#createTransports();\n\n // Recreate clients that use WebSocket transport\n this.#infoClient = new InfoClient({ transport: newWsTransport });\n this.#subscriptionClient = new SubscriptionClient({\n transport: newWsTransport,\n });\n\n await newWsTransport.ready();\n\n this.#deps.debugLogger.log(\n 'HyperLiquid: Transport ready, restoring subscriptions',\n { timestamp: new Date().toISOString() },\n );\n\n // NOW safe to restore subscriptions\n if (this.#onReconnectCallback) {\n await this.#onReconnectCallback();\n }\n\n // Cancel any pending retry timeout from previous failed attempts\n if (this.#reconnectionRetryTimeout) {\n clearTimeout(this.#reconnectionRetryTimeout);\n this.#reconnectionRetryTimeout = null;\n }\n\n this.#updateConnectionState(WebSocketConnectionState.Connected);\n this.#isReconnecting = false;\n } catch {\n // Reset flag before scheduling retry so the next attempt can proceed\n this.#isReconnecting = false;\n\n // Check if we've exceeded max retry attempts\n if (this.#reconnectionAttempt >= MAX_RECONNECTION_ATTEMPTS) {\n this.#updateConnectionState(WebSocketConnectionState.Disconnected);\n return;\n }\n\n // Reconnection failed - schedule a retry after a delay\n // Store timeout reference so it can be cancelled on intentional disconnect\n this.#reconnectionRetryTimeout = setTimeout(() => {\n this.#reconnectionRetryTimeout = null; // Clear reference after execution\n // Only retry if we haven't been intentionally disconnected\n // and no manual reconnect() is already in progress\n // Note: State may be CONNECTING or DISCONNECTED (if terminate event fired during reconnect)\n if (\n (this.#connectionState === WebSocketConnectionState.Connecting ||\n this.#connectionState === WebSocketConnectionState.Disconnected) &&\n !this.#disconnectionPromise &&\n !this.#isReconnecting\n ) {\n this.#handleConnectionDrop().catch(() => {\n // Errors are handled internally in handleConnectionDrop\n });\n }\n }, PERPS_CONSTANTS.ReconnectionRetryDelayMs);\n }\n }\n}\n"]}
|