@metamask-previews/perps-controller 1.3.0-preview-2d89a26 → 1.3.0-preview-afe010990

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 (158) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/PerpsController-method-action-types.cjs +3 -0
  3. package/dist/PerpsController-method-action-types.cjs.map +1 -0
  4. package/dist/PerpsController-method-action-types.d.cts +147 -0
  5. package/dist/PerpsController-method-action-types.d.cts.map +1 -0
  6. package/dist/PerpsController-method-action-types.d.mts +147 -0
  7. package/dist/PerpsController-method-action-types.d.mts.map +1 -0
  8. package/dist/PerpsController-method-action-types.mjs +2 -0
  9. package/dist/PerpsController-method-action-types.mjs.map +1 -0
  10. package/dist/PerpsController.cjs +488 -183
  11. package/dist/PerpsController.cjs.map +1 -1
  12. package/dist/PerpsController.d.cts +91 -131
  13. package/dist/PerpsController.d.cts.map +1 -1
  14. package/dist/PerpsController.d.mts +91 -131
  15. package/dist/PerpsController.d.mts.map +1 -1
  16. package/dist/PerpsController.mjs +485 -182
  17. package/dist/PerpsController.mjs.map +1 -1
  18. package/dist/constants/eventNames.cjs +26 -0
  19. package/dist/constants/eventNames.cjs.map +1 -1
  20. package/dist/constants/eventNames.d.cts +19 -0
  21. package/dist/constants/eventNames.d.cts.map +1 -1
  22. package/dist/constants/eventNames.d.mts +19 -0
  23. package/dist/constants/eventNames.d.mts.map +1 -1
  24. package/dist/constants/eventNames.mjs +26 -0
  25. package/dist/constants/eventNames.mjs.map +1 -1
  26. package/dist/constants/hyperLiquidConfig.cjs +24 -4
  27. package/dist/constants/hyperLiquidConfig.cjs.map +1 -1
  28. package/dist/constants/hyperLiquidConfig.d.cts +8 -3
  29. package/dist/constants/hyperLiquidConfig.d.cts.map +1 -1
  30. package/dist/constants/hyperLiquidConfig.d.mts +8 -3
  31. package/dist/constants/hyperLiquidConfig.d.mts.map +1 -1
  32. package/dist/constants/hyperLiquidConfig.mjs +23 -3
  33. package/dist/constants/hyperLiquidConfig.mjs.map +1 -1
  34. package/dist/constants/myxConfig.cjs +75 -51
  35. package/dist/constants/myxConfig.cjs.map +1 -1
  36. package/dist/constants/myxConfig.d.cts +58 -19
  37. package/dist/constants/myxConfig.d.cts.map +1 -1
  38. package/dist/constants/myxConfig.d.mts +58 -19
  39. package/dist/constants/myxConfig.d.mts.map +1 -1
  40. package/dist/constants/myxConfig.mjs +74 -50
  41. package/dist/constants/myxConfig.mjs.map +1 -1
  42. package/dist/constants/perpsConfig.cjs +6 -2
  43. package/dist/constants/perpsConfig.cjs.map +1 -1
  44. package/dist/constants/perpsConfig.d.cts +5 -1
  45. package/dist/constants/perpsConfig.d.cts.map +1 -1
  46. package/dist/constants/perpsConfig.d.mts +5 -1
  47. package/dist/constants/perpsConfig.d.mts.map +1 -1
  48. package/dist/constants/perpsConfig.mjs +5 -1
  49. package/dist/constants/perpsConfig.mjs.map +1 -1
  50. package/dist/index.cjs +243 -25
  51. package/dist/index.cjs.map +1 -1
  52. package/dist/index.d.cts +48 -5
  53. package/dist/index.d.cts.map +1 -1
  54. package/dist/index.d.mts +48 -5
  55. package/dist/index.d.mts.map +1 -1
  56. package/dist/index.mjs +36 -10
  57. package/dist/index.mjs.map +1 -1
  58. package/dist/providers/AggregatedPerpsProvider.cjs +24 -0
  59. package/dist/providers/AggregatedPerpsProvider.cjs.map +1 -1
  60. package/dist/providers/AggregatedPerpsProvider.d.cts +4 -0
  61. package/dist/providers/AggregatedPerpsProvider.d.cts.map +1 -1
  62. package/dist/providers/AggregatedPerpsProvider.d.mts +4 -0
  63. package/dist/providers/AggregatedPerpsProvider.d.mts.map +1 -1
  64. package/dist/providers/AggregatedPerpsProvider.mjs +24 -0
  65. package/dist/providers/AggregatedPerpsProvider.mjs.map +1 -1
  66. package/dist/providers/HyperLiquidProvider.cjs +470 -154
  67. package/dist/providers/HyperLiquidProvider.cjs.map +1 -1
  68. package/dist/providers/HyperLiquidProvider.d.cts +11 -2
  69. package/dist/providers/HyperLiquidProvider.d.cts.map +1 -1
  70. package/dist/providers/HyperLiquidProvider.d.mts +11 -2
  71. package/dist/providers/HyperLiquidProvider.d.mts.map +1 -1
  72. package/dist/providers/HyperLiquidProvider.mjs +471 -155
  73. package/dist/providers/HyperLiquidProvider.mjs.map +1 -1
  74. package/dist/selectors.cjs +1 -1
  75. package/dist/selectors.cjs.map +1 -1
  76. package/dist/selectors.mjs +1 -1
  77. package/dist/selectors.mjs.map +1 -1
  78. package/dist/services/AccountService.cjs +1 -1
  79. package/dist/services/AccountService.cjs.map +1 -1
  80. package/dist/services/AccountService.d.cts.map +1 -1
  81. package/dist/services/AccountService.d.mts.map +1 -1
  82. package/dist/services/AccountService.mjs +2 -2
  83. package/dist/services/AccountService.mjs.map +1 -1
  84. package/dist/services/DepositService.cjs +2 -1
  85. package/dist/services/DepositService.cjs.map +1 -1
  86. package/dist/services/DepositService.d.cts.map +1 -1
  87. package/dist/services/DepositService.d.mts.map +1 -1
  88. package/dist/services/DepositService.mjs +2 -1
  89. package/dist/services/DepositService.mjs.map +1 -1
  90. package/dist/services/EligibilityService.cjs +8 -103
  91. package/dist/services/EligibilityService.cjs.map +1 -1
  92. package/dist/services/EligibilityService.d.cts +4 -15
  93. package/dist/services/EligibilityService.d.cts.map +1 -1
  94. package/dist/services/EligibilityService.d.mts +4 -15
  95. package/dist/services/EligibilityService.d.mts.map +1 -1
  96. package/dist/services/EligibilityService.mjs +8 -103
  97. package/dist/services/EligibilityService.mjs.map +1 -1
  98. package/dist/services/HyperLiquidSubscriptionService.cjs +252 -46
  99. package/dist/services/HyperLiquidSubscriptionService.cjs.map +1 -1
  100. package/dist/services/HyperLiquidSubscriptionService.d.cts +1 -0
  101. package/dist/services/HyperLiquidSubscriptionService.d.cts.map +1 -1
  102. package/dist/services/HyperLiquidSubscriptionService.d.mts +1 -0
  103. package/dist/services/HyperLiquidSubscriptionService.d.mts.map +1 -1
  104. package/dist/services/HyperLiquidSubscriptionService.mjs +252 -46
  105. package/dist/services/HyperLiquidSubscriptionService.mjs.map +1 -1
  106. package/dist/services/MarketDataService.cjs +2 -4
  107. package/dist/services/MarketDataService.cjs.map +1 -1
  108. package/dist/services/MarketDataService.d.cts.map +1 -1
  109. package/dist/services/MarketDataService.d.mts.map +1 -1
  110. package/dist/services/MarketDataService.mjs +2 -4
  111. package/dist/services/MarketDataService.mjs.map +1 -1
  112. package/dist/services/TradingService.cjs +72 -6
  113. package/dist/services/TradingService.cjs.map +1 -1
  114. package/dist/services/TradingService.d.cts.map +1 -1
  115. package/dist/services/TradingService.d.mts.map +1 -1
  116. package/dist/services/TradingService.mjs +72 -6
  117. package/dist/services/TradingService.mjs.map +1 -1
  118. package/dist/types/index.cjs.map +1 -1
  119. package/dist/types/index.d.cts +51 -3
  120. package/dist/types/index.d.cts.map +1 -1
  121. package/dist/types/index.d.mts +51 -3
  122. package/dist/types/index.d.mts.map +1 -1
  123. package/dist/types/index.mjs.map +1 -1
  124. package/dist/types/messenger.cjs.map +1 -1
  125. package/dist/types/messenger.d.cts +2 -1
  126. package/dist/types/messenger.d.cts.map +1 -1
  127. package/dist/types/messenger.d.mts +2 -1
  128. package/dist/types/messenger.d.mts.map +1 -1
  129. package/dist/types/messenger.mjs.map +1 -1
  130. package/dist/types/myx-types.cjs +19 -3
  131. package/dist/types/myx-types.cjs.map +1 -1
  132. package/dist/types/myx-types.d.cts +33 -2
  133. package/dist/types/myx-types.d.cts.map +1 -1
  134. package/dist/types/myx-types.d.mts +33 -2
  135. package/dist/types/myx-types.d.mts.map +1 -1
  136. package/dist/types/myx-types.mjs +6 -2
  137. package/dist/types/myx-types.mjs.map +1 -1
  138. package/dist/types/perps-types.cjs +3 -0
  139. package/dist/types/perps-types.cjs.map +1 -1
  140. package/dist/types/perps-types.d.cts +3 -3
  141. package/dist/types/perps-types.d.cts.map +1 -1
  142. package/dist/types/perps-types.d.mts +3 -3
  143. package/dist/types/perps-types.d.mts.map +1 -1
  144. package/dist/types/perps-types.mjs +3 -0
  145. package/dist/types/perps-types.mjs.map +1 -1
  146. package/dist/utils/accountUtils.cjs.map +1 -1
  147. package/dist/utils/accountUtils.d.cts.map +1 -1
  148. package/dist/utils/accountUtils.d.mts.map +1 -1
  149. package/dist/utils/accountUtils.mjs.map +1 -1
  150. package/dist/utils/myxAdapter.cjs +360 -15
  151. package/dist/utils/myxAdapter.cjs.map +1 -1
  152. package/dist/utils/myxAdapter.d.cts +94 -7
  153. package/dist/utils/myxAdapter.d.cts.map +1 -1
  154. package/dist/utils/myxAdapter.d.mts +94 -7
  155. package/dist/utils/myxAdapter.d.mts.map +1 -1
  156. package/dist/utils/myxAdapter.mjs +351 -16
  157. package/dist/utils/myxAdapter.mjs.map +1 -1
  158. package/package.json +4 -2
@@ -1 +1 @@
1
- {"version":3,"file":"myxConfig.d.mts","sourceRoot":"","sources":["../../src/constants/myxConfig.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,eAAe,EAChB,+BAA2B;AAM5B;;GAEG;AACH,eAAO,MAAM,oBAAoB,MAAgB,CAAC;AAClD,eAAO,MAAM,oBAAoB,MAAgB,CAAC;AAClD,eAAO,MAAM,yBAAyB,uBACW,CAAC;AAClD,eAAO,MAAM,yBAAyB,uBACW,CAAC;AAElD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAIzD;AAMD;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,YAS3B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAE9D;AAMD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAM1C;;GAEG;AACH,eAAO,MAAM,gBAAgB,8CAC0B,CAAC;AAEx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AM,qBAAqB,SAAS,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAG9D,CAAC"}
@@ -1,20 +1,24 @@
1
1
  /**
2
2
  * MYX Protocol Configuration Constants
3
3
  *
4
- * Stage 1 configuration for market display and price fetching.
5
- * Based on MYX SDK patterns but simplified for read-only operations.
4
+ * Configuration for market display, price fetching, and trading.
5
+ * Based on MYX SDK patterns.
6
6
  */
7
7
  import { BigNumber } from "bignumber.js";
8
8
  // ============================================================================
9
9
  // Network Constants
10
10
  // ============================================================================
11
11
  /**
12
- * BNB Chain IDs - MYX's primary network
12
+ * MYX Chain IDs
13
+ * Mainnet: BNB Chain (56)
14
+ * Testnet: Linea Sepolia (59141) — primary testnet chain with most active pools.
15
+ * The testnet API also has one pool on Arbitrum Sepolia (421614) but it has no
16
+ * ticker data, so Linea Sepolia is the effective testnet chain.
13
17
  */
14
- export const BNB_MAINNET_CHAIN_ID = '56';
15
- export const BNB_TESTNET_CHAIN_ID = '97';
16
- export const BNB_MAINNET_CAIP_CHAIN_ID = `eip155:${BNB_MAINNET_CHAIN_ID}`;
17
- export const BNB_TESTNET_CAIP_CHAIN_ID = `eip155:${BNB_TESTNET_CHAIN_ID}`;
18
+ export const MYX_MAINNET_CHAIN_ID = '56';
19
+ export const MYX_TESTNET_CHAIN_ID = '59141';
20
+ export const MYX_MAINNET_CAIP_CHAIN_ID = `eip155:${MYX_MAINNET_CHAIN_ID}`;
21
+ export const MYX_TESTNET_CAIP_CHAIN_ID = `eip155:${MYX_TESTNET_CHAIN_ID}`;
18
22
  /**
19
23
  * Get numeric chain ID for MYX network
20
24
  *
@@ -23,8 +27,8 @@ export const BNB_TESTNET_CAIP_CHAIN_ID = `eip155:${BNB_TESTNET_CHAIN_ID}`;
23
27
  */
24
28
  export function getMYXChainId(network) {
25
29
  return network === 'testnet'
26
- ? parseInt(BNB_TESTNET_CHAIN_ID, 10)
27
- : parseInt(BNB_MAINNET_CHAIN_ID, 10);
30
+ ? parseInt(MYX_TESTNET_CHAIN_ID, 10)
31
+ : parseInt(MYX_MAINNET_CHAIN_ID, 10);
28
32
  }
29
33
  // ============================================================================
30
34
  // API Endpoints
@@ -35,11 +39,11 @@ export function getMYXChainId(network) {
35
39
  export const MYX_ENDPOINTS = {
36
40
  mainnet: {
37
41
  http: 'https://api.myx.finance',
38
- ws: 'wss://ws.myx.finance',
42
+ ws: 'wss://oapi.myx.finance/ws',
39
43
  },
40
44
  testnet: {
41
- http: 'https://api-beta.myx.finance',
42
- ws: 'wss://ws-beta.myx.finance',
45
+ http: 'https://api-test.myx.cash',
46
+ ws: 'wss://oapi-test.myx.cash/ws',
43
47
  },
44
48
  };
45
49
  /**
@@ -55,10 +59,13 @@ export function getMYXHttpEndpoint(network) {
55
59
  // Decimal Constants
56
60
  // ============================================================================
57
61
  /**
58
- * MYX uses 30 decimals for price representation
59
- * This is consistent with the SDK's internal format
62
+ * MYX API returns prices as normal floating-point strings (e.g. "64854.76").
63
+ * No decimal scaling is needed for prices from the REST/WS API.
64
+ *
65
+ * Note: The SDK's internal contract layer uses 30 decimals, but the API
66
+ * endpoints (tickers, candles, order history) return human-readable values.
60
67
  */
61
- export const MYX_PRICE_DECIMALS = 30;
68
+ export const MYX_PRICE_DECIMALS = 0;
62
69
  /**
63
70
  * MYX uses 18 decimals for position sizes
64
71
  */
@@ -71,25 +78,31 @@ export const MYX_COLLATERAL_DECIMALS = 18;
71
78
  // Token Addresses
72
79
  // ============================================================================
73
80
  /**
74
- * USDT token address on BNB testnet
81
+ * Collateral token address — testnet (USDC on Linea Sepolia)
82
+ * From SDK: LINEA_SEPOLIA.USDC
75
83
  */
76
- export const USDT_BNB_TESTNET = '0x337610d27c682e347c9cd60bd4b3b107c9d34ddd';
84
+ export const MYX_COLLATERAL_TOKEN_TESTNET = '0xD984fd34f91F92DA0586e1bE82E262fF27DC431b';
77
85
  /**
78
- * USDT token address on BNB mainnet
86
+ * Collateral token address — mainnet (BUSD on BNB, per pool quoteToken)
87
+ * Note: individual pools may use different quote tokens
79
88
  */
80
- export const USDT_BNB_MAINNET = '0x55d398326f99059ff775485246999027b3197955';
89
+ export const MYX_COLLATERAL_TOKEN_MAINNET = '0x8bfc51e1928e91e47c6734983ac018b2fc0adf4e';
90
+ /** @deprecated Use MYX_COLLATERAL_TOKEN_TESTNET */
91
+ export const USDT_BNB_TESTNET = MYX_COLLATERAL_TOKEN_TESTNET;
92
+ /** @deprecated Use MYX_COLLATERAL_TOKEN_MAINNET */
93
+ export const USDT_BNB_MAINNET = MYX_COLLATERAL_TOKEN_MAINNET;
81
94
  /**
82
- * USDT configuration by network
95
+ * Collateral token configuration by network
83
96
  */
84
97
  export const MYX_ASSET_CONFIGS = {
85
98
  USDT: {
86
99
  mainnet: {
87
- chainId: BNB_MAINNET_CAIP_CHAIN_ID,
88
- tokenAddress: USDT_BNB_MAINNET,
100
+ chainId: MYX_MAINNET_CAIP_CHAIN_ID,
101
+ tokenAddress: MYX_COLLATERAL_TOKEN_MAINNET,
89
102
  },
90
103
  testnet: {
91
- chainId: BNB_TESTNET_CAIP_CHAIN_ID,
92
- tokenAddress: USDT_BNB_TESTNET,
104
+ chainId: MYX_TESTNET_CAIP_CHAIN_ID,
105
+ tokenAddress: MYX_COLLATERAL_TOKEN_TESTNET,
93
106
  },
94
107
  },
95
108
  };
@@ -97,45 +110,32 @@ export const MYX_ASSET_CONFIGS = {
97
110
  // Decimal Conversion Helpers
98
111
  // ============================================================================
99
112
  /**
100
- * Convert MYX SDK price (30 decimals) to standard number
113
+ * Convert MYX API price string to standard number.
114
+ *
115
+ * MYX API returns normal floating-point price strings (e.g. "64854.76"),
116
+ * NOT 30-decimal scaled integers. This is a simple parseFloat.
101
117
  *
102
- * @param myxPrice - Price string in 30-decimal format from SDK
118
+ * @param myxPrice - Price string from MYX API (e.g. "64854.760266796727")
103
119
  * @returns Standard decimal number
104
120
  */
105
121
  export function fromMYXPrice(myxPrice) {
106
122
  if (!myxPrice || myxPrice === '0') {
107
123
  return 0;
108
124
  }
109
- try {
110
- const bn = new BigNumber(myxPrice);
111
- if (bn.isNaN()) {
112
- return 0;
113
- }
114
- const divisor = new BigNumber(10).pow(MYX_PRICE_DECIMALS);
115
- return bn.dividedBy(divisor).toNumber();
116
- }
117
- catch {
118
- return 0;
119
- }
125
+ const parsed = parseFloat(myxPrice);
126
+ return isNaN(parsed) ? 0 : parsed;
120
127
  }
121
128
  /**
122
- * Convert standard number to MYX SDK price format (30 decimals)
129
+ * Convert standard number to MYX API price string.
130
+ *
131
+ * MYX API uses normal floating-point strings, so this is a simple toString.
123
132
  *
124
133
  * @param price - Standard decimal number
125
- * @returns Price string in 30-decimal format for SDK
134
+ * @returns Price string for MYX API
126
135
  */
127
136
  export function toMYXPrice(price) {
128
- try {
129
- const bn = new BigNumber(price);
130
- if (bn.isNaN()) {
131
- return '0';
132
- }
133
- const multiplier = new BigNumber(10).pow(MYX_PRICE_DECIMALS);
134
- return bn.multipliedBy(multiplier).toFixed(0);
135
- }
136
- catch {
137
- return '0';
138
- }
137
+ const parsed = typeof price === 'string' ? parseFloat(price) : price;
138
+ return isNaN(parsed) ? '0' : parsed.toString();
139
139
  }
140
140
  /**
141
141
  * Convert MYX SDK size (18 decimals) to standard number
@@ -216,4 +216,28 @@ export const MYX_HTTP_TIMEOUT_MS = 10000;
216
216
  * Maximum retries for failed API requests
217
217
  */
218
218
  export const MYX_MAX_RETRIES = 3;
219
+ /**
220
+ * Default slippage in basis points for MYX orders (1% — matches SDK default)
221
+ */
222
+ export const MYX_DEFAULT_SLIPPAGE_BPS = 100;
223
+ /**
224
+ * Maximum leverage supported by MYX (most markets)
225
+ */
226
+ export const MYX_MAX_LEVERAGE = 100;
227
+ /**
228
+ * Minimum order size in USD
229
+ */
230
+ export const MYX_MINIMUM_ORDER_SIZE_USD = 10;
231
+ /**
232
+ * MYX fee rates (placeholder — will be replaced with per-market rates)
233
+ */
234
+ export const MYX_FEE_RATE = 0.0005; // 0.05% total fee rate
235
+ export const MYX_PROTOCOL_FEE_RATE = 0.0005; // Protocol taker fee
236
+ /**
237
+ * USDT execution fee token address per network (used for order execution fees)
238
+ */
239
+ export const MYX_EXECUTION_FEE_TOKEN = {
240
+ testnet: MYX_COLLATERAL_TOKEN_TESTNET,
241
+ mainnet: MYX_COLLATERAL_TOKEN_MAINNET,
242
+ };
219
243
  //# sourceMappingURL=myxConfig.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"myxConfig.mjs","sourceRoot":"","sources":["../../src/constants/myxConfig.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAQzC,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAa,CAAC;AAClD,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAa,CAAC;AAClD,MAAM,CAAC,MAAM,yBAAyB,GACpC,UAAU,oBAAoB,EAAiB,CAAC;AAClD,MAAM,CAAC,MAAM,yBAAyB,GACpC,UAAU,oBAAoB,EAAiB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,OAAmB;IAC/C,OAAO,OAAO,KAAK,SAAS;QAC1B,CAAC,CAAC,QAAQ,CAAC,oBAAoB,EAAE,EAAE,CAAC;QACpC,CAAC,CAAC,QAAQ,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;AACzC,CAAC;AAED,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAiB;IACzC,OAAO,EAAE;QACP,IAAI,EAAE,yBAAyB;QAC/B,EAAE,EAAE,sBAAsB;KAC3B;IACD,OAAO,EAAE;QACP,IAAI,EAAE,8BAA8B;QACpC,EAAE,EAAE,2BAA2B;KAChC;CACF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,O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/B,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;YACf,OAAO,GAAG,CAAC;QACb,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,SAAS,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC5D,OAAO,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,aAAqB;IACrD,IAAI,CAAC,aAAa,IAAI,aAAa,KAAK,GAAG,EAAE,CAAC;QAC5C,OAAO,CAAC,CAAC;IACX,CAAC;IAED,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,IAAI,SAAS,CAAC,aAAa,CAAC,CAAC;QACxC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;YACf,OAAO,CAAC,CAAC;QACX,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,SAAS,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;QAC/D,OAAO,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AAED,+EAA+E;AAC/E,yBAAyB;AACzB,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC","sourcesContent":["/**\n * MYX Protocol Configuration Constants\n *\n * Stage 1 configuration for market display and price fetching.\n * Based on MYX SDK patterns but simplified for read-only operations.\n */\n\nimport type { CaipChainId } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport type {\n MYXNetwork,\n MYXEndpoints,\n MYXAssetConfigs,\n} from '../types/myx-types';\n\n// ============================================================================\n// Network Constants\n// ============================================================================\n\n/**\n * BNB Chain IDs - MYX's primary network\n */\nexport const BNB_MAINNET_CHAIN_ID = '56' as const;\nexport const BNB_TESTNET_CHAIN_ID = '97' as const;\nexport const BNB_MAINNET_CAIP_CHAIN_ID =\n `eip155:${BNB_MAINNET_CHAIN_ID}` as CaipChainId;\nexport const BNB_TESTNET_CAIP_CHAIN_ID =\n `eip155:${BNB_TESTNET_CHAIN_ID}` as CaipChainId;\n\n/**\n * Get numeric chain ID for MYX network\n *\n * @param network - The MYX network environment (mainnet or testnet).\n * @returns The numeric chain ID for the specified network.\n */\nexport function getMYXChainId(network: MYXNetwork): number {\n return network === 'testnet'\n ? parseInt(BNB_TESTNET_CHAIN_ID, 10)\n : parseInt(BNB_MAINNET_CHAIN_ID, 10);\n}\n\n// ============================================================================\n// API Endpoints\n// ============================================================================\n\n/**\n * MYX REST and WebSocket endpoints\n */\nexport const MYX_ENDPOINTS: MYXEndpoints = {\n mainnet: {\n http: 'https://api.myx.finance',\n ws: 'wss://ws.myx.finance',\n },\n testnet: {\n http: 'https://api-beta.myx.finance',\n ws: 'wss://ws-beta.myx.finance',\n },\n};\n\n/**\n * Get HTTP endpoint for network\n *\n * @param network - The MYX network environment (mainnet or testnet).\n * @returns The HTTP API endpoint URL for the specified network.\n */\nexport function getMYXHttpEndpoint(network: MYXNetwork): string {\n return MYX_ENDPOINTS[network].http;\n}\n\n// ============================================================================\n// Decimal Constants\n// ============================================================================\n\n/**\n * MYX uses 30 decimals for price representation\n * This is consistent with the SDK's internal format\n */\nexport const MYX_PRICE_DECIMALS = 30;\n\n/**\n * MYX uses 18 decimals for position sizes\n */\nexport const MYX_SIZE_DECIMALS = 18;\n\n/**\n * MYX uses 18 decimals for collateral amounts (USDT on BNB)\n */\nexport const MYX_COLLATERAL_DECIMALS = 18;\n\n// ============================================================================\n// Token Addresses\n// ============================================================================\n\n/**\n * USDT token address on BNB testnet\n */\nexport const USDT_BNB_TESTNET =\n '0x337610d27c682e347c9cd60bd4b3b107c9d34ddd' as const;\n\n/**\n * USDT token address on BNB mainnet\n */\nexport const USDT_BNB_MAINNET =\n '0x55d398326f99059ff775485246999027b3197955' as const;\n\n/**\n * USDT configuration by network\n */\nexport const MYX_ASSET_CONFIGS: MYXAssetConfigs = {\n USDT: {\n mainnet: {\n chainId: BNB_MAINNET_CAIP_CHAIN_ID,\n tokenAddress: USDT_BNB_MAINNET,\n },\n testnet: {\n chainId: BNB_TESTNET_CAIP_CHAIN_ID,\n tokenAddress: USDT_BNB_TESTNET,\n },\n },\n};\n\n// ============================================================================\n// Decimal Conversion Helpers\n// ============================================================================\n\n/**\n * Convert MYX SDK price (30 decimals) to standard number\n *\n * @param myxPrice - Price string in 30-decimal format from SDK\n * @returns Standard decimal number\n */\nexport function fromMYXPrice(myxPrice: string): number {\n if (!myxPrice || myxPrice === '0') {\n return 0;\n }\n\n try {\n const bn = new BigNumber(myxPrice);\n if (bn.isNaN()) {\n return 0;\n }\n const divisor = new BigNumber(10).pow(MYX_PRICE_DECIMALS);\n return bn.dividedBy(divisor).toNumber();\n } catch {\n return 0;\n }\n}\n\n/**\n * Convert standard number to MYX SDK price format (30 decimals)\n *\n * @param price - Standard decimal number\n * @returns Price string in 30-decimal format for SDK\n */\nexport function toMYXPrice(price: number | string): string {\n try {\n const bn = new BigNumber(price);\n if (bn.isNaN()) {\n return '0';\n }\n const multiplier = new BigNumber(10).pow(MYX_PRICE_DECIMALS);\n return bn.multipliedBy(multiplier).toFixed(0);\n } catch {\n return '0';\n }\n}\n\n/**\n * Convert MYX SDK size (18 decimals) to standard number\n *\n * @param myxSize - Size string in 18-decimal format from SDK\n * @returns Standard decimal number\n */\nexport function fromMYXSize(myxSize: string): number {\n if (!myxSize || myxSize === '0') {\n return 0;\n }\n\n try {\n const bn = new BigNumber(myxSize);\n if (bn.isNaN()) {\n return 0;\n }\n const divisor = new BigNumber(10).pow(MYX_SIZE_DECIMALS);\n return bn.dividedBy(divisor).toNumber();\n } catch {\n return 0;\n }\n}\n\n/**\n * Convert standard number to MYX SDK size format (18 decimals)\n *\n * @param size - Standard decimal number\n * @returns Size string in 18-decimal format for SDK\n */\nexport function toMYXSize(size: number | string): string {\n try {\n const bn = new BigNumber(size);\n if (bn.isNaN()) {\n return '0';\n }\n const multiplier = new BigNumber(10).pow(MYX_SIZE_DECIMALS);\n return bn.multipliedBy(multiplier).toFixed(0);\n } catch {\n return '0';\n }\n}\n\n/**\n * Convert MYX SDK collateral (18 decimals) to standard number\n *\n * @param myxCollateral - Collateral string in 18-decimal format from SDK\n * @returns Standard decimal number\n */\nexport function fromMYXCollateral(myxCollateral: string): number {\n if (!myxCollateral || myxCollateral === '0') {\n return 0;\n }\n\n try {\n const bn = new BigNumber(myxCollateral);\n if (bn.isNaN()) {\n return 0;\n }\n const divisor = new BigNumber(10).pow(MYX_COLLATERAL_DECIMALS);\n return bn.dividedBy(divisor).toNumber();\n } catch {\n return 0;\n }\n}\n\n// ============================================================================\n// REST API Configuration\n// ============================================================================\n\n/**\n * Price polling interval in milliseconds\n * Using 5 seconds as a fallback for unreliable WebSocket\n */\nexport const MYX_PRICE_POLLING_INTERVAL_MS = 5000;\n\n/**\n * HTTP request timeout in milliseconds\n */\nexport const MYX_HTTP_TIMEOUT_MS = 10000;\n\n/**\n * Maximum retries for failed API requests\n */\nexport const MYX_MAX_RETRIES = 3;\n"]}
1
+ {"version":3,"file":"myxConfig.mjs","sourceRoot":"","sources":["../../src/constants/myxConfig.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAQzC,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAa,CAAC;AAClD,MAAM,CAAC,MAAM,oB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AAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AAED,+EAA+E;AAC/E,yBAAyB;AACzB,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC;AAEjC;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAEpC;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,CAAC,uBAAuB;AAC3D,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,CAAC,qBAAqB;AAElE;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAA+B;IACjE,OAAO,EAAE,4BAA4B;IACrC,OAAO,EAAE,4BAA4B;CACtC,CAAC","sourcesContent":["/**\n * MYX Protocol Configuration Constants\n *\n * Configuration for market display, price fetching, and trading.\n * Based on MYX SDK patterns.\n */\n\nimport type { CaipChainId } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport type {\n MYXNetwork,\n MYXEndpoints,\n MYXAssetConfigs,\n} from '../types/myx-types';\n\n// ============================================================================\n// Network Constants\n// ============================================================================\n\n/**\n * MYX Chain IDs\n * Mainnet: BNB Chain (56)\n * Testnet: Linea Sepolia (59141) — primary testnet chain with most active pools.\n * The testnet API also has one pool on Arbitrum Sepolia (421614) but it has no\n * ticker data, so Linea Sepolia is the effective testnet chain.\n */\nexport const MYX_MAINNET_CHAIN_ID = '56' as const;\nexport const MYX_TESTNET_CHAIN_ID = '59141' as const;\nexport const MYX_MAINNET_CAIP_CHAIN_ID =\n `eip155:${MYX_MAINNET_CHAIN_ID}` as CaipChainId;\nexport const MYX_TESTNET_CAIP_CHAIN_ID =\n `eip155:${MYX_TESTNET_CHAIN_ID}` as CaipChainId;\n\n/**\n * Get numeric chain ID for MYX network\n *\n * @param network - The MYX network environment (mainnet or testnet).\n * @returns The numeric chain ID for the specified network.\n */\nexport function getMYXChainId(network: MYXNetwork): number {\n return network === 'testnet'\n ? parseInt(MYX_TESTNET_CHAIN_ID, 10)\n : parseInt(MYX_MAINNET_CHAIN_ID, 10);\n}\n\n// ============================================================================\n// API Endpoints\n// ============================================================================\n\n/**\n * MYX REST and WebSocket endpoints\n */\nexport const MYX_ENDPOINTS: MYXEndpoints = {\n mainnet: {\n http: 'https://api.myx.finance',\n ws: 'wss://oapi.myx.finance/ws',\n },\n testnet: {\n http: 'https://api-test.myx.cash',\n ws: 'wss://oapi-test.myx.cash/ws',\n },\n};\n\n/**\n * Get HTTP endpoint for network\n *\n * @param network - The MYX network environment (mainnet or testnet).\n * @returns The HTTP API endpoint URL for the specified network.\n */\nexport function getMYXHttpEndpoint(network: MYXNetwork): string {\n return MYX_ENDPOINTS[network].http;\n}\n\n// ============================================================================\n// Decimal Constants\n// ============================================================================\n\n/**\n * MYX API returns prices as normal floating-point strings (e.g. \"64854.76\").\n * No decimal scaling is needed for prices from the REST/WS API.\n *\n * Note: The SDK's internal contract layer uses 30 decimals, but the API\n * endpoints (tickers, candles, order history) return human-readable values.\n */\nexport const MYX_PRICE_DECIMALS = 0;\n\n/**\n * MYX uses 18 decimals for position sizes\n */\nexport const MYX_SIZE_DECIMALS = 18;\n\n/**\n * MYX uses 18 decimals for collateral amounts (USDT on BNB)\n */\nexport const MYX_COLLATERAL_DECIMALS = 18;\n\n// ============================================================================\n// Token Addresses\n// ============================================================================\n\n/**\n * Collateral token address — testnet (USDC on Linea Sepolia)\n * From SDK: LINEA_SEPOLIA.USDC\n */\nexport const MYX_COLLATERAL_TOKEN_TESTNET =\n '0xD984fd34f91F92DA0586e1bE82E262fF27DC431b' as const;\n\n/**\n * Collateral token address — mainnet (BUSD on BNB, per pool quoteToken)\n * Note: individual pools may use different quote tokens\n */\nexport const MYX_COLLATERAL_TOKEN_MAINNET =\n '0x8bfc51e1928e91e47c6734983ac018b2fc0adf4e' as const;\n\n/** @deprecated Use MYX_COLLATERAL_TOKEN_TESTNET */\nexport const USDT_BNB_TESTNET = MYX_COLLATERAL_TOKEN_TESTNET;\n/** @deprecated Use MYX_COLLATERAL_TOKEN_MAINNET */\nexport const USDT_BNB_MAINNET = MYX_COLLATERAL_TOKEN_MAINNET;\n\n/**\n * Collateral token configuration by network\n */\nexport const MYX_ASSET_CONFIGS: MYXAssetConfigs = {\n USDT: {\n mainnet: {\n chainId: MYX_MAINNET_CAIP_CHAIN_ID,\n tokenAddress: MYX_COLLATERAL_TOKEN_MAINNET,\n },\n testnet: {\n chainId: MYX_TESTNET_CAIP_CHAIN_ID,\n tokenAddress: MYX_COLLATERAL_TOKEN_TESTNET,\n },\n },\n};\n\n// ============================================================================\n// Decimal Conversion Helpers\n// ============================================================================\n\n/**\n * Convert MYX API price string to standard number.\n *\n * MYX API returns normal floating-point price strings (e.g. \"64854.76\"),\n * NOT 30-decimal scaled integers. This is a simple parseFloat.\n *\n * @param myxPrice - Price string from MYX API (e.g. \"64854.760266796727\")\n * @returns Standard decimal number\n */\nexport function fromMYXPrice(myxPrice: string): number {\n if (!myxPrice || myxPrice === '0') {\n return 0;\n }\n\n const parsed = parseFloat(myxPrice);\n return isNaN(parsed) ? 0 : parsed;\n}\n\n/**\n * Convert standard number to MYX API price string.\n *\n * MYX API uses normal floating-point strings, so this is a simple toString.\n *\n * @param price - Standard decimal number\n * @returns Price string for MYX API\n */\nexport function toMYXPrice(price: number | string): string {\n const parsed = typeof price === 'string' ? parseFloat(price) : price;\n return isNaN(parsed) ? '0' : parsed.toString();\n}\n\n/**\n * Convert MYX SDK size (18 decimals) to standard number\n *\n * @param myxSize - Size string in 18-decimal format from SDK\n * @returns Standard decimal number\n */\nexport function fromMYXSize(myxSize: string): number {\n if (!myxSize || myxSize === '0') {\n return 0;\n }\n\n try {\n const bn = new BigNumber(myxSize);\n if (bn.isNaN()) {\n return 0;\n }\n const divisor = new BigNumber(10).pow(MYX_SIZE_DECIMALS);\n return bn.dividedBy(divisor).toNumber();\n } catch {\n return 0;\n }\n}\n\n/**\n * Convert standard number to MYX SDK size format (18 decimals)\n *\n * @param size - Standard decimal number\n * @returns Size string in 18-decimal format for SDK\n */\nexport function toMYXSize(size: number | string): string {\n try {\n const bn = new BigNumber(size);\n if (bn.isNaN()) {\n return '0';\n }\n const multiplier = new BigNumber(10).pow(MYX_SIZE_DECIMALS);\n return bn.multipliedBy(multiplier).toFixed(0);\n } catch {\n return '0';\n }\n}\n\n/**\n * Convert MYX SDK collateral (18 decimals) to standard number\n *\n * @param myxCollateral - Collateral string in 18-decimal format from SDK\n * @returns Standard decimal number\n */\nexport function fromMYXCollateral(myxCollateral: string): number {\n if (!myxCollateral || myxCollateral === '0') {\n return 0;\n }\n\n try {\n const bn = new BigNumber(myxCollateral);\n if (bn.isNaN()) {\n return 0;\n }\n const divisor = new BigNumber(10).pow(MYX_COLLATERAL_DECIMALS);\n return bn.dividedBy(divisor).toNumber();\n } catch {\n return 0;\n }\n}\n\n// ============================================================================\n// REST API Configuration\n// ============================================================================\n\n/**\n * Price polling interval in milliseconds\n * Using 5 seconds as a fallback for unreliable WebSocket\n */\nexport const MYX_PRICE_POLLING_INTERVAL_MS = 5000;\n\n/**\n * HTTP request timeout in milliseconds\n */\nexport const MYX_HTTP_TIMEOUT_MS = 10000;\n\n/**\n * Maximum retries for failed API requests\n */\nexport const MYX_MAX_RETRIES = 3;\n\n/**\n * Default slippage in basis points for MYX orders (1% — matches SDK default)\n */\nexport const MYX_DEFAULT_SLIPPAGE_BPS = 100;\n\n/**\n * Maximum leverage supported by MYX (most markets)\n */\nexport const MYX_MAX_LEVERAGE = 100;\n\n/**\n * Minimum order size in USD\n */\nexport const MYX_MINIMUM_ORDER_SIZE_USD = 10;\n\n/**\n * MYX fee rates (placeholder — will be replaced with per-market rates)\n */\nexport const MYX_FEE_RATE = 0.0005; // 0.05% total fee rate\nexport const MYX_PROTOCOL_FEE_RATE = 0.0005; // Protocol taker fee\n\n/**\n * USDT execution fee token address per network (used for order execution fees)\n */\nexport const MYX_EXECUTION_FEE_TOKEN: Record<MYXNetwork, string> = {\n testnet: MYX_COLLATERAL_TOKEN_TESTNET,\n mainnet: MYX_COLLATERAL_TOKEN_MAINNET,\n};\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PROVIDER_CONFIG = exports.MARKET_SORTING_CONFIG = exports.DECIMAL_PRECISION_CONFIG = exports.DATA_LAKE_API_CONFIG = exports.MARGIN_ADJUSTMENT_CONFIG = exports.CLOSE_POSITION_CONFIG = exports.HYPERLIQUID_ORDER_LIMITS = exports.TP_SL_CONFIG = exports.PERFORMANCE_CONFIG = exports.ORDER_SLIPPAGE_CONFIG = exports.VALIDATION_THRESHOLDS = exports.WITHDRAWAL_CONSTANTS = exports.PERPS_CONSTANTS = void 0;
3
+ exports.PROVIDER_CONFIG = exports.MARKET_SORTING_CONFIG = exports.DECIMAL_PRECISION_CONFIG = exports.DATA_LAKE_API_CONFIG = exports.MARGIN_ADJUSTMENT_CONFIG = exports.CLOSE_POSITION_CONFIG = exports.HYPERLIQUID_ORDER_LIMITS = exports.TP_SL_CONFIG = exports.PERFORMANCE_CONFIG = exports.ORDER_SLIPPAGE_CONFIG = exports.VALIDATION_THRESHOLDS = exports.WITHDRAWAL_CONSTANTS = exports.PERPS_CONSTANTS = exports.ZERO_BALANCE = exports.ZERO_ADDRESS = void 0;
4
4
  /**
5
5
  * Perps feature constants - Controller layer (portable)
6
6
  *
@@ -11,6 +11,8 @@ exports.PROVIDER_CONFIG = exports.MARKET_SORTING_CONFIG = exports.DECIMAL_PRECIS
11
11
  * UI-only constants (layout, display, navigation) live in:
12
12
  * app/components/UI/Perps/constants/perpsConfig.ts
13
13
  */
14
+ exports.ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
15
+ exports.ZERO_BALANCE = '0x0';
14
16
  exports.PERPS_CONSTANTS = {
15
17
  FeatureFlagKey: 'perpsEnabled',
16
18
  FeatureName: 'perps', // Constant for Sentry error filtering - enables "feature:perps" dashboard queries
@@ -32,6 +34,8 @@ exports.PERPS_CONSTANTS = {
32
34
  ReconnectionDelayAndroidMs: 300, // Android-specific reconnection delay for better reliability on slower devices
33
35
  ReconnectionDelayIosMs: 100, // iOS-specific reconnection delay for optimal performance
34
36
  ReconnectionRetryDelayMs: 5000, // 5 seconds delay between reconnection attempts
37
+ NetworkRestoreMaxRetries: 8, // Max retry attempts when reconnecting after WiFi/network restore
38
+ NetworkRestoreRetryBaseMs: 1500, // Base delay (ms) between network restore retries (multiplied by attempt number)
35
39
  // Connection manager timing constants
36
40
  BalanceUpdateThrottleMs: 15000, // Update at most every 15 seconds to reduce state updates in PerpsConnectionManager
37
41
  InitialDataDelayMs: 100, // Delay to allow initial data to load after connection establishment
@@ -290,6 +294,6 @@ exports.PROVIDER_CONFIG = {
290
294
  /** Default perpetual DEX provider when no explicit selection exists */
291
295
  DefaultProvider: 'hyperliquid',
292
296
  /** Force MYX to testnet only (mainnet credentials not yet available) */
293
- MYX_TESTNET_ONLY: true,
297
+ MYX_TESTNET_ONLY: false,
294
298
  };
295
299
  //# sourceMappingURL=perpsConfig.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"perpsConfig.cjs","sourceRoot":"","sources":["../../src/constants/perpsConfig.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACU,QAAA,eAAe,GAAG;IAC7B,cAAc,EAAE,cAAc;IAC9B,WAAW,EAAE,OAAO,EAAE,kFAAkF;IACxG,sGAAsG;IACtG,4BAA4B,EAAE,eAAe;IAC7C,uFAAuF;IACvF,uBAAuB,EAAE,KAAK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EAAE,cAAc;YAClB,QAAQ,EAAE,0BAA0B;YACpC,KAAK,EAAE,cAAc;YACrB,SAAS,EAAE,MAAM;SAClB;QACD;YACE,EAAE,EAAE,aAAa;YACjB,QAAQ,EAAE,yBAAyB;YACnC,KAAK,EAAE,aAAa;YACpB,SAAS,EAAE,MAAM;SAClB;KACO;CACF,CAAC;AAUX;;GAEG;AACU,QAAA,eAAe,GAAG;IAC7B,uEAAuE;IACvE,eAAe,EAAE,aAAsB;IACvC,wEAAwE;IACxE,gBAAgB,EAAE,IAAI;CACd,CAAC","sourcesContent":["/**\n * Perps feature constants - Controller layer (portable)\n *\n * This file contains only controller-portable configuration:\n * - Constants used by controller logic, providers, and services\n * - Calculation thresholds, API configs, and protocol constants\n *\n * UI-only constants (layout, display, navigation) live in:\n * app/components/UI/Perps/constants/perpsConfig.ts\n */\nexport const PERPS_CONSTANTS = {\n FeatureFlagKey: 'perpsEnabled',\n FeatureName: 'perps', // Constant for Sentry error filtering - enables \"feature:perps\" dashboard queries\n /** Token description used to identify the synthetic \"Perps balance\" option in pay-with token lists */\n PerpsBalanceTokenDescription: 'perps-balance',\n /** Symbol displayed for the synthetic \"Perps balance\" token in pay-with token lists */\n PerpsBalanceTokenSymbol: 'USD',\n WebsocketTimeout: 5000, // 5 seconds\n WebsocketCleanupDelay: 1000, // 1 second\n BackgroundDisconnectDelay: 20_000, // 20 seconds delay before disconnecting when app is backgrounded or when user exits perps UX\n ConnectionTimeoutMs: 10_000, // 10 seconds timeout for connection and position loading states\n DefaultMonitoringTimeoutMs: 10_000, // 10 seconds default timeout for data monitoring operations\n\n // Connection timing constants\n ConnectionGracePeriodMs: 20_000, // 20 seconds grace period before actual disconnection (same as BackgroundDisconnectDelay for semantic clarity)\n ConnectionAttemptTimeoutMs: 30_000, // 30 seconds timeout for connection attempts to prevent indefinite hanging\n WebsocketPingTimeoutMs: 5_000, // 5 seconds timeout for WebSocket health check ping\n ConnectRetryDelayMs: 200, // Delay before retrying connect() when connection isn't ready yet\n ReconnectionCleanupDelayMs: 500, // Platform-agnostic delay to ensure WebSocket is ready\n ReconnectionDelayAndroidMs: 300, // Android-specific reconnection delay for better reliability on slower devices\n ReconnectionDelayIosMs: 100, // iOS-specific reconnection delay for optimal performance\n ReconnectionRetryDelayMs: 5_000, // 5 seconds delay between reconnection attempts\n\n // Connection manager timing constants\n BalanceUpdateThrottleMs: 15000, // Update at most every 15 seconds to reduce state updates in PerpsConnectionManager\n InitialDataDelayMs: 100, // Delay to allow initial data to load after connection establishment\n\n // Deposit toast timing\n DepositTakingLongerToastDelayMs: 30_000, // Delay before showing \"Deposit taking longer than usual\" toast\n\n DefaultAssetPreviewLimit: 5,\n DefaultMaxLeverage: 3 as number, // Default fallback max leverage when market data is unavailable - conservative default\n FallbackPriceDisplay: '$---', // Display when price data is unavailable\n FallbackPercentageDisplay: '--%', // Display when change data is unavailable\n FallbackDataDisplay: '--', // Display when non-price data is unavailable\n ZeroAmountDisplay: '$0', // Display for zero dollar amounts (e.g., no volume)\n ZeroAmountDetailedDisplay: '$0.00', // Display for zero dollar amounts with decimals\n\n RecentActivityLimit: 3,\n\n // Historical data fetching constants\n FillsLookbackMs: 90 * 24 * 60 * 60 * 1000, // 3 months in milliseconds - limits REST API fills fetch\n} as const;\n\n/**\n * Withdrawal-specific constants (protocol-agnostic)\n * Note: Protocol-specific values like estimated time should be defined in each protocol's config\n */\nexport const WITHDRAWAL_CONSTANTS = {\n DefaultMinAmount: '1.01', // Default minimum withdrawal amount in USDC\n DefaultFeeAmount: 1, // Default withdrawal fee in USDC\n DefaultFeeToken: 'USDC', // Default fee token\n} as const;\n\n/**\n * Validation thresholds for UI warnings and checks\n * These values control when warnings are shown to users\n */\nexport const VALIDATION_THRESHOLDS = {\n // Leverage threshold for warning users about high leverage\n HighLeverageWarning: 20, // Show warning when leverage > 20x\n\n // Limit price difference threshold (as decimal, 0.1 = 10%)\n LimitPriceDifferenceWarning: 0.1, // Warn if limit price differs by >10% from current price\n\n // Price deviation threshold (as decimal, 0.1 = 10%)\n PriceDeviation: 0.1, // Warn if perps price deviates by >10% from spot price\n} as const;\n\n/**\n * Order slippage configuration\n * Controls default slippage tolerance for different order types\n * Conservative defaults based on HyperLiquid platform interface\n * See: docs/perps/hyperliquid/ORDER-MATCHING-ERRORS.md\n */\nexport const ORDER_SLIPPAGE_CONFIG = {\n // Market order slippage (basis points)\n // 300 basis points = 3% = 0.03 decimal\n // Conservative default for measured rollout, prevents most IOC failures\n DefaultMarketSlippageBps: 300,\n\n // TP/SL order slippage (basis points)\n // 1000 basis points = 10% = 0.10 decimal\n // Aligns with HyperLiquid platform default for triggered orders\n DefaultTpslSlippageBps: 1000,\n\n // Limit order slippage (basis points)\n // 100 basis points = 1% = 0.01 decimal\n // Kept conservative as limit orders rest on book (not IOC/immediate execution)\n DefaultLimitSlippageBps: 100,\n} as const;\n\n/**\n * Performance optimization constants\n * These values control debouncing and throttling for better performance\n */\nexport const PERFORMANCE_CONFIG = {\n // Price updates debounce delay (milliseconds)\n // Batches rapid WebSocket price updates to reduce re-renders\n PriceUpdateDebounceMs: 1000,\n\n // Order validation debounce delay (milliseconds)\n // Prevents excessive validation calls during rapid form input changes\n ValidationDebounceMs: 300,\n\n // Liquidation price debounce delay (milliseconds)\n // Prevents excessive liquidation price calls during rapid form input changes\n LiquidationPriceDebounceMs: 500,\n\n // Navigation params delay (milliseconds)\n // Required for React Navigation to complete state transitions before setting params\n // This ensures navigation context is available when programmatically selecting tabs\n NavigationParamsDelayMs: 200,\n\n // Tab control reset delay (milliseconds)\n // Delay to reset programmatic tab control after tab switching to prevent render loops\n TabControlResetDelayMs: 500,\n\n // Market data cache duration (milliseconds)\n // How long to cache market list data before fetching fresh data\n MarketDataCacheDurationMs: 5 * 60 * 1000, // 5 minutes\n\n // Asset metadata cache duration (milliseconds)\n // How long to cache asset icon validation results\n AssetMetadataCacheDurationMs: 60 * 60 * 1000, // 1 hour\n\n // Max leverage cache duration (milliseconds)\n // How long to cache max leverage values per asset (leverage rarely changes)\n MaxLeverageCacheDurationMs: 60 * 60 * 1000, // 1 hour\n\n // Rewards cache durations (milliseconds)\n // How long to cache fee discount data from rewards API\n FeeDiscountCacheDurationMs: 5 * 60 * 1000, // 5 minutes\n // How long to cache points calculation parameters from rewards API\n PointsCalculationCacheDurationMs: 5 * 60 * 1000, // 5 minutes\n\n /**\n * Performance logging markers for filtering logs during development and debugging\n * These markers help isolate performance-related logs from general application logs\n * Usage: Use in DevLogger calls to easily filter specific performance areas\n * Impact: Development only (uses DevLogger) - zero production performance cost\n *\n * Examples:\n * - Filter Sentry performance logs: `adb logcat | grep PERPSMARK_SENTRY`\n * - Filter MetaMetrics events: `adb logcat | grep PERPSMARK_METRICS`\n * - Filter WebSocket performance: `adb logcat | grep PERPSMARK_WS`\n * - Filter all Perps performance: `adb logcat | grep PERPSMARK_`\n */\n LoggingMarkers: {\n // Sentry performance measurement logs (screen loads, bottom sheets, API timing)\n SentryPerformance: 'PERPSMARK_SENTRY',\n\n // MetaMetrics event tracking logs (user interactions, business analytics)\n MetametricsEvents: 'PERPSMARK_METRICS',\n\n // WebSocket performance logs (connection timing, data flow, reconnections)\n WebsocketPerformance: 'PERPSMARK_SENTRY_WS',\n } as const,\n} as const;\n\nexport const TP_SL_CONFIG = {\n UsePositionBoundTpsl: true,\n} as const;\n\n/**\n * HyperLiquid order limits based on leverage\n * From: https://hyperliquid.gitbook.io/hyperliquid-docs/trading/contract-specifications\n */\nexport const HYPERLIQUID_ORDER_LIMITS = {\n // Market orders\n MarketOrderLimits: {\n // $15,000,000 for max leverage >= 25\n HighLeverage: 15_000_000,\n // $5,000,000 for max leverage in [20, 25)\n MediumHighLeverage: 5_000_000,\n // $2,000,000 for max leverage in [10, 20)\n MediumLeverage: 2_000_000,\n // $500,000 for max leverage < 10\n LowLeverage: 500_000,\n },\n // Limit orders are 10x market order limits\n LimitOrderMultiplier: 10,\n} as const;\n\n/**\n * Close position configuration\n * Controls behavior and constants specific to position closing\n */\nexport const CLOSE_POSITION_CONFIG = {\n // Decimal places for USD amount input display\n UsdDecimalPlaces: 2,\n\n // Default close percentage when opening the close position view\n DefaultClosePercentage: 100,\n\n // Precision for position size calculations to prevent rounding errors\n AmountCalculationPrecision: 6,\n\n // Throttle delay for real-time price updates during position closing\n PriceThrottleMs: 3000,\n\n // Fallback decimal places for tokens without metadata\n FallbackTokenDecimals: 18,\n} as const;\n\n/**\n * Margin adjustment configuration\n * Controls behavior for adding/removing margin from positions\n */\nexport const MARGIN_ADJUSTMENT_CONFIG = {\n // Risk thresholds for margin removal warnings\n // Threshold values represent ratio of (price distance to liquidation) / (liquidation price)\n // Values < 1.0 mean price is dangerously close to liquidation\n LiquidationRiskThreshold: 1.2, // 20% buffer before liquidation - triggers danger state\n LiquidationWarningThreshold: 1.5, // 50% buffer before liquidation - triggers warning state\n\n // Minimum margin adjustment amount (USD)\n // Prevents dust adjustments and ensures meaningful position changes\n MinAdjustmentAmount: 1,\n\n // Precision for margin calculations\n // Ensures accurate decimal handling in margin/leverage calculations\n CalculationPrecision: 6,\n\n // Safety buffer for margin removal to account for HyperLiquid's transfer margin requirement\n // HyperLiquid enforces: transfer_margin_required = max(initial_margin_required, 0.1 * total_position_value)\n // See: https://hyperliquid.gitbook.io/hyperliquid-docs/trading/margin-and-pnl\n MarginRemovalSafetyBuffer: 0.1,\n\n // Fallback max leverage when market data is unavailable\n // Conservative value to prevent over-removal of margin\n // Most HyperLiquid assets support at least 50x leverage\n FallbackMaxLeverage: 50,\n} as const;\n\n/**\n * Data Lake API configuration\n * Endpoints for reporting perps trading activity for notifications\n */\nexport const DATA_LAKE_API_CONFIG = {\n // Order reporting endpoint - only used for mainnet perps trading\n OrdersEndpoint: 'https://perps.api.cx.metamask.io/api/v1/orders',\n} as const;\n\n/**\n * Decimal precision configuration\n * Controls maximum decimal places for price and input validation\n */\nexport const DECIMAL_PRECISION_CONFIG = {\n // Maximum decimal places for price input (matches Hyperliquid limit)\n // Used in TP/SL forms, limit price inputs, and price validation\n MaxPriceDecimals: 6,\n // Maximum significant figures allowed by HyperLiquid API\n // Orders with more than 5 significant figures will be rejected\n MaxSignificantFigures: 5,\n // Defensive fallback for size decimals when market data fails to load\n // Real szDecimals should always come from market data API (varies by asset)\n // Using 6 as safe maximum to prevent crashes (covers most assets)\n // NOTE: This is NOT semantically correct - just a defensive measure\n FallbackSizeDecimals: 6,\n} as const;\n\n/**\n * Market sorting configuration\n * Controls sorting behavior and presets for the trending markets view\n */\nexport const MARKET_SORTING_CONFIG = {\n // Default sort settings\n DefaultSortOptionId: 'volume' as const,\n DefaultDirection: 'desc' as const,\n\n // Available sort fields (only includes fields supported by PerpsMarketData)\n SortFields: {\n Volume: 'volume',\n PriceChange: 'priceChange',\n OpenInterest: 'openInterest',\n FundingRate: 'fundingRate',\n } as const,\n\n // Sort button presets for filter chips (simplified buttons without direction)\n SortButtonPresets: [\n { field: 'volume', labelKey: 'perps.sort.volume' },\n { field: 'priceChange', labelKey: 'perps.sort.price_change' },\n { field: 'fundingRate', labelKey: 'perps.sort.funding_rate' },\n ] as const,\n\n // Sort options for the bottom sheet\n // All options support direction toggle (high-to-low / low-to-high)\n SortOptions: [\n {\n id: 'volume',\n labelKey: 'perps.sort.volume',\n field: 'volume',\n direction: 'desc',\n },\n {\n id: 'priceChange',\n labelKey: 'perps.sort.price_change',\n field: 'priceChange',\n direction: 'desc',\n },\n {\n id: 'openInterest',\n labelKey: 'perps.sort.open_interest',\n field: 'openInterest',\n direction: 'desc',\n },\n {\n id: 'fundingRate',\n labelKey: 'perps.sort.funding_rate',\n field: 'fundingRate',\n direction: 'desc',\n },\n ] as const,\n} as const;\n\n/**\n * Type for valid sort option IDs\n * Derived from SORT_OPTIONS to ensure type safety\n * Valid values: 'volume' | 'priceChange' | 'openInterest' | 'fundingRate'\n */\nexport type SortOptionId =\n (typeof MARKET_SORTING_CONFIG.SortOptions)[number]['id'];\n\n/**\n * Provider configuration for multi-provider support\n */\nexport const PROVIDER_CONFIG = {\n /** Default perpetual DEX provider when no explicit selection exists */\n DefaultProvider: 'hyperliquid' as const,\n /** Force MYX to testnet only (mainnet credentials not yet available) */\n MYX_TESTNET_ONLY: true,\n} as const;\n"]}
1
+ {"version":3,"file":"perpsConfig.cjs","sourceRoot":"","sources":["../../src/constants/perpsConfig.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACU,QAAA,YAAY,GAAG,4CAA4C,CAAC;AAC5D,QAAA,YAAY,GAAG,KAAK,CAAC;AAErB,QAAA,eAAe,GAAG;IAC7B,cAAc,EAAE,cAAc;IAC9B,WAAW,EAAE,OAAO,EAAE,kFAAkF;IACxG,sGAAsG;IACtG,4BAA4B,EAAE,eAAe;IAC7C,uFAAuF;IACvF,uBAAuB,EAAE,KAAK;IAC9B,gBAAgB,EAAE,IAAI,EAAE,YAAY;IACpC,qBAAqB,EAAE,IAAI,EAAE,WAAW;IACxC,yBAAyB,EAAE,KAAM,EAAE,6FAA6F;IAChI,mBAAmB,EAAE,KAAM,EAAE,gEAAgE;IAC7F,0BAA0B,EAAE,KAAM,EAAE,4DAA4D;IAEhG,8BAA8B;IAC9B,uBAAuB,EAAE,KAAM,EAAE,+GAA+G;IAChJ,0BAA0B,EAAE,KAAM,EAAE,2EAA2E;IAC/G,sBAAsB,EAAE,IAAK,EAAE,oDAAoD;IACnF,mBAAmB,EAAE,GAAG,EAAE,kEAAkE;IAC5F,0BAA0B,EAAE,GAAG,EAAE,uDAAuD;IACxF,0BAA0B,EAAE,GAAG,EAAE,+EAA+E;IAChH,sBAAsB,EAAE,GAAG,EAAE,0DAA0D;IACvF,wBAAwB,EAAE,IAAK,EAAE,gDAAgD;IACjF,wBAAwB,EAAE,CAAC,EAAE,kEAAkE;IAC/F,yBAAyB,EAAE,IAAK,EAAE,iFAAiF;IAEnH,sCAAsC;IACtC,uBAAuB,EAAE,KAAK,EAAE,oFAAoF;IACpH,kBAAkB,EAAE,GAAG,EAAE,qEAAqE;IAE9F,uBAAuB;IACvB,+BAA+B,EAAE,KAAM,E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W,EAAE,aAAa;KAClB;IAEV,8EAA8E;IAC9E,iBAAiB,EAAE;QACjB,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,mBAAmB,EAAE;QAClD,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,yBAAyB,EAAE;QAC7D,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,yBAAyB,EAAE;KACrD;IAEV,oCAAoC;IACpC,mEAAmE;IACnE,WAAW,EAAE;QACX;YACE,EAAE,EAAE,QAAQ;YACZ,QAAQ,EAAE,mBAAmB;YAC7B,KAAK,EAAE,QAAQ;YACf,SAAS,EAAE,MAAM;SAClB;QACD;YACE,EAAE,EAAE,aAAa;YACjB,QAAQ,EAAE,yBAAyB;YACnC,KAAK,EAAE,aAAa;YACpB,SAAS,EAAE,MAAM;SAClB;QACD;YACE,EAAE,EAAE,cAAc;YAClB,QAAQ,EAAE,0BAA0B;YACpC,KAAK,EAAE,cAAc;YACrB,SAAS,EAAE,MAAM;SAClB;QACD;YACE,EAAE,EAAE,aAAa;YACjB,QAAQ,EAAE,yBAAyB;YACnC,KAAK,EAAE,aAAa;YACpB,SAAS,EAAE,MAAM;SAClB;KACO;CACF,CAAC;AAUX;;GAEG;AACU,QAAA,eAAe,GAAG;IAC7B,uEAAuE;IACvE,eAAe,EAAE,aAAsB;IACvC,wEAAwE;IACxE,gBAAgB,EAAE,KAAK;CACf,CAAC","sourcesContent":["/**\n * Perps feature constants - Controller layer (portable)\n *\n * This file contains only controller-portable configuration:\n * - Constants used by controller logic, providers, and services\n * - Calculation thresholds, API configs, and protocol constants\n *\n * UI-only constants (layout, display, navigation) live in:\n * app/components/UI/Perps/constants/perpsConfig.ts\n */\nexport const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';\nexport const ZERO_BALANCE = '0x0';\n\nexport const PERPS_CONSTANTS = {\n FeatureFlagKey: 'perpsEnabled',\n FeatureName: 'perps', // Constant for Sentry error filtering - enables \"feature:perps\" dashboard queries\n /** Token description used to identify the synthetic \"Perps balance\" option in pay-with token lists */\n PerpsBalanceTokenDescription: 'perps-balance',\n /** Symbol displayed for the synthetic \"Perps balance\" token in pay-with token lists */\n PerpsBalanceTokenSymbol: 'USD',\n WebsocketTimeout: 5000, // 5 seconds\n WebsocketCleanupDelay: 1000, // 1 second\n BackgroundDisconnectDelay: 20_000, // 20 seconds delay before disconnecting when app is backgrounded or when user exits perps UX\n ConnectionTimeoutMs: 10_000, // 10 seconds timeout for connection and position loading states\n DefaultMonitoringTimeoutMs: 10_000, // 10 seconds default timeout for data monitoring operations\n\n // Connection timing constants\n ConnectionGracePeriodMs: 20_000, // 20 seconds grace period before actual disconnection (same as BackgroundDisconnectDelay for semantic clarity)\n ConnectionAttemptTimeoutMs: 30_000, // 30 seconds timeout for connection attempts to prevent indefinite hanging\n WebsocketPingTimeoutMs: 5_000, // 5 seconds timeout for WebSocket health check ping\n ConnectRetryDelayMs: 200, // Delay before retrying connect() when connection isn't ready yet\n ReconnectionCleanupDelayMs: 500, // Platform-agnostic delay to ensure WebSocket is ready\n ReconnectionDelayAndroidMs: 300, // Android-specific reconnection delay for better reliability on slower devices\n ReconnectionDelayIosMs: 100, // iOS-specific reconnection delay for optimal performance\n ReconnectionRetryDelayMs: 5_000, // 5 seconds delay between reconnection attempts\n NetworkRestoreMaxRetries: 8, // Max retry attempts when reconnecting after WiFi/network restore\n NetworkRestoreRetryBaseMs: 1_500, // Base delay (ms) between network restore retries (multiplied by attempt number)\n\n // Connection manager timing constants\n BalanceUpdateThrottleMs: 15000, // Update at most every 15 seconds to reduce state updates in PerpsConnectionManager\n InitialDataDelayMs: 100, // Delay to allow initial data to load after connection establishment\n\n // Deposit toast timing\n DepositTakingLongerToastDelayMs: 30_000, // Delay before showing \"Deposit taking longer than usual\" toast\n\n DefaultAssetPreviewLimit: 5,\n DefaultMaxLeverage: 3 as number, // Default fallback max leverage when market data is unavailable - conservative default\n FallbackPriceDisplay: '$---', // Display when price data is unavailable\n FallbackPercentageDisplay: '--%', // Display when change data is unavailable\n FallbackDataDisplay: '--', // Display when non-price data is unavailable\n ZeroAmountDisplay: '$0', // Display for zero dollar amounts (e.g., no volume)\n ZeroAmountDetailedDisplay: '$0.00', // Display for zero dollar amounts with decimals\n\n RecentActivityLimit: 3,\n\n // Historical data fetching constants\n FillsLookbackMs: 90 * 24 * 60 * 60 * 1000, // 3 months in milliseconds - limits REST API fills fetch\n} as const;\n\n/**\n * Withdrawal-specific constants (protocol-agnostic)\n * Note: Protocol-specific values like estimated time should be defined in each protocol's config\n */\nexport const WITHDRAWAL_CONSTANTS = {\n DefaultMinAmount: '1.01', // Default minimum withdrawal amount in USDC\n DefaultFeeAmount: 1, // Default withdrawal fee in USDC\n DefaultFeeToken: 'USDC', // Default fee token\n} as const;\n\n/**\n * Validation thresholds for UI warnings and checks\n * These values control when warnings are shown to users\n */\nexport const VALIDATION_THRESHOLDS = {\n // Leverage threshold for warning users about high leverage\n HighLeverageWarning: 20, // Show warning when leverage > 20x\n\n // Limit price difference threshold (as decimal, 0.1 = 10%)\n LimitPriceDifferenceWarning: 0.1, // Warn if limit price differs by >10% from current price\n\n // Price deviation threshold (as decimal, 0.1 = 10%)\n PriceDeviation: 0.1, // Warn if perps price deviates by >10% from spot price\n} as const;\n\n/**\n * Order slippage configuration\n * Controls default slippage tolerance for different order types\n * Conservative defaults based on HyperLiquid platform interface\n * See: docs/perps/hyperliquid/ORDER-MATCHING-ERRORS.md\n */\nexport const ORDER_SLIPPAGE_CONFIG = {\n // Market order slippage (basis points)\n // 300 basis points = 3% = 0.03 decimal\n // Conservative default for measured rollout, prevents most IOC failures\n DefaultMarketSlippageBps: 300,\n\n // TP/SL order slippage (basis points)\n // 1000 basis points = 10% = 0.10 decimal\n // Aligns with HyperLiquid platform default for triggered orders\n DefaultTpslSlippageBps: 1000,\n\n // Limit order slippage (basis points)\n // 100 basis points = 1% = 0.01 decimal\n // Kept conservative as limit orders rest on book (not IOC/immediate execution)\n DefaultLimitSlippageBps: 100,\n} as const;\n\n/**\n * Performance optimization constants\n * These values control debouncing and throttling for better performance\n */\nexport const PERFORMANCE_CONFIG = {\n // Price updates debounce delay (milliseconds)\n // Batches rapid WebSocket price updates to reduce re-renders\n PriceUpdateDebounceMs: 1000,\n\n // Order validation debounce delay (milliseconds)\n // Prevents excessive validation calls during rapid form input changes\n ValidationDebounceMs: 300,\n\n // Liquidation price debounce delay (milliseconds)\n // Prevents excessive liquidation price calls during rapid form input changes\n LiquidationPriceDebounceMs: 500,\n\n // Navigation params delay (milliseconds)\n // Required for React Navigation to complete state transitions before setting params\n // This ensures navigation context is available when programmatically selecting tabs\n NavigationParamsDelayMs: 200,\n\n // Tab control reset delay (milliseconds)\n // Delay to reset programmatic tab control after tab switching to prevent render loops\n TabControlResetDelayMs: 500,\n\n // Market data cache duration (milliseconds)\n // How long to cache market list data before fetching fresh data\n MarketDataCacheDurationMs: 5 * 60 * 1000, // 5 minutes\n\n // Asset metadata cache duration (milliseconds)\n // How long to cache asset icon validation results\n AssetMetadataCacheDurationMs: 60 * 60 * 1000, // 1 hour\n\n // Max leverage cache duration (milliseconds)\n // How long to cache max leverage values per asset (leverage rarely changes)\n MaxLeverageCacheDurationMs: 60 * 60 * 1000, // 1 hour\n\n // Rewards cache durations (milliseconds)\n // How long to cache fee discount data from rewards API\n FeeDiscountCacheDurationMs: 5 * 60 * 1000, // 5 minutes\n // How long to cache points calculation parameters from rewards API\n PointsCalculationCacheDurationMs: 5 * 60 * 1000, // 5 minutes\n\n /**\n * Performance logging markers for filtering logs during development and debugging\n * These markers help isolate performance-related logs from general application logs\n * Usage: Use in DevLogger calls to easily filter specific performance areas\n * Impact: Development only (uses DevLogger) - zero production performance cost\n *\n * Examples:\n * - Filter Sentry performance logs: `adb logcat | grep PERPSMARK_SENTRY`\n * - Filter MetaMetrics events: `adb logcat | grep PERPSMARK_METRICS`\n * - Filter WebSocket performance: `adb logcat | grep PERPSMARK_WS`\n * - Filter all Perps performance: `adb logcat | grep PERPSMARK_`\n */\n LoggingMarkers: {\n // Sentry performance measurement logs (screen loads, bottom sheets, API timing)\n SentryPerformance: 'PERPSMARK_SENTRY',\n\n // MetaMetrics event tracking logs (user interactions, business analytics)\n MetametricsEvents: 'PERPSMARK_METRICS',\n\n // WebSocket performance logs (connection timing, data flow, reconnections)\n WebsocketPerformance: 'PERPSMARK_SENTRY_WS',\n } as const,\n} as const;\n\nexport const TP_SL_CONFIG = {\n UsePositionBoundTpsl: true,\n} as const;\n\n/**\n * HyperLiquid order limits based on leverage\n * From: https://hyperliquid.gitbook.io/hyperliquid-docs/trading/contract-specifications\n */\nexport const HYPERLIQUID_ORDER_LIMITS = {\n // Market orders\n MarketOrderLimits: {\n // $15,000,000 for max leverage >= 25\n HighLeverage: 15_000_000,\n // $5,000,000 for max leverage in [20, 25)\n MediumHighLeverage: 5_000_000,\n // $2,000,000 for max leverage in [10, 20)\n MediumLeverage: 2_000_000,\n // $500,000 for max leverage < 10\n LowLeverage: 500_000,\n },\n // Limit orders are 10x market order limits\n LimitOrderMultiplier: 10,\n} as const;\n\n/**\n * Close position configuration\n * Controls behavior and constants specific to position closing\n */\nexport const CLOSE_POSITION_CONFIG = {\n // Decimal places for USD amount input display\n UsdDecimalPlaces: 2,\n\n // Default close percentage when opening the close position view\n DefaultClosePercentage: 100,\n\n // Precision for position size calculations to prevent rounding errors\n AmountCalculationPrecision: 6,\n\n // Throttle delay for real-time price updates during position closing\n PriceThrottleMs: 3000,\n\n // Fallback decimal places for tokens without metadata\n FallbackTokenDecimals: 18,\n} as const;\n\n/**\n * Margin adjustment configuration\n * Controls behavior for adding/removing margin from positions\n */\nexport const MARGIN_ADJUSTMENT_CONFIG = {\n // Risk thresholds for margin removal warnings\n // Threshold values represent ratio of (price distance to liquidation) / (liquidation price)\n // Values < 1.0 mean price is dangerously close to liquidation\n LiquidationRiskThreshold: 1.2, // 20% buffer before liquidation - triggers danger state\n LiquidationWarningThreshold: 1.5, // 50% buffer before liquidation - triggers warning state\n\n // Minimum margin adjustment amount (USD)\n // Prevents dust adjustments and ensures meaningful position changes\n MinAdjustmentAmount: 1,\n\n // Precision for margin calculations\n // Ensures accurate decimal handling in margin/leverage calculations\n CalculationPrecision: 6,\n\n // Safety buffer for margin removal to account for HyperLiquid's transfer margin requirement\n // HyperLiquid enforces: transfer_margin_required = max(initial_margin_required, 0.1 * total_position_value)\n // See: https://hyperliquid.gitbook.io/hyperliquid-docs/trading/margin-and-pnl\n MarginRemovalSafetyBuffer: 0.1,\n\n // Fallback max leverage when market data is unavailable\n // Conservative value to prevent over-removal of margin\n // Most HyperLiquid assets support at least 50x leverage\n FallbackMaxLeverage: 50,\n} as const;\n\n/**\n * Data Lake API configuration\n * Endpoints for reporting perps trading activity for notifications\n */\nexport const DATA_LAKE_API_CONFIG = {\n // Order reporting endpoint - only used for mainnet perps trading\n OrdersEndpoint: 'https://perps.api.cx.metamask.io/api/v1/orders',\n} as const;\n\n/**\n * Decimal precision configuration\n * Controls maximum decimal places for price and input validation\n */\nexport const DECIMAL_PRECISION_CONFIG = {\n // Maximum decimal places for price input (matches Hyperliquid limit)\n // Used in TP/SL forms, limit price inputs, and price validation\n MaxPriceDecimals: 6,\n // Maximum significant figures allowed by HyperLiquid API\n // Orders with more than 5 significant figures will be rejected\n MaxSignificantFigures: 5,\n // Defensive fallback for size decimals when market data fails to load\n // Real szDecimals should always come from market data API (varies by asset)\n // Using 6 as safe maximum to prevent crashes (covers most assets)\n // NOTE: This is NOT semantically correct - just a defensive measure\n FallbackSizeDecimals: 6,\n} as const;\n\n/**\n * Market sorting configuration\n * Controls sorting behavior and presets for the trending markets view\n */\nexport const MARKET_SORTING_CONFIG = {\n // Default sort settings\n DefaultSortOptionId: 'volume' as const,\n DefaultDirection: 'desc' as const,\n\n // Available sort fields (only includes fields supported by PerpsMarketData)\n SortFields: {\n Volume: 'volume',\n PriceChange: 'priceChange',\n OpenInterest: 'openInterest',\n FundingRate: 'fundingRate',\n } as const,\n\n // Sort button presets for filter chips (simplified buttons without direction)\n SortButtonPresets: [\n { field: 'volume', labelKey: 'perps.sort.volume' },\n { field: 'priceChange', labelKey: 'perps.sort.price_change' },\n { field: 'fundingRate', labelKey: 'perps.sort.funding_rate' },\n ] as const,\n\n // Sort options for the bottom sheet\n // All options support direction toggle (high-to-low / low-to-high)\n SortOptions: [\n {\n id: 'volume',\n labelKey: 'perps.sort.volume',\n field: 'volume',\n direction: 'desc',\n },\n {\n id: 'priceChange',\n labelKey: 'perps.sort.price_change',\n field: 'priceChange',\n direction: 'desc',\n },\n {\n id: 'openInterest',\n labelKey: 'perps.sort.open_interest',\n field: 'openInterest',\n direction: 'desc',\n },\n {\n id: 'fundingRate',\n labelKey: 'perps.sort.funding_rate',\n field: 'fundingRate',\n direction: 'desc',\n },\n ] as const,\n} as const;\n\n/**\n * Type for valid sort option IDs\n * Derived from SORT_OPTIONS to ensure type safety\n * Valid values: 'volume' | 'priceChange' | 'openInterest' | 'fundingRate'\n */\nexport type SortOptionId =\n (typeof MARKET_SORTING_CONFIG.SortOptions)[number]['id'];\n\n/**\n * Provider configuration for multi-provider support\n */\nexport const PROVIDER_CONFIG = {\n /** Default perpetual DEX provider when no explicit selection exists */\n DefaultProvider: 'hyperliquid' as const,\n /** Force MYX to testnet only (mainnet credentials not yet available) */\n MYX_TESTNET_ONLY: false,\n} as const;\n"]}
@@ -8,6 +8,8 @@
8
8
  * UI-only constants (layout, display, navigation) live in:
9
9
  * app/components/UI/Perps/constants/perpsConfig.ts
10
10
  */
11
+ export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
12
+ export declare const ZERO_BALANCE = "0x0";
11
13
  export declare const PERPS_CONSTANTS: {
12
14
  readonly FeatureFlagKey: "perpsEnabled";
13
15
  readonly FeatureName: "perps";
@@ -28,6 +30,8 @@ export declare const PERPS_CONSTANTS: {
28
30
  readonly ReconnectionDelayAndroidMs: 300;
29
31
  readonly ReconnectionDelayIosMs: 100;
30
32
  readonly ReconnectionRetryDelayMs: 5000;
33
+ readonly NetworkRestoreMaxRetries: 8;
34
+ readonly NetworkRestoreRetryBaseMs: 1500;
31
35
  readonly BalanceUpdateThrottleMs: 15000;
32
36
  readonly InitialDataDelayMs: 100;
33
37
  readonly DepositTakingLongerToastDelayMs: 30000;
@@ -216,6 +220,6 @@ export declare const PROVIDER_CONFIG: {
216
220
  /** Default perpetual DEX provider when no explicit selection exists */
217
221
  readonly DefaultProvider: "hyperliquid";
218
222
  /** Force MYX to testnet only (mainnet credentials not yet available) */
219
- readonly MYX_TESTNET_ONLY: true;
223
+ readonly MYX_TESTNET_ONLY: false;
220
224
  };
221
225
  //# sourceMappingURL=perpsConfig.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"perpsConfig.d.cts","sourceRoot":"","sources":["../../src/constants/perpsConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;;IAG1B,sGAAsG;;IAEtG,uFAAuF;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqC/E,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;CAIvB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;CASxB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;;CAexB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;IAwC7B;;;;;;;;;;;OAWG;;;;;;CAWK,CAAC;AAEX,eAAO,MAAM,YAAY;;CAEf,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;CAc3B,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;CAexB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;;;CAwB3B,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;CAGvB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;CAY3B,CAAC;AAEX;;;G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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDxB,CAAC;AAEX;;;;GAIG;AACH,MAAM,MAAM,YAAY,GACtB,CAAC,OAAO,qBAAqB,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,eAAe;IAC1B,uEAAuE;;IAEvE,wEAAwE;;CAEhE,CAAC"}
@@ -8,6 +8,8 @@
8
8
  * UI-only constants (layout, display, navigation) live in:
9
9
  * app/components/UI/Perps/constants/perpsConfig.ts
10
10
  */
11
+ export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
12
+ export declare const ZERO_BALANCE = "0x0";
11
13
  export declare const PERPS_CONSTANTS: {
12
14
  readonly FeatureFlagKey: "perpsEnabled";
13
15
  readonly FeatureName: "perps";
@@ -28,6 +30,8 @@ export declare const PERPS_CONSTANTS: {
28
30
  readonly ReconnectionDelayAndroidMs: 300;
29
31
  readonly ReconnectionDelayIosMs: 100;
30
32
  readonly ReconnectionRetryDelayMs: 5000;
33
+ readonly NetworkRestoreMaxRetries: 8;
34
+ readonly NetworkRestoreRetryBaseMs: 1500;
31
35
  readonly BalanceUpdateThrottleMs: 15000;
32
36
  readonly InitialDataDelayMs: 100;
33
37
  readonly DepositTakingLongerToastDelayMs: 30000;
@@ -216,6 +220,6 @@ export declare const PROVIDER_CONFIG: {
216
220
  /** Default perpetual DEX provider when no explicit selection exists */
217
221
  readonly DefaultProvider: "hyperliquid";
218
222
  /** Force MYX to testnet only (mainnet credentials not yet available) */
219
- readonly MYX_TESTNET_ONLY: true;
223
+ readonly MYX_TESTNET_ONLY: false;
220
224
  };
221
225
  //# sourceMappingURL=perpsConfig.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"perpsConfig.d.mts","sourceRoot":"","sources":["../../src/constants/perpsConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;;IAG1B,sGAAsG;;I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;;;;CAuC/E,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;CAIvB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;CASxB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;;CAexB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;IAwC7B;;;;;;;;;;;OAWG;;;;;;CAWK,CAAC;AAEX,eAAO,MAAM,YAAY;;CAEf,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;CAc3B,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;CAexB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;;;CAwB3B,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;CAGvB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;CAY3B,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDxB,CAAC;AAEX;;;;GAIG;AACH,MAAM,MAAM,YAAY,GACtB,CAAC,OAAO,qBAAqB,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,eAAe;IAC1B,uEAAuE;;IAEvE,wEAAwE;;CAEhE,CAAC"}
@@ -8,6 +8,8 @@
8
8
  * UI-only constants (layout, display, navigation) live in:
9
9
  * app/components/UI/Perps/constants/perpsConfig.ts
10
10
  */
11
+ export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
12
+ export const ZERO_BALANCE = '0x0';
11
13
  export const PERPS_CONSTANTS = {
12
14
  FeatureFlagKey: 'perpsEnabled',
13
15
  FeatureName: 'perps', // Constant for Sentry error filtering - enables "feature:perps" dashboard queries
@@ -29,6 +31,8 @@ export const PERPS_CONSTANTS = {
29
31
  ReconnectionDelayAndroidMs: 300, // Android-specific reconnection delay for better reliability on slower devices
30
32
  ReconnectionDelayIosMs: 100, // iOS-specific reconnection delay for optimal performance
31
33
  ReconnectionRetryDelayMs: 5000, // 5 seconds delay between reconnection attempts
34
+ NetworkRestoreMaxRetries: 8, // Max retry attempts when reconnecting after WiFi/network restore
35
+ NetworkRestoreRetryBaseMs: 1500, // Base delay (ms) between network restore retries (multiplied by attempt number)
32
36
  // Connection manager timing constants
33
37
  BalanceUpdateThrottleMs: 15000, // Update at most every 15 seconds to reduce state updates in PerpsConnectionManager
34
38
  InitialDataDelayMs: 100, // Delay to allow initial data to load after connection establishment
@@ -287,6 +291,6 @@ export const PROVIDER_CONFIG = {
287
291
  /** Default perpetual DEX provider when no explicit selection exists */
288
292
  DefaultProvider: 'hyperliquid',
289
293
  /** Force MYX to testnet only (mainnet credentials not yet available) */
290
- MYX_TESTNET_ONLY: true,
294
+ MYX_TESTNET_ONLY: false,
291
295
  };
292
296
  //# sourceMappingURL=perpsConfig.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"perpsConfig.mjs","sourceRoot":"","sources":["../../src/constants/perpsConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,cAAc,EAAE,cAAc;IAC9B,WAAW,EAAE,OAAO,EAAE,kFAAkF;IACxG,sGAAsG;IACtG,4BAA4B,EAAE,eAAe;IAC7C,uFAAuF;IACvF,uBAAuB,EAAE,KAAK;IAC9B,gBAAgB,EAAE,IAAI,EAAE,YAAY;IACpC,qBAAqB,EAAE,IAAI,EAAE,WAAW;IACxC,yBAAyB,EAAE,KAAM,EAAE,6FAA6F;IAChI,mBAAmB,EAAE,KAAM,EAAE,gEAAgE;IAC7F,0BAA0B,EAAE,KAAM,EAAE,4DAA4D;IAEhG,8BAA8B;IAC9B,uBAAuB,EAAE,KAAM,EAAE,+GAA+G;IAChJ,0BAA0B,EA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B;YACnC,KAAK,EAAE,aAAa;YACpB,SAAS,EAAE,MAAM;SAClB;KACO;CACF,CAAC;AAUX;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,uEAAuE;IACvE,eAAe,EAAE,aAAsB;IACvC,wEAAwE;IACxE,gBAAgB,EAAE,IAAI;CACd,CAAC","sourcesContent":["/**\n * Perps feature constants - Controller layer (portable)\n *\n * This file contains only controller-portable configuration:\n * - Constants used by controller logic, providers, and services\n * - Calculation thresholds, API configs, and protocol constants\n *\n * UI-only constants (layout, display, navigation) live in:\n * app/components/UI/Perps/constants/perpsConfig.ts\n */\nexport const PERPS_CONSTANTS = {\n FeatureFlagKey: 'perpsEnabled',\n FeatureName: 'perps', // Constant for Sentry error filtering - enables \"feature:perps\" dashboard queries\n /** Token description used to identify the synthetic \"Perps balance\" option in pay-with token lists */\n PerpsBalanceTokenDescription: 'perps-balance',\n /** Symbol displayed for the synthetic \"Perps balance\" token in pay-with token lists */\n PerpsBalanceTokenSymbol: 'USD',\n WebsocketTimeout: 5000, // 5 seconds\n WebsocketCleanupDelay: 1000, // 1 second\n BackgroundDisconnectDelay: 20_000, // 20 seconds delay before disconnecting when app is backgrounded or when user exits perps UX\n ConnectionTimeoutMs: 10_000, // 10 seconds timeout for connection and position loading states\n DefaultMonitoringTimeoutMs: 10_000, // 10 seconds default timeout for data monitoring operations\n\n // Connection timing constants\n ConnectionGracePeriodMs: 20_000, // 20 seconds grace period before actual disconnection (same as BackgroundDisconnectDelay for semantic clarity)\n ConnectionAttemptTimeoutMs: 30_000, // 30 seconds timeout for connection attempts to prevent indefinite hanging\n WebsocketPingTimeoutMs: 5_000, // 5 seconds timeout for WebSocket health check ping\n ConnectRetryDelayMs: 200, // Delay before retrying connect() when connection isn't ready yet\n ReconnectionCleanupDelayMs: 500, // Platform-agnostic delay to ensure WebSocket is ready\n ReconnectionDelayAndroidMs: 300, // Android-specific reconnection delay for better reliability on slower devices\n ReconnectionDelayIosMs: 100, // iOS-specific reconnection delay for optimal performance\n ReconnectionRetryDelayMs: 5_000, // 5 seconds delay between reconnection attempts\n\n // Connection manager timing constants\n BalanceUpdateThrottleMs: 15000, // Update at most every 15 seconds to reduce state updates in PerpsConnectionManager\n InitialDataDelayMs: 100, // Delay to allow initial data to load after connection establishment\n\n // Deposit toast timing\n DepositTakingLongerToastDelayMs: 30_000, // Delay before showing \"Deposit taking longer than usual\" toast\n\n DefaultAssetPreviewLimit: 5,\n DefaultMaxLeverage: 3 as number, // Default fallback max leverage when market data is unavailable - conservative default\n FallbackPriceDisplay: '$---', // Display when price data is unavailable\n FallbackPercentageDisplay: '--%', // Display when change data is unavailable\n FallbackDataDisplay: '--', // Display when non-price data is unavailable\n ZeroAmountDisplay: '$0', // Display for zero dollar amounts (e.g., no volume)\n ZeroAmountDetailedDisplay: '$0.00', // Display for zero dollar amounts with decimals\n\n RecentActivityLimit: 3,\n\n // Historical data fetching constants\n FillsLookbackMs: 90 * 24 * 60 * 60 * 1000, // 3 months in milliseconds - limits REST API fills fetch\n} as const;\n\n/**\n * Withdrawal-specific constants (protocol-agnostic)\n * Note: Protocol-specific values like estimated time should be defined in each protocol's config\n */\nexport const WITHDRAWAL_CONSTANTS = {\n DefaultMinAmount: '1.01', // Default minimum withdrawal amount in USDC\n DefaultFeeAmount: 1, // Default withdrawal fee in USDC\n DefaultFeeToken: 'USDC', // Default fee token\n} as const;\n\n/**\n * Validation thresholds for UI warnings and checks\n * These values control when warnings are shown to users\n */\nexport const VALIDATION_THRESHOLDS = {\n // Leverage threshold for warning users about high leverage\n HighLeverageWarning: 20, // Show warning when leverage > 20x\n\n // Limit price difference threshold (as decimal, 0.1 = 10%)\n LimitPriceDifferenceWarning: 0.1, // Warn if limit price differs by >10% from current price\n\n // Price deviation threshold (as decimal, 0.1 = 10%)\n PriceDeviation: 0.1, // Warn if perps price deviates by >10% from spot price\n} as const;\n\n/**\n * Order slippage configuration\n * Controls default slippage tolerance for different order types\n * Conservative defaults based on HyperLiquid platform interface\n * See: docs/perps/hyperliquid/ORDER-MATCHING-ERRORS.md\n */\nexport const ORDER_SLIPPAGE_CONFIG = {\n // Market order slippage (basis points)\n // 300 basis points = 3% = 0.03 decimal\n // Conservative default for measured rollout, prevents most IOC failures\n DefaultMarketSlippageBps: 300,\n\n // TP/SL order slippage (basis points)\n // 1000 basis points = 10% = 0.10 decimal\n // Aligns with HyperLiquid platform default for triggered orders\n DefaultTpslSlippageBps: 1000,\n\n // Limit order slippage (basis points)\n // 100 basis points = 1% = 0.01 decimal\n // Kept conservative as limit orders rest on book (not IOC/immediate execution)\n DefaultLimitSlippageBps: 100,\n} as const;\n\n/**\n * Performance optimization constants\n * These values control debouncing and throttling for better performance\n */\nexport const PERFORMANCE_CONFIG = {\n // Price updates debounce delay (milliseconds)\n // Batches rapid WebSocket price updates to reduce re-renders\n PriceUpdateDebounceMs: 1000,\n\n // Order validation debounce delay (milliseconds)\n // Prevents excessive validation calls during rapid form input changes\n ValidationDebounceMs: 300,\n\n // Liquidation price debounce delay (milliseconds)\n // Prevents excessive liquidation price calls during rapid form input changes\n LiquidationPriceDebounceMs: 500,\n\n // Navigation params delay (milliseconds)\n // Required for React Navigation to complete state transitions before setting params\n // This ensures navigation context is available when programmatically selecting tabs\n NavigationParamsDelayMs: 200,\n\n // Tab control reset delay (milliseconds)\n // Delay to reset programmatic tab control after tab switching to prevent render loops\n TabControlResetDelayMs: 500,\n\n // Market data cache duration (milliseconds)\n // How long to cache market list data before fetching fresh data\n MarketDataCacheDurationMs: 5 * 60 * 1000, // 5 minutes\n\n // Asset metadata cache duration (milliseconds)\n // How long to cache asset icon validation results\n AssetMetadataCacheDurationMs: 60 * 60 * 1000, // 1 hour\n\n // Max leverage cache duration (milliseconds)\n // How long to cache max leverage values per asset (leverage rarely changes)\n MaxLeverageCacheDurationMs: 60 * 60 * 1000, // 1 hour\n\n // Rewards cache durations (milliseconds)\n // How long to cache fee discount data from rewards API\n FeeDiscountCacheDurationMs: 5 * 60 * 1000, // 5 minutes\n // How long to cache points calculation parameters from rewards API\n PointsCalculationCacheDurationMs: 5 * 60 * 1000, // 5 minutes\n\n /**\n * Performance logging markers for filtering logs during development and debugging\n * These markers help isolate performance-related logs from general application logs\n * Usage: Use in DevLogger calls to easily filter specific performance areas\n * Impact: Development only (uses DevLogger) - zero production performance cost\n *\n * Examples:\n * - Filter Sentry performance logs: `adb logcat | grep PERPSMARK_SENTRY`\n * - Filter MetaMetrics events: `adb logcat | grep PERPSMARK_METRICS`\n * - Filter WebSocket performance: `adb logcat | grep PERPSMARK_WS`\n * - Filter all Perps performance: `adb logcat | grep PERPSMARK_`\n */\n LoggingMarkers: {\n // Sentry performance measurement logs (screen loads, bottom sheets, API timing)\n SentryPerformance: 'PERPSMARK_SENTRY',\n\n // MetaMetrics event tracking logs (user interactions, business analytics)\n MetametricsEvents: 'PERPSMARK_METRICS',\n\n // WebSocket performance logs (connection timing, data flow, reconnections)\n WebsocketPerformance: 'PERPSMARK_SENTRY_WS',\n } as const,\n} as const;\n\nexport const TP_SL_CONFIG = {\n UsePositionBoundTpsl: true,\n} as const;\n\n/**\n * HyperLiquid order limits based on leverage\n * From: https://hyperliquid.gitbook.io/hyperliquid-docs/trading/contract-specifications\n */\nexport const HYPERLIQUID_ORDER_LIMITS = {\n // Market orders\n MarketOrderLimits: {\n // $15,000,000 for max leverage >= 25\n HighLeverage: 15_000_000,\n // $5,000,000 for max leverage in [20, 25)\n MediumHighLeverage: 5_000_000,\n // $2,000,000 for max leverage in [10, 20)\n MediumLeverage: 2_000_000,\n // $500,000 for max leverage < 10\n LowLeverage: 500_000,\n },\n // Limit orders are 10x market order limits\n LimitOrderMultiplier: 10,\n} as const;\n\n/**\n * Close position configuration\n * Controls behavior and constants specific to position closing\n */\nexport const CLOSE_POSITION_CONFIG = {\n // Decimal places for USD amount input display\n UsdDecimalPlaces: 2,\n\n // Default close percentage when opening the close position view\n DefaultClosePercentage: 100,\n\n // Precision for position size calculations to prevent rounding errors\n AmountCalculationPrecision: 6,\n\n // Throttle delay for real-time price updates during position closing\n PriceThrottleMs: 3000,\n\n // Fallback decimal places for tokens without metadata\n FallbackTokenDecimals: 18,\n} as const;\n\n/**\n * Margin adjustment configuration\n * Controls behavior for adding/removing margin from positions\n */\nexport const MARGIN_ADJUSTMENT_CONFIG = {\n // Risk thresholds for margin removal warnings\n // Threshold values represent ratio of (price distance to liquidation) / (liquidation price)\n // Values < 1.0 mean price is dangerously close to liquidation\n LiquidationRiskThreshold: 1.2, // 20% buffer before liquidation - triggers danger state\n LiquidationWarningThreshold: 1.5, // 50% buffer before liquidation - triggers warning state\n\n // Minimum margin adjustment amount (USD)\n // Prevents dust adjustments and ensures meaningful position changes\n MinAdjustmentAmount: 1,\n\n // Precision for margin calculations\n // Ensures accurate decimal handling in margin/leverage calculations\n CalculationPrecision: 6,\n\n // Safety buffer for margin removal to account for HyperLiquid's transfer margin requirement\n // HyperLiquid enforces: transfer_margin_required = max(initial_margin_required, 0.1 * total_position_value)\n // See: https://hyperliquid.gitbook.io/hyperliquid-docs/trading/margin-and-pnl\n MarginRemovalSafetyBuffer: 0.1,\n\n // Fallback max leverage when market data is unavailable\n // Conservative value to prevent over-removal of margin\n // Most HyperLiquid assets support at least 50x leverage\n FallbackMaxLeverage: 50,\n} as const;\n\n/**\n * Data Lake API configuration\n * Endpoints for reporting perps trading activity for notifications\n */\nexport const DATA_LAKE_API_CONFIG = {\n // Order reporting endpoint - only used for mainnet perps trading\n OrdersEndpoint: 'https://perps.api.cx.metamask.io/api/v1/orders',\n} as const;\n\n/**\n * Decimal precision configuration\n * Controls maximum decimal places for price and input validation\n */\nexport const DECIMAL_PRECISION_CONFIG = {\n // Maximum decimal places for price input (matches Hyperliquid limit)\n // Used in TP/SL forms, limit price inputs, and price validation\n MaxPriceDecimals: 6,\n // Maximum significant figures allowed by HyperLiquid API\n // Orders with more than 5 significant figures will be rejected\n MaxSignificantFigures: 5,\n // Defensive fallback for size decimals when market data fails to load\n // Real szDecimals should always come from market data API (varies by asset)\n // Using 6 as safe maximum to prevent crashes (covers most assets)\n // NOTE: This is NOT semantically correct - just a defensive measure\n FallbackSizeDecimals: 6,\n} as const;\n\n/**\n * Market sorting configuration\n * Controls sorting behavior and presets for the trending markets view\n */\nexport const MARKET_SORTING_CONFIG = {\n // Default sort settings\n DefaultSortOptionId: 'volume' as const,\n DefaultDirection: 'desc' as const,\n\n // Available sort fields (only includes fields supported by PerpsMarketData)\n SortFields: {\n Volume: 'volume',\n PriceChange: 'priceChange',\n OpenInterest: 'openInterest',\n FundingRate: 'fundingRate',\n } as const,\n\n // Sort button presets for filter chips (simplified buttons without direction)\n SortButtonPresets: [\n { field: 'volume', labelKey: 'perps.sort.volume' },\n { field: 'priceChange', labelKey: 'perps.sort.price_change' },\n { field: 'fundingRate', labelKey: 'perps.sort.funding_rate' },\n ] as const,\n\n // Sort options for the bottom sheet\n // All options support direction toggle (high-to-low / low-to-high)\n SortOptions: [\n {\n id: 'volume',\n labelKey: 'perps.sort.volume',\n field: 'volume',\n direction: 'desc',\n },\n {\n id: 'priceChange',\n labelKey: 'perps.sort.price_change',\n field: 'priceChange',\n direction: 'desc',\n },\n {\n id: 'openInterest',\n labelKey: 'perps.sort.open_interest',\n field: 'openInterest',\n direction: 'desc',\n },\n {\n id: 'fundingRate',\n labelKey: 'perps.sort.funding_rate',\n field: 'fundingRate',\n direction: 'desc',\n },\n ] as const,\n} as const;\n\n/**\n * Type for valid sort option IDs\n * Derived from SORT_OPTIONS to ensure type safety\n * Valid values: 'volume' | 'priceChange' | 'openInterest' | 'fundingRate'\n */\nexport type SortOptionId =\n (typeof MARKET_SORTING_CONFIG.SortOptions)[number]['id'];\n\n/**\n * Provider configuration for multi-provider support\n */\nexport const PROVIDER_CONFIG = {\n /** Default perpetual DEX provider when no explicit selection exists */\n DefaultProvider: 'hyperliquid' as const,\n /** Force MYX to testnet only (mainnet credentials not yet available) */\n MYX_TESTNET_ONLY: true,\n} as const;\n"]}
1
+ {"version":3,"file":"perpsConfig.m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,YAAY,EAAE,cAAc;QAC5B,WAAW,EAAE,aAAa;KAClB;IAEV,8EAA8E;IAC9E,iBAAiB,EAAE;QACjB,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,mBAAmB,EAAE;QAClD,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,yBAAyB,EAAE;QAC7D,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,yBAAyB,EAAE;KACrD;IAEV,oCAAoC;IACpC,mEAAmE;IACnE,WAAW,EAAE;QACX;YACE,EAAE,EAAE,QAAQ;YACZ,QAAQ,EAAE,mBAAmB;YAC7B,KAAK,EAAE,QAAQ;YACf,SAAS,EAAE,MAAM;SAClB;QACD;YACE,EAAE,EAAE,aAAa;YACjB,QAAQ,EAAE,yBAAyB;YACnC,KAAK,EAAE,aAAa;YACpB,SAAS,EAAE,MAAM;SAClB;QACD;YACE,EAAE,EAAE,cAAc;YAClB,QAAQ,EAAE,0BAA0B;YACpC,KAAK,EAAE,cAAc;YACrB,SAAS,EAAE,MAAM;SAClB;QACD;YACE,EAAE,EAAE,aAAa;YACjB,QAAQ,EAAE,yBAAyB;YACnC,KAAK,EAAE,aAAa;YACpB,SAAS,EAAE,MAAM;SAClB;KACO;CACF,CAAC;AAUX;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,uEAAuE;IACvE,eAAe,EAAE,aAAsB;IACvC,wEAAwE;IACxE,gBAAgB,EAAE,KAAK;CACf,CAAC","sourcesContent":["/**\n * Perps feature constants - Controller layer (portable)\n *\n * This file contains only controller-portable configuration:\n * - Constants used by controller logic, providers, and services\n * - Calculation thresholds, API configs, and protocol constants\n *\n * UI-only constants (layout, display, navigation) live in:\n * app/components/UI/Perps/constants/perpsConfig.ts\n */\nexport const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';\nexport const ZERO_BALANCE = '0x0';\n\nexport const PERPS_CONSTANTS = {\n FeatureFlagKey: 'perpsEnabled',\n FeatureName: 'perps', // Constant for Sentry error filtering - enables \"feature:perps\" dashboard queries\n /** Token description used to identify the synthetic \"Perps balance\" option in pay-with token lists */\n PerpsBalanceTokenDescription: 'perps-balance',\n /** Symbol displayed for the synthetic \"Perps balance\" token in pay-with token lists */\n PerpsBalanceTokenSymbol: 'USD',\n WebsocketTimeout: 5000, // 5 seconds\n WebsocketCleanupDelay: 1000, // 1 second\n BackgroundDisconnectDelay: 20_000, // 20 seconds delay before disconnecting when app is backgrounded or when user exits perps UX\n ConnectionTimeoutMs: 10_000, // 10 seconds timeout for connection and position loading states\n DefaultMonitoringTimeoutMs: 10_000, // 10 seconds default timeout for data monitoring operations\n\n // Connection timing constants\n ConnectionGracePeriodMs: 20_000, // 20 seconds grace period before actual disconnection (same as BackgroundDisconnectDelay for semantic clarity)\n ConnectionAttemptTimeoutMs: 30_000, // 30 seconds timeout for connection attempts to prevent indefinite hanging\n WebsocketPingTimeoutMs: 5_000, // 5 seconds timeout for WebSocket health check ping\n ConnectRetryDelayMs: 200, // Delay before retrying connect() when connection isn't ready yet\n ReconnectionCleanupDelayMs: 500, // Platform-agnostic delay to ensure WebSocket is ready\n ReconnectionDelayAndroidMs: 300, // Android-specific reconnection delay for better reliability on slower devices\n ReconnectionDelayIosMs: 100, // iOS-specific reconnection delay for optimal performance\n ReconnectionRetryDelayMs: 5_000, // 5 seconds delay between reconnection attempts\n NetworkRestoreMaxRetries: 8, // Max retry attempts when reconnecting after WiFi/network restore\n NetworkRestoreRetryBaseMs: 1_500, // Base delay (ms) between network restore retries (multiplied by attempt number)\n\n // Connection manager timing constants\n BalanceUpdateThrottleMs: 15000, // Update at most every 15 seconds to reduce state updates in PerpsConnectionManager\n InitialDataDelayMs: 100, // Delay to allow initial data to load after connection establishment\n\n // Deposit toast timing\n DepositTakingLongerToastDelayMs: 30_000, // Delay before showing \"Deposit taking longer than usual\" toast\n\n DefaultAssetPreviewLimit: 5,\n DefaultMaxLeverage: 3 as number, // Default fallback max leverage when market data is unavailable - conservative default\n FallbackPriceDisplay: '$---', // Display when price data is unavailable\n FallbackPercentageDisplay: '--%', // Display when change data is unavailable\n FallbackDataDisplay: '--', // Display when non-price data is unavailable\n ZeroAmountDisplay: '$0', // Display for zero dollar amounts (e.g., no volume)\n ZeroAmountDetailedDisplay: '$0.00', // Display for zero dollar amounts with decimals\n\n RecentActivityLimit: 3,\n\n // Historical data fetching constants\n FillsLookbackMs: 90 * 24 * 60 * 60 * 1000, // 3 months in milliseconds - limits REST API fills fetch\n} as const;\n\n/**\n * Withdrawal-specific constants (protocol-agnostic)\n * Note: Protocol-specific values like estimated time should be defined in each protocol's config\n */\nexport const WITHDRAWAL_CONSTANTS = {\n DefaultMinAmount: '1.01', // Default minimum withdrawal amount in USDC\n DefaultFeeAmount: 1, // Default withdrawal fee in USDC\n DefaultFeeToken: 'USDC', // Default fee token\n} as const;\n\n/**\n * Validation thresholds for UI warnings and checks\n * These values control when warnings are shown to users\n */\nexport const VALIDATION_THRESHOLDS = {\n // Leverage threshold for warning users about high leverage\n HighLeverageWarning: 20, // Show warning when leverage > 20x\n\n // Limit price difference threshold (as decimal, 0.1 = 10%)\n LimitPriceDifferenceWarning: 0.1, // Warn if limit price differs by >10% from current price\n\n // Price deviation threshold (as decimal, 0.1 = 10%)\n PriceDeviation: 0.1, // Warn if perps price deviates by >10% from spot price\n} as const;\n\n/**\n * Order slippage configuration\n * Controls default slippage tolerance for different order types\n * Conservative defaults based on HyperLiquid platform interface\n * See: docs/perps/hyperliquid/ORDER-MATCHING-ERRORS.md\n */\nexport const ORDER_SLIPPAGE_CONFIG = {\n // Market order slippage (basis points)\n // 300 basis points = 3% = 0.03 decimal\n // Conservative default for measured rollout, prevents most IOC failures\n DefaultMarketSlippageBps: 300,\n\n // TP/SL order slippage (basis points)\n // 1000 basis points = 10% = 0.10 decimal\n // Aligns with HyperLiquid platform default for triggered orders\n DefaultTpslSlippageBps: 1000,\n\n // Limit order slippage (basis points)\n // 100 basis points = 1% = 0.01 decimal\n // Kept conservative as limit orders rest on book (not IOC/immediate execution)\n DefaultLimitSlippageBps: 100,\n} as const;\n\n/**\n * Performance optimization constants\n * These values control debouncing and throttling for better performance\n */\nexport const PERFORMANCE_CONFIG = {\n // Price updates debounce delay (milliseconds)\n // Batches rapid WebSocket price updates to reduce re-renders\n PriceUpdateDebounceMs: 1000,\n\n // Order validation debounce delay (milliseconds)\n // Prevents excessive validation calls during rapid form input changes\n ValidationDebounceMs: 300,\n\n // Liquidation price debounce delay (milliseconds)\n // Prevents excessive liquidation price calls during rapid form input changes\n LiquidationPriceDebounceMs: 500,\n\n // Navigation params delay (milliseconds)\n // Required for React Navigation to complete state transitions before setting params\n // This ensures navigation context is available when programmatically selecting tabs\n NavigationParamsDelayMs: 200,\n\n // Tab control reset delay (milliseconds)\n // Delay to reset programmatic tab control after tab switching to prevent render loops\n TabControlResetDelayMs: 500,\n\n // Market data cache duration (milliseconds)\n // How long to cache market list data before fetching fresh data\n MarketDataCacheDurationMs: 5 * 60 * 1000, // 5 minutes\n\n // Asset metadata cache duration (milliseconds)\n // How long to cache asset icon validation results\n AssetMetadataCacheDurationMs: 60 * 60 * 1000, // 1 hour\n\n // Max leverage cache duration (milliseconds)\n // How long to cache max leverage values per asset (leverage rarely changes)\n MaxLeverageCacheDurationMs: 60 * 60 * 1000, // 1 hour\n\n // Rewards cache durations (milliseconds)\n // How long to cache fee discount data from rewards API\n FeeDiscountCacheDurationMs: 5 * 60 * 1000, // 5 minutes\n // How long to cache points calculation parameters from rewards API\n PointsCalculationCacheDurationMs: 5 * 60 * 1000, // 5 minutes\n\n /**\n * Performance logging markers for filtering logs during development and debugging\n * These markers help isolate performance-related logs from general application logs\n * Usage: Use in DevLogger calls to easily filter specific performance areas\n * Impact: Development only (uses DevLogger) - zero production performance cost\n *\n * Examples:\n * - Filter Sentry performance logs: `adb logcat | grep PERPSMARK_SENTRY`\n * - Filter MetaMetrics events: `adb logcat | grep PERPSMARK_METRICS`\n * - Filter WebSocket performance: `adb logcat | grep PERPSMARK_WS`\n * - Filter all Perps performance: `adb logcat | grep PERPSMARK_`\n */\n LoggingMarkers: {\n // Sentry performance measurement logs (screen loads, bottom sheets, API timing)\n SentryPerformance: 'PERPSMARK_SENTRY',\n\n // MetaMetrics event tracking logs (user interactions, business analytics)\n MetametricsEvents: 'PERPSMARK_METRICS',\n\n // WebSocket performance logs (connection timing, data flow, reconnections)\n WebsocketPerformance: 'PERPSMARK_SENTRY_WS',\n } as const,\n} as const;\n\nexport const TP_SL_CONFIG = {\n UsePositionBoundTpsl: true,\n} as const;\n\n/**\n * HyperLiquid order limits based on leverage\n * From: https://hyperliquid.gitbook.io/hyperliquid-docs/trading/contract-specifications\n */\nexport const HYPERLIQUID_ORDER_LIMITS = {\n // Market orders\n MarketOrderLimits: {\n // $15,000,000 for max leverage >= 25\n HighLeverage: 15_000_000,\n // $5,000,000 for max leverage in [20, 25)\n MediumHighLeverage: 5_000_000,\n // $2,000,000 for max leverage in [10, 20)\n MediumLeverage: 2_000_000,\n // $500,000 for max leverage < 10\n LowLeverage: 500_000,\n },\n // Limit orders are 10x market order limits\n LimitOrderMultiplier: 10,\n} as const;\n\n/**\n * Close position configuration\n * Controls behavior and constants specific to position closing\n */\nexport const CLOSE_POSITION_CONFIG = {\n // Decimal places for USD amount input display\n UsdDecimalPlaces: 2,\n\n // Default close percentage when opening the close position view\n DefaultClosePercentage: 100,\n\n // Precision for position size calculations to prevent rounding errors\n AmountCalculationPrecision: 6,\n\n // Throttle delay for real-time price updates during position closing\n PriceThrottleMs: 3000,\n\n // Fallback decimal places for tokens without metadata\n FallbackTokenDecimals: 18,\n} as const;\n\n/**\n * Margin adjustment configuration\n * Controls behavior for adding/removing margin from positions\n */\nexport const MARGIN_ADJUSTMENT_CONFIG = {\n // Risk thresholds for margin removal warnings\n // Threshold values represent ratio of (price distance to liquidation) / (liquidation price)\n // Values < 1.0 mean price is dangerously close to liquidation\n LiquidationRiskThreshold: 1.2, // 20% buffer before liquidation - triggers danger state\n LiquidationWarningThreshold: 1.5, // 50% buffer before liquidation - triggers warning state\n\n // Minimum margin adjustment amount (USD)\n // Prevents dust adjustments and ensures meaningful position changes\n MinAdjustmentAmount: 1,\n\n // Precision for margin calculations\n // Ensures accurate decimal handling in margin/leverage calculations\n CalculationPrecision: 6,\n\n // Safety buffer for margin removal to account for HyperLiquid's transfer margin requirement\n // HyperLiquid enforces: transfer_margin_required = max(initial_margin_required, 0.1 * total_position_value)\n // See: https://hyperliquid.gitbook.io/hyperliquid-docs/trading/margin-and-pnl\n MarginRemovalSafetyBuffer: 0.1,\n\n // Fallback max leverage when market data is unavailable\n // Conservative value to prevent over-removal of margin\n // Most HyperLiquid assets support at least 50x leverage\n FallbackMaxLeverage: 50,\n} as const;\n\n/**\n * Data Lake API configuration\n * Endpoints for reporting perps trading activity for notifications\n */\nexport const DATA_LAKE_API_CONFIG = {\n // Order reporting endpoint - only used for mainnet perps trading\n OrdersEndpoint: 'https://perps.api.cx.metamask.io/api/v1/orders',\n} as const;\n\n/**\n * Decimal precision configuration\n * Controls maximum decimal places for price and input validation\n */\nexport const DECIMAL_PRECISION_CONFIG = {\n // Maximum decimal places for price input (matches Hyperliquid limit)\n // Used in TP/SL forms, limit price inputs, and price validation\n MaxPriceDecimals: 6,\n // Maximum significant figures allowed by HyperLiquid API\n // Orders with more than 5 significant figures will be rejected\n MaxSignificantFigures: 5,\n // Defensive fallback for size decimals when market data fails to load\n // Real szDecimals should always come from market data API (varies by asset)\n // Using 6 as safe maximum to prevent crashes (covers most assets)\n // NOTE: This is NOT semantically correct - just a defensive measure\n FallbackSizeDecimals: 6,\n} as const;\n\n/**\n * Market sorting configuration\n * Controls sorting behavior and presets for the trending markets view\n */\nexport const MARKET_SORTING_CONFIG = {\n // Default sort settings\n DefaultSortOptionId: 'volume' as const,\n DefaultDirection: 'desc' as const,\n\n // Available sort fields (only includes fields supported by PerpsMarketData)\n SortFields: {\n Volume: 'volume',\n PriceChange: 'priceChange',\n OpenInterest: 'openInterest',\n FundingRate: 'fundingRate',\n } as const,\n\n // Sort button presets for filter chips (simplified buttons without direction)\n SortButtonPresets: [\n { field: 'volume', labelKey: 'perps.sort.volume' },\n { field: 'priceChange', labelKey: 'perps.sort.price_change' },\n { field: 'fundingRate', labelKey: 'perps.sort.funding_rate' },\n ] as const,\n\n // Sort options for the bottom sheet\n // All options support direction toggle (high-to-low / low-to-high)\n SortOptions: [\n {\n id: 'volume',\n labelKey: 'perps.sort.volume',\n field: 'volume',\n direction: 'desc',\n },\n {\n id: 'priceChange',\n labelKey: 'perps.sort.price_change',\n field: 'priceChange',\n direction: 'desc',\n },\n {\n id: 'openInterest',\n labelKey: 'perps.sort.open_interest',\n field: 'openInterest',\n direction: 'desc',\n },\n {\n id: 'fundingRate',\n labelKey: 'perps.sort.funding_rate',\n field: 'fundingRate',\n direction: 'desc',\n },\n ] as const,\n} as const;\n\n/**\n * Type for valid sort option IDs\n * Derived from SORT_OPTIONS to ensure type safety\n * Valid values: 'volume' | 'priceChange' | 'openInterest' | 'fundingRate'\n */\nexport type SortOptionId =\n (typeof MARKET_SORTING_CONFIG.SortOptions)[number]['id'];\n\n/**\n * Provider configuration for multi-provider support\n */\nexport const PROVIDER_CONFIG = {\n /** Default perpetual DEX provider when no explicit selection exists */\n DefaultProvider: 'hyperliquid' as const,\n /** Force MYX to testnet only (mainnet credentials not yet available) */\n MYX_TESTNET_ONLY: false,\n} as const;\n"]}