@metamask-previews/perps-controller 26.2.0-preview-2cd622db9 → 26.2.0-preview-53b9b7d11

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.
Files changed (65) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/dist/PerpsController-method-action-types.d.ts +11 -1
  3. package/dist/PerpsController-method-action-types.d.ts.map +1 -1
  4. package/dist/PerpsController-method-action-types.js.map +1 -1
  5. package/dist/PerpsController.d.ts +8 -1
  6. package/dist/PerpsController.d.ts.map +1 -1
  7. package/dist/PerpsController.js +45 -13
  8. package/dist/PerpsController.js.map +1 -1
  9. package/dist/aggregation/SubscriptionMultiplexer.d.ts.map +1 -1
  10. package/dist/aggregation/SubscriptionMultiplexer.js +10 -2
  11. package/dist/aggregation/SubscriptionMultiplexer.js.map +1 -1
  12. package/dist/constants/eventNames.d.ts +2 -0
  13. package/dist/constants/eventNames.d.ts.map +1 -1
  14. package/dist/constants/eventNames.js +3 -0
  15. package/dist/constants/eventNames.js.map +1 -1
  16. package/dist/constants/lighterConfig.d.ts +11 -0
  17. package/dist/constants/lighterConfig.d.ts.map +1 -1
  18. package/dist/constants/lighterConfig.js +11 -0
  19. package/dist/constants/lighterConfig.js.map +1 -1
  20. package/dist/constants/perpsConfig.d.ts +6 -0
  21. package/dist/constants/perpsConfig.d.ts.map +1 -1
  22. package/dist/constants/perpsConfig.js +6 -0
  23. package/dist/constants/perpsConfig.js.map +1 -1
  24. package/dist/errors.d.ts +7 -0
  25. package/dist/errors.d.ts.map +1 -1
  26. package/dist/errors.js +10 -0
  27. package/dist/errors.js.map +1 -1
  28. package/dist/index.d.ts +3 -3
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +1 -1
  31. package/dist/index.js.map +1 -1
  32. package/dist/perpsErrorCodes.d.ts +1 -0
  33. package/dist/perpsErrorCodes.d.ts.map +1 -1
  34. package/dist/perpsErrorCodes.js +1 -0
  35. package/dist/perpsErrorCodes.js.map +1 -1
  36. package/dist/providers/AggregatedPerpsProvider.d.ts +6 -1
  37. package/dist/providers/AggregatedPerpsProvider.d.ts.map +1 -1
  38. package/dist/providers/AggregatedPerpsProvider.js +14 -0
  39. package/dist/providers/AggregatedPerpsProvider.js.map +1 -1
  40. package/dist/providers/HyperLiquidProvider.d.ts.map +1 -1
  41. package/dist/providers/HyperLiquidProvider.js +1 -3
  42. package/dist/providers/HyperLiquidProvider.js.map +1 -1
  43. package/dist/providers/LighterProvider.d.ts +6 -1
  44. package/dist/providers/LighterProvider.d.ts.map +1 -1
  45. package/dist/providers/LighterProvider.js +458 -149
  46. package/dist/providers/LighterProvider.js.map +1 -1
  47. package/dist/services/HyperLiquidClientService.d.ts.map +1 -1
  48. package/dist/services/HyperLiquidClientService.js +13 -1
  49. package/dist/services/HyperLiquidClientService.js.map +1 -1
  50. package/dist/services/HyperLiquidSubscriptionService.d.ts.map +1 -1
  51. package/dist/services/HyperLiquidSubscriptionService.js +1 -0
  52. package/dist/services/HyperLiquidSubscriptionService.js.map +1 -1
  53. package/dist/services/StreamChannelManager.d.ts +12 -2
  54. package/dist/services/StreamChannelManager.d.ts.map +1 -1
  55. package/dist/services/StreamChannelManager.js +18 -0
  56. package/dist/services/StreamChannelManager.js.map +1 -1
  57. package/dist/types/index.d.ts +21 -2
  58. package/dist/types/index.d.ts.map +1 -1
  59. package/dist/types/index.js.map +1 -1
  60. package/dist/utils/perpsClientCopy.d.ts.map +1 -1
  61. package/dist/utils/perpsClientCopy.js +4 -0
  62. package/dist/utils/perpsClientCopy.js.map +1 -1
  63. package/docs/architecture.md +5 -4
  64. package/docs/venues/lighter/api-keys.md +8 -0
  65. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"perpsClientCopy.d.ts","sourceRoot":"","sources":["../../src/utils/perpsClientCopy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,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,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,cAAc,CAI/D;AAED,mEAAmE;AACnE,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAC5C,MAAM,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAuBtC,CAAC"}
@@ -377,6 +377,10 @@ export const PERPS_ERROR_COPY = freezeCopyMap({
377
377
  key: 'perps.errors.ordersFailed',
378
378
  defaultMessage: 'Unable to load orders. Please refresh and try again.',
379
379
  },
380
+ [PERPS_ERROR_CODES.ORDERS_STREAM_PAUSED]: {
381
+ key: 'perps.errors.ordersStreamPaused',
382
+ defaultMessage: 'Your open orders will appear once trading is set up.',
383
+ },
380
384
  [PERPS_ERROR_CODES.LIQUIDATION_PRICE_UNAVAILABLE]: {
381
385
  key: 'perps.errors.liquidationPriceUnavailable',
382
386
  defaultMessage: 'A liquidation price estimate is unavailable for this order.',
@@ -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,gEA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AAE;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
+ {"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;QACx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AAG,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.ORDERS_STREAM_PAUSED]: {\n key: 'perps.errors.ordersStreamPaused',\n defaultMessage: 'Your open orders will appear once trading is set up.',\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"]}
@@ -163,7 +163,7 @@ Code: `src/types/index.ts` `PerpsPlatformDependencies`, `PerpsCacheInvalidator`,
163
163
 
164
164
  ## Messenger surface
165
165
 
166
- - 150 method actions named `PerpsController:<method>`, generated into `PerpsController-method-action-types.ts` from `MESSENGER_EXPOSED_METHODS`, plus `PerpsController:getState`. Handlers are registered on the first `init()`, not in the constructor.
166
+ - Method actions named `PerpsController:<method>` are generated into `PerpsController-method-action-types.ts` from `MESSENGER_EXPOSED_METHODS`, plus `PerpsController:getState`. Handlers are registered on the first `init()`, not in the constructor.
167
167
  - 3 own events: `stateChange`, `stateChanged` and `chaseOrderMaxDistanceReached`.
168
168
  - 16 allowed external actions and 3 allowed external events (`RemoteFeatureFlagController:stateChange`, `AccountsController:selectedAccountChange`, `AccountTreeController:selectedAccountGroupChange`).
169
169
 
@@ -211,11 +211,11 @@ The controller provides the connect and disconnect primitives. The client decide
211
211
  | Event | What the controller does |
212
212
  | ---------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
213
213
  | `init()` | Waits for any disconnect or reinitialization in flight, reuses `#initializationPromise`, runs `#performInitialization`. Up to 3 attempts, with a 1 s then a 2 s wait between them. On final failure it sets `initializationState` to `Failed` and `initializationError`, then resolves without throwing. |
214
- | Data call before init | `getActiveProvider()` throws `CLIENT_REINITIALIZING`, `CLIENT_NOT_INITIALIZED` or `PROVIDER_NOT_AVAILABLE`. `subscribeTo*` joins a pending channel that opens on the next successful init (see Streams). |
214
+ | Data call before init | `getActiveProvider()` throws `CLIENT_REINITIALIZING`, `CLIENT_NOT_INITIALIZED` or `PROVIDER_NOT_AVAILABLE`. `subscribeTo*` returns a no-op unsubscribe when no provider exists. |
215
215
  | `reconnect()` | Delegates to `provider.reconnect()`. HyperLiquid rebuilds its socket through `HyperLiquidClientService` (up to 10 attempts); the SDK transport also retries 5 times. |
216
216
  | `disconnect()` | Serialised. Stops the preload timer and subscriptions, waits for init or reinit in flight, disconnects the active provider, clears it and `effectiveProvider`, retires the standalone provider, resets `isInitialized`. State caches and the feature-flag subscription stay. |
217
217
  | Network change (`toggleTestnet`) or provider change (`switchProvider`) | `#beginReinitialization` sets `isReinitializing`, the state flips, init runs again. Failure rolls back. When preload is running it re-runs for the new key. |
218
- | Account change | No reinit. User preload refreshes, the rewards address re-registers and default-account stream channels move to the new account. |
218
+ | Account change | No reinit. User preload refreshes and the rewards address re-registers. Reconnecting the provider for the new account is the client's call. |
219
219
  | HIP-3 remote flag change | `FeatureFlagConfigurationService` bumps `hip3ConfigVersion` and the preload watcher re-preloads. Providers get the new HIP-3 config on the next `init()`. |
220
220
 
221
221
  `PERPS_CONSTANTS` carries the default timings clients use, among them `ConnectionGracePeriodMs` (20 s), `ConnectionAttemptTimeoutMs` (30 s) and `ConnectRetryDelayMs` (200 ms). The controller does not read them; each client's connection owner does.
@@ -269,7 +269,7 @@ Agreed for every client ([TAT-4656](https://consensyssoftware.atlassian.net/brow
269
269
 
270
270
  - One owner per client decides when to call `init` and `disconnect`. Other components read state; they don't connect.
271
271
  - Read connection timings from one config per client. It defaults to the `PERPS_CONSTANTS` timings (`ConnectionGracePeriodMs` 20 s, `ConnectionAttemptTimeoutMs` 30 s, `ConnectRetryDelayMs` 200 ms), and an override goes in that config, not in a local literal.
272
- - On account change, don't resubscribe streams: default-account channels move to the new account and call `onReset`. The controller refreshes preload but does not reconnect the provider.
272
+ - On account change, reconnect the provider if the new account needs live data; the controller refreshes preload but does not reconnect.
273
273
  - While `initializationState` is not ready, show the loading or failed state; don't call data methods.
274
274
  - Every `subscribeTo*` call keeps its unsubscribe and calls it on teardown.
275
275
 
@@ -286,6 +286,7 @@ Balance display must keep spendable balance, collateral and HyperLiquid account
286
286
  | `crossMarginSummary` | Optional `accountValue`, `maintenanceMargin`, `marginUsed`, `notional` | Summed across DEXs |
287
287
  | `spotCollateral` | Optional spot USDC counted as cross collateral; pass it to `calculateAccountSummary`. Absent while spot state or abstraction mode is unknown, or when the USDC balance is malformed | `'0'` for Standard (`disabled`, `default`); free spot USDC, `max(0, total - hold)`, for Unified and portfolio margin; `'0'` on Lighter |
288
288
  | `subAccountBreakdown` | Optional per-sub-account balances | Main DEX and HIP-3 DEXs |
289
+ | `exchangeAccountStatus` | Optional venue registration status: `{ registered: false }` only when the venue confirms the wallet has no account there, `{ registered: true, accountIndex }` once it does | Absent (HyperLiquid has no registration step) |
289
290
  | `unavailableSubAccounts` | Optional DEX names (`''` for main) whose state is unavailable (read failed, or not yet streamed); the totals exclude them | HIP-3 or main DEXs whose clearinghouse read failed |
290
291
  | `providerId` | Venue, set by the aggregator on a one-venue result. Absent on a combined result | |
291
292
  | `providerStates` | Combined result only: one entry per enabled venue, `available` (with that venue's own `state`), `unavailable` (with optional `error`) or `pending` (stream only, not yet reported) | |
@@ -18,6 +18,14 @@ Key derivation, key storage and Mobile's env variables are in [metamask-mobile/d
18
18
 
19
19
  Code: `src/constants/lighterConfig.ts` `LIGHTER_DEFAULT_API_KEY_INDEX`, `LIGHTER_MIN_TRADING_API_KEY_INDEX`, `LIGHTER_MAX_TRADING_API_KEY_INDEX`; `src/types/index.ts` `LighterCredentials`; `src/providers/LighterProvider.ts` `#ensureAccountIndex`, `#assertStandardAccount`, `#assertAccountOwnership`.
20
20
 
21
+ ## Checking registration after a first deposit
22
+
23
+ Keep `subscribeToAccount` open after a first deposit. A confirmed missing account emits a zero balance with `exchangeAccountStatus: { registered: false }`. Lighter retries discovery after 3 seconds, doubling the interval up to 15 seconds for at most 3 minutes (`LIGHTER_ACCOUNT_DISCOVERY_CONFIG`). Discovery stops when the account is found or the last account-scoped listener leaves. A timeout does not confirm a failed deposit.
24
+
25
+ Once discovered, the existing stream delivers the venue balance and `exchangeAccountStatus: { registered: true, accountIndex }`, even for a zero balance. In a multi-venue aggregate, read the status from the available Lighter entry in `providerStates`. Recovery never registers a trading key. For a one-time registration check without a signature, call `PerpsController:getExchangeAccountStatus` with `{ providerId: 'lighter' }`. Venue and transport errors reject. The index identifies the master account, not a trading-key slot.
26
+
27
+ Code: `src/providers/LighterProvider.ts` `getExchangeAccountStatus`, `#scheduleAccountDiscovery`, `#ensureAccountIndex`; `src/constants/lighterConfig.ts` `LIGHTER_ACCOUNT_DISCOVERY_CONFIG`.
28
+
21
29
  ## Slot selection
22
30
 
23
31
  `#signerCandidates` builds the ordered list of slots to try.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/perps-controller",
3
- "version": "26.2.0-preview-2cd622db9",
3
+ "version": "26.2.0-preview-53b9b7d11",
4
4
  "description": "Controller for perpetual trading functionality in MetaMask",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -99,8 +99,8 @@
99
99
  "@metamask/network-controller": "^38.0.1",
100
100
  "@metamask/profile-sync-controller": "^36.1.2",
101
101
  "@metamask/remote-feature-flag-controller": "^7.0.0",
102
- "@metamask/subscription-controller": "^15.4.0",
103
- "@metamask/transaction-controller": "^74.4.1",
102
+ "@metamask/subscription-controller": "^16.0.0",
103
+ "@metamask/transaction-controller": "^74.5.1",
104
104
  "@typescript/native": "npm:typescript@^7.0.2",
105
105
  "rimraf": "^6.1.4",
106
106
  "tsx": "^4.20.5",