@metamask-previews/perps-controller 11.0.0-preview-9c0f91815 → 11.0.0-preview-e57e5c3dc

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 (82) hide show
  1. package/CHANGELOG.md +0 -49
  2. package/dist/PerpsController.cjs.map +1 -1
  3. package/dist/PerpsController.d.cts +1 -1
  4. package/dist/PerpsController.d.cts.map +1 -1
  5. package/dist/PerpsController.d.mts +1 -1
  6. package/dist/PerpsController.d.mts.map +1 -1
  7. package/dist/PerpsController.mjs.map +1 -1
  8. package/dist/constants/eventNames.cjs +0 -4
  9. package/dist/constants/eventNames.cjs.map +1 -1
  10. package/dist/constants/eventNames.d.cts +0 -3
  11. package/dist/constants/eventNames.d.cts.map +1 -1
  12. package/dist/constants/eventNames.d.mts +0 -3
  13. package/dist/constants/eventNames.d.mts.map +1 -1
  14. package/dist/constants/eventNames.mjs +0 -4
  15. package/dist/constants/eventNames.mjs.map +1 -1
  16. package/dist/constants/perpsConfig.cjs +1 -54
  17. package/dist/constants/perpsConfig.cjs.map +1 -1
  18. package/dist/constants/perpsConfig.d.cts +2 -71
  19. package/dist/constants/perpsConfig.d.cts.map +1 -1
  20. package/dist/constants/perpsConfig.d.mts +2 -71
  21. package/dist/constants/perpsConfig.d.mts.map +1 -1
  22. package/dist/constants/perpsConfig.mjs +0 -53
  23. package/dist/constants/perpsConfig.mjs.map +1 -1
  24. package/dist/index.cjs +3 -12
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +4 -4
  27. package/dist/index.d.cts.map +1 -1
  28. package/dist/index.d.mts +4 -4
  29. package/dist/index.d.mts.map +1 -1
  30. package/dist/index.mjs +2 -2
  31. package/dist/index.mjs.map +1 -1
  32. package/dist/perpsErrorCodes.cjs +0 -20
  33. package/dist/perpsErrorCodes.cjs.map +1 -1
  34. package/dist/perpsErrorCodes.d.cts +0 -19
  35. package/dist/perpsErrorCodes.d.cts.map +1 -1
  36. package/dist/perpsErrorCodes.d.mts +0 -19
  37. package/dist/perpsErrorCodes.d.mts.map +1 -1
  38. package/dist/perpsErrorCodes.mjs +0 -20
  39. package/dist/perpsErrorCodes.mjs.map +1 -1
  40. package/dist/providers/HyperLiquidProvider.cjs +14 -1276
  41. package/dist/providers/HyperLiquidProvider.cjs.map +1 -1
  42. package/dist/providers/HyperLiquidProvider.d.cts.map +1 -1
  43. package/dist/providers/HyperLiquidProvider.d.mts.map +1 -1
  44. package/dist/providers/HyperLiquidProvider.mjs +17 -1279
  45. package/dist/providers/HyperLiquidProvider.mjs.map +1 -1
  46. package/dist/types/index.cjs.map +1 -1
  47. package/dist/types/index.d.cts +2 -40
  48. package/dist/types/index.d.cts.map +1 -1
  49. package/dist/types/index.d.mts +2 -40
  50. package/dist/types/index.d.mts.map +1 -1
  51. package/dist/types/index.mjs.map +1 -1
  52. package/dist/types/perps-types.cjs.map +1 -1
  53. package/dist/types/perps-types.d.cts +2 -33
  54. package/dist/types/perps-types.d.cts.map +1 -1
  55. package/dist/types/perps-types.d.mts +2 -33
  56. package/dist/types/perps-types.d.mts.map +1 -1
  57. package/dist/types/perps-types.mjs.map +1 -1
  58. package/dist/utils/hyperLiquidValidation.cjs +3 -192
  59. package/dist/utils/hyperLiquidValidation.cjs.map +1 -1
  60. package/dist/utils/hyperLiquidValidation.d.cts +3 -30
  61. package/dist/utils/hyperLiquidValidation.d.cts.map +1 -1
  62. package/dist/utils/hyperLiquidValidation.d.mts +3 -30
  63. package/dist/utils/hyperLiquidValidation.d.mts.map +1 -1
  64. package/dist/utils/hyperLiquidValidation.mjs +5 -194
  65. package/dist/utils/hyperLiquidValidation.mjs.map +1 -1
  66. package/dist/utils/orderCalculations.cjs +1 -131
  67. package/dist/utils/orderCalculations.cjs.map +1 -1
  68. package/dist/utils/orderCalculations.d.cts +3 -88
  69. package/dist/utils/orderCalculations.d.cts.map +1 -1
  70. package/dist/utils/orderCalculations.d.mts +3 -88
  71. package/dist/utils/orderCalculations.d.mts.map +1 -1
  72. package/dist/utils/orderCalculations.mjs +2 -128
  73. package/dist/utils/orderCalculations.mjs.map +1 -1
  74. package/dist/utils/orderTypes.cjs +4 -56
  75. package/dist/utils/orderTypes.cjs.map +1 -1
  76. package/dist/utils/orderTypes.d.cts +3 -32
  77. package/dist/utils/orderTypes.d.cts.map +1 -1
  78. package/dist/utils/orderTypes.d.mts +3 -32
  79. package/dist/utils/orderTypes.d.mts.map +1 -1
  80. package/dist/utils/orderTypes.mjs +3 -54
  81. package/dist/utils/orderTypes.mjs.map +1 -1
  82. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"perps-types.d.mts","sourceRoot":"","sources":["../../src/types/perps-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,YAAY,EAAE,qCAAoC;AAE3D;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,OAAO,GACP,aAAa,GACb,YAAY,GACZ,oBAAoB,GACpB,mBAAmB,GACnB,MAAM,GACN,OAAO,GACP,OAAO,CAAC;AAEZ;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,YAAY,GACZ,oBAAoB,GACpB,mBAAmB,CAAC;AAExB;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;AAEtE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;AAExD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,aAAa,CAAC;AAEtD,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,SAAS,G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,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kFAAkF;IAClF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,6CAA6C;IAC7C,8BAA8B,CAAC,EAAE,MAAM,CAAC;CACzC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,uEAAuE;IACvE,GAAG,EAAE,CAAC,eAAe,GAAG,IAAI,CAAC,EAAE,CAAC;IAChC,8EAA8E;IAC9E,SAAS,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAC7B,2DAA2D;IAC3D,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"perps-types.mjs","sourceRoot":"","sources":["../../src/types/perps-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,YAAY,EAAE,qCAAoC","sourcesContent":["/**\n * Test result states for SDK validation\n */\nimport { CandlePeriod } from '../constants/chartConfig.js';\n\n/**\n * Order type enumeration (placement type).\n *\n * - `market` / `limit`: immediate placement.\n * - `stop_*` / `take_profit_*`: trigger placement — the order rests off-book until\n * `OrderParams.triggerPrice` is reached, then executes as a market or limit order\n * according to the suffix.\n * - `twap` / `scale` / `chase`: strategy placement — one request expands into an\n * execution schedule rather than a single resting order. See `StrategyOrderType`.\n *\n * Provider-agnostic by design: no protocol vocabulary (HyperLiquid's `tpsl`,\n * `triggerPx`, `isMarket`) appears in the params model.\n */\nexport type OrderType =\n | 'market'\n | 'limit'\n | 'stop_market'\n | 'stop_limit'\n | 'take_profit_market'\n | 'take_profit_limit'\n | 'twap'\n | 'scale'\n | 'chase';\n\n/**\n * The subset of `OrderType` values that require a trigger price.\n *\n * Spelled out rather than derived with `Exclude`: every order type added to\n * `OrderType` that is neither `market` nor `limit` would otherwise be pulled in\n * here automatically and start demanding a trigger price it has no concept of.\n */\nexport type TriggerOrderType =\n | 'stop_market'\n | 'stop_limit'\n | 'take_profit_market'\n | 'take_profit_limit';\n\n/**\n * The subset of `OrderType` values that describe an execution *strategy* rather\n * than a single order.\n *\n * - `twap`: slice the size over `OrderParams.twapDuration` minutes. Placed and\n * cancelled through the venue's own TWAP endpoints, not the order book.\n * - `scale`: fan out `OrderParams.scaleNumOrders` limit orders evenly between\n * `OrderParams.scaleMinPrice` and `OrderParams.scaleMaxPrice`.\n * - `chase`: rest a post-only order at the near touch and re-price it as the\n * touch moves, until it fills or the chase window closes.\n *\n * A strategy placement returns a *handle* in `OrderResult.orderId` — a venue\n * TWAP id, or a client-generated group/session id — which is what\n * `CancelOrderParams` takes together with the matching `orderType`.\n */\nexport type StrategyOrderType = 'twap' | 'scale' | 'chase';\n\n/**\n * Every `OrderType` that resolves to a single order the exchange can be handed\n * directly — market, limit, and the four trigger placements.\n *\n * Derived with `Exclude` on purpose, the safe direction: it *shrinks* as\n * `StrategyOrderType` grows, so a strategy added later is kept out of the\n * single-order helpers automatically rather than silently falling through them.\n */\nexport type OrdinaryOrderType = Exclude<OrderType, StrategyOrderType>;\n\n/**\n * Whether a triggered order executes as a market or a limit order.\n */\nexport type OrderExecution = 'market' | 'limit';\n\n/**\n * How an attached TP/SL relates to what it protects.\n *\n * - `none`: the order carries no attached TP/SL.\n * - `order`: the TP/SL belongs to this order and is cancelled with it.\n * - `position`: the TP/SL belongs to the resulting position and covers all of it.\n *\n * Provider-agnostic replacement for the HyperLiquid-shaped `OrderParams.grouping`.\n */\nexport type TpslLinkage = 'none' | 'order' | 'position';\n\n/**\n * Which side of the mark price a trigger order fires on.\n * `stop` protects against adverse moves, `take_profit` realizes gains.\n */\nexport type TriggerDirection = 'stop' | 'take_profit';\n\nexport type TestResultStatus =\n | 'idle'\n | 'loading'\n | 'success'\n | 'warning'\n | 'error';\n\n/**\n * Test result data structure\n */\nexport type TestResult = {\n status: TestResultStatus;\n message: string;\n data?: Record<string, unknown>;\n};\n\n/**\n * SDK test types\n */\nexport type SDKTestType = 'connection' | 'asset-listing' | 'websocket';\n\n/**\n * Hyperliquid asset interface (basic structure)\n */\nexport type HyperliquidAsset = {\n name: string;\n [key: string]: unknown;\n};\n\n/**\n * Represents a single candlestick data point\n */\nexport type CandleStick = {\n time: number;\n open: string;\n high: string;\n low: string;\n close: string;\n volume: string;\n};\n\n/**\n * Represents historical candlestick data for a specific symbol and interval\n */\nexport type CandleData = {\n /** Asset identifier (e.g., 'BTC', 'ETH'). Protocol-agnostic terminology for multi-provider support. */\n symbol: string;\n interval: CandlePeriod;\n candles: CandleStick[];\n};\n\n// Configuration types\nexport type {\n HyperLiquidEndpoints,\n AssetNetworkConfig,\n HyperLiquidAssetConfigs,\n BridgeContractConfig,\n HyperLiquidBridgeContracts,\n TransportReconnectConfig,\n TransportKeepAliveConfig,\n HyperLiquidTransportConfig,\n TradingAmountConfig,\n TradingDefaultsConfig,\n FeeRatesConfig,\n HyperLiquidNetwork,\n} from './config.js';\n\n// Token types\nexport type { PerpsToken } from './token.js';\n\n/**\n * Order form state for the Perps order view\n */\nexport type OrderFormState = {\n asset: string;\n direction: 'long' | 'short';\n amount: string;\n leverage: number;\n balancePercent: number;\n takeProfitPrice?: string;\n stopLossPrice?: string;\n limitPrice?: string;\n type: OrderType;\n};\n\nexport type OrderDirection = 'long' | 'short';\n\n/**\n * Options for reconnecting the Perps connection\n */\nexport type ReconnectOptions = {\n /**\n * If true, forces immediate disconnect and cancels all pending operations.\n * Use for user-initiated retry actions.\n * If false (default), waits for pending operations to complete.\n * Use for automatic reconnections like account switches.\n */\n force?: boolean;\n};\n\n/**\n * Extended asset metadata including Growth Mode fields not in SDK types.\n * The HyperLiquid API returns these fields but the SDK doesn't type them.\n *\n * @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees#fee-formula-for-developers\n */\nexport type ExtendedAssetMeta = {\n name: string;\n szDecimals: number;\n maxLeverage: number;\n /** Per-asset Growth Mode status - \"enabled\" means 90% fee reduction */\n growthMode?: 'enabled' | null;\n /** ISO timestamp of last Growth Mode change */\n lastGrowthModeChangeTime?: string;\n};\n\n/**\n * Extended perp DEX info including fee scale fields not in SDK types.\n * The HyperLiquid API returns these fields but the SDK doesn't type them.\n *\n * @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees#fee-formula-for-developers\n */\nexport type ExtendedPerpDex = {\n name: string;\n fullName?: string;\n deployer?: string;\n /** DEX-level fee scale (e.g., \"1.0\" for xyz DEX) - determines HIP-3 multiplier */\n deployerFeeScale?: string;\n /** ISO timestamp of last fee scale change */\n lastDeployerFeeScaleChangeTime?: string;\n};\n\n/**\n * Unified DEX discovery state — single source of truth for all perpDexs() derivatives.\n * Replaces three separate caches (#cachedAllPerpDexs, #cachedValidatedDexs, #perpDexsCache)\n * to eliminate desync bugs by construction.\n */\nexport type DexDiscoveryState = {\n /** perpDexs() API response (raw objects with deployerFeeScale etc.) */\n raw: (ExtendedPerpDex | null)[];\n /** Feature-flag-filtered DEX names (null = main DEX, strings = HIP-3 DEXs) */\n validated: (string | null)[];\n /** When raw was fetched — used for fee-scale TTL checks */\n timestamp: number;\n};\n"]}
1
+ {"version":3,"file":"perps-types.mjs","sourceRoot":"","sources":["../../src/types/perps-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,YAAY,EAAE,qCAAoC","sourcesContent":["/**\n * Test result states for SDK validation\n */\nimport { CandlePeriod } from '../constants/chartConfig.js';\n\n/**\n * Order type enumeration (placement type).\n *\n * - `market` / `limit`: immediate placement.\n * - `stop_*` / `take_profit_*`: trigger placement — the order rests off-book until\n * `OrderParams.triggerPrice` is reached, then executes as a market or limit order\n * according to the suffix.\n *\n * Provider-agnostic by design: no protocol vocabulary (HyperLiquid's `tpsl`,\n * `triggerPx`, `isMarket`) appears in the params model.\n */\nexport type OrderType =\n | 'market'\n | 'limit'\n | 'stop_market'\n | 'stop_limit'\n | 'take_profit_market'\n | 'take_profit_limit';\n\n/**\n * The subset of `OrderType` values that require a trigger price.\n */\nexport type TriggerOrderType = Exclude<OrderType, 'market' | 'limit'>;\n\n/**\n * Whether a triggered order executes as a market or a limit order.\n */\nexport type OrderExecution = 'market' | 'limit';\n\n/**\n * How an attached TP/SL relates to what it protects.\n *\n * - `none`: the order carries no attached TP/SL.\n * - `order`: the TP/SL belongs to this order and is cancelled with it.\n * - `position`: the TP/SL belongs to the resulting position and covers all of it.\n *\n * Provider-agnostic replacement for the HyperLiquid-shaped `OrderParams.grouping`.\n */\nexport type TpslLinkage = 'none' | 'order' | 'position';\n\n/**\n * Which side of the mark price a trigger order fires on.\n * `stop` protects against adverse moves, `take_profit` realizes gains.\n */\nexport type TriggerDirection = 'stop' | 'take_profit';\n\nexport type TestResultStatus =\n | 'idle'\n | 'loading'\n | 'success'\n | 'warning'\n | 'error';\n\n/**\n * Test result data structure\n */\nexport type TestResult = {\n status: TestResultStatus;\n message: string;\n data?: Record<string, unknown>;\n};\n\n/**\n * SDK test types\n */\nexport type SDKTestType = 'connection' | 'asset-listing' | 'websocket';\n\n/**\n * Hyperliquid asset interface (basic structure)\n */\nexport type HyperliquidAsset = {\n name: string;\n [key: string]: unknown;\n};\n\n/**\n * Represents a single candlestick data point\n */\nexport type CandleStick = {\n time: number;\n open: string;\n high: string;\n low: string;\n close: string;\n volume: string;\n};\n\n/**\n * Represents historical candlestick data for a specific symbol and interval\n */\nexport type CandleData = {\n /** Asset identifier (e.g., 'BTC', 'ETH'). Protocol-agnostic terminology for multi-provider support. */\n symbol: string;\n interval: CandlePeriod;\n candles: CandleStick[];\n};\n\n// Configuration types\nexport type {\n HyperLiquidEndpoints,\n AssetNetworkConfig,\n HyperLiquidAssetConfigs,\n BridgeContractConfig,\n HyperLiquidBridgeContracts,\n TransportReconnectConfig,\n TransportKeepAliveConfig,\n HyperLiquidTransportConfig,\n TradingAmountConfig,\n TradingDefaultsConfig,\n FeeRatesConfig,\n HyperLiquidNetwork,\n} from './config.js';\n\n// Token types\nexport type { PerpsToken } from './token.js';\n\n/**\n * Order form state for the Perps order view\n */\nexport type OrderFormState = {\n asset: string;\n direction: 'long' | 'short';\n amount: string;\n leverage: number;\n balancePercent: number;\n takeProfitPrice?: string;\n stopLossPrice?: string;\n limitPrice?: string;\n type: OrderType;\n};\n\nexport type OrderDirection = 'long' | 'short';\n\n/**\n * Options for reconnecting the Perps connection\n */\nexport type ReconnectOptions = {\n /**\n * If true, forces immediate disconnect and cancels all pending operations.\n * Use for user-initiated retry actions.\n * If false (default), waits for pending operations to complete.\n * Use for automatic reconnections like account switches.\n */\n force?: boolean;\n};\n\n/**\n * Extended asset metadata including Growth Mode fields not in SDK types.\n * The HyperLiquid API returns these fields but the SDK doesn't type them.\n *\n * @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees#fee-formula-for-developers\n */\nexport type ExtendedAssetMeta = {\n name: string;\n szDecimals: number;\n maxLeverage: number;\n /** Per-asset Growth Mode status - \"enabled\" means 90% fee reduction */\n growthMode?: 'enabled' | null;\n /** ISO timestamp of last Growth Mode change */\n lastGrowthModeChangeTime?: string;\n};\n\n/**\n * Extended perp DEX info including fee scale fields not in SDK types.\n * The HyperLiquid API returns these fields but the SDK doesn't type them.\n *\n * @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees#fee-formula-for-developers\n */\nexport type ExtendedPerpDex = {\n name: string;\n fullName?: string;\n deployer?: string;\n /** DEX-level fee scale (e.g., \"1.0\" for xyz DEX) - determines HIP-3 multiplier */\n deployerFeeScale?: string;\n /** ISO timestamp of last fee scale change */\n lastDeployerFeeScaleChangeTime?: string;\n};\n\n/**\n * Unified DEX discovery state — single source of truth for all perpDexs() derivatives.\n * Replaces three separate caches (#cachedAllPerpDexs, #cachedValidatedDexs, #perpDexsCache)\n * to eliminate desync bugs by construction.\n */\nexport type DexDiscoveryState = {\n /** perpDexs() API response (raw objects with deployerFeeScale etc.) */\n raw: (ExtendedPerpDex | null)[];\n /** Feature-flag-filtered DEX names (null = main DEX, strings = HIP-3 DEXs) */\n validated: (string | null)[];\n /** When raw was fetched — used for fee-scale TTL checks */\n timestamp: number;\n};\n"]}
@@ -353,9 +353,8 @@ exports.getSupportedPaths = getSupportedPaths;
353
353
  * Based on HyperLiquid contract specifications.
354
354
  *
355
355
  * @param maxLeverage - The maximum leverage for the market
356
- * @param orderType - The order type; every type follows the limit/market
357
- * multiplier of its execution mode, so `stop_limit`, `scale` and `chase` are all
358
- * treated as limit orders and `twap` as a market order
356
+ * @param orderType - The order type; trigger types follow the limit/market
357
+ * multiplier of their execution mode (e.g. `stop_limit` is treated as a limit order)
359
358
  * @returns Maximum order value in USD
360
359
  */
361
360
  function getMaxOrderValue(maxLeverage, orderType) {
@@ -372,11 +371,7 @@ function getMaxOrderValue(maxLeverage, orderType) {
372
371
  else {
373
372
  marketLimit = perpsConfig_js_1.HYPERLIQUID_ORDER_LIMITS.MarketOrderLimits.LowLeverage;
374
373
  }
375
- // The higher cap follows how the order executes, not whose price it uses: a
376
- // scale ladder and a chase rest limit orders on the book, so holding them to
377
- // the tighter market-order cap would bound them by how they were requested
378
- // rather than by what they do.
379
- return (0, orderTypes_js_1.getTriggerExecution)(orderType) === 'limit'
374
+ return (0, orderTypes_js_1.isLimitExecutionOrderType)(orderType)
380
375
  ? marketLimit * perpsConfig_js_1.HYPERLIQUID_ORDER_LIMITS.LimitOrderMultiplier
381
376
  : marketLimit;
382
377
  }
@@ -390,175 +385,6 @@ const TPSL_LINKAGE_GROUPING = {
390
385
  order: 'normalTpsl',
391
386
  position: 'positionTpsl',
392
387
  };
393
- /**
394
- * Which strategy owns each strategy-only field.
395
- *
396
- * Anything a placement does not own is rejected rather than ignored: a `twap`
397
- * carrying `scaleNumOrders` is a caller mistake, and dropping it silently would
398
- * execute something other than what was asked for.
399
- */
400
- const STRATEGY_FIELD_OWNER = {
401
- twapDuration: 'twap',
402
- twapRandomize: 'twap',
403
- scaleMinPrice: 'scale',
404
- scaleMaxPrice: 'scale',
405
- scaleNumOrders: 'scale',
406
- chaseIntervalMs: 'chase',
407
- chaseMaxDurationMs: 'chase',
408
- chaseMaxRepricings: 'chase',
409
- };
410
- /**
411
- * Validate the TWAP-specific parameters of a `twap` placement.
412
- *
413
- * @param params - Strategy fields supplied by the caller.
414
- * @returns Validation result with isValid flag and optional error message.
415
- */
416
- function validateTwapParams(params) {
417
- if (params.twapDuration === undefined) {
418
- return {
419
- isValid: false,
420
- error: perpsErrorCodes_js_1.PERPS_ERROR_CODES.ORDER_TWAP_DURATION_REQUIRED,
421
- };
422
- }
423
- // The venue validates `twap.m` as a safe integer within these bounds before
424
- // the request is signed, so checking it here turns an opaque SDK failure into
425
- // a typed rejection that costs no round trip.
426
- if (!Number.isInteger(params.twapDuration) ||
427
- params.twapDuration < perpsConfig_js_1.HYPERLIQUID_TWAP_LIMITS.MinDurationMinutes ||
428
- params.twapDuration > perpsConfig_js_1.HYPERLIQUID_TWAP_LIMITS.MaxDurationMinutes) {
429
- return {
430
- isValid: false,
431
- error: perpsErrorCodes_js_1.PERPS_ERROR_CODES.ORDER_TWAP_DURATION_INVALID,
432
- };
433
- }
434
- return { isValid: true };
435
- }
436
- /**
437
- * Validate the ladder parameters of a `scale` placement.
438
- *
439
- * @param params - Strategy fields supplied by the caller.
440
- * @returns Validation result with isValid flag and optional error message.
441
- */
442
- function validateScaleParams(params) {
443
- if (params.scaleMinPrice === undefined ||
444
- params.scaleMaxPrice === undefined) {
445
- return {
446
- isValid: false,
447
- error: perpsErrorCodes_js_1.PERPS_ERROR_CODES.ORDER_SCALE_RANGE_REQUIRED,
448
- };
449
- }
450
- const minPrice = parseFloat(params.scaleMinPrice);
451
- const maxPrice = parseFloat(params.scaleMaxPrice);
452
- if (!Number.isFinite(minPrice) ||
453
- !Number.isFinite(maxPrice) ||
454
- minPrice <= 0 ||
455
- maxPrice <= minPrice) {
456
- return {
457
- isValid: false,
458
- error: perpsErrorCodes_js_1.PERPS_ERROR_CODES.ORDER_SCALE_RANGE_INVALID,
459
- };
460
- }
461
- if (params.scaleNumOrders === undefined ||
462
- !Number.isInteger(params.scaleNumOrders) ||
463
- params.scaleNumOrders < orderTypes_js_1.SCALE_ORDER_COUNT.min ||
464
- params.scaleNumOrders > orderTypes_js_1.SCALE_ORDER_COUNT.max) {
465
- return {
466
- isValid: false,
467
- error: perpsErrorCodes_js_1.PERPS_ERROR_CODES.ORDER_SCALE_COUNT_INVALID,
468
- };
469
- }
470
- return { isValid: true };
471
- }
472
- /**
473
- * Validate the polling parameters of a `chase` placement.
474
- *
475
- * @param params - Strategy fields supplied by the caller.
476
- * @returns Validation result with isValid flag and optional error message.
477
- */
478
- function validateChaseParams(params) {
479
- const interval = params.chaseIntervalMs ?? perpsConfig_js_1.CHASE_ORDER_CONFIG.DefaultIntervalMs;
480
- if (!Number.isFinite(interval) ||
481
- interval < perpsConfig_js_1.CHASE_ORDER_CONFIG.MinIntervalMs) {
482
- return {
483
- isValid: false,
484
- error: perpsErrorCodes_js_1.PERPS_ERROR_CODES.ORDER_CHASE_INTERVAL_INVALID,
485
- };
486
- }
487
- const maxDuration = params.chaseMaxDurationMs ?? perpsConfig_js_1.CHASE_ORDER_CONFIG.DefaultMaxDurationMs;
488
- // A window shorter than one poll would place the order and immediately stop
489
- // chasing it — a plain post-only limit order wearing a chase's name.
490
- if (!Number.isFinite(maxDuration) || maxDuration < interval) {
491
- return {
492
- isValid: false,
493
- error: perpsErrorCodes_js_1.PERPS_ERROR_CODES.ORDER_CHASE_DURATION_INVALID,
494
- };
495
- }
496
- const maxRepricings = params.chaseMaxRepricings ?? perpsConfig_js_1.CHASE_ORDER_CONFIG.DefaultMaxRepricings;
497
- if (!Number.isInteger(maxRepricings) || maxRepricings < 1) {
498
- return {
499
- isValid: false,
500
- error: perpsErrorCodes_js_1.PERPS_ERROR_CODES.ORDER_CHASE_DURATION_INVALID,
501
- };
502
- }
503
- return { isValid: true };
504
- }
505
- /**
506
- * Validate strategy placement parameters, and the absence of them.
507
- *
508
- * Runs before every other order rule so a strategy placement is rejected with a
509
- * strategy-shaped reason rather than with the trigger/limit rule its shape
510
- * happens to trip first.
511
- *
512
- * @param params - Order parameters to validate.
513
- * @param params.orderType - The order placement type.
514
- * @returns Validation result with isValid flag and optional error message.
515
- */
516
- function validateStrategyOrderParams(params) {
517
- const { orderType } = params;
518
- const strategy = orderType !== undefined && (0, orderTypes_js_1.isStrategyOrderType)(orderType)
519
- ? orderType
520
- : undefined;
521
- // Every strategy-only field must belong to the placement carrying it. This
522
- // also covers the non-strategy case, where no field has an owner to match.
523
- const foreignField = Object.keys(STRATEGY_FIELD_OWNER).find((field) => params[field] !== undefined && STRATEGY_FIELD_OWNER[field] !== strategy);
524
- if (foreignField) {
525
- return {
526
- isValid: false,
527
- error: perpsErrorCodes_js_1.PERPS_ERROR_CODES.ORDER_STRATEGY_PARAMS_NOT_SUPPORTED,
528
- };
529
- }
530
- if (!strategy) {
531
- return { isValid: true };
532
- }
533
- // A strategy owns its own execution: it derives its own prices, rests its own
534
- // orders, and decides its own time in force. Accepting these fields would
535
- // mean quietly ignoring them.
536
- //
537
- // `clientOrderId` is refused for the same reason and cannot be honoured even
538
- // in principle: the venue's TWAP action carries no client id, a scale ladder
539
- // is many orders and a client id must be unique per order, and a chase
540
- // replaces its order on every re-price. One id cannot name any of them.
541
- if (params.price !== undefined ||
542
- params.triggerPrice !== undefined ||
543
- params.timeInForce !== undefined ||
544
- params.clientOrderId !== undefined ||
545
- params.takeProfitPrice !== undefined ||
546
- params.stopLossPrice !== undefined ||
547
- params.takeProfitSize !== undefined ||
548
- params.stopLossSize !== undefined) {
549
- return {
550
- isValid: false,
551
- error: perpsErrorCodes_js_1.PERPS_ERROR_CODES.ORDER_STRATEGY_FIELD_UNSUPPORTED,
552
- };
553
- }
554
- if (strategy === 'twap') {
555
- return validateTwapParams(params);
556
- }
557
- if (strategy === 'scale') {
558
- return validateScaleParams(params);
559
- }
560
- return validateChaseParams(params);
561
- }
562
388
  /**
563
389
  * Validate order parameters.
564
390
  * Basic validation - checks required fields are present.
@@ -578,15 +404,6 @@ function validateStrategyOrderParams(params) {
578
404
  * @param params.tpslLinkage - How an attached TP/SL is linked
579
405
  * @param params.grouping - Deprecated protocol-shaped spelling of `tpslLinkage`
580
406
  * @param params.timeInForce - Time in force; only a plain limit order can carry one
581
- * @param params.clientOrderId - Client-provided order ID; a strategy placement cannot carry one
582
- * @param params.twapDuration - TWAP window in whole minutes
583
- * @param params.twapRandomize - Whether to randomize the TWAP slice timing
584
- * @param params.scaleMinPrice - Lowest price in a scale ladder
585
- * @param params.scaleMaxPrice - Highest price in a scale ladder
586
- * @param params.scaleNumOrders - How many orders a scale ladder fans out into
587
- * @param params.chaseIntervalMs - How often a chase re-reads the touch
588
- * @param params.chaseMaxDurationMs - How long a chase keeps re-pricing
589
- * @param params.chaseMaxRepricings - Cap on a chase's cancel/replace cycles
590
407
  * @returns Validation result with isValid flag and optional error message
591
408
  */
592
409
  function validateOrderParams(params) {
@@ -597,12 +414,6 @@ function validateOrderParams(params) {
597
414
  };
598
415
  }
599
416
  // Note: Size validation removed - validateOrder handles amount validation using USD as source of truth
600
- // Strategy placements are decided first: their shape trips the limit-price and
601
- // trigger rules below, and the strategy-shaped reason is the useful one.
602
- const strategyValidation = validateStrategyOrderParams(params);
603
- if (!strategyValidation.isValid) {
604
- return strategyValidation;
605
- }
606
417
  const { orderType } = params;
607
418
  const isTrigger = orderType !== undefined && (0, orderTypes_js_1.isTriggerOrderType)(orderType);
608
419
  // Require price for orders that execute as limit orders (limit, stop_limit,
@@ -1 +1 @@
1
- {"version":3,"file":"hyperLiquidValidation.cjs","sourceRoot":"","sources":["../../src/utils/hyperLiquidValidation.ts"],"names":[],"mappings":";;;AAAA,2CAAoD;AAGpD,6EAI2C;AAC3C,iEAIqC;AACrC,+DAA0D;AAM1D,oDAMyB;AASzB;;GAEG;AAEH;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAE/B,KAAc,EAAE,eAAuB;IACvC,OAAO;QACL,GAAG,eAAe;QAClB,OAAO,EAAE,KAAK;QACd,K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K,CAAC,KAAK,EAAE,CAAC;YACjB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,sCAAiB,CAAC,uBAAuB;aACjD,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC;YAC7B,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,sCAAiB,CAAC,uBAAuB;aACjD,CAAC;QACJ,CAAC;QAED,IAAI,SAAS,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,IAAI,GAAG,SAAS,EAAE,CAAC;YACrE,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,sCAAiB,CAAC,uBAAuB;aACjD,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAChC,IAAY,EACZ,aAAkC;IAElC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,sCAAiB,CAAC,kBAAkB;SAC5C,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC;AAZD,gDAYC","sourcesContent":["import { isValidHexAddress } from '@metamask/utils';\nimport type { CaipAssetId, Hex } from '@metamask/utils';\n\nimport {\n HYPERLIQUID_ASSET_CONFIGS,\n getSupportedAssets,\n TRADING_DEFAULTS,\n} from '../constants/hyperLiquidConfig.js';\nimport {\n CHASE_ORDER_CONFIG,\n HYPERLIQUID_ORDER_LIMITS,\n HYPERLIQUID_TWAP_LIMITS,\n} from '../constants/perpsConfig.js';\nimport { PERPS_ERROR_CODES } from '../perpsErrorCodes.js';\nimport type {\n GetSupportedPathsParams,\n PerpsDebugLogger,\n} from '../types/index.js';\nimport type { OrderType, TpslLinkage } from '../types/perps-types.js';\nimport {\n getTriggerExecution,\n isLimitExecutionOrderType,\n isStrategyOrderType,\n isTriggerOrderType,\n SCALE_ORDER_COUNT,\n} from './orderTypes.js';\n\n/**\n * Optional debug logger for validation functions.\n * When provided, enables detailed logging for debugging.\n * When omitted, validation runs silently.\n */\nexport type ValidationDebugLogger = PerpsDebugLogger | undefined;\n\n/**\n * Validation utilities for HyperLiquid operations\n */\n\n/**\n * Create standardized error response.\n *\n * @param error - The error that occurred\n * @param defaultResponse - The default response object to use as template\n * @returns The error response with success=false and error message\n */\nexport function createErrorResult<\n TValue extends { success: boolean; error?: string },\n>(error: unknown, defaultResponse: TValue): TValue {\n return {\n ...defaultResponse,\n success: false,\n error:\n error instanceof Error ? error.message : PERPS_ERROR_CODES.UNKNOWN_ERROR,\n };\n}\n\n/**\n * Validate withdrawal parameters.\n *\n * @param params - Withdrawal parameters to validate\n * @param params.assetId - The CAIP asset ID to withdraw\n * @param params.amount - Amount to withdraw as string\n * @param params.destination - Optional destination hex address\n * @param debugLogger - Optional debug logger for detailed logging\n * @returns Validation result with isValid flag and optional error message\n */\nexport function validateWithdrawalParams(\n params: {\n assetId?: CaipAssetId;\n amount?: string;\n destination?: Hex;\n },\n debugLogger?: ValidationDebugLogger,\n): { isValid: boolean; error?: string } {\n debugLogger?.log('validateWithdrawalParams: Starting validation', {\n params,\n hasAssetId: Boolean(params.assetId),\n hasAmount: Boolean(params.amount),\n hasDestination: Boolean(params.destination),\n });\n\n // Validate required parameters\n if (!params.assetId) {\n debugLogger?.log('validateWithdrawalParams: Missing assetId', {\n error: PERPS_ERROR_CODES.WITHDRAW_ASSET_ID_REQUIRED,\n params,\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.WITHDRAW_ASSET_ID_REQUIRED,\n };\n }\n\n // Validate amount\n if (!params.amount) {\n debugLogger?.log('validateWithdrawalParams: Missing amount', {\n error: PERPS_ERROR_CODES.WITHDRAW_AMOUNT_REQUIRED,\n params,\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.WITHDRAW_AMOUNT_REQUIRED,\n };\n }\n\n const amount = parseFloat(params.amount);\n if (isNaN(amount) || amount <= 0) {\n debugLogger?.log('validateWithdrawalParams: Invalid amount', {\n error: PERPS_ERROR_CODES.WITHDRAW_AMOUNT_POSITIVE,\n amount: params.amount,\n parsedAmount: amount,\n isNaN: isNaN(amount),\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.WITHDRAW_AMOUNT_POSITIVE,\n };\n }\n\n // Validate destination address if provided\n if (params.destination && !isValidHexAddress(params.destination)) {\n debugLogger?.log('validateWithdrawalParams: Invalid destination address', {\n error: PERPS_ERROR_CODES.WITHDRAW_INVALID_DESTINATION,\n destination: params.destination,\n isValidHex: isValidHexAddress(params.destination),\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.WITHDRAW_INVALID_DESTINATION,\n };\n }\n\n debugLogger?.log('validateWithdrawalParams: All validations passed', {\n assetId: params.assetId,\n amount: params.amount,\n destination: params.destination ?? 'will use user wallet',\n });\n\n return { isValid: true };\n}\n\n/**\n * Validate deposit parameters.\n *\n * @param params - Deposit parameters to validate\n * @param params.assetId - The CAIP asset ID to deposit\n * @param params.amount - Amount to deposit as string\n * @param params.isTestnet - Whether this is a testnet deposit\n * @param debugLogger - Optional debug logger for detailed logging\n * @returns Validation result with isValid flag and optional error message\n */\nexport function validateDepositParams(\n params: {\n assetId?: CaipAssetId;\n amount?: string;\n isTestnet?: boolean;\n },\n debugLogger?: ValidationDebugLogger,\n): { isValid: boolean; error?: string } {\n debugLogger?.log('validateDepositParams: Starting validation', {\n params,\n hasAssetId: Boolean(params.assetId),\n hasAmount: Boolean(params.amount),\n isTestnet: params.isTestnet,\n });\n\n // Validate required parameters\n if (!params.assetId) {\n debugLogger?.log('validateDepositParams: Missing assetId', {\n error: PERPS_ERROR_CODES.DEPOSIT_ASSET_ID_REQUIRED,\n params,\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.DEPOSIT_ASSET_ID_REQUIRED,\n };\n }\n\n // Validate amount\n if (!params.amount) {\n debugLogger?.log('validateDepositParams: Missing amount', {\n error: PERPS_ERROR_CODES.DEPOSIT_AMOUNT_REQUIRED,\n params,\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.DEPOSIT_AMOUNT_REQUIRED,\n };\n }\n\n const amount = parseFloat(params.amount);\n if (isNaN(amount) || amount <= 0) {\n debugLogger?.log('validateDepositParams: Invalid amount', {\n error: PERPS_ERROR_CODES.DEPOSIT_AMOUNT_POSITIVE,\n amount: params.amount,\n parsedAmount: amount,\n isNaN: isNaN(amount),\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.DEPOSIT_AMOUNT_POSITIVE,\n };\n }\n\n // Check minimum deposit amount\n const minimumAmount = params.isTestnet\n ? TRADING_DEFAULTS.amount.testnet\n : TRADING_DEFAULTS.amount.mainnet;\n\n debugLogger?.log('validateDepositParams: Checking minimum amount', {\n amount,\n minimumAmount,\n isTestnet: params.isTestnet,\n network: params.isTestnet ? 'testnet' : 'mainnet',\n });\n\n if (amount < minimumAmount) {\n debugLogger?.log('validateDepositParams: Below minimum deposit', {\n error: PERPS_ERROR_CODES.DEPOSIT_MINIMUM_AMOUNT,\n amount,\n minimumAmount,\n difference: minimumAmount - amount,\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.DEPOSIT_MINIMUM_AMOUNT,\n };\n }\n\n debugLogger?.log('validateDepositParams: All validations passed', {\n assetId: params.assetId,\n amount: params.amount,\n parsedAmount: amount,\n minimumAmount,\n isTestnet: params.isTestnet,\n });\n\n return { isValid: true };\n}\n\n/**\n * Validate asset support for withdrawals using AssetRoute arrays.\n *\n * @param assetId - The CAIP asset ID to validate\n * @param supportedRoutes - Array of supported asset routes\n * @param debugLogger - Optional debug logger for detailed logging\n * @returns Validation result with isValid flag and optional error message\n */\nexport function validateAssetSupport(\n assetId: CaipAssetId,\n supportedRoutes: { assetId: CaipAssetId }[],\n debugLogger?: ValidationDebugLogger,\n): { isValid: boolean; error?: string } {\n debugLogger?.log('validateAssetSupport: Checking asset support', {\n assetId,\n supportedRoutesCount: supportedRoutes.length,\n });\n\n const supportedAssetIds = supportedRoutes.map((route) => route.assetId);\n\n // Check if asset is supported\n const isSupported = supportedAssetIds.includes(assetId);\n\n if (!isSupported) {\n // Also check case-insensitive match for contract addresses\n const isSupportedCaseInsensitive = supportedAssetIds.some(\n (supportedId) => supportedId.toLowerCase() === assetId.toLowerCase(),\n );\n\n if (!isSupportedCaseInsensitive) {\n debugLogger?.log('validateAssetSupport: Asset not supported', {\n error: PERPS_ERROR_CODES.WITHDRAW_ASSET_NOT_SUPPORTED,\n assetId,\n supportedAssetIds,\n checkedCaseInsensitive: true,\n });\n\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.WITHDRAW_ASSET_NOT_SUPPORTED,\n };\n }\n\n debugLogger?.log(\n '⚠️ validateAssetSupport: Asset supported with case mismatch',\n {\n providedAssetId: assetId,\n matchedAssetId: supportedAssetIds.find(\n (id) => id.toLowerCase() === assetId.toLowerCase(),\n ),\n },\n );\n }\n\n debugLogger?.log('validateAssetSupport: Asset is supported', {\n assetId,\n });\n\n return { isValid: true };\n}\n\n/**\n * Validate balance against withdrawal amount.\n *\n * @param withdrawAmount - The amount to withdraw\n * @param withdrawableBalance - Max USD that can leave the venue right now\n * @param debugLogger - Optional debug logger for detailed logging\n * @returns Validation result with isValid flag and optional error message\n */\nexport function validateBalance(\n withdrawAmount: number,\n withdrawableBalance: number,\n debugLogger?: ValidationDebugLogger,\n): { isValid: boolean; error?: string } {\n debugLogger?.log('validateBalance: Checking balance sufficiency', {\n withdrawAmount,\n withdrawableBalance,\n difference: withdrawableBalance - withdrawAmount,\n });\n\n if (withdrawAmount > withdrawableBalance) {\n const shortfall = withdrawAmount - withdrawableBalance;\n\n debugLogger?.log('validateBalance: Insufficient balance', {\n error: PERPS_ERROR_CODES.WITHDRAW_INSUFFICIENT_BALANCE,\n withdrawAmount,\n withdrawableBalance,\n shortfall,\n percentageOfAvailable: `${((withdrawAmount / withdrawableBalance) * 100).toFixed(2)}%`,\n });\n\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.WITHDRAW_INSUFFICIENT_BALANCE,\n };\n }\n\n const remainingBalance = withdrawableBalance - withdrawAmount;\n debugLogger?.log('validateBalance: Balance is sufficient', {\n withdrawAmount,\n withdrawableBalance,\n remainingBalance,\n percentageUsed: `${((withdrawAmount / withdrawableBalance) * 100).toFixed(2)}%`,\n });\n\n return { isValid: true };\n}\n\n/**\n * Apply filters to asset paths with comprehensive logging.\n *\n * @param assets - Array of CAIP asset IDs to filter\n * @param params - Filter parameters including chainId, symbol, and assetId\n * @param debugLogger - Optional debug logger for detailed logging\n * @returns Filtered array of CAIP asset IDs\n */\nexport function applyPathFilters(\n assets: CaipAssetId[],\n params?: GetSupportedPathsParams,\n debugLogger?: ValidationDebugLogger,\n): CaipAssetId[] {\n if (!params) {\n debugLogger?.log(\n 'HyperLiquid: applyPathFilters - no params, returning all assets',\n { assets },\n );\n return assets;\n }\n\n let filtered = assets;\n\n debugLogger?.log('HyperLiquid: applyPathFilters - starting filter', {\n initialAssets: assets,\n filterParams: params,\n });\n\n if (params.chainId) {\n const before = filtered;\n filtered = filtered.filter((asset) =>\n asset.startsWith(params.chainId as string),\n );\n debugLogger?.log('HyperLiquid: applyPathFilters - chainId filter', {\n chainId: params.chainId,\n before,\n after: filtered,\n });\n }\n\n // Note: `in` is the idiomatic TypeScript way to narrow a string to\n // `keyof typeof` for indexed access; `hasProperty` types the indexed\n // result as `unknown` and loses the `{ testnet, mainnet }` shape.\n /* eslint-disable-next-line no-restricted-syntax */\n if (params.symbol && params.symbol in HYPERLIQUID_ASSET_CONFIGS) {\n const config =\n HYPERLIQUID_ASSET_CONFIGS[\n params.symbol as keyof typeof HYPERLIQUID_ASSET_CONFIGS\n ];\n const isTestnet = params.isTestnet ?? false;\n const selectedAsset = isTestnet ? config.testnet : config.mainnet;\n const before = filtered;\n filtered = [selectedAsset];\n debugLogger?.log('HyperLiquid: applyPathFilters - symbol filter', {\n symbol: params.symbol,\n isTestnet,\n config,\n selectedAsset,\n before,\n after: filtered,\n });\n }\n\n if (params.assetId) {\n const before = filtered;\n // Use case-insensitive comparison for asset ID matching to handle address case differences\n filtered = filtered.filter(\n (asset) => asset.toLowerCase() === params.assetId?.toLowerCase(),\n );\n debugLogger?.log('HyperLiquid: applyPathFilters - assetId filter', {\n assetId: params.assetId,\n before,\n after: filtered,\n exactMatch: before.includes(params.assetId),\n caseInsensitiveMatch: before.some(\n (asset) => asset.toLowerCase() === params.assetId?.toLowerCase(),\n ),\n });\n }\n\n debugLogger?.log('HyperLiquid: applyPathFilters - final result', {\n initialAssets: assets,\n finalFiltered: filtered,\n filterParams: params,\n });\n\n return filtered;\n}\n\n/**\n * Get supported deposit/withdrawal paths with filtering.\n *\n * @param params - Filter parameters including isTestnet, chainId, symbol\n * @param debugLogger - Optional debug logger for detailed logging\n * @returns Array of supported CAIP asset IDs\n */\nexport function getSupportedPaths(\n params?: GetSupportedPathsParams,\n debugLogger?: ValidationDebugLogger,\n): CaipAssetId[] {\n const isTestnet = params?.isTestnet ?? false;\n const assets = getSupportedAssets(isTestnet);\n const filteredAssets = applyPathFilters(assets, params, debugLogger);\n\n debugLogger?.log('HyperLiquid: getSupportedPaths', {\n isTestnet,\n requestedParams: params,\n allAssets: assets,\n filteredAssets,\n returnType: 'CaipAssetId[]',\n example: filteredAssets[0],\n });\n\n return filteredAssets;\n}\n\n/**\n * Get maximum order value based on leverage and order type.\n * Based on HyperLiquid contract specifications.\n *\n * @param maxLeverage - The maximum leverage for the market\n * @param orderType - The order type; every type follows the limit/market\n * multiplier of its execution mode, so `stop_limit`, `scale` and `chase` are all\n * treated as limit orders and `twap` as a market order\n * @returns Maximum order value in USD\n */\nexport function getMaxOrderValue(\n maxLeverage: number,\n orderType: OrderType,\n): number {\n let marketLimit: number;\n\n if (maxLeverage >= 25) {\n marketLimit = HYPERLIQUID_ORDER_LIMITS.MarketOrderLimits.HighLeverage;\n } else if (maxLeverage >= 20) {\n marketLimit = HYPERLIQUID_ORDER_LIMITS.MarketOrderLimits.MediumHighLeverage;\n } else if (maxLeverage >= 10) {\n marketLimit = HYPERLIQUID_ORDER_LIMITS.MarketOrderLimits.MediumLeverage;\n } else {\n marketLimit = HYPERLIQUID_ORDER_LIMITS.MarketOrderLimits.LowLeverage;\n }\n\n // The higher cap follows how the order executes, not whose price it uses: a\n // scale ladder and a chase rest limit orders on the book, so holding them to\n // the tighter market-order cap would bound them by how they were requested\n // rather than by what they do.\n return getTriggerExecution(orderType) === 'limit'\n ? marketLimit * HYPERLIQUID_ORDER_LIMITS.LimitOrderMultiplier\n : marketLimit;\n}\n\n/**\n * The `grouping` value each provider-agnostic linkage corresponds to, used to\n * detect a caller supplying both spellings with different meanings.\n */\nconst TPSL_LINKAGE_GROUPING: Record<\n TpslLinkage,\n 'na' | 'normalTpsl' | 'positionTpsl'\n> = {\n none: 'na',\n order: 'normalTpsl',\n position: 'positionTpsl',\n};\n\n/**\n * The strategy-placement fields of `OrderParams`, as validation sees them.\n *\n * Named so the provider can forward exactly this group to `validateOrderParams`\n * without the field list drifting between the two call sites.\n */\nexport type StrategyOrderValidationParams = {\n twapDuration?: number;\n twapRandomize?: boolean;\n scaleMinPrice?: string;\n scaleMaxPrice?: string;\n scaleNumOrders?: number;\n chaseIntervalMs?: number;\n chaseMaxDurationMs?: number;\n chaseMaxRepricings?: number;\n};\n\n/**\n * Which strategy owns each strategy-only field.\n *\n * Anything a placement does not own is rejected rather than ignored: a `twap`\n * carrying `scaleNumOrders` is a caller mistake, and dropping it silently would\n * execute something other than what was asked for.\n */\nconst STRATEGY_FIELD_OWNER: Record<\n keyof StrategyOrderValidationParams,\n 'twap' | 'scale' | 'chase'\n> = {\n twapDuration: 'twap',\n twapRandomize: 'twap',\n scaleMinPrice: 'scale',\n scaleMaxPrice: 'scale',\n scaleNumOrders: 'scale',\n chaseIntervalMs: 'chase',\n chaseMaxDurationMs: 'chase',\n chaseMaxRepricings: 'chase',\n};\n\n/**\n * Validate the TWAP-specific parameters of a `twap` placement.\n *\n * @param params - Strategy fields supplied by the caller.\n * @returns Validation result with isValid flag and optional error message.\n */\nfunction validateTwapParams(params: StrategyOrderValidationParams): {\n isValid: boolean;\n error?: string;\n} {\n if (params.twapDuration === undefined) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TWAP_DURATION_REQUIRED,\n };\n }\n\n // The venue validates `twap.m` as a safe integer within these bounds before\n // the request is signed, so checking it here turns an opaque SDK failure into\n // a typed rejection that costs no round trip.\n if (\n !Number.isInteger(params.twapDuration) ||\n params.twapDuration < HYPERLIQUID_TWAP_LIMITS.MinDurationMinutes ||\n params.twapDuration > HYPERLIQUID_TWAP_LIMITS.MaxDurationMinutes\n ) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TWAP_DURATION_INVALID,\n };\n }\n\n return { isValid: true };\n}\n\n/**\n * Validate the ladder parameters of a `scale` placement.\n *\n * @param params - Strategy fields supplied by the caller.\n * @returns Validation result with isValid flag and optional error message.\n */\nfunction validateScaleParams(params: StrategyOrderValidationParams): {\n isValid: boolean;\n error?: string;\n} {\n if (\n params.scaleMinPrice === undefined ||\n params.scaleMaxPrice === undefined\n ) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_SCALE_RANGE_REQUIRED,\n };\n }\n\n const minPrice = parseFloat(params.scaleMinPrice);\n const maxPrice = parseFloat(params.scaleMaxPrice);\n if (\n !Number.isFinite(minPrice) ||\n !Number.isFinite(maxPrice) ||\n minPrice <= 0 ||\n maxPrice <= minPrice\n ) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_SCALE_RANGE_INVALID,\n };\n }\n\n if (\n params.scaleNumOrders === undefined ||\n !Number.isInteger(params.scaleNumOrders) ||\n params.scaleNumOrders < SCALE_ORDER_COUNT.min ||\n params.scaleNumOrders > SCALE_ORDER_COUNT.max\n ) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_SCALE_COUNT_INVALID,\n };\n }\n\n return { isValid: true };\n}\n\n/**\n * Validate the polling parameters of a `chase` placement.\n *\n * @param params - Strategy fields supplied by the caller.\n * @returns Validation result with isValid flag and optional error message.\n */\nfunction validateChaseParams(params: StrategyOrderValidationParams): {\n isValid: boolean;\n error?: string;\n} {\n const interval =\n params.chaseIntervalMs ?? CHASE_ORDER_CONFIG.DefaultIntervalMs;\n if (\n !Number.isFinite(interval) ||\n interval < CHASE_ORDER_CONFIG.MinIntervalMs\n ) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_CHASE_INTERVAL_INVALID,\n };\n }\n\n const maxDuration =\n params.chaseMaxDurationMs ?? CHASE_ORDER_CONFIG.DefaultMaxDurationMs;\n // A window shorter than one poll would place the order and immediately stop\n // chasing it — a plain post-only limit order wearing a chase's name.\n if (!Number.isFinite(maxDuration) || maxDuration < interval) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_CHASE_DURATION_INVALID,\n };\n }\n\n const maxRepricings =\n params.chaseMaxRepricings ?? CHASE_ORDER_CONFIG.DefaultMaxRepricings;\n if (!Number.isInteger(maxRepricings) || maxRepricings < 1) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_CHASE_DURATION_INVALID,\n };\n }\n\n return { isValid: true };\n}\n\n/**\n * Validate strategy placement parameters, and the absence of them.\n *\n * Runs before every other order rule so a strategy placement is rejected with a\n * strategy-shaped reason rather than with the trigger/limit rule its shape\n * happens to trip first.\n *\n * @param params - Order parameters to validate.\n * @param params.orderType - The order placement type.\n * @returns Validation result with isValid flag and optional error message.\n */\nfunction validateStrategyOrderParams(\n params: StrategyOrderValidationParams & {\n orderType?: OrderType;\n price?: string;\n triggerPrice?: string;\n timeInForce?: 'GTC' | 'IOC' | 'ALO';\n clientOrderId?: string;\n takeProfitPrice?: string;\n stopLossPrice?: string;\n takeProfitSize?: string;\n stopLossSize?: string;\n },\n): { isValid: boolean; error?: string } {\n const { orderType } = params;\n const strategy =\n orderType !== undefined && isStrategyOrderType(orderType)\n ? orderType\n : undefined;\n\n // Every strategy-only field must belong to the placement carrying it. This\n // also covers the non-strategy case, where no field has an owner to match.\n const foreignField = (\n Object.keys(STRATEGY_FIELD_OWNER) as (keyof StrategyOrderValidationParams)[]\n ).find(\n (field) =>\n params[field] !== undefined && STRATEGY_FIELD_OWNER[field] !== strategy,\n );\n if (foreignField) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_STRATEGY_PARAMS_NOT_SUPPORTED,\n };\n }\n\n if (!strategy) {\n return { isValid: true };\n }\n\n // A strategy owns its own execution: it derives its own prices, rests its own\n // orders, and decides its own time in force. Accepting these fields would\n // mean quietly ignoring them.\n //\n // `clientOrderId` is refused for the same reason and cannot be honoured even\n // in principle: the venue's TWAP action carries no client id, a scale ladder\n // is many orders and a client id must be unique per order, and a chase\n // replaces its order on every re-price. One id cannot name any of them.\n if (\n params.price !== undefined ||\n params.triggerPrice !== undefined ||\n params.timeInForce !== undefined ||\n params.clientOrderId !== undefined ||\n params.takeProfitPrice !== undefined ||\n params.stopLossPrice !== undefined ||\n params.takeProfitSize !== undefined ||\n params.stopLossSize !== undefined\n ) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_STRATEGY_FIELD_UNSUPPORTED,\n };\n }\n\n if (strategy === 'twap') {\n return validateTwapParams(params);\n }\n if (strategy === 'scale') {\n return validateScaleParams(params);\n }\n return validateChaseParams(params);\n}\n\n/**\n * Validate order parameters.\n * Basic validation - checks required fields are present.\n * Amount validation (size/USD) is handled by validateOrder.\n *\n * @param params - Order parameters to validate\n * @param params.coin - The trading pair coin symbol\n * @param params.size - The order size as string\n * @param params.price - The order price as string\n * @param params.orderType - The order placement type\n * @param params.triggerPrice - Trigger price; required for trigger placement types and\n * rejected for market/limit orders so a stray value can never be silently dropped\n * @param params.takeProfitPrice - Attached take profit price\n * @param params.stopLossPrice - Attached stop loss price\n * @param params.takeProfitSize - Partial take profit size\n * @param params.stopLossSize - Partial stop loss size\n * @param params.tpslLinkage - How an attached TP/SL is linked\n * @param params.grouping - Deprecated protocol-shaped spelling of `tpslLinkage`\n * @param params.timeInForce - Time in force; only a plain limit order can carry one\n * @param params.clientOrderId - Client-provided order ID; a strategy placement cannot carry one\n * @param params.twapDuration - TWAP window in whole minutes\n * @param params.twapRandomize - Whether to randomize the TWAP slice timing\n * @param params.scaleMinPrice - Lowest price in a scale ladder\n * @param params.scaleMaxPrice - Highest price in a scale ladder\n * @param params.scaleNumOrders - How many orders a scale ladder fans out into\n * @param params.chaseIntervalMs - How often a chase re-reads the touch\n * @param params.chaseMaxDurationMs - How long a chase keeps re-pricing\n * @param params.chaseMaxRepricings - Cap on a chase's cancel/replace cycles\n * @returns Validation result with isValid flag and optional error message\n */\nexport function validateOrderParams(\n params: StrategyOrderValidationParams & {\n coin?: string;\n size?: string;\n price?: string;\n orderType?: OrderType;\n triggerPrice?: string;\n takeProfitPrice?: string;\n stopLossPrice?: string;\n takeProfitSize?: string;\n stopLossSize?: string;\n tpslLinkage?: TpslLinkage;\n grouping?: 'na' | 'normalTpsl' | 'positionTpsl';\n timeInForce?: 'GTC' | 'IOC' | 'ALO';\n clientOrderId?: string;\n },\n): { isValid: boolean; error?: string } {\n if (!params.coin) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_COIN_REQUIRED,\n };\n }\n\n // Note: Size validation removed - validateOrder handles amount validation using USD as source of truth\n\n // Strategy placements are decided first: their shape trips the limit-price and\n // trigger rules below, and the strategy-shaped reason is the useful one.\n const strategyValidation = validateStrategyOrderParams(params);\n if (!strategyValidation.isValid) {\n return strategyValidation;\n }\n\n const { orderType } = params;\n const isTrigger = orderType !== undefined && isTriggerOrderType(orderType);\n\n // Require price for orders that execute as limit orders (limit, stop_limit,\n // take_profit_limit)\n if (\n orderType !== undefined &&\n isLimitExecutionOrderType(orderType) &&\n !params.price\n ) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_LIMIT_PRICE_REQUIRED,\n };\n }\n\n if (params.price && parseFloat(params.price) <= 0) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_PRICE_POSITIVE,\n };\n }\n\n if (isTrigger) {\n if (!params.triggerPrice) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_REQUIRED,\n };\n }\n\n const triggerPrice = parseFloat(params.triggerPrice);\n if (isNaN(triggerPrice) || triggerPrice <= 0) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_POSITIVE,\n };\n }\n\n // A trigger placement combined with attached TP/SL children is rejected\n // rather than silently reshaped: the exchange semantics of a triggered\n // parent owning triggered children are not part of this contract.\n // Each field is checked explicitly: a falsy-but-present price (e.g. '') is\n // still an attached TP/SL request and must be rejected, not skipped.\n if (\n params.takeProfitPrice !== undefined ||\n params.stopLossPrice !== undefined\n ) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TRIGGER_TPSL_UNSUPPORTED,\n };\n }\n // Consistent with the attached-TP/SL check above: a falsy-but-present value\n // (e.g. '') is still a request to place a trigger, not an absent field.\n } else if (params.triggerPrice !== undefined) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_NOT_SUPPORTED,\n };\n }\n\n // `tpslLinkage` supersedes `grouping`, but two spellings that disagree are a\n // caller mistake — resolving one silently would hide it.\n if (params.tpslLinkage !== undefined && params.grouping !== undefined) {\n const expectedGrouping = TPSL_LINKAGE_GROUPING[params.tpslLinkage];\n if (expectedGrouping !== params.grouping) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TPSL_LINKAGE_CONFLICT,\n };\n }\n }\n\n const hasAttachedTpsl =\n params.takeProfitPrice !== undefined || params.stopLossPrice !== undefined;\n\n // Every order in a `positionTpsl` batch has to be a trigger order, and no\n // shape of order placement produces one. With an attached TP/SL the batch\n // carries the ordinary parent order the TP/SL protects; without one it is\n // that parent order alone. HyperLiquid rejects both, so the linkage is\n // refused outright — it belongs to `updatePositionTPSL`, applied to the\n // position once the parent has filled.\n const requestsPositionLinkage =\n params.tpslLinkage === 'position' || params.grouping === 'positionTpsl';\n if (requestsPositionLinkage) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TPSL_POSITION_LINKAGE_UNSUPPORTED,\n };\n }\n\n // `na` grouping submits the attached TP/SL as standalone triggers, bound to\n // neither the parent order nor the resulting position. An unfilled parent\n // then leaves them behind as orphan reduce-only triggers that fire against\n // whatever position happens to exist. An attached TP/SL needs a linkage that\n // links it, so the combination is a caller mistake rather than a mode.\n const requestsNoLinkage =\n params.tpslLinkage === 'none' || params.grouping === 'na';\n if (requestsNoLinkage && hasAttachedTpsl) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TPSL_LINKAGE_REQUIRED,\n };\n }\n\n // Only a plain limit order rests on the book long enough for a time in force to\n // mean anything: a market order fills immediately and a trigger order's\n // execution is decided when it fires. Rejected here, at step 1 of placement, so\n // it cannot fire after leverage changes or a HIP-3 margin transfer.\n if (params.timeInForce !== undefined && orderType !== 'limit') {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TIME_IN_FORCE_NOT_SUPPORTED,\n };\n }\n\n const partialTpslValidation = validatePartialTpslSizes(params);\n if (!partialTpslValidation.isValid) {\n return partialTpslValidation;\n }\n\n return { isValid: true };\n}\n\n/**\n * Validate quantity-scoped (partial) TP/SL sizes against the parent order.\n *\n * @param params - Order parameters carrying the TP/SL prices and sizes\n * @param params.size - Parent order size\n * @param params.takeProfitPrice - Attached take profit price\n * @param params.stopLossPrice - Attached stop loss price\n * @param params.takeProfitSize - Partial take profit size\n * @param params.stopLossSize - Partial stop loss size\n * @returns Validation result with isValid flag and optional error message\n */\nfunction validatePartialTpslSizes(params: {\n size?: string;\n takeProfitPrice?: string;\n stopLossPrice?: string;\n takeProfitSize?: string;\n stopLossSize?: string;\n}): { isValid: boolean; error?: string } {\n const orderSize = params.size ? Math.abs(parseFloat(params.size)) : undefined;\n\n const entries: { size?: string; price?: string }[] = [\n { size: params.takeProfitSize, price: params.takeProfitPrice },\n { size: params.stopLossSize, price: params.stopLossPrice },\n ];\n\n for (const entry of entries) {\n if (entry.size === undefined) {\n continue;\n }\n\n // A size without its price would silently place nothing.\n if (!entry.price) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TPSL_SIZE_INVALID,\n };\n }\n\n const size = parseFloat(entry.size);\n if (isNaN(size) || size <= 0) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TPSL_SIZE_INVALID,\n };\n }\n\n if (orderSize !== undefined && !isNaN(orderSize) && size > orderSize) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TPSL_SIZE_INVALID,\n };\n }\n }\n\n return { isValid: true };\n}\n\n/**\n * Validate coin exists in asset mapping.\n *\n * @param coin - The coin symbol to validate\n * @param coinToAssetId - Map of coin symbols to asset IDs\n * @returns Validation result with isValid flag and optional error message\n */\nexport function validateCoinExists(\n coin: string,\n coinToAssetId: Map<string, number>,\n): { isValid: boolean; error?: string } {\n if (!coinToAssetId.has(coin)) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_UNKNOWN_COIN,\n };\n }\n\n return { isValid: true };\n}\n"]}
1
+ {"version":3,"file":"hyperLiquidValidation.cjs","sourceRoot":"","sources":["../../src/utils/hyperLiquidValidation.ts"],"names":[],"mappings":";;;AAAA,2CAAoD;AAGpD,6EAI2C;AAC3C,iEAAuE;AACvE,+DAA0D;AAM1D,oDAAgF;AAShF;;GAEG;AAEH;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAE/B,KAAc,EAAE,eAAuB;IACvC,OAAO;QACL,GAAG,eAAe;QAClB,OA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AAkB;SAC5C,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC;AAZD,gDAYC","sourcesContent":["import { isValidHexAddress } from '@metamask/utils';\nimport type { CaipAssetId, Hex } from '@metamask/utils';\n\nimport {\n HYPERLIQUID_ASSET_CONFIGS,\n getSupportedAssets,\n TRADING_DEFAULTS,\n} from '../constants/hyperLiquidConfig.js';\nimport { HYPERLIQUID_ORDER_LIMITS } from '../constants/perpsConfig.js';\nimport { PERPS_ERROR_CODES } from '../perpsErrorCodes.js';\nimport type {\n GetSupportedPathsParams,\n PerpsDebugLogger,\n} from '../types/index.js';\nimport type { OrderType, TpslLinkage } from '../types/perps-types.js';\nimport { isLimitExecutionOrderType, isTriggerOrderType } from './orderTypes.js';\n\n/**\n * Optional debug logger for validation functions.\n * When provided, enables detailed logging for debugging.\n * When omitted, validation runs silently.\n */\nexport type ValidationDebugLogger = PerpsDebugLogger | undefined;\n\n/**\n * Validation utilities for HyperLiquid operations\n */\n\n/**\n * Create standardized error response.\n *\n * @param error - The error that occurred\n * @param defaultResponse - The default response object to use as template\n * @returns The error response with success=false and error message\n */\nexport function createErrorResult<\n TValue extends { success: boolean; error?: string },\n>(error: unknown, defaultResponse: TValue): TValue {\n return {\n ...defaultResponse,\n success: false,\n error:\n error instanceof Error ? error.message : PERPS_ERROR_CODES.UNKNOWN_ERROR,\n };\n}\n\n/**\n * Validate withdrawal parameters.\n *\n * @param params - Withdrawal parameters to validate\n * @param params.assetId - The CAIP asset ID to withdraw\n * @param params.amount - Amount to withdraw as string\n * @param params.destination - Optional destination hex address\n * @param debugLogger - Optional debug logger for detailed logging\n * @returns Validation result with isValid flag and optional error message\n */\nexport function validateWithdrawalParams(\n params: {\n assetId?: CaipAssetId;\n amount?: string;\n destination?: Hex;\n },\n debugLogger?: ValidationDebugLogger,\n): { isValid: boolean; error?: string } {\n debugLogger?.log('validateWithdrawalParams: Starting validation', {\n params,\n hasAssetId: Boolean(params.assetId),\n hasAmount: Boolean(params.amount),\n hasDestination: Boolean(params.destination),\n });\n\n // Validate required parameters\n if (!params.assetId) {\n debugLogger?.log('validateWithdrawalParams: Missing assetId', {\n error: PERPS_ERROR_CODES.WITHDRAW_ASSET_ID_REQUIRED,\n params,\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.WITHDRAW_ASSET_ID_REQUIRED,\n };\n }\n\n // Validate amount\n if (!params.amount) {\n debugLogger?.log('validateWithdrawalParams: Missing amount', {\n error: PERPS_ERROR_CODES.WITHDRAW_AMOUNT_REQUIRED,\n params,\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.WITHDRAW_AMOUNT_REQUIRED,\n };\n }\n\n const amount = parseFloat(params.amount);\n if (isNaN(amount) || amount <= 0) {\n debugLogger?.log('validateWithdrawalParams: Invalid amount', {\n error: PERPS_ERROR_CODES.WITHDRAW_AMOUNT_POSITIVE,\n amount: params.amount,\n parsedAmount: amount,\n isNaN: isNaN(amount),\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.WITHDRAW_AMOUNT_POSITIVE,\n };\n }\n\n // Validate destination address if provided\n if (params.destination && !isValidHexAddress(params.destination)) {\n debugLogger?.log('validateWithdrawalParams: Invalid destination address', {\n error: PERPS_ERROR_CODES.WITHDRAW_INVALID_DESTINATION,\n destination: params.destination,\n isValidHex: isValidHexAddress(params.destination),\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.WITHDRAW_INVALID_DESTINATION,\n };\n }\n\n debugLogger?.log('validateWithdrawalParams: All validations passed', {\n assetId: params.assetId,\n amount: params.amount,\n destination: params.destination ?? 'will use user wallet',\n });\n\n return { isValid: true };\n}\n\n/**\n * Validate deposit parameters.\n *\n * @param params - Deposit parameters to validate\n * @param params.assetId - The CAIP asset ID to deposit\n * @param params.amount - Amount to deposit as string\n * @param params.isTestnet - Whether this is a testnet deposit\n * @param debugLogger - Optional debug logger for detailed logging\n * @returns Validation result with isValid flag and optional error message\n */\nexport function validateDepositParams(\n params: {\n assetId?: CaipAssetId;\n amount?: string;\n isTestnet?: boolean;\n },\n debugLogger?: ValidationDebugLogger,\n): { isValid: boolean; error?: string } {\n debugLogger?.log('validateDepositParams: Starting validation', {\n params,\n hasAssetId: Boolean(params.assetId),\n hasAmount: Boolean(params.amount),\n isTestnet: params.isTestnet,\n });\n\n // Validate required parameters\n if (!params.assetId) {\n debugLogger?.log('validateDepositParams: Missing assetId', {\n error: PERPS_ERROR_CODES.DEPOSIT_ASSET_ID_REQUIRED,\n params,\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.DEPOSIT_ASSET_ID_REQUIRED,\n };\n }\n\n // Validate amount\n if (!params.amount) {\n debugLogger?.log('validateDepositParams: Missing amount', {\n error: PERPS_ERROR_CODES.DEPOSIT_AMOUNT_REQUIRED,\n params,\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.DEPOSIT_AMOUNT_REQUIRED,\n };\n }\n\n const amount = parseFloat(params.amount);\n if (isNaN(amount) || amount <= 0) {\n debugLogger?.log('validateDepositParams: Invalid amount', {\n error: PERPS_ERROR_CODES.DEPOSIT_AMOUNT_POSITIVE,\n amount: params.amount,\n parsedAmount: amount,\n isNaN: isNaN(amount),\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.DEPOSIT_AMOUNT_POSITIVE,\n };\n }\n\n // Check minimum deposit amount\n const minimumAmount = params.isTestnet\n ? TRADING_DEFAULTS.amount.testnet\n : TRADING_DEFAULTS.amount.mainnet;\n\n debugLogger?.log('validateDepositParams: Checking minimum amount', {\n amount,\n minimumAmount,\n isTestnet: params.isTestnet,\n network: params.isTestnet ? 'testnet' : 'mainnet',\n });\n\n if (amount < minimumAmount) {\n debugLogger?.log('validateDepositParams: Below minimum deposit', {\n error: PERPS_ERROR_CODES.DEPOSIT_MINIMUM_AMOUNT,\n amount,\n minimumAmount,\n difference: minimumAmount - amount,\n });\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.DEPOSIT_MINIMUM_AMOUNT,\n };\n }\n\n debugLogger?.log('validateDepositParams: All validations passed', {\n assetId: params.assetId,\n amount: params.amount,\n parsedAmount: amount,\n minimumAmount,\n isTestnet: params.isTestnet,\n });\n\n return { isValid: true };\n}\n\n/**\n * Validate asset support for withdrawals using AssetRoute arrays.\n *\n * @param assetId - The CAIP asset ID to validate\n * @param supportedRoutes - Array of supported asset routes\n * @param debugLogger - Optional debug logger for detailed logging\n * @returns Validation result with isValid flag and optional error message\n */\nexport function validateAssetSupport(\n assetId: CaipAssetId,\n supportedRoutes: { assetId: CaipAssetId }[],\n debugLogger?: ValidationDebugLogger,\n): { isValid: boolean; error?: string } {\n debugLogger?.log('validateAssetSupport: Checking asset support', {\n assetId,\n supportedRoutesCount: supportedRoutes.length,\n });\n\n const supportedAssetIds = supportedRoutes.map((route) => route.assetId);\n\n // Check if asset is supported\n const isSupported = supportedAssetIds.includes(assetId);\n\n if (!isSupported) {\n // Also check case-insensitive match for contract addresses\n const isSupportedCaseInsensitive = supportedAssetIds.some(\n (supportedId) => supportedId.toLowerCase() === assetId.toLowerCase(),\n );\n\n if (!isSupportedCaseInsensitive) {\n debugLogger?.log('validateAssetSupport: Asset not supported', {\n error: PERPS_ERROR_CODES.WITHDRAW_ASSET_NOT_SUPPORTED,\n assetId,\n supportedAssetIds,\n checkedCaseInsensitive: true,\n });\n\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.WITHDRAW_ASSET_NOT_SUPPORTED,\n };\n }\n\n debugLogger?.log(\n '⚠️ validateAssetSupport: Asset supported with case mismatch',\n {\n providedAssetId: assetId,\n matchedAssetId: supportedAssetIds.find(\n (id) => id.toLowerCase() === assetId.toLowerCase(),\n ),\n },\n );\n }\n\n debugLogger?.log('validateAssetSupport: Asset is supported', {\n assetId,\n });\n\n return { isValid: true };\n}\n\n/**\n * Validate balance against withdrawal amount.\n *\n * @param withdrawAmount - The amount to withdraw\n * @param withdrawableBalance - Max USD that can leave the venue right now\n * @param debugLogger - Optional debug logger for detailed logging\n * @returns Validation result with isValid flag and optional error message\n */\nexport function validateBalance(\n withdrawAmount: number,\n withdrawableBalance: number,\n debugLogger?: ValidationDebugLogger,\n): { isValid: boolean; error?: string } {\n debugLogger?.log('validateBalance: Checking balance sufficiency', {\n withdrawAmount,\n withdrawableBalance,\n difference: withdrawableBalance - withdrawAmount,\n });\n\n if (withdrawAmount > withdrawableBalance) {\n const shortfall = withdrawAmount - withdrawableBalance;\n\n debugLogger?.log('validateBalance: Insufficient balance', {\n error: PERPS_ERROR_CODES.WITHDRAW_INSUFFICIENT_BALANCE,\n withdrawAmount,\n withdrawableBalance,\n shortfall,\n percentageOfAvailable: `${((withdrawAmount / withdrawableBalance) * 100).toFixed(2)}%`,\n });\n\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.WITHDRAW_INSUFFICIENT_BALANCE,\n };\n }\n\n const remainingBalance = withdrawableBalance - withdrawAmount;\n debugLogger?.log('validateBalance: Balance is sufficient', {\n withdrawAmount,\n withdrawableBalance,\n remainingBalance,\n percentageUsed: `${((withdrawAmount / withdrawableBalance) * 100).toFixed(2)}%`,\n });\n\n return { isValid: true };\n}\n\n/**\n * Apply filters to asset paths with comprehensive logging.\n *\n * @param assets - Array of CAIP asset IDs to filter\n * @param params - Filter parameters including chainId, symbol, and assetId\n * @param debugLogger - Optional debug logger for detailed logging\n * @returns Filtered array of CAIP asset IDs\n */\nexport function applyPathFilters(\n assets: CaipAssetId[],\n params?: GetSupportedPathsParams,\n debugLogger?: ValidationDebugLogger,\n): CaipAssetId[] {\n if (!params) {\n debugLogger?.log(\n 'HyperLiquid: applyPathFilters - no params, returning all assets',\n { assets },\n );\n return assets;\n }\n\n let filtered = assets;\n\n debugLogger?.log('HyperLiquid: applyPathFilters - starting filter', {\n initialAssets: assets,\n filterParams: params,\n });\n\n if (params.chainId) {\n const before = filtered;\n filtered = filtered.filter((asset) =>\n asset.startsWith(params.chainId as string),\n );\n debugLogger?.log('HyperLiquid: applyPathFilters - chainId filter', {\n chainId: params.chainId,\n before,\n after: filtered,\n });\n }\n\n // Note: `in` is the idiomatic TypeScript way to narrow a string to\n // `keyof typeof` for indexed access; `hasProperty` types the indexed\n // result as `unknown` and loses the `{ testnet, mainnet }` shape.\n /* eslint-disable-next-line no-restricted-syntax */\n if (params.symbol && params.symbol in HYPERLIQUID_ASSET_CONFIGS) {\n const config =\n HYPERLIQUID_ASSET_CONFIGS[\n params.symbol as keyof typeof HYPERLIQUID_ASSET_CONFIGS\n ];\n const isTestnet = params.isTestnet ?? false;\n const selectedAsset = isTestnet ? config.testnet : config.mainnet;\n const before = filtered;\n filtered = [selectedAsset];\n debugLogger?.log('HyperLiquid: applyPathFilters - symbol filter', {\n symbol: params.symbol,\n isTestnet,\n config,\n selectedAsset,\n before,\n after: filtered,\n });\n }\n\n if (params.assetId) {\n const before = filtered;\n // Use case-insensitive comparison for asset ID matching to handle address case differences\n filtered = filtered.filter(\n (asset) => asset.toLowerCase() === params.assetId?.toLowerCase(),\n );\n debugLogger?.log('HyperLiquid: applyPathFilters - assetId filter', {\n assetId: params.assetId,\n before,\n after: filtered,\n exactMatch: before.includes(params.assetId),\n caseInsensitiveMatch: before.some(\n (asset) => asset.toLowerCase() === params.assetId?.toLowerCase(),\n ),\n });\n }\n\n debugLogger?.log('HyperLiquid: applyPathFilters - final result', {\n initialAssets: assets,\n finalFiltered: filtered,\n filterParams: params,\n });\n\n return filtered;\n}\n\n/**\n * Get supported deposit/withdrawal paths with filtering.\n *\n * @param params - Filter parameters including isTestnet, chainId, symbol\n * @param debugLogger - Optional debug logger for detailed logging\n * @returns Array of supported CAIP asset IDs\n */\nexport function getSupportedPaths(\n params?: GetSupportedPathsParams,\n debugLogger?: ValidationDebugLogger,\n): CaipAssetId[] {\n const isTestnet = params?.isTestnet ?? false;\n const assets = getSupportedAssets(isTestnet);\n const filteredAssets = applyPathFilters(assets, params, debugLogger);\n\n debugLogger?.log('HyperLiquid: getSupportedPaths', {\n isTestnet,\n requestedParams: params,\n allAssets: assets,\n filteredAssets,\n returnType: 'CaipAssetId[]',\n example: filteredAssets[0],\n });\n\n return filteredAssets;\n}\n\n/**\n * Get maximum order value based on leverage and order type.\n * Based on HyperLiquid contract specifications.\n *\n * @param maxLeverage - The maximum leverage for the market\n * @param orderType - The order type; trigger types follow the limit/market\n * multiplier of their execution mode (e.g. `stop_limit` is treated as a limit order)\n * @returns Maximum order value in USD\n */\nexport function getMaxOrderValue(\n maxLeverage: number,\n orderType: OrderType,\n): number {\n let marketLimit: number;\n\n if (maxLeverage >= 25) {\n marketLimit = HYPERLIQUID_ORDER_LIMITS.MarketOrderLimits.HighLeverage;\n } else if (maxLeverage >= 20) {\n marketLimit = HYPERLIQUID_ORDER_LIMITS.MarketOrderLimits.MediumHighLeverage;\n } else if (maxLeverage >= 10) {\n marketLimit = HYPERLIQUID_ORDER_LIMITS.MarketOrderLimits.MediumLeverage;\n } else {\n marketLimit = HYPERLIQUID_ORDER_LIMITS.MarketOrderLimits.LowLeverage;\n }\n\n return isLimitExecutionOrderType(orderType)\n ? marketLimit * HYPERLIQUID_ORDER_LIMITS.LimitOrderMultiplier\n : marketLimit;\n}\n\n/**\n * The `grouping` value each provider-agnostic linkage corresponds to, used to\n * detect a caller supplying both spellings with different meanings.\n */\nconst TPSL_LINKAGE_GROUPING: Record<\n TpslLinkage,\n 'na' | 'normalTpsl' | 'positionTpsl'\n> = {\n none: 'na',\n order: 'normalTpsl',\n position: 'positionTpsl',\n};\n\n/**\n * Validate order parameters.\n * Basic validation - checks required fields are present.\n * Amount validation (size/USD) is handled by validateOrder.\n *\n * @param params - Order parameters to validate\n * @param params.coin - The trading pair coin symbol\n * @param params.size - The order size as string\n * @param params.price - The order price as string\n * @param params.orderType - The order placement type\n * @param params.triggerPrice - Trigger price; required for trigger placement types and\n * rejected for market/limit orders so a stray value can never be silently dropped\n * @param params.takeProfitPrice - Attached take profit price\n * @param params.stopLossPrice - Attached stop loss price\n * @param params.takeProfitSize - Partial take profit size\n * @param params.stopLossSize - Partial stop loss size\n * @param params.tpslLinkage - How an attached TP/SL is linked\n * @param params.grouping - Deprecated protocol-shaped spelling of `tpslLinkage`\n * @param params.timeInForce - Time in force; only a plain limit order can carry one\n * @returns Validation result with isValid flag and optional error message\n */\nexport function validateOrderParams(params: {\n coin?: string;\n size?: string;\n price?: string;\n orderType?: OrderType;\n triggerPrice?: string;\n takeProfitPrice?: string;\n stopLossPrice?: string;\n takeProfitSize?: string;\n stopLossSize?: string;\n tpslLinkage?: TpslLinkage;\n grouping?: 'na' | 'normalTpsl' | 'positionTpsl';\n timeInForce?: 'GTC' | 'IOC' | 'ALO';\n}): { isValid: boolean; error?: string } {\n if (!params.coin) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_COIN_REQUIRED,\n };\n }\n\n // Note: Size validation removed - validateOrder handles amount validation using USD as source of truth\n\n const { orderType } = params;\n const isTrigger = orderType !== undefined && isTriggerOrderType(orderType);\n\n // Require price for orders that execute as limit orders (limit, stop_limit,\n // take_profit_limit)\n if (\n orderType !== undefined &&\n isLimitExecutionOrderType(orderType) &&\n !params.price\n ) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_LIMIT_PRICE_REQUIRED,\n };\n }\n\n if (params.price && parseFloat(params.price) <= 0) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_PRICE_POSITIVE,\n };\n }\n\n if (isTrigger) {\n if (!params.triggerPrice) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_REQUIRED,\n };\n }\n\n const triggerPrice = parseFloat(params.triggerPrice);\n if (isNaN(triggerPrice) || triggerPrice <= 0) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_POSITIVE,\n };\n }\n\n // A trigger placement combined with attached TP/SL children is rejected\n // rather than silently reshaped: the exchange semantics of a triggered\n // parent owning triggered children are not part of this contract.\n // Each field is checked explicitly: a falsy-but-present price (e.g. '') is\n // still an attached TP/SL request and must be rejected, not skipped.\n if (\n params.takeProfitPrice !== undefined ||\n params.stopLossPrice !== undefined\n ) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TRIGGER_TPSL_UNSUPPORTED,\n };\n }\n // Consistent with the attached-TP/SL check above: a falsy-but-present value\n // (e.g. '') is still a request to place a trigger, not an absent field.\n } else if (params.triggerPrice !== undefined) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TRIGGER_PRICE_NOT_SUPPORTED,\n };\n }\n\n // `tpslLinkage` supersedes `grouping`, but two spellings that disagree are a\n // caller mistake — resolving one silently would hide it.\n if (params.tpslLinkage !== undefined && params.grouping !== undefined) {\n const expectedGrouping = TPSL_LINKAGE_GROUPING[params.tpslLinkage];\n if (expectedGrouping !== params.grouping) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TPSL_LINKAGE_CONFLICT,\n };\n }\n }\n\n const hasAttachedTpsl =\n params.takeProfitPrice !== undefined || params.stopLossPrice !== undefined;\n\n // Every order in a `positionTpsl` batch has to be a trigger order, and no\n // shape of order placement produces one. With an attached TP/SL the batch\n // carries the ordinary parent order the TP/SL protects; without one it is\n // that parent order alone. HyperLiquid rejects both, so the linkage is\n // refused outright — it belongs to `updatePositionTPSL`, applied to the\n // position once the parent has filled.\n const requestsPositionLinkage =\n params.tpslLinkage === 'position' || params.grouping === 'positionTpsl';\n if (requestsPositionLinkage) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TPSL_POSITION_LINKAGE_UNSUPPORTED,\n };\n }\n\n // `na` grouping submits the attached TP/SL as standalone triggers, bound to\n // neither the parent order nor the resulting position. An unfilled parent\n // then leaves them behind as orphan reduce-only triggers that fire against\n // whatever position happens to exist. An attached TP/SL needs a linkage that\n // links it, so the combination is a caller mistake rather than a mode.\n const requestsNoLinkage =\n params.tpslLinkage === 'none' || params.grouping === 'na';\n if (requestsNoLinkage && hasAttachedTpsl) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TPSL_LINKAGE_REQUIRED,\n };\n }\n\n // Only a plain limit order rests on the book long enough for a time in force to\n // mean anything: a market order fills immediately and a trigger order's\n // execution is decided when it fires. Rejected here, at step 1 of placement, so\n // it cannot fire after leverage changes or a HIP-3 margin transfer.\n if (params.timeInForce !== undefined && orderType !== 'limit') {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TIME_IN_FORCE_NOT_SUPPORTED,\n };\n }\n\n const partialTpslValidation = validatePartialTpslSizes(params);\n if (!partialTpslValidation.isValid) {\n return partialTpslValidation;\n }\n\n return { isValid: true };\n}\n\n/**\n * Validate quantity-scoped (partial) TP/SL sizes against the parent order.\n *\n * @param params - Order parameters carrying the TP/SL prices and sizes\n * @param params.size - Parent order size\n * @param params.takeProfitPrice - Attached take profit price\n * @param params.stopLossPrice - Attached stop loss price\n * @param params.takeProfitSize - Partial take profit size\n * @param params.stopLossSize - Partial stop loss size\n * @returns Validation result with isValid flag and optional error message\n */\nfunction validatePartialTpslSizes(params: {\n size?: string;\n takeProfitPrice?: string;\n stopLossPrice?: string;\n takeProfitSize?: string;\n stopLossSize?: string;\n}): { isValid: boolean; error?: string } {\n const orderSize = params.size ? Math.abs(parseFloat(params.size)) : undefined;\n\n const entries: { size?: string; price?: string }[] = [\n { size: params.takeProfitSize, price: params.takeProfitPrice },\n { size: params.stopLossSize, price: params.stopLossPrice },\n ];\n\n for (const entry of entries) {\n if (entry.size === undefined) {\n continue;\n }\n\n // A size without its price would silently place nothing.\n if (!entry.price) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TPSL_SIZE_INVALID,\n };\n }\n\n const size = parseFloat(entry.size);\n if (isNaN(size) || size <= 0) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TPSL_SIZE_INVALID,\n };\n }\n\n if (orderSize !== undefined && !isNaN(orderSize) && size > orderSize) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_TPSL_SIZE_INVALID,\n };\n }\n }\n\n return { isValid: true };\n}\n\n/**\n * Validate coin exists in asset mapping.\n *\n * @param coin - The coin symbol to validate\n * @param coinToAssetId - Map of coin symbols to asset IDs\n * @returns Validation result with isValid flag and optional error message\n */\nexport function validateCoinExists(\n coin: string,\n coinToAssetId: Map<string, number>,\n): { isValid: boolean; error?: string } {\n if (!coinToAssetId.has(coin)) {\n return {\n isValid: false,\n error: PERPS_ERROR_CODES.ORDER_UNKNOWN_COIN,\n };\n }\n\n return { isValid: true };\n}\n"]}
@@ -105,28 +105,11 @@ export declare function getSupportedPaths(params?: GetSupportedPathsParams, debu
105
105
  * Based on HyperLiquid contract specifications.
106
106
  *
107
107
  * @param maxLeverage - The maximum leverage for the market
108
- * @param orderType - The order type; every type follows the limit/market
109
- * multiplier of its execution mode, so `stop_limit`, `scale` and `chase` are all
110
- * treated as limit orders and `twap` as a market order
108
+ * @param orderType - The order type; trigger types follow the limit/market
109
+ * multiplier of their execution mode (e.g. `stop_limit` is treated as a limit order)
111
110
  * @returns Maximum order value in USD
112
111
  */
113
112
  export declare function getMaxOrderValue(maxLeverage: number, orderType: OrderType): number;
114
- /**
115
- * The strategy-placement fields of `OrderParams`, as validation sees them.
116
- *
117
- * Named so the provider can forward exactly this group to `validateOrderParams`
118
- * without the field list drifting between the two call sites.
119
- */
120
- export type StrategyOrderValidationParams = {
121
- twapDuration?: number;
122
- twapRandomize?: boolean;
123
- scaleMinPrice?: string;
124
- scaleMaxPrice?: string;
125
- scaleNumOrders?: number;
126
- chaseIntervalMs?: number;
127
- chaseMaxDurationMs?: number;
128
- chaseMaxRepricings?: number;
129
- };
130
113
  /**
131
114
  * Validate order parameters.
132
115
  * Basic validation - checks required fields are present.
@@ -146,18 +129,9 @@ export type StrategyOrderValidationParams = {
146
129
  * @param params.tpslLinkage - How an attached TP/SL is linked
147
130
  * @param params.grouping - Deprecated protocol-shaped spelling of `tpslLinkage`
148
131
  * @param params.timeInForce - Time in force; only a plain limit order can carry one
149
- * @param params.clientOrderId - Client-provided order ID; a strategy placement cannot carry one
150
- * @param params.twapDuration - TWAP window in whole minutes
151
- * @param params.twapRandomize - Whether to randomize the TWAP slice timing
152
- * @param params.scaleMinPrice - Lowest price in a scale ladder
153
- * @param params.scaleMaxPrice - Highest price in a scale ladder
154
- * @param params.scaleNumOrders - How many orders a scale ladder fans out into
155
- * @param params.chaseIntervalMs - How often a chase re-reads the touch
156
- * @param params.chaseMaxDurationMs - How long a chase keeps re-pricing
157
- * @param params.chaseMaxRepricings - Cap on a chase's cancel/replace cycles
158
132
  * @returns Validation result with isValid flag and optional error message
159
133
  */
160
- export declare function validateOrderParams(params: StrategyOrderValidationParams & {
134
+ export declare function validateOrderParams(params: {
161
135
  coin?: string;
162
136
  size?: string;
163
137
  price?: string;
@@ -170,7 +144,6 @@ export declare function validateOrderParams(params: StrategyOrderValidationParam
170
144
  tpslLinkage?: TpslLinkage;
171
145
  grouping?: 'na' | 'normalTpsl' | 'positionTpsl';
172
146
  timeInForce?: 'GTC' | 'IOC' | 'ALO';
173
- clientOrderId?: string;
174
147
  }): {
175
148
  isValid: boolean;
176
149
  error?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"hyperLiquidValidation.d.cts","sourceRoot":"","sources":["../../src/utils/hyperLiquidValidation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,wBAAwB;AAaxD,OAAO,KAAK,EACV,uBAAuB,EACvB,gBAAgB,EACjB,2BAA0B;AAC3B,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,iCAAgC;AAStE;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAEjE;;GAEG;AAEH;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,SAAS;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EACnD,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM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;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,EAAE,IAAI,GAAG,YAAY,GAAG,cAAc,CAAC;IAChD,WAAW,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;CACrC,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAqIvC;AA2DD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACjC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAStC"}
@@ -105,28 +105,11 @@ export declare function getSupportedPaths(params?: GetSupportedPathsParams, debu
105
105
  * Based on HyperLiquid contract specifications.
106
106
  *
107
107
  * @param maxLeverage - The maximum leverage for the market
108
- * @param orderType - The order type; every type follows the limit/market
109
- * multiplier of its execution mode, so `stop_limit`, `scale` and `chase` are all
110
- * treated as limit orders and `twap` as a market order
108
+ * @param orderType - The order type; trigger types follow the limit/market
109
+ * multiplier of their execution mode (e.g. `stop_limit` is treated as a limit order)
111
110
  * @returns Maximum order value in USD
112
111
  */
113
112
  export declare function getMaxOrderValue(maxLeverage: number, orderType: OrderType): number;
114
- /**
115
- * The strategy-placement fields of `OrderParams`, as validation sees them.
116
- *
117
- * Named so the provider can forward exactly this group to `validateOrderParams`
118
- * without the field list drifting between the two call sites.
119
- */
120
- export type StrategyOrderValidationParams = {
121
- twapDuration?: number;
122
- twapRandomize?: boolean;
123
- scaleMinPrice?: string;
124
- scaleMaxPrice?: string;
125
- scaleNumOrders?: number;
126
- chaseIntervalMs?: number;
127
- chaseMaxDurationMs?: number;
128
- chaseMaxRepricings?: number;
129
- };
130
113
  /**
131
114
  * Validate order parameters.
132
115
  * Basic validation - checks required fields are present.
@@ -146,18 +129,9 @@ export type StrategyOrderValidationParams = {
146
129
  * @param params.tpslLinkage - How an attached TP/SL is linked
147
130
  * @param params.grouping - Deprecated protocol-shaped spelling of `tpslLinkage`
148
131
  * @param params.timeInForce - Time in force; only a plain limit order can carry one
149
- * @param params.clientOrderId - Client-provided order ID; a strategy placement cannot carry one
150
- * @param params.twapDuration - TWAP window in whole minutes
151
- * @param params.twapRandomize - Whether to randomize the TWAP slice timing
152
- * @param params.scaleMinPrice - Lowest price in a scale ladder
153
- * @param params.scaleMaxPrice - Highest price in a scale ladder
154
- * @param params.scaleNumOrders - How many orders a scale ladder fans out into
155
- * @param params.chaseIntervalMs - How often a chase re-reads the touch
156
- * @param params.chaseMaxDurationMs - How long a chase keeps re-pricing
157
- * @param params.chaseMaxRepricings - Cap on a chase's cancel/replace cycles
158
132
  * @returns Validation result with isValid flag and optional error message
159
133
  */
160
- export declare function validateOrderParams(params: StrategyOrderValidationParams & {
134
+ export declare function validateOrderParams(params: {
161
135
  coin?: string;
162
136
  size?: string;
163
137
  price?: string;
@@ -170,7 +144,6 @@ export declare function validateOrderParams(params: StrategyOrderValidationParam
170
144
  tpslLinkage?: TpslLinkage;
171
145
  grouping?: 'na' | 'normalTpsl' | 'positionTpsl';
172
146
  timeInForce?: 'GTC' | 'IOC' | 'ALO';
173
- clientOrderId?: string;
174
147
  }): {
175
148
  isValid: boolean;
176
149
  error?: string;