@metamask-previews/perps-controller 25.0.0-preview-4046c2f69 → 26.0.0-preview-203750488
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 +105 -9
- package/dist/PerpsController-method-action-types.d.ts +149 -3
- package/dist/PerpsController-method-action-types.d.ts.map +1 -1
- package/dist/PerpsController-method-action-types.js.map +1 -1
- package/dist/PerpsController.d.ts +125 -3
- package/dist/PerpsController.d.ts.map +1 -1
- package/dist/PerpsController.js +787 -31
- package/dist/PerpsController.js.map +1 -1
- package/dist/constants/eventNames.d.ts +69 -9
- package/dist/constants/eventNames.d.ts.map +1 -1
- package/dist/constants/eventNames.js +82 -11
- package/dist/constants/eventNames.js.map +1 -1
- package/dist/constants/hyperLiquidConfig.d.ts +15 -0
- package/dist/constants/hyperLiquidConfig.d.ts.map +1 -1
- package/dist/constants/hyperLiquidConfig.js +14 -0
- package/dist/constants/hyperLiquidConfig.js.map +1 -1
- package/dist/constants/perpsConfig.d.ts +10 -2
- package/dist/constants/perpsConfig.d.ts.map +1 -1
- package/dist/constants/perpsConfig.js +11 -3
- package/dist/constants/perpsConfig.js.map +1 -1
- package/dist/index.d.ts +10 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/accountReturnOnEquity.d.ts +12 -0
- package/dist/internal/accountReturnOnEquity.d.ts.map +1 -0
- package/dist/internal/accountReturnOnEquity.js +18 -0
- package/dist/internal/accountReturnOnEquity.js.map +1 -0
- package/dist/internal/hyperLiquidHip3Rebalance.d.ts +14 -0
- package/dist/internal/hyperLiquidHip3Rebalance.d.ts.map +1 -0
- package/dist/internal/hyperLiquidHip3Rebalance.js +18 -0
- package/dist/internal/hyperLiquidHip3Rebalance.js.map +1 -0
- package/dist/internal/marketNumericValues.d.ts +10 -0
- package/dist/internal/marketNumericValues.d.ts.map +1 -0
- package/dist/internal/marketNumericValues.js +9 -0
- package/dist/internal/marketNumericValues.js.map +1 -0
- package/dist/internal/perpsDisplaySymbol.d.ts +12 -0
- package/dist/internal/perpsDisplaySymbol.d.ts.map +1 -0
- package/dist/internal/perpsDisplaySymbol.js +21 -0
- package/dist/internal/perpsDisplaySymbol.js.map +1 -0
- package/dist/perpsErrorCodes.d.ts +1 -0
- package/dist/perpsErrorCodes.d.ts.map +1 -1
- package/dist/perpsErrorCodes.js +1 -0
- package/dist/perpsErrorCodes.js.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.d.ts +47 -1
- package/dist/providers/AggregatedPerpsProvider.d.ts.map +1 -1
- package/dist/providers/AggregatedPerpsProvider.js +140 -0
- package/dist/providers/AggregatedPerpsProvider.js.map +1 -1
- package/dist/providers/HyperLiquidProvider.d.ts +72 -4
- package/dist/providers/HyperLiquidProvider.d.ts.map +1 -1
- package/dist/providers/HyperLiquidProvider.js +751 -159
- package/dist/providers/HyperLiquidProvider.js.map +1 -1
- package/dist/providers/LighterProvider.d.ts +2 -1
- package/dist/providers/LighterProvider.d.ts.map +1 -1
- package/dist/providers/LighterProvider.js +11 -6
- package/dist/providers/LighterProvider.js.map +1 -1
- package/dist/selectors.d.ts +15 -5
- package/dist/selectors.d.ts.map +1 -1
- package/dist/selectors.js +23 -5
- package/dist/selectors.js.map +1 -1
- package/dist/services/AggregatedOrderBookConnection.d.ts.map +1 -1
- package/dist/services/AggregatedOrderBookConnection.js +8 -10
- package/dist/services/AggregatedOrderBookConnection.js.map +1 -1
- package/dist/services/HyperLiquidClientService.d.ts +8 -0
- package/dist/services/HyperLiquidClientService.d.ts.map +1 -1
- package/dist/services/HyperLiquidClientService.js +65 -0
- package/dist/services/HyperLiquidClientService.js.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.d.ts +30 -1
- package/dist/services/HyperLiquidSubscriptionService.d.ts.map +1 -1
- package/dist/services/HyperLiquidSubscriptionService.js +117 -30
- package/dist/services/HyperLiquidSubscriptionService.js.map +1 -1
- package/dist/services/MarketDataService.d.ts +20 -3
- package/dist/services/MarketDataService.d.ts.map +1 -1
- package/dist/services/MarketDataService.js +55 -3
- package/dist/services/MarketDataService.js.map +1 -1
- package/dist/services/StreamChannelManager.d.ts +139 -0
- package/dist/services/StreamChannelManager.d.ts.map +1 -0
- package/dist/services/StreamChannelManager.js +475 -0
- package/dist/services/StreamChannelManager.js.map +1 -0
- package/dist/services/TerminalMarketService.d.ts.map +1 -1
- package/dist/services/TerminalMarketService.js +7 -0
- package/dist/services/TerminalMarketService.js.map +1 -1
- package/dist/services/agentSigner.d.ts +8 -0
- package/dist/services/agentSigner.d.ts.map +1 -1
- package/dist/services/agentSigner.js +13 -0
- package/dist/services/agentSigner.js.map +1 -1
- package/dist/types/hyperliquid-types.d.ts +9 -1
- package/dist/types/hyperliquid-types.d.ts.map +1 -1
- package/dist/types/hyperliquid-types.js +10 -0
- package/dist/types/hyperliquid-types.js.map +1 -1
- package/dist/types/index.d.ts +434 -17
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utils/accountAggregation.d.ts +17 -0
- package/dist/utils/accountAggregation.d.ts.map +1 -1
- package/dist/utils/accountAggregation.js +21 -5
- package/dist/utils/accountAggregation.js.map +1 -1
- package/dist/utils/accountUtils.d.ts +31 -10
- package/dist/utils/accountUtils.d.ts.map +1 -1
- package/dist/utils/accountUtils.js +68 -28
- package/dist/utils/accountUtils.js.map +1 -1
- package/dist/utils/closeCalculations.d.ts +17 -4
- package/dist/utils/closeCalculations.d.ts.map +1 -1
- package/dist/utils/closeCalculations.js +23 -7
- package/dist/utils/closeCalculations.js.map +1 -1
- package/dist/utils/hyperLiquidAdapter.d.ts +10 -1
- package/dist/utils/hyperLiquidAdapter.d.ts.map +1 -1
- package/dist/utils/hyperLiquidAdapter.js +17 -1
- package/dist/utils/hyperLiquidAdapter.js.map +1 -1
- package/dist/utils/hyperLiquidPositionPreview.d.ts +133 -9
- package/dist/utils/hyperLiquidPositionPreview.d.ts.map +1 -1
- package/dist/utils/hyperLiquidPositionPreview.js +264 -29
- package/dist/utils/hyperLiquidPositionPreview.js.map +1 -1
- package/dist/utils/index.d.ts +4 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/lighterAdapter.d.ts.map +1 -1
- package/dist/utils/lighterAdapter.js +46 -9
- package/dist/utils/lighterAdapter.js.map +1 -1
- package/dist/utils/marketDataTransform.d.ts.map +1 -1
- package/dist/utils/marketDataTransform.js +13 -8
- package/dist/utils/marketDataTransform.js.map +1 -1
- package/dist/utils/marketUtils.d.ts +1 -2
- package/dist/utils/marketUtils.d.ts.map +1 -1
- package/dist/utils/marketUtils.js +7 -17
- package/dist/utils/marketUtils.js.map +1 -1
- package/dist/utils/orderBookGrouping.d.ts +35 -5
- package/dist/utils/orderBookGrouping.d.ts.map +1 -1
- package/dist/utils/orderBookGrouping.js +62 -6
- package/dist/utils/orderBookGrouping.js.map +1 -1
- package/dist/utils/perpsClientCopy.d.ts.map +1 -1
- package/dist/utils/perpsClientCopy.js +4 -0
- package/dist/utils/perpsClientCopy.js.map +1 -1
- package/dist/utils/perpsDiskPersistence.d.ts.map +1 -1
- package/dist/utils/perpsDiskPersistence.js +10 -0
- package/dist/utils/perpsDiskPersistence.js.map +1 -1
- package/dist/utils/perpsFormatters.d.ts +31 -0
- package/dist/utils/perpsFormatters.d.ts.map +1 -1
- package/dist/utils/perpsFormatters.js +26 -0
- package/dist/utils/perpsFormatters.js.map +1 -1
- package/dist/utils/priceDeviation.d.ts +9 -6
- package/dist/utils/priceDeviation.d.ts.map +1 -1
- package/dist/utils/priceDeviation.js +17 -26
- package/dist/utils/priceDeviation.js.map +1 -1
- package/dist/utils/sortMarkets.d.ts +13 -5
- package/dist/utils/sortMarkets.d.ts.map +1 -1
- package/dist/utils/sortMarkets.js +60 -38
- package/dist/utils/sortMarkets.js.map +1 -1
- package/docs/architecture.md +54 -24
- package/docs/client-contract.md +52 -27
- package/docs/contracts/events.md +38 -32
- package/docs/contracts/feature-flags.md +4 -4
- package/docs/formatting.md +2 -0
- package/docs/venues/lighter/capabilities.md +18 -15
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perpsClientCopy.js","sourceRoot":"","sources":["../../src/utils/perpsClientCopy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAiB5E;;;;;GAKG;AACH,SAAS,aAAa,CACpB,OAAgB;IAEhB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3C,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAEzB,aAAa,CAAC;IAChB,CAAC,iBAAiB,CAAC,sBAAsB,CAAC,EAAE;QAC1C,GAAG,EAAE,mCAAmC;QACxC,cAAc,EAAE,kDAAkD;KACnE;IACD,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,EAAE;QACzC,GAAG,EAAE,mCAAmC;QACxC,cAAc,EACZ,gEAAgE;KACnE;IACD,CAAC,iBAAiB,CAAC,sBAAsB,CAAC,EAAE;QAC1C,GAAG,EAAE,mCAAmC;QACxC,cAAc,EAAE,uCAAuC;KACxD;IACD,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,EAAE;QACtC,GAAG,EAAE,mCAAmC;QACxC,cAAc,EAAE,uCAAuC;KACxD;IACD,CAAC,iBAAiB,CAAC,uBAAuB,CAAC,EAAE;QAC3C,GAAG,EAAE,oCAAoC;QACzC,cAAc,EAAE,iDAAiD;KAClE;IACD,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,EAAE;QAC5C,GAAG,EAAE,mCAAmC;QACxC,cAAc,EACZ,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{ PerpsErrorCode } from '../perpsErrorCodes.js';\nimport type { OrderType } from '../types/perps-types.js';\n\n/**\n * Translation key and English text for one piece of client copy. Clients\n * translate `key` and fall back to the default when they have no\n * translation. `{{name}}` placeholders are filled by the client.\n */\nexport type PerpsErrorCopy = Readonly<{ key: string; defaultMessage: string }>;\n\n/** Translation key and English label of an order type. */\nexport type PerpsOrderTypeLabel = Readonly<{\n key: string;\n defaultLabel: string;\n}>;\n\n/**\n * Freeze a client copy map and its string-valued entries.\n *\n * @param copyMap - The copy or label entries.\n * @returns The immutable copy map.\n */\nfunction freezeCopyMap<CopyMap extends Record<string, object>>(\n copyMap: CopyMap,\n): Readonly<CopyMap> {\n for (const entry of Object.values(copyMap)) {\n Object.freeze(entry);\n }\n return Object.freeze(copyMap);\n}\n\n/**\n * Copy for every `PERPS_ERROR_CODES` value. Keys follow the Mobile locale\n * files. `IOC_CANCEL` expects `{{maxSlippage}}`; without a known tolerance,\n * clients show `perps.errors.iocCancelUnknownTolerance` instead.\n */\nexport const PERPS_ERROR_COPY: Readonly<\n Record<PerpsErrorCode, PerpsErrorCopy>\n> = freezeCopyMap({\n [PERPS_ERROR_CODES.CLIENT_NOT_INITIALIZED]: {\n key: 'perps.errors.clientNotInitialized',\n defaultMessage: 'HyperLiquid SDK clients not properly initialized',\n },\n [PERPS_ERROR_CODES.CLIENT_REINITIALIZING]: {\n key: 'perps.errors.clientReinitializing',\n defaultMessage:\n 'Service is reinitializing. Please wait a moment and try again.',\n },\n [PERPS_ERROR_CODES.PROVIDER_NOT_AVAILABLE]: {\n key: 'perps.errors.providerNotAvailable',\n defaultMessage: 'Provider {{providerId}} not available',\n },\n [PERPS_ERROR_CODES.PROVIDER_NOT_FOUND]: {\n key: 'perps.errors.providerNotAvailable',\n defaultMessage: 'Provider {{providerId}} not available',\n },\n [PERPS_ERROR_CODES.PROVIDER_ROUTE_REQUIRED]: {\n key: 'perps.errors.providerRouteRequired',\n defaultMessage: 'Choose a provider for this order and try again.',\n },\n [PERPS_ERROR_CODES.PROVIDER_LIFECYCLE_STALE]: {\n key: 'perps.errors.clientReinitializing',\n defaultMessage:\n 'Service is reinitializing. Please wait a moment and try again.',\n },\n [PERPS_ERROR_CODES.TOKEN_NOT_SUPPORTED]: {\n key: 'perps.errors.tokenNotSupported',\n defaultMessage: 'Token {{token}} not supported for deposits',\n },\n [PERPS_ERROR_CODES.BRIDGE_CONTRACT_NOT_FOUND]: {\n key: 'perps.errors.bridgeContractNotFound',\n defaultMessage: 'Unable to get HyperLiquid bridge contract address',\n },\n [PERPS_ERROR_CODES.WITHDRAW_FAILED]: {\n key: 'perps.errors.withdrawFailed',\n defaultMessage: 'Failed to withdraw',\n },\n [PERPS_ERROR_CODES.POSITIONS_FAILED]: {\n key: 'perps.errors.positionsFailed',\n defaultMessage: 'Failed to get positions',\n },\n [PERPS_ERROR_CODES.ACCOUNT_STATE_FAILED]: {\n key: 'perps.errors.accountStateFailed',\n defaultMessage: 'Failed to get account state',\n },\n [PERPS_ERROR_CODES.MARKETS_FAILED]: {\n key: 'perps.errors.marketsFailed',\n defaultMessage: 'Failed to get markets',\n },\n [PERPS_ERROR_CODES.UNKNOWN_ERROR]: {\n key: 'perps.errors.unknownError',\n defaultMessage: 'Unknown error occurred',\n },\n [PERPS_ERROR_CODES.ORDER_LEVERAGE_REDUCTION_FAILED]: {\n key: 'perps.errors.orderLeverageReductionFailed',\n defaultMessage: 'You cannot reduce your leverage',\n },\n [PERPS_ERROR_CODES.IOC_CANCEL]: {\n key: 'perps.errors.iocCancel',\n defaultMessage:\n \"Your order couldn't fill within your {{maxSlippage}}% slippage tolerance. Try a limit order or adjust your slippage.\",\n },\n [PERPS_ERROR_CODES.CONNECTION_TIMEOUT]: {\n key: 'perps.errors.connectionTimeout',\n defaultMessage:\n 'Connection timed out. Please check your network and try again.',\n },\n [PERPS_ERROR_CODES.WITHDRAW_ASSET_ID_REQUIRED]: {\n key: 'perps.errors.withdrawValidation.assetIdRequired',\n defaultMessage: 'assetId is required for withdrawals',\n },\n [PERPS_ERROR_CODES.WITHDRAW_AMOUNT_REQUIRED]: {\n key: 'perps.errors.withdrawValidation.amountRequired',\n defaultMessage: 'amount is required for withdrawals',\n },\n [PERPS_ERROR_CODES.WITHDRAW_AMOUNT_POSITIVE]: {\n key: 'perps.errors.withdrawValidation.amountPositive',\n defaultMessage: 'Amount must be a positive number',\n },\n [PERPS_ERROR_CODES.WITHDRAW_INVALID_DESTINATION]: {\n key: 'perps.errors.withdrawValidation.invalidDestination',\n defaultMessage: 'Invalid destination address format: {{address}}',\n },\n [PERPS_ERROR_CODES.WITHDRAW_ASSET_NOT_SUPPORTED]: {\n key: 'perps.errors.withdrawValidation.assetNotSupported',\n defaultMessage:\n 'Asset {{assetId}} is not supported for withdrawals. Supported assets: {{supportedAssets}}',\n },\n [PERPS_ERROR_CODES.WITHDRAW_INSUFFICIENT_BALANCE]: {\n key: 'perps.errors.withdrawValidation.insufficientBalance',\n defaultMessage:\n 'Insufficient balance. Available: {{available}}, Requested: {{requested}}',\n },\n [PERPS_ERROR_CODES.DEPOSIT_ASSET_ID_REQUIRED]: {\n key: 'perps.errors.depositValidation.assetIdRequired',\n defaultMessage: 'AssetId is required for deposit validation',\n },\n [PERPS_ERROR_CODES.DEPOSIT_AMOUNT_REQUIRED]: {\n key: 'perps.errors.depositValidation.amountRequired',\n defaultMessage: 'Amount is required and must be greater than 0',\n },\n [PERPS_ERROR_CODES.DEPOSIT_AMOUNT_POSITIVE]: {\n key: 'perps.errors.depositValidation.amountPositive',\n defaultMessage: 'Amount must be a positive number',\n },\n [PERPS_ERROR_CODES.DEPOSIT_MINIMUM_AMOUNT]: {\n key: 'perps.errors.minimumDeposit',\n defaultMessage: 'Minimum deposit amount is {{amount}} USDC',\n },\n [PERPS_ERROR_CODES.ORDER_COIN_REQUIRED]: {\n key: 'perps.errors.orderValidation.coinRequired',\n defaultMessage: 'Coin is required for orders',\n },\n [PERPS_ERROR_CODES.ORDER_LIMIT_PRICE_REQUIRED]: {\n key: 'perps.errors.orderValidation.limitPriceRequired',\n defaultMessage: 'Price is required for limit orders',\n },\n [PERPS_ERROR_CODES.ORDER_PRICE_POSITIVE]: {\n key: 'perps.errors.orderValidation.pricePositive',\n defaultMessage: 'Price must be a positive number if provided',\n },\n [PERPS_ERROR_CODES.ORDER_UNKNOWN_COIN]: {\n key: 'perps.errors.orderValidation.unknownCoin',\n defaultMessage: 'Unknown coin: {{coin}}',\n },\n [PERPS_ERROR_CODES.ORDER_SIZE_POSITIVE]: {\n key: 'perps.errors.orderValidation.sizePositive',\n defaultMessage: 'Size must be a positive number',\n },\n [PERPS_ERROR_CODES.ORDER_PRICE_REQUIRED]: {\n key: 'perps.order.validation.price_required',\n defaultMessage: 'Price is required',\n },\n [PERPS_ERROR_CODES.ORDER_SIZE_MIN]: {\n key: 'perps.order.validation.minimum_amount',\n // A literal dollar sign before a client-filled placeholder.\n // eslint-disable-next-line no-template-curly-in-string\n defaultMessage: 'Minimum order size is ${{amount}}',\n },\n [PERPS_ERROR_CODES.ORDER_LEVERAGE_INVALID]: {\n key: 'perps.order.validation.invalid_leverage',\n defaultMessage: 'Leverage must be between {{min}}x and {{max}}x',\n },\n [PERPS_ERROR_CODES.ORDER_MARGIN_MODE_INVALID]: {\n key: 'perps.errors.orderValidation.marginModeInvalid',\n defaultMessage: 'Choose a valid margin mode.',\n },\n [PERPS_ERROR_CODES.ORDER_MARGIN_MODE_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.marginModeUnsupported',\n defaultMessage:\n 'The selected margin mode is not available for this market.',\n },\n [PERPS_ERROR_CODES.ORDER_MARGIN_MODE_POSITION_OPEN]: {\n key: 'perps.errors.orderValidation.marginModePositionOpen',\n defaultMessage:\n 'Close the open position on this market before changing margin mode.',\n },\n [PERPS_ERROR_CODES.ORDER_MARGIN_MODE_ORDER_OPEN]: {\n key: 'perps.errors.orderValidation.marginModeOrderOpen',\n defaultMessage:\n 'Cancel the open orders on this market before changing margin mode.',\n },\n [PERPS_ERROR_CODES.ORDER_LEVERAGE_BELOW_POSITION]: {\n key: 'perps.order.validation.leverage_below_position',\n defaultMessage:\n 'Leverage must be at least {{required}}x to match your existing position (current: {{provided}}x)',\n },\n [PERPS_ERROR_CODES.ORDER_MAX_VALUE_EXCEEDED]: {\n key: 'perps.order.validation.max_order_value',\n // A literal dollar sign before a client-filled placeholder.\n // eslint-disable-next-line no-template-curly-in-string\n defaultMessage: 'Order size must be below ${{maxValue}}',\n },\n [PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_REQUIRED]: {\n key: 'perps.errors.orderValidation.triggerPriceRequired',\n defaultMessage:\n 'A trigger price is required for stop and take profit orders',\n },\n [PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_POSITIVE]: {\n key: 'perps.errors.orderValidation.triggerPricePositive',\n defaultMessage: 'Trigger price must be a positive number',\n },\n [PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_NOT_SUPPORTED]: {\n key: 'perps.errors.orderValidation.triggerPriceNotSupported',\n defaultMessage: \"Market and limit orders can't have a trigger price\",\n },\n [PERPS_ERROR_CODES.ORDER_TRIGGER_TPSL_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.triggerTpslUnsupported',\n defaultMessage:\n \"Stop and take profit orders can't carry their own take profit or stop loss\",\n },\n [PERPS_ERROR_CODES.ORDER_TPSL_SIZE_INVALID]: {\n key: 'perps.errors.orderValidation.tpslSizeInvalid',\n defaultMessage:\n 'Take profit and stop loss size must be positive and no larger than the order',\n },\n [PERPS_ERROR_CODES.ORDER_EDIT_TRIGGER_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.editTriggerUnsupported',\n defaultMessage:\n \"Stop and take profit orders can't be edited. Cancel the order and place a new one.\",\n },\n [PERPS_ERROR_CODES.ORDER_TPSL_LINKAGE_CONFLICT]: {\n key: 'perps.errors.orderValidation.tpslLinkageConflict',\n defaultMessage: 'Conflicting take profit and stop loss settings',\n },\n [PERPS_ERROR_CODES.ORDER_TPSL_POSITION_LINKAGE_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.tpslPositionLinkageUnsupported',\n defaultMessage:\n 'Take profit and stop loss can only be attached to a position once the order has filled',\n },\n [PERPS_ERROR_CODES.ORDER_TPSL_LINKAGE_REQUIRED]: {\n key: 'perps.errors.orderValidation.tpslLinkageRequired',\n defaultMessage:\n 'Take profit and stop loss must be attached to the order or to the position',\n },\n [PERPS_ERROR_CODES.ORDER_EDIT_ORDER_UNVERIFIABLE]: {\n key: 'perps.errors.orderValidation.editOrderUnverifiable',\n defaultMessage:\n 'This order can no longer be found. Refresh your orders and try again.',\n },\n [PERPS_ERROR_CODES.ORDER_TIME_IN_FORCE_NOT_SUPPORTED]: {\n key: 'perps.errors.orderValidation.timeInForceNotSupported',\n defaultMessage: 'Time in force can only be set on limit orders',\n },\n [PERPS_ERROR_CODES.ORDER_STRATEGY_PARAMS_NOT_SUPPORTED]: {\n key: 'perps.errors.orderValidation.strategyParamsNotSupported',\n defaultMessage: \"These order settings aren't supported for this order type\",\n },\n [PERPS_ERROR_CODES.ORDER_STRATEGY_FIELD_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.strategyFieldUnsupported',\n defaultMessage:\n \"This field can't be used with a TWAP, scale, or chase order\",\n },\n [PERPS_ERROR_CODES.ORDER_STRATEGY_MARKET_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.strategyMarketUnsupported',\n defaultMessage:\n \"TWAP, scale, and chase orders aren't available on this market\",\n },\n [PERPS_ERROR_CODES.ORDER_STRATEGY_ROUTE_UNAVAILABLE]: {\n key: 'perps.errors.orderValidation.strategyMarketUnsupported',\n defaultMessage:\n \"TWAP, scale, and chase orders aren't available on this market\",\n },\n [PERPS_ERROR_CODES.ORDER_STRATEGY_HANDLE_UNKNOWN]: {\n key: 'perps.errors.orderValidation.strategyHandleUnknown',\n defaultMessage:\n 'This strategy order can no longer be found. Refresh your orders and try again.',\n },\n [PERPS_ERROR_CODES.ORDER_EDIT_STRATEGY_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.strategyEditUnsupported',\n defaultMessage:\n \"TWAP, scale, and chase orders can't be edited. Cancel the order and place a new one.\",\n },\n [PERPS_ERROR_CODES.ORDER_STRATEGY_CANCEL_INCOMPLETE]: {\n key: 'perps.errors.orderValidation.strategyCancelIncomplete',\n defaultMessage:\n \"Some parts of this strategy order couldn't be cancelled. Try again.\",\n },\n [PERPS_ERROR_CODES.ORDER_TWAP_DURATION_REQUIRED]: {\n key: 'perps.errors.orderValidation.twapDurationRequired',\n defaultMessage: 'A duration is required for TWAP orders',\n },\n [PERPS_ERROR_CODES.ORDER_TWAP_DURATION_INVALID]: {\n key: 'perps.errors.orderValidation.twapDurationInvalid',\n defaultMessage: 'TWAP duration must be between 5 and 1440 minutes',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_PREVIEW_STALE]: {\n key: 'perps.errors.orderValidation.scalePreviewStale',\n defaultMessage:\n 'Scale order details changed. Review the updated preview and try again.',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_RANGE_REQUIRED]: {\n key: 'perps.errors.orderValidation.scaleRangeRequired',\n defaultMessage: 'Scale orders need a minimum and maximum price',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_RANGE_INVALID]: {\n key: 'perps.errors.orderValidation.scaleRangeInvalid',\n defaultMessage: 'Scale order maximum price must be above the minimum',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_COUNT_INVALID]: {\n key: 'perps.errors.orderValidation.scaleCountInvalid',\n defaultMessage: 'Scale order count is invalid',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_SIZE_TOO_SMALL]: {\n key: 'perps.errors.orderValidation.scaleSizeTooSmall',\n defaultMessage: 'Each scale order is below the minimum size',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_NOTIONAL_TOO_SMALL]: {\n key: 'perps.errors.orderValidation.scaleNotionalTooSmall',\n defaultMessage: 'Each scale order is below the exchange minimum value',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_SIZE_CONSERVATION_FAILED]: {\n key: 'perps.errors.unknownError',\n defaultMessage: 'Unknown error occurred',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_EXPOSURE_EXCEEDS_INTENT]: {\n key: 'perps.errors.unknownError',\n defaultMessage: 'Unknown error occurred',\n },\n [PERPS_ERROR_CODES.ORDER_TWAP_NOTIONAL_TOO_SMALL]: {\n key: 'perps.errors.orderValidation.twapNotionalTooSmall',\n defaultMessage: 'TWAP order value is below the exchange minimum',\n },\n [PERPS_ERROR_CODES.ORDER_CHASE_INTERVAL_INVALID]: {\n key: 'perps.errors.orderValidation.chaseIntervalInvalid',\n defaultMessage: 'Chase interval is invalid',\n },\n [PERPS_ERROR_CODES.ORDER_CHASE_DURATION_INVALID]: {\n key: 'perps.errors.orderValidation.chaseDurationInvalid',\n defaultMessage: 'Chase duration is invalid',\n },\n [PERPS_ERROR_CODES.ORDER_CHASE_MAX_DISTANCE_INVALID]: {\n key: 'perps.errors.orderValidation.chaseMaxDistanceInvalid',\n defaultMessage: 'Max chase distance is outside the allowed range',\n },\n [PERPS_ERROR_CODES.ORDER_CHASE_ABANDONED]: {\n key: 'perps.errors.orderValidation.chaseStoppedCheckOpenOrders',\n defaultMessage:\n 'The chase stopped. Check open orders for any remaining orders.',\n },\n [PERPS_ERROR_CODES.ORDER_CHASE_LIMIT_REACHED]: {\n key: 'perps.errors.orderValidation.chaseLimitReached',\n defaultMessage: 'Too many chase orders are already running',\n },\n [PERPS_ERROR_CODES.ORDER_CHASE_TOUCH_UNAVAILABLE]: {\n key: 'perps.errors.orderValidation.chaseTouchUnavailable',\n defaultMessage: 'No market price is available to place this chase order',\n },\n [PERPS_ERROR_CODES.EXCHANGE_CLIENT_NOT_AVAILABLE]: {\n key: 'perps.errors.exchangeClientNotAvailable',\n defaultMessage: 'ExchangeClient not available after initialization',\n },\n [PERPS_ERROR_CODES.INFO_CLIENT_NOT_AVAILABLE]: {\n key: 'perps.errors.infoClientNotAvailable',\n defaultMessage: 'InfoClient not available after initialization',\n },\n [PERPS_ERROR_CODES.SUBSCRIPTION_CLIENT_NOT_AVAILABLE]: {\n key: 'perps.errors.subscriptionClientNotAvailable',\n defaultMessage: 'SubscriptionClient not available after initialization',\n },\n [PERPS_ERROR_CODES.NO_ACCOUNT_SELECTED]: {\n key: 'perps.errors.noAccountSelected',\n defaultMessage: 'No account selected',\n },\n [PERPS_ERROR_CODES.KEYRING_LOCKED]: {\n key: 'perps.errors.unknownError',\n defaultMessage: 'Unknown error occurred',\n },\n [PERPS_ERROR_CODES.INVALID_ADDRESS_FORMAT]: {\n key: 'perps.errors.invalidAddressFormat',\n defaultMessage: 'Invalid address format: {{address}}',\n },\n [PERPS_ERROR_CODES.EXCHANGE_ACCOUNT_NOT_FOUND]: {\n key: 'perps.errors.exchangeAccountNotFound',\n defaultMessage: 'Add funds to your account before placing an order',\n },\n [PERPS_ERROR_CODES.EXCHANGE_MULTI_SIG_REQUIRED]: {\n key: 'perps.errors.exchangeMultiSigRequired',\n defaultMessage: 'This account needs its multi-signature signers to trade',\n },\n [PERPS_ERROR_CODES.EXCHANGE_INVALID_NONCE]: {\n key: 'perps.errors.exchangeInvalidNonce',\n defaultMessage: 'Something went wrong. Try again.',\n },\n [PERPS_ERROR_CODES.TRANSFER_FAILED]: {\n key: 'perps.errors.transferFailed',\n defaultMessage: 'Unable to transfer funds. Please try again.',\n },\n [PERPS_ERROR_CODES.SWAP_FAILED]: {\n key: 'perps.errors.swapFailed',\n defaultMessage: 'Unable to swap tokens. Please try again.',\n },\n [PERPS_ERROR_CODES.SPOT_PAIR_NOT_FOUND]: {\n key: 'perps.errors.spotPairNotFound',\n defaultMessage: 'Trading pair is not available at this time.',\n },\n [PERPS_ERROR_CODES.ORDERS_FAILED]: {\n key: 'perps.errors.ordersFailed',\n defaultMessage: 'Unable to load orders. Please refresh and try again.',\n },\n [PERPS_ERROR_CODES.LIQUIDATION_PRICE_UNAVAILABLE]: {\n key: 'perps.errors.liquidationPriceUnavailable',\n defaultMessage:\n 'A liquidation price estimate is unavailable for this order.',\n },\n [PERPS_ERROR_CODES.PRICE_UNAVAILABLE]: {\n key: 'perps.errors.priceUnavailable',\n defaultMessage: 'Price data is unavailable. Please refresh and try again.',\n },\n [PERPS_ERROR_CODES.UNSUPPORTED_COLLATERAL]: {\n key: 'perps.errors.unsupportedCollateral',\n defaultMessage: \"This market's collateral is not supported\",\n },\n [PERPS_ERROR_CODES.BATCH_INCOMPLETE]: {\n key: 'perps.errors.batchIncomplete',\n defaultMessage:\n 'The action did not complete on every venue. Check the result for each venue.',\n },\n [PERPS_ERROR_CODES.ORDER_NO_LONGER_OPEN]: {\n key: 'perps.errors.orderNoLongerOpen',\n defaultMessage: 'This order is no longer open.',\n },\n [PERPS_ERROR_CODES.ORDER_POST_ONLY_WOULD_CROSS]: {\n key: 'perps.errors.postOnlyWouldCross',\n defaultMessage:\n 'This post-only order would execute immediately. Check the order status before trying a different price.',\n },\n [PERPS_ERROR_CODES.ORDER_POST_ONLY_WINDOW]: {\n key: 'perps.errors.postOnlyWindow',\n defaultMessage: 'Only post-only orders are available right now.',\n },\n [PERPS_ERROR_CODES.BATCH_CANCEL_FAILED]: {\n key: 'perps.errors.batchCancelFailed',\n defaultMessage: \"Some orders couldn't be cancelled. Please try again.\",\n },\n [PERPS_ERROR_CODES.BATCH_CLOSE_FAILED]: {\n key: 'perps.errors.batchCloseFailed',\n defaultMessage: \"Some positions couldn't be closed. Please try again.\",\n },\n [PERPS_ERROR_CODES.INSUFFICIENT_MARGIN]: {\n key: 'perps.errors.insufficientMargin',\n defaultMessage:\n 'Insufficient margin to execute this trade. Consider adding more funds or reducing your position size.',\n },\n [PERPS_ERROR_CODES.INSUFFICIENT_BALANCE]: {\n key: 'perps.errors.insufficientBalance',\n defaultMessage:\n 'Insufficient balance to complete this operation. Check your available funds.',\n },\n [PERPS_ERROR_CODES.REDUCE_ONLY_VIOLATION]: {\n key: 'perps.errors.reduceOnlyViolation',\n defaultMessage:\n 'This order would increase your position. Only reduce-only orders are allowed.',\n },\n [PERPS_ERROR_CODES.POSITION_WOULD_FLIP]: {\n key: 'perps.errors.positionWouldFlip',\n defaultMessage:\n 'This order would flip your position direction. Please close your existing position first.',\n },\n [PERPS_ERROR_CODES.POSITION_NOT_FOUND]: {\n key: 'perps.errors.position_not_found',\n defaultMessage: 'Position not found',\n },\n [PERPS_ERROR_CODES.MARGIN_ADJUSTMENT_FAILED]: {\n key: 'perps.errors.marginAdjustmentFailed',\n defaultMessage: 'Unable to adjust margin. Try again.',\n },\n [PERPS_ERROR_CODES.TPSL_UPDATE_FAILED]: {\n key: 'perps.errors.tpslUpdateFailed',\n defaultMessage: 'Unable to update take profit/stop loss. Try again.',\n },\n [PERPS_ERROR_CODES.TPSL_PROTECTION_LOST]: {\n key: 'perps.errors.tpslProtectionLost',\n defaultMessage:\n \"We could not confirm the previous protection was restored. Check the position's take profit and stop loss.\",\n },\n [PERPS_ERROR_CODES.TPSL_LEG_REPLACE_UNSUPPORTED]: {\n key: 'perps.errors.tpslLegReplaceUnsupported',\n defaultMessage:\n 'Updating only take profit or only stop loss isn’t available for this provider. Update take profit and stop loss together instead.',\n },\n [PERPS_ERROR_CODES.ORDER_REJECTED]: {\n key: 'perps.errors.orderRejected',\n defaultMessage: 'Order was rejected. Check your parameters and try again.',\n },\n [PERPS_ERROR_CODES.SLIPPAGE_EXCEEDED]: {\n key: 'perps.errors.slippageExceeded',\n defaultMessage:\n 'Price moved too much. Try using a limit order or increase slippage tolerance.',\n },\n [PERPS_ERROR_CODES.PRICE_MOVED]: {\n key: 'perps.errors.priceMoved',\n defaultMessage:\n 'The price moved {{priceDelta}}%, exceeding your {{maxSlippage}}% slippage tolerance. Review the updated price and try again.',\n },\n [PERPS_ERROR_CODES.RATE_LIMIT_EXCEEDED]: {\n key: 'perps.errors.rateLimitExceeded',\n defaultMessage: 'Too many requests. Wait a moment and try again.',\n },\n [PERPS_ERROR_CODES.SERVICE_UNAVAILABLE]: {\n key: 'perps.errors.serviceUnavailable',\n defaultMessage: 'Service is temporarily unavailable. Try again later.',\n },\n [PERPS_ERROR_CODES.NETWORK_ERROR]: {\n key: 'perps.errors.networkErrorSimple',\n defaultMessage:\n 'Network error occurred. Check your connection and try again.',\n },\n});\n\n/**\n * Copy for an error code, or the `UNKNOWN_ERROR` copy for anything that is not\n * a Perps error code (a code from a newer controller, or a raw message).\n *\n * @param code - Error code from a controller result or error.\n * @returns The code's copy.\n */\nexport function getPerpsErrorCopy(code: unknown): PerpsErrorCopy {\n return isPerpsErrorCode(code)\n ? PERPS_ERROR_COPY[code]\n : PERPS_ERROR_COPY[PERPS_ERROR_CODES.UNKNOWN_ERROR];\n}\n\n/** Label for every normalised order type, keyed by `OrderType`. */\nexport const PERPS_ORDER_TYPE_LABELS: Readonly<\n Record<OrderType, PerpsOrderTypeLabel>\n> = freezeCopyMap({\n market: { key: 'perps.order.type.market.title', defaultLabel: 'Market' },\n limit: { key: 'perps.order.type.limit.title', defaultLabel: 'Limit' },\n stop_market: {\n key: 'perps.order.type.stop_market.title',\n defaultLabel: 'Stop market',\n },\n stop_limit: {\n key: 'perps.order.type.stop_limit.title',\n defaultLabel: 'Stop limit',\n },\n take_profit_market: {\n key: 'perps.order.type.take_profit_market.title',\n defaultLabel: 'Take market',\n },\n take_profit_limit: {\n key: 'perps.order.type.take_profit_limit.title',\n defaultLabel: 'Take limit',\n },\n twap: { key: 'perps.order.type.twap.title', defaultLabel: 'TWAP' },\n scale: { key: 'perps.order.type.scale.title', defaultLabel: 'Scale' },\n chase: { key: 'perps.order.type.chase.title', defaultLabel: 'Chase' },\n});\n"]}
|
|
1
|
+
{"version":3,"file":"perpsClientCopy.js","sourceRoot":"","sources":["../../src/utils/perpsClientCopy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAiB5E;;;;;GAKG;AACH,SAAS,aAAa,CACpB,OAAgB;IAEhB,KAAK,MAAM,KAAK,IAAI,MA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,IAAI,CAAC;QAC3B,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC;QACxB,CAAC,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;AACxD,CAAC;AAED,mEAAmE;AACnE,MAAM,CAAC,MAAM,uBAAuB,GAEhC,aAAa,CAAC;IAChB,MAAM,EAAE,EAAE,GAAG,EAAE,+BAA+B,EAAE,YAAY,EAAE,QAAQ,EAAE;IACxE,KAAK,EAAE,EAAE,GAAG,EAAE,8BAA8B,EAAE,YAAY,EAAE,OAAO,EAAE;IACrE,WAAW,EAAE;QACX,GAAG,EAAE,oCAAoC;QACzC,YAAY,EAAE,aAAa;KAC5B;IACD,UAAU,EAAE;QACV,GAAG,EAAE,mCAAmC;QACxC,YAAY,EAAE,YAAY;KAC3B;IACD,kBAAkB,EAAE;QAClB,GAAG,EAAE,2CAA2C;QAChD,YAAY,EAAE,aAAa;KAC5B;IACD,iBAAiB,EAAE;QACjB,GAAG,EAAE,0CAA0C;QAC/C,YAAY,EAAE,YAAY;KAC3B;IACD,IAAI,EAAE,EAAE,GAAG,EAAE,6BAA6B,EAAE,YAAY,EAAE,MAAM,EAAE;IAClE,KAAK,EAAE,EAAE,GAAG,EAAE,8BAA8B,EAAE,YAAY,EAAE,OAAO,EAAE;IACrE,KAAK,EAAE,EAAE,GAAG,EAAE,8BAA8B,EAAE,YAAY,EAAE,OAAO,EAAE;CACtE,CAAC,CAAC","sourcesContent":["import { PERPS_ERROR_CODES, isPerpsErrorCode } from '../perpsErrorCodes.js';\nimport type { PerpsErrorCode } from '../perpsErrorCodes.js';\nimport type { OrderType } from '../types/perps-types.js';\n\n/**\n * Translation key and English text for one piece of client copy. Clients\n * translate `key` and fall back to the default when they have no\n * translation. `{{name}}` placeholders are filled by the client.\n */\nexport type PerpsErrorCopy = Readonly<{ key: string; defaultMessage: string }>;\n\n/** Translation key and English label of an order type. */\nexport type PerpsOrderTypeLabel = Readonly<{\n key: string;\n defaultLabel: string;\n}>;\n\n/**\n * Freeze a client copy map and its string-valued entries.\n *\n * @param copyMap - The copy or label entries.\n * @returns The immutable copy map.\n */\nfunction freezeCopyMap<CopyMap extends Record<string, object>>(\n copyMap: CopyMap,\n): Readonly<CopyMap> {\n for (const entry of Object.values(copyMap)) {\n Object.freeze(entry);\n }\n return Object.freeze(copyMap);\n}\n\n/**\n * Copy for every `PERPS_ERROR_CODES` value. Keys follow the Mobile locale\n * files. `IOC_CANCEL` expects `{{maxSlippage}}`; without a known tolerance,\n * clients show `perps.errors.iocCancelUnknownTolerance` instead.\n */\nexport const PERPS_ERROR_COPY: Readonly<\n Record<PerpsErrorCode, PerpsErrorCopy>\n> = freezeCopyMap({\n [PERPS_ERROR_CODES.CLIENT_NOT_INITIALIZED]: {\n key: 'perps.errors.clientNotInitialized',\n defaultMessage: 'HyperLiquid SDK clients not properly initialized',\n },\n [PERPS_ERROR_CODES.CLIENT_REINITIALIZING]: {\n key: 'perps.errors.clientReinitializing',\n defaultMessage:\n 'Service is reinitializing. Please wait a moment and try again.',\n },\n [PERPS_ERROR_CODES.PROVIDER_NOT_AVAILABLE]: {\n key: 'perps.errors.providerNotAvailable',\n defaultMessage: 'Provider {{providerId}} not available',\n },\n [PERPS_ERROR_CODES.PROVIDER_NOT_FOUND]: {\n key: 'perps.errors.providerNotAvailable',\n defaultMessage: 'Provider {{providerId}} not available',\n },\n [PERPS_ERROR_CODES.PROVIDER_ROUTE_REQUIRED]: {\n key: 'perps.errors.providerRouteRequired',\n defaultMessage: 'Choose a provider for this order and try again.',\n },\n [PERPS_ERROR_CODES.PROVIDER_LIFECYCLE_STALE]: {\n key: 'perps.errors.clientReinitializing',\n defaultMessage:\n 'Service is reinitializing. Please wait a moment and try again.',\n },\n [PERPS_ERROR_CODES.TOKEN_NOT_SUPPORTED]: {\n key: 'perps.errors.tokenNotSupported',\n defaultMessage: 'Token {{token}} not supported for deposits',\n },\n [PERPS_ERROR_CODES.BRIDGE_CONTRACT_NOT_FOUND]: {\n key: 'perps.errors.bridgeContractNotFound',\n defaultMessage: 'Unable to get HyperLiquid bridge contract address',\n },\n [PERPS_ERROR_CODES.WITHDRAW_FAILED]: {\n key: 'perps.errors.withdrawFailed',\n defaultMessage: 'Failed to withdraw',\n },\n [PERPS_ERROR_CODES.POSITIONS_FAILED]: {\n key: 'perps.errors.positionsFailed',\n defaultMessage: 'Failed to get positions',\n },\n [PERPS_ERROR_CODES.ACCOUNT_STATE_FAILED]: {\n key: 'perps.errors.accountStateFailed',\n defaultMessage: 'Failed to get account state',\n },\n [PERPS_ERROR_CODES.MARKETS_FAILED]: {\n key: 'perps.errors.marketsFailed',\n defaultMessage: 'Failed to get markets',\n },\n [PERPS_ERROR_CODES.MARKET_NOT_FOUND]: {\n key: 'perps.errors.marketNotFound',\n defaultMessage: 'Market not found',\n },\n [PERPS_ERROR_CODES.UNKNOWN_ERROR]: {\n key: 'perps.errors.unknownError',\n defaultMessage: 'Unknown error occurred',\n },\n [PERPS_ERROR_CODES.ORDER_LEVERAGE_REDUCTION_FAILED]: {\n key: 'perps.errors.orderLeverageReductionFailed',\n defaultMessage: 'You cannot reduce your leverage',\n },\n [PERPS_ERROR_CODES.IOC_CANCEL]: {\n key: 'perps.errors.iocCancel',\n defaultMessage:\n \"Your order couldn't fill within your {{maxSlippage}}% slippage tolerance. Try a limit order or adjust your slippage.\",\n },\n [PERPS_ERROR_CODES.CONNECTION_TIMEOUT]: {\n key: 'perps.errors.connectionTimeout',\n defaultMessage:\n 'Connection timed out. Please check your network and try again.',\n },\n [PERPS_ERROR_CODES.WITHDRAW_ASSET_ID_REQUIRED]: {\n key: 'perps.errors.withdrawValidation.assetIdRequired',\n defaultMessage: 'assetId is required for withdrawals',\n },\n [PERPS_ERROR_CODES.WITHDRAW_AMOUNT_REQUIRED]: {\n key: 'perps.errors.withdrawValidation.amountRequired',\n defaultMessage: 'amount is required for withdrawals',\n },\n [PERPS_ERROR_CODES.WITHDRAW_AMOUNT_POSITIVE]: {\n key: 'perps.errors.withdrawValidation.amountPositive',\n defaultMessage: 'Amount must be a positive number',\n },\n [PERPS_ERROR_CODES.WITHDRAW_INVALID_DESTINATION]: {\n key: 'perps.errors.withdrawValidation.invalidDestination',\n defaultMessage: 'Invalid destination address format: {{address}}',\n },\n [PERPS_ERROR_CODES.WITHDRAW_ASSET_NOT_SUPPORTED]: {\n key: 'perps.errors.withdrawValidation.assetNotSupported',\n defaultMessage:\n 'Asset {{assetId}} is not supported for withdrawals. Supported assets: {{supportedAssets}}',\n },\n [PERPS_ERROR_CODES.WITHDRAW_INSUFFICIENT_BALANCE]: {\n key: 'perps.errors.withdrawValidation.insufficientBalance',\n defaultMessage:\n 'Insufficient balance. Available: {{available}}, Requested: {{requested}}',\n },\n [PERPS_ERROR_CODES.DEPOSIT_ASSET_ID_REQUIRED]: {\n key: 'perps.errors.depositValidation.assetIdRequired',\n defaultMessage: 'AssetId is required for deposit validation',\n },\n [PERPS_ERROR_CODES.DEPOSIT_AMOUNT_REQUIRED]: {\n key: 'perps.errors.depositValidation.amountRequired',\n defaultMessage: 'Amount is required and must be greater than 0',\n },\n [PERPS_ERROR_CODES.DEPOSIT_AMOUNT_POSITIVE]: {\n key: 'perps.errors.depositValidation.amountPositive',\n defaultMessage: 'Amount must be a positive number',\n },\n [PERPS_ERROR_CODES.DEPOSIT_MINIMUM_AMOUNT]: {\n key: 'perps.errors.minimumDeposit',\n defaultMessage: 'Minimum deposit amount is {{amount}} USDC',\n },\n [PERPS_ERROR_CODES.ORDER_COIN_REQUIRED]: {\n key: 'perps.errors.orderValidation.coinRequired',\n defaultMessage: 'Coin is required for orders',\n },\n [PERPS_ERROR_CODES.ORDER_LIMIT_PRICE_REQUIRED]: {\n key: 'perps.errors.orderValidation.limitPriceRequired',\n defaultMessage: 'Price is required for limit orders',\n },\n [PERPS_ERROR_CODES.ORDER_PRICE_POSITIVE]: {\n key: 'perps.errors.orderValidation.pricePositive',\n defaultMessage: 'Price must be a positive number if provided',\n },\n [PERPS_ERROR_CODES.ORDER_UNKNOWN_COIN]: {\n key: 'perps.errors.orderValidation.unknownCoin',\n defaultMessage: 'Unknown coin: {{coin}}',\n },\n [PERPS_ERROR_CODES.ORDER_SIZE_POSITIVE]: {\n key: 'perps.errors.orderValidation.sizePositive',\n defaultMessage: 'Size must be a positive number',\n },\n [PERPS_ERROR_CODES.ORDER_PRICE_REQUIRED]: {\n key: 'perps.order.validation.price_required',\n defaultMessage: 'Price is required',\n },\n [PERPS_ERROR_CODES.ORDER_SIZE_MIN]: {\n key: 'perps.order.validation.minimum_amount',\n // A literal dollar sign before a client-filled placeholder.\n // eslint-disable-next-line no-template-curly-in-string\n defaultMessage: 'Minimum order size is ${{amount}}',\n },\n [PERPS_ERROR_CODES.ORDER_LEVERAGE_INVALID]: {\n key: 'perps.order.validation.invalid_leverage',\n defaultMessage: 'Leverage must be between {{min}}x and {{max}}x',\n },\n [PERPS_ERROR_CODES.ORDER_MARGIN_MODE_INVALID]: {\n key: 'perps.errors.orderValidation.marginModeInvalid',\n defaultMessage: 'Choose a valid margin mode.',\n },\n [PERPS_ERROR_CODES.ORDER_MARGIN_MODE_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.marginModeUnsupported',\n defaultMessage:\n 'The selected margin mode is not available for this market.',\n },\n [PERPS_ERROR_CODES.ORDER_MARGIN_MODE_POSITION_OPEN]: {\n key: 'perps.errors.orderValidation.marginModePositionOpen',\n defaultMessage:\n 'Close the open position on this market before changing margin mode.',\n },\n [PERPS_ERROR_CODES.ORDER_MARGIN_MODE_ORDER_OPEN]: {\n key: 'perps.errors.orderValidation.marginModeOrderOpen',\n defaultMessage:\n 'Cancel the open orders on this market before changing margin mode.',\n },\n [PERPS_ERROR_CODES.ORDER_LEVERAGE_BELOW_POSITION]: {\n key: 'perps.order.validation.leverage_below_position',\n defaultMessage:\n 'Leverage must be at least {{required}}x to match your existing position (current: {{provided}}x)',\n },\n [PERPS_ERROR_CODES.ORDER_MAX_VALUE_EXCEEDED]: {\n key: 'perps.order.validation.max_order_value',\n // A literal dollar sign before a client-filled placeholder.\n // eslint-disable-next-line no-template-curly-in-string\n defaultMessage: 'Order size must be below ${{maxValue}}',\n },\n [PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_REQUIRED]: {\n key: 'perps.errors.orderValidation.triggerPriceRequired',\n defaultMessage:\n 'A trigger price is required for stop and take profit orders',\n },\n [PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_POSITIVE]: {\n key: 'perps.errors.orderValidation.triggerPricePositive',\n defaultMessage: 'Trigger price must be a positive number',\n },\n [PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_NOT_SUPPORTED]: {\n key: 'perps.errors.orderValidation.triggerPriceNotSupported',\n defaultMessage: \"Market and limit orders can't have a trigger price\",\n },\n [PERPS_ERROR_CODES.ORDER_TRIGGER_TPSL_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.triggerTpslUnsupported',\n defaultMessage:\n \"Stop and take profit orders can't carry their own take profit or stop loss\",\n },\n [PERPS_ERROR_CODES.ORDER_TPSL_SIZE_INVALID]: {\n key: 'perps.errors.orderValidation.tpslSizeInvalid',\n defaultMessage:\n 'Take profit and stop loss size must be positive and no larger than the order',\n },\n [PERPS_ERROR_CODES.ORDER_EDIT_TRIGGER_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.editTriggerUnsupported',\n defaultMessage:\n \"Stop and take profit orders can't be edited. Cancel the order and place a new one.\",\n },\n [PERPS_ERROR_CODES.ORDER_TPSL_LINKAGE_CONFLICT]: {\n key: 'perps.errors.orderValidation.tpslLinkageConflict',\n defaultMessage: 'Conflicting take profit and stop loss settings',\n },\n [PERPS_ERROR_CODES.ORDER_TPSL_POSITION_LINKAGE_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.tpslPositionLinkageUnsupported',\n defaultMessage:\n 'Take profit and stop loss can only be attached to a position once the order has filled',\n },\n [PERPS_ERROR_CODES.ORDER_TPSL_LINKAGE_REQUIRED]: {\n key: 'perps.errors.orderValidation.tpslLinkageRequired',\n defaultMessage:\n 'Take profit and stop loss must be attached to the order or to the position',\n },\n [PERPS_ERROR_CODES.ORDER_EDIT_ORDER_UNVERIFIABLE]: {\n key: 'perps.errors.orderValidation.editOrderUnverifiable',\n defaultMessage:\n 'This order can no longer be found. Refresh your orders and try again.',\n },\n [PERPS_ERROR_CODES.ORDER_TIME_IN_FORCE_NOT_SUPPORTED]: {\n key: 'perps.errors.orderValidation.timeInForceNotSupported',\n defaultMessage: 'Time in force can only be set on limit orders',\n },\n [PERPS_ERROR_CODES.ORDER_STRATEGY_PARAMS_NOT_SUPPORTED]: {\n key: 'perps.errors.orderValidation.strategyParamsNotSupported',\n defaultMessage: \"These order settings aren't supported for this order type\",\n },\n [PERPS_ERROR_CODES.ORDER_STRATEGY_FIELD_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.strategyFieldUnsupported',\n defaultMessage:\n \"This field can't be used with a TWAP, scale, or chase order\",\n },\n [PERPS_ERROR_CODES.ORDER_STRATEGY_MARKET_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.strategyMarketUnsupported',\n defaultMessage:\n \"TWAP, scale, and chase orders aren't available on this market\",\n },\n [PERPS_ERROR_CODES.ORDER_STRATEGY_ROUTE_UNAVAILABLE]: {\n key: 'perps.errors.orderValidation.strategyMarketUnsupported',\n defaultMessage:\n \"TWAP, scale, and chase orders aren't available on this market\",\n },\n [PERPS_ERROR_CODES.ORDER_STRATEGY_HANDLE_UNKNOWN]: {\n key: 'perps.errors.orderValidation.strategyHandleUnknown',\n defaultMessage:\n 'This strategy order can no longer be found. Refresh your orders and try again.',\n },\n [PERPS_ERROR_CODES.ORDER_EDIT_STRATEGY_UNSUPPORTED]: {\n key: 'perps.errors.orderValidation.strategyEditUnsupported',\n defaultMessage:\n \"TWAP, scale, and chase orders can't be edited. Cancel the order and place a new one.\",\n },\n [PERPS_ERROR_CODES.ORDER_STRATEGY_CANCEL_INCOMPLETE]: {\n key: 'perps.errors.orderValidation.strategyCancelIncomplete',\n defaultMessage:\n \"Some parts of this strategy order couldn't be cancelled. Try again.\",\n },\n [PERPS_ERROR_CODES.ORDER_TWAP_DURATION_REQUIRED]: {\n key: 'perps.errors.orderValidation.twapDurationRequired',\n defaultMessage: 'A duration is required for TWAP orders',\n },\n [PERPS_ERROR_CODES.ORDER_TWAP_DURATION_INVALID]: {\n key: 'perps.errors.orderValidation.twapDurationInvalid',\n defaultMessage: 'TWAP duration must be between 5 and 1440 minutes',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_PREVIEW_STALE]: {\n key: 'perps.errors.orderValidation.scalePreviewStale',\n defaultMessage:\n 'Scale order details changed. Review the updated preview and try again.',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_RANGE_REQUIRED]: {\n key: 'perps.errors.orderValidation.scaleRangeRequired',\n defaultMessage: 'Scale orders need a minimum and maximum price',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_RANGE_INVALID]: {\n key: 'perps.errors.orderValidation.scaleRangeInvalid',\n defaultMessage: 'Scale order maximum price must be above the minimum',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_COUNT_INVALID]: {\n key: 'perps.errors.orderValidation.scaleCountInvalid',\n defaultMessage: 'Scale order count is invalid',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_SIZE_TOO_SMALL]: {\n key: 'perps.errors.orderValidation.scaleSizeTooSmall',\n defaultMessage: 'Each scale order is below the minimum size',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_NOTIONAL_TOO_SMALL]: {\n key: 'perps.errors.orderValidation.scaleNotionalTooSmall',\n defaultMessage: 'Each scale order is below the exchange minimum value',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_SIZE_CONSERVATION_FAILED]: {\n key: 'perps.errors.unknownError',\n defaultMessage: 'Unknown error occurred',\n },\n [PERPS_ERROR_CODES.ORDER_SCALE_EXPOSURE_EXCEEDS_INTENT]: {\n key: 'perps.errors.unknownError',\n defaultMessage: 'Unknown error occurred',\n },\n [PERPS_ERROR_CODES.ORDER_TWAP_NOTIONAL_TOO_SMALL]: {\n key: 'perps.errors.orderValidation.twapNotionalTooSmall',\n defaultMessage: 'TWAP order value is below the exchange minimum',\n },\n [PERPS_ERROR_CODES.ORDER_CHASE_INTERVAL_INVALID]: {\n key: 'perps.errors.orderValidation.chaseIntervalInvalid',\n defaultMessage: 'Chase interval is invalid',\n },\n [PERPS_ERROR_CODES.ORDER_CHASE_DURATION_INVALID]: {\n key: 'perps.errors.orderValidation.chaseDurationInvalid',\n defaultMessage: 'Chase duration is invalid',\n },\n [PERPS_ERROR_CODES.ORDER_CHASE_MAX_DISTANCE_INVALID]: {\n key: 'perps.errors.orderValidation.chaseMaxDistanceInvalid',\n defaultMessage: 'Max chase distance is outside the allowed range',\n },\n [PERPS_ERROR_CODES.ORDER_CHASE_ABANDONED]: {\n key: 'perps.errors.orderValidation.chaseStoppedCheckOpenOrders',\n defaultMessage:\n 'The chase stopped. Check open orders for any remaining orders.',\n },\n [PERPS_ERROR_CODES.ORDER_CHASE_LIMIT_REACHED]: {\n key: 'perps.errors.orderValidation.chaseLimitReached',\n defaultMessage: 'Too many chase orders are already running',\n },\n [PERPS_ERROR_CODES.ORDER_CHASE_TOUCH_UNAVAILABLE]: {\n key: 'perps.errors.orderValidation.chaseTouchUnavailable',\n defaultMessage: 'No market price is available to place this chase order',\n },\n [PERPS_ERROR_CODES.EXCHANGE_CLIENT_NOT_AVAILABLE]: {\n key: 'perps.errors.exchangeClientNotAvailable',\n defaultMessage: 'ExchangeClient not available after initialization',\n },\n [PERPS_ERROR_CODES.INFO_CLIENT_NOT_AVAILABLE]: {\n key: 'perps.errors.infoClientNotAvailable',\n defaultMessage: 'InfoClient not available after initialization',\n },\n [PERPS_ERROR_CODES.SUBSCRIPTION_CLIENT_NOT_AVAILABLE]: {\n key: 'perps.errors.subscriptionClientNotAvailable',\n defaultMessage: 'SubscriptionClient not available after initialization',\n },\n [PERPS_ERROR_CODES.NO_ACCOUNT_SELECTED]: {\n key: 'perps.errors.noAccountSelected',\n defaultMessage: 'No account selected',\n },\n [PERPS_ERROR_CODES.KEYRING_LOCKED]: {\n key: 'perps.errors.unknownError',\n defaultMessage: 'Unknown error occurred',\n },\n [PERPS_ERROR_CODES.INVALID_ADDRESS_FORMAT]: {\n key: 'perps.errors.invalidAddressFormat',\n defaultMessage: 'Invalid address format: {{address}}',\n },\n [PERPS_ERROR_CODES.EXCHANGE_ACCOUNT_NOT_FOUND]: {\n key: 'perps.errors.exchangeAccountNotFound',\n defaultMessage: 'Add funds to your account before placing an order',\n },\n [PERPS_ERROR_CODES.EXCHANGE_MULTI_SIG_REQUIRED]: {\n key: 'perps.errors.exchangeMultiSigRequired',\n defaultMessage: 'This account needs its multi-signature signers to trade',\n },\n [PERPS_ERROR_CODES.EXCHANGE_INVALID_NONCE]: {\n key: 'perps.errors.exchangeInvalidNonce',\n defaultMessage: 'Something went wrong. Try again.',\n },\n [PERPS_ERROR_CODES.TRANSFER_FAILED]: {\n key: 'perps.errors.transferFailed',\n defaultMessage: 'Unable to transfer funds. Please try again.',\n },\n [PERPS_ERROR_CODES.SWAP_FAILED]: {\n key: 'perps.errors.swapFailed',\n defaultMessage: 'Unable to swap tokens. Please try again.',\n },\n [PERPS_ERROR_CODES.SPOT_PAIR_NOT_FOUND]: {\n key: 'perps.errors.spotPairNotFound',\n defaultMessage: 'Trading pair is not available at this time.',\n },\n [PERPS_ERROR_CODES.ORDERS_FAILED]: {\n key: 'perps.errors.ordersFailed',\n defaultMessage: 'Unable to load orders. Please refresh and try again.',\n },\n [PERPS_ERROR_CODES.LIQUIDATION_PRICE_UNAVAILABLE]: {\n key: 'perps.errors.liquidationPriceUnavailable',\n defaultMessage:\n 'A liquidation price estimate is unavailable for this order.',\n },\n [PERPS_ERROR_CODES.PRICE_UNAVAILABLE]: {\n key: 'perps.errors.priceUnavailable',\n defaultMessage: 'Price data is unavailable. Please refresh and try again.',\n },\n [PERPS_ERROR_CODES.UNSUPPORTED_COLLATERAL]: {\n key: 'perps.errors.unsupportedCollateral',\n defaultMessage: \"This market's collateral is not supported\",\n },\n [PERPS_ERROR_CODES.BATCH_INCOMPLETE]: {\n key: 'perps.errors.batchIncomplete',\n defaultMessage:\n 'The action did not complete on every venue. Check the result for each venue.',\n },\n [PERPS_ERROR_CODES.ORDER_NO_LONGER_OPEN]: {\n key: 'perps.errors.orderNoLongerOpen',\n defaultMessage: 'This order is no longer open.',\n },\n [PERPS_ERROR_CODES.ORDER_POST_ONLY_WOULD_CROSS]: {\n key: 'perps.errors.postOnlyWouldCross',\n defaultMessage:\n 'This post-only order would execute immediately. Check the order status before trying a different price.',\n },\n [PERPS_ERROR_CODES.ORDER_POST_ONLY_WINDOW]: {\n key: 'perps.errors.postOnlyWindow',\n defaultMessage: 'Only post-only orders are available right now.',\n },\n [PERPS_ERROR_CODES.BATCH_CANCEL_FAILED]: {\n key: 'perps.errors.batchCancelFailed',\n defaultMessage: \"Some orders couldn't be cancelled. Please try again.\",\n },\n [PERPS_ERROR_CODES.BATCH_CLOSE_FAILED]: {\n key: 'perps.errors.batchCloseFailed',\n defaultMessage: \"Some positions couldn't be closed. Please try again.\",\n },\n [PERPS_ERROR_CODES.INSUFFICIENT_MARGIN]: {\n key: 'perps.errors.insufficientMargin',\n defaultMessage:\n 'Insufficient margin to execute this trade. Consider adding more funds or reducing your position size.',\n },\n [PERPS_ERROR_CODES.INSUFFICIENT_BALANCE]: {\n key: 'perps.errors.insufficientBalance',\n defaultMessage:\n 'Insufficient balance to complete this operation. Check your available funds.',\n },\n [PERPS_ERROR_CODES.REDUCE_ONLY_VIOLATION]: {\n key: 'perps.errors.reduceOnlyViolation',\n defaultMessage:\n 'This order would increase your position. Only reduce-only orders are allowed.',\n },\n [PERPS_ERROR_CODES.POSITION_WOULD_FLIP]: {\n key: 'perps.errors.positionWouldFlip',\n defaultMessage:\n 'This order would flip your position direction. Please close your existing position first.',\n },\n [PERPS_ERROR_CODES.POSITION_NOT_FOUND]: {\n key: 'perps.errors.position_not_found',\n defaultMessage: 'Position not found',\n },\n [PERPS_ERROR_CODES.MARGIN_ADJUSTMENT_FAILED]: {\n key: 'perps.errors.marginAdjustmentFailed',\n defaultMessage: 'Unable to adjust margin. Try again.',\n },\n [PERPS_ERROR_CODES.TPSL_UPDATE_FAILED]: {\n key: 'perps.errors.tpslUpdateFailed',\n defaultMessage: 'Unable to update take profit/stop loss. Try again.',\n },\n [PERPS_ERROR_CODES.TPSL_PROTECTION_LOST]: {\n key: 'perps.errors.tpslProtectionLost',\n defaultMessage:\n \"We could not confirm the previous protection was restored. Check the position's take profit and stop loss.\",\n },\n [PERPS_ERROR_CODES.TPSL_LEG_REPLACE_UNSUPPORTED]: {\n key: 'perps.errors.tpslLegReplaceUnsupported',\n defaultMessage:\n 'Updating only take profit or only stop loss isn’t available for this provider. Update take profit and stop loss together instead.',\n },\n [PERPS_ERROR_CODES.ORDER_REJECTED]: {\n key: 'perps.errors.orderRejected',\n defaultMessage: 'Order was rejected. Check your parameters and try again.',\n },\n [PERPS_ERROR_CODES.SLIPPAGE_EXCEEDED]: {\n key: 'perps.errors.slippageExceeded',\n defaultMessage:\n 'Price moved too much. Try using a limit order or increase slippage tolerance.',\n },\n [PERPS_ERROR_CODES.PRICE_MOVED]: {\n key: 'perps.errors.priceMoved',\n defaultMessage:\n 'The price moved {{priceDelta}}%, exceeding your {{maxSlippage}}% slippage tolerance. Review the updated price and try again.',\n },\n [PERPS_ERROR_CODES.RATE_LIMIT_EXCEEDED]: {\n key: 'perps.errors.rateLimitExceeded',\n defaultMessage: 'Too many requests. Wait a moment and try again.',\n },\n [PERPS_ERROR_CODES.SERVICE_UNAVAILABLE]: {\n key: 'perps.errors.serviceUnavailable',\n defaultMessage: 'Service is temporarily unavailable. Try again later.',\n },\n [PERPS_ERROR_CODES.NETWORK_ERROR]: {\n key: 'perps.errors.networkErrorSimple',\n defaultMessage:\n 'Network error occurred. Check your connection and try again.',\n },\n});\n\n/**\n * Copy for an error code, or the `UNKNOWN_ERROR` copy for anything that is not\n * a Perps error code (a code from a newer controller, or a raw message).\n *\n * @param code - Error code from a controller result or error.\n * @returns The code's copy.\n */\nexport function getPerpsErrorCopy(code: unknown): PerpsErrorCopy {\n return isPerpsErrorCode(code)\n ? PERPS_ERROR_COPY[code]\n : PERPS_ERROR_COPY[PERPS_ERROR_CODES.UNKNOWN_ERROR];\n}\n\n/** Label for every normalised order type, keyed by `OrderType`. */\nexport const PERPS_ORDER_TYPE_LABELS: Readonly<\n Record<OrderType, PerpsOrderTypeLabel>\n> = freezeCopyMap({\n market: { key: 'perps.order.type.market.title', defaultLabel: 'Market' },\n limit: { key: 'perps.order.type.limit.title', defaultLabel: 'Limit' },\n stop_market: {\n key: 'perps.order.type.stop_market.title',\n defaultLabel: 'Stop market',\n },\n stop_limit: {\n key: 'perps.order.type.stop_limit.title',\n defaultLabel: 'Stop limit',\n },\n take_profit_market: {\n key: 'perps.order.type.take_profit_market.title',\n defaultLabel: 'Take market',\n },\n take_profit_limit: {\n key: 'perps.order.type.take_profit_limit.title',\n defaultLabel: 'Take limit',\n },\n twap: { key: 'perps.order.type.twap.title', defaultLabel: 'TWAP' },\n scale: { key: 'perps.order.type.scale.title', defaultLabel: 'Scale' },\n chase: { key: 'perps.order.type.chase.title', defaultLabel: 'Chase' },\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perpsDiskPersistence.d.ts","sourceRoot":"","sources":["../../src/utils/perpsDiskPersistence.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,YAAY,EACZ,KAAK,EACL,eAAe,EACf,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAU3B,sEAAsE;AACtE,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7C,WAAW,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACzC,OAAO,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AAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,cAAc,EACzB,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,EACzD,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,EACvD,YAAY,EAAE,MAAM,GACnB,qBAAqB,CA2IvB"}
|
|
@@ -178,6 +178,16 @@ export function hydrateFromDiskSync(diskCache, currentMarketCache, currentUserCa
|
|
|
178
178
|
}
|
|
179
179
|
delete structuralMarket.dataSource;
|
|
180
180
|
delete structuralMarket.sourceExpiresAt;
|
|
181
|
+
if (structuralMarket.numericValues) {
|
|
182
|
+
// Price and change are shown as placeholders below, so
|
|
183
|
+
// their stale sort values go too. Volume and OI stay.
|
|
184
|
+
const structuralValues = {
|
|
185
|
+
...structuralMarket.numericValues,
|
|
186
|
+
};
|
|
187
|
+
delete structuralValues.price;
|
|
188
|
+
delete structuralValues.change24hPercent;
|
|
189
|
+
structuralMarket.numericValues = structuralValues;
|
|
190
|
+
}
|
|
181
191
|
return {
|
|
182
192
|
...structuralMarket,
|
|
183
193
|
price: PERPS_CONSTANTS.FallbackPriceDisplay,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perpsDiskPersistence.js","sourceRoot":"","sources":["../../src/utils/perpsDiskPersistence.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,wBAAwB,EACxB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,6BAA6B,CAAC;AAQrC;;;;;GAKG;AACH,MAAM,+BAA+B,GAAG,EAAE,CAAC;AAqC3C;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAA0B,EAC1B,cAAsB,EACtB,SAAkB,EAClB,GAAW;IAEX,IAAI,cAA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K,CAAC,SAAS,CAAC,MAAM,CAAC;4BACxC,UAAU,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;wBACpC,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,iCAAiC;YACnC,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,mCAAmC;IACrC,CAAC;IAED,OAAO;QACL,aAAa;QACb,WAAW;QACX,KAAK,EAAE;YACL,WAAW;YACX,aAAa;YACb,UAAU;YACV,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;SACnC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n buildProviderCacheKey,\n PERPS_CONSTANTS,\n PERPS_DISK_CACHE_MARKETS,\n PERPS_DISK_CACHE_USER_DATA,\n PROVIDER_CONFIG,\n} from '../constants/perpsConfig.js';\nimport type {\n AccountState,\n Order,\n PerpsMarketData,\n Position,\n} from '../types/index.js';\n\n/**\n * Multiplier applied to staleGuardMs (preloadGuardMs, currently 30s) to compute\n * the staleness cap for disk-hydrated timestamps. A factor of 10 ensures hydrated\n * data is always TTL-expired so the stream manager overwrites it with live data,\n * while still being recent enough for a useful first paint.\n */\nconst DISK_HYDRATION_STALENESS_FACTOR = 10;\n\n/** Minimal disk cache interface required by persistence utilities. */\nexport type PerpsDiskCache = {\n getItem(key: string): Promise<string | null>;\n getItemSync?(key: string): string | null;\n setItem(key: string, value: string): Promise<void>;\n};\n\n/** Shape of a single market entry persisted to disk cache. */\nexport type DiskCacheMarketEntry = {\n providerNetworkKey: string;\n data: PerpsMarketData[];\n timestamp: number;\n};\n\n/** Shape of a single user-data entry persisted to disk cache. */\nexport type DiskCacheUserEntry = {\n providerNetworkKey: string;\n address: string;\n positions: Position[];\n orders: Order[];\n accountState: AccountState | null;\n timestamp: number;\n hip3ConfigVersion?: number;\n dexes?: string[];\n};\n\n/** Disk payload shape — either a single entry or a multi-provider wrapper. */\nexport type DiskCacheMarketPayload =\n | DiskCacheMarketEntry\n | { entries: DiskCacheMarketEntry[] };\n\nexport type DiskCacheUserPayload =\n | DiskCacheUserEntry\n | { entries: DiskCacheUserEntry[] };\n\n/**\n * Build the disk-cache payload for market data.\n * In aggregated mode, groups markets by provider into separate entries.\n *\n * @param markets - Current market data snapshot.\n * @param activeProvider - The active provider id (may be \"aggregated\").\n * @param isTestnet - Global testnet flag.\n * @param now - Timestamp to stamp entries with.\n * @returns Payload ready for JSON serialization.\n */\nexport function buildMarketDataPayload(\n markets: PerpsMarketData[],\n activeProvider: string,\n isTestnet: boolean,\n now: number,\n): DiskCacheMarketPayload {\n if (activeProvider === 'aggregated') {\n const entriesByKey = new Map<string, DiskCacheMarketEntry>();\n for (const market of markets) {\n const providerId = market.providerId ?? PROVIDER_CONFIG.DefaultProvider;\n const key = buildProviderCacheKey(providerId, isTestnet);\n const existing = entriesByKey.get(key);\n if (existing) {\n existing.data.push(market);\n } else {\n entriesByKey.set(key, {\n providerNetworkKey: key,\n data: [market],\n timestamp: now,\n });\n }\n }\n const entries = Array.from(entriesByKey.values());\n return entries.length === 1 ? entries[0] : { entries };\n }\n return {\n providerNetworkKey: buildProviderCacheKey(\n activeProvider ?? PROVIDER_CONFIG.DefaultProvider,\n isTestnet,\n ),\n data: markets,\n timestamp: now,\n };\n}\n\n/**\n * Build the disk-cache payload for user data (positions, orders, account).\n * In aggregated mode, groups entries by provider.\n *\n * @param positions - Current positions snapshot.\n * @param orders - Current orders snapshot.\n * @param accountState - Current account state snapshot.\n * @param address - EVM account address.\n * @param activeProvider - The active provider id (may be \"aggregated\").\n * @param isTestnet - Global testnet flag.\n * @param now - Timestamp to stamp entries with.\n * @returns Payload ready for JSON serialization.\n */\nexport function buildUserDataPayload(\n positions: Position[],\n orders: Order[],\n accountState: AccountState | null,\n address: string,\n activeProvider: string,\n isTestnet: boolean,\n now: number,\n): DiskCacheUserPayload {\n if (activeProvider === 'aggregated') {\n const entriesByKey = new Map<string, DiskCacheUserEntry>();\n const ensureEntry = (providerId: string): DiskCacheUserEntry => {\n const key = buildProviderCacheKey(providerId, isTestnet);\n let entry = entriesByKey.get(key);\n if (!entry) {\n entry = {\n providerNetworkKey: key,\n address,\n positions: [],\n orders: [],\n accountState: null,\n timestamp: now,\n };\n entriesByKey.set(key, entry);\n }\n return entry;\n };\n\n for (const position of positions) {\n ensureEntry(\n position.providerId ?? PROVIDER_CONFIG.DefaultProvider,\n ).positions.push(position);\n }\n for (const order of orders) {\n ensureEntry(\n order.providerId ?? PROVIDER_CONFIG.DefaultProvider,\n ).orders.push(order);\n }\n if (accountState) {\n ensureEntry(\n accountState.providerId ?? PROVIDER_CONFIG.DefaultProvider,\n ).accountState = accountState;\n }\n\n const entries = Array.from(entriesByKey.values()).filter(\n (entry) =>\n entry.positions.length > 0 ||\n entry.orders.length > 0 ||\n entry.accountState !== null,\n );\n return entries.length === 1 ? entries[0] : { entries };\n }\n return {\n providerNetworkKey: buildProviderCacheKey(\n activeProvider ?? PROVIDER_CONFIG.DefaultProvider,\n isTestnet,\n ),\n address,\n positions,\n orders,\n accountState,\n timestamp: now,\n };\n}\n\n/**\n * Write market entries to disk (best-effort, non-blocking).\n *\n * @param diskCache - Disk cache instance from controller infrastructure.\n * @param entries - Pre-assembled market cache entries to persist.\n */\nexport function persistMarketEntriesToDisk(\n diskCache: PerpsDiskCache,\n entries: DiskCacheMarketEntry[],\n): void {\n if (entries.length === 0) {\n return;\n }\n const payload = entries.length === 1 ? entries[0] : { entries };\n diskCache\n .setItem(PERPS_DISK_CACHE_MARKETS, JSON.stringify(payload))\n .catch(() => {\n // Disk persistence is best-effort and must never block preload.\n });\n}\n\n/**\n * Write user data entries to disk (best-effort, non-blocking).\n *\n * @param diskCache - Disk cache instance from controller infrastructure.\n * @param entries - Pre-assembled user cache entries to persist.\n */\nexport async function persistUserEntriesToDisk(\n diskCache: PerpsDiskCache,\n entries: DiskCacheUserEntry[],\n): Promise<void> {\n if (entries.length === 0) {\n return;\n }\n const payload = entries.length === 1 ? entries[0] : { entries };\n await diskCache.setItem(PERPS_DISK_CACHE_USER_DATA, JSON.stringify(payload));\n}\n\n/** Computed updates returned by hydrateFromDiskSync. */\nexport type HydrateFromDiskResult = {\n marketUpdates: Record<string, { data: PerpsMarketData[]; timestamp: number }>;\n userUpdates: Record<\n string,\n {\n positions: Position[];\n orders: Order[];\n accountState: AccountState | null;\n timestamp: number;\n address: string;\n hip3ConfigVersion?: number;\n dexes?: string[];\n }\n >;\n stats: {\n marketCount: number;\n userPositions: number;\n userOrders: number;\n durationMs: number;\n };\n};\n\n/**\n * Read disk-persisted cache snapshots and compute the state updates to apply.\n * Returns plain objects rather than mutating state directly, so the caller\n * can apply all changes in a single batched this.update() call.\n *\n * All returned timestamps are capped at DISK_HYDRATION_STALENESS_FACTOR * staleGuardMs\n * in the past so the stream manager always overwrites disk data with fresh live data.\n *\n * @param diskCache - Disk cache instance from controller infrastructure.\n * @param currentMarketCache - Current cachedMarketDataByProvider state.\n * @param currentUserCache - Current cachedUserDataByProvider state.\n * @param staleGuardMs - preloadGuardMs constant from the controller.\n * @returns Updates to apply plus stats for debug logging.\n */\nexport function hydrateFromDiskSync(\n diskCache: PerpsDiskCache,\n currentMarketCache: Record<string, { timestamp: number }>,\n currentUserCache: Record<string, { timestamp: number }>,\n staleGuardMs: number,\n): HydrateFromDiskResult {\n const hydrateT0 = Date.now();\n const marketUpdates: HydrateFromDiskResult['marketUpdates'] = {};\n const userUpdates: HydrateFromDiskResult['userUpdates'] = {};\n let marketCount = 0;\n let userPositions = 0;\n let userOrders = 0;\n\n if (!diskCache.getItemSync) {\n return {\n marketUpdates,\n userUpdates,\n stats: { marketCount, userPositions, userOrders, durationMs: 0 },\n };\n }\n\n const staleHydratedTimestamp =\n Date.now() - staleGuardMs * DISK_HYDRATION_STALENESS_FACTOR - 1;\n\n try {\n const marketsRaw = diskCache.getItemSync(PERPS_DISK_CACHE_MARKETS);\n const userRaw = diskCache.getItemSync(PERPS_DISK_CACHE_USER_DATA);\n\n if (marketsRaw) {\n try {\n const parsed = JSON.parse(marketsRaw) as\n | DiskCacheMarketEntry\n | { entries: DiskCacheMarketEntry[] };\n const entries = Array.isArray((parsed as { entries?: unknown }).entries)\n ? (parsed as { entries: DiskCacheMarketEntry[] }).entries\n : [parsed as DiskCacheMarketEntry];\n\n for (const entry of entries) {\n if (entry.providerNetworkKey && Array.isArray(entry.data)) {\n const existing = currentMarketCache[entry.providerNetworkKey];\n if (!existing || existing.timestamp < entry.timestamp) {\n const strippedData = entry.data.map((market) => {\n const structuralMarket = { ...market };\n if (\n structuralMarket.dataSource ===\n 'terminal-global-snapshot-mark'\n ) {\n delete structuralMarket.trend;\n }\n delete structuralMarket.dataSource;\n delete structuralMarket.sourceExpiresAt;\n return {\n ...structuralMarket,\n price: PERPS_CONSTANTS.FallbackPriceDisplay,\n change24h: PERPS_CONSTANTS.FallbackDataDisplay,\n change24hPercent: PERPS_CONSTANTS.FallbackPercentageDisplay,\n ...(structuralMarket.change5m !== undefined && {\n change5m: PERPS_CONSTANTS.FallbackDataDisplay,\n }),\n ...(structuralMarket.changePercent5m !== undefined && {\n changePercent5m: PERPS_CONSTANTS.FallbackPercentageDisplay,\n }),\n ...(structuralMarket.change1h !== undefined && {\n change1h: PERPS_CONSTANTS.FallbackDataDisplay,\n }),\n ...(structuralMarket.changePercent1h !== undefined && {\n changePercent1h: PERPS_CONSTANTS.FallbackPercentageDisplay,\n }),\n };\n });\n marketUpdates[entry.providerNetworkKey] = {\n data: strippedData,\n // Disk-hydrated market snapshots are only for structural\n // first paint. Keep them TTL-stale so the stream manager\n // still fetches fresh prices on connect.\n timestamp: Math.min(entry.timestamp, staleHydratedTimestamp),\n };\n marketCount += strippedData.length;\n }\n }\n }\n } catch {\n // Corrupt JSON — silently ignore\n }\n }\n\n if (userRaw) {\n try {\n const parsed = JSON.parse(userRaw) as\n | DiskCacheUserEntry\n | { entries: DiskCacheUserEntry[] };\n const entries = Array.isArray((parsed as { entries?: unknown }).entries)\n ? (parsed as { entries: DiskCacheUserEntry[] }).entries\n : [parsed as DiskCacheUserEntry];\n\n for (const entry of entries) {\n if (entry.providerNetworkKey && entry.address) {\n // Skip address check here — accounts may not be loaded yet at\n // constructor time. getCachedUserDataForActiveProvider validates\n // the address at read time, so stale-account data is never served.\n const existing = currentUserCache[entry.providerNetworkKey];\n if (!existing || existing.timestamp < entry.timestamp) {\n userUpdates[entry.providerNetworkKey] = {\n positions: entry.positions,\n orders: entry.orders,\n accountState: entry.accountState,\n timestamp: Math.min(entry.timestamp, staleHydratedTimestamp),\n address: entry.address,\n hip3ConfigVersion: entry.hip3ConfigVersion,\n dexes: entry.dexes,\n };\n userPositions += entry.positions.length;\n userOrders += entry.orders.length;\n }\n }\n }\n } catch {\n // Corrupt JSON — silently ignore\n }\n }\n } catch {\n // Disk read failure — non-critical\n }\n\n return {\n marketUpdates,\n userUpdates,\n stats: {\n marketCount,\n userPositions,\n userOrders,\n durationMs: Date.now() - hydrateT0,\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"perpsDiskPersistence.js","sourceRoot":"","sources":["../../src/utils/perpsDiskPersistence.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,wBAAwB,EACxB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,6BAA6B,CAAC;AAQrC;;;;;GAKG;AACH,MAAM,+BAA+B,GAAG,EAAE,CAAC;AAqC3C;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAA0B,EAC1B,cAAsB,EACtB,SAAkB,EAClB,GAAW;IAEX,IAAI,cAAc,KAAK,YAAY,EAAE,CAAC;QACpC,MAAM,YAAY,GAAG,IAAI,GAAG,EAAgC,CAAC;QAC7D,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,eAAe,CAAC,eAAe,CAAC;YACxE,MAAM,GAAG,GAAG,qBAAqB,CAAC,UAA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KAAK,CAAC,KAAK;6BACnB,CAAC;4BACF,aAAa,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC;4BACxC,UAAU,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;wBACpC,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,iCAAiC;YACnC,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,mCAAmC;IACrC,CAAC;IAED,OAAO;QACL,aAAa;QACb,WAAW;QACX,KAAK,EAAE;YACL,WAAW;YACX,aAAa;YACb,UAAU;YACV,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;SACnC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n buildProviderCacheKey,\n PERPS_CONSTANTS,\n PERPS_DISK_CACHE_MARKETS,\n PERPS_DISK_CACHE_USER_DATA,\n PROVIDER_CONFIG,\n} from '../constants/perpsConfig.js';\nimport type {\n AccountState,\n Order,\n PerpsMarketData,\n Position,\n} from '../types/index.js';\n\n/**\n * Multiplier applied to staleGuardMs (preloadGuardMs, currently 30s) to compute\n * the staleness cap for disk-hydrated timestamps. A factor of 10 ensures hydrated\n * data is always TTL-expired so the stream manager overwrites it with live data,\n * while still being recent enough for a useful first paint.\n */\nconst DISK_HYDRATION_STALENESS_FACTOR = 10;\n\n/** Minimal disk cache interface required by persistence utilities. */\nexport type PerpsDiskCache = {\n getItem(key: string): Promise<string | null>;\n getItemSync?(key: string): string | null;\n setItem(key: string, value: string): Promise<void>;\n};\n\n/** Shape of a single market entry persisted to disk cache. */\nexport type DiskCacheMarketEntry = {\n providerNetworkKey: string;\n data: PerpsMarketData[];\n timestamp: number;\n};\n\n/** Shape of a single user-data entry persisted to disk cache. */\nexport type DiskCacheUserEntry = {\n providerNetworkKey: string;\n address: string;\n positions: Position[];\n orders: Order[];\n accountState: AccountState | null;\n timestamp: number;\n hip3ConfigVersion?: number;\n dexes?: string[];\n};\n\n/** Disk payload shape — either a single entry or a multi-provider wrapper. */\nexport type DiskCacheMarketPayload =\n | DiskCacheMarketEntry\n | { entries: DiskCacheMarketEntry[] };\n\nexport type DiskCacheUserPayload =\n | DiskCacheUserEntry\n | { entries: DiskCacheUserEntry[] };\n\n/**\n * Build the disk-cache payload for market data.\n * In aggregated mode, groups markets by provider into separate entries.\n *\n * @param markets - Current market data snapshot.\n * @param activeProvider - The active provider id (may be \"aggregated\").\n * @param isTestnet - Global testnet flag.\n * @param now - Timestamp to stamp entries with.\n * @returns Payload ready for JSON serialization.\n */\nexport function buildMarketDataPayload(\n markets: PerpsMarketData[],\n activeProvider: string,\n isTestnet: boolean,\n now: number,\n): DiskCacheMarketPayload {\n if (activeProvider === 'aggregated') {\n const entriesByKey = new Map<string, DiskCacheMarketEntry>();\n for (const market of markets) {\n const providerId = market.providerId ?? PROVIDER_CONFIG.DefaultProvider;\n const key = buildProviderCacheKey(providerId, isTestnet);\n const existing = entriesByKey.get(key);\n if (existing) {\n existing.data.push(market);\n } else {\n entriesByKey.set(key, {\n providerNetworkKey: key,\n data: [market],\n timestamp: now,\n });\n }\n }\n const entries = Array.from(entriesByKey.values());\n return entries.length === 1 ? entries[0] : { entries };\n }\n return {\n providerNetworkKey: buildProviderCacheKey(\n activeProvider ?? PROVIDER_CONFIG.DefaultProvider,\n isTestnet,\n ),\n data: markets,\n timestamp: now,\n };\n}\n\n/**\n * Build the disk-cache payload for user data (positions, orders, account).\n * In aggregated mode, groups entries by provider.\n *\n * @param positions - Current positions snapshot.\n * @param orders - Current orders snapshot.\n * @param accountState - Current account state snapshot.\n * @param address - EVM account address.\n * @param activeProvider - The active provider id (may be \"aggregated\").\n * @param isTestnet - Global testnet flag.\n * @param now - Timestamp to stamp entries with.\n * @returns Payload ready for JSON serialization.\n */\nexport function buildUserDataPayload(\n positions: Position[],\n orders: Order[],\n accountState: AccountState | null,\n address: string,\n activeProvider: string,\n isTestnet: boolean,\n now: number,\n): DiskCacheUserPayload {\n if (activeProvider === 'aggregated') {\n const entriesByKey = new Map<string, DiskCacheUserEntry>();\n const ensureEntry = (providerId: string): DiskCacheUserEntry => {\n const key = buildProviderCacheKey(providerId, isTestnet);\n let entry = entriesByKey.get(key);\n if (!entry) {\n entry = {\n providerNetworkKey: key,\n address,\n positions: [],\n orders: [],\n accountState: null,\n timestamp: now,\n };\n entriesByKey.set(key, entry);\n }\n return entry;\n };\n\n for (const position of positions) {\n ensureEntry(\n position.providerId ?? PROVIDER_CONFIG.DefaultProvider,\n ).positions.push(position);\n }\n for (const order of orders) {\n ensureEntry(\n order.providerId ?? PROVIDER_CONFIG.DefaultProvider,\n ).orders.push(order);\n }\n if (accountState) {\n ensureEntry(\n accountState.providerId ?? PROVIDER_CONFIG.DefaultProvider,\n ).accountState = accountState;\n }\n\n const entries = Array.from(entriesByKey.values()).filter(\n (entry) =>\n entry.positions.length > 0 ||\n entry.orders.length > 0 ||\n entry.accountState !== null,\n );\n return entries.length === 1 ? entries[0] : { entries };\n }\n return {\n providerNetworkKey: buildProviderCacheKey(\n activeProvider ?? PROVIDER_CONFIG.DefaultProvider,\n isTestnet,\n ),\n address,\n positions,\n orders,\n accountState,\n timestamp: now,\n };\n}\n\n/**\n * Write market entries to disk (best-effort, non-blocking).\n *\n * @param diskCache - Disk cache instance from controller infrastructure.\n * @param entries - Pre-assembled market cache entries to persist.\n */\nexport function persistMarketEntriesToDisk(\n diskCache: PerpsDiskCache,\n entries: DiskCacheMarketEntry[],\n): void {\n if (entries.length === 0) {\n return;\n }\n const payload = entries.length === 1 ? entries[0] : { entries };\n diskCache\n .setItem(PERPS_DISK_CACHE_MARKETS, JSON.stringify(payload))\n .catch(() => {\n // Disk persistence is best-effort and must never block preload.\n });\n}\n\n/**\n * Write user data entries to disk (best-effort, non-blocking).\n *\n * @param diskCache - Disk cache instance from controller infrastructure.\n * @param entries - Pre-assembled user cache entries to persist.\n */\nexport async function persistUserEntriesToDisk(\n diskCache: PerpsDiskCache,\n entries: DiskCacheUserEntry[],\n): Promise<void> {\n if (entries.length === 0) {\n return;\n }\n const payload = entries.length === 1 ? entries[0] : { entries };\n await diskCache.setItem(PERPS_DISK_CACHE_USER_DATA, JSON.stringify(payload));\n}\n\n/** Computed updates returned by hydrateFromDiskSync. */\nexport type HydrateFromDiskResult = {\n marketUpdates: Record<string, { data: PerpsMarketData[]; timestamp: number }>;\n userUpdates: Record<\n string,\n {\n positions: Position[];\n orders: Order[];\n accountState: AccountState | null;\n timestamp: number;\n address: string;\n hip3ConfigVersion?: number;\n dexes?: string[];\n }\n >;\n stats: {\n marketCount: number;\n userPositions: number;\n userOrders: number;\n durationMs: number;\n };\n};\n\n/**\n * Read disk-persisted cache snapshots and compute the state updates to apply.\n * Returns plain objects rather than mutating state directly, so the caller\n * can apply all changes in a single batched this.update() call.\n *\n * All returned timestamps are capped at DISK_HYDRATION_STALENESS_FACTOR * staleGuardMs\n * in the past so the stream manager always overwrites disk data with fresh live data.\n *\n * @param diskCache - Disk cache instance from controller infrastructure.\n * @param currentMarketCache - Current cachedMarketDataByProvider state.\n * @param currentUserCache - Current cachedUserDataByProvider state.\n * @param staleGuardMs - preloadGuardMs constant from the controller.\n * @returns Updates to apply plus stats for debug logging.\n */\nexport function hydrateFromDiskSync(\n diskCache: PerpsDiskCache,\n currentMarketCache: Record<string, { timestamp: number }>,\n currentUserCache: Record<string, { timestamp: number }>,\n staleGuardMs: number,\n): HydrateFromDiskResult {\n const hydrateT0 = Date.now();\n const marketUpdates: HydrateFromDiskResult['marketUpdates'] = {};\n const userUpdates: HydrateFromDiskResult['userUpdates'] = {};\n let marketCount = 0;\n let userPositions = 0;\n let userOrders = 0;\n\n if (!diskCache.getItemSync) {\n return {\n marketUpdates,\n userUpdates,\n stats: { marketCount, userPositions, userOrders, durationMs: 0 },\n };\n }\n\n const staleHydratedTimestamp =\n Date.now() - staleGuardMs * DISK_HYDRATION_STALENESS_FACTOR - 1;\n\n try {\n const marketsRaw = diskCache.getItemSync(PERPS_DISK_CACHE_MARKETS);\n const userRaw = diskCache.getItemSync(PERPS_DISK_CACHE_USER_DATA);\n\n if (marketsRaw) {\n try {\n const parsed = JSON.parse(marketsRaw) as\n | DiskCacheMarketEntry\n | { entries: DiskCacheMarketEntry[] };\n const entries = Array.isArray((parsed as { entries?: unknown }).entries)\n ? (parsed as { entries: DiskCacheMarketEntry[] }).entries\n : [parsed as DiskCacheMarketEntry];\n\n for (const entry of entries) {\n if (entry.providerNetworkKey && Array.isArray(entry.data)) {\n const existing = currentMarketCache[entry.providerNetworkKey];\n if (!existing || existing.timestamp < entry.timestamp) {\n const strippedData = entry.data.map((market) => {\n const structuralMarket = { ...market };\n if (\n structuralMarket.dataSource ===\n 'terminal-global-snapshot-mark'\n ) {\n delete structuralMarket.trend;\n }\n delete structuralMarket.dataSource;\n delete structuralMarket.sourceExpiresAt;\n if (structuralMarket.numericValues) {\n // Price and change are shown as placeholders below, so\n // their stale sort values go too. Volume and OI stay.\n const structuralValues = {\n ...structuralMarket.numericValues,\n };\n delete structuralValues.price;\n delete structuralValues.change24hPercent;\n structuralMarket.numericValues = structuralValues;\n }\n return {\n ...structuralMarket,\n price: PERPS_CONSTANTS.FallbackPriceDisplay,\n change24h: PERPS_CONSTANTS.FallbackDataDisplay,\n change24hPercent: PERPS_CONSTANTS.FallbackPercentageDisplay,\n ...(structuralMarket.change5m !== undefined && {\n change5m: PERPS_CONSTANTS.FallbackDataDisplay,\n }),\n ...(structuralMarket.changePercent5m !== undefined && {\n changePercent5m: PERPS_CONSTANTS.FallbackPercentageDisplay,\n }),\n ...(structuralMarket.change1h !== undefined && {\n change1h: PERPS_CONSTANTS.FallbackDataDisplay,\n }),\n ...(structuralMarket.changePercent1h !== undefined && {\n changePercent1h: PERPS_CONSTANTS.FallbackPercentageDisplay,\n }),\n };\n });\n marketUpdates[entry.providerNetworkKey] = {\n data: strippedData,\n // Disk-hydrated market snapshots are only for structural\n // first paint. Keep them TTL-stale so the stream manager\n // still fetches fresh prices on connect.\n timestamp: Math.min(entry.timestamp, staleHydratedTimestamp),\n };\n marketCount += strippedData.length;\n }\n }\n }\n } catch {\n // Corrupt JSON — silently ignore\n }\n }\n\n if (userRaw) {\n try {\n const parsed = JSON.parse(userRaw) as\n | DiskCacheUserEntry\n | { entries: DiskCacheUserEntry[] };\n const entries = Array.isArray((parsed as { entries?: unknown }).entries)\n ? (parsed as { entries: DiskCacheUserEntry[] }).entries\n : [parsed as DiskCacheUserEntry];\n\n for (const entry of entries) {\n if (entry.providerNetworkKey && entry.address) {\n // Skip address check here — accounts may not be loaded yet at\n // constructor time. getCachedUserDataForActiveProvider validates\n // the address at read time, so stale-account data is never served.\n const existing = currentUserCache[entry.providerNetworkKey];\n if (!existing || existing.timestamp < entry.timestamp) {\n userUpdates[entry.providerNetworkKey] = {\n positions: entry.positions,\n orders: entry.orders,\n accountState: entry.accountState,\n timestamp: Math.min(entry.timestamp, staleHydratedTimestamp),\n address: entry.address,\n hip3ConfigVersion: entry.hip3ConfigVersion,\n dexes: entry.dexes,\n };\n userPositions += entry.positions.length;\n userOrders += entry.orders.length;\n }\n }\n }\n } catch {\n // Corrupt JSON — silently ignore\n }\n }\n } catch {\n // Disk read failure — non-critical\n }\n\n return {\n marketUpdates,\n userUpdates,\n stats: {\n marketCount,\n userPositions,\n userOrders,\n durationMs: Date.now() - hydrateT0,\n },\n };\n}\n"]}
|
|
@@ -414,6 +414,37 @@ export declare const formatFeeBps: (rate: string | number | null | undefined, op
|
|
|
414
414
|
* @example formatLiquidationDistance(100, undefined) => "--%"
|
|
415
415
|
*/
|
|
416
416
|
export declare const formatLiquidationDistance: (entryPrice: string | number | null | undefined, liquidationPrice: string | number | null | undefined, options?: PerpsDisplayFormatOptions) => string;
|
|
417
|
+
/**
|
|
418
|
+
* Options for `formatLeverage`.
|
|
419
|
+
*/
|
|
420
|
+
export type PerpsLeverageFormatOptions = Pick<PerpsDisplayFormatOptions, 'formatters'> & {
|
|
421
|
+
/** Fraction digits always shown (default 0). */
|
|
422
|
+
minimumFractionDigits?: number;
|
|
423
|
+
/**
|
|
424
|
+
* Fraction digits at most shown (default
|
|
425
|
+
* `PERPS_DISPLAY_PRECISION.Leverage`, 2). Raised to `minimumFractionDigits`
|
|
426
|
+
* when lower.
|
|
427
|
+
*/
|
|
428
|
+
maximumFractionDigits?: number;
|
|
429
|
+
};
|
|
430
|
+
/**
|
|
431
|
+
* Formats a leverage multiplier, such as account or position leverage, with
|
|
432
|
+
* an `x` suffix and locale separators.
|
|
433
|
+
*
|
|
434
|
+
* @param value - The leverage multiplier (`0.2` for 0.2x).
|
|
435
|
+
* @param options - `formatters` (default `en-US`), `minimumFractionDigits`
|
|
436
|
+
* (default 0) and `maximumFractionDigits` (default
|
|
437
|
+
* `PERPS_DISPLAY_PRECISION.Leverage`, 2).
|
|
438
|
+
* @returns Format: "X.XXx", or `PERPS_CONSTANTS.FallbackDataDisplay` (`--`)
|
|
439
|
+
* for a missing or negative value.
|
|
440
|
+
* @example formatLeverage(0.2) => "0.2x"
|
|
441
|
+
* @example formatLeverage(0.2, { minimumFractionDigits: 2 }) => "0.20x"
|
|
442
|
+
* @example formatLeverage(1.2149) => "1.21x"
|
|
443
|
+
* @example formatLeverage(2.5, { minimumFractionDigits: 1, maximumFractionDigits: 1 }) => "2.5x"
|
|
444
|
+
* @example formatLeverage(1.2149, { formatters: createFormatters({ locale: 'de' }) }) => "1,21x"
|
|
445
|
+
* @example formatLeverage(undefined) => "--"
|
|
446
|
+
*/
|
|
447
|
+
export declare const formatLeverage: (value: string | number | null | undefined, options?: PerpsLeverageFormatOptions) => string;
|
|
417
448
|
/**
|
|
418
449
|
* The value a compact number stands for, which sets its unit and precision.
|
|
419
450
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perpsFormatters.d.ts","sourceRoot":"","sources":["../../src/utils/perpsFormatters.ts"],"names":[],"mappings":"AAwBA;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,yDAAyD;IACzD,YAAY,CAAC,K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C,KACxC,MA0BF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,4BAA4B,aAC7B,MAAM,GAAG,IAAI,GAAG,SAAS,YAC1B,2BAA2B,KACnC,yBAAyB,GAAG,IA6C9B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;OAGG;IACH,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;CACvC,CAAC;AAqCF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAqDF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,mBAAmB,UACvB,MAAM,YACJ,0BAA0B,KAClC,aAoEF,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC3C,yBAAyB,EACzB,YAAY,CACb,GAAG;IACF,wEAAwE;IACxE,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;CAC3C,CAAC;AASF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,mBAAmB,eAClB,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,YACrC,0BAA0B,KAClC,MAwBF,CAAC"}
|
|
@@ -925,6 +925,32 @@ export const formatLiquidationDistance = (entryPrice, liquidationPrice, options
|
|
|
925
925
|
sign: options.sign ?? 'never',
|
|
926
926
|
});
|
|
927
927
|
};
|
|
928
|
+
/**
|
|
929
|
+
* Formats a leverage multiplier, such as account or position leverage, with
|
|
930
|
+
* an `x` suffix and locale separators.
|
|
931
|
+
*
|
|
932
|
+
* @param value - The leverage multiplier (`0.2` for 0.2x).
|
|
933
|
+
* @param options - `formatters` (default `en-US`), `minimumFractionDigits`
|
|
934
|
+
* (default 0) and `maximumFractionDigits` (default
|
|
935
|
+
* `PERPS_DISPLAY_PRECISION.Leverage`, 2).
|
|
936
|
+
* @returns Format: "X.XXx", or `PERPS_CONSTANTS.FallbackDataDisplay` (`--`)
|
|
937
|
+
* for a missing or negative value.
|
|
938
|
+
* @example formatLeverage(0.2) => "0.2x"
|
|
939
|
+
* @example formatLeverage(0.2, { minimumFractionDigits: 2 }) => "0.20x"
|
|
940
|
+
* @example formatLeverage(1.2149) => "1.21x"
|
|
941
|
+
* @example formatLeverage(2.5, { minimumFractionDigits: 1, maximumFractionDigits: 1 }) => "2.5x"
|
|
942
|
+
* @example formatLeverage(1.2149, { formatters: createFormatters({ locale: 'de' }) }) => "1,21x"
|
|
943
|
+
* @example formatLeverage(undefined) => "--"
|
|
944
|
+
*/
|
|
945
|
+
export const formatLeverage = (value, options = {}) => {
|
|
946
|
+
const { formatters = _fallbackFormatters, minimumFractionDigits = 0, maximumFractionDigits = PERPS_DISPLAY_PRECISION.Leverage, } = options;
|
|
947
|
+
const parsed = _parseDisplayNumber(value);
|
|
948
|
+
if (parsed === undefined || parsed < 0) {
|
|
949
|
+
return PERPS_CONSTANTS.FallbackDataDisplay;
|
|
950
|
+
}
|
|
951
|
+
const maximum = Math.max(minimumFractionDigits, maximumFractionDigits);
|
|
952
|
+
return `${_formatDecimal(formatters, _roundedMagnitude(parsed, maximum), minimumFractionDigits, maximum, true)}x`;
|
|
953
|
+
};
|
|
928
954
|
/** Each magnitude scale is this many times the next smaller one. */
|
|
929
955
|
const SCALE_STEP = 1000;
|
|
930
956
|
/** Magnitude scales of compact values, largest first. */
|