@metamask-previews/perps-controller 13.1.0-preview-8c2a2eeb2 → 13.1.0-preview-4f4c98e
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 +4 -1
- package/dist/{PerpsController-method-action-types.d.mts → PerpsController-method-action-types.d.ts} +2 -2
- package/dist/PerpsController-method-action-types.d.ts.map +1 -0
- package/dist/{PerpsController-method-action-types.mjs → PerpsController-method-action-types.js} +1 -1
- package/dist/PerpsController-method-action-types.js.map +1 -0
- package/dist/{PerpsController.d.mts → PerpsController.d.ts} +17 -17
- package/dist/PerpsController.d.ts.map +1 -0
- package/dist/{PerpsController.mjs → PerpsController.js} +33 -31
- package/dist/PerpsController.js.map +1 -0
- package/dist/aggregation/{SubscriptionMultiplexer.d.cts → SubscriptionMultiplexer.d.ts} +2 -2
- package/dist/aggregation/SubscriptionMultiplexer.d.ts.map +1 -0
- package/dist/aggregation/{SubscriptionMultiplexer.mjs → SubscriptionMultiplexer.js} +3 -3
- 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.mts → chartConfig.d.ts} +34 -34
- package/dist/constants/chartConfig.d.ts.map +1 -0
- package/dist/constants/{chartConfig.mjs → chartConfig.js} +1 -1
- package/dist/constants/chartConfig.js.map +1 -0
- package/dist/constants/eventNames.d.ts +555 -0
- package/dist/constants/eventNames.d.ts.map +1 -0
- package/dist/constants/{eventNames.mjs → eventNames.js} +1 -1
- package/dist/constants/eventNames.js.map +1 -0
- package/dist/constants/{hyperLiquidConfig.d.cts → hyperLiquidConfig.d.ts} +12 -12
- package/dist/constants/hyperLiquidConfig.d.ts.map +1 -0
- package/dist/constants/{hyperLiquidConfig.mjs → hyperLiquidConfig.js} +4 -4
- 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/{myxConfig.d.mts → myxConfig.d.ts} +9 -8
- package/dist/constants/myxConfig.d.ts.map +1 -0
- package/dist/constants/{myxConfig.mjs → myxConfig.js} +2 -2
- package/dist/constants/myxConfig.js.map +1 -0
- package/dist/constants/{orderTypes.d.cts → orderTypes.d.ts} +7 -7
- package/dist/constants/orderTypes.d.ts.map +1 -0
- package/dist/constants/{orderTypes.mjs → orderTypes.js} +1 -1
- package/dist/constants/orderTypes.js.map +1 -0
- package/dist/constants/{performanceMetrics.d.cts → performanceMetrics.d.ts} +1 -1
- package/dist/constants/performanceMetrics.d.ts.map +1 -0
- package/dist/constants/{performanceMetrics.mjs → performanceMetrics.js} +1 -1
- package/dist/constants/performanceMetrics.js.map +1 -0
- package/dist/constants/{perpsConfig.d.mts → perpsConfig.d.ts} +56 -56
- package/dist/constants/perpsConfig.d.ts.map +1 -0
- package/dist/constants/{perpsConfig.mjs → perpsConfig.js} +1 -1
- package/dist/constants/perpsConfig.js.map +1 -0
- package/dist/constants/{transactionsHistoryConfig.d.cts → transactionsHistoryConfig.d.ts} +1 -1
- package/dist/constants/transactionsHistoryConfig.d.ts.map +1 -0
- package/dist/constants/{transactionsHistoryConfig.mjs → transactionsHistoryConfig.js} +1 -1
- package/dist/constants/transactionsHistoryConfig.js.map +1 -0
- package/dist/{index.d.mts → index.d.ts} +64 -64
- package/dist/index.d.ts.map +1 -0
- package/dist/{index.mjs → index.js} +41 -41
- package/dist/index.js.map +1 -0
- package/dist/perpsErrorCodes.d.ts +104 -0
- package/dist/perpsErrorCodes.d.ts.map +1 -0
- package/dist/{perpsErrorCodes.mjs → perpsErrorCodes.js} +1 -1
- package/dist/perpsErrorCodes.js.map +1 -0
- package/dist/providers/{AggregatedPerpsProvider.d.cts → AggregatedPerpsProvider.d.ts} +5 -5
- package/dist/providers/AggregatedPerpsProvider.d.ts.map +1 -0
- package/dist/providers/{AggregatedPerpsProvider.mjs → AggregatedPerpsProvider.js} +5 -5
- package/dist/providers/AggregatedPerpsProvider.js.map +1 -0
- package/dist/providers/{HyperLiquidProvider.d.mts → HyperLiquidProvider.d.ts} +7 -7
- package/dist/providers/HyperLiquidProvider.d.ts.map +1 -0
- package/dist/providers/{HyperLiquidProvider.mjs → HyperLiquidProvider.js} +48 -50
- package/dist/providers/HyperLiquidProvider.js.map +1 -0
- package/dist/routing/{ProviderRouter.d.mts → ProviderRouter.d.ts} +2 -2
- package/dist/routing/ProviderRouter.d.ts.map +1 -0
- package/dist/routing/{ProviderRouter.mjs → ProviderRouter.js} +1 -1
- 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.mts → selectors.d.ts} +97 -97
- package/dist/selectors.d.ts.map +1 -0
- package/dist/{selectors.mjs → selectors.js} +4 -4
- package/dist/selectors.js.map +1 -0
- package/dist/services/{AccountService.d.cts → AccountService.d.ts} +4 -4
- package/dist/services/AccountService.d.ts.map +1 -0
- package/dist/services/{AccountService.mjs → AccountService.js} +9 -9
- package/dist/services/AccountService.js.map +1 -0
- package/dist/services/{AggregatedOrderBookConnection.d.cts → AggregatedOrderBookConnection.d.ts} +2 -2
- package/dist/services/AggregatedOrderBookConnection.d.ts.map +1 -0
- package/dist/services/{AggregatedOrderBookConnection.mjs → AggregatedOrderBookConnection.js} +3 -3
- package/dist/services/AggregatedOrderBookConnection.js.map +1 -0
- package/dist/services/{DataLakeService.d.cts → DataLakeService.d.ts} +4 -4
- package/dist/services/DataLakeService.d.ts.map +1 -0
- package/dist/services/{DataLakeService.mjs → DataLakeService.js} +7 -7
- package/dist/services/DataLakeService.js.map +1 -0
- package/dist/services/{DepositService.d.cts → DepositService.d.ts} +4 -4
- package/dist/services/DepositService.d.ts.map +1 -0
- package/dist/services/{DepositService.mjs → DepositService.js} +7 -7
- package/dist/services/DepositService.js.map +1 -0
- package/dist/services/{DexDiscoveryCacheManager.d.cts → DexDiscoveryCacheManager.d.ts} +2 -2
- package/dist/services/DexDiscoveryCacheManager.d.ts.map +1 -0
- package/dist/services/{DexDiscoveryCacheManager.mjs → DexDiscoveryCacheManager.js} +2 -2
- package/dist/services/DexDiscoveryCacheManager.js.map +1 -0
- package/dist/services/{EligibilityService.d.cts → EligibilityService.d.ts} +2 -2
- package/dist/services/EligibilityService.d.ts.map +1 -0
- package/dist/services/{EligibilityService.mjs → EligibilityService.js} +3 -3
- package/dist/services/EligibilityService.js.map +1 -0
- package/dist/services/{FeatureFlagConfigurationService.d.cts → FeatureFlagConfigurationService.d.ts} +3 -3
- package/dist/services/FeatureFlagConfigurationService.d.ts.map +1 -0
- package/dist/services/{FeatureFlagConfigurationService.mjs → FeatureFlagConfigurationService.js} +7 -7
- package/dist/services/FeatureFlagConfigurationService.js.map +1 -0
- package/dist/services/{HyperLiquidClientService.d.cts → HyperLiquidClientService.d.ts} +10 -10
- package/dist/services/HyperLiquidClientService.d.ts.map +1 -0
- package/dist/services/{HyperLiquidClientService.mjs → HyperLiquidClientService.js} +11 -11
- package/dist/services/HyperLiquidClientService.js.map +1 -0
- package/dist/services/{HyperLiquidSubscriptionService.d.cts → HyperLiquidSubscriptionService.d.ts} +6 -6
- package/dist/services/HyperLiquidSubscriptionService.d.ts.map +1 -0
- package/dist/services/{HyperLiquidSubscriptionService.mjs → HyperLiquidSubscriptionService.js} +12 -12
- package/dist/services/HyperLiquidSubscriptionService.js.map +1 -0
- package/dist/services/{HyperLiquidWalletService.d.cts → HyperLiquidWalletService.d.ts} +4 -4
- package/dist/services/HyperLiquidWalletService.d.ts.map +1 -0
- package/dist/services/{HyperLiquidWalletService.mjs → HyperLiquidWalletService.js} +5 -5
- package/dist/services/HyperLiquidWalletService.js.map +1 -0
- package/dist/services/{MarketDataService.d.cts → MarketDataService.d.ts} +5 -5
- package/dist/services/MarketDataService.d.ts.map +1 -0
- package/dist/services/{MarketDataService.mjs → MarketDataService.js} +9 -9
- package/dist/services/MarketDataService.js.map +1 -0
- package/dist/services/{RewardsIntegrationService.d.cts → RewardsIntegrationService.d.ts} +3 -3
- package/dist/services/RewardsIntegrationService.d.ts.map +1 -0
- package/dist/services/{RewardsIntegrationService.mjs → RewardsIntegrationService.js} +6 -6
- package/dist/services/RewardsIntegrationService.js.map +1 -0
- package/dist/services/{ServiceContext.d.cts → ServiceContext.d.ts} +3 -3
- 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.cts → TerminalMarketService.d.ts} +2 -2
- package/dist/services/TerminalMarketService.d.ts.map +1 -0
- package/dist/services/{TerminalMarketService.mjs → TerminalMarketService.js} +9 -9
- package/dist/services/TerminalMarketService.js.map +1 -0
- package/dist/services/{TradingReadinessCache.d.mts → TradingReadinessCache.d.ts} +1 -1
- package/dist/services/TradingReadinessCache.d.ts.map +1 -0
- package/dist/services/{TradingReadinessCache.mjs → TradingReadinessCache.js} +1 -1
- package/dist/services/TradingReadinessCache.js.map +1 -0
- package/dist/services/{TradingService.d.cts → TradingService.d.ts} +4 -4
- package/dist/services/TradingService.d.ts.map +1 -0
- package/dist/services/{TradingService.mjs → TradingService.js} +10 -10
- package/dist/services/TradingService.js.map +1 -0
- package/dist/types/{config.d.cts → config.d.ts} +2 -2
- 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.cts → hyperliquid-types.d.ts} +6 -6
- package/dist/types/hyperliquid-types.d.ts.map +1 -0
- package/dist/types/{hyperliquid-types.mjs → hyperliquid-types.js} +1 -1
- package/dist/types/hyperliquid-types.js.map +1 -0
- package/dist/types/{index.d.cts → index.d.ts} +41 -41
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/{index.mjs → index.js} +3 -3
- package/dist/types/index.js.map +1 -0
- package/dist/types/{messenger.d.mts → messenger.d.ts} +11 -11
- 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/{myx-types.d.mts → myx-types.d.ts} +16 -16
- package/dist/types/myx-types.d.ts.map +1 -0
- package/dist/types/{myx-types.mjs → myx-types.js} +3 -3
- package/dist/types/myx-types.js.map +1 -0
- package/dist/types/{perps-types.d.cts → perps-types.d.ts} +4 -4
- 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.cts → token.d.ts} +2 -2
- 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.cts → transactionTypes.d.ts} +1 -1
- package/dist/types/transactionTypes.d.ts.map +1 -0
- package/dist/types/{transactionTypes.mjs → transactionTypes.js} +2 -2
- package/dist/types/transactionTypes.js.map +1 -0
- package/dist/utils/{accountUtils.d.cts → accountUtils.d.ts} +4 -4
- package/dist/utils/accountUtils.d.ts.map +1 -0
- package/dist/utils/{accountUtils.mjs → accountUtils.js} +2 -2
- package/dist/utils/accountUtils.js.map +1 -0
- package/dist/utils/{capabilitySymbols.d.mts → capabilitySymbols.d.ts} +1 -1
- package/dist/utils/capabilitySymbols.d.ts.map +1 -0
- package/dist/utils/{capabilitySymbols.mjs → capabilitySymbols.js} +1 -1
- package/dist/utils/capabilitySymbols.js.map +1 -0
- package/dist/utils/{coalescePerpsRestRequest.d.cts → coalescePerpsRestRequest.d.ts} +1 -1
- package/dist/utils/coalescePerpsRestRequest.d.ts.map +1 -0
- package/dist/utils/{coalescePerpsRestRequest.mjs → coalescePerpsRestRequest.js} +2 -2
- package/dist/utils/coalescePerpsRestRequest.js.map +1 -0
- package/dist/utils/{errorUtils.d.mts → errorUtils.d.ts} +1 -1
- package/dist/utils/errorUtils.d.ts.map +1 -0
- package/dist/utils/{errorUtils.mjs → errorUtils.js} +3 -3
- package/dist/utils/errorUtils.js.map +1 -0
- package/dist/utils/{hyperLiquidAbstraction.d.cts → hyperLiquidAbstraction.d.ts} +2 -2
- package/dist/utils/hyperLiquidAbstraction.d.ts.map +1 -0
- package/dist/utils/{hyperLiquidAbstraction.mjs → hyperLiquidAbstraction.js} +1 -1
- package/dist/utils/hyperLiquidAbstraction.js.map +1 -0
- package/dist/utils/{hyperLiquidAdapter.d.cts → hyperLiquidAdapter.d.ts} +4 -4
- package/dist/utils/hyperLiquidAdapter.d.ts.map +1 -0
- package/dist/utils/{hyperLiquidAdapter.mjs → hyperLiquidAdapter.js} +9 -9
- package/dist/utils/hyperLiquidAdapter.js.map +1 -0
- package/dist/utils/{hyperLiquidOrderBookProcessor.d.mts → hyperLiquidOrderBookProcessor.d.ts} +3 -3
- package/dist/utils/hyperLiquidOrderBookProcessor.d.ts.map +1 -0
- package/dist/utils/{hyperLiquidOrderBookProcessor.mjs → hyperLiquidOrderBookProcessor.js} +1 -1
- package/dist/utils/hyperLiquidOrderBookProcessor.js.map +1 -0
- package/dist/utils/{hyperLiquidValidation.d.cts → hyperLiquidValidation.d.ts} +4 -4
- package/dist/utils/hyperLiquidValidation.d.ts.map +1 -0
- package/dist/utils/{hyperLiquidValidation.mjs → hyperLiquidValidation.js} +6 -6
- package/dist/utils/hyperLiquidValidation.js.map +1 -0
- package/dist/utils/{idUtils.d.cts → idUtils.d.ts} +1 -1
- package/dist/utils/idUtils.d.ts.map +1 -0
- package/dist/utils/{idUtils.mjs → idUtils.js} +2 -2
- package/dist/utils/idUtils.js.map +1 -0
- package/dist/utils/index.d.ts +28 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/{index.mjs → index.js} +21 -21
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/{marketDataTransform.d.cts → marketDataTransform.d.ts} +3 -3
- package/dist/utils/marketDataTransform.d.ts.map +1 -0
- package/dist/utils/{marketDataTransform.mjs → marketDataTransform.js} +5 -5
- package/dist/utils/marketDataTransform.js.map +1 -0
- package/dist/utils/{marketSearch.d.cts → marketSearch.d.ts} +2 -2
- package/dist/utils/marketSearch.d.ts.map +1 -0
- package/dist/utils/{marketSearch.mjs → marketSearch.js} +1 -1
- package/dist/utils/marketSearch.js.map +1 -0
- package/dist/utils/{marketUtils.d.cts → marketUtils.d.ts} +3 -3
- package/dist/utils/marketUtils.d.ts.map +1 -0
- package/dist/utils/{marketUtils.mjs → marketUtils.js} +2 -2
- package/dist/utils/marketUtils.js.map +1 -0
- package/dist/utils/{myxAdapter.d.cts → myxAdapter.d.ts} +3 -3
- package/dist/utils/myxAdapter.d.ts.map +1 -0
- package/dist/utils/{myxAdapter.mjs → myxAdapter.js} +3 -3
- package/dist/utils/myxAdapter.js.map +1 -0
- package/dist/utils/{orderCalculations.d.cts → orderCalculations.d.ts} +4 -4
- package/dist/utils/orderCalculations.d.ts.map +1 -0
- package/dist/utils/{orderCalculations.mjs → orderCalculations.js} +6 -6
- package/dist/utils/orderCalculations.js.map +1 -0
- package/dist/utils/{orderTypes.d.mts → orderTypes.d.ts} +3 -3
- package/dist/utils/orderTypes.d.ts.map +1 -0
- package/dist/utils/{orderTypes.mjs → orderTypes.js} +1 -1
- package/dist/utils/orderTypes.js.map +1 -0
- package/dist/utils/{perpsConnectionAttemptContext.d.mts → perpsConnectionAttemptContext.d.ts} +1 -1
- package/dist/utils/perpsConnectionAttemptContext.d.ts.map +1 -0
- package/dist/utils/{perpsConnectionAttemptContext.mjs → perpsConnectionAttemptContext.js} +1 -1
- package/dist/utils/perpsConnectionAttemptContext.js.map +1 -0
- package/dist/utils/{perpsDiskPersistence.d.cts → perpsDiskPersistence.d.ts} +2 -2
- package/dist/utils/perpsDiskPersistence.d.ts.map +1 -0
- package/dist/utils/{perpsDiskPersistence.mjs → perpsDiskPersistence.js} +2 -2
- package/dist/utils/perpsDiskPersistence.js.map +1 -0
- package/dist/utils/{perpsFormatters.d.cts → perpsFormatters.d.ts} +1 -1
- package/dist/utils/perpsFormatters.d.ts.map +1 -0
- package/dist/utils/{perpsFormatters.mjs → perpsFormatters.js} +2 -2
- package/dist/utils/perpsFormatters.js.map +1 -0
- package/dist/utils/{rewardsUtils.d.cts → rewardsUtils.d.ts} +4 -4
- package/dist/utils/rewardsUtils.d.ts.map +1 -0
- package/dist/utils/{rewardsUtils.mjs → rewardsUtils.js} +4 -4
- package/dist/utils/rewardsUtils.js.map +1 -0
- package/dist/utils/{significantFigures.d.cts → significantFigures.d.ts} +1 -1
- package/dist/utils/significantFigures.d.ts.map +1 -0
- package/dist/utils/{significantFigures.mjs → significantFigures.js} +2 -2
- package/dist/utils/significantFigures.js.map +1 -0
- package/dist/utils/{sortMarkets.d.cts → sortMarkets.d.ts} +2 -2
- package/dist/utils/sortMarkets.d.ts.map +1 -0
- package/dist/utils/{sortMarkets.mjs → sortMarkets.js} +2 -2
- package/dist/utils/sortMarkets.js.map +1 -0
- package/dist/utils/{standaloneInfoClient.d.cts → standaloneInfoClient.d.ts} +3 -3
- package/dist/utils/standaloneInfoClient.d.ts.map +1 -0
- package/dist/utils/{standaloneInfoClient.mjs → standaloneInfoClient.js} +3 -3
- package/dist/utils/standaloneInfoClient.js.map +1 -0
- package/dist/utils/{stringParseUtils.d.cts → stringParseUtils.d.ts} +1 -1
- package/dist/utils/stringParseUtils.d.ts.map +1 -0
- package/dist/utils/{stringParseUtils.mjs → stringParseUtils.js} +1 -1
- package/dist/utils/stringParseUtils.js.map +1 -0
- package/dist/utils/{transferData.d.cts → transferData.d.ts} +1 -1
- package/dist/utils/transferData.d.ts.map +1 -0
- package/dist/utils/{transferData.mjs → transferData.js} +3 -3
- package/dist/utils/transferData.js.map +1 -0
- package/dist/utils/{wait.d.cts → wait.d.ts} +1 -1
- package/dist/utils/wait.d.ts.map +1 -0
- package/dist/utils/{wait.mjs → wait.js} +1 -1
- package/dist/utils/wait.js.map +1 -0
- package/package.json +20 -48
- 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 -1163
- package/dist/PerpsController-method-action-types.d.cts.map +0 -1
- package/dist/PerpsController-method-action-types.d.mts.map +0 -1
- package/dist/PerpsController-method-action-types.mjs.map +0 -1
- package/dist/PerpsController.cjs +0 -5063
- package/dist/PerpsController.cjs.map +0 -1
- package/dist/PerpsController.d.cts +0 -1274
- package/dist/PerpsController.d.cts.map +0 -1
- package/dist/PerpsController.d.mts.map +0 -1
- 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.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.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.map +0 -1
- package/dist/constants/chartConfig.mjs.map +0 -1
- package/dist/constants/eventNames.cjs +0 -650
- package/dist/constants/eventNames.cjs.map +0 -1
- package/dist/constants/eventNames.d.cts +0 -555
- package/dist/constants/eventNames.d.cts.map +0 -1
- package/dist/constants/eventNames.d.mts +0 -555
- package/dist/constants/eventNames.d.mts.map +0 -1
- 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.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.map +0 -1
- package/dist/constants/index.cjs +0 -28
- package/dist/constants/index.cjs.map +0 -1
- package/dist/constants/index.d.cts +0 -12
- package/dist/constants/index.d.cts.map +0 -1
- package/dist/constants/index.d.mts +0 -12
- package/dist/constants/index.d.mts.map +0 -1
- package/dist/constants/index.mjs +0 -12
- package/dist/constants/index.mjs.map +0 -1
- package/dist/constants/myxConfig.cjs +0 -253
- package/dist/constants/myxConfig.cjs.map +0 -1
- package/dist/constants/myxConfig.d.cts +0 -145
- package/dist/constants/myxConfig.d.cts.map +0 -1
- package/dist/constants/myxConfig.d.mts.map +0 -1
- package/dist/constants/myxConfig.mjs.map +0 -1
- package/dist/constants/orderTypes.cjs +0 -31
- package/dist/constants/orderTypes.cjs.map +0 -1
- package/dist/constants/orderTypes.d.cts.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.map +0 -1
- package/dist/constants/performanceMetrics.cjs +0 -63
- package/dist/constants/performanceMetrics.cjs.map +0 -1
- 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.map +0 -1
- package/dist/constants/perpsConfig.cjs +0 -553
- package/dist/constants/perpsConfig.cjs.map +0 -1
- package/dist/constants/perpsConfig.d.cts +0 -474
- package/dist/constants/perpsConfig.d.cts.map +0 -1
- package/dist/constants/perpsConfig.d.mts.map +0 -1
- 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.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.map +0 -1
- package/dist/index.cjs +0 -344
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -92
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/perpsErrorCodes.cjs +0 -127
- package/dist/perpsErrorCodes.cjs.map +0 -1
- package/dist/perpsErrorCodes.d.cts +0 -104
- package/dist/perpsErrorCodes.d.cts.map +0 -1
- package/dist/perpsErrorCodes.d.mts +0 -104
- package/dist/perpsErrorCodes.d.mts.map +0 -1
- package/dist/perpsErrorCodes.mjs.map +0 -1
- package/dist/providers/AggregatedPerpsProvider.cjs +0 -689
- package/dist/providers/AggregatedPerpsProvider.cjs.map +0 -1
- package/dist/providers/AggregatedPerpsProvider.d.cts.map +0 -1
- package/dist/providers/AggregatedPerpsProvider.d.mts +0 -232
- package/dist/providers/AggregatedPerpsProvider.d.mts.map +0 -1
- package/dist/providers/AggregatedPerpsProvider.mjs.map +0 -1
- package/dist/providers/HyperLiquidProvider.cjs +0 -10416
- package/dist/providers/HyperLiquidProvider.cjs.map +0 -1
- package/dist/providers/HyperLiquidProvider.d.cts +0 -625
- package/dist/providers/HyperLiquidProvider.d.cts.map +0 -1
- package/dist/providers/HyperLiquidProvider.d.mts.map +0 -1
- package/dist/providers/HyperLiquidProvider.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.map +0 -1
- 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.map +0 -1
- 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.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.map +0 -1
- package/dist/services/AggregatedOrderBookConnection.cjs +0 -405
- package/dist/services/AggregatedOrderBookConnection.cjs.map +0 -1
- 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.map +0 -1
- package/dist/services/DataLakeService.cjs +0 -233
- package/dist/services/DataLakeService.cjs.map +0 -1
- 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.map +0 -1
- package/dist/services/DepositService.cjs +0 -99
- package/dist/services/DepositService.cjs.map +0 -1
- 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.map +0 -1
- package/dist/services/DexDiscoveryCacheManager.cjs +0 -147
- package/dist/services/DexDiscoveryCacheManager.cjs.map +0 -1
- 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.map +0 -1
- package/dist/services/EligibilityService.cjs +0 -78
- package/dist/services/EligibilityService.cjs.map +0 -1
- 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.map +0 -1
- package/dist/services/FeatureFlagConfigurationService.cjs +0 -257
- package/dist/services/FeatureFlagConfigurationService.cjs.map +0 -1
- 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.map +0 -1
- package/dist/services/HyperLiquidClientService.cjs +0 -1045
- package/dist/services/HyperLiquidClientService.cjs.map +0 -1
- package/dist/services/HyperLiquidClientService.d.cts.map +0 -1
- package/dist/services/HyperLiquidClientService.d.mts +0 -239
- package/dist/services/HyperLiquidClientService.d.mts.map +0 -1
- package/dist/services/HyperLiquidClientService.mjs.map +0 -1
- package/dist/services/HyperLiquidSubscriptionService.cjs +0 -3196
- package/dist/services/HyperLiquidSubscriptionService.cjs.map +0 -1
- package/dist/services/HyperLiquidSubscriptionService.d.cts.map +0 -1
- package/dist/services/HyperLiquidSubscriptionService.d.mts +0 -227
- package/dist/services/HyperLiquidSubscriptionService.d.mts.map +0 -1
- 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.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.map +0 -1
- package/dist/services/MarketDataService.cjs +0 -1138
- package/dist/services/MarketDataService.cjs.map +0 -1
- package/dist/services/MarketDataService.d.cts.map +0 -1
- package/dist/services/MarketDataService.d.mts +0 -334
- package/dist/services/MarketDataService.d.mts.map +0 -1
- 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.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.map +0 -1
- package/dist/services/ServiceContext.cjs +0 -3
- package/dist/services/ServiceContext.cjs.map +0 -1
- 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.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.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.map +0 -1
- package/dist/services/TradingReadinessCache.mjs.map +0 -1
- package/dist/services/TradingService.cjs +0 -1865
- package/dist/services/TradingService.cjs.map +0 -1
- 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.map +0 -1
- package/dist/types/config.cjs +0 -3
- package/dist/types/config.cjs.map +0 -1
- 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.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.map +0 -1
- package/dist/types/index.cjs +0 -151
- package/dist/types/index.cjs.map +0 -1
- package/dist/types/index.d.cts.map +0 -1
- package/dist/types/index.d.mts +0 -1951
- package/dist/types/index.d.mts.map +0 -1
- package/dist/types/index.mjs.map +0 -1
- package/dist/types/messenger.cjs +0 -3
- package/dist/types/messenger.cjs.map +0 -1
- package/dist/types/messenger.d.cts +0 -30
- package/dist/types/messenger.d.cts.map +0 -1
- package/dist/types/messenger.d.mts.map +0 -1
- package/dist/types/messenger.mjs +0 -2
- package/dist/types/messenger.mjs.map +0 -1
- package/dist/types/myx-types.cjs +0 -41
- package/dist/types/myx-types.cjs.map +0 -1
- package/dist/types/myx-types.d.cts +0 -94
- package/dist/types/myx-types.d.cts.map +0 -1
- package/dist/types/myx-types.d.mts.map +0 -1
- package/dist/types/myx-types.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.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.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.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.map +0 -1
- package/dist/utils/accountUtils.cjs +0 -236
- package/dist/utils/accountUtils.cjs.map +0 -1
- 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.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.map +0 -1
- 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.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.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.map +0 -1
- 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.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.map +0 -1
- package/dist/utils/hyperLiquidAdapter.cjs +0 -512
- package/dist/utils/hyperLiquidAdapter.cjs.map +0 -1
- 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.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.map +0 -1
- package/dist/utils/hyperLiquidOrderBookProcessor.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.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.map +0 -1
- package/dist/utils/idUtils.cjs +0 -18
- package/dist/utils/idUtils.cjs.map +0 -1
- 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.map +0 -1
- package/dist/utils/index.cjs +0 -65
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.d.cts +0 -28
- package/dist/utils/index.d.cts.map +0 -1
- package/dist/utils/index.d.mts +0 -28
- package/dist/utils/index.d.mts.map +0 -1
- package/dist/utils/index.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.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.map +0 -1
- package/dist/utils/marketSearch.cjs +0 -111
- package/dist/utils/marketSearch.cjs.map +0 -1
- 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.map +0 -1
- package/dist/utils/marketUtils.cjs +0 -266
- package/dist/utils/marketUtils.cjs.map +0 -1
- 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.map +0 -1
- package/dist/utils/myxAdapter.cjs +0 -569
- package/dist/utils/myxAdapter.cjs.map +0 -1
- package/dist/utils/myxAdapter.d.cts.map +0 -1
- package/dist/utils/myxAdapter.d.mts +0 -168
- package/dist/utils/myxAdapter.d.mts.map +0 -1
- package/dist/utils/myxAdapter.mjs.map +0 -1
- package/dist/utils/orderCalculations.cjs +0 -823
- package/dist/utils/orderCalculations.cjs.map +0 -1
- package/dist/utils/orderCalculations.d.cts.map +0 -1
- package/dist/utils/orderCalculations.d.mts +0 -298
- package/dist/utils/orderCalculations.d.mts.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.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.map +0 -1
- package/dist/utils/perpsFormatters.cjs +0 -509
- package/dist/utils/perpsFormatters.cjs.map +0 -1
- 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.map +0 -1
- package/dist/utils/rewardsUtils.cjs +0 -98
- package/dist/utils/rewardsUtils.cjs.map +0 -1
- 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.map +0 -1
- package/dist/utils/significantFigures.cjs +0 -88
- package/dist/utils/significantFigures.cjs.map +0 -1
- 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.map +0 -1
- package/dist/utils/sortMarkets.cjs +0 -93
- package/dist/utils/sortMarkets.cjs.map +0 -1
- 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.map +0 -1
- package/dist/utils/standaloneInfoClient.cjs +0 -70
- package/dist/utils/standaloneInfoClient.cjs.map +0 -1
- 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.map +0 -1
- package/dist/utils/stringParseUtils.cjs +0 -34
- package/dist/utils/stringParseUtils.cjs.map +0 -1
- 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.map +0 -1
- package/dist/utils/transferData.cjs +0 -33
- package/dist/utils/transferData.cjs.map +0 -1
- 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.map +0 -1
- package/dist/utils/wait.cjs +0 -6
- package/dist/utils/wait.cjs.map +0 -1
- 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.map +0 -1
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Price threshold constants for PRICE_RANGES_UNIVERSAL
|
|
3
|
-
* These define the boundaries between different formatting ranges
|
|
4
|
-
*/
|
|
5
|
-
export declare const PRICE_THRESHOLD: {
|
|
6
|
-
/** Very high values boundary (> $100k) */
|
|
7
|
-
readonly VERY_HIGH: 100000;
|
|
8
|
-
/** High values boundary (> $10k) */
|
|
9
|
-
readonly HIGH: 10000;
|
|
10
|
-
/** Large values boundary (> $1k) */
|
|
11
|
-
readonly LARGE: 1000;
|
|
12
|
-
/** Medium values boundary (> $100) */
|
|
13
|
-
readonly MEDIUM: 100;
|
|
14
|
-
/** Medium-low values boundary (> $10) */
|
|
15
|
-
readonly MEDIUM_LOW: 10;
|
|
16
|
-
/** Low values boundary (>= $0.01) */
|
|
17
|
-
readonly LOW: 0.01;
|
|
18
|
-
/**
|
|
19
|
-
* Very small values threshold (< $0.01)
|
|
20
|
-
* This is the minimum value for formatWithThreshold and should align with
|
|
21
|
-
* the 6 decimal maximum (0.000001 is the smallest representable value)
|
|
22
|
-
*/
|
|
23
|
-
readonly VERY_SMALL: 0.000001;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Configuration for a specific number range formatting
|
|
27
|
-
*/
|
|
28
|
-
export type FiatRangeConfig = {
|
|
29
|
-
/**
|
|
30
|
-
* The condition to match for this range (e.g., < 0.0001, < 1, >= 1000)
|
|
31
|
-
* Function should return true if this config should be applied
|
|
32
|
-
*/
|
|
33
|
-
condition: (value: number) => boolean;
|
|
34
|
-
/** Minimum decimal places for this range */
|
|
35
|
-
minimumDecimals: number;
|
|
36
|
-
/** Maximum decimal places for this range */
|
|
37
|
-
maximumDecimals: number;
|
|
38
|
-
/** Optional threshold for formatWithThreshold (defaults to the range boundary) */
|
|
39
|
-
threshold?: number;
|
|
40
|
-
/** Optional significant digits for this range (overrides decimal places when set) */
|
|
41
|
-
significantDigits?: number;
|
|
42
|
-
/** Optional custom formatting logic for this range */
|
|
43
|
-
customFormat?: (value: number, locale: string, currency: string) => string;
|
|
44
|
-
/** Optional flag to strip trailing zeros for this range (overrides global stripTrailingZeros option) */
|
|
45
|
-
stripTrailingZeros?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Optional flag for fiat-style stripping (only strips .00, preserves meaningful decimals like .10, .40)
|
|
48
|
-
* When true, "$1,250.00" → "$1,250" but "$1,250.10" stays "$1,250.10"
|
|
49
|
-
* When false (default), strips all trailing zeros: "$1,250.10" → "$1,250.1"
|
|
50
|
-
*/
|
|
51
|
-
fiatStyleStripping?: boolean;
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Formats a number to a specific number of significant digits
|
|
55
|
-
* Strips trailing zeros unless minDecimals requires them
|
|
56
|
-
*
|
|
57
|
-
* @param value - The numeric value to format
|
|
58
|
-
* @param significantDigits - Number of significant digits to maintain
|
|
59
|
-
* @param minDecimals - Minimum decimal places to show (may add zeros)
|
|
60
|
-
* @param maxDecimals - Maximum decimal places allowed
|
|
61
|
-
* @returns Formatted number with appropriate precision, trailing zeros removed
|
|
62
|
-
*/
|
|
63
|
-
export declare function formatWithSignificantDigits(value: number, significantDigits: number, minDecimals?: number, maxDecimals?: number): {
|
|
64
|
-
value: number;
|
|
65
|
-
decimals: number;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Minimal view fiat range configuration
|
|
69
|
-
* Uses fiat-style stripping for clean currency display
|
|
70
|
-
* Strips only .00 to avoid partial decimals like $1,250.1
|
|
71
|
-
*/
|
|
72
|
-
export declare const PRICE_RANGES_MINIMAL_VIEW: FiatRangeConfig[];
|
|
73
|
-
/**
|
|
74
|
-
* Universal price range configuration following comprehensive rules from rules-decimals.md
|
|
75
|
-
*
|
|
76
|
-
* Rules:
|
|
77
|
-
* - Max 6 decimals across all ranges (Hyperliquid limit)
|
|
78
|
-
* - Strip trailing zeros by default
|
|
79
|
-
* - Use |v| (absolute value) for conditions
|
|
80
|
-
*
|
|
81
|
-
* Significant digits by range:
|
|
82
|
-
* - > $100,000: 6 sig digs
|
|
83
|
-
* - $100,000 > x > $0.01: 5 sig digs
|
|
84
|
-
* - < $0.01: 4 sig digs
|
|
85
|
-
*
|
|
86
|
-
* Decimal limits by price range:
|
|
87
|
-
* - |v| > 10,000: min 0, max 0 decimals; 5 sig digs (6 if >100k)
|
|
88
|
-
* - |v| > 1,000: min 0, max 1 decimal; 5 sig digs
|
|
89
|
-
* - |v| > 100: min 0, max 2 decimals; 5 sig digs
|
|
90
|
-
* - |v| > 10: min 0, max 4 decimals; 5 sig digs
|
|
91
|
-
* - |v| ≥ 0.01: 5 sig digs, min 2, max 6 decimals
|
|
92
|
-
* - |v| < 0.01: 4 sig digs, min 2, max 6 decimals
|
|
93
|
-
*
|
|
94
|
-
* Examples:
|
|
95
|
-
* - $123,456.78 → $123,457 (>$10k: 0 decimals, 6 sig figs)
|
|
96
|
-
* - $12,345.67 → $12,346 (>$10k: 0 decimals, 5 sig figs)
|
|
97
|
-
* - $1,234.56 → $1,234.6 ($1k-$10k: 1 decimal, 5 sig figs)
|
|
98
|
-
* - $123.456 → $123.46 ($100-$1k: 2 decimals, 5 sig figs)
|
|
99
|
-
* - $12.34567 → $12.346 ($10-$100: 4 decimals, 5 sig figs)
|
|
100
|
-
* - $1.3445555 → $1.3446 (≥$0.01: 5 sig figs)
|
|
101
|
-
* - $0.333333 → $0.33333 (≥$0.01: 5 sig figs)
|
|
102
|
-
* - $0.004236 → $0.004236 (<$0.01: 4 sig figs, max 6 decimals)
|
|
103
|
-
* - $0.0000006 → $0.000001 (<$0.01: 4 sig figs, rounds with max 6 decimals)
|
|
104
|
-
*/
|
|
105
|
-
export declare const PRICE_RANGES_UNIVERSAL: FiatRangeConfig[];
|
|
106
|
-
/**
|
|
107
|
-
* Formats a balance value as USD currency with appropriate decimal places
|
|
108
|
-
*
|
|
109
|
-
* @param balance - Raw numeric balance value (e.g., 1234.56, not token minimal denomination)
|
|
110
|
-
* @param options - Optional formatting options
|
|
111
|
-
* @param options.minimumDecimals - Global minimum decimal places (overrides range configs)
|
|
112
|
-
* @param options.maximumDecimals - Global maximum decimal places (overrides range configs)
|
|
113
|
-
* @param options.significantDigits - Global significant digits (overrides decimal settings when set)
|
|
114
|
-
* @param options.ranges - Custom range configurations (defaults to PRICE_RANGES_MINIMAL_VIEW)
|
|
115
|
-
* @param options.currency - Currency code (default: 'USD')
|
|
116
|
-
* @param options.locale - Locale for formatting (default: 'en-US')
|
|
117
|
-
* @param options.stripTrailingZeros - Strip trailing zeros from output (default: false via PRICE_RANGES_MINIMAL_VIEW). When true, overrides minimumDecimals constraint.
|
|
118
|
-
* @returns Formatted currency string with variable decimals based on configured ranges
|
|
119
|
-
* @example
|
|
120
|
-
* // Using defaults (preserves trailing zeros for fiat)
|
|
121
|
-
* formatPerpsFiat(1234.56) => "$1,234.56"
|
|
122
|
-
* formatPerpsFiat(1250.00) => "$1,250.00" // Trailing zeros preserved
|
|
123
|
-
* formatPerpsFiat(50000) => "$50,000.00" // Trailing zeros preserved
|
|
124
|
-
*
|
|
125
|
-
* // Stripping trailing zeros when needed (e.g., for crypto)
|
|
126
|
-
* formatPerpsFiat(1250, { stripTrailingZeros: true }) => "$1,250"
|
|
127
|
-
*
|
|
128
|
-
* // With custom ranges
|
|
129
|
-
* formatPerpsFiat(0.00001, {
|
|
130
|
-
* ranges: [
|
|
131
|
-
* { condition: (v) => v < 0.001, minimumDecimals: 6, maximumDecimals: 8 },
|
|
132
|
-
* { condition: () => true, minimumDecimals: 2, maximumDecimals: 2 }
|
|
133
|
-
* ]
|
|
134
|
-
* }) => "$0.00001" // Trailing zero stripped
|
|
135
|
-
*
|
|
136
|
-
* // With significant digits
|
|
137
|
-
* formatPerpsFiat(1234.56789, { significantDigits: 5 }) => "$1,234.6"
|
|
138
|
-
* formatPerpsFiat(0.0001234, { significantDigits: 3 }) => "$0.000123"
|
|
139
|
-
*/
|
|
140
|
-
export declare const formatPerpsFiat: (balance: string | number, options?: {
|
|
141
|
-
minimumDecimals?: number;
|
|
142
|
-
maximumDecimals?: number;
|
|
143
|
-
significantDigits?: number;
|
|
144
|
-
ranges?: FiatRangeConfig[];
|
|
145
|
-
currency?: string;
|
|
146
|
-
locale?: string;
|
|
147
|
-
stripTrailingZeros?: boolean;
|
|
148
|
-
}) => string;
|
|
149
|
-
/**
|
|
150
|
-
* Formats position size with variable decimal precision based on magnitude or asset-specific decimals
|
|
151
|
-
* Removes trailing zeros to match task requirements
|
|
152
|
-
*
|
|
153
|
-
* @param size - Raw position size value
|
|
154
|
-
* @param szDecimals - Optional asset-specific decimal precision from Hyperliquid metadata (e.g., BTC=5, ETH=4, DOGE=1)
|
|
155
|
-
* @returns Format varies by size or uses asset-specific decimals, with trailing zeros removed:
|
|
156
|
-
* If szDecimals provided: Uses exact decimals (e.g., 0.00009 BTC with szDecimals=5 => "0.00009")
|
|
157
|
-
* Otherwise falls back to magnitude-based logic:
|
|
158
|
-
* - Size < 0.01: Up to 6 decimals (e.g., "0.00009" not "0.000090")
|
|
159
|
-
* - Size < 1: Up to 4 decimals (e.g., "0.0024" not "0.002400")
|
|
160
|
-
* - Size >= 1: Up to 2 decimals (e.g., "44" not "44.00")
|
|
161
|
-
* @example formatPositionSize(0.00009, 5) => "0.00009" (uses szDecimals)
|
|
162
|
-
* @example formatPositionSize(44.00, 1) => "44" (uses szDecimals, trailing zeros removed)
|
|
163
|
-
* @example formatPositionSize(0.0024) => "0.0024" (no szDecimals, uses magnitude logic)
|
|
164
|
-
* @example formatPositionSize(44.00) => "44" (no szDecimals, uses magnitude logic)
|
|
165
|
-
*/
|
|
166
|
-
export declare const formatPositionSize: (size: string | number, szDecimals?: number) => string;
|
|
167
|
-
/**
|
|
168
|
-
* Formats a PnL (Profit and Loss) value with sign prefix
|
|
169
|
-
*
|
|
170
|
-
* @param pnl - Raw numeric PnL value (positive for profit, negative for loss)
|
|
171
|
-
* @returns Format: "+$X,XXX.XX" or "-$X,XXX.XX" (always shows sign, 2 decimals)
|
|
172
|
-
* @example formatPnl(1234.56) => "+$1,234.56"
|
|
173
|
-
* @example formatPnl(-500) => "-$500.00"
|
|
174
|
-
* @example formatPnl(0) => "+$0.00"
|
|
175
|
-
*/
|
|
176
|
-
export declare const formatPnl: (pnl: string | number) => string;
|
|
177
|
-
/**
|
|
178
|
-
* Formats a percentage value with sign prefix
|
|
179
|
-
*
|
|
180
|
-
* @param value - Raw percentage value (e.g., 5.25 for 5.25%, not 0.0525)
|
|
181
|
-
* @param decimals - Number of decimal places to show (default: 2)
|
|
182
|
-
* @returns Format: "+X.XX%" or "-X.XX%" (always shows sign, 2 decimals)
|
|
183
|
-
* @example formatPercentage(5.25) => "+5.25%"
|
|
184
|
-
* @example formatPercentage(-2.75) => "-2.75%"
|
|
185
|
-
* @example formatPercentage(0) => "+0.00%"
|
|
186
|
-
*/
|
|
187
|
-
export declare const formatPercentage: (value: string | number, decimals?: number) => string;
|
|
188
|
-
/**
|
|
189
|
-
* Formats funding rate for display
|
|
190
|
-
*
|
|
191
|
-
* @param value - Raw funding rate value (decimal, not percentage)
|
|
192
|
-
* @param options - Optional formatting options
|
|
193
|
-
* @param options.showZero - Whether to return zero display value for zero/undefined (default: true)
|
|
194
|
-
* @returns Formatted funding rate as percentage string
|
|
195
|
-
* @example formatFundingRate(0.0005) => "0.0500%"
|
|
196
|
-
* @example formatFundingRate(-0.0001) => "-0.0100%"
|
|
197
|
-
* @example formatFundingRate(0.000000059) => "<0.0001%"
|
|
198
|
-
* @example formatFundingRate(-0.000000059) => "-<0.0001%"
|
|
199
|
-
* @example formatFundingRate(undefined) => "0.0000%"
|
|
200
|
-
*/
|
|
201
|
-
export declare const formatFundingRate: (value?: number | null, options?: {
|
|
202
|
-
showZero?: boolean;
|
|
203
|
-
}) => string;
|
|
204
|
-
//# sourceMappingURL=perpsFormatters.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"perpsFormatters.d.mts","sourceRoot":"","sources":["../../src/utils/perpsFormatters.ts"],"names":[],"mappings":"AAyEA;;;GAGG;AACH,eAAO,MAAM,eAAe;IAC1B,0CAA0C;;IAE1C,oCAAoC;;IAEpC,oCAAoC;;IAEpC,sCAAsC;;IAEtC,yCAAyC;;IAEzC,qCAAqC;;IAErC;;;;OAIG;;CAEK,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACtC,4CAA4C;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,4CAA4C;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qFAAqF;IACrF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3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B,CAAC,QAAQ,CAC7B,CAAC;QACF,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,SAAS,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS,GAAG,CAAC;IAC1D,CAAC;IAED,0CAA0C;IAC1C,IAAI,QAAQ,IAAI,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5C,OAAO,mBAAmB,CAAC,WAAW,CAAC;IACzC,CAAC;IAED,OAAO,GAAG,SAAS,GAAG,CAAC;AACzB,CAAC,CAAC","sourcesContent":["/**\n * Portable perps decimal formatters.\n *\n * These are the canonical implementations, exported from the controller so\n * extension and any future consumer can import them directly.\n * No mobile-specific imports — safe to sync to Core.\n *\n * Intl.NumberFormat instances are cached in a module-level Map keyed by\n * serialized options, avoiding repeated construction costs.\n */\nimport {\n DECIMAL_PRECISION_CONFIG,\n FUNDING_RATE_CONFIG,\n PERPS_CONSTANTS,\n} from '../constants/perpsConfig.js';\n\n// Module-level Intl.NumberFormat cache (keyed by serialized options).\nconst _fmtCache = new Map<string, Intl.NumberFormat>();\n\nfunction _formatCurrency(\n value: number,\n currency: string,\n opts: { minimumFractionDigits: number; maximumFractionDigits: number },\n): string {\n const key = `${currency}:${opts.minimumFractionDigits}:${opts.maximumFractionDigits}`;\n let formatter = _fmtCache.get(key);\n if (!formatter) {\n formatter = new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency,\n currencyDisplay: 'narrowSymbol',\n minimumFractionDigits: opts.minimumFractionDigits,\n maximumFractionDigits: opts.maximumFractionDigits,\n });\n _fmtCache.set(key, formatter);\n }\n return formatter.format(value);\n}\n\n/**\n * Internal equivalent of the mobile formatWithThreshold utility.\n * Formats a currency value, returning \"<$X.XX\" for values below threshold.\n *\n * @param amount - The numeric amount to format.\n * @param threshold - The threshold below which the \"<\" prefix is shown.\n * @param options - Intl formatting options.\n * @param options.currency - ISO 4217 currency code.\n * @param options.minimumFractionDigits - Minimum decimal digits.\n * @param options.maximumFractionDigits - Maximum decimal digits.\n * @returns Formatted currency string.\n */\nfunction _formatWithThreshold(\n amount: number,\n threshold: number,\n options: {\n currency: string;\n minimumFractionDigits: number;\n maximumFractionDigits: number;\n },\n): string {\n const formatOpts = {\n minimumFractionDigits: options.minimumFractionDigits,\n maximumFractionDigits: options.maximumFractionDigits,\n currencyDisplay: 'narrowSymbol' as const,\n };\n if (amount === 0) {\n return _formatCurrency(0, options.currency, formatOpts);\n }\n return Math.abs(amount) < threshold\n ? `<${_formatCurrency(threshold, options.currency, formatOpts)}`\n : _formatCurrency(amount, options.currency, formatOpts);\n}\n\n/**\n * Price threshold constants for PRICE_RANGES_UNIVERSAL\n * These define the boundaries between different formatting ranges\n */\nexport const PRICE_THRESHOLD = {\n /** Very high values boundary (> $100k) */\n VERY_HIGH: 100_000,\n /** High values boundary (> $10k) */\n HIGH: 10_000,\n /** Large values boundary (> $1k) */\n LARGE: 1_000,\n /** Medium values boundary (> $100) */\n MEDIUM: 100,\n /** Medium-low values boundary (> $10) */\n MEDIUM_LOW: 10,\n /** Low values boundary (>= $0.01) */\n LOW: 0.01,\n /**\n * Very small values threshold (< $0.01)\n * This is the minimum value for formatWithThreshold and should align with\n * the 6 decimal maximum (0.000001 is the smallest representable value)\n */\n VERY_SMALL: 0.000001,\n} as const;\n\n/**\n * Configuration for a specific number range formatting\n */\nexport type FiatRangeConfig = {\n /**\n * The condition to match for this range (e.g., < 0.0001, < 1, >= 1000)\n * Function should return true if this config should be applied\n */\n condition: (value: number) => boolean;\n /** Minimum decimal places for this range */\n minimumDecimals: number;\n /** Maximum decimal places for this range */\n maximumDecimals: number;\n /** Optional threshold for formatWithThreshold (defaults to the range boundary) */\n threshold?: number;\n /** Optional significant digits for this range (overrides decimal places when set) */\n significantDigits?: number;\n /** Optional custom formatting logic for this range */\n customFormat?: (value: number, locale: string, currency: string) => string;\n /** Optional flag to strip trailing zeros for this range (overrides global stripTrailingZeros option) */\n stripTrailingZeros?: boolean;\n /**\n * Optional flag for fiat-style stripping (only strips .00, preserves meaningful decimals like .10, .40)\n * When true, \"$1,250.00\" → \"$1,250\" but \"$1,250.10\" stays \"$1,250.10\"\n * When false (default), strips all trailing zeros: \"$1,250.10\" → \"$1,250.1\"\n */\n fiatStyleStripping?: boolean;\n};\n\n/**\n * Formats a number to a specific number of significant digits\n * Strips trailing zeros unless minDecimals requires them\n *\n * @param value - The numeric value to format\n * @param significantDigits - Number of significant digits to maintain\n * @param minDecimals - Minimum decimal places to show (may add zeros)\n * @param maxDecimals - Maximum decimal places allowed\n * @returns Formatted number with appropriate precision, trailing zeros removed\n */\nexport function formatWithSignificantDigits(\n value: number,\n significantDigits: number,\n minDecimals?: number,\n maxDecimals?: number,\n): { value: number; decimals: number } {\n // Handle special cases\n if (value === 0) {\n // Return zero with no trailing decimals by default (matches stripTrailingZeros behavior)\n // Can be overridden by explicit minDecimals if needed\n return { value: 0, decimals: minDecimals ?? 0 };\n }\n\n const absValue = Math.abs(value);\n\n // For numbers >= 1, calculate decimals based on magnitude to achieve target significant figures\n // This ensures consistent precision across different price ranges:\n // Examples with 4 significant figures:\n // $123,456.78 → $123,456.78 (≥$1000: 2 decimals minimum, 8 sig figs)\n // $456.12 → $456.12 (≥$10: 2 decimals minimum, 5 sig figs)\n // $56.123 → $56.123 (≥$10: 2 decimals minimum, 5 sig figs)\n // $5.123 → $5.123 ($1-$10: 3 decimals = 4 sig figs)\n // $2.801 → $2.801 ($1-$10: 3 decimals = 4 sig figs)\n // $1.234 → $1.234 ($1-$10: 3 decimals = 4 sig figs)\n if (absValue >= 1) {\n let targetDecimals: number;\n\n // Calculate decimals needed based on integer digits to achieve target significant figures\n // For $38.388 with 5 sig figs: 2 integer digits, need 3 decimals (3,8,3,8,8)\n // For $123.45 with 5 sig figs: 3 integer digits, need 2 decimals (1,2,3,4,5)\n const integerDigits = Math.floor(Math.log10(absValue)) + 1;\n const decimalsNeeded = significantDigits - integerDigits;\n targetDecimals = Math.max(decimalsNeeded, 0); // Can't have negative decimals\n\n // Apply explicit minimum decimals constraint if provided (for special cases)\n if (minDecimals !== undefined && targetDecimals < minDecimals) {\n targetDecimals = minDecimals;\n }\n\n // Apply maximum decimals constraint if specified\n const finalDecimals =\n maxDecimals === undefined\n ? targetDecimals\n : Math.min(targetDecimals, maxDecimals);\n\n // Round to prevent floating-point artifacts (e.g., 2.820000000000003 → 2.82)\n const roundedValue = Number(value.toFixed(finalDecimals));\n\n return {\n value: roundedValue,\n decimals: finalDecimals,\n };\n }\n\n // For numbers < 1, use toPrecision to limit to significantDigits\n // Examples: 0.1234, 0.01234 should show exactly 4 sig figs\n const precisionStr = absValue.toPrecision(significantDigits);\n const precisionNum = parseFloat(precisionStr);\n\n // Convert to string to count actual decimals after trailing zeros are removed\n const valueStr = precisionNum.toString();\n const [, decPart = ''] = valueStr.split('.');\n let actualDecimals = decPart.length;\n\n // Apply min/max decimal constraints\n if (minDecimals !== undefined && actualDecimals < minDecimals) {\n actualDecimals = minDecimals; // Will add zeros if needed\n }\n if (maxDecimals !== undefined && actualDecimals > maxDecimals) {\n actualDecimals = maxDecimals;\n }\n\n // Return the value with sign restored and decimal count\n return {\n value: value < 0 ? -precisionNum : precisionNum,\n decimals: actualDecimals,\n };\n}\n\n/**\n * Minimal view fiat range configuration\n * Uses fiat-style stripping for clean currency display\n * Strips only .00 to avoid partial decimals like $1,250.1\n */\nexport const PRICE_RANGES_MINIMAL_VIEW: FiatRangeConfig[] = [\n {\n // Large values (>= $1000): Strip .00 only ($5,000 not $5,000.00, but $5,000.10 stays)\n condition: (val: number) => Math.abs(val) >= PRICE_THRESHOLD.LARGE,\n minimumDecimals: 2,\n maximumDecimals: 2,\n threshold: PRICE_THRESHOLD.LARGE,\n stripTrailingZeros: true,\n fiatStyleStripping: true,\n },\n {\n // Small values (< $1000): Also use fiat-style stripping ($100 not $100.00, but $13.40 stays)\n condition: () => true,\n minimumDecimals: 2,\n maximumDecimals: 2,\n threshold: PRICE_THRESHOLD.LOW,\n stripTrailingZeros: true,\n fiatStyleStripping: true,\n },\n];\n\n/**\n * Universal price range configuration following comprehensive rules from rules-decimals.md\n *\n * Rules:\n * - Max 6 decimals across all ranges (Hyperliquid limit)\n * - Strip trailing zeros by default\n * - Use |v| (absolute value) for conditions\n *\n * Significant digits by range:\n * - > $100,000: 6 sig digs\n * - $100,000 > x > $0.01: 5 sig digs\n * - < $0.01: 4 sig digs\n *\n * Decimal limits by price range:\n * - |v| > 10,000: min 0, max 0 decimals; 5 sig digs (6 if >100k)\n * - |v| > 1,000: min 0, max 1 decimal; 5 sig digs\n * - |v| > 100: min 0, max 2 decimals; 5 sig digs\n * - |v| > 10: min 0, max 4 decimals; 5 sig digs\n * - |v| ≥ 0.01: 5 sig digs, min 2, max 6 decimals\n * - |v| < 0.01: 4 sig digs, min 2, max 6 decimals\n *\n * Examples:\n * - $123,456.78 → $123,457 (>$10k: 0 decimals, 6 sig figs)\n * - $12,345.67 → $12,346 (>$10k: 0 decimals, 5 sig figs)\n * - $1,234.56 → $1,234.6 ($1k-$10k: 1 decimal, 5 sig figs)\n * - $123.456 → $123.46 ($100-$1k: 2 decimals, 5 sig figs)\n * - $12.34567 → $12.346 ($10-$100: 4 decimals, 5 sig figs)\n * - $1.3445555 → $1.3446 (≥$0.01: 5 sig figs)\n * - $0.333333 → $0.33333 (≥$0.01: 5 sig figs)\n * - $0.004236 → $0.004236 (<$0.01: 4 sig figs, max 6 decimals)\n * - $0.0000006 → $0.000001 (<$0.01: 4 sig figs, rounds with max 6 decimals)\n */\nexport const PRICE_RANGES_UNIVERSAL: FiatRangeConfig[] = [\n {\n // Very high values (> $100,000): No decimals, 6 significant figures\n // Ex: $123,456.78 → $123,457\n condition: (val) => Math.abs(val) > PRICE_THRESHOLD.VERY_HIGH,\n minimumDecimals: 0,\n maximumDecimals: 0,\n significantDigits: 6,\n threshold: PRICE_THRESHOLD.VERY_HIGH,\n },\n {\n // High values ($10,000-$100,000]: No decimals, 5 significant figures\n // Ex: $12,345.67 → $12,346\n condition: (val) => Math.abs(val) > PRICE_THRESHOLD.HIGH,\n minimumDecimals: 0,\n maximumDecimals: 0,\n significantDigits: 5,\n threshold: PRICE_THRESHOLD.HIGH,\n },\n {\n // Large values ($1,000-$10,000]: Max 1 decimal, 5 significant figures\n // Ex: $1,234.56 → $1,234.6\n condition: (val) => Math.abs(val) > PRICE_THRESHOLD.LARGE,\n minimumDecimals: 0,\n maximumDecimals: 1,\n significantDigits: 5,\n threshold: PRICE_THRESHOLD.LARGE,\n },\n {\n // Medium values ($100-$1,000]: Max 2 decimals, 5 significant figures\n // Ex: $123.456 → $123.46\n condition: (val) => Math.abs(val) > PRICE_THRESHOLD.MEDIUM,\n minimumDecimals: 0,\n maximumDecimals: 2,\n significantDigits: 5,\n threshold: PRICE_THRESHOLD.MEDIUM,\n },\n {\n // Medium-low values ($10-$100]: Max 4 decimals, 5 significant figures\n // Ex: $12.34567 → $12.346\n condition: (val) => Math.abs(val) > PRICE_THRESHOLD.MEDIUM_LOW,\n minimumDecimals: 0,\n maximumDecimals: 4,\n significantDigits: 5,\n threshold: PRICE_THRESHOLD.MEDIUM_LOW,\n },\n {\n // Low values ($0.01-$10]: 5 significant figures, min 2 max MAX_PRICE_DECIMALS decimals\n // Ex: $1.3445555 → $1.3446 | $0.333333 → $0.33333\n condition: (val) => Math.abs(val) >= PRICE_THRESHOLD.LOW,\n significantDigits: 5,\n minimumDecimals: 2,\n maximumDecimals: DECIMAL_PRECISION_CONFIG.MaxPriceDecimals,\n threshold: PRICE_THRESHOLD.LOW,\n },\n {\n // Very small values (< $0.01): 4 significant figures, min 2 max MAX_PRICE_DECIMALS decimals\n // Ex: $0.004236 → $0.004236 | $0.0000006 → $0.000001\n condition: () => true,\n significantDigits: 4,\n minimumDecimals: 2,\n maximumDecimals: DECIMAL_PRECISION_CONFIG.MaxPriceDecimals,\n threshold: PRICE_THRESHOLD.VERY_SMALL,\n },\n];\n\n/**\n * Formats a balance value as USD currency with appropriate decimal places\n *\n * @param balance - Raw numeric balance value (e.g., 1234.56, not token minimal denomination)\n * @param options - Optional formatting options\n * @param options.minimumDecimals - Global minimum decimal places (overrides range configs)\n * @param options.maximumDecimals - Global maximum decimal places (overrides range configs)\n * @param options.significantDigits - Global significant digits (overrides decimal settings when set)\n * @param options.ranges - Custom range configurations (defaults to PRICE_RANGES_MINIMAL_VIEW)\n * @param options.currency - Currency code (default: 'USD')\n * @param options.locale - Locale for formatting (default: 'en-US')\n * @param options.stripTrailingZeros - Strip trailing zeros from output (default: false via PRICE_RANGES_MINIMAL_VIEW). When true, overrides minimumDecimals constraint.\n * @returns Formatted currency string with variable decimals based on configured ranges\n * @example\n * // Using defaults (preserves trailing zeros for fiat)\n * formatPerpsFiat(1234.56) => \"$1,234.56\"\n * formatPerpsFiat(1250.00) => \"$1,250.00\" // Trailing zeros preserved\n * formatPerpsFiat(50000) => \"$50,000.00\" // Trailing zeros preserved\n *\n * // Stripping trailing zeros when needed (e.g., for crypto)\n * formatPerpsFiat(1250, { stripTrailingZeros: true }) => \"$1,250\"\n *\n * // With custom ranges\n * formatPerpsFiat(0.00001, {\n * ranges: [\n * { condition: (v) => v < 0.001, minimumDecimals: 6, maximumDecimals: 8 },\n * { condition: () => true, minimumDecimals: 2, maximumDecimals: 2 }\n * ]\n * }) => \"$0.00001\" // Trailing zero stripped\n *\n * // With significant digits\n * formatPerpsFiat(1234.56789, { significantDigits: 5 }) => \"$1,234.6\"\n * formatPerpsFiat(0.0001234, { significantDigits: 3 }) => \"$0.000123\"\n */\nexport const formatPerpsFiat = (\n balance: string | number,\n options?: {\n minimumDecimals?: number;\n maximumDecimals?: number;\n significantDigits?: number;\n ranges?: FiatRangeConfig[];\n currency?: string;\n locale?: string;\n stripTrailingZeros?: boolean;\n },\n): string => {\n const value = typeof balance === 'string' ? parseFloat(balance) : balance;\n const currency = options?.currency ?? 'USD';\n\n let formatted: string;\n\n if (isNaN(value)) {\n // Return placeholder for invalid values to avoid confusion with actual $0 values\n return PERPS_CONSTANTS.FallbackPriceDisplay;\n }\n\n // Use custom ranges or defaults\n const ranges = options?.ranges ?? PRICE_RANGES_MINIMAL_VIEW;\n\n // Find the first matching range configuration\n const rangeConfig = ranges.find((range) => range.condition(value));\n\n if (rangeConfig) {\n // Check for significant digits (global or range-specific)\n const sigDigits =\n options?.significantDigits ?? rangeConfig.significantDigits;\n\n // If significant digits are specified, use them\n if (sigDigits) {\n // Get min/max decimals (global overrides range, range overrides default)\n const minDecimals =\n options?.minimumDecimals ?? rangeConfig.minimumDecimals;\n const maxDecimals =\n options?.maximumDecimals ?? rangeConfig.maximumDecimals;\n\n // Calculate appropriate formatting based on significant digits\n const { value: formattedValue, decimals } = formatWithSignificantDigits(\n value,\n sigDigits,\n minDecimals,\n maxDecimals,\n );\n\n // Format with the calculated decimal places\n formatted = _formatWithThreshold(\n formattedValue,\n rangeConfig.threshold ?? 0.01,\n {\n currency,\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n },\n );\n } else {\n // Standard decimal-based formatting (existing logic)\n const minDecimals =\n options?.minimumDecimals ?? rangeConfig.minimumDecimals;\n const maxDecimals =\n options?.maximumDecimals ?? rangeConfig.maximumDecimals;\n\n // Use custom formatting if provided\n if (rangeConfig.customFormat) {\n formatted = rangeConfig.customFormat(\n value,\n options?.locale ?? 'en-US',\n currency,\n );\n } else {\n // Use standard formatting with threshold\n formatted = _formatWithThreshold(value, rangeConfig.threshold ?? 0.01, {\n currency,\n minimumFractionDigits: minDecimals,\n maximumFractionDigits: maxDecimals,\n });\n }\n }\n } else {\n // Fallback if no range matches (shouldn't happen with proper default config)\n const fallbackMin = options?.minimumDecimals ?? 2;\n const fallbackMax = options?.maximumDecimals ?? 2;\n formatted = _formatWithThreshold(value, 0.01, {\n currency,\n minimumFractionDigits: fallbackMin,\n maximumFractionDigits: fallbackMax,\n });\n }\n\n // Post-process: strip trailing zeros unless explicitly disabled\n // Priority: explicit options.stripTrailingZeros false > rangeConfig > options default > true\n // If options.stripTrailingZeros is explicitly false, skip stripping entirely\n if (options?.stripTrailingZeros === false) {\n return formatted;\n }\n\n // Otherwise check range config or default to true\n const shouldStrip =\n rangeConfig?.stripTrailingZeros ?? options?.stripTrailingZeros ?? true;\n\n if (shouldStrip) {\n // Check if fiat-style stripping is enabled (only strips .00)\n const useFiatStyle = rangeConfig?.fiatStyleStripping ?? false;\n\n if (useFiatStyle) {\n // Fiat-style: Only strip .00 (no meaningful decimals), preserve 2-decimal format\n // Examples: $1,250.00 → $1,250 | $1,000.10 → $1,000.10 | $13.40 → $13.40\n return formatted.replace(/\\.00$/u, '');\n }\n // Standard: Strip all trailing zeros after decimal point\n // Examples: $1,250.00 → $1,250 | $100.0 → $100 | $10.5 → $10.5 | $1.234 → $1.234\n return formatted.replace(/(\\.\\d*?)0+$/u, '$1').replace(/\\.$/u, '');\n }\n\n return formatted;\n};\n\n/**\n * Formats position size with variable decimal precision based on magnitude or asset-specific decimals\n * Removes trailing zeros to match task requirements\n *\n * @param size - Raw position size value\n * @param szDecimals - Optional asset-specific decimal precision from Hyperliquid metadata (e.g., BTC=5, ETH=4, DOGE=1)\n * @returns Format varies by size or uses asset-specific decimals, with trailing zeros removed:\n * If szDecimals provided: Uses exact decimals (e.g., 0.00009 BTC with szDecimals=5 => \"0.00009\")\n * Otherwise falls back to magnitude-based logic:\n * - Size < 0.01: Up to 6 decimals (e.g., \"0.00009\" not \"0.000090\")\n * - Size < 1: Up to 4 decimals (e.g., \"0.0024\" not \"0.002400\")\n * - Size >= 1: Up to 2 decimals (e.g., \"44\" not \"44.00\")\n * @example formatPositionSize(0.00009, 5) => \"0.00009\" (uses szDecimals)\n * @example formatPositionSize(44.00, 1) => \"44\" (uses szDecimals, trailing zeros removed)\n * @example formatPositionSize(0.0024) => \"0.0024\" (no szDecimals, uses magnitude logic)\n * @example formatPositionSize(44.00) => \"44\" (no szDecimals, uses magnitude logic)\n */\nexport const formatPositionSize = (\n size: string | number,\n szDecimals?: number,\n): string => {\n const value = typeof size === 'string' ? parseFloat(size) : size;\n\n if (isNaN(value) || value === 0) {\n return '0';\n }\n\n // Use asset-specific decimals if provided (Hyperliquid metadata)\n if (szDecimals !== undefined) {\n const fixed = value.toFixed(szDecimals);\n // Only strip trailing zeros when a decimal point is present; toFixed(0)\n // returns an integer string and the regex would otherwise eat valid zeros\n // on whole-unit assets (szDecimals=0), e.g. \"100\" -> \"1\".\n return fixed.includes('.') ? fixed.replace(/\\.?0+$/u, '') : fixed;\n }\n\n // Fallback: magnitude-based decimal logic for backwards compatibility\n const abs = Math.abs(value);\n let formatted: string;\n\n if (abs < 0.01) {\n // For very small numbers, use more decimal places\n formatted = value.toFixed(6);\n } else if (abs < 1) {\n // For small numbers, use 4 decimal places\n formatted = value.toFixed(4);\n } else {\n // For normal numbers, use 2 decimal places\n formatted = value.toFixed(2);\n }\n\n // Remove trailing zeros and unnecessary decimal point\n return formatted.replace(/\\.?0+$/u, '');\n};\n\n/**\n * Formats a PnL (Profit and Loss) value with sign prefix\n *\n * @param pnl - Raw numeric PnL value (positive for profit, negative for loss)\n * @returns Format: \"+$X,XXX.XX\" or \"-$X,XXX.XX\" (always shows sign, 2 decimals)\n * @example formatPnl(1234.56) => \"+$1,234.56\"\n * @example formatPnl(-500) => \"-$500.00\"\n * @example formatPnl(0) => \"+$0.00\"\n */\nexport const formatPnl = (pnl: string | number): string => {\n const value = typeof pnl === 'string' ? parseFloat(pnl) : pnl;\n\n if (isNaN(value)) {\n return PERPS_CONSTANTS.ZeroAmountDetailedDisplay;\n }\n\n const formatted = _formatCurrency(Math.abs(value), 'USD', {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n });\n\n return value >= 0 ? `+${formatted}` : `-${formatted}`;\n};\n\n/**\n * Formats a percentage value with sign prefix\n *\n * @param value - Raw percentage value (e.g., 5.25 for 5.25%, not 0.0525)\n * @param decimals - Number of decimal places to show (default: 2)\n * @returns Format: \"+X.XX%\" or \"-X.XX%\" (always shows sign, 2 decimals)\n * @example formatPercentage(5.25) => \"+5.25%\"\n * @example formatPercentage(-2.75) => \"-2.75%\"\n * @example formatPercentage(0) => \"+0.00%\"\n */\nexport const formatPercentage = (\n value: string | number,\n decimals: number = 2,\n): string => {\n const parsed = typeof value === 'string' ? parseFloat(value) : value;\n\n if (isNaN(parsed)) {\n return '0.00%';\n }\n\n return `${parsed >= 0 ? '+' : ''}${parsed.toFixed(decimals)}%`;\n};\n\n/**\n * Formats funding rate for display\n *\n * @param value - Raw funding rate value (decimal, not percentage)\n * @param options - Optional formatting options\n * @param options.showZero - Whether to return zero display value for zero/undefined (default: true)\n * @returns Formatted funding rate as percentage string\n * @example formatFundingRate(0.0005) => \"0.0500%\"\n * @example formatFundingRate(-0.0001) => \"-0.0100%\"\n * @example formatFundingRate(0.000000059) => \"<0.0001%\"\n * @example formatFundingRate(-0.000000059) => \"-<0.0001%\"\n * @example formatFundingRate(undefined) => \"0.0000%\"\n */\nexport const formatFundingRate = (\n value?: number | null,\n options?: { showZero?: boolean },\n): string => {\n const showZero = options?.showZero ?? true;\n\n if (value === undefined || value === null) {\n return showZero ? FUNDING_RATE_CONFIG.ZeroDisplay : '';\n }\n\n const percentage = value * FUNDING_RATE_CONFIG.PercentageMultiplier;\n const formatted = percentage.toFixed(FUNDING_RATE_CONFIG.Decimals);\n const minimumDisplayPercentage = 10 ** -FUNDING_RATE_CONFIG.Decimals;\n\n if (value !== 0 && parseFloat(formatted) === 0) {\n const threshold = minimumDisplayPercentage.toFixed(\n FUNDING_RATE_CONFIG.Decimals,\n );\n return value > 0 ? `<${threshold}%` : `-<${threshold}%`;\n }\n\n // Check if the result is effectively zero\n if (showZero && parseFloat(formatted) === 0) {\n return FUNDING_RATE_CONFIG.ZeroDisplay;\n }\n\n return `${formatted}%`;\n};\n"]}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.handleRewardsError = exports.isCaipAccountId = exports.formatAccountToCaipAccountId = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Shared rewards utilities for Perps components
|
|
6
|
-
* Handles CAIP account formatting and rewards integration
|
|
7
|
-
*
|
|
8
|
-
* Portable: no mobile-specific imports.
|
|
9
|
-
* Logger is injected as optional parameter for platform-agnostic error reporting.
|
|
10
|
-
*/
|
|
11
|
-
const controller_utils_1 = require("@metamask/controller-utils");
|
|
12
|
-
const utils_1 = require("@metamask/utils");
|
|
13
|
-
const errorUtils_js_1 = require("./errorUtils.cjs");
|
|
14
|
-
/**
|
|
15
|
-
* Converts a numeric or hex chain ID to a CAIP-2 chain ID string.
|
|
16
|
-
* e.g. '0x1' → 'eip155:1', '42161' → 'eip155:42161'
|
|
17
|
-
*
|
|
18
|
-
* @param chainId - Numeric string or hex string chain ID.
|
|
19
|
-
* @returns CAIP-2 formatted chain ID.
|
|
20
|
-
*/
|
|
21
|
-
function formatChainIdToCaip(chainId) {
|
|
22
|
-
const decimal = chainId.startsWith('0x')
|
|
23
|
-
? parseInt(chainId, 16)
|
|
24
|
-
: parseInt(chainId, 10);
|
|
25
|
-
if (isNaN(decimal)) {
|
|
26
|
-
throw new Error(`Invalid chain ID: ${chainId}`);
|
|
27
|
-
}
|
|
28
|
-
return `eip155:${decimal}`;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Formats an address to CAIP-10 account ID format
|
|
32
|
-
*
|
|
33
|
-
* @param address - The wallet address to format
|
|
34
|
-
* @param chainId - The chain ID (e.g., '1' for mainnet, '42161' for Arbitrum)
|
|
35
|
-
* @param logger - Optional logger for error reporting
|
|
36
|
-
* @returns CAIP-10 formatted account ID or null if formatting fails
|
|
37
|
-
* @example
|
|
38
|
-
* ```typescript
|
|
39
|
-
* const caipId = formatAccountToCaipAccountId('0x123...', '42161');
|
|
40
|
-
* // Returns: 'eip155:42161:0x123...'
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
const formatAccountToCaipAccountId = (address, chainId, logger) => {
|
|
44
|
-
try {
|
|
45
|
-
const caipChainId = formatChainIdToCaip(chainId);
|
|
46
|
-
const { namespace, reference } = (0, utils_1.parseCaipChainId)(caipChainId);
|
|
47
|
-
// Normalize EVM addresses to checksummed format for consistent CAIP IDs
|
|
48
|
-
let normalizedAddress = address;
|
|
49
|
-
if (namespace === 'eip155') {
|
|
50
|
-
normalizedAddress = (0, controller_utils_1.toChecksumHexAddress)(address);
|
|
51
|
-
}
|
|
52
|
-
return (0, utils_1.toCaipAccountId)(namespace, reference, normalizedAddress);
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
logger?.error((0, errorUtils_js_1.ensureError)(error, 'rewardsUtils.formatAccountToCaipAccountId'), {
|
|
56
|
-
context: {
|
|
57
|
-
name: 'rewardsUtils.formatAccountToCaipAccountId',
|
|
58
|
-
data: { address, chainId },
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
exports.formatAccountToCaipAccountId = formatAccountToCaipAccountId;
|
|
65
|
-
/**
|
|
66
|
-
* Type guard to check if a value is a valid CAIP account ID
|
|
67
|
-
*
|
|
68
|
-
* @param value - Value to check
|
|
69
|
-
* @returns True if value is a valid CAIP account ID
|
|
70
|
-
*/
|
|
71
|
-
const isCaipAccountId = (value) => {
|
|
72
|
-
if (typeof value !== 'string') {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
// CAIP-10 format: namespace:reference:account_address
|
|
76
|
-
const parts = value.split(':');
|
|
77
|
-
return parts.length >= 3 && parts[0] === 'eip155';
|
|
78
|
-
};
|
|
79
|
-
exports.isCaipAccountId = isCaipAccountId;
|
|
80
|
-
/**
|
|
81
|
-
* Helper to handle rewards-related errors consistently
|
|
82
|
-
*
|
|
83
|
-
* @param error - The error that occurred
|
|
84
|
-
* @param logger - Optional logger for error reporting
|
|
85
|
-
* @param context - Optional context information
|
|
86
|
-
* @returns A user-friendly error message
|
|
87
|
-
*/
|
|
88
|
-
const handleRewardsError = (error, logger, context) => {
|
|
89
|
-
logger?.error((0, errorUtils_js_1.ensureError)(error, 'rewardsUtils.handleRewardsError'), {
|
|
90
|
-
context: {
|
|
91
|
-
name: 'rewardsUtils.handleRewardsError',
|
|
92
|
-
data: { additionalContext: context },
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
return 'Rewards operation failed';
|
|
96
|
-
};
|
|
97
|
-
exports.handleRewardsError = handleRewardsError;
|
|
98
|
-
//# sourceMappingURL=rewardsUtils.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rewardsUtils.cjs","sourceRoot":"","sources":["../../src/utils/rewardsUtils.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,iEAAkE;AAClE,2CAIyB;AAGzB,oDAA8C;AAE9C;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,OAAe;IAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;QACtC,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;QACvB,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC1B,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,qBAAqB,OAAO,EAAE,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,UAAU,OAAO,EAAE,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;;GAYG;AACI,MAAM,4BAA4B,GAAG,CAC1C,OAAe,EACf,OAAe,EACf,MAAoB,EACE,EAAE;IACxB,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,mBAAmB,CAAC,OAAO,CAA0B,CAAC;QAC1E,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,IAAA,wBAAgB,EAAC,WAAW,CAAC,CAAC;QAE/D,wEAAwE;QACxE,IAAI,iBAAiB,GAAG,OAAO,CAAC;QAChC,IAAI,SAAS,KAAK,QAAQ,EAAE,CAA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components\n * Handles CAIP account formatting and rewards integration\n *\n * Portable: no mobile-specific imports.\n * Logger is injected as optional parameter for platform-agnostic error reporting.\n */\nimport { toChecksumHexAddress } from '@metamask/controller-utils';\nimport {\n toCaipAccountId,\n CaipAccountId,\n parseCaipChainId,\n} from '@metamask/utils';\n\nimport type { PerpsLogger } from '../types/index.js';\nimport { ensureError } from './errorUtils.js';\n\n/**\n * Converts a numeric or hex chain ID to a CAIP-2 chain ID string.\n * e.g. '0x1' → 'eip155:1', '42161' → 'eip155:42161'\n *\n * @param chainId - Numeric string or hex string chain ID.\n * @returns CAIP-2 formatted chain ID.\n */\nfunction formatChainIdToCaip(chainId: string): string {\n const decimal = chainId.startsWith('0x')\n ? parseInt(chainId, 16)\n : parseInt(chainId, 10);\n if (isNaN(decimal)) {\n throw new Error(`Invalid chain ID: ${chainId}`);\n }\n return `eip155:${decimal}`;\n}\n\n/**\n * Formats an address to CAIP-10 account ID format\n *\n * @param address - The wallet address to format\n * @param chainId - The chain ID (e.g., '1' for mainnet, '42161' for Arbitrum)\n * @param logger - Optional logger for error reporting\n * @returns CAIP-10 formatted account ID or null if formatting fails\n * @example\n * ```typescript\n * const caipId = formatAccountToCaipAccountId('0x123...', '42161');\n * // Returns: 'eip155:42161:0x123...'\n * ```\n */\nexport const formatAccountToCaipAccountId = (\n address: string,\n chainId: string,\n logger?: PerpsLogger,\n): CaipAccountId | null => {\n try {\n const caipChainId = formatChainIdToCaip(chainId) as `${string}:${string}`;\n const { namespace, reference } = parseCaipChainId(caipChainId);\n\n // Normalize EVM addresses to checksummed format for consistent CAIP IDs\n let normalizedAddress = address;\n if (namespace === 'eip155') {\n normalizedAddress = toChecksumHexAddress(address);\n }\n\n return toCaipAccountId(namespace, reference, normalizedAddress);\n } catch (error) {\n logger?.error(\n ensureError(error, 'rewardsUtils.formatAccountToCaipAccountId'),\n {\n context: {\n name: 'rewardsUtils.formatAccountToCaipAccountId',\n data: { address, chainId },\n },\n },\n );\n return null;\n }\n};\n\n/**\n * Type guard to check if a value is a valid CAIP account ID\n *\n * @param value - Value to check\n * @returns True if value is a valid CAIP account ID\n */\nexport const isCaipAccountId = (value: unknown): value is CaipAccountId => {\n if (typeof value !== 'string') {\n return false;\n }\n\n // CAIP-10 format: namespace:reference:account_address\n const parts = value.split(':');\n return parts.length >= 3 && parts[0] === 'eip155';\n};\n\n/**\n * Helper to handle rewards-related errors consistently\n *\n * @param error - The error that occurred\n * @param logger - Optional logger for error reporting\n * @param context - Optional context information\n * @returns A user-friendly error message\n */\nexport const handleRewardsError = (\n error: unknown,\n logger?: PerpsLogger,\n context?: Record<string, unknown>,\n): string => {\n logger?.error(ensureError(error, 'rewardsUtils.handleRewardsError'), {\n context: {\n name: 'rewardsUtils.handleRewardsError',\n data: { additionalContext: context },\n },\n });\n\n return 'Rewards operation failed';\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rewardsUtils.d.cts","sourceRoot":"","sources":["../../src/utils/rewardsUtils.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,aAAa,EAEd,wBAAwB;AAEzB,OAAO,KAAK,EAAE,WAAW,EAAE,2BAA0B;AAoBrD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,YAC9B,MAAM,WACN,MAAM,WACN,WAAW,KACnB,aAAa,GAAG,IAwBlB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UAAW,OAAO,6CAQ7C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,UACtB,OAAO,WACL,WAAW,YACV,OAAO,MAAM,EAAE,OAAO,CAAC,KAChC,MASF,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { CaipAccountId } from "@metamask/utils";
|
|
2
|
-
import type { PerpsLogger } from "../types/index.mjs";
|
|
3
|
-
/**
|
|
4
|
-
* Formats an address to CAIP-10 account ID format
|
|
5
|
-
*
|
|
6
|
-
* @param address - The wallet address to format
|
|
7
|
-
* @param chainId - The chain ID (e.g., '1' for mainnet, '42161' for Arbitrum)
|
|
8
|
-
* @param logger - Optional logger for error reporting
|
|
9
|
-
* @returns CAIP-10 formatted account ID or null if formatting fails
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* const caipId = formatAccountToCaipAccountId('0x123...', '42161');
|
|
13
|
-
* // Returns: 'eip155:42161:0x123...'
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export declare const formatAccountToCaipAccountId: (address: string, chainId: string, logger?: PerpsLogger) => CaipAccountId | null;
|
|
17
|
-
/**
|
|
18
|
-
* Type guard to check if a value is a valid CAIP account ID
|
|
19
|
-
*
|
|
20
|
-
* @param value - Value to check
|
|
21
|
-
* @returns True if value is a valid CAIP account ID
|
|
22
|
-
*/
|
|
23
|
-
export declare const isCaipAccountId: (value: unknown) => value is `${string}:${string}:${string}`;
|
|
24
|
-
/**
|
|
25
|
-
* Helper to handle rewards-related errors consistently
|
|
26
|
-
*
|
|
27
|
-
* @param error - The error that occurred
|
|
28
|
-
* @param logger - Optional logger for error reporting
|
|
29
|
-
* @param context - Optional context information
|
|
30
|
-
* @returns A user-friendly error message
|
|
31
|
-
*/
|
|
32
|
-
export declare const handleRewardsError: (error: unknown, logger?: PerpsLogger, context?: Record<string, unknown>) => string;
|
|
33
|
-
//# sourceMappingURL=rewardsUtils.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rewardsUtils.d.mts","sourceRoot":"","sources":["../../src/utils/rewardsUtils.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,aAAa,EAEd,wBAAwB;AAEzB,OAAO,KAAK,EAAE,WAAW,EAAE,2BAA0B;AAoBrD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,YAC9B,MAAM,WACN,MAAM,WACN,WAAW,KACnB,aAAa,GAAG,IAwBlB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UAAW,OAAO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AED,OAAO,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;IAClE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,EAAE,KAAK,CACX,WAAW,CAAC,KAAK,EAAE,2CAA2C,CAAC,EAC/D;YACE,OAAO,EAAE;gBACP,IAAI,EAAE,2CAA2C;gBACjD,IAAI,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;aAC3B;SACF,CACF,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAc,EAA0B,EAAE;IACxE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,sDAAsD;IACtD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,OAAO,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;AACpD,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,KAAc,EACd,MAAoB,EACpB,OAAiC,EACzB,EAAE;IACV,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,iCAAiC,CAAC,EAAE;QACnE,OAAO,EAAE;YACP,IAAI,EAAE,iCAAiC;YACvC,IAAI,EAAE,EAAE,iBAAiB,EAAE,OAAO,EAAE;SACrC;KACF,CAAC,CAAC;IAEH,OAAO,0BAA0B,CAAC;AACpC,CAAC,CAAC","sourcesContent":["/**\n * Shared rewards utilities for Perps components\n * Handles CAIP account formatting and rewards integration\n *\n * Portable: no mobile-specific imports.\n * Logger is injected as optional parameter for platform-agnostic error reporting.\n */\nimport { toChecksumHexAddress } from '@metamask/controller-utils';\nimport {\n toCaipAccountId,\n CaipAccountId,\n parseCaipChainId,\n} from '@metamask/utils';\n\nimport type { PerpsLogger } from '../types/index.js';\nimport { ensureError } from './errorUtils.js';\n\n/**\n * Converts a numeric or hex chain ID to a CAIP-2 chain ID string.\n * e.g. '0x1' → 'eip155:1', '42161' → 'eip155:42161'\n *\n * @param chainId - Numeric string or hex string chain ID.\n * @returns CAIP-2 formatted chain ID.\n */\nfunction formatChainIdToCaip(chainId: string): string {\n const decimal = chainId.startsWith('0x')\n ? parseInt(chainId, 16)\n : parseInt(chainId, 10);\n if (isNaN(decimal)) {\n throw new Error(`Invalid chain ID: ${chainId}`);\n }\n return `eip155:${decimal}`;\n}\n\n/**\n * Formats an address to CAIP-10 account ID format\n *\n * @param address - The wallet address to format\n * @param chainId - The chain ID (e.g., '1' for mainnet, '42161' for Arbitrum)\n * @param logger - Optional logger for error reporting\n * @returns CAIP-10 formatted account ID or null if formatting fails\n * @example\n * ```typescript\n * const caipId = formatAccountToCaipAccountId('0x123...', '42161');\n * // Returns: 'eip155:42161:0x123...'\n * ```\n */\nexport const formatAccountToCaipAccountId = (\n address: string,\n chainId: string,\n logger?: PerpsLogger,\n): CaipAccountId | null => {\n try {\n const caipChainId = formatChainIdToCaip(chainId) as `${string}:${string}`;\n const { namespace, reference } = parseCaipChainId(caipChainId);\n\n // Normalize EVM addresses to checksummed format for consistent CAIP IDs\n let normalizedAddress = address;\n if (namespace === 'eip155') {\n normalizedAddress = toChecksumHexAddress(address);\n }\n\n return toCaipAccountId(namespace, reference, normalizedAddress);\n } catch (error) {\n logger?.error(\n ensureError(error, 'rewardsUtils.formatAccountToCaipAccountId'),\n {\n context: {\n name: 'rewardsUtils.formatAccountToCaipAccountId',\n data: { address, chainId },\n },\n },\n );\n return null;\n }\n};\n\n/**\n * Type guard to check if a value is a valid CAIP account ID\n *\n * @param value - Value to check\n * @returns True if value is a valid CAIP account ID\n */\nexport const isCaipAccountId = (value: unknown): value is CaipAccountId => {\n if (typeof value !== 'string') {\n return false;\n }\n\n // CAIP-10 format: namespace:reference:account_address\n const parts = value.split(':');\n return parts.length >= 3 && parts[0] === 'eip155';\n};\n\n/**\n * Helper to handle rewards-related errors consistently\n *\n * @param error - The error that occurred\n * @param logger - Optional logger for error reporting\n * @param context - Optional context information\n * @returns A user-friendly error message\n */\nexport const handleRewardsError = (\n error: unknown,\n logger?: PerpsLogger,\n context?: Record<string, unknown>,\n): string => {\n logger?.error(ensureError(error, 'rewardsUtils.handleRewardsError'), {\n context: {\n name: 'rewardsUtils.handleRewardsError',\n data: { additionalContext: context },\n },\n });\n\n return 'Rewards operation failed';\n};\n"]}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.roundToSignificantFigures = exports.hasExceededSignificantFigures = exports.countSignificantFigures = void 0;
|
|
4
|
-
const perpsConfig_js_1 = require("../constants/perpsConfig.cjs");
|
|
5
|
-
/**
|
|
6
|
-
* Count significant figures in a price string.
|
|
7
|
-
* Pure math function extracted from formatUtils for portability.
|
|
8
|
-
*
|
|
9
|
-
* @param priceString - The price string to count significant figures for.
|
|
10
|
-
* @returns The number of significant figures in the price string.
|
|
11
|
-
*/
|
|
12
|
-
const countSignificantFigures = (priceString) => {
|
|
13
|
-
if (!priceString) {
|
|
14
|
-
return 0;
|
|
15
|
-
}
|
|
16
|
-
const cleaned = priceString.replace(/[$,]/gu, '').trim();
|
|
17
|
-
const number = parseFloat(cleaned);
|
|
18
|
-
if (isNaN(number) || number === 0) {
|
|
19
|
-
return 0;
|
|
20
|
-
}
|
|
21
|
-
const normalized = number.toString();
|
|
22
|
-
const [integerPart, decimalPart = ''] = normalized.split('.');
|
|
23
|
-
const trimmedInteger = integerPart.replace(/^-?0*/u, '') || '';
|
|
24
|
-
const effectiveIntegerLength = decimalPart
|
|
25
|
-
? trimmedInteger.length
|
|
26
|
-
: trimmedInteger.replace(/0+$/u, '').length ||
|
|
27
|
-
(trimmedInteger.length > 0 ? 1 : 0);
|
|
28
|
-
return effectiveIntegerLength + decimalPart.length;
|
|
29
|
-
};
|
|
30
|
-
exports.countSignificantFigures = countSignificantFigures;
|
|
31
|
-
/**
|
|
32
|
-
* Check if a price string exceeds the maximum significant figures.
|
|
33
|
-
*
|
|
34
|
-
* @param priceString - The price string to check.
|
|
35
|
-
* @param maxSigFigs - The maximum allowed significant figures.
|
|
36
|
-
* @returns True if the price string exceeds the maximum significant figures.
|
|
37
|
-
*/
|
|
38
|
-
const hasExceededSignificantFigures = (priceString, maxSigFigs = perpsConfig_js_1.DECIMAL_PRECISION_CONFIG.MaxSignificantFigures) => {
|
|
39
|
-
if (!priceString || priceString.trim() === '') {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
const cleaned = priceString.replace(/[$,]/gu, '').trim();
|
|
43
|
-
const number = parseFloat(cleaned);
|
|
44
|
-
if (isNaN(number)) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
const normalized = number.toString();
|
|
48
|
-
if (!normalized.includes('.')) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
return (0, exports.countSignificantFigures)(priceString) > maxSigFigs;
|
|
52
|
-
};
|
|
53
|
-
exports.hasExceededSignificantFigures = hasExceededSignificantFigures;
|
|
54
|
-
/**
|
|
55
|
-
* Round a price string to the maximum significant figures.
|
|
56
|
-
*
|
|
57
|
-
* @param priceString - The price string to round.
|
|
58
|
-
* @param maxSigFigs - The maximum allowed significant figures.
|
|
59
|
-
* @returns The price string rounded to the specified significant figures.
|
|
60
|
-
*/
|
|
61
|
-
const roundToSignificantFigures = (priceString, maxSigFigs = perpsConfig_js_1.DECIMAL_PRECISION_CONFIG.MaxSignificantFigures) => {
|
|
62
|
-
if (!priceString || priceString.trim() === '') {
|
|
63
|
-
return priceString;
|
|
64
|
-
}
|
|
65
|
-
const cleaned = priceString.replace(/[$,]/gu, '').trim();
|
|
66
|
-
const number = Number.parseFloat(cleaned);
|
|
67
|
-
if (Number.isNaN(number) || number === 0) {
|
|
68
|
-
return priceString;
|
|
69
|
-
}
|
|
70
|
-
const normalized = number.toString();
|
|
71
|
-
const [integerPart, decimalPart = ''] = normalized.split('.');
|
|
72
|
-
const trimmedInteger = integerPart.replace(/^-?0*/u, '') || '';
|
|
73
|
-
const integerSigFigs = trimmedInteger.length;
|
|
74
|
-
if (!decimalPart) {
|
|
75
|
-
return normalized;
|
|
76
|
-
}
|
|
77
|
-
const allowedDecimalDigits = maxSigFigs - integerSigFigs;
|
|
78
|
-
if (allowedDecimalDigits <= 0) {
|
|
79
|
-
return Math.round(number).toString();
|
|
80
|
-
}
|
|
81
|
-
if (decimalPart.length <= allowedDecimalDigits) {
|
|
82
|
-
return normalized;
|
|
83
|
-
}
|
|
84
|
-
const rounded = number.toFixed(allowedDecimalDigits);
|
|
85
|
-
return Number.parseFloat(rounded).toString();
|
|
86
|
-
};
|
|
87
|
-
exports.roundToSignificantFigures = roundToSignificantFigures;
|
|
88
|
-
//# sourceMappingURL=significantFigures.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"significantFigures.cjs","sourceRoot":"","sources":["../../src/utils/significantFigures.ts"],"names":[],"mappings":";;;AAAA,iEAAuE;AAEvE;;;;;;GAMG;AACI,MAAM,uBAAuB,GAAG,CAAC,WAAmB,EAAU,EAAE;IACrE,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACzD,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACnC,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IACrC,MAAM,CAAC,WAAW,EAAE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O,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC/C,CAAC,CAAC;AApCW,QAAA,yBAAyB,6BAoCpC","sourcesContent":["import { DECIMAL_PRECISION_CONFIG } from '../constants/perpsConfig.js';\n\n/**\n * Count significant figures in a price string.\n * Pure math function extracted from formatUtils for portability.\n *\n * @param priceString - The price string to count significant figures for.\n * @returns The number of significant figures in the price string.\n */\nexport const countSignificantFigures = (priceString: string): number => {\n if (!priceString) {\n return 0;\n }\n\n const cleaned = priceString.replace(/[$,]/gu, '').trim();\n const number = parseFloat(cleaned);\n if (isNaN(number) || number === 0) {\n return 0;\n }\n\n const normalized = number.toString();\n const [integerPart, decimalPart = ''] = normalized.split('.');\n const trimmedInteger = integerPart.replace(/^-?0*/u, '') || '';\n\n const effectiveIntegerLength = decimalPart\n ? trimmedInteger.length\n : trimmedInteger.replace(/0+$/u, '').length ||\n (trimmedInteger.length > 0 ? 1 : 0);\n\n return effectiveIntegerLength + decimalPart.length;\n};\n\n/**\n * Check if a price string exceeds the maximum significant figures.\n *\n * @param priceString - The price string to check.\n * @param maxSigFigs - The maximum allowed significant figures.\n * @returns True if the price string exceeds the maximum significant figures.\n */\nexport const hasExceededSignificantFigures = (\n priceString: string,\n maxSigFigs: number = DECIMAL_PRECISION_CONFIG.MaxSignificantFigures,\n): boolean => {\n if (!priceString || priceString.trim() === '') {\n return false;\n }\n\n const cleaned = priceString.replace(/[$,]/gu, '').trim();\n const number = parseFloat(cleaned);\n if (isNaN(number)) {\n return false;\n }\n\n const normalized = number.toString();\n if (!normalized.includes('.')) {\n return false;\n }\n\n return countSignificantFigures(priceString) > maxSigFigs;\n};\n\n/**\n * Round a price string to the maximum significant figures.\n *\n * @param priceString - The price string to round.\n * @param maxSigFigs - The maximum allowed significant figures.\n * @returns The price string rounded to the specified significant figures.\n */\nexport const roundToSignificantFigures = (\n priceString: string,\n maxSigFigs: number = DECIMAL_PRECISION_CONFIG.MaxSignificantFigures,\n): string => {\n if (!priceString || priceString.trim() === '') {\n return priceString;\n }\n\n const cleaned = priceString.replace(/[$,]/gu, '').trim();\n const number = Number.parseFloat(cleaned);\n if (Number.isNaN(number) || number === 0) {\n return priceString;\n }\n\n const normalized = number.toString();\n const [integerPart, decimalPart = ''] = normalized.split('.');\n\n const trimmedInteger = integerPart.replace(/^-?0*/u, '') || '';\n const integerSigFigs = trimmedInteger.length;\n\n if (!decimalPart) {\n return normalized;\n }\n\n const allowedDecimalDigits = maxSigFigs - integerSigFigs;\n\n if (allowedDecimalDigits <= 0) {\n return Math.round(number).toString();\n }\n\n if (decimalPart.length <= allowedDecimalDigits) {\n return normalized;\n }\n\n const rounded = number.toFixed(allowedDecimalDigits);\n return Number.parseFloat(rounded).toString();\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"significantFigures.d.cts","sourceRoot":"","sources":["../../src/utils/significantFigures.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,gBAAiB,MAAM,KAAG,MAqB7D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,gBAC3B,MAAM,eACP,MAAM,KACjB,OAiBF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,gBACvB,MAAM,eACP,MAAM,KACjB,MAiCF,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Count significant figures in a price string.
|
|
3
|
-
* Pure math function extracted from formatUtils for portability.
|
|
4
|
-
*
|
|
5
|
-
* @param priceString - The price string to count significant figures for.
|
|
6
|
-
* @returns The number of significant figures in the price string.
|
|
7
|
-
*/
|
|
8
|
-
export declare const countSignificantFigures: (priceString: string) => number;
|
|
9
|
-
/**
|
|
10
|
-
* Check if a price string exceeds the maximum significant figures.
|
|
11
|
-
*
|
|
12
|
-
* @param priceString - The price string to check.
|
|
13
|
-
* @param maxSigFigs - The maximum allowed significant figures.
|
|
14
|
-
* @returns True if the price string exceeds the maximum significant figures.
|
|
15
|
-
*/
|
|
16
|
-
export declare const hasExceededSignificantFigures: (priceString: string, maxSigFigs?: number) => boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Round a price string to the maximum significant figures.
|
|
19
|
-
*
|
|
20
|
-
* @param priceString - The price string to round.
|
|
21
|
-
* @param maxSigFigs - The maximum allowed significant figures.
|
|
22
|
-
* @returns The price string rounded to the specified significant figures.
|
|
23
|
-
*/
|
|
24
|
-
export declare const roundToSignificantFigures: (priceString: string, maxSigFigs?: number) => string;
|
|
25
|
-
//# sourceMappingURL=significantFigures.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"significantFigures.d.mts","sourceRoot":"","sources":["../../src/utils/significantFigures.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,gBAAiB,MAAM,KAAG,MAqB7D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,gBAC3B,MAAM,eACP,MAAM,KACjB,OAiBF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,gBACvB,MAAM,eACP,MAAM,KACjB,MAiCF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"significantFigures.mjs","sourceRoot":"","sources":["../../src/utils/significantFigures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,qCAAoC;AAEvE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,WAAmB,EAAU,EAAE;IACrE,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACzD,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACnC,IAAI,KAAK,C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B,EAAE,CAAC;QAC/C,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACrD,OAAO,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC/C,CAAC,CAAC","sourcesContent":["import { DECIMAL_PRECISION_CONFIG } from '../constants/perpsConfig.js';\n\n/**\n * Count significant figures in a price string.\n * Pure math function extracted from formatUtils for portability.\n *\n * @param priceString - The price string to count significant figures for.\n * @returns The number of significant figures in the price string.\n */\nexport const countSignificantFigures = (priceString: string): number => {\n if (!priceString) {\n return 0;\n }\n\n const cleaned = priceString.replace(/[$,]/gu, '').trim();\n const number = parseFloat(cleaned);\n if (isNaN(number) || number === 0) {\n return 0;\n }\n\n const normalized = number.toString();\n const [integerPart, decimalPart = ''] = normalized.split('.');\n const trimmedInteger = integerPart.replace(/^-?0*/u, '') || '';\n\n const effectiveIntegerLength = decimalPart\n ? trimmedInteger.length\n : trimmedInteger.replace(/0+$/u, '').length ||\n (trimmedInteger.length > 0 ? 1 : 0);\n\n return effectiveIntegerLength + decimalPart.length;\n};\n\n/**\n * Check if a price string exceeds the maximum significant figures.\n *\n * @param priceString - The price string to check.\n * @param maxSigFigs - The maximum allowed significant figures.\n * @returns True if the price string exceeds the maximum significant figures.\n */\nexport const hasExceededSignificantFigures = (\n priceString: string,\n maxSigFigs: number = DECIMAL_PRECISION_CONFIG.MaxSignificantFigures,\n): boolean => {\n if (!priceString || priceString.trim() === '') {\n return false;\n }\n\n const cleaned = priceString.replace(/[$,]/gu, '').trim();\n const number = parseFloat(cleaned);\n if (isNaN(number)) {\n return false;\n }\n\n const normalized = number.toString();\n if (!normalized.includes('.')) {\n return false;\n }\n\n return countSignificantFigures(priceString) > maxSigFigs;\n};\n\n/**\n * Round a price string to the maximum significant figures.\n *\n * @param priceString - The price string to round.\n * @param maxSigFigs - The maximum allowed significant figures.\n * @returns The price string rounded to the specified significant figures.\n */\nexport const roundToSignificantFigures = (\n priceString: string,\n maxSigFigs: number = DECIMAL_PRECISION_CONFIG.MaxSignificantFigures,\n): string => {\n if (!priceString || priceString.trim() === '') {\n return priceString;\n }\n\n const cleaned = priceString.replace(/[$,]/gu, '').trim();\n const number = Number.parseFloat(cleaned);\n if (Number.isNaN(number) || number === 0) {\n return priceString;\n }\n\n const normalized = number.toString();\n const [integerPart, decimalPart = ''] = normalized.split('.');\n\n const trimmedInteger = integerPart.replace(/^-?0*/u, '') || '';\n const integerSigFigs = trimmedInteger.length;\n\n if (!decimalPart) {\n return normalized;\n }\n\n const allowedDecimalDigits = maxSigFigs - integerSigFigs;\n\n if (allowedDecimalDigits <= 0) {\n return Math.round(number).toString();\n }\n\n if (decimalPart.length <= allowedDecimalDigits) {\n return normalized;\n }\n\n const rounded = number.toFixed(allowedDecimalDigits);\n return Number.parseFloat(rounded).toString();\n};\n"]}
|