@metamask-previews/perps-controller 16.1.0-preview-abca9bcea → 17.0.0-preview-0a30e47
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 +35 -1
- package/README.md +17 -0
- package/dist/PerpsController-method-action-types.d.ts +1235 -0
- package/dist/PerpsController-method-action-types.d.ts.map +1 -0
- package/dist/PerpsController-method-action-types.js +6 -0
- package/dist/PerpsController-method-action-types.js.map +1 -0
- package/dist/PerpsController.d.ts +1313 -0
- package/dist/PerpsController.d.ts.map +1 -0
- package/dist/PerpsController.js +5331 -0
- package/dist/PerpsController.js.map +1 -0
- package/dist/aggregation/SubscriptionMultiplexer.d.ts +171 -0
- package/dist/aggregation/SubscriptionMultiplexer.d.ts.map +1 -0
- package/dist/aggregation/SubscriptionMultiplexer.js +451 -0
- package/dist/aggregation/SubscriptionMultiplexer.js.map +1 -0
- package/dist/aggregation/index.d.ts +6 -0
- package/dist/aggregation/index.d.ts.map +1 -0
- package/dist/aggregation/index.js +5 -0
- package/dist/aggregation/index.js.map +1 -0
- package/dist/constants/chartConfig.d.ts +228 -0
- package/dist/constants/chartConfig.d.ts.map +1 -0
- package/dist/constants/chartConfig.js +233 -0
- package/dist/constants/chartConfig.js.map +1 -0
- package/dist/constants/eventNames.d.ts +565 -0
- package/dist/constants/eventNames.d.ts.map +1 -0
- package/dist/constants/eventNames.js +657 -0
- package/dist/constants/eventNames.js.map +1 -0
- package/dist/constants/hyperLiquidConfig.d.ts +280 -0
- package/dist/constants/hyperLiquidConfig.d.ts.map +1 -0
- package/dist/constants/hyperLiquidConfig.js +596 -0
- package/dist/constants/hyperLiquidConfig.js.map +1 -0
- package/dist/constants/index.d.ts +12 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +12 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/lighterConfig.d.ts +204 -0
- package/dist/constants/lighterConfig.d.ts.map +1 -0
- package/dist/constants/lighterConfig.js +317 -0
- package/dist/constants/lighterConfig.js.map +1 -0
- package/dist/constants/orderTypes.d.ts +19 -0
- package/dist/constants/orderTypes.d.ts.map +1 -0
- package/dist/constants/orderTypes.js +27 -0
- package/dist/constants/orderTypes.js.map +1 -0
- package/dist/constants/performanceMetrics.d.ts +46 -0
- package/dist/constants/performanceMetrics.d.ts.map +1 -0
- package/dist/constants/performanceMetrics.js +60 -0
- package/dist/constants/performanceMetrics.js.map +1 -0
- package/dist/constants/perpsConfig.d.ts +480 -0
- package/dist/constants/perpsConfig.d.ts.map +1 -0
- package/dist/constants/perpsConfig.js +555 -0
- package/dist/constants/perpsConfig.js.map +1 -0
- package/dist/constants/transactionsHistoryConfig.d.ts +35 -0
- package/dist/constants/transactionsHistoryConfig.d.ts.map +1 -0
- package/dist/constants/transactionsHistoryConfig.js +35 -0
- package/dist/constants/transactionsHistoryConfig.js.map +1 -0
- package/dist/index.d.ts +95 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/dist/perpsErrorCodes.d.ts +113 -0
- package/dist/perpsErrorCodes.d.ts.map +1 -0
- package/dist/perpsErrorCodes.js +133 -0
- package/dist/perpsErrorCodes.js.map +1 -0
- package/dist/providers/AggregatedPerpsProvider.d.ts +277 -0
- package/dist/providers/AggregatedPerpsProvider.d.ts.map +1 -0
- package/dist/providers/AggregatedPerpsProvider.js +827 -0
- package/dist/providers/AggregatedPerpsProvider.js.map +1 -0
- package/dist/providers/HyperLiquidProvider.d.ts +656 -0
- package/dist/providers/HyperLiquidProvider.d.ts.map +1 -0
- package/dist/providers/HyperLiquidProvider.js +11308 -0
- package/dist/providers/HyperLiquidProvider.js.map +1 -0
- package/dist/providers/LighterProvider.d.ts +179 -0
- package/dist/providers/LighterProvider.d.ts.map +1 -0
- package/dist/providers/LighterProvider.js +6599 -0
- package/dist/providers/LighterProvider.js.map +1 -0
- package/dist/routing/ProviderRouter.d.ts +112 -0
- package/dist/routing/ProviderRouter.d.ts.map +1 -0
- package/dist/routing/ProviderRouter.js +137 -0
- package/dist/routing/ProviderRouter.js.map +1 -0
- package/dist/routing/index.d.ts +6 -0
- package/dist/routing/index.d.ts.map +1 -0
- package/dist/routing/index.js +5 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/selectors.d.ts +336 -0
- package/dist/selectors.d.ts.map +1 -0
- package/dist/selectors.js +249 -0
- package/dist/selectors.js.map +1 -0
- package/dist/services/AccountService.d.ts +56 -0
- package/dist/services/AccountService.d.ts.map +1 -0
- package/dist/services/AccountService.js +307 -0
- package/dist/services/AccountService.js.map +1 -0
- package/dist/services/AggregatedOrderBookConnection.d.ts +106 -0
- package/dist/services/AggregatedOrderBookConnection.d.ts.map +1 -0
- package/dist/services/AggregatedOrderBookConnection.js +388 -0
- package/dist/services/AggregatedOrderBookConnection.js.map +1 -0
- package/dist/services/DataLakeService.d.ts +51 -0
- package/dist/services/DataLakeService.d.ts.map +1 -0
- package/dist/services/DataLakeService.js +215 -0
- package/dist/services/DataLakeService.js.map +1 -0
- package/dist/services/DepositService.d.ts +39 -0
- package/dist/services/DepositService.d.ts.map +1 -0
- package/dist/services/DepositService.js +88 -0
- package/dist/services/DepositService.js.map +1 -0
- package/dist/services/DexDiscoveryCacheManager.d.ts +52 -0
- package/dist/services/DexDiscoveryCacheManager.d.ts.map +1 -0
- package/dist/services/DexDiscoveryCacheManager.js +130 -0
- package/dist/services/DexDiscoveryCacheManager.js.map +1 -0
- package/dist/services/EligibilityService.d.ts +28 -0
- package/dist/services/EligibilityService.d.ts.map +1 -0
- package/dist/services/EligibilityService.js +61 -0
- package/dist/services/EligibilityService.js.map +1 -0
- package/dist/services/FeatureFlagConfigurationService.d.ts +73 -0
- package/dist/services/FeatureFlagConfigurationService.d.ts.map +1 -0
- package/dist/services/FeatureFlagConfigurationService.js +266 -0
- package/dist/services/FeatureFlagConfigurationService.js.map +1 -0
- package/dist/services/HyperLiquidClientService.d.ts +252 -0
- package/dist/services/HyperLiquidClientService.d.ts.map +1 -0
- package/dist/services/HyperLiquidClientService.js +1152 -0
- package/dist/services/HyperLiquidClientService.js.map +1 -0
- package/dist/services/HyperLiquidSubscriptionService.d.ts +265 -0
- package/dist/services/HyperLiquidSubscriptionService.d.ts.map +1 -0
- package/dist/services/HyperLiquidSubscriptionService.js +3874 -0
- package/dist/services/HyperLiquidSubscriptionService.js.map +1 -0
- package/dist/services/HyperLiquidWalletService.d.ts +84 -0
- package/dist/services/HyperLiquidWalletService.d.ts.map +1 -0
- package/dist/services/HyperLiquidWalletService.js +168 -0
- package/dist/services/HyperLiquidWalletService.js.map +1 -0
- package/dist/services/LighterClientService.d.ts +200 -0
- package/dist/services/LighterClientService.d.ts.map +1 -0
- package/dist/services/LighterClientService.js +634 -0
- package/dist/services/LighterClientService.js.map +1 -0
- package/dist/services/LighterWalletService.d.ts +51 -0
- package/dist/services/LighterWalletService.d.ts.map +1 -0
- package/dist/services/LighterWalletService.js +92 -0
- package/dist/services/LighterWalletService.js.map +1 -0
- package/dist/services/MarketDataService.d.ts +350 -0
- package/dist/services/MarketDataService.d.ts.map +1 -0
- package/dist/services/MarketDataService.js +1165 -0
- package/dist/services/MarketDataService.js.map +1 -0
- package/dist/services/RewardsIntegrationService.d.ts +84 -0
- package/dist/services/RewardsIntegrationService.d.ts.map +1 -0
- package/dist/services/RewardsIntegrationService.js +380 -0
- package/dist/services/RewardsIntegrationService.js.map +1 -0
- package/dist/services/ServiceContext.d.ts +102 -0
- package/dist/services/ServiceContext.d.ts.map +1 -0
- package/dist/services/ServiceContext.js +2 -0
- package/dist/services/ServiceContext.js.map +1 -0
- package/dist/services/TerminalMarketService.d.ts +45 -0
- package/dist/services/TerminalMarketService.d.ts.map +1 -0
- package/dist/services/TerminalMarketService.js +640 -0
- package/dist/services/TerminalMarketService.js.map +1 -0
- package/dist/services/TradingReadinessCache.d.ts +204 -0
- package/dist/services/TradingReadinessCache.d.ts.map +1 -0
- package/dist/services/TradingReadinessCache.js +313 -0
- package/dist/services/TradingReadinessCache.js.map +1 -0
- package/dist/services/TradingService.d.ts +201 -0
- package/dist/services/TradingService.d.ts.map +1 -0
- package/dist/services/TradingService.js +1967 -0
- package/dist/services/TradingService.js.map +1 -0
- package/dist/types/config.d.ts +49 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +2 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/hyperliquid-types.d.ts +67 -0
- package/dist/types/hyperliquid-types.d.ts.map +1 -0
- package/dist/types/hyperliquid-types.js +41 -0
- package/dist/types/hyperliquid-types.js.map +1 -0
- package/dist/types/index.d.ts +2192 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +133 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/lighter-types.d.ts +772 -0
- package/dist/types/lighter-types.d.ts.map +1 -0
- package/dist/types/lighter-types.js +10 -0
- package/dist/types/lighter-types.js.map +1 -0
- package/dist/types/messenger.d.ts +30 -0
- package/dist/types/messenger.d.ts.map +1 -0
- package/dist/types/messenger.js +2 -0
- package/dist/types/messenger.js.map +1 -0
- package/dist/types/perps-types.d.ts +184 -0
- package/dist/types/perps-types.d.ts.map +1 -0
- package/dist/types/perps-types.js +2 -0
- package/dist/types/perps-types.js.map +1 -0
- package/dist/types/token.d.ts +25 -0
- package/dist/types/token.d.ts.map +1 -0
- package/dist/types/token.js +2 -0
- package/dist/types/token.js.map +1 -0
- package/dist/types/transactionTypes.d.ts +60 -0
- package/dist/types/transactionTypes.d.ts.map +1 -0
- package/dist/types/transactionTypes.js +24 -0
- package/dist/types/transactionTypes.js.map +1 -0
- package/dist/utils/accountUtils.d.ts +72 -0
- package/dist/utils/accountUtils.d.ts.map +1 -0
- package/dist/utils/accountUtils.js +223 -0
- package/dist/utils/accountUtils.js.map +1 -0
- package/dist/utils/capabilitySymbols.d.ts +15 -0
- package/dist/utils/capabilitySymbols.d.ts.map +1 -0
- package/dist/utils/capabilitySymbols.js +21 -0
- package/dist/utils/capabilitySymbols.js.map +1 -0
- package/dist/utils/coalescePerpsRestRequest.d.ts +32 -0
- package/dist/utils/coalescePerpsRestRequest.d.ts.map +1 -0
- package/dist/utils/coalescePerpsRestRequest.js +66 -0
- package/dist/utils/coalescePerpsRestRequest.js.map +1 -0
- package/dist/utils/errorUtils.d.ts +50 -0
- package/dist/utils/errorUtils.d.ts.map +1 -0
- package/dist/utils/errorUtils.js +96 -0
- package/dist/utils/errorUtils.js.map +1 -0
- package/dist/utils/hyperLiquidAbstraction.d.ts +11 -0
- package/dist/utils/hyperLiquidAbstraction.d.ts.map +1 -0
- package/dist/utils/hyperLiquidAbstraction.js +19 -0
- package/dist/utils/hyperLiquidAbstraction.js.map +1 -0
- package/dist/utils/hyperLiquidAdapter.d.ts +77 -0
- package/dist/utils/hyperLiquidAdapter.d.ts.map +1 -0
- package/dist/utils/hyperLiquidAdapter.js +495 -0
- package/dist/utils/hyperLiquidAdapter.js.map +1 -0
- package/dist/utils/hyperLiquidOrderBookProcessor.d.ts +55 -0
- package/dist/utils/hyperLiquidOrderBookProcessor.d.ts.map +1 -0
- package/dist/utils/hyperLiquidOrderBookProcessor.js +78 -0
- package/dist/utils/hyperLiquidOrderBookProcessor.js.map +1 -0
- package/dist/utils/hyperLiquidPositionPreview.d.ts +124 -0
- package/dist/utils/hyperLiquidPositionPreview.d.ts.map +1 -0
- package/dist/utils/hyperLiquidPositionPreview.js +347 -0
- package/dist/utils/hyperLiquidPositionPreview.js.map +1 -0
- package/dist/utils/hyperLiquidValidation.d.ts +192 -0
- package/dist/utils/hyperLiquidValidation.d.ts.map +1 -0
- package/dist/utils/hyperLiquidValidation.js +786 -0
- package/dist/utils/hyperLiquidValidation.js.map +1 -0
- package/dist/utils/idUtils.d.ts +6 -0
- package/dist/utils/idUtils.d.ts.map +1 -0
- package/dist/utils/idUtils.js +10 -0
- package/dist/utils/idUtils.js.map +1 -0
- package/dist/utils/index.d.ts +29 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +34 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/lighterAdapter.d.ts +117 -0
- package/dist/utils/lighterAdapter.d.ts.map +1 -0
- package/dist/utils/lighterAdapter.js +562 -0
- package/dist/utils/lighterAdapter.js.map +1 -0
- package/dist/utils/marketDataTransform.d.ts +71 -0
- package/dist/utils/marketDataTransform.d.ts.map +1 -0
- package/dist/utils/marketDataTransform.js +243 -0
- package/dist/utils/marketDataTransform.js.map +1 -0
- package/dist/utils/marketSearch.d.ts +48 -0
- package/dist/utils/marketSearch.d.ts.map +1 -0
- package/dist/utils/marketSearch.js +106 -0
- package/dist/utils/marketSearch.js.map +1 -0
- package/dist/utils/marketUtils.d.ts +73 -0
- package/dist/utils/marketUtils.d.ts.map +1 -0
- package/dist/utils/marketUtils.js +248 -0
- package/dist/utils/marketUtils.js.map +1 -0
- package/dist/utils/orderCalculations.d.ts +306 -0
- package/dist/utils/orderCalculations.d.ts.map +1 -0
- package/dist/utils/orderCalculations.js +833 -0
- package/dist/utils/orderCalculations.js.map +1 -0
- package/dist/utils/orderTypes.d.ts +166 -0
- package/dist/utils/orderTypes.d.ts.map +1 -0
- package/dist/utils/orderTypes.js +287 -0
- package/dist/utils/orderTypes.js.map +1 -0
- package/dist/utils/perpsConnectionAttemptContext.d.ts +7 -0
- package/dist/utils/perpsConnectionAttemptContext.d.ts.map +1 -0
- package/dist/utils/perpsConnectionAttemptContext.js +15 -0
- package/dist/utils/perpsConnectionAttemptContext.js.map +1 -0
- package/dist/utils/perpsDiskPersistence.d.ts +112 -0
- package/dist/utils/perpsDiskPersistence.d.ts.map +1 -0
- package/dist/utils/perpsDiskPersistence.js +251 -0
- package/dist/utils/perpsDiskPersistence.js.map +1 -0
- package/dist/utils/perpsFormatters.d.ts +204 -0
- package/dist/utils/perpsFormatters.d.ts.map +1 -0
- package/dist/utils/perpsFormatters.js +500 -0
- package/dist/utils/perpsFormatters.js.map +1 -0
- package/dist/utils/rewardsUtils.d.ts +33 -0
- package/dist/utils/rewardsUtils.d.ts.map +1 -0
- package/dist/utils/rewardsUtils.js +92 -0
- package/dist/utils/rewardsUtils.js.map +1 -0
- package/dist/utils/significantFigures.d.ts +25 -0
- package/dist/utils/significantFigures.d.ts.map +1 -0
- package/dist/utils/significantFigures.js +82 -0
- package/dist/utils/significantFigures.js.map +1 -0
- package/dist/utils/sortMarkets.d.ts +25 -0
- package/dist/utils/sortMarkets.d.ts.map +1 -0
- package/dist/utils/sortMarkets.js +88 -0
- package/dist/utils/sortMarkets.js.map +1 -0
- package/dist/utils/standaloneInfoClient.d.ts +37 -0
- package/dist/utils/standaloneInfoClient.d.ts.map +1 -0
- package/dist/utils/standaloneInfoClient.js +64 -0
- package/dist/utils/standaloneInfoClient.js.map +1 -0
- package/dist/utils/stringParseUtils.d.ts +11 -0
- package/dist/utils/stringParseUtils.d.ts.map +1 -0
- package/dist/utils/stringParseUtils.js +28 -0
- package/dist/utils/stringParseUtils.js.map +1 -0
- package/dist/utils/transferData.d.ts +9 -0
- package/dist/utils/transferData.d.ts.map +1 -0
- package/dist/utils/transferData.js +29 -0
- package/dist/utils/transferData.js.map +1 -0
- package/dist/utils/wait.d.ts +2 -0
- package/dist/utils/wait.d.ts.map +1 -0
- package/dist/utils/wait.js +2 -0
- package/dist/utils/wait.js.map +1 -0
- package/package.json +33 -61
- package/dist/PerpsController-method-action-types.cjs +0 -7
- package/dist/PerpsController-method-action-types.cjs.map +0 -1
- package/dist/PerpsController-method-action-types.d.cts +0 -1235
- package/dist/PerpsController-method-action-types.d.cts.map +0 -1
- package/dist/PerpsController-method-action-types.d.mts +0 -1235
- package/dist/PerpsController-method-action-types.d.mts.map +0 -1
- package/dist/PerpsController-method-action-types.mjs +0 -6
- package/dist/PerpsController-method-action-types.mjs.map +0 -1
- package/dist/PerpsController.cjs +0 -5154
- package/dist/PerpsController.cjs.map +0 -1
- package/dist/PerpsController.d.cts +0 -1313
- package/dist/PerpsController.d.cts.map +0 -1
- package/dist/PerpsController.d.mts +0 -1313
- package/dist/PerpsController.d.mts.map +0 -1
- package/dist/PerpsController.mjs +0 -5142
- package/dist/PerpsController.mjs.map +0 -1
- package/dist/aggregation/SubscriptionMultiplexer.cjs +0 -441
- package/dist/aggregation/SubscriptionMultiplexer.cjs.map +0 -1
- package/dist/aggregation/SubscriptionMultiplexer.d.cts +0 -171
- package/dist/aggregation/SubscriptionMultiplexer.d.cts.map +0 -1
- package/dist/aggregation/SubscriptionMultiplexer.d.mts +0 -171
- package/dist/aggregation/SubscriptionMultiplexer.d.mts.map +0 -1
- package/dist/aggregation/SubscriptionMultiplexer.mjs +0 -437
- package/dist/aggregation/SubscriptionMultiplexer.mjs.map +0 -1
- package/dist/aggregation/index.cjs +0 -9
- package/dist/aggregation/index.cjs.map +0 -1
- package/dist/aggregation/index.d.cts +0 -6
- package/dist/aggregation/index.d.cts.map +0 -1
- package/dist/aggregation/index.d.mts +0 -6
- package/dist/aggregation/index.d.mts.map +0 -1
- package/dist/aggregation/index.mjs +0 -5
- package/dist/aggregation/index.mjs.map +0 -1
- package/dist/constants/chartConfig.cjs +0 -239
- package/dist/constants/chartConfig.cjs.map +0 -1
- package/dist/constants/chartConfig.d.cts +0 -228
- package/dist/constants/chartConfig.d.cts.map +0 -1
- package/dist/constants/chartConfig.d.mts +0 -228
- package/dist/constants/chartConfig.d.mts.map +0 -1
- package/dist/constants/chartConfig.mjs +0 -233
- package/dist/constants/chartConfig.mjs.map +0 -1
- package/dist/constants/eventNames.cjs +0 -660
- package/dist/constants/eventNames.cjs.map +0 -1
- package/dist/constants/eventNames.d.cts +0 -565
- package/dist/constants/eventNames.d.cts.map +0 -1
- package/dist/constants/eventNames.d.mts +0 -565
- package/dist/constants/eventNames.d.mts.map +0 -1
- package/dist/constants/eventNames.mjs +0 -657
- package/dist/constants/eventNames.mjs.map +0 -1
- package/dist/constants/hyperLiquidConfig.cjs +0 -607
- package/dist/constants/hyperLiquidConfig.cjs.map +0 -1
- package/dist/constants/hyperLiquidConfig.d.cts +0 -280
- package/dist/constants/hyperLiquidConfig.d.cts.map +0 -1
- package/dist/constants/hyperLiquidConfig.d.mts +0 -280
- package/dist/constants/hyperLiquidConfig.d.mts.map +0 -1
- package/dist/constants/hyperLiquidConfig.mjs +0 -596
- package/dist/constants/hyperLiquidConfig.mjs.map +0 -1
- package/dist/constants/index.cjs +0 -28
- package/dist/constants/index.cjs.map +0 -1
- package/dist/constants/index.d.cts +0 -12
- package/dist/constants/index.d.cts.map +0 -1
- package/dist/constants/index.d.mts +0 -12
- package/dist/constants/index.d.mts.map +0 -1
- package/dist/constants/index.mjs +0 -12
- package/dist/constants/index.mjs.map +0 -1
- package/dist/constants/lighterConfig.cjs +0 -328
- package/dist/constants/lighterConfig.cjs.map +0 -1
- package/dist/constants/lighterConfig.d.cts +0 -204
- package/dist/constants/lighterConfig.d.cts.map +0 -1
- package/dist/constants/lighterConfig.d.mts +0 -204
- package/dist/constants/lighterConfig.d.mts.map +0 -1
- package/dist/constants/lighterConfig.mjs +0 -317
- package/dist/constants/lighterConfig.mjs.map +0 -1
- package/dist/constants/orderTypes.cjs +0 -31
- package/dist/constants/orderTypes.cjs.map +0 -1
- package/dist/constants/orderTypes.d.cts +0 -19
- package/dist/constants/orderTypes.d.cts.map +0 -1
- package/dist/constants/orderTypes.d.mts +0 -19
- package/dist/constants/orderTypes.d.mts.map +0 -1
- package/dist/constants/orderTypes.mjs +0 -27
- package/dist/constants/orderTypes.mjs.map +0 -1
- package/dist/constants/performanceMetrics.cjs +0 -63
- package/dist/constants/performanceMetrics.cjs.map +0 -1
- package/dist/constants/performanceMetrics.d.cts +0 -46
- package/dist/constants/performanceMetrics.d.cts.map +0 -1
- package/dist/constants/performanceMetrics.d.mts +0 -46
- package/dist/constants/performanceMetrics.d.mts.map +0 -1
- package/dist/constants/performanceMetrics.mjs +0 -60
- package/dist/constants/performanceMetrics.mjs.map +0 -1
- package/dist/constants/perpsConfig.cjs +0 -560
- package/dist/constants/perpsConfig.cjs.map +0 -1
- package/dist/constants/perpsConfig.d.cts +0 -480
- package/dist/constants/perpsConfig.d.cts.map +0 -1
- package/dist/constants/perpsConfig.d.mts +0 -480
- package/dist/constants/perpsConfig.d.mts.map +0 -1
- package/dist/constants/perpsConfig.mjs +0 -555
- package/dist/constants/perpsConfig.mjs.map +0 -1
- package/dist/constants/transactionsHistoryConfig.cjs +0 -38
- package/dist/constants/transactionsHistoryConfig.cjs.map +0 -1
- package/dist/constants/transactionsHistoryConfig.d.cts +0 -35
- package/dist/constants/transactionsHistoryConfig.d.cts.map +0 -1
- package/dist/constants/transactionsHistoryConfig.d.mts +0 -35
- package/dist/constants/transactionsHistoryConfig.d.mts.map +0 -1
- package/dist/constants/transactionsHistoryConfig.mjs +0 -35
- package/dist/constants/transactionsHistoryConfig.mjs.map +0 -1
- package/dist/index.cjs +0 -334
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -95
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts +0 -95
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -80
- package/dist/index.mjs.map +0 -1
- package/dist/perpsErrorCodes.cjs +0 -128
- package/dist/perpsErrorCodes.cjs.map +0 -1
- package/dist/perpsErrorCodes.d.cts +0 -105
- package/dist/perpsErrorCodes.d.cts.map +0 -1
- package/dist/perpsErrorCodes.d.mts +0 -105
- package/dist/perpsErrorCodes.d.mts.map +0 -1
- package/dist/perpsErrorCodes.mjs +0 -125
- package/dist/perpsErrorCodes.mjs.map +0 -1
- package/dist/providers/AggregatedPerpsProvider.cjs +0 -810
- package/dist/providers/AggregatedPerpsProvider.cjs.map +0 -1
- package/dist/providers/AggregatedPerpsProvider.d.cts +0 -277
- package/dist/providers/AggregatedPerpsProvider.d.cts.map +0 -1
- package/dist/providers/AggregatedPerpsProvider.d.mts +0 -277
- package/dist/providers/AggregatedPerpsProvider.d.mts.map +0 -1
- package/dist/providers/AggregatedPerpsProvider.mjs +0 -805
- package/dist/providers/AggregatedPerpsProvider.mjs.map +0 -1
- package/dist/providers/HyperLiquidProvider.cjs +0 -10963
- package/dist/providers/HyperLiquidProvider.cjs.map +0 -1
- package/dist/providers/HyperLiquidProvider.d.cts +0 -656
- package/dist/providers/HyperLiquidProvider.d.cts.map +0 -1
- package/dist/providers/HyperLiquidProvider.d.mts +0 -656
- package/dist/providers/HyperLiquidProvider.d.mts.map +0 -1
- package/dist/providers/HyperLiquidProvider.mjs +0 -10959
- package/dist/providers/HyperLiquidProvider.mjs.map +0 -1
- package/dist/providers/LighterProvider.cjs +0 -6575
- package/dist/providers/LighterProvider.cjs.map +0 -1
- package/dist/providers/LighterProvider.d.cts +0 -179
- package/dist/providers/LighterProvider.d.cts.map +0 -1
- package/dist/providers/LighterProvider.d.mts +0 -179
- package/dist/providers/LighterProvider.d.mts.map +0 -1
- package/dist/providers/LighterProvider.mjs +0 -6571
- package/dist/providers/LighterProvider.mjs.map +0 -1
- package/dist/routing/ProviderRouter.cjs +0 -154
- package/dist/routing/ProviderRouter.cjs.map +0 -1
- package/dist/routing/ProviderRouter.d.cts +0 -112
- package/dist/routing/ProviderRouter.d.cts.map +0 -1
- package/dist/routing/ProviderRouter.d.mts +0 -112
- package/dist/routing/ProviderRouter.d.mts.map +0 -1
- package/dist/routing/ProviderRouter.mjs +0 -150
- package/dist/routing/ProviderRouter.mjs.map +0 -1
- package/dist/routing/index.cjs +0 -9
- package/dist/routing/index.cjs.map +0 -1
- package/dist/routing/index.d.cts +0 -6
- package/dist/routing/index.d.cts.map +0 -1
- package/dist/routing/index.d.mts +0 -6
- package/dist/routing/index.d.mts.map +0 -1
- package/dist/routing/index.mjs +0 -5
- package/dist/routing/index.mjs.map +0 -1
- package/dist/selectors.cjs +0 -264
- package/dist/selectors.cjs.map +0 -1
- package/dist/selectors.d.cts +0 -336
- package/dist/selectors.d.cts.map +0 -1
- package/dist/selectors.d.mts +0 -336
- package/dist/selectors.d.mts.map +0 -1
- package/dist/selectors.mjs +0 -249
- package/dist/selectors.mjs.map +0 -1
- package/dist/services/AccountService.cjs +0 -324
- package/dist/services/AccountService.cjs.map +0 -1
- package/dist/services/AccountService.d.cts +0 -56
- package/dist/services/AccountService.d.cts.map +0 -1
- package/dist/services/AccountService.d.mts +0 -56
- package/dist/services/AccountService.d.mts.map +0 -1
- package/dist/services/AccountService.mjs +0 -320
- package/dist/services/AccountService.mjs.map +0 -1
- package/dist/services/AggregatedOrderBookConnection.cjs +0 -405
- package/dist/services/AggregatedOrderBookConnection.cjs.map +0 -1
- package/dist/services/AggregatedOrderBookConnection.d.cts +0 -106
- package/dist/services/AggregatedOrderBookConnection.d.cts.map +0 -1
- package/dist/services/AggregatedOrderBookConnection.d.mts +0 -106
- package/dist/services/AggregatedOrderBookConnection.d.mts.map +0 -1
- package/dist/services/AggregatedOrderBookConnection.mjs +0 -400
- package/dist/services/AggregatedOrderBookConnection.mjs.map +0 -1
- package/dist/services/DataLakeService.cjs +0 -233
- package/dist/services/DataLakeService.cjs.map +0 -1
- package/dist/services/DataLakeService.d.cts +0 -51
- package/dist/services/DataLakeService.d.cts.map +0 -1
- package/dist/services/DataLakeService.d.mts +0 -51
- package/dist/services/DataLakeService.d.mts.map +0 -1
- package/dist/services/DataLakeService.mjs +0 -229
- package/dist/services/DataLakeService.mjs.map +0 -1
- package/dist/services/DepositService.cjs +0 -105
- package/dist/services/DepositService.cjs.map +0 -1
- package/dist/services/DepositService.d.cts +0 -39
- package/dist/services/DepositService.d.cts.map +0 -1
- package/dist/services/DepositService.d.mts +0 -39
- package/dist/services/DepositService.d.mts.map +0 -1
- package/dist/services/DepositService.mjs +0 -101
- package/dist/services/DepositService.mjs.map +0 -1
- package/dist/services/DexDiscoveryCacheManager.cjs +0 -147
- package/dist/services/DexDiscoveryCacheManager.cjs.map +0 -1
- package/dist/services/DexDiscoveryCacheManager.d.cts +0 -52
- package/dist/services/DexDiscoveryCacheManager.d.cts.map +0 -1
- package/dist/services/DexDiscoveryCacheManager.d.mts +0 -52
- package/dist/services/DexDiscoveryCacheManager.d.mts.map +0 -1
- package/dist/services/DexDiscoveryCacheManager.mjs +0 -143
- package/dist/services/DexDiscoveryCacheManager.mjs.map +0 -1
- package/dist/services/EligibilityService.cjs +0 -78
- package/dist/services/EligibilityService.cjs.map +0 -1
- package/dist/services/EligibilityService.d.cts +0 -28
- package/dist/services/EligibilityService.d.cts.map +0 -1
- package/dist/services/EligibilityService.d.mts +0 -28
- package/dist/services/EligibilityService.d.mts.map +0 -1
- package/dist/services/EligibilityService.mjs +0 -74
- package/dist/services/EligibilityService.mjs.map +0 -1
- package/dist/services/FeatureFlagConfigurationService.cjs +0 -257
- package/dist/services/FeatureFlagConfigurationService.cjs.map +0 -1
- package/dist/services/FeatureFlagConfigurationService.d.cts +0 -73
- package/dist/services/FeatureFlagConfigurationService.d.cts.map +0 -1
- package/dist/services/FeatureFlagConfigurationService.d.mts +0 -73
- package/dist/services/FeatureFlagConfigurationService.d.mts.map +0 -1
- package/dist/services/FeatureFlagConfigurationService.mjs +0 -253
- package/dist/services/FeatureFlagConfigurationService.mjs.map +0 -1
- package/dist/services/HyperLiquidClientService.cjs +0 -1114
- package/dist/services/HyperLiquidClientService.cjs.map +0 -1
- package/dist/services/HyperLiquidClientService.d.cts +0 -252
- package/dist/services/HyperLiquidClientService.d.cts.map +0 -1
- package/dist/services/HyperLiquidClientService.d.mts +0 -252
- package/dist/services/HyperLiquidClientService.d.mts.map +0 -1
- package/dist/services/HyperLiquidClientService.mjs +0 -1109
- package/dist/services/HyperLiquidClientService.mjs.map +0 -1
- package/dist/services/HyperLiquidSubscriptionService.cjs +0 -3594
- package/dist/services/HyperLiquidSubscriptionService.cjs.map +0 -1
- package/dist/services/HyperLiquidSubscriptionService.d.cts +0 -265
- package/dist/services/HyperLiquidSubscriptionService.d.cts.map +0 -1
- package/dist/services/HyperLiquidSubscriptionService.d.mts +0 -265
- package/dist/services/HyperLiquidSubscriptionService.d.mts.map +0 -1
- package/dist/services/HyperLiquidSubscriptionService.mjs +0 -3590
- package/dist/services/HyperLiquidSubscriptionService.mjs.map +0 -1
- package/dist/services/HyperLiquidWalletService.cjs +0 -186
- package/dist/services/HyperLiquidWalletService.cjs.map +0 -1
- package/dist/services/HyperLiquidWalletService.d.cts +0 -84
- package/dist/services/HyperLiquidWalletService.d.cts.map +0 -1
- package/dist/services/HyperLiquidWalletService.d.mts +0 -84
- package/dist/services/HyperLiquidWalletService.d.mts.map +0 -1
- package/dist/services/HyperLiquidWalletService.mjs +0 -182
- package/dist/services/HyperLiquidWalletService.mjs.map +0 -1
- package/dist/services/LighterClientService.cjs +0 -643
- package/dist/services/LighterClientService.cjs.map +0 -1
- package/dist/services/LighterClientService.d.cts +0 -200
- package/dist/services/LighterClientService.d.cts.map +0 -1
- package/dist/services/LighterClientService.d.mts +0 -200
- package/dist/services/LighterClientService.d.mts.map +0 -1
- package/dist/services/LighterClientService.mjs +0 -637
- package/dist/services/LighterClientService.mjs.map +0 -1
- package/dist/services/LighterWalletService.cjs +0 -109
- package/dist/services/LighterWalletService.cjs.map +0 -1
- package/dist/services/LighterWalletService.d.cts +0 -51
- package/dist/services/LighterWalletService.d.cts.map +0 -1
- package/dist/services/LighterWalletService.d.mts +0 -51
- package/dist/services/LighterWalletService.d.mts.map +0 -1
- package/dist/services/LighterWalletService.mjs +0 -105
- package/dist/services/LighterWalletService.mjs.map +0 -1
- package/dist/services/MarketDataService.cjs +0 -1171
- package/dist/services/MarketDataService.cjs.map +0 -1
- package/dist/services/MarketDataService.d.cts +0 -350
- package/dist/services/MarketDataService.d.cts.map +0 -1
- package/dist/services/MarketDataService.d.mts +0 -350
- package/dist/services/MarketDataService.d.mts.map +0 -1
- package/dist/services/MarketDataService.mjs +0 -1167
- package/dist/services/MarketDataService.mjs.map +0 -1
- package/dist/services/RewardsIntegrationService.cjs +0 -391
- package/dist/services/RewardsIntegrationService.cjs.map +0 -1
- package/dist/services/RewardsIntegrationService.d.cts +0 -84
- package/dist/services/RewardsIntegrationService.d.cts.map +0 -1
- package/dist/services/RewardsIntegrationService.d.mts +0 -84
- package/dist/services/RewardsIntegrationService.d.mts.map +0 -1
- package/dist/services/RewardsIntegrationService.mjs +0 -387
- package/dist/services/RewardsIntegrationService.mjs.map +0 -1
- package/dist/services/ServiceContext.cjs +0 -3
- package/dist/services/ServiceContext.cjs.map +0 -1
- package/dist/services/ServiceContext.d.cts +0 -102
- package/dist/services/ServiceContext.d.cts.map +0 -1
- package/dist/services/ServiceContext.d.mts +0 -102
- package/dist/services/ServiceContext.d.mts.map +0 -1
- package/dist/services/ServiceContext.mjs +0 -2
- package/dist/services/ServiceContext.mjs.map +0 -1
- package/dist/services/TerminalMarketService.cjs +0 -623
- package/dist/services/TerminalMarketService.cjs.map +0 -1
- package/dist/services/TerminalMarketService.d.cts +0 -45
- package/dist/services/TerminalMarketService.d.cts.map +0 -1
- package/dist/services/TerminalMarketService.d.mts +0 -45
- package/dist/services/TerminalMarketService.d.mts.map +0 -1
- package/dist/services/TerminalMarketService.mjs +0 -619
- package/dist/services/TerminalMarketService.mjs.map +0 -1
- package/dist/services/TradingReadinessCache.cjs +0 -329
- package/dist/services/TradingReadinessCache.cjs.map +0 -1
- package/dist/services/TradingReadinessCache.d.cts +0 -204
- package/dist/services/TradingReadinessCache.d.cts.map +0 -1
- package/dist/services/TradingReadinessCache.d.mts +0 -204
- package/dist/services/TradingReadinessCache.d.mts.map +0 -1
- package/dist/services/TradingReadinessCache.mjs +0 -326
- package/dist/services/TradingReadinessCache.mjs.map +0 -1
- package/dist/services/TradingService.cjs +0 -1895
- package/dist/services/TradingService.cjs.map +0 -1
- package/dist/services/TradingService.d.cts +0 -201
- package/dist/services/TradingService.d.cts.map +0 -1
- package/dist/services/TradingService.d.mts +0 -201
- package/dist/services/TradingService.d.mts.map +0 -1
- package/dist/services/TradingService.mjs +0 -1891
- package/dist/services/TradingService.mjs.map +0 -1
- package/dist/types/config.cjs +0 -3
- package/dist/types/config.cjs.map +0 -1
- package/dist/types/config.d.cts +0 -49
- package/dist/types/config.d.cts.map +0 -1
- package/dist/types/config.d.mts +0 -49
- package/dist/types/config.d.mts.map +0 -1
- package/dist/types/config.mjs +0 -2
- package/dist/types/config.mjs.map +0 -1
- package/dist/types/hyperliquid-types.cjs +0 -45
- package/dist/types/hyperliquid-types.cjs.map +0 -1
- package/dist/types/hyperliquid-types.d.cts +0 -67
- package/dist/types/hyperliquid-types.d.cts.map +0 -1
- package/dist/types/hyperliquid-types.d.mts +0 -67
- package/dist/types/hyperliquid-types.d.mts.map +0 -1
- package/dist/types/hyperliquid-types.mjs +0 -41
- package/dist/types/hyperliquid-types.mjs.map +0 -1
- package/dist/types/index.cjs +0 -151
- package/dist/types/index.cjs.map +0 -1
- package/dist/types/index.d.cts +0 -2183
- package/dist/types/index.d.cts.map +0 -1
- package/dist/types/index.d.mts +0 -2183
- package/dist/types/index.d.mts.map +0 -1
- package/dist/types/index.mjs +0 -133
- package/dist/types/index.mjs.map +0 -1
- package/dist/types/lighter-types.cjs +0 -11
- package/dist/types/lighter-types.cjs.map +0 -1
- package/dist/types/lighter-types.d.cts +0 -763
- package/dist/types/lighter-types.d.cts.map +0 -1
- package/dist/types/lighter-types.d.mts +0 -763
- package/dist/types/lighter-types.d.mts.map +0 -1
- package/dist/types/lighter-types.mjs +0 -10
- package/dist/types/lighter-types.mjs.map +0 -1
- package/dist/types/messenger.cjs +0 -3
- package/dist/types/messenger.cjs.map +0 -1
- package/dist/types/messenger.d.cts +0 -30
- package/dist/types/messenger.d.cts.map +0 -1
- package/dist/types/messenger.d.mts +0 -30
- package/dist/types/messenger.d.mts.map +0 -1
- package/dist/types/messenger.mjs +0 -2
- package/dist/types/messenger.mjs.map +0 -1
- package/dist/types/perps-types.cjs +0 -7
- package/dist/types/perps-types.cjs.map +0 -1
- package/dist/types/perps-types.d.cts +0 -184
- package/dist/types/perps-types.d.cts.map +0 -1
- package/dist/types/perps-types.d.mts +0 -184
- package/dist/types/perps-types.d.mts.map +0 -1
- package/dist/types/perps-types.mjs +0 -5
- package/dist/types/perps-types.mjs.map +0 -1
- package/dist/types/token.cjs +0 -3
- package/dist/types/token.cjs.map +0 -1
- package/dist/types/token.d.cts +0 -25
- package/dist/types/token.d.cts.map +0 -1
- package/dist/types/token.d.mts +0 -25
- package/dist/types/token.d.mts.map +0 -1
- package/dist/types/token.mjs +0 -2
- package/dist/types/token.mjs.map +0 -1
- package/dist/types/transactionTypes.cjs +0 -29
- package/dist/types/transactionTypes.cjs.map +0 -1
- package/dist/types/transactionTypes.d.cts +0 -60
- package/dist/types/transactionTypes.d.cts.map +0 -1
- package/dist/types/transactionTypes.d.mts +0 -60
- package/dist/types/transactionTypes.d.mts.map +0 -1
- package/dist/types/transactionTypes.mjs +0 -24
- package/dist/types/transactionTypes.mjs.map +0 -1
- package/dist/utils/accountUtils.cjs +0 -236
- package/dist/utils/accountUtils.cjs.map +0 -1
- package/dist/utils/accountUtils.d.cts +0 -72
- package/dist/utils/accountUtils.d.cts.map +0 -1
- package/dist/utils/accountUtils.d.mts +0 -72
- package/dist/utils/accountUtils.d.mts.map +0 -1
- package/dist/utils/accountUtils.mjs +0 -223
- package/dist/utils/accountUtils.mjs.map +0 -1
- package/dist/utils/capabilitySymbols.cjs +0 -25
- package/dist/utils/capabilitySymbols.cjs.map +0 -1
- package/dist/utils/capabilitySymbols.d.cts +0 -15
- package/dist/utils/capabilitySymbols.d.cts.map +0 -1
- package/dist/utils/capabilitySymbols.d.mts +0 -15
- package/dist/utils/capabilitySymbols.d.mts.map +0 -1
- package/dist/utils/capabilitySymbols.mjs +0 -21
- package/dist/utils/capabilitySymbols.mjs.map +0 -1
- package/dist/utils/coalescePerpsRestRequest.cjs +0 -71
- package/dist/utils/coalescePerpsRestRequest.cjs.map +0 -1
- package/dist/utils/coalescePerpsRestRequest.d.cts +0 -32
- package/dist/utils/coalescePerpsRestRequest.d.cts.map +0 -1
- package/dist/utils/coalescePerpsRestRequest.d.mts +0 -32
- package/dist/utils/coalescePerpsRestRequest.d.mts.map +0 -1
- package/dist/utils/coalescePerpsRestRequest.mjs +0 -66
- package/dist/utils/coalescePerpsRestRequest.mjs.map +0 -1
- package/dist/utils/errorUtils.cjs +0 -104
- package/dist/utils/errorUtils.cjs.map +0 -1
- package/dist/utils/errorUtils.d.cts +0 -50
- package/dist/utils/errorUtils.d.cts.map +0 -1
- package/dist/utils/errorUtils.d.mts +0 -50
- package/dist/utils/errorUtils.d.mts.map +0 -1
- package/dist/utils/errorUtils.mjs +0 -96
- package/dist/utils/errorUtils.mjs.map +0 -1
- package/dist/utils/hyperLiquidAbstraction.cjs +0 -23
- package/dist/utils/hyperLiquidAbstraction.cjs.map +0 -1
- package/dist/utils/hyperLiquidAbstraction.d.cts +0 -11
- package/dist/utils/hyperLiquidAbstraction.d.cts.map +0 -1
- package/dist/utils/hyperLiquidAbstraction.d.mts +0 -11
- package/dist/utils/hyperLiquidAbstraction.d.mts.map +0 -1
- package/dist/utils/hyperLiquidAbstraction.mjs +0 -19
- package/dist/utils/hyperLiquidAbstraction.mjs.map +0 -1
- package/dist/utils/hyperLiquidAdapter.cjs +0 -512
- package/dist/utils/hyperLiquidAdapter.cjs.map +0 -1
- package/dist/utils/hyperLiquidAdapter.d.cts +0 -77
- package/dist/utils/hyperLiquidAdapter.d.cts.map +0 -1
- package/dist/utils/hyperLiquidAdapter.d.mts +0 -77
- package/dist/utils/hyperLiquidAdapter.d.mts.map +0 -1
- package/dist/utils/hyperLiquidAdapter.mjs +0 -494
- package/dist/utils/hyperLiquidAdapter.mjs.map +0 -1
- package/dist/utils/hyperLiquidOrderBookProcessor.cjs +0 -83
- package/dist/utils/hyperLiquidOrderBookProcessor.cjs.map +0 -1
- package/dist/utils/hyperLiquidOrderBookProcessor.d.cts +0 -55
- package/dist/utils/hyperLiquidOrderBookProcessor.d.cts.map +0 -1
- package/dist/utils/hyperLiquidOrderBookProcessor.d.mts +0 -55
- package/dist/utils/hyperLiquidOrderBookProcessor.d.mts.map +0 -1
- package/dist/utils/hyperLiquidOrderBookProcessor.mjs +0 -78
- package/dist/utils/hyperLiquidOrderBookProcessor.mjs.map +0 -1
- package/dist/utils/hyperLiquidPositionPreview.cjs +0 -355
- package/dist/utils/hyperLiquidPositionPreview.cjs.map +0 -1
- package/dist/utils/hyperLiquidPositionPreview.d.cts +0 -124
- package/dist/utils/hyperLiquidPositionPreview.d.cts.map +0 -1
- package/dist/utils/hyperLiquidPositionPreview.d.mts +0 -124
- package/dist/utils/hyperLiquidPositionPreview.d.mts.map +0 -1
- package/dist/utils/hyperLiquidPositionPreview.mjs +0 -347
- package/dist/utils/hyperLiquidPositionPreview.mjs.map +0 -1
- package/dist/utils/hyperLiquidValidation.cjs +0 -799
- package/dist/utils/hyperLiquidValidation.cjs.map +0 -1
- package/dist/utils/hyperLiquidValidation.d.cts +0 -192
- package/dist/utils/hyperLiquidValidation.d.cts.map +0 -1
- package/dist/utils/hyperLiquidValidation.d.mts +0 -192
- package/dist/utils/hyperLiquidValidation.d.mts.map +0 -1
- package/dist/utils/hyperLiquidValidation.mjs +0 -786
- package/dist/utils/hyperLiquidValidation.mjs.map +0 -1
- package/dist/utils/idUtils.cjs +0 -18
- package/dist/utils/idUtils.cjs.map +0 -1
- package/dist/utils/idUtils.d.cts +0 -6
- package/dist/utils/idUtils.d.cts.map +0 -1
- package/dist/utils/idUtils.d.mts +0 -6
- package/dist/utils/idUtils.d.mts.map +0 -1
- package/dist/utils/idUtils.mjs +0 -10
- package/dist/utils/idUtils.mjs.map +0 -1
- package/dist/utils/index.cjs +0 -66
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.d.cts +0 -29
- package/dist/utils/index.d.cts.map +0 -1
- package/dist/utils/index.d.mts +0 -29
- package/dist/utils/index.d.mts.map +0 -1
- package/dist/utils/index.mjs +0 -34
- package/dist/utils/index.mjs.map +0 -1
- package/dist/utils/lighterAdapter.cjs +0 -575
- package/dist/utils/lighterAdapter.cjs.map +0 -1
- package/dist/utils/lighterAdapter.d.cts +0 -117
- package/dist/utils/lighterAdapter.d.cts.map +0 -1
- package/dist/utils/lighterAdapter.d.mts +0 -117
- package/dist/utils/lighterAdapter.d.mts.map +0 -1
- package/dist/utils/lighterAdapter.mjs +0 -562
- package/dist/utils/lighterAdapter.mjs.map +0 -1
- package/dist/utils/marketDataTransform.cjs +0 -250
- package/dist/utils/marketDataTransform.cjs.map +0 -1
- package/dist/utils/marketDataTransform.d.cts +0 -71
- package/dist/utils/marketDataTransform.d.cts.map +0 -1
- package/dist/utils/marketDataTransform.d.mts +0 -71
- package/dist/utils/marketDataTransform.d.mts.map +0 -1
- package/dist/utils/marketDataTransform.mjs +0 -243
- package/dist/utils/marketDataTransform.mjs.map +0 -1
- package/dist/utils/marketSearch.cjs +0 -111
- package/dist/utils/marketSearch.cjs.map +0 -1
- package/dist/utils/marketSearch.d.cts +0 -48
- package/dist/utils/marketSearch.d.cts.map +0 -1
- package/dist/utils/marketSearch.d.mts +0 -48
- package/dist/utils/marketSearch.d.mts.map +0 -1
- package/dist/utils/marketSearch.mjs +0 -106
- package/dist/utils/marketSearch.mjs.map +0 -1
- package/dist/utils/marketUtils.cjs +0 -266
- package/dist/utils/marketUtils.cjs.map +0 -1
- package/dist/utils/marketUtils.d.cts +0 -73
- package/dist/utils/marketUtils.d.cts.map +0 -1
- package/dist/utils/marketUtils.d.mts +0 -73
- package/dist/utils/marketUtils.d.mts.map +0 -1
- package/dist/utils/marketUtils.mjs +0 -248
- package/dist/utils/marketUtils.mjs.map +0 -1
- package/dist/utils/orderCalculations.cjs +0 -849
- package/dist/utils/orderCalculations.cjs.map +0 -1
- package/dist/utils/orderCalculations.d.cts +0 -306
- package/dist/utils/orderCalculations.d.cts.map +0 -1
- package/dist/utils/orderCalculations.d.mts +0 -306
- package/dist/utils/orderCalculations.d.mts.map +0 -1
- package/dist/utils/orderCalculations.mjs +0 -833
- package/dist/utils/orderCalculations.mjs.map +0 -1
- package/dist/utils/orderTypes.cjs +0 -301
- package/dist/utils/orderTypes.cjs.map +0 -1
- package/dist/utils/orderTypes.d.cts +0 -166
- package/dist/utils/orderTypes.d.cts.map +0 -1
- package/dist/utils/orderTypes.d.mts +0 -166
- package/dist/utils/orderTypes.d.mts.map +0 -1
- package/dist/utils/orderTypes.mjs +0 -287
- package/dist/utils/orderTypes.mjs.map +0 -1
- package/dist/utils/perpsConnectionAttemptContext.cjs +0 -20
- package/dist/utils/perpsConnectionAttemptContext.cjs.map +0 -1
- package/dist/utils/perpsConnectionAttemptContext.d.cts +0 -7
- package/dist/utils/perpsConnectionAttemptContext.d.cts.map +0 -1
- package/dist/utils/perpsConnectionAttemptContext.d.mts +0 -7
- package/dist/utils/perpsConnectionAttemptContext.d.mts.map +0 -1
- package/dist/utils/perpsConnectionAttemptContext.mjs +0 -15
- package/dist/utils/perpsConnectionAttemptContext.mjs.map +0 -1
- package/dist/utils/perpsDiskPersistence.cjs +0 -259
- package/dist/utils/perpsDiskPersistence.cjs.map +0 -1
- package/dist/utils/perpsDiskPersistence.d.cts +0 -112
- package/dist/utils/perpsDiskPersistence.d.cts.map +0 -1
- package/dist/utils/perpsDiskPersistence.d.mts +0 -112
- package/dist/utils/perpsDiskPersistence.d.mts.map +0 -1
- package/dist/utils/perpsDiskPersistence.mjs +0 -251
- package/dist/utils/perpsDiskPersistence.mjs.map +0 -1
- package/dist/utils/perpsFormatters.cjs +0 -509
- package/dist/utils/perpsFormatters.cjs.map +0 -1
- package/dist/utils/perpsFormatters.d.cts +0 -204
- package/dist/utils/perpsFormatters.d.cts.map +0 -1
- package/dist/utils/perpsFormatters.d.mts +0 -204
- package/dist/utils/perpsFormatters.d.mts.map +0 -1
- package/dist/utils/perpsFormatters.mjs +0 -500
- package/dist/utils/perpsFormatters.mjs.map +0 -1
- package/dist/utils/rewardsUtils.cjs +0 -98
- package/dist/utils/rewardsUtils.cjs.map +0 -1
- package/dist/utils/rewardsUtils.d.cts +0 -33
- package/dist/utils/rewardsUtils.d.cts.map +0 -1
- package/dist/utils/rewardsUtils.d.mts +0 -33
- package/dist/utils/rewardsUtils.d.mts.map +0 -1
- package/dist/utils/rewardsUtils.mjs +0 -92
- package/dist/utils/rewardsUtils.mjs.map +0 -1
- package/dist/utils/significantFigures.cjs +0 -88
- package/dist/utils/significantFigures.cjs.map +0 -1
- package/dist/utils/significantFigures.d.cts +0 -25
- package/dist/utils/significantFigures.d.cts.map +0 -1
- package/dist/utils/significantFigures.d.mts +0 -25
- package/dist/utils/significantFigures.d.mts.map +0 -1
- package/dist/utils/significantFigures.mjs +0 -82
- package/dist/utils/significantFigures.mjs.map +0 -1
- package/dist/utils/sortMarkets.cjs +0 -93
- package/dist/utils/sortMarkets.cjs.map +0 -1
- package/dist/utils/sortMarkets.d.cts +0 -25
- package/dist/utils/sortMarkets.d.cts.map +0 -1
- package/dist/utils/sortMarkets.d.mts +0 -25
- package/dist/utils/sortMarkets.d.mts.map +0 -1
- package/dist/utils/sortMarkets.mjs +0 -88
- package/dist/utils/sortMarkets.mjs.map +0 -1
- package/dist/utils/standaloneInfoClient.cjs +0 -70
- package/dist/utils/standaloneInfoClient.cjs.map +0 -1
- package/dist/utils/standaloneInfoClient.d.cts +0 -37
- package/dist/utils/standaloneInfoClient.d.cts.map +0 -1
- package/dist/utils/standaloneInfoClient.d.mts +0 -37
- package/dist/utils/standaloneInfoClient.d.mts.map +0 -1
- package/dist/utils/standaloneInfoClient.mjs +0 -64
- package/dist/utils/standaloneInfoClient.mjs.map +0 -1
- package/dist/utils/stringParseUtils.cjs +0 -34
- package/dist/utils/stringParseUtils.cjs.map +0 -1
- package/dist/utils/stringParseUtils.d.cts +0 -11
- package/dist/utils/stringParseUtils.d.cts.map +0 -1
- package/dist/utils/stringParseUtils.d.mts +0 -11
- package/dist/utils/stringParseUtils.d.mts.map +0 -1
- package/dist/utils/stringParseUtils.mjs +0 -28
- package/dist/utils/stringParseUtils.mjs.map +0 -1
- package/dist/utils/transferData.cjs +0 -33
- package/dist/utils/transferData.cjs.map +0 -1
- package/dist/utils/transferData.d.cts +0 -9
- package/dist/utils/transferData.d.cts.map +0 -1
- package/dist/utils/transferData.d.mts +0 -9
- package/dist/utils/transferData.d.mts.map +0 -1
- package/dist/utils/transferData.mjs +0 -29
- package/dist/utils/transferData.mjs.map +0 -1
- package/dist/utils/wait.cjs +0 -6
- package/dist/utils/wait.cjs.map +0 -1
- package/dist/utils/wait.d.cts +0 -2
- package/dist/utils/wait.d.cts.map +0 -1
- package/dist/utils/wait.d.mts +0 -2
- package/dist/utils/wait.d.mts.map +0 -1
- package/dist/utils/wait.mjs +0 -2
- package/dist/utils/wait.mjs.map +0 -1
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { PERPS_CONSTANTS } from '../constants/perpsConfig.js';
|
|
2
|
+
const EVM_ACCOUNT_TYPES = new Set(['eip155:eoa', 'eip155:erc4337']);
|
|
3
|
+
function isEvmAccountType(type) {
|
|
4
|
+
return EVM_ACCOUNT_TYPES.has(type);
|
|
5
|
+
}
|
|
6
|
+
export function findEvmAccount(accounts) {
|
|
7
|
+
const evmAccount = accounts.find((account) => account && isEvmAccountType(account.type));
|
|
8
|
+
return evmAccount ?? null;
|
|
9
|
+
}
|
|
10
|
+
export function getEvmAccountFromAccountGroup(accounts) {
|
|
11
|
+
const evmAccount = findEvmAccount(accounts);
|
|
12
|
+
return evmAccount ? { address: evmAccount.address } : undefined;
|
|
13
|
+
}
|
|
14
|
+
export function getSelectedEvmAccount(accounts) {
|
|
15
|
+
return getEvmAccountFromAccountGroup(accounts);
|
|
16
|
+
}
|
|
17
|
+
function isAccountLike(value) {
|
|
18
|
+
const account = value;
|
|
19
|
+
return (typeof value === 'object' &&
|
|
20
|
+
value !== null &&
|
|
21
|
+
typeof account?.address === 'string' &&
|
|
22
|
+
typeof account.type === 'string');
|
|
23
|
+
}
|
|
24
|
+
export function getSelectedEvmAccountDetailsFromMessenger(messenger) {
|
|
25
|
+
try {
|
|
26
|
+
const selectedAccount = messenger.call('AccountsController:getSelectedAccount');
|
|
27
|
+
if (isAccountLike(selectedAccount)) {
|
|
28
|
+
const evmAccount = findEvmAccount([selectedAccount]);
|
|
29
|
+
if (evmAccount) {
|
|
30
|
+
return evmAccount;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// Fall back to the selected account group if the direct lookup is unavailable.
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const selectedAccountGroup = messenger.call('AccountTreeController:getAccountsFromSelectedAccountGroup');
|
|
39
|
+
return Array.isArray(selectedAccountGroup)
|
|
40
|
+
? (findEvmAccount(selectedAccountGroup.filter(isAccountLike)) ??
|
|
41
|
+
undefined)
|
|
42
|
+
: undefined;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export function getSelectedEvmAccountFromMessenger(messenger) {
|
|
49
|
+
const evmAccount = getSelectedEvmAccountDetailsFromMessenger(messenger);
|
|
50
|
+
return evmAccount ? { address: evmAccount.address } : undefined;
|
|
51
|
+
}
|
|
52
|
+
export function calculateWeightedReturnOnEquity(accounts) {
|
|
53
|
+
if (accounts.length === 0) {
|
|
54
|
+
return '0';
|
|
55
|
+
}
|
|
56
|
+
let totalWeightedROE = 0;
|
|
57
|
+
let totalMarginUsed = 0;
|
|
58
|
+
for (const account of accounts) {
|
|
59
|
+
const unrealizedPnl = typeof account.unrealizedPnl === 'string'
|
|
60
|
+
? Number.parseFloat(account.unrealizedPnl)
|
|
61
|
+
: account.unrealizedPnl;
|
|
62
|
+
const returnOnEquity = typeof account.returnOnEquity === 'string'
|
|
63
|
+
? Number.parseFloat(account.returnOnEquity)
|
|
64
|
+
: account.returnOnEquity;
|
|
65
|
+
if (Number.isNaN(unrealizedPnl) || Number.isNaN(returnOnEquity)) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (returnOnEquity === 0) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const marginUsed = (unrealizedPnl / returnOnEquity) * 100;
|
|
72
|
+
if (Number.isNaN(marginUsed) || marginUsed <= 0) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const roeDecimal = returnOnEquity / 100;
|
|
76
|
+
totalWeightedROE += roeDecimal * marginUsed;
|
|
77
|
+
totalMarginUsed += marginUsed;
|
|
78
|
+
}
|
|
79
|
+
if (totalMarginUsed <= 0) {
|
|
80
|
+
return '0';
|
|
81
|
+
}
|
|
82
|
+
const weightedROE = (totalWeightedROE / totalMarginUsed) * 100;
|
|
83
|
+
return weightedROE.toString();
|
|
84
|
+
}
|
|
85
|
+
// The release-branch balance bridge is USDC-only. Non-USDC spot assets must
|
|
86
|
+
// not inflate the balances shown or validated by withdraw/payment flows.
|
|
87
|
+
const SPOT_COLLATERAL_COINS = new Set(['USDC']);
|
|
88
|
+
export function getSpotBalance(spotState) {
|
|
89
|
+
if (!spotState?.balances || !Array.isArray(spotState.balances)) {
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
return spotState.balances.reduce((sum, balance) => {
|
|
93
|
+
if (!balance.coin || !SPOT_COLLATERAL_COINS.has(balance.coin)) {
|
|
94
|
+
return sum;
|
|
95
|
+
}
|
|
96
|
+
const value = parseFloat(balance.total ?? '0');
|
|
97
|
+
return Number.isFinite(value) ? sum + value : sum;
|
|
98
|
+
}, 0);
|
|
99
|
+
}
|
|
100
|
+
export function getSpotHold(spotState) {
|
|
101
|
+
if (!spotState?.balances || !Array.isArray(spotState.balances)) {
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
104
|
+
return spotState.balances.reduce((sum, balance) => {
|
|
105
|
+
if (!balance.coin || !SPOT_COLLATERAL_COINS.has(balance.coin)) {
|
|
106
|
+
return sum;
|
|
107
|
+
}
|
|
108
|
+
const value = parseFloat(balance.hold ?? '0');
|
|
109
|
+
return Number.isFinite(value) ? sum + value : sum;
|
|
110
|
+
}, 0);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Add spot USDC to the AccountState contract. Caller decides whether the
|
|
114
|
+
* spot balance counts as perps collateral via `options.foldIntoCollateral`
|
|
115
|
+
* — the util stays provider-agnostic.
|
|
116
|
+
*
|
|
117
|
+
* @param accountState - Base AccountState produced by a provider adapter.
|
|
118
|
+
* @param spotState - Raw spot clearinghouse response (HL-shaped); null or missing means no spot balance and the state is returned unchanged.
|
|
119
|
+
* @param options - See {@link AddSpotBalanceOptions}.
|
|
120
|
+
* @returns AccountState with spot folded into `totalBalance` always, and into spendable/withdrawable when `foldIntoCollateral` is true.
|
|
121
|
+
*/
|
|
122
|
+
export function addSpotBalanceToAccountState(accountState, spotState, options) {
|
|
123
|
+
// Fail-closed default: align with `hyperLiquidModeFoldsSpot(null) → false`.
|
|
124
|
+
// A caller that omits `options` should NOT silently fold spot — that would
|
|
125
|
+
// over-report withdrawable funds for Standard / dexAbstraction users.
|
|
126
|
+
const foldIntoCollateral = options?.foldIntoCollateral ?? false;
|
|
127
|
+
const spotBalance = getSpotBalance(spotState);
|
|
128
|
+
const spotHold = getSpotHold(spotState);
|
|
129
|
+
const freeSpot = Math.max(0, spotBalance - spotHold);
|
|
130
|
+
const currentTotal = parseFloat(accountState.totalBalance);
|
|
131
|
+
const currentSpendable = parseFloat(accountState.spendableBalance);
|
|
132
|
+
const currentWithdrawable = parseFloat(accountState.withdrawableBalance);
|
|
133
|
+
// Preserve sentinel totals (e.g. PERPS_CONSTANTS.FallbackDataDisplay '--')
|
|
134
|
+
// rather than coercing them to NaN.
|
|
135
|
+
if (!Number.isFinite(currentTotal)) {
|
|
136
|
+
return accountState;
|
|
137
|
+
}
|
|
138
|
+
if (spotBalance === 0) {
|
|
139
|
+
// No spot wealth means no hold either in the HL payload shape, so the
|
|
140
|
+
// later totalBalance adjustment would also be a no-op.
|
|
141
|
+
return accountState;
|
|
142
|
+
}
|
|
143
|
+
// Folding is gated strictly on the resolved abstraction mode (see callers'
|
|
144
|
+
// `foldIntoCollateral` argument). Standard / DEX-abstraction users keep
|
|
145
|
+
// perps and spot independent, so spot must NOT surface as a perps-
|
|
146
|
+
// withdrawable balance for them — withdraw3 only draws from the perps
|
|
147
|
+
// ledger in those modes. Unified / portfolio-margin users get the fold;
|
|
148
|
+
// live callers fail-CLOSED via `hyperLiquidModeFoldsSpot` when mode is
|
|
149
|
+
// unresolved.
|
|
150
|
+
const nextSpendable = resolveFoldedBalance(currentSpendable, accountState.spendableBalance, freeSpot, foldIntoCollateral);
|
|
151
|
+
const nextWithdrawable = resolveFoldedBalance(currentWithdrawable, accountState.withdrawableBalance, freeSpot, foldIntoCollateral);
|
|
152
|
+
// Total always reflects combined wealth: subtract spotHold to avoid
|
|
153
|
+
// double-counting on Unified/PM accounts where marginSummary.accountValue
|
|
154
|
+
// already includes the margin that HL surfaces via spot.hold. Standard
|
|
155
|
+
// mode has spotHold = 0 by construction, so the subtraction is a no-op.
|
|
156
|
+
const nextTotal = currentTotal + spotBalance - spotHold;
|
|
157
|
+
return {
|
|
158
|
+
...accountState,
|
|
159
|
+
totalBalance: nextTotal.toString(),
|
|
160
|
+
spendableBalance: nextSpendable,
|
|
161
|
+
withdrawableBalance: nextWithdrawable,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function resolveFoldedBalance(currentNumeric, currentRaw, freeSpot, foldIntoCollateral) {
|
|
165
|
+
if (!foldIntoCollateral) {
|
|
166
|
+
return currentRaw;
|
|
167
|
+
}
|
|
168
|
+
if (Number.isFinite(currentNumeric)) {
|
|
169
|
+
return (currentNumeric + freeSpot).toString();
|
|
170
|
+
}
|
|
171
|
+
// Non-finite currentNumeric means the adapter passed a sentinel like
|
|
172
|
+
// `PERPS_CONSTANTS.FallbackDataDisplay` ("--") during loading. Preserve
|
|
173
|
+
// the sentinel rather than synthesising a numeric fold; the caller's
|
|
174
|
+
// UI treats "--" as "loading" and would otherwise show a misleading
|
|
175
|
+
// spot-only figure while the per-DEX perps fetch is still in flight.
|
|
176
|
+
return currentRaw;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Aggregate multiple per-DEX AccountState objects into one by summing numeric fields.
|
|
180
|
+
* ROE is recalculated as (totalUnrealizedPnl / totalMarginUsed) * 100.
|
|
181
|
+
*
|
|
182
|
+
* @param states - The array of per-DEX account states to aggregate.
|
|
183
|
+
* @returns The combined account state with summed balances and recalculated ROE.
|
|
184
|
+
*/
|
|
185
|
+
export function aggregateAccountStates(states) {
|
|
186
|
+
const fallback = {
|
|
187
|
+
spendableBalance: PERPS_CONSTANTS.FallbackDataDisplay,
|
|
188
|
+
withdrawableBalance: PERPS_CONSTANTS.FallbackDataDisplay,
|
|
189
|
+
totalBalance: PERPS_CONSTANTS.FallbackDataDisplay,
|
|
190
|
+
marginUsed: PERPS_CONSTANTS.FallbackDataDisplay,
|
|
191
|
+
unrealizedPnl: PERPS_CONSTANTS.FallbackDataDisplay,
|
|
192
|
+
returnOnEquity: PERPS_CONSTANTS.FallbackDataDisplay,
|
|
193
|
+
};
|
|
194
|
+
if (states.length === 0) {
|
|
195
|
+
return fallback;
|
|
196
|
+
}
|
|
197
|
+
const aggregated = states.reduce((acc, state, index) => {
|
|
198
|
+
if (index === 0) {
|
|
199
|
+
return { ...state };
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
spendableBalance: (parseFloat(acc.spendableBalance) + parseFloat(state.spendableBalance)).toString(),
|
|
203
|
+
withdrawableBalance: (parseFloat(acc.withdrawableBalance) +
|
|
204
|
+
parseFloat(state.withdrawableBalance)).toString(),
|
|
205
|
+
totalBalance: (parseFloat(acc.totalBalance) + parseFloat(state.totalBalance)).toString(),
|
|
206
|
+
marginUsed: (parseFloat(acc.marginUsed) + parseFloat(state.marginUsed)).toString(),
|
|
207
|
+
unrealizedPnl: (parseFloat(acc.unrealizedPnl) + parseFloat(state.unrealizedPnl)).toString(),
|
|
208
|
+
returnOnEquity: '0',
|
|
209
|
+
};
|
|
210
|
+
}, fallback);
|
|
211
|
+
// Recalculate ROE across all DEXs
|
|
212
|
+
const totalMarginUsed = parseFloat(aggregated.marginUsed);
|
|
213
|
+
const totalUnrealizedPnl = parseFloat(aggregated.unrealizedPnl);
|
|
214
|
+
if (totalMarginUsed > 0) {
|
|
215
|
+
aggregated.returnOnEquity = ((totalUnrealizedPnl / totalMarginUsed) *
|
|
216
|
+
100).toString();
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
aggregated.returnOnEquity = '0';
|
|
220
|
+
}
|
|
221
|
+
return aggregated;
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=accountUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountUtils.js","sourceRoot":"","sources":["../../src/utils/accountUtils.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAI9D,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAEpE,SAAS,gBAAgB,CAAC,IAAY;IACpC,OAAO,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,QAAoD;IAEpD,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAC9B,CAAC,OAAO,EAAE,EAAE,CACV,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,IAA+B,CAAC,CACvE,CAAC;IACF,OAAO,UAAU,IAAI,IAAI,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,6BAA6B,CAC3C,QAAoD;IAEpD,MAAM,UAAU,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC5C,OAAO,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,QAAoD;IAEpD,OAAO,6BAA6B,CAAC,QAAQ,CAAC,CAAC;AACjD,CAAC;AAUD,SAAS,aAAa,CACpB,KAAc;IAEd,MAAM,O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ACN,UAAU,CAAC,cAAc,GAAG,GAAG,CAAC;IAClC,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["/**\n * Account utilities for Perps components\n * Handles account selection and EVM account filtering\n */\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { PERPS_CONSTANTS } from '../constants/perpsConfig.js';\nimport type { SpotClearinghouseStateResponse } from '../types/hyperliquid-types.js';\nimport type { AccountState, PerpsInternalAccount } from '../types/index.js';\n\nconst EVM_ACCOUNT_TYPES = new Set(['eip155:eoa', 'eip155:erc4337']);\n\nfunction isEvmAccountType(type: string): boolean {\n return EVM_ACCOUNT_TYPES.has(type);\n}\n\nexport function findEvmAccount(\n accounts: (InternalAccount | PerpsInternalAccount)[],\n): InternalAccount | PerpsInternalAccount | null {\n const evmAccount = accounts.find(\n (account) =>\n account && isEvmAccountType(account.type as InternalAccount['type']),\n );\n return evmAccount ?? null;\n}\n\nexport function getEvmAccountFromAccountGroup(\n accounts: (InternalAccount | PerpsInternalAccount)[],\n): { address: string } | undefined {\n const evmAccount = findEvmAccount(accounts);\n return evmAccount ? { address: evmAccount.address } : undefined;\n}\n\nexport function getSelectedEvmAccount(\n accounts: (InternalAccount | PerpsInternalAccount)[],\n): { address: string } | undefined {\n return getEvmAccountFromAccountGroup(accounts);\n}\n\ntype SelectedEvmAccountMessenger = {\n call(\n actionType:\n | 'AccountsController:getSelectedAccount'\n | 'AccountTreeController:getAccountsFromSelectedAccountGroup',\n ): unknown;\n};\n\nfunction isAccountLike(\n value: unknown,\n): value is InternalAccount | PerpsInternalAccount {\n const account = value as { address?: unknown; type?: unknown } | null;\n\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof account?.address === 'string' &&\n typeof account.type === 'string'\n );\n}\n\nexport function getSelectedEvmAccountDetailsFromMessenger(\n messenger: SelectedEvmAccountMessenger,\n): InternalAccount | PerpsInternalAccount | undefined {\n try {\n const selectedAccount = messenger.call(\n 'AccountsController:getSelectedAccount',\n );\n if (isAccountLike(selectedAccount)) {\n const evmAccount = findEvmAccount([selectedAccount]);\n if (evmAccount) {\n return evmAccount;\n }\n }\n } catch {\n // Fall back to the selected account group if the direct lookup is unavailable.\n }\n\n try {\n const selectedAccountGroup = messenger.call(\n 'AccountTreeController:getAccountsFromSelectedAccountGroup',\n );\n return Array.isArray(selectedAccountGroup)\n ? (findEvmAccount(selectedAccountGroup.filter(isAccountLike)) ??\n undefined)\n : undefined;\n } catch {\n return undefined;\n }\n}\n\nexport function getSelectedEvmAccountFromMessenger(\n messenger: SelectedEvmAccountMessenger,\n): { address: string } | undefined {\n const evmAccount = getSelectedEvmAccountDetailsFromMessenger(messenger);\n\n return evmAccount ? { address: evmAccount.address } : undefined;\n}\n\nexport type ReturnOnEquityInput = {\n unrealizedPnl: string | number;\n returnOnEquity: string | number;\n};\n\nexport function calculateWeightedReturnOnEquity(\n accounts: ReturnOnEquityInput[],\n): string {\n if (accounts.length === 0) {\n return '0';\n }\n\n let totalWeightedROE = 0;\n let totalMarginUsed = 0;\n\n for (const account of accounts) {\n const unrealizedPnl =\n typeof account.unrealizedPnl === 'string'\n ? Number.parseFloat(account.unrealizedPnl)\n : account.unrealizedPnl;\n const returnOnEquity =\n typeof account.returnOnEquity === 'string'\n ? Number.parseFloat(account.returnOnEquity)\n : account.returnOnEquity;\n\n if (Number.isNaN(unrealizedPnl) || Number.isNaN(returnOnEquity)) {\n continue;\n }\n\n if (returnOnEquity === 0) {\n continue;\n }\n\n const marginUsed = (unrealizedPnl / returnOnEquity) * 100;\n\n if (Number.isNaN(marginUsed) || marginUsed <= 0) {\n continue;\n }\n\n const roeDecimal = returnOnEquity / 100;\n\n totalWeightedROE += roeDecimal * marginUsed;\n totalMarginUsed += marginUsed;\n }\n\n if (totalMarginUsed <= 0) {\n return '0';\n }\n\n const weightedROE = (totalWeightedROE / totalMarginUsed) * 100;\n return weightedROE.toString();\n}\n\n// The release-branch balance bridge is USDC-only. Non-USDC spot assets must\n// not inflate the balances shown or validated by withdraw/payment flows.\nconst SPOT_COLLATERAL_COINS = new Set<string>(['USDC']);\n\nexport function getSpotBalance(\n spotState?: SpotClearinghouseStateResponse | null,\n): number {\n if (!spotState?.balances || !Array.isArray(spotState.balances)) {\n return 0;\n }\n\n return spotState.balances.reduce(\n (sum: number, balance: { coin?: string; total?: string }) => {\n if (!balance.coin || !SPOT_COLLATERAL_COINS.has(balance.coin)) {\n return sum;\n }\n const value = parseFloat(balance.total ?? '0');\n return Number.isFinite(value) ? sum + value : sum;\n },\n 0,\n );\n}\n\nexport function getSpotHold(\n spotState?: SpotClearinghouseStateResponse | null,\n): number {\n if (!spotState?.balances || !Array.isArray(spotState.balances)) {\n return 0;\n }\n\n return spotState.balances.reduce(\n (sum: number, balance: { coin?: string; hold?: string }) => {\n if (!balance.coin || !SPOT_COLLATERAL_COINS.has(balance.coin)) {\n return sum;\n }\n const value = parseFloat(balance.hold ?? '0');\n return Number.isFinite(value) ? sum + value : sum;\n },\n 0,\n );\n}\n\n/**\n * Options controlling how `addSpotBalanceToAccountState` folds spot balance\n * into the three-field AccountState contract.\n */\nexport type AddSpotBalanceOptions = {\n /**\n * When `true`, free spot USDC contributes to both `spendableBalance` and\n * `withdrawableBalance` in addition to `totalBalance` — appropriate for\n * venues where spot is automatically used as perps collateral (e.g.\n * HyperLiquid Unified/Portfolio mode, where `withdraw3` draws from the\n * unified ledger).\n *\n * When `false`, free spot contributes to `totalBalance` only; spendable\n * and withdrawable stay perps-only — appropriate for venues where spot\n * is a separate ledger the backend cannot auto-draw from (e.g. HL\n * Standard mode). The caller is responsible for translating\n * provider-specific state into this flag.\n *\n * Defaults to `true` for backward compatibility with call sites that\n * haven't yet been wired with provider-specific context.\n */\n foldIntoCollateral?: boolean;\n};\n\n/**\n * Add spot USDC to the AccountState contract. Caller decides whether the\n * spot balance counts as perps collateral via `options.foldIntoCollateral`\n * — the util stays provider-agnostic.\n *\n * @param accountState - Base AccountState produced by a provider adapter.\n * @param spotState - Raw spot clearinghouse response (HL-shaped); null or missing means no spot balance and the state is returned unchanged.\n * @param options - See {@link AddSpotBalanceOptions}.\n * @returns AccountState with spot folded into `totalBalance` always, and into spendable/withdrawable when `foldIntoCollateral` is true.\n */\nexport function addSpotBalanceToAccountState(\n accountState: AccountState,\n spotState?: SpotClearinghouseStateResponse | null,\n options?: AddSpotBalanceOptions,\n): AccountState {\n // Fail-closed default: align with `hyperLiquidModeFoldsSpot(null) → false`.\n // A caller that omits `options` should NOT silently fold spot — that would\n // over-report withdrawable funds for Standard / dexAbstraction users.\n const foldIntoCollateral = options?.foldIntoCollateral ?? false;\n\n const spotBalance = getSpotBalance(spotState);\n const spotHold = getSpotHold(spotState);\n const freeSpot = Math.max(0, spotBalance - spotHold);\n\n const currentTotal = parseFloat(accountState.totalBalance);\n const currentSpendable = parseFloat(accountState.spendableBalance);\n const currentWithdrawable = parseFloat(accountState.withdrawableBalance);\n\n // Preserve sentinel totals (e.g. PERPS_CONSTANTS.FallbackDataDisplay '--')\n // rather than coercing them to NaN.\n if (!Number.isFinite(currentTotal)) {\n return accountState;\n }\n\n if (spotBalance === 0) {\n // No spot wealth means no hold either in the HL payload shape, so the\n // later totalBalance adjustment would also be a no-op.\n return accountState;\n }\n\n // Folding is gated strictly on the resolved abstraction mode (see callers'\n // `foldIntoCollateral` argument). Standard / DEX-abstraction users keep\n // perps and spot independent, so spot must NOT surface as a perps-\n // withdrawable balance for them — withdraw3 only draws from the perps\n // ledger in those modes. Unified / portfolio-margin users get the fold;\n // live callers fail-CLOSED via `hyperLiquidModeFoldsSpot` when mode is\n // unresolved.\n const nextSpendable = resolveFoldedBalance(\n currentSpendable,\n accountState.spendableBalance,\n freeSpot,\n foldIntoCollateral,\n );\n const nextWithdrawable = resolveFoldedBalance(\n currentWithdrawable,\n accountState.withdrawableBalance,\n freeSpot,\n foldIntoCollateral,\n );\n\n // Total always reflects combined wealth: subtract spotHold to avoid\n // double-counting on Unified/PM accounts where marginSummary.accountValue\n // already includes the margin that HL surfaces via spot.hold. Standard\n // mode has spotHold = 0 by construction, so the subtraction is a no-op.\n const nextTotal = currentTotal + spotBalance - spotHold;\n\n return {\n ...accountState,\n totalBalance: nextTotal.toString(),\n spendableBalance: nextSpendable,\n withdrawableBalance: nextWithdrawable,\n };\n}\n\nfunction resolveFoldedBalance(\n currentNumeric: number,\n currentRaw: string,\n freeSpot: number,\n foldIntoCollateral: boolean,\n): string {\n if (!foldIntoCollateral) {\n return currentRaw;\n }\n if (Number.isFinite(currentNumeric)) {\n return (currentNumeric + freeSpot).toString();\n }\n // Non-finite currentNumeric means the adapter passed a sentinel like\n // `PERPS_CONSTANTS.FallbackDataDisplay` (\"--\") during loading. Preserve\n // the sentinel rather than synthesising a numeric fold; the caller's\n // UI treats \"--\" as \"loading\" and would otherwise show a misleading\n // spot-only figure while the per-DEX perps fetch is still in flight.\n return currentRaw;\n}\n\n/**\n * Aggregate multiple per-DEX AccountState objects into one by summing numeric fields.\n * ROE is recalculated as (totalUnrealizedPnl / totalMarginUsed) * 100.\n *\n * @param states - The array of per-DEX account states to aggregate.\n * @returns The combined account state with summed balances and recalculated ROE.\n */\nexport function aggregateAccountStates(states: AccountState[]): AccountState {\n const fallback: AccountState = {\n spendableBalance: PERPS_CONSTANTS.FallbackDataDisplay,\n withdrawableBalance: PERPS_CONSTANTS.FallbackDataDisplay,\n totalBalance: PERPS_CONSTANTS.FallbackDataDisplay,\n marginUsed: PERPS_CONSTANTS.FallbackDataDisplay,\n unrealizedPnl: PERPS_CONSTANTS.FallbackDataDisplay,\n returnOnEquity: PERPS_CONSTANTS.FallbackDataDisplay,\n };\n\n if (states.length === 0) {\n return fallback;\n }\n\n const aggregated = states.reduce<AccountState>((acc, state, index) => {\n if (index === 0) {\n return { ...state };\n }\n\n return {\n spendableBalance: (\n parseFloat(acc.spendableBalance) + parseFloat(state.spendableBalance)\n ).toString(),\n withdrawableBalance: (\n parseFloat(acc.withdrawableBalance) +\n parseFloat(state.withdrawableBalance)\n ).toString(),\n totalBalance: (\n parseFloat(acc.totalBalance) + parseFloat(state.totalBalance)\n ).toString(),\n marginUsed: (\n parseFloat(acc.marginUsed) + parseFloat(state.marginUsed)\n ).toString(),\n unrealizedPnl: (\n parseFloat(acc.unrealizedPnl) + parseFloat(state.unrealizedPnl)\n ).toString(),\n returnOnEquity: '0',\n };\n }, fallback);\n\n // Recalculate ROE across all DEXs\n const totalMarginUsed = parseFloat(aggregated.marginUsed);\n const totalUnrealizedPnl = parseFloat(aggregated.unrealizedPnl);\n if (totalMarginUsed > 0) {\n aggregated.returnOnEquity = (\n (totalUnrealizedPnl / totalMarginUsed) *\n 100\n ).toString();\n } else {\n aggregated.returnOnEquity = '0';\n }\n\n return aggregated;\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check whether a capability symbol has the provider-independent shape the
|
|
3
|
+
* caller allows.
|
|
4
|
+
*
|
|
5
|
+
* @param symbol - Market symbol supplied by a consumer.
|
|
6
|
+
* @param options - Provider route syntax supported by the caller.
|
|
7
|
+
* @param options.allowProviderRoute - Whether one non-empty `dex:market`
|
|
8
|
+
* route prefix is allowed.
|
|
9
|
+
* @returns Whether the symbol is non-empty, contains no whitespace, and uses
|
|
10
|
+
* the allowed route shape.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isValidCapabilitySymbol(symbol: string, options: {
|
|
13
|
+
allowProviderRoute: boolean;
|
|
14
|
+
}): boolean;
|
|
15
|
+
//# sourceMappingURL=capabilitySymbols.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilitySymbols.d.ts","sourceRoot":"","sources":["../../src/utils/capabilitySymbols.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAE,kBAAkB,EAAE,OAAO,CAAA;CAAE,GACvC,OAAO,CAST"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check whether a capability symbol has the provider-independent shape the
|
|
3
|
+
* caller allows.
|
|
4
|
+
*
|
|
5
|
+
* @param symbol - Market symbol supplied by a consumer.
|
|
6
|
+
* @param options - Provider route syntax supported by the caller.
|
|
7
|
+
* @param options.allowProviderRoute - Whether one non-empty `dex:market`
|
|
8
|
+
* route prefix is allowed.
|
|
9
|
+
* @returns Whether the symbol is non-empty, contains no whitespace, and uses
|
|
10
|
+
* the allowed route shape.
|
|
11
|
+
*/
|
|
12
|
+
export function isValidCapabilitySymbol(symbol, options) {
|
|
13
|
+
if (symbol.length === 0 || /\s/u.test(symbol)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const routeParts = symbol.split(':');
|
|
17
|
+
return options.allowProviderRoute
|
|
18
|
+
? routeParts.length <= 2 && routeParts.every((part) => part.length > 0)
|
|
19
|
+
: routeParts.length === 1;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=capabilitySymbols.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilitySymbols.js","sourceRoot":"","sources":["../../src/utils/capabilitySymbols.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAAc,EACd,OAAwC;IAExC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrC,OAAO,OAAO,CAAC,kBAAkB;QAC/B,CAAC,CAAC,UAAU,CAAC,MAAM,IAAI,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QACvE,CAAC,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["/**\n * Check whether a capability symbol has the provider-independent shape the\n * caller allows.\n *\n * @param symbol - Market symbol supplied by a consumer.\n * @param options - Provider route syntax supported by the caller.\n * @param options.allowProviderRoute - Whether one non-empty `dex:market`\n * route prefix is allowed.\n * @returns Whether the symbol is non-empty, contains no whitespace, and uses\n * the allowed route shape.\n */\nexport function isValidCapabilitySymbol(\n symbol: string,\n options: { allowProviderRoute: boolean },\n): boolean {\n if (symbol.length === 0 || /\\s/u.test(symbol)) {\n return false;\n }\n\n const routeParts = symbol.split(':');\n return options.allowProviderRoute\n ? routeParts.length <= 2 && routeParts.every((part) => part.length > 0)\n : routeParts.length === 1;\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type CoalesceOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* Cache TTL in milliseconds. Defaults to
|
|
4
|
+
* {@link PERFORMANCE_CONFIG.PerpsRestCoalesceTtlMs}.
|
|
5
|
+
*/
|
|
6
|
+
ttlMs?: number;
|
|
7
|
+
/**
|
|
8
|
+
* Bypass the cache and any in-flight promise. The fresh result will be
|
|
9
|
+
* written back to the cache under the same key.
|
|
10
|
+
*/
|
|
11
|
+
forceRefresh?: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Coalesce an idempotent perps REST call.
|
|
15
|
+
*
|
|
16
|
+
* - If a fresh cached value exists for `key`, it is returned immediately.
|
|
17
|
+
* - If an in-flight promise exists for `key`, it is shared with the caller.
|
|
18
|
+
* - Otherwise, `fetcher` runs once; the result populates the cache for `ttlMs`.
|
|
19
|
+
*
|
|
20
|
+
* `forceRefresh` skips both cache and in-flight dedup.
|
|
21
|
+
*
|
|
22
|
+
* @param key - Stable cache key identifying this logical REST call.
|
|
23
|
+
* @param fetcher - Thunk that performs the REST call when no cache/inflight hit.
|
|
24
|
+
* @param options - Optional overrides for TTL and forceRefresh behavior.
|
|
25
|
+
* @returns The fetched (or cached) value.
|
|
26
|
+
*/
|
|
27
|
+
export declare function coalescePerpsRestRequest<TValue>(key: string, fetcher: () => Promise<TValue>, options?: CoalesceOptions): Promise<TValue>;
|
|
28
|
+
/**
|
|
29
|
+
* Test-only: wipe all cached entries and in-flight promises.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resetPerpsRestCacheForTests(): void;
|
|
32
|
+
//# sourceMappingURL=coalescePerpsRestRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coalescePerpsRestRequest.d.ts","sourceRoot":"","sources":["../../src/utils/coalescePerpsRestRequest.ts"],"names":[],"mappings":"AAqBA,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAC7C,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EAC9B,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC,CA6CjB;AAED;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CAGlD"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { PERFORMANCE_CONFIG } from '../constants/perpsConfig.js';
|
|
2
|
+
const inflight = new Map();
|
|
3
|
+
const cache = new Map();
|
|
4
|
+
/**
|
|
5
|
+
* Coalesce an idempotent perps REST call.
|
|
6
|
+
*
|
|
7
|
+
* - If a fresh cached value exists for `key`, it is returned immediately.
|
|
8
|
+
* - If an in-flight promise exists for `key`, it is shared with the caller.
|
|
9
|
+
* - Otherwise, `fetcher` runs once; the result populates the cache for `ttlMs`.
|
|
10
|
+
*
|
|
11
|
+
* `forceRefresh` skips both cache and in-flight dedup.
|
|
12
|
+
*
|
|
13
|
+
* @param key - Stable cache key identifying this logical REST call.
|
|
14
|
+
* @param fetcher - Thunk that performs the REST call when no cache/inflight hit.
|
|
15
|
+
* @param options - Optional overrides for TTL and forceRefresh behavior.
|
|
16
|
+
* @returns The fetched (or cached) value.
|
|
17
|
+
*/
|
|
18
|
+
export function coalescePerpsRestRequest(key, fetcher, options = {}) {
|
|
19
|
+
const ttlMs = options.ttlMs ?? PERFORMANCE_CONFIG.PerpsRestCoalesceTtlMs;
|
|
20
|
+
const forceRefresh = options.forceRefresh ?? false;
|
|
21
|
+
if (forceRefresh) {
|
|
22
|
+
cache.delete(key);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const now = Date.now();
|
|
26
|
+
const cached = cache.get(key);
|
|
27
|
+
if (cached) {
|
|
28
|
+
if (cached.expiresAt > now) {
|
|
29
|
+
return Promise.resolve(cached.value);
|
|
30
|
+
}
|
|
31
|
+
// Evict expired entry so callers with per-call-unique keys (e.g.
|
|
32
|
+
// CandleStreamChannel historical paging with per-page endTime) do
|
|
33
|
+
// not accumulate dead blobs for the life of the process.
|
|
34
|
+
cache.delete(key);
|
|
35
|
+
}
|
|
36
|
+
const existing = inflight.get(key);
|
|
37
|
+
if (existing !== undefined) {
|
|
38
|
+
return existing;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const run = fetcher().then((value) => {
|
|
42
|
+
// Only the currently-tracked in-flight promise writes to cache. A stale
|
|
43
|
+
// in-flight (e.g. one that was racing a later forceRefresh=true caller)
|
|
44
|
+
// must not clobber the fresh value once it finally resolves.
|
|
45
|
+
if (inflight.get(key) === run) {
|
|
46
|
+
cache.set(key, { value, expiresAt: Date.now() + ttlMs });
|
|
47
|
+
inflight.delete(key);
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
}, (error) => {
|
|
51
|
+
if (inflight.get(key) === run) {
|
|
52
|
+
inflight.delete(key);
|
|
53
|
+
}
|
|
54
|
+
throw error;
|
|
55
|
+
});
|
|
56
|
+
inflight.set(key, run);
|
|
57
|
+
return run;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Test-only: wipe all cached entries and in-flight promises.
|
|
61
|
+
*/
|
|
62
|
+
export function resetPerpsRestCacheForTests() {
|
|
63
|
+
cache.clear();
|
|
64
|
+
inflight.clear();
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=coalescePerpsRestRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coalescePerpsRestRequest.js","sourceRoot":"","sources":["../../src/utils/coalescePerpsRestRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAkBjE,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA4B,CAAC;AACrD,MAAM,KAAK,GAAG,IAAI,GAAG,EAA+B,CAAC;AAerD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,wBAAwB,CACtC,GAAW,EACX,OAA8B,EAC9B,OAAO,GAAoB,EAAE;IAE7B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,kBAAkB,CAAC,sBAAsB,CAAC;IACzE,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,KAAK,CAAC;IAEnD,IAAI,YAAY,EAAE,CAAC;QACjB,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAmC,CAAC;QAChE,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,MAAM,CAAC,SAAS,GAAG,GAAG,EAAE,CAAC;gBAC3B,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvC,CAAC;YACD,iEAAiE;YACjE,kEAAkE;YAClE,yDAAyD;YACzD,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;QACD,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAgC,CAAC;QAClE,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IAED,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC,IAAI,CACxB,CAAC,KAAK,EAAE,EAAE;QACR,wEAAwE;QACxE,wEAAwE;QACxE,6DAA6D;QAC7D,IAAI,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC;YAC9B,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;YACzD,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;QACR,IAAI,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC;YAC9B,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC,CACF,CAAC;IAEF,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACvB,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B;IACzC,KAAK,CAAC,KAAK,EAAE,CAAC;IACd,QAAQ,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC","sourcesContent":["import { PERFORMANCE_CONFIG } from '../constants/perpsConfig.js';\n\n// Rapid perps market switching (candle bridge + activity tab burst) drives\n// duplicate REST calls against api.hyperliquid.xyz and occasionally trips 429.\n// This helper collapses concurrent identical calls into one in-flight promise\n// and serves a short TTL cache to absorb the burst. Explicit refresh bypasses\n// the cache so user-initiated refetch still re-runs.\n//\n// Lives at the service layer (MarketDataService) rather than per-hook so every\n// current and future caller — hooks, controller, aggregated provider — is\n// deduped automatically. Centralized at MarketDataService because it is\n// already a single choke point.\n\ntype CacheEntry<TValue> = {\n value: TValue;\n expiresAt: number;\n};\n\nconst inflight = new Map<string, Promise<unknown>>();\nconst cache = new Map<string, CacheEntry<unknown>>();\n\nexport type CoalesceOptions = {\n /**\n * Cache TTL in milliseconds. Defaults to\n * {@link PERFORMANCE_CONFIG.PerpsRestCoalesceTtlMs}.\n */\n ttlMs?: number;\n /**\n * Bypass the cache and any in-flight promise. The fresh result will be\n * written back to the cache under the same key.\n */\n forceRefresh?: boolean;\n};\n\n/**\n * Coalesce an idempotent perps REST call.\n *\n * - If a fresh cached value exists for `key`, it is returned immediately.\n * - If an in-flight promise exists for `key`, it is shared with the caller.\n * - Otherwise, `fetcher` runs once; the result populates the cache for `ttlMs`.\n *\n * `forceRefresh` skips both cache and in-flight dedup.\n *\n * @param key - Stable cache key identifying this logical REST call.\n * @param fetcher - Thunk that performs the REST call when no cache/inflight hit.\n * @param options - Optional overrides for TTL and forceRefresh behavior.\n * @returns The fetched (or cached) value.\n */\nexport function coalescePerpsRestRequest<TValue>(\n key: string,\n fetcher: () => Promise<TValue>,\n options: CoalesceOptions = {},\n): Promise<TValue> {\n const ttlMs = options.ttlMs ?? PERFORMANCE_CONFIG.PerpsRestCoalesceTtlMs;\n const forceRefresh = options.forceRefresh ?? false;\n\n if (forceRefresh) {\n cache.delete(key);\n } else {\n const now = Date.now();\n const cached = cache.get(key) as CacheEntry<TValue> | undefined;\n if (cached) {\n if (cached.expiresAt > now) {\n return Promise.resolve(cached.value);\n }\n // Evict expired entry so callers with per-call-unique keys (e.g.\n // CandleStreamChannel historical paging with per-page endTime) do\n // not accumulate dead blobs for the life of the process.\n cache.delete(key);\n }\n const existing = inflight.get(key) as Promise<TValue> | undefined;\n if (existing !== undefined) {\n return existing;\n }\n }\n\n const run = fetcher().then(\n (value) => {\n // Only the currently-tracked in-flight promise writes to cache. A stale\n // in-flight (e.g. one that was racing a later forceRefresh=true caller)\n // must not clobber the fresh value once it finally resolves.\n if (inflight.get(key) === run) {\n cache.set(key, { value, expiresAt: Date.now() + ttlMs });\n inflight.delete(key);\n }\n return value;\n },\n (error) => {\n if (inflight.get(key) === run) {\n inflight.delete(key);\n }\n throw error;\n },\n );\n\n inflight.set(key, run);\n return run;\n}\n\n/**\n * Test-only: wipe all cached entries and in-flight promises.\n */\nexport function resetPerpsRestCacheForTests(): void {\n cache.clear();\n inflight.clear();\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detects expected cancellation/abort errors that should not be reported to Sentry.
|
|
3
|
+
* These occur during normal navigation or view teardown when in-flight fetch requests
|
|
4
|
+
* are cancelled via AbortController.
|
|
5
|
+
*
|
|
6
|
+
* @param error - The error to check.
|
|
7
|
+
* @returns True if the error is an expected abort/cancellation.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isAbortError(error: unknown): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Detects keyring-locked errors, including SDK-wrapped errors that preserve the
|
|
12
|
+
* original error in `cause`.
|
|
13
|
+
*
|
|
14
|
+
* @param error - The error to check.
|
|
15
|
+
* @returns True if any error in the cause chain is KEYRING_LOCKED.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isKeyringLockedError(error: unknown): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Ensures we have a proper Error object for logging.
|
|
20
|
+
* Converts unknown/string errors to proper Error instances.
|
|
21
|
+
* Handles undefined/null specially for better Sentry context.
|
|
22
|
+
*
|
|
23
|
+
* @param error - The caught error (could be Error, string, or unknown)
|
|
24
|
+
* @param context - Optional context string to help identify the source of the error
|
|
25
|
+
* @returns A proper Error instance
|
|
26
|
+
*/
|
|
27
|
+
export declare function ensureError(error: unknown, context?: string): Error;
|
|
28
|
+
/**
|
|
29
|
+
* Hyperliquid rejects user-scoped exchange writes (`agentSetAbstraction`,
|
|
30
|
+
* `userSetAbstraction`, `setReferrer`, ...) with this exact message when the
|
|
31
|
+
* wallet has never funded a Hyperliquid account. It is a benign pre-account
|
|
32
|
+
* state, not an error we should forward to Sentry.
|
|
33
|
+
*
|
|
34
|
+
* @param error - The caught error.
|
|
35
|
+
* @returns True if the error matches the Hyperliquid "user not on chain yet" rejection.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isHyperLiquidUserNotFoundError(error: unknown): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Hyperliquid rejects every single-signer exchange write for an account that
|
|
40
|
+
* has been converted to multi-sig (`ApiRequestError: Multi-sig required`).
|
|
41
|
+
* MetaMask signs Perps actions with a single agent/user wallet, so this is a
|
|
42
|
+
* permanent account-shape condition rather than a failure we should retry or
|
|
43
|
+
* forward to Sentry. Only the hyphenated spelling has been observed from the
|
|
44
|
+
* venue; the unhyphenated variant is matched defensively.
|
|
45
|
+
*
|
|
46
|
+
* @param error - The caught error.
|
|
47
|
+
* @returns True if the error indicates multi-sig signing is required.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isHyperLiquidMultiSigRequiredError(error: unknown): boolean;
|
|
50
|
+
//# sourceMappingURL=errorUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorUtils.d.ts","sourceRoot":"","sources":["../../src/utils/errorUtils.ts"],"names":[],"mappings":"AAQA;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CASpD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAe5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAkBnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAKtE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAK1E"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for error handling across Perps controller code.
|
|
3
|
+
* Includes generic error helpers and Perps error classification helpers.
|
|
4
|
+
*/
|
|
5
|
+
import { hasProperty } from '@metamask/utils';
|
|
6
|
+
import { PERPS_ERROR_CODES } from '../perpsErrorCodes.js';
|
|
7
|
+
/**
|
|
8
|
+
* Detects expected cancellation/abort errors that should not be reported to Sentry.
|
|
9
|
+
* These occur during normal navigation or view teardown when in-flight fetch requests
|
|
10
|
+
* are cancelled via AbortController.
|
|
11
|
+
*
|
|
12
|
+
* @param error - The error to check.
|
|
13
|
+
* @returns True if the error is an expected abort/cancellation.
|
|
14
|
+
*/
|
|
15
|
+
export function isAbortError(error) {
|
|
16
|
+
if (error instanceof Error) {
|
|
17
|
+
return (error.name === 'AbortError' ||
|
|
18
|
+
error.message.includes('signal is aborted') ||
|
|
19
|
+
error.message.includes('The operation was aborted'));
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Detects keyring-locked errors, including SDK-wrapped errors that preserve the
|
|
25
|
+
* original error in `cause`.
|
|
26
|
+
*
|
|
27
|
+
* @param error - The error to check.
|
|
28
|
+
* @returns True if any error in the cause chain is KEYRING_LOCKED.
|
|
29
|
+
*/
|
|
30
|
+
export function isKeyringLockedError(error) {
|
|
31
|
+
let current = error;
|
|
32
|
+
const seen = new Set();
|
|
33
|
+
while (current instanceof Error && !seen.has(current)) {
|
|
34
|
+
seen.add(current);
|
|
35
|
+
if (current.message === PERPS_ERROR_CODES.KEYRING_LOCKED) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
current = current.cause;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Ensures we have a proper Error object for logging.
|
|
44
|
+
* Converts unknown/string errors to proper Error instances.
|
|
45
|
+
* Handles undefined/null specially for better Sentry context.
|
|
46
|
+
*
|
|
47
|
+
* @param error - The caught error (could be Error, string, or unknown)
|
|
48
|
+
* @param context - Optional context string to help identify the source of the error
|
|
49
|
+
* @returns A proper Error instance
|
|
50
|
+
*/
|
|
51
|
+
export function ensureError(error, context) {
|
|
52
|
+
if (error instanceof Error) {
|
|
53
|
+
return error;
|
|
54
|
+
}
|
|
55
|
+
// Handle undefined/null specifically for better error context
|
|
56
|
+
// e.g. Hyperliquid SDK may reject with undefined when AbortSignal.reason is not set
|
|
57
|
+
if (error === undefined || error === null) {
|
|
58
|
+
const baseMessage = 'Unknown error (no details provided)';
|
|
59
|
+
return new Error(context ? `${baseMessage} [${context}]` : baseMessage);
|
|
60
|
+
}
|
|
61
|
+
if (typeof error === 'string') {
|
|
62
|
+
return new Error(error);
|
|
63
|
+
}
|
|
64
|
+
return new Error(typeof error === 'object' && error !== null && hasProperty(error, 'message')
|
|
65
|
+
? String(error.message)
|
|
66
|
+
: 'Unknown error');
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Hyperliquid rejects user-scoped exchange writes (`agentSetAbstraction`,
|
|
70
|
+
* `userSetAbstraction`, `setReferrer`, ...) with this exact message when the
|
|
71
|
+
* wallet has never funded a Hyperliquid account. It is a benign pre-account
|
|
72
|
+
* state, not an error we should forward to Sentry.
|
|
73
|
+
*
|
|
74
|
+
* @param error - The caught error.
|
|
75
|
+
* @returns True if the error matches the Hyperliquid "user not on chain yet" rejection.
|
|
76
|
+
*/
|
|
77
|
+
export function isHyperLiquidUserNotFoundError(error) {
|
|
78
|
+
const lower = ensureError(error).message.toLowerCase();
|
|
79
|
+
return (lower.includes('user or api wallet') && lower.includes('does not exist'));
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Hyperliquid rejects every single-signer exchange write for an account that
|
|
83
|
+
* has been converted to multi-sig (`ApiRequestError: Multi-sig required`).
|
|
84
|
+
* MetaMask signs Perps actions with a single agent/user wallet, so this is a
|
|
85
|
+
* permanent account-shape condition rather than a failure we should retry or
|
|
86
|
+
* forward to Sentry. Only the hyphenated spelling has been observed from the
|
|
87
|
+
* venue; the unhyphenated variant is matched defensively.
|
|
88
|
+
*
|
|
89
|
+
* @param error - The caught error.
|
|
90
|
+
* @returns True if the error indicates multi-sig signing is required.
|
|
91
|
+
*/
|
|
92
|
+
export function isHyperLiquidMultiSigRequiredError(error) {
|
|
93
|
+
const lower = ensureError(error).message.toLowerCase();
|
|
94
|
+
return (lower.includes('multi-sig required') || lower.includes('multisig required'));
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=errorUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorUtils.js","sourceRoot":"","sources":["../../src/utils/errorUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,CACL,KAAK,CAAC,IAAI,KAAK,YAAY;YAC3B,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC;YAC3C,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAAC,CACpD,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,IAAI,OAAO,GAAY,KAAK,CAAC;IAC7B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAW,CAAC;IAEhC,OAAO,OAAO,YAAY,KAAK,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QACtD,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAElB,IAA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,UAAU,kCAAkC,CAAC,KAAc;IAC/D,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IACvD,OAAO,CACL,KAAK,CAAC,QAAQ,CAAC,oBAAoB,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAC5E,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Utility functions for error handling across Perps controller code.\n * Includes generic error helpers and Perps error classification helpers.\n */\nimport { hasProperty } from '@metamask/utils';\n\nimport { PERPS_ERROR_CODES } from '../perpsErrorCodes.js';\n\n/**\n * Detects expected cancellation/abort errors that should not be reported to Sentry.\n * These occur during normal navigation or view teardown when in-flight fetch requests\n * are cancelled via AbortController.\n *\n * @param error - The error to check.\n * @returns True if the error is an expected abort/cancellation.\n */\nexport function isAbortError(error: unknown): boolean {\n if (error instanceof Error) {\n return (\n error.name === 'AbortError' ||\n error.message.includes('signal is aborted') ||\n error.message.includes('The operation was aborted')\n );\n }\n return false;\n}\n\n/**\n * Detects keyring-locked errors, including SDK-wrapped errors that preserve the\n * original error in `cause`.\n *\n * @param error - The error to check.\n * @returns True if any error in the cause chain is KEYRING_LOCKED.\n */\nexport function isKeyringLockedError(error: unknown): boolean {\n let current: unknown = error;\n const seen = new Set<unknown>();\n\n while (current instanceof Error && !seen.has(current)) {\n seen.add(current);\n\n if (current.message === PERPS_ERROR_CODES.KEYRING_LOCKED) {\n return true;\n }\n\n current = (current as { cause?: unknown }).cause;\n }\n\n return false;\n}\n\n/**\n * Ensures we have a proper Error object for logging.\n * Converts unknown/string errors to proper Error instances.\n * Handles undefined/null specially for better Sentry context.\n *\n * @param error - The caught error (could be Error, string, or unknown)\n * @param context - Optional context string to help identify the source of the error\n * @returns A proper Error instance\n */\nexport function ensureError(error: unknown, context?: string): Error {\n if (error instanceof Error) {\n return error;\n }\n // Handle undefined/null specifically for better error context\n // e.g. Hyperliquid SDK may reject with undefined when AbortSignal.reason is not set\n if (error === undefined || error === null) {\n const baseMessage = 'Unknown error (no details provided)';\n return new Error(context ? `${baseMessage} [${context}]` : baseMessage);\n }\n if (typeof error === 'string') {\n return new Error(error);\n }\n return new Error(\n typeof error === 'object' && error !== null && hasProperty(error, 'message')\n ? String((error as { message: unknown }).message)\n : 'Unknown error',\n );\n}\n\n/**\n * Hyperliquid rejects user-scoped exchange writes (`agentSetAbstraction`,\n * `userSetAbstraction`, `setReferrer`, ...) with this exact message when the\n * wallet has never funded a Hyperliquid account. It is a benign pre-account\n * state, not an error we should forward to Sentry.\n *\n * @param error - The caught error.\n * @returns True if the error matches the Hyperliquid \"user not on chain yet\" rejection.\n */\nexport function isHyperLiquidUserNotFoundError(error: unknown): boolean {\n const lower = ensureError(error).message.toLowerCase();\n return (\n lower.includes('user or api wallet') && lower.includes('does not exist')\n );\n}\n\n/**\n * Hyperliquid rejects every single-signer exchange write for an account that\n * has been converted to multi-sig (`ApiRequestError: Multi-sig required`).\n * MetaMask signs Perps actions with a single agent/user wallet, so this is a\n * permanent account-shape condition rather than a failure we should retry or\n * forward to Sentry. Only the hyphenated spelling has been observed from the\n * venue; the unhyphenated variant is matched defensively.\n *\n * @param error - The caught error.\n * @returns True if the error indicates multi-sig signing is required.\n */\nexport function isHyperLiquidMultiSigRequiredError(error: unknown): boolean {\n const lower = ensureError(error).message.toLowerCase();\n return (\n lower.includes('multi-sig required') || lower.includes('multisig required')\n );\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HyperLiquidAbstractionMode } from '../types/hyperliquid-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Determine whether unified-account setup should be deferred until a user
|
|
4
|
+
* explicitly starts a trading or withdrawal action.
|
|
5
|
+
*
|
|
6
|
+
* @param currentMode - The user's current HyperLiquid abstraction mode.
|
|
7
|
+
* @param allowUserSigning - Whether the caller is allowed to trigger wallet signing.
|
|
8
|
+
* @returns True when migration would require a signing-backed mutation that should be deferred.
|
|
9
|
+
*/
|
|
10
|
+
export declare function shouldDeferUnifiedAccountSetup(currentMode: HyperLiquidAbstractionMode | undefined, allowUserSigning: boolean): boolean;
|
|
11
|
+
//# sourceMappingURL=hyperLiquidAbstraction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hyperLiquidAbstraction.d.ts","sourceRoot":"","sources":["../../src/utils/hyperLiquidAbstraction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAQhF;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAC5C,WAAW,EAAE,0BAA0B,GAAG,SAAS,EACnD,gBAAgB,EAAE,OAAO,GACxB,OAAO,CAMT"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const MIGRATABLE_ABSTRACTION_MODES = new Set([
|
|
2
|
+
'dexAbstraction',
|
|
3
|
+
'default',
|
|
4
|
+
'disabled',
|
|
5
|
+
]);
|
|
6
|
+
/**
|
|
7
|
+
* Determine whether unified-account setup should be deferred until a user
|
|
8
|
+
* explicitly starts a trading or withdrawal action.
|
|
9
|
+
*
|
|
10
|
+
* @param currentMode - The user's current HyperLiquid abstraction mode.
|
|
11
|
+
* @param allowUserSigning - Whether the caller is allowed to trigger wallet signing.
|
|
12
|
+
* @returns True when migration would require a signing-backed mutation that should be deferred.
|
|
13
|
+
*/
|
|
14
|
+
export function shouldDeferUnifiedAccountSetup(currentMode, allowUserSigning) {
|
|
15
|
+
return (!allowUserSigning &&
|
|
16
|
+
currentMode !== undefined &&
|
|
17
|
+
MIGRATABLE_ABSTRACTION_MODES.has(currentMode));
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=hyperLiquidAbstraction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hyperLiquidAbstraction.js","sourceRoot":"","sources":["../../src/utils/hyperLiquidAbstraction.ts"],"names":[],"mappings":"AAEA,MAAM,4BAA4B,GAAG,IAAI,GAAG,CAA6B;IACvE,gBAAgB;IAChB,SAAS;IACT,UAAU;CACX,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,8BAA8B,CAC5C,WAAmD,EACnD,gBAAyB;IAEzB,OAAO,CACL,CAAC,gBAAgB;QACjB,WAAW,KAAK,SAAS;QACzB,4BAA4B,CAAC,GAAG,CAAC,WAAW,CAAC,CAC9C,CAAC;AACJ,CAAC","sourcesContent":["import type { HyperLiquidAbstractionMode } from '../types/hyperliquid-types.js';\n\nconst MIGRATABLE_ABSTRACTION_MODES = new Set<HyperLiquidAbstractionMode>([\n 'dexAbstraction',\n 'default',\n 'disabled',\n]);\n\n/**\n * Determine whether unified-account setup should be deferred until a user\n * explicitly starts a trading or withdrawal action.\n *\n * @param currentMode - The user's current HyperLiquid abstraction mode.\n * @param allowUserSigning - Whether the caller is allowed to trigger wallet signing.\n * @returns True when migration would require a signing-backed mutation that should be deferred.\n */\nexport function shouldDeferUnifiedAccountSetup(\n currentMode: HyperLiquidAbstractionMode | undefined,\n allowUserSigning: boolean,\n): boolean {\n return (\n !allowUserSigning &&\n currentMode !== undefined &&\n MIGRATABLE_ABSTRACTION_MODES.has(currentMode)\n );\n}\n"]}
|