@metamask-previews/perps-controller 19.0.0-preview-8cc0f94 → 19.0.0-preview-cbae429b5

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 (114) hide show
  1. package/CHANGELOG.md +3 -114
  2. package/README.md +1 -586
  3. package/dist/PerpsController-method-action-types.d.ts +14 -133
  4. package/dist/PerpsController-method-action-types.d.ts.map +1 -1
  5. package/dist/PerpsController-method-action-types.js.map +1 -1
  6. package/dist/PerpsController.d.ts +14 -111
  7. package/dist/PerpsController.d.ts.map +1 -1
  8. package/dist/PerpsController.js +42 -507
  9. package/dist/PerpsController.js.map +1 -1
  10. package/dist/aggregation/SubscriptionMultiplexer.d.ts +3 -7
  11. package/dist/aggregation/SubscriptionMultiplexer.d.ts.map +1 -1
  12. package/dist/aggregation/SubscriptionMultiplexer.js +2 -4
  13. package/dist/aggregation/SubscriptionMultiplexer.js.map +1 -1
  14. package/dist/constants/hyperLiquidConfig.d.ts +1 -15
  15. package/dist/constants/hyperLiquidConfig.d.ts.map +1 -1
  16. package/dist/constants/hyperLiquidConfig.js +2 -16
  17. package/dist/constants/hyperLiquidConfig.js.map +1 -1
  18. package/dist/constants/lighterConfig.d.ts +1 -61
  19. package/dist/constants/lighterConfig.d.ts.map +1 -1
  20. package/dist/constants/lighterConfig.js +1 -62
  21. package/dist/constants/lighterConfig.js.map +1 -1
  22. package/dist/index.d.ts +3 -3
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/perpsErrorCodes.d.ts +0 -1
  26. package/dist/perpsErrorCodes.d.ts.map +1 -1
  27. package/dist/perpsErrorCodes.js +0 -1
  28. package/dist/perpsErrorCodes.js.map +1 -1
  29. package/dist/providers/AggregatedPerpsProvider.d.ts +4 -69
  30. package/dist/providers/AggregatedPerpsProvider.d.ts.map +1 -1
  31. package/dist/providers/AggregatedPerpsProvider.js +7 -176
  32. package/dist/providers/AggregatedPerpsProvider.js.map +1 -1
  33. package/dist/providers/HyperLiquidProvider.d.ts +5 -5
  34. package/dist/providers/HyperLiquidProvider.d.ts.map +1 -1
  35. package/dist/providers/HyperLiquidProvider.js +145 -416
  36. package/dist/providers/HyperLiquidProvider.js.map +1 -1
  37. package/dist/providers/LighterProvider.d.ts +57 -149
  38. package/dist/providers/LighterProvider.d.ts.map +1 -1
  39. package/dist/providers/LighterProvider.js +1119 -8262
  40. package/dist/providers/LighterProvider.js.map +1 -1
  41. package/dist/services/HyperLiquidClientService.d.ts +2 -3
  42. package/dist/services/HyperLiquidClientService.d.ts.map +1 -1
  43. package/dist/services/HyperLiquidClientService.js +3 -14
  44. package/dist/services/HyperLiquidClientService.js.map +1 -1
  45. package/dist/services/LighterClientService.d.ts +2 -30
  46. package/dist/services/LighterClientService.d.ts.map +1 -1
  47. package/dist/services/LighterClientService.js +10 -151
  48. package/dist/services/LighterClientService.js.map +1 -1
  49. package/dist/services/TradingService.d.ts.map +1 -1
  50. package/dist/services/TradingService.js +2 -23
  51. package/dist/services/TradingService.js.map +1 -1
  52. package/dist/types/index.d.ts +21 -402
  53. package/dist/types/index.d.ts.map +1 -1
  54. package/dist/types/index.js.map +1 -1
  55. package/dist/types/lighter-types.d.ts +1 -94
  56. package/dist/types/lighter-types.d.ts.map +1 -1
  57. package/dist/types/lighter-types.js.map +1 -1
  58. package/dist/utils/lighterAdapter.d.ts +0 -7
  59. package/dist/utils/lighterAdapter.d.ts.map +1 -1
  60. package/dist/utils/lighterAdapter.js +4 -4
  61. package/dist/utils/lighterAdapter.js.map +1 -1
  62. package/dist/utils/subscriptionFeeWaiver.d.ts +6 -7
  63. package/dist/utils/subscriptionFeeWaiver.d.ts.map +1 -1
  64. package/dist/utils/subscriptionFeeWaiver.js +6 -12
  65. package/dist/utils/subscriptionFeeWaiver.js.map +1 -1
  66. package/package.json +1 -1
  67. package/dist/services/LighterChaseService.d.ts +0 -578
  68. package/dist/services/LighterChaseService.d.ts.map +0 -1
  69. package/dist/services/LighterChaseService.js +0 -1117
  70. package/dist/services/LighterChaseService.js.map +0 -1
  71. package/dist/services/LighterTwapService.d.ts +0 -288
  72. package/dist/services/LighterTwapService.d.ts.map +0 -1
  73. package/dist/services/LighterTwapService.js +0 -511
  74. package/dist/services/LighterTwapService.js.map +0 -1
  75. package/dist/services/lighterDispatchIdentity.d.ts +0 -28
  76. package/dist/services/lighterDispatchIdentity.d.ts.map +0 -1
  77. package/dist/services/lighterDispatchIdentity.js +0 -43
  78. package/dist/services/lighterDispatchIdentity.js.map +0 -1
  79. package/dist/utils/guardedHyperLiquidClient.d.ts +0 -13
  80. package/dist/utils/guardedHyperLiquidClient.d.ts.map +0 -1
  81. package/dist/utils/guardedHyperLiquidClient.js +0 -38
  82. package/dist/utils/guardedHyperLiquidClient.js.map +0 -1
  83. package/dist/utils/lighterAttachedOrders.d.ts +0 -53
  84. package/dist/utils/lighterAttachedOrders.d.ts.map +0 -1
  85. package/dist/utils/lighterAttachedOrders.js +0 -212
  86. package/dist/utils/lighterAttachedOrders.js.map +0 -1
  87. package/dist/utils/lighterChase.d.ts +0 -75
  88. package/dist/utils/lighterChase.d.ts.map +0 -1
  89. package/dist/utils/lighterChase.js +0 -207
  90. package/dist/utils/lighterChase.js.map +0 -1
  91. package/dist/utils/lighterLosslessJson.d.ts +0 -11
  92. package/dist/utils/lighterLosslessJson.d.ts.map +0 -1
  93. package/dist/utils/lighterLosslessJson.js +0 -136
  94. package/dist/utils/lighterLosslessJson.js.map +0 -1
  95. package/dist/utils/lighterNativeEdit.d.ts +0 -238
  96. package/dist/utils/lighterNativeEdit.d.ts.map +0 -1
  97. package/dist/utils/lighterNativeEdit.js +0 -573
  98. package/dist/utils/lighterNativeEdit.js.map +0 -1
  99. package/dist/utils/lighterScaleOrders.d.ts +0 -106
  100. package/dist/utils/lighterScaleOrders.d.ts.map +0 -1
  101. package/dist/utils/lighterScaleOrders.js +0 -496
  102. package/dist/utils/lighterScaleOrders.js.map +0 -1
  103. package/dist/utils/lighterTwap.d.ts +0 -42
  104. package/dist/utils/lighterTwap.d.ts.map +0 -1
  105. package/dist/utils/lighterTwap.js +0 -79
  106. package/dist/utils/lighterTwap.js.map +0 -1
  107. package/dist/utils/lighterTwapReconciliation.d.ts +0 -35
  108. package/dist/utils/lighterTwapReconciliation.d.ts.map +0 -1
  109. package/dist/utils/lighterTwapReconciliation.js +0 -237
  110. package/dist/utils/lighterTwapReconciliation.js.map +0 -1
  111. package/dist/utils/positionProtection.d.ts +0 -12
  112. package/dist/utils/positionProtection.d.ts.map +0 -1
  113. package/dist/utils/positionProtection.js +0 -29
  114. package/dist/utils/positionProtection.js.map +0 -1
@@ -7,7 +7,7 @@
7
7
  * - Support aggregation modes: 'merge' (all prices) or 'best_price' (best price per symbol)
8
8
  * - Cache latest updates per provider per symbol for aggregation
9
9
  */
10
- import type { PerpsProviderType, PerpsProvider, PerpsLogger, PriceUpdate, Position, AccountState, SubscribeOrderFillsParams, SubscribeOrdersParams } from '../types/index.js';
10
+ import type { PerpsProviderType, PerpsProvider, PerpsLogger, PriceUpdate, Position, OrderFill, Order, AccountState } from '../types/index.js';
11
11
  /**
12
12
  * Options for constructing SubscriptionMultiplexer
13
13
  */
@@ -51,23 +51,19 @@ export type MultiplexedPositionsParams = {
51
51
  * Parameters for multiplexed order fill subscriptions
52
52
  */
53
53
  export type MultiplexedOrderFillsParams = {
54
- /** Report provider errors without emitting a fabricated empty snapshot. */
55
- onError?: SubscribeOrderFillsParams['onError'];
56
54
  /** Provider instances to subscribe through */
57
55
  providers: [PerpsProviderType, PerpsProvider][];
58
56
  /** Callback to receive aggregated order fill updates */
59
- callback: SubscribeOrderFillsParams['callback'];
57
+ callback: (fills: OrderFill[], isSnapshot?: boolean) => void;
60
58
  };
61
59
  /**
62
60
  * Parameters for multiplexed order subscriptions
63
61
  */
64
62
  export type MultiplexedOrdersParams = {
65
- /** Report provider errors without emitting a fabricated empty snapshot. */
66
- onError?: SubscribeOrdersParams['onError'];
67
63
  /** Provider instances to subscribe through */
68
64
  providers: [PerpsProviderType, PerpsProvider][];
69
65
  /** Callback to receive aggregated order updates */
70
- callback: SubscribeOrdersParams['callback'];
66
+ callback: (orders: Order[]) => void;
71
67
  };
72
68
  /**
73
69
  * Parameters for multiplexed account subscriptions
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionMultiplexer.d.ts","sourceRoot":"","sources":["../../src/aggregation/SubscriptionMultiplexer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,WAAW,EACX,QAAQ,EAER,YAAY,EAGZ,yBAAyB,EACzB,qBAAqB,EAEtB,MAAM,mBAAmB,CAAC;AAG3B;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,yDAAyD;IACzD,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,YAAY,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,8BAA8B;IAC9B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,8CAA8C;IAC9C,SAAS,EAAE,CAAC,iBAAiB,EAAE,aAAa,CAAC,EAAE,CAAC;IAChD,mDAAmD;IACnD,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC;IAC1C,yFAAyF;IACzF,eAAe,CAAC,EAAE,oBAAoB,CAAC;IACvC,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gDAAgD;IAChD,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,8CAA8C;IAC9C,SAAS,EAAE,CAAC,iBAAiB,EAAE,aAAa,CAAC,EAAE,CAAC;IAChD,sD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rE;IAED;;;;;OAKG;IACH,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,GAAG,MAAM,IAAI,CAkD7D;IAED;;;;;OAKG;IACH,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,MAAM,IAAI,CAqD/D;IA8FD;;OAEG;IACH,UAAU,IAAI,IAAI,CAKjB;IAED;;;;;;OAMG;IACH,cAAc,CACZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,iBAAiB,GAC5B,WAAW,GAAG,SAAS,CAEzB;IAED;;;;;OAKG;IACH,2BAA2B,CACzB,MAAM,EAAE,MAAM,GACb,GAAG,CAAC,iBAAiB,EAAE,WAAW,CAAC,GAAG,SAAS,CAEjD;CACF"}
1
+ {"version":3,"file":"SubscriptionMultiplexer.d.ts","sourceRoot":"","sources":["../../src/aggregation/SubscriptionMultiplexer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,WAAW,EACX,QAAQ,EACR,SAAS,EACT,KAAK,EACL,YAAY,EAMb,MAAM,mBAAmB,CAAC;AAG3B;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,yDAAyD;IACzD,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,YAAY,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,8BAA8B;IAC9B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,8CAA8C;IAC9C,SAAS,EAAE,CAAC,iBAAiB,EAAE,aAAa,CAAC,EAAE,CAAC;IAChD,mDAAmD;IACnD,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC;IAC1C,yFAAyF;IACzF,eAAe,CAAC,EAAE,oBAAoB,CAAC;IACvC,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM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IAAI,CA2E7D;IAED;;;;;OAKG;IACH,oBAAoB,CAAC,MAAM,EAAE,0BAA0B,GAAG,MAAM,IAAI,CAkDnE;IAED;;;;;OAKG;IACH,qBAAqB,CAAC,MAAM,EAAE,2BAA2B,GAAG,MAAM,IAAI,CA4CrE;IAED;;;;;OAKG;IACH,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,GAAG,MAAM,IAAI,CAiD7D;IAED;;;;;OAKG;IACH,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,MAAM,IAAI,CAqD/D;IA8FD;;OAEG;IACH,UAAU,IAAI,IAAI,CAKjB;IAED;;;;;;OAMG;IACH,cAAc,CACZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,iBAAiB,GAC5B,WAAW,GAAG,SAAS,CAEzB;IAED;;;;;OAKG;IACH,2BAA2B,CACzB,MAAM,EAAE,MAAM,GACb,GAAG,CAAC,iBAAiB,EAAE,WAAW,CAAC,GAAG,SAAS,CAEjD;CACF"}
@@ -201,7 +201,6 @@ export class SubscriptionMultiplexer {
201
201
  for (const [providerId, provider] of providers) {
202
202
  try {
203
203
  const subscribeParams = {
204
- onError: (error) => params.onError?.(error, providerId),
205
204
  callback: (fills, isSnapshot) => {
206
205
  // Tag fills with providerId
207
206
  const taggedFills = fills.map((fill) => ({
@@ -209,7 +208,7 @@ export class SubscriptionMultiplexer {
209
208
  providerId,
210
209
  }));
211
210
  // For fills, we don't aggregate - emit immediately with tags
212
- callback(taggedFills, isSnapshot, providerId);
211
+ callback(taggedFills, isSnapshot);
213
212
  },
214
213
  };
215
214
  const unsub = provider.subscribeToOrderFills(subscribeParams);
@@ -247,7 +246,6 @@ export class SubscriptionMultiplexer {
247
246
  for (const [providerId, provider] of providers) {
248
247
  try {
249
248
  const subscribeParams = {
250
- onError: (error) => params.onError?.(error, providerId),
251
249
  callback: (orders) => {
252
250
  // Tag orders with providerId and cache
253
251
  const taggedOrders = orders.map((order) => ({
@@ -257,7 +255,7 @@ export class SubscriptionMultiplexer {
257
255
  this.#orderCache.set(providerId, taggedOrders);
258
256
  // Emit aggregated orders from all providers
259
257
  const allOrders = this.#aggregateOrders();
260
- callback(allOrders, providerId);
258
+ callback(allOrders);
261
259
  },
262
260
  };
263
261
  const unsub = provider.subscribeToOrders(subscribeParams);
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionMultiplexer.js","sourceRoot":"","sources":["../../src/aggregation/SubscriptionMultiplexer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAe9D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AA+ErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,OAAO,uBAAuB;IAClC;;OAEG;IACM,OAAO,CAAe;IAE/B;;;OAGG;IACM,WAAW,GAClB,IAAI,GAAG,EAAE,CAAC;IAEZ;;;OAGG;IACM,cAAc,GAAuC,IAAI,GAAG,EAAE,CAAC;IAExE;;;OAGG;IACM,WAAW,GAAoC,IAAI,GAAG,EAAE,CAAC;IAElE;;;OAGG;IACM,aAAa,GAAyC,IAAI,GAAG,EAAE,CAAC;IAEzE;;;;OAIG;IACH,YAAY,OAAwC;QAClD,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,MAAM,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACH,iBAAiB,CAAC,MAA+B;QAC/C,MAAM,EACJ,OAAO,EACP,SAAS,EACT,QAAQ,EACR,eAAe,GAAG,OAAO,EACzB,UAAU,EACV,gBAAgB,EAChB,iBAAiB,GAClB,GAAG,MAAM,CAAC;QAEX,MAAM,aAAa,GAAmB,EAAE,CAAC;QAEzC,2DAA2D;QAC3D,KAAK,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC;YAC/C,IAAI,CAAC;gBACH,MAAM,eAAe,GAA0B;oBAC7C,OAAO;oBACP,QAAQ,EAA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QACH,OAAO,YAAY,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,gBAAgB;QACd,MAAM,SAAS,GAAY,EAAE,CAAC;QAC9B,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YAClC,SAAS,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAED;;;;;;OAMG;IACH,cAAc,CACZ,MAAc,EACd,UAA6B;QAE7B,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;IACvD,CAAC;IAED;;;;;OAKG;IACH,2BAA2B,CACzB,MAAc;QAEd,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;CACF","sourcesContent":["/**\n * SubscriptionMultiplexer - Manages WebSocket subscriptions across multiple providers\n *\n * Responsibilities:\n * - Manage subscriptions to multiple providers simultaneously\n * - Tag all updates with providerId so UI can differentiate sources\n * - Support aggregation modes: 'merge' (all prices) or 'best_price' (best price per symbol)\n * - Cache latest updates per provider per symbol for aggregation\n */\n\nimport { PERPS_CONSTANTS } from '../constants/perpsConfig.js';\nimport type {\n PerpsProviderType,\n PerpsProvider,\n PerpsLogger,\n PriceUpdate,\n Position,\n Order,\n AccountState,\n SubscribePricesParams,\n SubscribePositionsParams,\n SubscribeOrderFillsParams,\n SubscribeOrdersParams,\n SubscribeAccountParams,\n} from '../types/index.js';\nimport { ensureError } from '../utils/errorUtils.js';\n\n/**\n * Options for constructing SubscriptionMultiplexer\n */\nexport type SubscriptionMultiplexerOptions = {\n /** Optional logger for error reporting (e.g., Sentry) */\n logger?: PerpsLogger;\n};\n\n/**\n * Aggregation mode for price subscriptions\n */\nexport type PriceAggregationMode = 'merge' | 'best_price';\n\n/**\n * Parameters for multiplexed price subscriptions\n */\nexport type MultiplexedPricesParams = {\n /** Symbols to subscribe to */\n symbols: string[];\n /** Provider instances to subscribe through */\n providers: [PerpsProviderType, PerpsProvider][];\n /** Callback to receive aggregated price updates */\n callback: (prices: PriceUpdate[]) => void;\n /** Aggregation mode: 'merge' returns all prices, 'best_price' returns best per symbol */\n aggregationMode?: PriceAggregationMode;\n /** Optional throttle in milliseconds */\n throttleMs?: number;\n /** Include order book data */\n includeOrderBook?: boolean;\n /** Include market data (funding, OI, volume) */\n includeMarketData?: boolean;\n};\n\n/**\n * Parameters for multiplexed position subscriptions\n */\nexport type MultiplexedPositionsParams = {\n /** Provider instances to subscribe through */\n providers: [PerpsProviderType, PerpsProvider][];\n /** Callback to receive aggregated position updates */\n callback: (positions: Position[]) => void;\n};\n\n/**\n * Parameters for multiplexed order fill subscriptions\n */\nexport type MultiplexedOrderFillsParams = {\n /** Report provider errors without emitting a fabricated empty snapshot. */\n onError?: SubscribeOrderFillsParams['onError'];\n /** Provider instances to subscribe through */\n providers: [PerpsProviderType, PerpsProvider][];\n /** Callback to receive aggregated order fill updates */\n callback: SubscribeOrderFillsParams['callback'];\n};\n\n/**\n * Parameters for multiplexed order subscriptions\n */\nexport type MultiplexedOrdersParams = {\n /** Report provider errors without emitting a fabricated empty snapshot. */\n onError?: SubscribeOrdersParams['onError'];\n /** Provider instances to subscribe through */\n providers: [PerpsProviderType, PerpsProvider][];\n /** Callback to receive aggregated order updates */\n callback: SubscribeOrdersParams['callback'];\n};\n\n/**\n * Parameters for multiplexed account subscriptions\n */\nexport type MultiplexedAccountParams = {\n /** Provider instances to subscribe through */\n providers: [PerpsProviderType, PerpsProvider][];\n /** Callback to receive account updates (one per provider) */\n callback: (accounts: AccountState[]) => void;\n};\n\n/**\n * SubscriptionMultiplexer manages real-time data subscriptions across\n * multiple perps providers.\n *\n * Key features:\n * - Subscribes to all providers simultaneously\n * - Tags all updates with source providerId\n * - Caches latest values for aggregation\n * - Supports different aggregation modes for prices\n *\n * @example\n * ```typescript\n * const mux = new SubscriptionMultiplexer();\n *\n * const unsubscribe = mux.subscribeToPrices({\n * symbols: ['BTC', 'ETH'],\n * providers: [\n * ['hyperliquid', hlProvider],\n * ['lighter', lighterProvider],\n * ],\n * callback: (prices) => {\n * // prices have providerId injected\n * prices.forEach(p => console.log(`${p.providerId}: ${p.symbol} = ${p.price}`));\n * },\n * aggregationMode: 'merge',\n * });\n *\n * // Later: clean up\n * unsubscribe();\n * ```\n */\nexport class SubscriptionMultiplexer {\n /**\n * Optional logger for error reporting\n */\n readonly #logger?: PerpsLogger;\n\n /**\n * Cache of latest prices per symbol per provider\n * Map<symbol, Map<providerId, PriceUpdate>>\n */\n readonly #priceCache: Map<string, Map<PerpsProviderType, PriceUpdate>> =\n new Map();\n\n /**\n * Cache of latest positions per provider\n * Map<providerId, Position[]>\n */\n readonly #positionCache: Map<PerpsProviderType, Position[]> = new Map();\n\n /**\n * Cache of latest orders per provider\n * Map<providerId, Order[]>\n */\n readonly #orderCache: Map<PerpsProviderType, Order[]> = new Map();\n\n /**\n * Cache of latest account state per provider\n * Map<providerId, AccountState>\n */\n readonly #accountCache: Map<PerpsProviderType, AccountState> = new Map();\n\n /**\n * Create a new SubscriptionMultiplexer.\n *\n * @param options - Optional configuration including logger for error reporting\n */\n constructor(options?: SubscriptionMultiplexerOptions) {\n this.#logger = options?.logger;\n }\n\n /**\n * Subscribe to price updates from multiple providers.\n *\n * @param params - Subscription parameters\n * @returns Unsubscribe function\n */\n subscribeToPrices(params: MultiplexedPricesParams): () => void {\n const {\n symbols,\n providers,\n callback,\n aggregationMode = 'merge',\n throttleMs,\n includeOrderBook,\n includeMarketData,\n } = params;\n\n const unsubscribers: (() => void)[] = [];\n\n // Subscribe to each provider with defensive error handling\n for (const [providerId, provider] of providers) {\n try {\n const subscribeParams: SubscribePricesParams = {\n symbols,\n callback: (updates) => {\n // Tag and cache each update\n updates.forEach((update) => {\n const taggedUpdate: PriceUpdate = { ...update, providerId };\n\n // Initialize symbol cache if needed\n if (!this.#priceCache.has(update.symbol)) {\n this.#priceCache.set(update.symbol, new Map());\n }\n const symbolCache = this.#priceCache.get(update.symbol);\n if (symbolCache) {\n symbolCache.set(providerId, taggedUpdate);\n }\n });\n\n // Aggregate and emit based on mode\n const aggregated = this.#aggregatePrices(symbols, aggregationMode);\n callback(aggregated);\n },\n throttleMs,\n includeOrderBook,\n includeMarketData,\n };\n\n const unsub = provider.subscribeToPrices(subscribeParams);\n unsubscribers.push(unsub);\n } catch (error) {\n // Log to Sentry before cleanup\n this.#logger?.error(\n ensureError(error, 'SubscriptionMultiplexer.subscribeToPrices'),\n {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n provider: providerId,\n method: 'subscribeToPrices',\n },\n context: {\n name: 'SubscriptionMultiplexer',\n data: { subscribedCount: unsubscribers.length },\n },\n },\n );\n\n // Clean up any subscriptions created before the failure\n unsubscribers.forEach((unsub) => unsub());\n throw error;\n }\n }\n\n // Return combined unsubscribe function\n return () => {\n unsubscribers.forEach((unsub) => unsub());\n // Optionally clear cache for these symbols\n symbols.forEach((symbol) => {\n this.#priceCache.delete(symbol);\n });\n };\n }\n\n /**\n * Subscribe to position updates from multiple providers.\n *\n * @param params - Subscription parameters\n * @returns Unsubscribe function\n */\n subscribeToPositions(params: MultiplexedPositionsParams): () => void {\n const { providers, callback } = params;\n const unsubscribers: (() => void)[] = [];\n\n for (const [providerId, provider] of providers) {\n try {\n const subscribeParams: SubscribePositionsParams = {\n callback: (positions) => {\n // Tag positions with providerId and cache\n const taggedPositions = positions.map((pos) => ({\n ...pos,\n providerId,\n }));\n this.#positionCache.set(providerId, taggedPositions);\n\n // Emit aggregated positions from all providers\n const allPositions = this.#aggregatePositions();\n callback(allPositions);\n },\n };\n\n const unsub = provider.subscribeToPositions(subscribeParams);\n unsubscribers.push(unsub);\n } catch (error) {\n this.#logger?.error(\n ensureError(error, 'SubscriptionMultiplexer.subscribeToPositions'),\n {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n provider: providerId,\n method: 'subscribeToPositions',\n },\n context: {\n name: 'SubscriptionMultiplexer',\n data: { subscribedCount: unsubscribers.length },\n },\n },\n );\n unsubscribers.forEach((unsub) => unsub());\n throw error;\n }\n }\n\n return () => {\n unsubscribers.forEach((unsub) => unsub());\n // Clear position cache for these providers\n providers.forEach(([providerId]) => {\n this.#positionCache.delete(providerId);\n });\n };\n }\n\n /**\n * Subscribe to order fill updates from multiple providers.\n *\n * @param params - Subscription parameters\n * @returns Unsubscribe function\n */\n subscribeToOrderFills(params: MultiplexedOrderFillsParams): () => void {\n const { providers, callback } = params;\n const unsubscribers: (() => void)[] = [];\n\n for (const [providerId, provider] of providers) {\n try {\n const subscribeParams: SubscribeOrderFillsParams = {\n onError: (error) => params.onError?.(error, providerId),\n callback: (fills, isSnapshot) => {\n // Tag fills with providerId\n const taggedFills = fills.map((fill) => ({\n ...fill,\n providerId,\n }));\n\n // For fills, we don't aggregate - emit immediately with tags\n callback(taggedFills, isSnapshot, providerId);\n },\n };\n\n const unsub = provider.subscribeToOrderFills(subscribeParams);\n unsubscribers.push(unsub);\n } catch (error) {\n this.#logger?.error(\n ensureError(error, 'SubscriptionMultiplexer.subscribeToOrderFills'),\n {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n provider: providerId,\n method: 'subscribeToOrderFills',\n },\n context: {\n name: 'SubscriptionMultiplexer',\n data: { subscribedCount: unsubscribers.length },\n },\n },\n );\n unsubscribers.forEach((unsub) => unsub());\n throw error;\n }\n }\n\n return () => {\n unsubscribers.forEach((unsub) => unsub());\n };\n }\n\n /**\n * Subscribe to order updates from multiple providers.\n *\n * @param params - Subscription parameters\n * @returns Unsubscribe function\n */\n subscribeToOrders(params: MultiplexedOrdersParams): () => void {\n const { providers, callback } = params;\n const unsubscribers: (() => void)[] = [];\n\n for (const [providerId, provider] of providers) {\n try {\n const subscribeParams: SubscribeOrdersParams = {\n onError: (error) => params.onError?.(error, providerId),\n callback: (orders) => {\n // Tag orders with providerId and cache\n const taggedOrders = orders.map((order) => ({\n ...order,\n providerId,\n }));\n this.#orderCache.set(providerId, taggedOrders);\n\n // Emit aggregated orders from all providers\n const allOrders = this.#aggregateOrders();\n callback(allOrders, providerId);\n },\n };\n\n const unsub = provider.subscribeToOrders(subscribeParams);\n unsubscribers.push(unsub);\n } catch (error) {\n this.#logger?.error(\n ensureError(error, 'SubscriptionMultiplexer.subscribeToOrders'),\n {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n provider: providerId,\n method: 'subscribeToOrders',\n },\n context: {\n name: 'SubscriptionMultiplexer',\n data: { subscribedCount: unsubscribers.length },\n },\n },\n );\n unsubscribers.forEach((unsub) => unsub());\n throw error;\n }\n }\n\n return () => {\n unsubscribers.forEach((unsub) => unsub());\n providers.forEach(([providerId]) => {\n this.#orderCache.delete(providerId);\n });\n };\n }\n\n /**\n * Subscribe to account updates from multiple providers.\n *\n * @param params - Subscription parameters\n * @returns Unsubscribe function\n */\n subscribeToAccount(params: MultiplexedAccountParams): () => void {\n const { providers, callback } = params;\n const unsubscribers: (() => void)[] = [];\n\n for (const [providerId, provider] of providers) {\n try {\n const subscribeParams: SubscribeAccountParams = {\n callback: (account) => {\n if (account === null) {\n this.#accountCache.delete(providerId);\n } else {\n // Tag account with providerId and cache\n const taggedAccount: AccountState = {\n ...account,\n providerId,\n };\n this.#accountCache.set(providerId, taggedAccount);\n }\n\n // Emit all cached account states\n const allAccounts = Array.from(this.#accountCache.values());\n callback(allAccounts);\n },\n };\n\n const unsub = provider.subscribeToAccount(subscribeParams);\n unsubscribers.push(unsub);\n } catch (error) {\n this.#logger?.error(\n ensureError(error, 'SubscriptionMultiplexer.subscribeToAccount'),\n {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n provider: providerId,\n method: 'subscribeToAccount',\n },\n context: {\n name: 'SubscriptionMultiplexer',\n data: { subscribedCount: unsubscribers.length },\n },\n },\n );\n unsubscribers.forEach((unsub) => unsub());\n throw error;\n }\n }\n\n return () => {\n unsubscribers.forEach((unsub) => unsub());\n providers.forEach(([providerId]) => {\n this.#accountCache.delete(providerId);\n });\n };\n }\n\n /**\n * Aggregate cached prices based on mode.\n *\n * @param symbols - Symbols to include in result\n * @param mode - Aggregation mode\n * @returns Aggregated price updates\n */\n #aggregatePrices(\n symbols: string[],\n mode: PriceAggregationMode,\n ): PriceUpdate[] {\n const result: PriceUpdate[] = [];\n\n symbols.forEach((symbol) => {\n const providerPrices = this.#priceCache.get(symbol);\n if (!providerPrices || providerPrices.size === 0) {\n return;\n }\n\n if (mode === 'merge') {\n // Return all prices (one per provider)\n providerPrices.forEach((price) => {\n result.push(price);\n });\n } else {\n // 'best_price': Return the best price across providers\n const best = this.#findBestPrice(providerPrices);\n if (best) {\n result.push(best);\n }\n }\n });\n\n return result;\n }\n\n /**\n * Find the best price from multiple provider prices.\n * \"Best\" is defined as the price with the smallest spread.\n *\n * @param providerPrices - Map of provider prices for a symbol\n * @returns Best price update or undefined\n */\n #findBestPrice(\n providerPrices: Map<PerpsProviderType, PriceUpdate>,\n ): PriceUpdate | undefined {\n let bestPrice: PriceUpdate | undefined;\n let smallestSpread = Infinity;\n\n providerPrices.forEach((price) => {\n if (price.spread === undefined) {\n // No spread info - just use the first one\n bestPrice ??= price;\n } else {\n // If spread is available, use it to determine best\n const spreadValue = parseFloat(price.spread);\n if (!isNaN(spreadValue) && spreadValue < smallestSpread) {\n smallestSpread = spreadValue;\n bestPrice = price;\n }\n }\n });\n\n return bestPrice;\n }\n\n /**\n * Aggregate positions from all providers.\n *\n * @returns All cached positions\n */\n #aggregatePositions(): Position[] {\n const allPositions: Position[] = [];\n this.#positionCache.forEach((positions) => {\n allPositions.push(...positions);\n });\n return allPositions;\n }\n\n /**\n * Aggregate orders from all providers.\n *\n * @returns All cached orders\n */\n #aggregateOrders(): Order[] {\n const allOrders: Order[] = [];\n this.#orderCache.forEach((orders) => {\n allOrders.push(...orders);\n });\n return allOrders;\n }\n\n /**\n * Clear all cached data.\n */\n clearCache(): void {\n this.#priceCache.clear();\n this.#positionCache.clear();\n this.#orderCache.clear();\n this.#accountCache.clear();\n }\n\n /**\n * Get cached price for a symbol from a specific provider.\n *\n * @param symbol - Market symbol\n * @param providerId - Provider ID\n * @returns Cached price update or undefined\n */\n getCachedPrice(\n symbol: string,\n providerId: PerpsProviderType,\n ): PriceUpdate | undefined {\n return this.#priceCache.get(symbol)?.get(providerId);\n }\n\n /**\n * Get all cached prices for a symbol.\n *\n * @param symbol - Market symbol\n * @returns Map of provider ID to price update\n */\n getAllCachedPricesForSymbol(\n symbol: string,\n ): Map<PerpsProviderType, PriceUpdate> | undefined {\n return this.#priceCache.get(symbol);\n }\n}\n"]}
1
+ {"version":3,"file":"SubscriptionMultiplexer.js","sourceRoot":"","sources":["../../src/aggregation/SubscriptionMultiplexer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAgB9D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AA2ErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,OAAO,uBAAuB;IAClC;;OAEG;IACM,OAAO,CAAe;IAE/B;;;OAGG;IACM,WAAW,GAClB,IAAI,GAAG,EAAE,CAAC;IAEZ;;;OAGG;IACM,cAAc,GAAuC,IAAI,GAAG,EAAE,CAAC;IAExE;;;OAGG;IACM,WAAW,GAAoC,IAAI,GAAG,EAAE,CAAC;IAElE;;;OAGG;IACM,aAAa,GAAyC,IAAI,GAAG,EAAE,CAAC;IAEzE;;;;OAIG;IACH,YAAY,OAAwC;QAClD,IAAI,C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;;OAIG;IACH,mBAAmB;QACjB,MAAM,YAAY,GAAe,EAAE,CAAC;QACpC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;YACxC,YAAY,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QACH,OAAO,YAAY,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,gBAAgB;QACd,MAAM,SAAS,GAAY,EAAE,CAAC;QAC9B,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YAClC,SAAS,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAED;;;;;;OAMG;IACH,cAAc,CACZ,MAAc,EACd,UAA6B;QAE7B,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;IACvD,CAAC;IAED;;;;;OAKG;IACH,2BAA2B,CACzB,MAAc;QAEd,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;CACF","sourcesContent":["/**\n * SubscriptionMultiplexer - Manages WebSocket subscriptions across multiple providers\n *\n * Responsibilities:\n * - Manage subscriptions to multiple providers simultaneously\n * - Tag all updates with providerId so UI can differentiate sources\n * - Support aggregation modes: 'merge' (all prices) or 'best_price' (best price per symbol)\n * - Cache latest updates per provider per symbol for aggregation\n */\n\nimport { PERPS_CONSTANTS } from '../constants/perpsConfig.js';\nimport type {\n PerpsProviderType,\n PerpsProvider,\n PerpsLogger,\n PriceUpdate,\n Position,\n OrderFill,\n Order,\n AccountState,\n SubscribePricesParams,\n SubscribePositionsParams,\n SubscribeOrderFillsParams,\n SubscribeOrdersParams,\n SubscribeAccountParams,\n} from '../types/index.js';\nimport { ensureError } from '../utils/errorUtils.js';\n\n/**\n * Options for constructing SubscriptionMultiplexer\n */\nexport type SubscriptionMultiplexerOptions = {\n /** Optional logger for error reporting (e.g., Sentry) */\n logger?: PerpsLogger;\n};\n\n/**\n * Aggregation mode for price subscriptions\n */\nexport type PriceAggregationMode = 'merge' | 'best_price';\n\n/**\n * Parameters for multiplexed price subscriptions\n */\nexport type MultiplexedPricesParams = {\n /** Symbols to subscribe to */\n symbols: string[];\n /** Provider instances to subscribe through */\n providers: [PerpsProviderType, PerpsProvider][];\n /** Callback to receive aggregated price updates */\n callback: (prices: PriceUpdate[]) => void;\n /** Aggregation mode: 'merge' returns all prices, 'best_price' returns best per symbol */\n aggregationMode?: PriceAggregationMode;\n /** Optional throttle in milliseconds */\n throttleMs?: number;\n /** Include order book data */\n includeOrderBook?: boolean;\n /** Include market data (funding, OI, volume) */\n includeMarketData?: boolean;\n};\n\n/**\n * Parameters for multiplexed position subscriptions\n */\nexport type MultiplexedPositionsParams = {\n /** Provider instances to subscribe through */\n providers: [PerpsProviderType, PerpsProvider][];\n /** Callback to receive aggregated position updates */\n callback: (positions: Position[]) => void;\n};\n\n/**\n * Parameters for multiplexed order fill subscriptions\n */\nexport type MultiplexedOrderFillsParams = {\n /** Provider instances to subscribe through */\n providers: [PerpsProviderType, PerpsProvider][];\n /** Callback to receive aggregated order fill updates */\n callback: (fills: OrderFill[], isSnapshot?: boolean) => void;\n};\n\n/**\n * Parameters for multiplexed order subscriptions\n */\nexport type MultiplexedOrdersParams = {\n /** Provider instances to subscribe through */\n providers: [PerpsProviderType, PerpsProvider][];\n /** Callback to receive aggregated order updates */\n callback: (orders: Order[]) => void;\n};\n\n/**\n * Parameters for multiplexed account subscriptions\n */\nexport type MultiplexedAccountParams = {\n /** Provider instances to subscribe through */\n providers: [PerpsProviderType, PerpsProvider][];\n /** Callback to receive account updates (one per provider) */\n callback: (accounts: AccountState[]) => void;\n};\n\n/**\n * SubscriptionMultiplexer manages real-time data subscriptions across\n * multiple perps providers.\n *\n * Key features:\n * - Subscribes to all providers simultaneously\n * - Tags all updates with source providerId\n * - Caches latest values for aggregation\n * - Supports different aggregation modes for prices\n *\n * @example\n * ```typescript\n * const mux = new SubscriptionMultiplexer();\n *\n * const unsubscribe = mux.subscribeToPrices({\n * symbols: ['BTC', 'ETH'],\n * providers: [\n * ['hyperliquid', hlProvider],\n * ['lighter', lighterProvider],\n * ],\n * callback: (prices) => {\n * // prices have providerId injected\n * prices.forEach(p => console.log(`${p.providerId}: ${p.symbol} = ${p.price}`));\n * },\n * aggregationMode: 'merge',\n * });\n *\n * // Later: clean up\n * unsubscribe();\n * ```\n */\nexport class SubscriptionMultiplexer {\n /**\n * Optional logger for error reporting\n */\n readonly #logger?: PerpsLogger;\n\n /**\n * Cache of latest prices per symbol per provider\n * Map<symbol, Map<providerId, PriceUpdate>>\n */\n readonly #priceCache: Map<string, Map<PerpsProviderType, PriceUpdate>> =\n new Map();\n\n /**\n * Cache of latest positions per provider\n * Map<providerId, Position[]>\n */\n readonly #positionCache: Map<PerpsProviderType, Position[]> = new Map();\n\n /**\n * Cache of latest orders per provider\n * Map<providerId, Order[]>\n */\n readonly #orderCache: Map<PerpsProviderType, Order[]> = new Map();\n\n /**\n * Cache of latest account state per provider\n * Map<providerId, AccountState>\n */\n readonly #accountCache: Map<PerpsProviderType, AccountState> = new Map();\n\n /**\n * Create a new SubscriptionMultiplexer.\n *\n * @param options - Optional configuration including logger for error reporting\n */\n constructor(options?: SubscriptionMultiplexerOptions) {\n this.#logger = options?.logger;\n }\n\n /**\n * Subscribe to price updates from multiple providers.\n *\n * @param params - Subscription parameters\n * @returns Unsubscribe function\n */\n subscribeToPrices(params: MultiplexedPricesParams): () => void {\n const {\n symbols,\n providers,\n callback,\n aggregationMode = 'merge',\n throttleMs,\n includeOrderBook,\n includeMarketData,\n } = params;\n\n const unsubscribers: (() => void)[] = [];\n\n // Subscribe to each provider with defensive error handling\n for (const [providerId, provider] of providers) {\n try {\n const subscribeParams: SubscribePricesParams = {\n symbols,\n callback: (updates) => {\n // Tag and cache each update\n updates.forEach((update) => {\n const taggedUpdate: PriceUpdate = { ...update, providerId };\n\n // Initialize symbol cache if needed\n if (!this.#priceCache.has(update.symbol)) {\n this.#priceCache.set(update.symbol, new Map());\n }\n const symbolCache = this.#priceCache.get(update.symbol);\n if (symbolCache) {\n symbolCache.set(providerId, taggedUpdate);\n }\n });\n\n // Aggregate and emit based on mode\n const aggregated = this.#aggregatePrices(symbols, aggregationMode);\n callback(aggregated);\n },\n throttleMs,\n includeOrderBook,\n includeMarketData,\n };\n\n const unsub = provider.subscribeToPrices(subscribeParams);\n unsubscribers.push(unsub);\n } catch (error) {\n // Log to Sentry before cleanup\n this.#logger?.error(\n ensureError(error, 'SubscriptionMultiplexer.subscribeToPrices'),\n {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n provider: providerId,\n method: 'subscribeToPrices',\n },\n context: {\n name: 'SubscriptionMultiplexer',\n data: { subscribedCount: unsubscribers.length },\n },\n },\n );\n\n // Clean up any subscriptions created before the failure\n unsubscribers.forEach((unsub) => unsub());\n throw error;\n }\n }\n\n // Return combined unsubscribe function\n return () => {\n unsubscribers.forEach((unsub) => unsub());\n // Optionally clear cache for these symbols\n symbols.forEach((symbol) => {\n this.#priceCache.delete(symbol);\n });\n };\n }\n\n /**\n * Subscribe to position updates from multiple providers.\n *\n * @param params - Subscription parameters\n * @returns Unsubscribe function\n */\n subscribeToPositions(params: MultiplexedPositionsParams): () => void {\n const { providers, callback } = params;\n const unsubscribers: (() => void)[] = [];\n\n for (const [providerId, provider] of providers) {\n try {\n const subscribeParams: SubscribePositionsParams = {\n callback: (positions) => {\n // Tag positions with providerId and cache\n const taggedPositions = positions.map((pos) => ({\n ...pos,\n providerId,\n }));\n this.#positionCache.set(providerId, taggedPositions);\n\n // Emit aggregated positions from all providers\n const allPositions = this.#aggregatePositions();\n callback(allPositions);\n },\n };\n\n const unsub = provider.subscribeToPositions(subscribeParams);\n unsubscribers.push(unsub);\n } catch (error) {\n this.#logger?.error(\n ensureError(error, 'SubscriptionMultiplexer.subscribeToPositions'),\n {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n provider: providerId,\n method: 'subscribeToPositions',\n },\n context: {\n name: 'SubscriptionMultiplexer',\n data: { subscribedCount: unsubscribers.length },\n },\n },\n );\n unsubscribers.forEach((unsub) => unsub());\n throw error;\n }\n }\n\n return () => {\n unsubscribers.forEach((unsub) => unsub());\n // Clear position cache for these providers\n providers.forEach(([providerId]) => {\n this.#positionCache.delete(providerId);\n });\n };\n }\n\n /**\n * Subscribe to order fill updates from multiple providers.\n *\n * @param params - Subscription parameters\n * @returns Unsubscribe function\n */\n subscribeToOrderFills(params: MultiplexedOrderFillsParams): () => void {\n const { providers, callback } = params;\n const unsubscribers: (() => void)[] = [];\n\n for (const [providerId, provider] of providers) {\n try {\n const subscribeParams: SubscribeOrderFillsParams = {\n callback: (fills, isSnapshot) => {\n // Tag fills with providerId\n const taggedFills = fills.map((fill) => ({\n ...fill,\n providerId,\n }));\n\n // For fills, we don't aggregate - emit immediately with tags\n callback(taggedFills, isSnapshot);\n },\n };\n\n const unsub = provider.subscribeToOrderFills(subscribeParams);\n unsubscribers.push(unsub);\n } catch (error) {\n this.#logger?.error(\n ensureError(error, 'SubscriptionMultiplexer.subscribeToOrderFills'),\n {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n provider: providerId,\n method: 'subscribeToOrderFills',\n },\n context: {\n name: 'SubscriptionMultiplexer',\n data: { subscribedCount: unsubscribers.length },\n },\n },\n );\n unsubscribers.forEach((unsub) => unsub());\n throw error;\n }\n }\n\n return () => {\n unsubscribers.forEach((unsub) => unsub());\n };\n }\n\n /**\n * Subscribe to order updates from multiple providers.\n *\n * @param params - Subscription parameters\n * @returns Unsubscribe function\n */\n subscribeToOrders(params: MultiplexedOrdersParams): () => void {\n const { providers, callback } = params;\n const unsubscribers: (() => void)[] = [];\n\n for (const [providerId, provider] of providers) {\n try {\n const subscribeParams: SubscribeOrdersParams = {\n callback: (orders) => {\n // Tag orders with providerId and cache\n const taggedOrders = orders.map((order) => ({\n ...order,\n providerId,\n }));\n this.#orderCache.set(providerId, taggedOrders);\n\n // Emit aggregated orders from all providers\n const allOrders = this.#aggregateOrders();\n callback(allOrders);\n },\n };\n\n const unsub = provider.subscribeToOrders(subscribeParams);\n unsubscribers.push(unsub);\n } catch (error) {\n this.#logger?.error(\n ensureError(error, 'SubscriptionMultiplexer.subscribeToOrders'),\n {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n provider: providerId,\n method: 'subscribeToOrders',\n },\n context: {\n name: 'SubscriptionMultiplexer',\n data: { subscribedCount: unsubscribers.length },\n },\n },\n );\n unsubscribers.forEach((unsub) => unsub());\n throw error;\n }\n }\n\n return () => {\n unsubscribers.forEach((unsub) => unsub());\n providers.forEach(([providerId]) => {\n this.#orderCache.delete(providerId);\n });\n };\n }\n\n /**\n * Subscribe to account updates from multiple providers.\n *\n * @param params - Subscription parameters\n * @returns Unsubscribe function\n */\n subscribeToAccount(params: MultiplexedAccountParams): () => void {\n const { providers, callback } = params;\n const unsubscribers: (() => void)[] = [];\n\n for (const [providerId, provider] of providers) {\n try {\n const subscribeParams: SubscribeAccountParams = {\n callback: (account) => {\n if (account === null) {\n this.#accountCache.delete(providerId);\n } else {\n // Tag account with providerId and cache\n const taggedAccount: AccountState = {\n ...account,\n providerId,\n };\n this.#accountCache.set(providerId, taggedAccount);\n }\n\n // Emit all cached account states\n const allAccounts = Array.from(this.#accountCache.values());\n callback(allAccounts);\n },\n };\n\n const unsub = provider.subscribeToAccount(subscribeParams);\n unsubscribers.push(unsub);\n } catch (error) {\n this.#logger?.error(\n ensureError(error, 'SubscriptionMultiplexer.subscribeToAccount'),\n {\n tags: {\n feature: PERPS_CONSTANTS.FeatureName,\n provider: providerId,\n method: 'subscribeToAccount',\n },\n context: {\n name: 'SubscriptionMultiplexer',\n data: { subscribedCount: unsubscribers.length },\n },\n },\n );\n unsubscribers.forEach((unsub) => unsub());\n throw error;\n }\n }\n\n return () => {\n unsubscribers.forEach((unsub) => unsub());\n providers.forEach(([providerId]) => {\n this.#accountCache.delete(providerId);\n });\n };\n }\n\n /**\n * Aggregate cached prices based on mode.\n *\n * @param symbols - Symbols to include in result\n * @param mode - Aggregation mode\n * @returns Aggregated price updates\n */\n #aggregatePrices(\n symbols: string[],\n mode: PriceAggregationMode,\n ): PriceUpdate[] {\n const result: PriceUpdate[] = [];\n\n symbols.forEach((symbol) => {\n const providerPrices = this.#priceCache.get(symbol);\n if (!providerPrices || providerPrices.size === 0) {\n return;\n }\n\n if (mode === 'merge') {\n // Return all prices (one per provider)\n providerPrices.forEach((price) => {\n result.push(price);\n });\n } else {\n // 'best_price': Return the best price across providers\n const best = this.#findBestPrice(providerPrices);\n if (best) {\n result.push(best);\n }\n }\n });\n\n return result;\n }\n\n /**\n * Find the best price from multiple provider prices.\n * \"Best\" is defined as the price with the smallest spread.\n *\n * @param providerPrices - Map of provider prices for a symbol\n * @returns Best price update or undefined\n */\n #findBestPrice(\n providerPrices: Map<PerpsProviderType, PriceUpdate>,\n ): PriceUpdate | undefined {\n let bestPrice: PriceUpdate | undefined;\n let smallestSpread = Infinity;\n\n providerPrices.forEach((price) => {\n if (price.spread === undefined) {\n // No spread info - just use the first one\n bestPrice ??= price;\n } else {\n // If spread is available, use it to determine best\n const spreadValue = parseFloat(price.spread);\n if (!isNaN(spreadValue) && spreadValue < smallestSpread) {\n smallestSpread = spreadValue;\n bestPrice = price;\n }\n }\n });\n\n return bestPrice;\n }\n\n /**\n * Aggregate positions from all providers.\n *\n * @returns All cached positions\n */\n #aggregatePositions(): Position[] {\n const allPositions: Position[] = [];\n this.#positionCache.forEach((positions) => {\n allPositions.push(...positions);\n });\n return allPositions;\n }\n\n /**\n * Aggregate orders from all providers.\n *\n * @returns All cached orders\n */\n #aggregateOrders(): Order[] {\n const allOrders: Order[] = [];\n this.#orderCache.forEach((orders) => {\n allOrders.push(...orders);\n });\n return allOrders;\n }\n\n /**\n * Clear all cached data.\n */\n clearCache(): void {\n this.#priceCache.clear();\n this.#positionCache.clear();\n this.#orderCache.clear();\n this.#accountCache.clear();\n }\n\n /**\n * Get cached price for a symbol from a specific provider.\n *\n * @param symbol - Market symbol\n * @param providerId - Provider ID\n * @returns Cached price update or undefined\n */\n getCachedPrice(\n symbol: string,\n providerId: PerpsProviderType,\n ): PriceUpdate | undefined {\n return this.#priceCache.get(symbol)?.get(providerId);\n }\n\n /**\n * Get all cached prices for a symbol.\n *\n * @param symbol - Market symbol\n * @returns Map of provider ID to price update\n */\n getAllCachedPricesForSymbol(\n symbol: string,\n ): Map<PerpsProviderType, PriceUpdate> | undefined {\n return this.#priceCache.get(symbol);\n }\n}\n"]}
@@ -95,7 +95,7 @@ export declare const BUILDER_FEE_CONFIG: {
95
95
  MaxFeeRate: string;
96
96
  };
97
97
  /**
98
- * Strategies and standalone trigger orders HyperLiquid executes for its markets.
98
+ * Strategies that HyperLiquid can execute for its routed perp markets.
99
99
  * Providers own this declaration so clients never infer support from a
100
100
  * provider name.
101
101
  */
@@ -103,20 +103,6 @@ export declare const HYPERLIQUID_ORDER_CAPABILITIES: Readonly<{
103
103
  status: "ready";
104
104
  providerId: "hyperliquid";
105
105
  supportedStrategies: readonly ("chase" | "scale" | "twap")[];
106
- supportedTriggerOrderTypes: readonly ("stop_limit" | "stop_market" | "take_profit_limit" | "take_profit_market")[];
107
- positionTpsl: Readonly<{
108
- supportsExpectedPosition: true;
109
- childOrderIds: "request-correlated";
110
- takeProfitOrderType: "take_profit_limit";
111
- stopLossOrderType: "stop_market";
112
- defaultCoverage: "dynamic-position";
113
- partialCoverage: Readonly<{
114
- single: true;
115
- pair: "independent";
116
- replacement: "cancel-before-create";
117
- recovery: "provider-default";
118
- }>;
119
- }>;
120
106
  }>;
121
107
  export declare const REFERRAL_CONFIG: {
122
108
  MainnetCode: string;
@@ -1 +1 @@
1
- {"version":3,"file":"hyperLiquidConfig.d.ts","sourceRoot":"","sources":["../../src/constants/hyperLiquidConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAGrE,OAAO,KAAK,EAEV,UAAU,EACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAEV,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,EACrB,cAAc,EACf,MAAM,yBAAyB,CAAC;AAQjC,eAAO,MAAM,6BAA6B,EAAG,QAAiB,CAAC;AAC/D,eAAO,MAAM,yBAAyB,UAAU,CAAC;AACjD,eAAO,MAAM,yBAAyB,WAAW,CAAC;AAClD,eAAO,MAAM,8BAA8B,iBAAwC,CAAC;AACpF,eAAO,MAAM,8BAA8B,kBAAwC,CAAC;AAGpF,eAAO,MAAM,4BAA4B,UAAU,CAAC;AACpD,eAAO,MAAM,4BAA4B,UAAU,CAAC;AACpD,eAAO,MAAM,iCAAiC,EAAmB,WAAW,CAAC;AAC7E,eAAO,MAAM,iCAAiC,EAAmB,WAAW,CAAC;AAC7E,eAAO,MAAM,wBAAwB,gBAAgB,CAAC;AAEtD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,GACtB,MAAM,EAAE,CAIV;AAGD,eAAO,MAAM,WAAW,SAAS,CAAC;AAClC,eAAO,MAAM,SAAS,aAAa,CAAC;AACpC,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,cAAc,KAAK,CAAC;AAGjC,eAAO,MAAM,yBAAyB,Y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EF;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAA2B,GACtD,MAAM,CAER;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB;IAC9B;;;;OAIG;aACH,WAAW,EAAa,MAAM,EAAE;IAEhC;;;OAGG;aACH,eAAe;CACP,CAAC;AAEX;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB;IAC9B;;;;OAIG;aACH,eAAe;CACP,CAAC;AAEX;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB;IAC7B;;;OAGG;aACH,gBAAgB,EAAE,KAAK;IAEvB;;;OAGG;aACH,sBAAsB,EAAE,GAAG;IAE3B;;;OAGG;aACH,qBAAqB,EAAE,GAAG;CAClB,CAAC;AAGX,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAC7C,eAAO,MAAM,0BAA0B,UAEtC,CAAC;AACF,eAAO,MAAM,gCAAgC,MAAM,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { MarketCategory } from '../types/index.js';
2
- import { STRATEGY_ORDER_TYPES, TRIGGER_ORDER_TYPES, } from '../utils/orderTypes.js';
2
+ import { STRATEGY_ORDER_TYPES } from '../utils/orderTypes.js';
3
3
  import { PROVIDER_CONFIG } from './perpsConfig.js';
4
4
  // Network constants
5
5
  export const ARBITRUM_MAINNET_CHAIN_ID_HEX = '0xa4b1';
@@ -164,7 +164,7 @@ export const BUILDER_FEE_CONFIG = {
164
164
  .replace(/\.?0+$/u, '')}%`,
165
165
  };
166
166
  /**
167
- * Strategies and standalone trigger orders HyperLiquid executes for its markets.
167
+ * Strategies that HyperLiquid can execute for its routed perp markets.
168
168
  * Providers own this declaration so clients never infer support from a
169
169
  * provider name.
170
170
  */
@@ -172,20 +172,6 @@ export const HYPERLIQUID_ORDER_CAPABILITIES = Object.freeze({
172
172
  status: 'ready',
173
173
  providerId: PROVIDER_CONFIG.DefaultProvider,
174
174
  supportedStrategies: Object.freeze([...STRATEGY_ORDER_TYPES]),
175
- supportedTriggerOrderTypes: Object.freeze([...TRIGGER_ORDER_TYPES]),
176
- positionTpsl: Object.freeze({
177
- supportsExpectedPosition: true,
178
- childOrderIds: 'request-correlated',
179
- takeProfitOrderType: 'take_profit_limit',
180
- stopLossOrderType: 'stop_market',
181
- defaultCoverage: 'dynamic-position',
182
- partialCoverage: Object.freeze({
183
- single: true,
184
- pair: 'independent',
185
- replacement: 'cancel-before-create',
186
- recovery: 'provider-default',
187
- }),
188
- }),
189
175
  });
190
176
  // Referral code configuration
191
177
  export const REFERRAL_CONFIG = {
@@ -1 +1 @@
1
- {"version":3,"file":"hyperLiquidConfig.js","sourceRoot":"","sources":["../../src/constants/hyperLiquidConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAenD,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,oBAAoB;AACpB,MAAM,CAAC,MAAM,6BAA6B,GAAG,QAAiB,CAAC;AAC/D,MAAM,CAAC,MAAM,yBAAyB,GAAG,OAAO,CAAC;AACjD,MAAM,CAAC,MAAM,yBAAyB,GAAG,QAAQ,CAAC;AAClD,MAAM,CAAC,MAAM,8BAA8B,GAAG,UAAU,yBAAyB,EAAE,CAAC;AACpF,MAAM,CAAC,MAAM,8BAA8B,GAAG,UAAU,yBAAyB,EAAE,CAAC;AAEpF,8BAA8B;AAC9B,MAAM,CAAC,MAAM,4BAA4B,GAAG,OAAO,CAAC,CAAC,iBAAiB;AACtE,MAAM,CAAC,MAAM,4BAA4B,GAAG,OAAO,CAAC,CAAC,2BAA2B;AAChF,MAAM,CAAC,MAAM,iCAAiC,GAAG,YAA2B,CAAC;AAC7E,MAAM,CAAC,MAAM,iCAAiC,GAAG,YAA2B,CAAC;AAC7E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B,GAAG;IAChC;;;OAGG;IACH,gBAAgB,EAAE,KAAK;IAEvB;;;OAGG;IACH,sBAAsB,EAAE,GAAG;IAE3B;;;OAGG;IACH,qBAAqB,EAAE,GAAG;CAClB,CAAC;AAEX,yBAAyB;AACzB,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAC7C,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;CACvC,CAAC;AACF,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAG,CAAC","sourcesContent":["import type { CaipAssetId, CaipChainId, Hex } from '@metamask/utils';\n\nimport { MarketCategory } from '../types/index.js';\nimport type {\n DirectProviderOrderCapabilities,\n MarketType,\n} from '../types/index.js';\nimport type {\n HyperLiquidNetwork,\n HyperLiquidEndpoints,\n HyperLiquidAssetConfigs,\n BridgeContractConfig,\n HyperLiquidBridgeContracts,\n HyperLiquidTransportConfig,\n TradingDefaultsConfig,\n FeeRatesConfig,\n} from '../types/perps-types.js';\nimport {\n STRATEGY_ORDER_TYPES,\n TRIGGER_ORDER_TYPES,\n} from '../utils/orderTypes.js';\nimport { PROVIDER_CONFIG } from './perpsConfig.js';\n\n// Network constants\nexport const ARBITRUM_MAINNET_CHAIN_ID_HEX = '0xa4b1' as const;\nexport const ARBITRUM_MAINNET_CHAIN_ID = '42161';\nexport const ARBITRUM_TESTNET_CHAIN_ID = '421614';\nexport const ARBITRUM_MAINNET_CAIP_CHAIN_ID = `eip155:${ARBITRUM_MAINNET_CHAIN_ID}`;\nexport const ARBITRUM_TESTNET_CAIP_CHAIN_ID = `eip155:${ARBITRUM_TESTNET_CHAIN_ID}`;\n\n// Hyperliquid chain constants\nexport const HYPERLIQUID_MAINNET_CHAIN_ID = '0x3e7'; // 999 in decimal\nexport const HYPERLIQUID_TESTNET_CHAIN_ID = '0x3e6'; // 998 in decimal (assumed)\nexport const HYPERLIQUID_MAINNET_CAIP_CHAIN_ID = 'eip155:999' as CaipChainId;\nexport const HYPERLIQUID_TESTNET_CAIP_CHAIN_ID = 'eip155:998' as CaipChainId;\nexport const HYPERLIQUID_NETWORK_NAME = 'Hyperliquid';\n\n/**\n * Return the canonical snapshot identity: main first, then unique DEX ids.\n *\n * @param dexes - DEX identifiers to canonicalize.\n * @returns The canonical DEX identifiers.\n */\nexport function canonicalizeHyperLiquidDexes(\n dexes: Iterable<string>,\n): string[] {\n const additionalDexes = new Set(dexes);\n additionalDexes.delete('main');\n return ['main', ...Array.from(additionalDexes).sort()];\n}\n\n// Token constants\nexport const USDC_SYMBOL = 'USDC';\nexport const USDC_NAME = 'USD Coin';\nexport const USDC_DECIMALS = 6;\nexport const TOKEN_DECIMALS = 18;\n\n// Network constants\nexport const ARBITRUM_SEPOLIA_CHAIN_ID = '0x66eee'; // 421614 in decimal\n\n// USDC token addresses\nexport const USDC_ETHEREUM_MAINNET_ADDRESS =\n '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48';\nexport const USDC_ARBITRUM_MAINNET_ADDRESS =\n '0xaf88d065e77c8cC2239327C5EDb3A432268e5831';\nexport const USDC_ARBITRUM_TESTNET_ADDRESS =\n '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d';\n\n// USDC token icon URL using MetaMask's official Token Icons API\n// Format: https://static.cx.metamask.io/api/v1/tokenIcons/{chainId}/{contractAddress}.png\n// This URL follows the same pattern used throughout MetaMask (bridges, swaps, etc.)\nexport const USDC_TOKEN_ICON_URL = `https://static.cx.metamask.io/api/v1/tokenIcons/1/${USDC_ETHEREUM_MAINNET_ADDRESS}.png`;\n\n// WebSocket endpoints\nexport const HYPERLIQUID_ENDPOINTS: HyperLiquidEndpoints = {\n mainnet: 'wss://api.hyperliquid.xyz/ws',\n testnet: 'wss://api.hyperliquid-testnet.xyz/ws',\n};\n\n// Asset icons base URL (HyperLiquid CDN - fallback source)\nexport const HYPERLIQUID_ASSET_ICONS_BASE_URL =\n 'https://app.hyperliquid.xyz/coins/';\n\n// MetaMask-hosted Perps asset icons (primary source)\n// Assets uploaded to: https://github.com/MetaMask/contract-metadata/tree/master/icons/eip155:999\n// HIP-3 assets use format: hip3:dex_SYMBOL.svg (e.g., hip3:xyz_AAPL.svg)\n// Regular assets use format: SYMBOL.svg (e.g., BTC.svg)\nexport const METAMASK_PERPS_ICONS_BASE_URL =\n 'https://raw.githubusercontent.com/MetaMask/contract-metadata/master/icons/eip155:999/';\n\n// Asset configurations for multichain abstraction\nexport const HYPERLIQUID_ASSET_CONFIGS: HyperLiquidAssetConfigs = {\n usdc: {\n mainnet: `${ARBITRUM_MAINNET_CAIP_CHAIN_ID}/erc20:0xaf88d065e77c8cC2239327C5EDb3A432268e5831/default`,\n testnet: `${ARBITRUM_TESTNET_CAIP_CHAIN_ID}/erc20:0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d/default`,\n },\n};\n\n// HyperLiquid bridge contract addresses for direct USDC deposits\n// These are the official bridge contracts where USDC must be sent to credit user's HyperLiquid account\nexport const HYPERLIQUID_BRIDGE_CONTRACTS: HyperLiquidBridgeContracts = {\n mainnet: {\n chainId: ARBITRUM_MAINNET_CAIP_CHAIN_ID,\n contractAddress: '0x2df1c51e09aecf9cacb7bc98cb1742757f163df7',\n },\n testnet: {\n chainId: ARBITRUM_TESTNET_CAIP_CHAIN_ID,\n contractAddress: '0x08cfc1B6b2dCF36A1480b99353A354AA8AC56f89',\n },\n};\n\n// SDK transport configuration\nexport const HYPERLIQUID_TRANSPORT_CONFIG: HyperLiquidTransportConfig = {\n timeout: 10_000,\n keepAlive: { interval: 30_000 },\n reconnect: {\n maxRetries: 5,\n connectionTimeout: 10_000,\n },\n};\n\n// Trading configuration constants\nexport const TRADING_DEFAULTS: TradingDefaultsConfig = {\n leverage: 3, // 3x default leverage\n marginPercent: 10, // 10% fixed margin default\n takeProfitPercent: 0.3, // 30% take profit\n stopLossPercent: 0.1, // 10% stop loss\n amount: {\n mainnet: 10, // $10 minimum order size\n testnet: 10, // $10 minimum order size\n },\n};\n\n// Fee configuration\n// Note: These are base rates (Tier 0, no discounts)\n// Actual fees will be calculated based on user's volume tier and staking\nexport const FEE_RATES: FeeRatesConfig = {\n taker: 0.00045, // 0.045% - Market orders and aggressive limit orders\n maker: 0.00015, // 0.015% - Limit orders that add liquidity\n};\n\n/**\n * HIP-3 dynamic fee calculation configuration\n *\n * HIP-3 (builder-deployed) perpetual markets have variable fees based on:\n * 1. deployerFeeScale - Per-DEX fee multiplier (fetched from perpDexs API)\n * 2. growthMode - Per-asset 90% fee reduction (fetched from meta API)\n *\n * Fee Formula (from HyperLiquid docs):\n * - scaleIfHip3 = deployerFeeScale < 1 ? deployerFeeScale + 1 : deployerFeeScale * 2\n * - growthModeScale = growthMode ? 0.1 : 1\n * - finalRate = baseRate * scaleIfHip3 * growthModeScale\n *\n * Example: For xyz:TSLA with deployerFeeScale=1.0 and growthMode=\"enabled\":\n * - scaleIfHip3 = 1.0 * 2 = 2.0\n * - growthModeScale = 0.1 (90% reduction)\n * - Final multiplier = 2.0 * 0.1 = 0.2 (effectively 80% off standard 2x HIP-3 fees)\n *\n * @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees#fee-formula-for-developers\n * @see parseAssetName() in HyperLiquidProvider for HIP-3 asset detection\n */\nexport const HIP3_FEE_CONFIG = {\n /**\n * Growth Mode multiplier - 90% fee reduction for assets in growth phase\n * This is a protocol constant from HyperLiquid's fee formula\n */\n GrowthModeScale: 0.1,\n\n /**\n * Default deployerFeeScale when API is unavailable\n * Most HIP-3 DEXs use 1.0, which results in 2x base fees\n */\n DefaultDeployerFeeScale: 1.0,\n\n /**\n * Cache TTL for perpDexs data (5 minutes)\n * Fee scales rarely change, so longer cache is acceptable\n */\n PerpDexsCacheTtlMs: 5 * 60 * 1000,\n\n /**\n * @deprecated Use dynamic calculation via calculateHip3FeeMultiplier()\n * Kept for backwards compatibility during migration\n */\n FeeMultiplier: 2,\n} as const;\n\n/**\n * EIP-712 primary type of every HyperLiquid L1 action (orders, cancels,\n * leverage, ...). Only L1 actions may be signed by an agent; every other\n * request is a user-signed action for the main account.\n */\nexport const HYPERLIQUID_L1_ACTION_PRIMARY_TYPE = 'Agent';\n\n/**\n * EIP-712 domain name of every HyperLiquid L1 action.\n */\nexport const HYPERLIQUID_L1_ACTION_DOMAIN_NAME = 'Exchange';\n\nconst BUILDER_FEE_MAX_FEE_DECIMAL = 0.001;\n\n// Builder fee configuration\nexport const BUILDER_FEE_CONFIG = {\n // Test builder wallet\n TestnetBuilder: '0x724e57771ba749650875bd8adb2e29a85d0cacfa' as Hex,\n // Production builder wallet\n MainnetBuilder: '0xe95a5e31904e005066614247d309e00d8ad753aa' as Hex,\n // Fee in decimal (10 bp = 0.1%)\n MaxFeeDecimal: BUILDER_FEE_MAX_FEE_DECIMAL,\n MaxFeeTenthsBps: BUILDER_FEE_MAX_FEE_DECIMAL * 100000,\n MaxFeeRate: `${(BUILDER_FEE_MAX_FEE_DECIMAL * 100)\n .toFixed(4)\n .replace(/\\.?0+$/u, '')}%`,\n};\n\n/**\n * Strategies and standalone trigger orders HyperLiquid executes for its markets.\n * Providers own this declaration so clients never infer support from a\n * provider name.\n */\nexport const HYPERLIQUID_ORDER_CAPABILITIES = Object.freeze({\n status: 'ready',\n providerId: PROVIDER_CONFIG.DefaultProvider,\n supportedStrategies: Object.freeze([...STRATEGY_ORDER_TYPES]),\n supportedTriggerOrderTypes: Object.freeze([...TRIGGER_ORDER_TYPES]),\n positionTpsl: Object.freeze({\n supportsExpectedPosition: true,\n childOrderIds: 'request-correlated',\n takeProfitOrderType: 'take_profit_limit',\n stopLossOrderType: 'stop_market',\n defaultCoverage: 'dynamic-position',\n partialCoverage: Object.freeze({\n single: true,\n pair: 'independent',\n replacement: 'cancel-before-create',\n recovery: 'provider-default',\n }),\n }),\n}) satisfies DirectProviderOrderCapabilities;\n\n// Referral code configuration\nexport const REFERRAL_CONFIG = {\n // Production referral code\n MainnetCode: 'MMCSI',\n // Development/testnet referral code\n TestnetCode: 'MMCSITEST',\n};\n\n// Deposit constants\nexport const DEPOSIT_CONFIG = {\n EstimatedGasLimit: 100000, // Estimated gas limit for bridge deposit\n DefaultSlippage: 1, // 1% default slippage for bridge quotes\n BridgeQuoteTimeout: 1000, // 1 second timeout for bridge quotes\n RefreshRate: 30000, // 30 seconds quote refresh rate\n EstimatedTime: {\n DirectDeposit: '3-5 seconds', // Direct USDC deposit on Arbitrum\n SameChainSwap: '30-60 seconds', // Swap on same chain before deposit\n },\n};\n\n// Withdrawal constants (HyperLiquid-specific)\nexport const HYPERLIQUID_WITHDRAWAL_MINUTES = 5; // HyperLiquid withdrawal processing time in minutes\n\n// Type helpers\nexport type SupportedAsset = keyof typeof HYPERLIQUID_ASSET_CONFIGS;\n\n// Configuration helpers\nexport function getWebSocketEndpoint(isTestnet: boolean): string {\n return isTestnet\n ? HYPERLIQUID_ENDPOINTS.testnet\n : HYPERLIQUID_ENDPOINTS.mainnet;\n}\n\nexport function getChainId(isTestnet: boolean): string {\n return isTestnet ? ARBITRUM_TESTNET_CHAIN_ID : ARBITRUM_MAINNET_CHAIN_ID;\n}\n\nexport function getCaipChainId(isTestnet: boolean): CaipChainId {\n const network: HyperLiquidNetwork = isTestnet ? 'testnet' : 'mainnet';\n return HYPERLIQUID_BRIDGE_CONTRACTS[network].chainId;\n}\n\nexport function getBridgeInfo(isTestnet: boolean): BridgeContractConfig {\n const network: HyperLiquidNetwork = isTestnet ? 'testnet' : 'mainnet';\n return HYPERLIQUID_BRIDGE_CONTRACTS[network];\n}\n\nexport function getSupportedAssets(isTestnet?: boolean): CaipAssetId[] {\n const network = isTestnet ? 'testnet' : 'mainnet';\n return Object.values(HYPERLIQUID_ASSET_CONFIGS).map(\n (config) => config[network],\n );\n}\n\n// CAIP asset namespace constants\nexport const CAIP_ASSET_NAMESPACES = {\n Erc20: 'erc20',\n} as const;\n\n/**\n * HyperLiquid protocol-specific configuration\n * Contains constants specific to HyperLiquid's perps exchange\n */\nexport const HYPERLIQUID_CONFIG = {\n // Exchange name used in predicted funding data\n // HyperLiquid uses 'HlPerp' as their perps exchange identifier\n ExchangeName: 'HlPerp',\n // Maximum allowed deviation of the market (mid) price from the oracle (reference)\n // price before HyperLiquid rejects orders. HyperLiquid enforces \"Order price cannot\n // be more than 95% away from the reference price\", which makes markets — most often\n // HIP-3 builder-deployed ones — temporarily untradable when the mid price drifts past\n // this limit. Expressed as a decimal fraction (0.95 = 95%).\n // Protocol rule, not a UI warning threshold (see VALIDATION_THRESHOLDS.PriceDeviation).\n OraclePriceDeviationLimit: 0.95,\n} as const;\n\n/**\n * HIP-3 multi-DEX asset ID calculation constants\n * Per HIP-3-IMPLEMENTATION.md:\n * - Main DEX: assetId = index (0, 1, 2, ...)\n * - HIP-3 DEX: assetId = BASE_ASSET_ID + (perpDexIndex × DEX_MULTIPLIER) + index\n *\n * This formula enables proper order routing across multiple DEXs:\n * - Main DEX (perpDexIndex=0): Uses index directly (BTC=0, ETH=1, SOL=2, etc.)\n * - xyz DEX (perpDexIndex=1): 100000 + (1 × 10000) + index = 110000-110999\n * - abc DEX (perpDexIndex=2): 100000 + (2 × 10000) + index = 120000-120999\n *\n * Supports up to 10 HIP-3 DEXs with 10000 assets each.\n */\nexport const HIP3_ASSET_ID_CONFIG = {\n // Base offset for HIP-3 asset IDs (100000)\n // Ensures HIP-3 asset IDs don't conflict with main DEX indices\n BaseAssetId: 100000,\n\n // Multiplier for DEX index in asset ID calculation (10000)\n // Allocates 10000 asset ID slots per DEX (0-9999)\n DexMultiplier: 10000,\n} as const;\n\n/**\n * Basis points conversion constant\n * 1 basis point (bp) = 0.01% = 0.0001 as decimal\n * Used for fee discount calculations (e.g., 6500 bps = 65%)\n */\nexport const BASIS_POINTS_DIVISOR = 10000;\n\n/**\n * Offset added to spot market pair index to derive the spot asset ID\n * used in HyperLiquid order routing.\n * Per HyperLiquid protocol: spotAssetId = SPOT_ASSET_ID_OFFSET + pairIndex\n */\nexport const SPOT_ASSET_ID_OFFSET = 10000;\n\n/**\n * HIP-3 asset market type classifications (PRODUCTION DEFAULT)\n *\n * This is the production default configuration, can be overridden via feature flag\n * (remoteFeatureFlags.perpsAssetMarketTypes) for dynamic control.\n *\n * Maps asset symbols (e.g., \"xyz:TSLA\") to their market type for badge display.\n *\n * Market type determines the badge shown in the UI:\n * - 'stock': Individual stocks (TSLA, NVDA, AAPL, etc.)\n * - 'pre-ipo': Pre-IPO assets not yet publicly listed\n * - 'index': Market indices (SP500, JP225, VIX, etc.)\n * - 'etf': Exchange-traded funds (EWY, EWJ, USAR, etc.)\n * - 'commodity': Commodities (GOLD, SILVER, CL, etc.)\n * - 'forex': Forex pairs (EUR, JPY, DXY)\n * - 'crypto': Explicitly categorized crypto assets\n * - undefined: No badge for unmapped assets\n *\n * Format: 'dex:SYMBOL' → MarketType\n * This allows flexible per-asset classification.\n * Assets not listed here will have no market type (undefined).\n */\nexport const HIP3_ASSET_MARKET_TYPES: Record<string, MarketType> = {\n // xyz DEX - Stocks (US)\n 'xyz:TSLA': MarketCategory.Stock,\n 'xyz:NVDA': MarketCategory.Stock,\n 'xyz:INTC': MarketCategory.Stock,\n 'xyz:MU': MarketCategory.Stock,\n 'xyz:CRCL': MarketCategory.Stock,\n 'xyz:HOOD': MarketCategory.Stock,\n 'xyz:SNDK': MarketCategory.Stock,\n 'xyz:GOOGL': MarketCategory.Stock,\n 'xyz:COIN': MarketCategory.Stock,\n 'xyz:ORCL': MarketCategory.Stock,\n 'xyz:AMZN': MarketCategory.Stock,\n 'xyz:PLTR': MarketCategory.Stock,\n 'xyz:AAPL': MarketCategory.Stock,\n 'xyz:META': MarketCategory.Stock,\n 'xyz:AMD': MarketCategory.Stock,\n 'xyz:MSFT': MarketCategory.Stock,\n 'xyz:BABA': MarketCategory.Stock,\n 'xyz:RIVN': MarketCategory.Stock,\n 'xyz:NFLX': MarketCategory.Stock,\n 'xyz:COST': MarketCategory.Stock,\n 'xyz:LLY': MarketCategory.Stock,\n 'xyz:TSM': MarketCategory.Stock,\n 'xyz:MSTR': MarketCategory.Stock,\n 'xyz:CRWV': MarketCategory.Stock,\n 'xyz:GME': MarketCategory.Stock,\n 'xyz:HIMS': MarketCategory.Stock,\n 'xyz:USAR': MarketCategory.Stock,\n 'xyz:DKNG': MarketCategory.Stock,\n 'xyz:BIRD': MarketCategory.Stock,\n 'xyz:RKLB': MarketCategory.Stock,\n 'xyz:MRVL': MarketCategory.Stock,\n 'xyz:ZM': MarketCategory.Stock,\n 'xyz:EBAY': MarketCategory.Stock,\n 'xyz:PURRDAT': MarketCategory.Stock,\n 'xyz:ARM': MarketCategory.Stock,\n 'xyz:BX': MarketCategory.Stock,\n 'xyz:LITE': MarketCategory.Stock,\n 'xyz:CBRS': MarketCategory.Stock,\n 'xyz:SPCX': MarketCategory.Stock,\n\n // xyz DEX - Stocks (Korea)\n 'xyz:SKHX': MarketCategory.Stock,\n 'xyz:SMSN': MarketCategory.Stock,\n 'xyz:HYUNDAI': MarketCategory.Stock,\n\n // xyz DEX - Stocks (Japan)\n 'xyz:SOFTBANK': MarketCategory.Stock,\n 'xyz:KIOXIA': MarketCategory.Stock,\n\n // xyz DEX - Pre-IPO\n 'xyz:IPOP': MarketCategory.PreIpo,\n\n // xyz DEX - Indices\n 'xyz:SP500': MarketCategory.Index,\n 'xyz:XYZ100': MarketCategory.Index,\n 'xyz:JP225': MarketCategory.Index,\n 'xyz:KR200': MarketCategory.Index,\n 'xyz:VIX': MarketCategory.Index,\n\n // xyz DEX - ETFs\n 'xyz:EWY': MarketCategory.Etf,\n 'xyz:EWJ': MarketCategory.Etf,\n 'xyz:EWT': MarketCategory.Etf,\n 'xyz:EWZ': MarketCategory.Etf,\n 'xyz:URNM': MarketCategory.Etf,\n 'xyz:DRAM': MarketCategory.Etf,\n 'xyz:XLE': MarketCategory.Etf,\n\n // xyz DEX - Commodities\n 'xyz:GOLD': MarketCategory.Commodity,\n 'xyz:SILVER': MarketCategory.Commodity,\n 'xyz:CL': MarketCategory.Commodity,\n 'xyz:WTIOIL': MarketCategory.Commodity,\n 'xyz:COPPER': MarketCategory.Commodity,\n 'xyz:ALUMINIUM': MarketCategory.Commodity,\n 'xyz:URANIUM': MarketCategory.Commodity,\n 'xyz:NATGAS': MarketCategory.Commodity,\n 'xyz:PLATINUM': MarketCategory.Commodity,\n 'xyz:PALLADIUM': MarketCategory.Commodity,\n 'xyz:BRENTOIL': MarketCategory.Commodity,\n\n // xyz DEX - Forex\n 'xyz:EUR': MarketCategory.Forex,\n 'xyz:JPY': MarketCategory.Forex,\n 'xyz:GBP': MarketCategory.Forex,\n 'xyz:DXY': MarketCategory.Forex,\n};\n\n/**\n * Human-readable market names keyed by HyperLiquid asset symbol.\n *\n * HyperLiquid does NOT expose a human-readable name per market: the `meta`\n * universe only returns the ticker (`BTC`, `xyz:TSLA`), and `perpDexs` only\n * exposes a `fullName` for the DEX/venue, not the individual asset. This map is\n * therefore maintained client-side so that clients (mobile, extension) can:\n * - match markets by full name in search (\"Bitcoin\", \"Apple\", \"Gold\"), and\n * - display the full name alongside / instead of the ticker.\n *\n * Keys follow the same convention as {@link HIP3_ASSET_MARKET_TYPES}: bare\n * `SYMBOL` for main-DEX crypto and `dex:SYMBOL` for HIP-3 markets. Use\n * {@link getHyperLiquidAssetName} to resolve a name with a safe fallback to the\n * ticker for unmapped assets.\n *\n * This list is intentionally curated (not exhaustive): unmapped assets simply\n * fall back to their ticker, which matches prior behavior. Add entries as needed.\n */\nexport const HYPERLIQUID_ASSET_NAMES: Record<string, string> = {\n // Main DEX - Crypto majors\n BTC: 'Bitcoin',\n ETH: 'Ethereum',\n SOL: 'Solana',\n XRP: 'XRP',\n BNB: 'BNB',\n DOGE: 'Dogecoin',\n ADA: 'Cardano',\n AVAX: 'Avalanche',\n LINK: 'Chainlink',\n LTC: 'Litecoin',\n DOT: 'Polkadot',\n BCH: 'Bitcoin Cash',\n TRX: 'TRON',\n MATIC: 'Polygon',\n ARB: 'Arbitrum',\n OP: 'Optimism',\n SUI: 'Sui',\n APT: 'Aptos',\n ATOM: 'Cosmos',\n NEAR: 'NEAR Protocol',\n INJ: 'Injective',\n TIA: 'Celestia',\n SEI: 'Sei',\n UNI: 'Uniswap',\n AAVE: 'Aave',\n MKR: 'Maker',\n CRV: 'Curve DAO',\n LDO: 'Lido DAO',\n PEPE: 'Pepe',\n WIF: 'dogwifhat',\n BONK: 'Bonk',\n SHIB: 'Shiba Inu',\n ETC: 'Ethereum Classic',\n FIL: 'Filecoin',\n HBAR: 'Hedera',\n ICP: 'Internet Computer',\n STX: 'Stacks',\n RUNE: 'THORChain',\n TON: 'Toncoin',\n KAS: 'Kaspa',\n FET: 'Fetch.ai',\n ENA: 'Ethena',\n JUP: 'Jupiter',\n PYTH: 'Pyth Network',\n JTO: 'Jito',\n STRK: 'Starknet',\n BLUR: 'Blur',\n GMX: 'GMX',\n DYDX: 'dYdX',\n HYPE: 'Hyperliquid',\n\n // xyz DEX - Stocks (US)\n 'xyz:TSLA': 'Tesla',\n 'xyz:NVDA': 'NVIDIA',\n 'xyz:INTC': 'Intel',\n 'xyz:MU': 'Micron Technology',\n 'xyz:CRCL': 'Circle',\n 'xyz:HOOD': 'Robinhood',\n 'xyz:SNDK': 'SanDisk',\n 'xyz:GOOGL': 'Alphabet (Google)',\n 'xyz:COIN': 'Coinbase',\n 'xyz:ORCL': 'Oracle',\n 'xyz:AMZN': 'Amazon',\n 'xyz:PLTR': 'Palantir',\n 'xyz:AAPL': 'Apple',\n 'xyz:META': 'Meta Platforms',\n 'xyz:AMD': 'AMD',\n 'xyz:MSFT': 'Microsoft',\n 'xyz:BABA': 'Alibaba',\n 'xyz:RIVN': 'Rivian',\n 'xyz:NFLX': 'Netflix',\n 'xyz:COST': 'Costco',\n 'xyz:LLY': 'Eli Lilly',\n 'xyz:TSM': 'Taiwan Semiconductor',\n 'xyz:MSTR': 'Strategy (MicroStrategy)',\n 'xyz:CRWV': 'CoreWeave',\n 'xyz:GME': 'GameStop',\n 'xyz:HIMS': 'Hims & Hers',\n 'xyz:USAR': 'USA Rare Earth',\n 'xyz:DKNG': 'DraftKings',\n 'xyz:RKLB': 'Rocket Lab',\n 'xyz:MRVL': 'Marvell',\n 'xyz:ZM': 'Zoom',\n 'xyz:EBAY': 'eBay',\n 'xyz:ARM': 'Arm Holdings',\n 'xyz:BX': 'Blackstone',\n 'xyz:LITE': 'Lumentum',\n\n // xyz DEX - Stocks (Korea)\n 'xyz:SKHX': 'SK Hynix',\n 'xyz:SMSN': 'Samsung Electronics',\n 'xyz:HYUNDAI': 'Hyundai Motor',\n\n // xyz DEX - Stocks (Japan)\n 'xyz:SOFTBANK': 'SoftBank Group',\n 'xyz:KIOXIA': 'Kioxia',\n\n // xyz DEX - Pre-IPO\n 'xyz:SPCX': 'SpaceX',\n 'xyz:CBRS': 'Cerebras',\n 'xyz:IPOP': 'Quantinuum',\n\n // xyz DEX - Indices\n 'xyz:SP500': 'S&P 500',\n 'xyz:JP225': 'Nikkei 225',\n 'xyz:KR200': 'KOSPI 200',\n 'xyz:VIX': 'CBOE Volatility Index',\n\n // xyz DEX - ETFs\n 'xyz:EWY': 'iShares MSCI South Korea ETF',\n 'xyz:EWJ': 'iShares MSCI Japan ETF',\n 'xyz:EWT': 'iShares MSCI Taiwan ETF',\n 'xyz:EWZ': 'iShares MSCI Brazil ETF',\n 'xyz:URNM': 'Sprott Uranium Miners ETF',\n 'xyz:XLE': 'Energy Select Sector SPDR Fund',\n\n // xyz DEX - Commodities\n 'xyz:GOLD': 'Gold',\n 'xyz:SILVER': 'Silver',\n 'xyz:CL': 'Crude Oil',\n 'xyz:WTIOIL': 'WTI Crude Oil',\n 'xyz:COPPER': 'Copper',\n 'xyz:ALUMINIUM': 'Aluminium',\n 'xyz:URANIUM': 'Uranium',\n 'xyz:NATGAS': 'Natural Gas',\n 'xyz:PLATINUM': 'Platinum',\n 'xyz:PALLADIUM': 'Palladium',\n 'xyz:BRENTOIL': 'Brent Crude Oil',\n\n // xyz DEX - Forex\n 'xyz:EUR': 'Euro',\n 'xyz:JPY': 'Japanese Yen',\n 'xyz:GBP': 'British Pound',\n 'xyz:DXY': 'US Dollar Index',\n};\n\n/**\n * Resolve the human-readable name for a HyperLiquid market.\n *\n * Falls back to the ticker symbol when the asset is not present in\n * {@link HYPERLIQUID_ASSET_NAMES}, so callers always receive a displayable\n * string and unmapped assets keep their prior behavior.\n *\n * @param symbol - HyperLiquid asset symbol (bare `SYMBOL` for main-DEX crypto,\n * `dex:SYMBOL` for HIP-3 markets).\n * @param names - Name map to look up against (defaults to the bundled\n * {@link HYPERLIQUID_ASSET_NAMES}); injectable for testing/overrides.\n * @returns The human-readable name, or the symbol itself when unmapped.\n */\nexport function getHyperLiquidAssetName(\n symbol: string,\n names: Record<string, string> = HYPERLIQUID_ASSET_NAMES,\n): string {\n return names[symbol] ?? symbol;\n}\n\n/**\n * Testnet-specific HIP-3 DEX configuration\n *\n * On testnet, there are many HIP-3 DEXs (test deployments from various builders).\n * Subscribing to all of them causes connection/subscription overload and instability.\n * This configuration limits which DEXs are discovered and subscribed to on testnet.\n */\nexport const TESTNET_HIP3_CONFIG = {\n /**\n * Allowed DEX names for testnet\n * Empty array = main DEX only (no HIP-3 DEXs)\n * Add specific DEX names to test with particular HIP-3 DEXs: ['testdex1', 'testdex2']\n */\n EnabledDexs: ['xyz'] as string[],\n\n /**\n * Set to true to enable full HIP-3 discovery on testnet (not recommended)\n * When false, only DEXs in ENABLED_DEXS are used\n */\n AutoDiscoverAll: false,\n} as const;\n\n/**\n * Mainnet-specific HIP-3 DEX configuration\n *\n * On mainnet, DEX filtering is dynamically determined from the allowlist markets\n * feature flag. This avoids hardcoding DEX names and ensures consistency with\n * the market filtering logic.\n *\n * When AutoDiscoverAll is false and no allowlist is provided, only the main DEX is used.\n * When an allowlist is provided, DEXs are extracted from the allowlist patterns.\n */\nexport const MAINNET_HIP3_CONFIG = {\n /**\n * Set to true to enable full HIP-3 discovery on mainnet\n * When false, DEXs are filtered based on the allowlist markets feature flag\n * (recommended for production to reduce subscription overhead)\n */\n AutoDiscoverAll: false,\n} as const;\n\n/**\n * HIP-3 margin management configuration\n * Controls margin buffers and auto-rebalance behavior for HIP-3 DEXes with isolated margin\n *\n * Background: HyperLiquid validates spendableBalance >= totalRequiredMargin BEFORE reallocating\n * existing locked margin. This requires temporary over-funding when increasing positions,\n * followed by automatic cleanup to minimize locked capital.\n */\nexport const HIP3_MARGIN_CONFIG = {\n /**\n * Margin buffer multiplier for fees and slippage (0.3% = multiply by 1.003)\n * Covers HyperLiquid's max taker fee (0.035%) with comfortable margin\n */\n BufferMultiplier: 1.003,\n\n /**\n * Desired buffer to keep on HIP-3 DEX after auto-rebalance (USDC amount)\n * Small buffer allows quick follow-up orders without transfers\n */\n RebalanceDesiredBuffer: 0.1,\n\n /**\n * Minimum excess threshold to trigger auto-rebalance (USDC amount)\n * Prevents unnecessary transfers for tiny amounts\n */\n RebalanceMinThreshold: 0.1,\n} as const;\n\n// Progress bar constants\nexport const INITIAL_AMOUNT_UI_PROGRESS = 10;\nexport const WITHDRAWAL_PROGRESS_STAGES = [\n 25, 35, 45, 55, 65, 75, 85, 90, 95, 98,\n];\nexport const PROGRESS_BAR_COMPLETION_DELAY_MS = 500;\n"]}
1
+ {"version":3,"file":"hyperLiquidConfig.js","sourceRoot":"","sources":["../../src/constants/hyperLiquidConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAenD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,oBAAoB;AACpB,MAAM,CAAC,MAAM,6BAA6B,GAAG,QAAiB,CAAC;AAC/D,MAAM,CAAC,MAAM,yBAAyB,GAAG,OAAO,CAAC;AACjD,MAAM,CAAC,MAAM,yBAAyB,GAAG,QAAQ,CAAC;AAClD,MAAM,CAAC,M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;OAGG;IACH,sBAAsB,EAAE,GAAG;IAE3B;;;OAGG;IACH,qBAAqB,EAAE,GAAG;CAClB,CAAC;AAEX,yBAAyB;AACzB,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAC7C,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;CACvC,CAAC;AACF,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAG,CAAC","sourcesContent":["import type { CaipAssetId, CaipChainId, Hex } from '@metamask/utils';\n\nimport { MarketCategory } from '../types/index.js';\nimport type {\n DirectProviderOrderCapabilities,\n MarketType,\n} from '../types/index.js';\nimport type {\n HyperLiquidNetwork,\n HyperLiquidEndpoints,\n HyperLiquidAssetConfigs,\n BridgeContractConfig,\n HyperLiquidBridgeContracts,\n HyperLiquidTransportConfig,\n TradingDefaultsConfig,\n FeeRatesConfig,\n} from '../types/perps-types.js';\nimport { STRATEGY_ORDER_TYPES } from '../utils/orderTypes.js';\nimport { PROVIDER_CONFIG } from './perpsConfig.js';\n\n// Network constants\nexport const ARBITRUM_MAINNET_CHAIN_ID_HEX = '0xa4b1' as const;\nexport const ARBITRUM_MAINNET_CHAIN_ID = '42161';\nexport const ARBITRUM_TESTNET_CHAIN_ID = '421614';\nexport const ARBITRUM_MAINNET_CAIP_CHAIN_ID = `eip155:${ARBITRUM_MAINNET_CHAIN_ID}`;\nexport const ARBITRUM_TESTNET_CAIP_CHAIN_ID = `eip155:${ARBITRUM_TESTNET_CHAIN_ID}`;\n\n// Hyperliquid chain constants\nexport const HYPERLIQUID_MAINNET_CHAIN_ID = '0x3e7'; // 999 in decimal\nexport const HYPERLIQUID_TESTNET_CHAIN_ID = '0x3e6'; // 998 in decimal (assumed)\nexport const HYPERLIQUID_MAINNET_CAIP_CHAIN_ID = 'eip155:999' as CaipChainId;\nexport const HYPERLIQUID_TESTNET_CAIP_CHAIN_ID = 'eip155:998' as CaipChainId;\nexport const HYPERLIQUID_NETWORK_NAME = 'Hyperliquid';\n\n/**\n * Return the canonical snapshot identity: main first, then unique DEX ids.\n *\n * @param dexes - DEX identifiers to canonicalize.\n * @returns The canonical DEX identifiers.\n */\nexport function canonicalizeHyperLiquidDexes(\n dexes: Iterable<string>,\n): string[] {\n const additionalDexes = new Set(dexes);\n additionalDexes.delete('main');\n return ['main', ...Array.from(additionalDexes).sort()];\n}\n\n// Token constants\nexport const USDC_SYMBOL = 'USDC';\nexport const USDC_NAME = 'USD Coin';\nexport const USDC_DECIMALS = 6;\nexport const TOKEN_DECIMALS = 18;\n\n// Network constants\nexport const ARBITRUM_SEPOLIA_CHAIN_ID = '0x66eee'; // 421614 in decimal\n\n// USDC token addresses\nexport const USDC_ETHEREUM_MAINNET_ADDRESS =\n '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48';\nexport const USDC_ARBITRUM_MAINNET_ADDRESS =\n '0xaf88d065e77c8cC2239327C5EDb3A432268e5831';\nexport const USDC_ARBITRUM_TESTNET_ADDRESS =\n '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d';\n\n// USDC token icon URL using MetaMask's official Token Icons API\n// Format: https://static.cx.metamask.io/api/v1/tokenIcons/{chainId}/{contractAddress}.png\n// This URL follows the same pattern used throughout MetaMask (bridges, swaps, etc.)\nexport const USDC_TOKEN_ICON_URL = `https://static.cx.metamask.io/api/v1/tokenIcons/1/${USDC_ETHEREUM_MAINNET_ADDRESS}.png`;\n\n// WebSocket endpoints\nexport const HYPERLIQUID_ENDPOINTS: HyperLiquidEndpoints = {\n mainnet: 'wss://api.hyperliquid.xyz/ws',\n testnet: 'wss://api.hyperliquid-testnet.xyz/ws',\n};\n\n// Asset icons base URL (HyperLiquid CDN - fallback source)\nexport const HYPERLIQUID_ASSET_ICONS_BASE_URL =\n 'https://app.hyperliquid.xyz/coins/';\n\n// MetaMask-hosted Perps asset icons (primary source)\n// Assets uploaded to: https://github.com/MetaMask/contract-metadata/tree/master/icons/eip155:999\n// HIP-3 assets use format: hip3:dex_SYMBOL.svg (e.g., hip3:xyz_AAPL.svg)\n// Regular assets use format: SYMBOL.svg (e.g., BTC.svg)\nexport const METAMASK_PERPS_ICONS_BASE_URL =\n 'https://raw.githubusercontent.com/MetaMask/contract-metadata/master/icons/eip155:999/';\n\n// Asset configurations for multichain abstraction\nexport const HYPERLIQUID_ASSET_CONFIGS: HyperLiquidAssetConfigs = {\n usdc: {\n mainnet: `${ARBITRUM_MAINNET_CAIP_CHAIN_ID}/erc20:0xaf88d065e77c8cC2239327C5EDb3A432268e5831/default`,\n testnet: `${ARBITRUM_TESTNET_CAIP_CHAIN_ID}/erc20:0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d/default`,\n },\n};\n\n// HyperLiquid bridge contract addresses for direct USDC deposits\n// These are the official bridge contracts where USDC must be sent to credit user's HyperLiquid account\nexport const HYPERLIQUID_BRIDGE_CONTRACTS: HyperLiquidBridgeContracts = {\n mainnet: {\n chainId: ARBITRUM_MAINNET_CAIP_CHAIN_ID,\n contractAddress: '0x2df1c51e09aecf9cacb7bc98cb1742757f163df7',\n },\n testnet: {\n chainId: ARBITRUM_TESTNET_CAIP_CHAIN_ID,\n contractAddress: '0x08cfc1B6b2dCF36A1480b99353A354AA8AC56f89',\n },\n};\n\n// SDK transport configuration\nexport const HYPERLIQUID_TRANSPORT_CONFIG: HyperLiquidTransportConfig = {\n timeout: 10_000,\n keepAlive: { interval: 30_000 },\n reconnect: {\n maxRetries: 5,\n connectionTimeout: 10_000,\n },\n};\n\n// Trading configuration constants\nexport const TRADING_DEFAULTS: TradingDefaultsConfig = {\n leverage: 3, // 3x default leverage\n marginPercent: 10, // 10% fixed margin default\n takeProfitPercent: 0.3, // 30% take profit\n stopLossPercent: 0.1, // 10% stop loss\n amount: {\n mainnet: 10, // $10 minimum order size\n testnet: 10, // $10 minimum order size\n },\n};\n\n// Fee configuration\n// Note: These are base rates (Tier 0, no discounts)\n// Actual fees will be calculated based on user's volume tier and staking\nexport const FEE_RATES: FeeRatesConfig = {\n taker: 0.00045, // 0.045% - Market orders and aggressive limit orders\n maker: 0.00015, // 0.015% - Limit orders that add liquidity\n};\n\n/**\n * HIP-3 dynamic fee calculation configuration\n *\n * HIP-3 (builder-deployed) perpetual markets have variable fees based on:\n * 1. deployerFeeScale - Per-DEX fee multiplier (fetched from perpDexs API)\n * 2. growthMode - Per-asset 90% fee reduction (fetched from meta API)\n *\n * Fee Formula (from HyperLiquid docs):\n * - scaleIfHip3 = deployerFeeScale < 1 ? deployerFeeScale + 1 : deployerFeeScale * 2\n * - growthModeScale = growthMode ? 0.1 : 1\n * - finalRate = baseRate * scaleIfHip3 * growthModeScale\n *\n * Example: For xyz:TSLA with deployerFeeScale=1.0 and growthMode=\"enabled\":\n * - scaleIfHip3 = 1.0 * 2 = 2.0\n * - growthModeScale = 0.1 (90% reduction)\n * - Final multiplier = 2.0 * 0.1 = 0.2 (effectively 80% off standard 2x HIP-3 fees)\n *\n * @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees#fee-formula-for-developers\n * @see parseAssetName() in HyperLiquidProvider for HIP-3 asset detection\n */\nexport const HIP3_FEE_CONFIG = {\n /**\n * Growth Mode multiplier - 90% fee reduction for assets in growth phase\n * This is a protocol constant from HyperLiquid's fee formula\n */\n GrowthModeScale: 0.1,\n\n /**\n * Default deployerFeeScale when API is unavailable\n * Most HIP-3 DEXs use 1.0, which results in 2x base fees\n */\n DefaultDeployerFeeScale: 1.0,\n\n /**\n * Cache TTL for perpDexs data (5 minutes)\n * Fee scales rarely change, so longer cache is acceptable\n */\n PerpDexsCacheTtlMs: 5 * 60 * 1000,\n\n /**\n * @deprecated Use dynamic calculation via calculateHip3FeeMultiplier()\n * Kept for backwards compatibility during migration\n */\n FeeMultiplier: 2,\n} as const;\n\n/**\n * EIP-712 primary type of every HyperLiquid L1 action (orders, cancels,\n * leverage, ...). Only L1 actions may be signed by an agent; every other\n * request is a user-signed action for the main account.\n */\nexport const HYPERLIQUID_L1_ACTION_PRIMARY_TYPE = 'Agent';\n\n/**\n * EIP-712 domain name of every HyperLiquid L1 action.\n */\nexport const HYPERLIQUID_L1_ACTION_DOMAIN_NAME = 'Exchange';\n\nconst BUILDER_FEE_MAX_FEE_DECIMAL = 0.001;\n\n// Builder fee configuration\nexport const BUILDER_FEE_CONFIG = {\n // Test builder wallet\n TestnetBuilder: '0x724e57771ba749650875bd8adb2e29a85d0cacfa' as Hex,\n // Production builder wallet\n MainnetBuilder: '0xe95a5e31904e005066614247d309e00d8ad753aa' as Hex,\n // Fee in decimal (10 bp = 0.1%)\n MaxFeeDecimal: BUILDER_FEE_MAX_FEE_DECIMAL,\n MaxFeeTenthsBps: BUILDER_FEE_MAX_FEE_DECIMAL * 100000,\n MaxFeeRate: `${(BUILDER_FEE_MAX_FEE_DECIMAL * 100)\n .toFixed(4)\n .replace(/\\.?0+$/u, '')}%`,\n};\n\n/**\n * Strategies that HyperLiquid can execute for its routed perp markets.\n * Providers own this declaration so clients never infer support from a\n * provider name.\n */\nexport const HYPERLIQUID_ORDER_CAPABILITIES = Object.freeze({\n status: 'ready',\n providerId: PROVIDER_CONFIG.DefaultProvider,\n supportedStrategies: Object.freeze([...STRATEGY_ORDER_TYPES]),\n}) satisfies DirectProviderOrderCapabilities;\n\n// Referral code configuration\nexport const REFERRAL_CONFIG = {\n // Production referral code\n MainnetCode: 'MMCSI',\n // Development/testnet referral code\n TestnetCode: 'MMCSITEST',\n};\n\n// Deposit constants\nexport const DEPOSIT_CONFIG = {\n EstimatedGasLimit: 100000, // Estimated gas limit for bridge deposit\n DefaultSlippage: 1, // 1% default slippage for bridge quotes\n BridgeQuoteTimeout: 1000, // 1 second timeout for bridge quotes\n RefreshRate: 30000, // 30 seconds quote refresh rate\n EstimatedTime: {\n DirectDeposit: '3-5 seconds', // Direct USDC deposit on Arbitrum\n SameChainSwap: '30-60 seconds', // Swap on same chain before deposit\n },\n};\n\n// Withdrawal constants (HyperLiquid-specific)\nexport const HYPERLIQUID_WITHDRAWAL_MINUTES = 5; // HyperLiquid withdrawal processing time in minutes\n\n// Type helpers\nexport type SupportedAsset = keyof typeof HYPERLIQUID_ASSET_CONFIGS;\n\n// Configuration helpers\nexport function getWebSocketEndpoint(isTestnet: boolean): string {\n return isTestnet\n ? HYPERLIQUID_ENDPOINTS.testnet\n : HYPERLIQUID_ENDPOINTS.mainnet;\n}\n\nexport function getChainId(isTestnet: boolean): string {\n return isTestnet ? ARBITRUM_TESTNET_CHAIN_ID : ARBITRUM_MAINNET_CHAIN_ID;\n}\n\nexport function getCaipChainId(isTestnet: boolean): CaipChainId {\n const network: HyperLiquidNetwork = isTestnet ? 'testnet' : 'mainnet';\n return HYPERLIQUID_BRIDGE_CONTRACTS[network].chainId;\n}\n\nexport function getBridgeInfo(isTestnet: boolean): BridgeContractConfig {\n const network: HyperLiquidNetwork = isTestnet ? 'testnet' : 'mainnet';\n return HYPERLIQUID_BRIDGE_CONTRACTS[network];\n}\n\nexport function getSupportedAssets(isTestnet?: boolean): CaipAssetId[] {\n const network = isTestnet ? 'testnet' : 'mainnet';\n return Object.values(HYPERLIQUID_ASSET_CONFIGS).map(\n (config) => config[network],\n );\n}\n\n// CAIP asset namespace constants\nexport const CAIP_ASSET_NAMESPACES = {\n Erc20: 'erc20',\n} as const;\n\n/**\n * HyperLiquid protocol-specific configuration\n * Contains constants specific to HyperLiquid's perps exchange\n */\nexport const HYPERLIQUID_CONFIG = {\n // Exchange name used in predicted funding data\n // HyperLiquid uses 'HlPerp' as their perps exchange identifier\n ExchangeName: 'HlPerp',\n // Maximum allowed deviation of the market (mid) price from the oracle (reference)\n // price before HyperLiquid rejects orders. HyperLiquid enforces \"Order price cannot\n // be more than 95% away from the reference price\", which makes markets — most often\n // HIP-3 builder-deployed ones — temporarily untradable when the mid price drifts past\n // this limit. Expressed as a decimal fraction (0.95 = 95%).\n // Protocol rule, not a UI warning threshold (see VALIDATION_THRESHOLDS.PriceDeviation).\n OraclePriceDeviationLimit: 0.95,\n} as const;\n\n/**\n * HIP-3 multi-DEX asset ID calculation constants\n * Per HIP-3-IMPLEMENTATION.md:\n * - Main DEX: assetId = index (0, 1, 2, ...)\n * - HIP-3 DEX: assetId = BASE_ASSET_ID + (perpDexIndex × DEX_MULTIPLIER) + index\n *\n * This formula enables proper order routing across multiple DEXs:\n * - Main DEX (perpDexIndex=0): Uses index directly (BTC=0, ETH=1, SOL=2, etc.)\n * - xyz DEX (perpDexIndex=1): 100000 + (1 × 10000) + index = 110000-110999\n * - abc DEX (perpDexIndex=2): 100000 + (2 × 10000) + index = 120000-120999\n *\n * Supports up to 10 HIP-3 DEXs with 10000 assets each.\n */\nexport const HIP3_ASSET_ID_CONFIG = {\n // Base offset for HIP-3 asset IDs (100000)\n // Ensures HIP-3 asset IDs don't conflict with main DEX indices\n BaseAssetId: 100000,\n\n // Multiplier for DEX index in asset ID calculation (10000)\n // Allocates 10000 asset ID slots per DEX (0-9999)\n DexMultiplier: 10000,\n} as const;\n\n/**\n * Basis points conversion constant\n * 1 basis point (bp) = 0.01% = 0.0001 as decimal\n * Used for fee discount calculations (e.g., 6500 bps = 65%)\n */\nexport const BASIS_POINTS_DIVISOR = 10000;\n\n/**\n * Offset added to spot market pair index to derive the spot asset ID\n * used in HyperLiquid order routing.\n * Per HyperLiquid protocol: spotAssetId = SPOT_ASSET_ID_OFFSET + pairIndex\n */\nexport const SPOT_ASSET_ID_OFFSET = 10000;\n\n/**\n * HIP-3 asset market type classifications (PRODUCTION DEFAULT)\n *\n * This is the production default configuration, can be overridden via feature flag\n * (remoteFeatureFlags.perpsAssetMarketTypes) for dynamic control.\n *\n * Maps asset symbols (e.g., \"xyz:TSLA\") to their market type for badge display.\n *\n * Market type determines the badge shown in the UI:\n * - 'stock': Individual stocks (TSLA, NVDA, AAPL, etc.)\n * - 'pre-ipo': Pre-IPO assets not yet publicly listed\n * - 'index': Market indices (SP500, JP225, VIX, etc.)\n * - 'etf': Exchange-traded funds (EWY, EWJ, USAR, etc.)\n * - 'commodity': Commodities (GOLD, SILVER, CL, etc.)\n * - 'forex': Forex pairs (EUR, JPY, DXY)\n * - 'crypto': Explicitly categorized crypto assets\n * - undefined: No badge for unmapped assets\n *\n * Format: 'dex:SYMBOL' → MarketType\n * This allows flexible per-asset classification.\n * Assets not listed here will have no market type (undefined).\n */\nexport const HIP3_ASSET_MARKET_TYPES: Record<string, MarketType> = {\n // xyz DEX - Stocks (US)\n 'xyz:TSLA': MarketCategory.Stock,\n 'xyz:NVDA': MarketCategory.Stock,\n 'xyz:INTC': MarketCategory.Stock,\n 'xyz:MU': MarketCategory.Stock,\n 'xyz:CRCL': MarketCategory.Stock,\n 'xyz:HOOD': MarketCategory.Stock,\n 'xyz:SNDK': MarketCategory.Stock,\n 'xyz:GOOGL': MarketCategory.Stock,\n 'xyz:COIN': MarketCategory.Stock,\n 'xyz:ORCL': MarketCategory.Stock,\n 'xyz:AMZN': MarketCategory.Stock,\n 'xyz:PLTR': MarketCategory.Stock,\n 'xyz:AAPL': MarketCategory.Stock,\n 'xyz:META': MarketCategory.Stock,\n 'xyz:AMD': MarketCategory.Stock,\n 'xyz:MSFT': MarketCategory.Stock,\n 'xyz:BABA': MarketCategory.Stock,\n 'xyz:RIVN': MarketCategory.Stock,\n 'xyz:NFLX': MarketCategory.Stock,\n 'xyz:COST': MarketCategory.Stock,\n 'xyz:LLY': MarketCategory.Stock,\n 'xyz:TSM': MarketCategory.Stock,\n 'xyz:MSTR': MarketCategory.Stock,\n 'xyz:CRWV': MarketCategory.Stock,\n 'xyz:GME': MarketCategory.Stock,\n 'xyz:HIMS': MarketCategory.Stock,\n 'xyz:USAR': MarketCategory.Stock,\n 'xyz:DKNG': MarketCategory.Stock,\n 'xyz:BIRD': MarketCategory.Stock,\n 'xyz:RKLB': MarketCategory.Stock,\n 'xyz:MRVL': MarketCategory.Stock,\n 'xyz:ZM': MarketCategory.Stock,\n 'xyz:EBAY': MarketCategory.Stock,\n 'xyz:PURRDAT': MarketCategory.Stock,\n 'xyz:ARM': MarketCategory.Stock,\n 'xyz:BX': MarketCategory.Stock,\n 'xyz:LITE': MarketCategory.Stock,\n 'xyz:CBRS': MarketCategory.Stock,\n 'xyz:SPCX': MarketCategory.Stock,\n\n // xyz DEX - Stocks (Korea)\n 'xyz:SKHX': MarketCategory.Stock,\n 'xyz:SMSN': MarketCategory.Stock,\n 'xyz:HYUNDAI': MarketCategory.Stock,\n\n // xyz DEX - Stocks (Japan)\n 'xyz:SOFTBANK': MarketCategory.Stock,\n 'xyz:KIOXIA': MarketCategory.Stock,\n\n // xyz DEX - Pre-IPO\n 'xyz:IPOP': MarketCategory.PreIpo,\n\n // xyz DEX - Indices\n 'xyz:SP500': MarketCategory.Index,\n 'xyz:XYZ100': MarketCategory.Index,\n 'xyz:JP225': MarketCategory.Index,\n 'xyz:KR200': MarketCategory.Index,\n 'xyz:VIX': MarketCategory.Index,\n\n // xyz DEX - ETFs\n 'xyz:EWY': MarketCategory.Etf,\n 'xyz:EWJ': MarketCategory.Etf,\n 'xyz:EWT': MarketCategory.Etf,\n 'xyz:EWZ': MarketCategory.Etf,\n 'xyz:URNM': MarketCategory.Etf,\n 'xyz:DRAM': MarketCategory.Etf,\n 'xyz:XLE': MarketCategory.Etf,\n\n // xyz DEX - Commodities\n 'xyz:GOLD': MarketCategory.Commodity,\n 'xyz:SILVER': MarketCategory.Commodity,\n 'xyz:CL': MarketCategory.Commodity,\n 'xyz:WTIOIL': MarketCategory.Commodity,\n 'xyz:COPPER': MarketCategory.Commodity,\n 'xyz:ALUMINIUM': MarketCategory.Commodity,\n 'xyz:URANIUM': MarketCategory.Commodity,\n 'xyz:NATGAS': MarketCategory.Commodity,\n 'xyz:PLATINUM': MarketCategory.Commodity,\n 'xyz:PALLADIUM': MarketCategory.Commodity,\n 'xyz:BRENTOIL': MarketCategory.Commodity,\n\n // xyz DEX - Forex\n 'xyz:EUR': MarketCategory.Forex,\n 'xyz:JPY': MarketCategory.Forex,\n 'xyz:GBP': MarketCategory.Forex,\n 'xyz:DXY': MarketCategory.Forex,\n};\n\n/**\n * Human-readable market names keyed by HyperLiquid asset symbol.\n *\n * HyperLiquid does NOT expose a human-readable name per market: the `meta`\n * universe only returns the ticker (`BTC`, `xyz:TSLA`), and `perpDexs` only\n * exposes a `fullName` for the DEX/venue, not the individual asset. This map is\n * therefore maintained client-side so that clients (mobile, extension) can:\n * - match markets by full name in search (\"Bitcoin\", \"Apple\", \"Gold\"), and\n * - display the full name alongside / instead of the ticker.\n *\n * Keys follow the same convention as {@link HIP3_ASSET_MARKET_TYPES}: bare\n * `SYMBOL` for main-DEX crypto and `dex:SYMBOL` for HIP-3 markets. Use\n * {@link getHyperLiquidAssetName} to resolve a name with a safe fallback to the\n * ticker for unmapped assets.\n *\n * This list is intentionally curated (not exhaustive): unmapped assets simply\n * fall back to their ticker, which matches prior behavior. Add entries as needed.\n */\nexport const HYPERLIQUID_ASSET_NAMES: Record<string, string> = {\n // Main DEX - Crypto majors\n BTC: 'Bitcoin',\n ETH: 'Ethereum',\n SOL: 'Solana',\n XRP: 'XRP',\n BNB: 'BNB',\n DOGE: 'Dogecoin',\n ADA: 'Cardano',\n AVAX: 'Avalanche',\n LINK: 'Chainlink',\n LTC: 'Litecoin',\n DOT: 'Polkadot',\n BCH: 'Bitcoin Cash',\n TRX: 'TRON',\n MATIC: 'Polygon',\n ARB: 'Arbitrum',\n OP: 'Optimism',\n SUI: 'Sui',\n APT: 'Aptos',\n ATOM: 'Cosmos',\n NEAR: 'NEAR Protocol',\n INJ: 'Injective',\n TIA: 'Celestia',\n SEI: 'Sei',\n UNI: 'Uniswap',\n AAVE: 'Aave',\n MKR: 'Maker',\n CRV: 'Curve DAO',\n LDO: 'Lido DAO',\n PEPE: 'Pepe',\n WIF: 'dogwifhat',\n BONK: 'Bonk',\n SHIB: 'Shiba Inu',\n ETC: 'Ethereum Classic',\n FIL: 'Filecoin',\n HBAR: 'Hedera',\n ICP: 'Internet Computer',\n STX: 'Stacks',\n RUNE: 'THORChain',\n TON: 'Toncoin',\n KAS: 'Kaspa',\n FET: 'Fetch.ai',\n ENA: 'Ethena',\n JUP: 'Jupiter',\n PYTH: 'Pyth Network',\n JTO: 'Jito',\n STRK: 'Starknet',\n BLUR: 'Blur',\n GMX: 'GMX',\n DYDX: 'dYdX',\n HYPE: 'Hyperliquid',\n\n // xyz DEX - Stocks (US)\n 'xyz:TSLA': 'Tesla',\n 'xyz:NVDA': 'NVIDIA',\n 'xyz:INTC': 'Intel',\n 'xyz:MU': 'Micron Technology',\n 'xyz:CRCL': 'Circle',\n 'xyz:HOOD': 'Robinhood',\n 'xyz:SNDK': 'SanDisk',\n 'xyz:GOOGL': 'Alphabet (Google)',\n 'xyz:COIN': 'Coinbase',\n 'xyz:ORCL': 'Oracle',\n 'xyz:AMZN': 'Amazon',\n 'xyz:PLTR': 'Palantir',\n 'xyz:AAPL': 'Apple',\n 'xyz:META': 'Meta Platforms',\n 'xyz:AMD': 'AMD',\n 'xyz:MSFT': 'Microsoft',\n 'xyz:BABA': 'Alibaba',\n 'xyz:RIVN': 'Rivian',\n 'xyz:NFLX': 'Netflix',\n 'xyz:COST': 'Costco',\n 'xyz:LLY': 'Eli Lilly',\n 'xyz:TSM': 'Taiwan Semiconductor',\n 'xyz:MSTR': 'Strategy (MicroStrategy)',\n 'xyz:CRWV': 'CoreWeave',\n 'xyz:GME': 'GameStop',\n 'xyz:HIMS': 'Hims & Hers',\n 'xyz:USAR': 'USA Rare Earth',\n 'xyz:DKNG': 'DraftKings',\n 'xyz:RKLB': 'Rocket Lab',\n 'xyz:MRVL': 'Marvell',\n 'xyz:ZM': 'Zoom',\n 'xyz:EBAY': 'eBay',\n 'xyz:ARM': 'Arm Holdings',\n 'xyz:BX': 'Blackstone',\n 'xyz:LITE': 'Lumentum',\n\n // xyz DEX - Stocks (Korea)\n 'xyz:SKHX': 'SK Hynix',\n 'xyz:SMSN': 'Samsung Electronics',\n 'xyz:HYUNDAI': 'Hyundai Motor',\n\n // xyz DEX - Stocks (Japan)\n 'xyz:SOFTBANK': 'SoftBank Group',\n 'xyz:KIOXIA': 'Kioxia',\n\n // xyz DEX - Pre-IPO\n 'xyz:SPCX': 'SpaceX',\n 'xyz:CBRS': 'Cerebras',\n 'xyz:IPOP': 'Quantinuum',\n\n // xyz DEX - Indices\n 'xyz:SP500': 'S&P 500',\n 'xyz:JP225': 'Nikkei 225',\n 'xyz:KR200': 'KOSPI 200',\n 'xyz:VIX': 'CBOE Volatility Index',\n\n // xyz DEX - ETFs\n 'xyz:EWY': 'iShares MSCI South Korea ETF',\n 'xyz:EWJ': 'iShares MSCI Japan ETF',\n 'xyz:EWT': 'iShares MSCI Taiwan ETF',\n 'xyz:EWZ': 'iShares MSCI Brazil ETF',\n 'xyz:URNM': 'Sprott Uranium Miners ETF',\n 'xyz:XLE': 'Energy Select Sector SPDR Fund',\n\n // xyz DEX - Commodities\n 'xyz:GOLD': 'Gold',\n 'xyz:SILVER': 'Silver',\n 'xyz:CL': 'Crude Oil',\n 'xyz:WTIOIL': 'WTI Crude Oil',\n 'xyz:COPPER': 'Copper',\n 'xyz:ALUMINIUM': 'Aluminium',\n 'xyz:URANIUM': 'Uranium',\n 'xyz:NATGAS': 'Natural Gas',\n 'xyz:PLATINUM': 'Platinum',\n 'xyz:PALLADIUM': 'Palladium',\n 'xyz:BRENTOIL': 'Brent Crude Oil',\n\n // xyz DEX - Forex\n 'xyz:EUR': 'Euro',\n 'xyz:JPY': 'Japanese Yen',\n 'xyz:GBP': 'British Pound',\n 'xyz:DXY': 'US Dollar Index',\n};\n\n/**\n * Resolve the human-readable name for a HyperLiquid market.\n *\n * Falls back to the ticker symbol when the asset is not present in\n * {@link HYPERLIQUID_ASSET_NAMES}, so callers always receive a displayable\n * string and unmapped assets keep their prior behavior.\n *\n * @param symbol - HyperLiquid asset symbol (bare `SYMBOL` for main-DEX crypto,\n * `dex:SYMBOL` for HIP-3 markets).\n * @param names - Name map to look up against (defaults to the bundled\n * {@link HYPERLIQUID_ASSET_NAMES}); injectable for testing/overrides.\n * @returns The human-readable name, or the symbol itself when unmapped.\n */\nexport function getHyperLiquidAssetName(\n symbol: string,\n names: Record<string, string> = HYPERLIQUID_ASSET_NAMES,\n): string {\n return names[symbol] ?? symbol;\n}\n\n/**\n * Testnet-specific HIP-3 DEX configuration\n *\n * On testnet, there are many HIP-3 DEXs (test deployments from various builders).\n * Subscribing to all of them causes connection/subscription overload and instability.\n * This configuration limits which DEXs are discovered and subscribed to on testnet.\n */\nexport const TESTNET_HIP3_CONFIG = {\n /**\n * Allowed DEX names for testnet\n * Empty array = main DEX only (no HIP-3 DEXs)\n * Add specific DEX names to test with particular HIP-3 DEXs: ['testdex1', 'testdex2']\n */\n EnabledDexs: ['xyz'] as string[],\n\n /**\n * Set to true to enable full HIP-3 discovery on testnet (not recommended)\n * When false, only DEXs in ENABLED_DEXS are used\n */\n AutoDiscoverAll: false,\n} as const;\n\n/**\n * Mainnet-specific HIP-3 DEX configuration\n *\n * On mainnet, DEX filtering is dynamically determined from the allowlist markets\n * feature flag. This avoids hardcoding DEX names and ensures consistency with\n * the market filtering logic.\n *\n * When AutoDiscoverAll is false and no allowlist is provided, only the main DEX is used.\n * When an allowlist is provided, DEXs are extracted from the allowlist patterns.\n */\nexport const MAINNET_HIP3_CONFIG = {\n /**\n * Set to true to enable full HIP-3 discovery on mainnet\n * When false, DEXs are filtered based on the allowlist markets feature flag\n * (recommended for production to reduce subscription overhead)\n */\n AutoDiscoverAll: false,\n} as const;\n\n/**\n * HIP-3 margin management configuration\n * Controls margin buffers and auto-rebalance behavior for HIP-3 DEXes with isolated margin\n *\n * Background: HyperLiquid validates spendableBalance >= totalRequiredMargin BEFORE reallocating\n * existing locked margin. This requires temporary over-funding when increasing positions,\n * followed by automatic cleanup to minimize locked capital.\n */\nexport const HIP3_MARGIN_CONFIG = {\n /**\n * Margin buffer multiplier for fees and slippage (0.3% = multiply by 1.003)\n * Covers HyperLiquid's max taker fee (0.035%) with comfortable margin\n */\n BufferMultiplier: 1.003,\n\n /**\n * Desired buffer to keep on HIP-3 DEX after auto-rebalance (USDC amount)\n * Small buffer allows quick follow-up orders without transfers\n */\n RebalanceDesiredBuffer: 0.1,\n\n /**\n * Minimum excess threshold to trigger auto-rebalance (USDC amount)\n * Prevents unnecessary transfers for tiny amounts\n */\n RebalanceMinThreshold: 0.1,\n} as const;\n\n// Progress bar constants\nexport const INITIAL_AMOUNT_UI_PROGRESS = 10;\nexport const WITHDRAWAL_PROGRESS_STAGES = [\n 25, 35, 45, 55, 65, 75, 85, 90, 95, 98,\n];\nexport const PROGRESS_BAR_COMPLETION_DELAY_MS = 500;\n"]}
@@ -70,18 +70,10 @@ export type LighterTransactionOutcome = 'failed' | 'pending' | 'executed' | 'pen
70
70
  * @returns The documented outcome, or null for an unknown value.
71
71
  */
72
72
  export declare function getLighterTransactionOutcome(status: unknown): LighterTransactionOutcome | null;
73
- /** The pinned signer represents execution and trigger prices as uint32. */
74
- export declare const LIGHTER_MAX_WIRE_PRICE = 4294967295;
75
73
  export declare const LIGHTER_ORDER_TYPE_LIMIT = 0;
76
74
  export declare const LIGHTER_ORDER_TYPE_MARKET = 1;
77
75
  export declare const LIGHTER_ORDER_TYPE_STOP_LOSS = 2;
78
- export declare const LIGHTER_ORDER_TYPE_STOP_LOSS_LIMIT = 3;
79
76
  export declare const LIGHTER_ORDER_TYPE_TAKE_PROFIT = 4;
80
- export declare const LIGHTER_ORDER_TYPE_TAKE_PROFIT_LIMIT = 5;
81
- /** Native parent plus one attached child (OTO). */
82
- export declare const LIGHTER_GROUPING_ONE_TRIGGERS_THE_OTHER = 1;
83
- /** Native parent plus mutually cancelling attached children (OTOCO). */
84
- export declare const LIGHTER_GROUPING_ONE_TRIGGERS_OCO = 3;
85
77
  /** Grouped-orders grouping type: one-cancels-the-other (OCO). */
86
78
  export declare const LIGHTER_GROUPING_ONE_CANCELS_THE_OTHER = 2;
87
79
  /** L2 transaction type: CreateGroupedOrders (e.g. OCO TP/SL pairs). */
@@ -93,7 +85,7 @@ export declare const LIGHTER_TX_TYPE_UPDATE_LEVERAGE = 20;
93
85
  export declare const LIGHTER_TIME_IN_FORCE_IMMEDIATE_OR_CANCEL = 0;
94
86
  export declare const LIGHTER_TIME_IN_FORCE_GOOD_TILL_TIME = 1;
95
87
  export declare const LIGHTER_TIME_IN_FORCE_POST_ONLY = 2;
96
- /** Default pending expiry for GTT and trigger orders (per lighter SDKs). */
88
+ /** Sentinel for "no expiry" on GTT orders (per lighter SDKs). */
97
89
  export declare const LIGHTER_ORDER_EXPIRY_NONE = -1;
98
90
  /** Sentinel for "no trigger price". */
99
91
  export declare const LIGHTER_NO_TRIGGER_PRICE = 0;
@@ -103,17 +95,6 @@ export declare const LIGHTER_NO_TRIGGER_PRICE = 0;
103
95
  * slot avoids clobbering keys registered by other clients.
104
96
  */
105
97
  export declare const LIGHTER_DEFAULT_API_KEY_INDEX = 7;
106
- /** Inclusive venue range available for trading API keys. */
107
- export declare const LIGHTER_MIN_TRADING_API_KEY_INDEX = 2;
108
- export declare const LIGHTER_MAX_TRADING_API_KEY_INDEX = 254;
109
- /** Bounded number of trading slots scanned for account-local recovery state. */
110
- export declare const LIGHTER_TRADING_API_KEY_COUNT: number;
111
- /** Bound registration visibility reads before returning a retryable failure. */
112
- export declare const LIGHTER_KEY_REGISTRATION_VISIBILITY_TIMEOUT_MS = 10000;
113
- export declare const LIGHTER_KEY_REGISTRATION_VISIBILITY_POLL_MS = 250;
114
- export declare const LIGHTER_KEY_REGISTRATION_VISIBILITY_MAX_ATTEMPTS: number;
115
- /** Maximum newest-first complete fill history retained for late subscribers. */
116
- export declare const LIGHTER_FILL_REPLAY_LIMIT = 100;
117
98
  /**
118
99
  * HTTP request timeout in milliseconds
119
100
  */
@@ -220,45 +201,4 @@ export declare const LIGHTER_MARGIN_MODE_ISOLATED = 1;
220
201
  * instead of degrading them into empty state.
221
202
  */
222
203
  export declare const LIGHTER_UNSUPPORTED_CAPABILITY_PREFIX = "Unsupported Lighter capability:";
223
- /** Maximum verified venue accounts remembered per wallet/network for recovery inventory. */
224
- export declare const LIGHTER_RECOVERY_ACCOUNT_INDEX_LIMIT = 64;
225
- /** Clock slack for signed transaction expiry and venue trade provenance. */
226
- export declare const LIGHTER_TX_EXPIRY_SLACK_MS = 30000;
227
- /** Fixed native wire bounds and bounded probe inventory limits. */
228
- export declare const LIGHTER_MAX_MARKET_ID = 65535;
229
- export declare const LIGHTER_MAX_BASE_AMOUNT = "281474976710655";
230
- /** Inclusive uint48 client-order identity bound. */
231
- export declare const LIGHTER_MAX_CLIENT_ORDER_INDEX = "281474976710655";
232
- export declare const LIGHTER_MAX_ORDER_PRICE = "4294967295";
233
- export declare const LIGHTER_MAX_ORDER_ID = "1152921504606846975";
234
- export declare const LIGHTER_MAX_DECIMALS = 255;
235
- export declare const LIGHTER_MINUTE_MS = 60000;
236
- export declare const LIGHTER_NATIVE_PROBE_RECORD_LIMIT = 64;
237
- export declare const LIGHTER_NATIVE_PROBE_CANCEL_LIMIT = 16;
238
- export declare const LIGHTER_NATIVE_PROBE_PAGE_LIMIT = 100;
239
- export declare const LIGHTER_NATIVE_PROBE_PAGE_SIZE = 100;
240
- export declare const LIGHTER_CLIENT_ORDER_LOOKUP_LIMIT = 20;
241
- /** Shared bounded testnet native-probe notional ceiling, in USD. */
242
- export declare const LIGHTER_NATIVE_PROBE_MAX_NOTIONAL = 20;
243
- /** Settlement budget shared by every cancellation in one Scale group. */
244
- export declare const LIGHTER_SCALE_SETTLEMENT_WINDOW_MS = 10000;
245
- /** Read-only Scale visibility cadence, also used after each placement. */
246
- export declare const LIGHTER_SCALE_SETTLEMENT_POLL_MS = 250;
247
- /** Read-only settlement budget after an exact Chase cancellation dispatch. */
248
- export declare const LIGHTER_CHASE_CANCEL_SETTLEMENT_WINDOW_MS = 10000;
249
- /** Delay between exact Chase child reads, without another sign or send. */
250
- export declare const LIGHTER_CHASE_CANCEL_SETTLEMENT_POLL_MS = 250;
251
- /** Bounded Chase policy, distinct from native wire limits. */
252
- export declare const LIGHTER_CHASE_DEFAULT_INTERVAL_MS = 15000;
253
- export declare const LIGHTER_CHASE_DEFAULT_DURATION_MS = 60000;
254
- export declare const LIGHTER_CHASE_DEFAULT_REPRICINGS = 1;
255
- export declare const LIGHTER_CHASE_DEFAULT_DISTANCE_BPS = 100;
256
- export declare const LIGHTER_CHASE_MIN_INTERVAL_MS = 1000;
257
- export declare const LIGHTER_CHASE_MAX_DURATION_MS = 300000;
258
- export declare const LIGHTER_CHASE_MAX_REPRICINGS = 20;
259
- export declare const LIGHTER_CHASE_MAX_DISTANCE_BPS = 10000;
260
- export declare const LIGHTER_CHASE_QUOTE_MAX_AGE_MS = 5000;
261
- export declare const LIGHTER_CHASE_HANDLE_MAX_LENGTH = 128;
262
- /** Maximum duration of a post-only crossing-check book read. */
263
- export declare const LIGHTER_POST_ONLY_QUOTE_MAX_AGE_MS = 5000;
264
204
  //# sourceMappingURL=lighterConfig.d.ts.map