-
-
Notifications
You must be signed in to change notification settings - Fork 290
Expand file tree
/
Copy pathhyperLiquidConfig.ts
More file actions
657 lines (596 loc) · 21.9 KB
/
Copy pathhyperLiquidConfig.ts
File metadata and controls
657 lines (596 loc) · 21.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
import type { CaipAssetId, CaipChainId, Hex } from '@metamask/utils';
import { MarketCategory } from '../types';
import type { MarketType } from '../types';
import type {
HyperLiquidNetwork,
HyperLiquidEndpoints,
HyperLiquidAssetConfigs,
BridgeContractConfig,
HyperLiquidBridgeContracts,
HyperLiquidTransportConfig,
TradingDefaultsConfig,
FeeRatesConfig,
} from '../types/perps-types';
// Network constants
export const ARBITRUM_MAINNET_CHAIN_ID_HEX = '0xa4b1' as const;
export const ARBITRUM_MAINNET_CHAIN_ID = '42161';
export const ARBITRUM_TESTNET_CHAIN_ID = '421614';
export const ARBITRUM_MAINNET_CAIP_CHAIN_ID = `eip155:${ARBITRUM_MAINNET_CHAIN_ID}`;
export const ARBITRUM_TESTNET_CAIP_CHAIN_ID = `eip155:${ARBITRUM_TESTNET_CHAIN_ID}`;
// Hyperliquid chain constants
export const HYPERLIQUID_MAINNET_CHAIN_ID = '0x3e7'; // 999 in decimal
export const HYPERLIQUID_TESTNET_CHAIN_ID = '0x3e6'; // 998 in decimal (assumed)
export const HYPERLIQUID_MAINNET_CAIP_CHAIN_ID = 'eip155:999' as CaipChainId;
export const HYPERLIQUID_TESTNET_CAIP_CHAIN_ID = 'eip155:998' as CaipChainId;
export const HYPERLIQUID_NETWORK_NAME = 'Hyperliquid';
// Token constants
export const USDC_SYMBOL = 'USDC';
export const USDC_NAME = 'USD Coin';
export const USDC_DECIMALS = 6;
export const TOKEN_DECIMALS = 18;
// Network constants
export const ARBITRUM_SEPOLIA_CHAIN_ID = '0x66eee'; // 421614 in decimal
// USDC token addresses
export const USDC_ETHEREUM_MAINNET_ADDRESS =
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48';
export const USDC_ARBITRUM_MAINNET_ADDRESS =
'0xaf88d065e77c8cC2239327C5EDb3A432268e5831';
export const USDC_ARBITRUM_TESTNET_ADDRESS =
'0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d';
// USDC token icon URL using MetaMask's official Token Icons API
// Format: https://static.cx.metamask.io/api/v1/tokenIcons/{chainId}/{contractAddress}.png
// This URL follows the same pattern used throughout MetaMask (bridges, swaps, etc.)
export const USDC_TOKEN_ICON_URL = `https://static.cx.metamask.io/api/v1/tokenIcons/1/${USDC_ETHEREUM_MAINNET_ADDRESS}.png`;
// WebSocket endpoints
export const HYPERLIQUID_ENDPOINTS: HyperLiquidEndpoints = {
mainnet: 'wss://api.hyperliquid.xyz/ws',
testnet: 'wss://api.hyperliquid-testnet.xyz/ws',
};
// Asset icons base URL (HyperLiquid CDN - fallback source)
export const HYPERLIQUID_ASSET_ICONS_BASE_URL =
'https://app.hyperliquid.xyz/coins/';
// MetaMask-hosted Perps asset icons (primary source)
// Assets uploaded to: https://github.com/MetaMask/contract-metadata/tree/master/icons/eip155:999
// HIP-3 assets use format: hip3:dex_SYMBOL.svg (e.g., hip3:xyz_AAPL.svg)
// Regular assets use format: SYMBOL.svg (e.g., BTC.svg)
export const METAMASK_PERPS_ICONS_BASE_URL =
'https://raw.githubusercontent.com/MetaMask/contract-metadata/master/icons/eip155:999/';
// Asset configurations for multichain abstraction
export const HYPERLIQUID_ASSET_CONFIGS: HyperLiquidAssetConfigs = {
usdc: {
mainnet: `${ARBITRUM_MAINNET_CAIP_CHAIN_ID}/erc20:0xaf88d065e77c8cC2239327C5EDb3A432268e5831/default`,
testnet: `${ARBITRUM_TESTNET_CAIP_CHAIN_ID}/erc20:0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d/default`,
},
};
// HyperLiquid bridge contract addresses for direct USDC deposits
// These are the official bridge contracts where USDC must be sent to credit user's HyperLiquid account
export const HYPERLIQUID_BRIDGE_CONTRACTS: HyperLiquidBridgeContracts = {
mainnet: {
chainId: ARBITRUM_MAINNET_CAIP_CHAIN_ID,
contractAddress: '0x2df1c51e09aecf9cacb7bc98cb1742757f163df7',
},
testnet: {
chainId: ARBITRUM_TESTNET_CAIP_CHAIN_ID,
contractAddress: '0x08cfc1B6b2dCF36A1480b99353A354AA8AC56f89',
},
};
// SDK transport configuration
export const HYPERLIQUID_TRANSPORT_CONFIG: HyperLiquidTransportConfig = {
timeout: 10_000,
keepAlive: { interval: 30_000 },
reconnect: {
maxRetries: 5,
connectionTimeout: 10_000,
},
};
// Trading configuration constants
export const TRADING_DEFAULTS: TradingDefaultsConfig = {
leverage: 3, // 3x default leverage
marginPercent: 10, // 10% fixed margin default
takeProfitPercent: 0.3, // 30% take profit
stopLossPercent: 0.1, // 10% stop loss
amount: {
mainnet: 10, // $10 minimum order size
testnet: 10, // $10 minimum order size
},
};
// Fee configuration
// Note: These are base rates (Tier 0, no discounts)
// Actual fees will be calculated based on user's volume tier and staking
export const FEE_RATES: FeeRatesConfig = {
taker: 0.00045, // 0.045% - Market orders and aggressive limit orders
maker: 0.00015, // 0.015% - Limit orders that add liquidity
};
/**
* HIP-3 dynamic fee calculation configuration
*
* HIP-3 (builder-deployed) perpetual markets have variable fees based on:
* 1. deployerFeeScale - Per-DEX fee multiplier (fetched from perpDexs API)
* 2. growthMode - Per-asset 90% fee reduction (fetched from meta API)
*
* Fee Formula (from HyperLiquid docs):
* - scaleIfHip3 = deployerFeeScale < 1 ? deployerFeeScale + 1 : deployerFeeScale * 2
* - growthModeScale = growthMode ? 0.1 : 1
* - finalRate = baseRate * scaleIfHip3 * growthModeScale
*
* Example: For xyz:TSLA with deployerFeeScale=1.0 and growthMode="enabled":
* - scaleIfHip3 = 1.0 * 2 = 2.0
* - growthModeScale = 0.1 (90% reduction)
* - Final multiplier = 2.0 * 0.1 = 0.2 (effectively 80% off standard 2x HIP-3 fees)
*
* @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees#fee-formula-for-developers
* @see parseAssetName() in HyperLiquidProvider for HIP-3 asset detection
*/
export const HIP3_FEE_CONFIG = {
/**
* Growth Mode multiplier - 90% fee reduction for assets in growth phase
* This is a protocol constant from HyperLiquid's fee formula
*/
GrowthModeScale: 0.1,
/**
* Default deployerFeeScale when API is unavailable
* Most HIP-3 DEXs use 1.0, which results in 2x base fees
*/
DefaultDeployerFeeScale: 1.0,
/**
* Cache TTL for perpDexs data (5 minutes)
* Fee scales rarely change, so longer cache is acceptable
*/
PerpDexsCacheTtlMs: 5 * 60 * 1000,
/**
* @deprecated Use dynamic calculation via calculateHip3FeeMultiplier()
* Kept for backwards compatibility during migration
*/
FeeMultiplier: 2,
} as const;
const BUILDER_FEE_MAX_FEE_DECIMAL = 0.001;
// Builder fee configuration
export const BUILDER_FEE_CONFIG = {
// Test builder wallet
TestnetBuilder: '0x724e57771ba749650875bd8adb2e29a85d0cacfa' as Hex,
// Production builder wallet
MainnetBuilder: '0xe95a5e31904e005066614247d309e00d8ad753aa' as Hex,
// Fee in decimal (10 bp = 0.1%)
MaxFeeDecimal: BUILDER_FEE_MAX_FEE_DECIMAL,
MaxFeeTenthsBps: BUILDER_FEE_MAX_FEE_DECIMAL * 100000,
MaxFeeRate: `${(BUILDER_FEE_MAX_FEE_DECIMAL * 100)
.toFixed(4)
.replace(/\.?0+$/u, '')}%`,
};
// Referral code configuration
export const REFERRAL_CONFIG = {
// Production referral code
MainnetCode: 'MMCSI',
// Development/testnet referral code
TestnetCode: 'MMCSITEST',
};
// Deposit constants
export const DEPOSIT_CONFIG = {
EstimatedGasLimit: 100000, // Estimated gas limit for bridge deposit
DefaultSlippage: 1, // 1% default slippage for bridge quotes
BridgeQuoteTimeout: 1000, // 1 second timeout for bridge quotes
RefreshRate: 30000, // 30 seconds quote refresh rate
EstimatedTime: {
DirectDeposit: '3-5 seconds', // Direct USDC deposit on Arbitrum
SameChainSwap: '30-60 seconds', // Swap on same chain before deposit
},
};
// Withdrawal constants (HyperLiquid-specific)
export const HYPERLIQUID_WITHDRAWAL_MINUTES = 5; // HyperLiquid withdrawal processing time in minutes
// Type helpers
export type SupportedAsset = keyof typeof HYPERLIQUID_ASSET_CONFIGS;
// Configuration helpers
export function getWebSocketEndpoint(isTestnet: boolean): string {
return isTestnet
? HYPERLIQUID_ENDPOINTS.testnet
: HYPERLIQUID_ENDPOINTS.mainnet;
}
export function getChainId(isTestnet: boolean): string {
return isTestnet ? ARBITRUM_TESTNET_CHAIN_ID : ARBITRUM_MAINNET_CHAIN_ID;
}
export function getCaipChainId(isTestnet: boolean): CaipChainId {
const network: HyperLiquidNetwork = isTestnet ? 'testnet' : 'mainnet';
return HYPERLIQUID_BRIDGE_CONTRACTS[network].chainId;
}
export function getBridgeInfo(isTestnet: boolean): BridgeContractConfig {
const network: HyperLiquidNetwork = isTestnet ? 'testnet' : 'mainnet';
return HYPERLIQUID_BRIDGE_CONTRACTS[network];
}
export function getSupportedAssets(isTestnet?: boolean): CaipAssetId[] {
const network = isTestnet ? 'testnet' : 'mainnet';
return Object.values(HYPERLIQUID_ASSET_CONFIGS).map(
(config) => config[network],
);
}
// CAIP asset namespace constants
export const CAIP_ASSET_NAMESPACES = {
Erc20: 'erc20',
} as const;
/**
* HyperLiquid protocol-specific configuration
* Contains constants specific to HyperLiquid's perps exchange
*/
export const HYPERLIQUID_CONFIG = {
// Exchange name used in predicted funding data
// HyperLiquid uses 'HlPerp' as their perps exchange identifier
ExchangeName: 'HlPerp',
// Maximum allowed deviation of the market (mid) price from the oracle (reference)
// price before HyperLiquid rejects orders. HyperLiquid enforces "Order price cannot
// be more than 95% away from the reference price", which makes markets — most often
// HIP-3 builder-deployed ones — temporarily untradable when the mid price drifts past
// this limit. Expressed as a decimal fraction (0.95 = 95%).
// Protocol rule, not a UI warning threshold (see VALIDATION_THRESHOLDS.PriceDeviation).
OraclePriceDeviationLimit: 0.95,
} as const;
/**
* HIP-3 multi-DEX asset ID calculation constants
* Per HIP-3-IMPLEMENTATION.md:
* - Main DEX: assetId = index (0, 1, 2, ...)
* - HIP-3 DEX: assetId = BASE_ASSET_ID + (perpDexIndex × DEX_MULTIPLIER) + index
*
* This formula enables proper order routing across multiple DEXs:
* - Main DEX (perpDexIndex=0): Uses index directly (BTC=0, ETH=1, SOL=2, etc.)
* - xyz DEX (perpDexIndex=1): 100000 + (1 × 10000) + index = 110000-110999
* - abc DEX (perpDexIndex=2): 100000 + (2 × 10000) + index = 120000-120999
*
* Supports up to 10 HIP-3 DEXs with 10000 assets each.
*/
export const HIP3_ASSET_ID_CONFIG = {
// Base offset for HIP-3 asset IDs (100000)
// Ensures HIP-3 asset IDs don't conflict with main DEX indices
BaseAssetId: 100000,
// Multiplier for DEX index in asset ID calculation (10000)
// Allocates 10000 asset ID slots per DEX (0-9999)
DexMultiplier: 10000,
} as const;
/**
* Basis points conversion constant
* 1 basis point (bp) = 0.01% = 0.0001 as decimal
* Used for fee discount calculations (e.g., 6500 bps = 65%)
*/
export const BASIS_POINTS_DIVISOR = 10000;
/**
* Offset added to spot market pair index to derive the spot asset ID
* used in HyperLiquid order routing.
* Per HyperLiquid protocol: spotAssetId = SPOT_ASSET_ID_OFFSET + pairIndex
*/
export const SPOT_ASSET_ID_OFFSET = 10000;
/**
* HIP-3 asset market type classifications (PRODUCTION DEFAULT)
*
* This is the production default configuration, can be overridden via feature flag
* (remoteFeatureFlags.perpsAssetMarketTypes) for dynamic control.
*
* Maps asset symbols (e.g., "xyz:TSLA") to their market type for badge display.
*
* Market type determines the badge shown in the UI:
* - 'stock': Individual stocks (TSLA, NVDA, AAPL, etc.)
* - 'pre-ipo': Pre-IPO assets not yet publicly listed
* - 'index': Market indices (SP500, JP225, VIX, etc.)
* - 'etf': Exchange-traded funds (EWY, EWJ, USAR, etc.)
* - 'commodity': Commodities (GOLD, SILVER, CL, etc.)
* - 'forex': Forex pairs (EUR, JPY, DXY)
* - 'crypto': Explicitly categorized crypto assets
* - undefined: No badge for unmapped assets
*
* Format: 'dex:SYMBOL' → MarketType
* This allows flexible per-asset classification.
* Assets not listed here will have no market type (undefined).
*/
export const HIP3_ASSET_MARKET_TYPES: Record<string, MarketType> = {
// xyz DEX - Stocks (US)
'xyz:TSLA': MarketCategory.Stock,
'xyz:NVDA': MarketCategory.Stock,
'xyz:INTC': MarketCategory.Stock,
'xyz:MU': MarketCategory.Stock,
'xyz:CRCL': MarketCategory.Stock,
'xyz:HOOD': MarketCategory.Stock,
'xyz:SNDK': MarketCategory.Stock,
'xyz:GOOGL': MarketCategory.Stock,
'xyz:COIN': MarketCategory.Stock,
'xyz:ORCL': MarketCategory.Stock,
'xyz:AMZN': MarketCategory.Stock,
'xyz:PLTR': MarketCategory.Stock,
'xyz:AAPL': MarketCategory.Stock,
'xyz:META': MarketCategory.Stock,
'xyz:AMD': MarketCategory.Stock,
'xyz:MSFT': MarketCategory.Stock,
'xyz:BABA': MarketCategory.Stock,
'xyz:RIVN': MarketCategory.Stock,
'xyz:NFLX': MarketCategory.Stock,
'xyz:COST': MarketCategory.Stock,
'xyz:LLY': MarketCategory.Stock,
'xyz:TSM': MarketCategory.Stock,
'xyz:MSTR': MarketCategory.Stock,
'xyz:CRWV': MarketCategory.Stock,
'xyz:GME': MarketCategory.Stock,
'xyz:HIMS': MarketCategory.Stock,
'xyz:USAR': MarketCategory.Stock,
'xyz:DKNG': MarketCategory.Stock,
'xyz:BIRD': MarketCategory.Stock,
'xyz:RKLB': MarketCategory.Stock,
'xyz:MRVL': MarketCategory.Stock,
'xyz:ZM': MarketCategory.Stock,
'xyz:EBAY': MarketCategory.Stock,
'xyz:PURRDAT': MarketCategory.Stock,
'xyz:ARM': MarketCategory.Stock,
'xyz:BX': MarketCategory.Stock,
'xyz:LITE': MarketCategory.Stock,
// xyz DEX - Stocks (Korea)
'xyz:SKHX': MarketCategory.Stock,
'xyz:SMSN': MarketCategory.Stock,
'xyz:HYUNDAI': MarketCategory.Stock,
// xyz DEX - Stocks (Japan)
'xyz:SOFTBANK': MarketCategory.Stock,
'xyz:KIOXIA': MarketCategory.Stock,
// xyz DEX - Pre-IPO
'xyz:CBRS': MarketCategory.PreIpo,
'xyz:SPCX': MarketCategory.PreIpo,
'xyz:IPOP': MarketCategory.PreIpo,
// xyz DEX - Indices
'xyz:SP500': MarketCategory.Index,
'xyz:XYZ100': MarketCategory.Index,
'xyz:JP225': MarketCategory.Index,
'xyz:KR200': MarketCategory.Index,
'xyz:VIX': MarketCategory.Index,
// xyz DEX - ETFs
'xyz:EWY': MarketCategory.Etf,
'xyz:EWJ': MarketCategory.Etf,
'xyz:EWT': MarketCategory.Etf,
'xyz:EWZ': MarketCategory.Etf,
'xyz:URNM': MarketCategory.Etf,
'xyz:DRAM': MarketCategory.Etf,
'xyz:XLE': MarketCategory.Etf,
// xyz DEX - Commodities
'xyz:GOLD': MarketCategory.Commodity,
'xyz:SILVER': MarketCategory.Commodity,
'xyz:CL': MarketCategory.Commodity,
'xyz:WTIOIL': MarketCategory.Commodity,
'xyz:COPPER': MarketCategory.Commodity,
'xyz:ALUMINIUM': MarketCategory.Commodity,
'xyz:URANIUM': MarketCategory.Commodity,
'xyz:NATGAS': MarketCategory.Commodity,
'xyz:PLATINUM': MarketCategory.Commodity,
'xyz:PALLADIUM': MarketCategory.Commodity,
'xyz:BRENTOIL': MarketCategory.Commodity,
// xyz DEX - Forex
'xyz:EUR': MarketCategory.Forex,
'xyz:JPY': MarketCategory.Forex,
'xyz:GBP': MarketCategory.Forex,
'xyz:DXY': MarketCategory.Forex,
};
/**
* Human-readable market names keyed by HyperLiquid asset symbol.
*
* HyperLiquid does NOT expose a human-readable name per market: the `meta`
* universe only returns the ticker (`BTC`, `xyz:TSLA`), and `perpDexs` only
* exposes a `fullName` for the DEX/venue, not the individual asset. This map is
* therefore maintained client-side so that clients (mobile, extension) can:
* - match markets by full name in search ("Bitcoin", "Apple", "Gold"), and
* - display the full name alongside / instead of the ticker.
*
* Keys follow the same convention as {@link HIP3_ASSET_MARKET_TYPES}: bare
* `SYMBOL` for main-DEX crypto and `dex:SYMBOL` for HIP-3 markets. Use
* {@link getHyperLiquidAssetName} to resolve a name with a safe fallback to the
* ticker for unmapped assets.
*
* This list is intentionally curated (not exhaustive): unmapped assets simply
* fall back to their ticker, which matches prior behavior. Add entries as needed.
*/
export const HYPERLIQUID_ASSET_NAMES: Record<string, string> = {
// Main DEX - Crypto majors
BTC: 'Bitcoin',
ETH: 'Ethereum',
SOL: 'Solana',
XRP: 'XRP',
BNB: 'BNB',
DOGE: 'Dogecoin',
ADA: 'Cardano',
AVAX: 'Avalanche',
LINK: 'Chainlink',
LTC: 'Litecoin',
DOT: 'Polkadot',
BCH: 'Bitcoin Cash',
TRX: 'TRON',
MATIC: 'Polygon',
ARB: 'Arbitrum',
OP: 'Optimism',
SUI: 'Sui',
APT: 'Aptos',
ATOM: 'Cosmos',
NEAR: 'NEAR Protocol',
INJ: 'Injective',
TIA: 'Celestia',
SEI: 'Sei',
UNI: 'Uniswap',
AAVE: 'Aave',
MKR: 'Maker',
CRV: 'Curve DAO',
LDO: 'Lido DAO',
PEPE: 'Pepe',
WIF: 'dogwifhat',
BONK: 'Bonk',
SHIB: 'Shiba Inu',
ETC: 'Ethereum Classic',
FIL: 'Filecoin',
HBAR: 'Hedera',
ICP: 'Internet Computer',
STX: 'Stacks',
RUNE: 'THORChain',
TON: 'Toncoin',
KAS: 'Kaspa',
FET: 'Fetch.ai',
ENA: 'Ethena',
JUP: 'Jupiter',
PYTH: 'Pyth Network',
JTO: 'Jito',
STRK: 'Starknet',
BLUR: 'Blur',
GMX: 'GMX',
DYDX: 'dYdX',
HYPE: 'Hyperliquid',
// xyz DEX - Stocks (US)
'xyz:TSLA': 'Tesla',
'xyz:NVDA': 'NVIDIA',
'xyz:INTC': 'Intel',
'xyz:MU': 'Micron Technology',
'xyz:CRCL': 'Circle',
'xyz:HOOD': 'Robinhood',
'xyz:SNDK': 'SanDisk',
'xyz:GOOGL': 'Alphabet (Google)',
'xyz:COIN': 'Coinbase',
'xyz:ORCL': 'Oracle',
'xyz:AMZN': 'Amazon',
'xyz:PLTR': 'Palantir',
'xyz:AAPL': 'Apple',
'xyz:META': 'Meta Platforms',
'xyz:AMD': 'AMD',
'xyz:MSFT': 'Microsoft',
'xyz:BABA': 'Alibaba',
'xyz:RIVN': 'Rivian',
'xyz:NFLX': 'Netflix',
'xyz:COST': 'Costco',
'xyz:LLY': 'Eli Lilly',
'xyz:TSM': 'Taiwan Semiconductor',
'xyz:MSTR': 'Strategy (MicroStrategy)',
'xyz:CRWV': 'CoreWeave',
'xyz:GME': 'GameStop',
'xyz:HIMS': 'Hims & Hers',
'xyz:USAR': 'USA Rare Earth',
'xyz:DKNG': 'DraftKings',
'xyz:RKLB': 'Rocket Lab',
'xyz:MRVL': 'Marvell',
'xyz:ZM': 'Zoom',
'xyz:EBAY': 'eBay',
'xyz:ARM': 'Arm Holdings',
'xyz:BX': 'Blackstone',
'xyz:LITE': 'Lumentum',
// xyz DEX - Stocks (Korea)
'xyz:SKHX': 'SK Hynix',
'xyz:SMSN': 'Samsung Electronics',
'xyz:HYUNDAI': 'Hyundai Motor',
// xyz DEX - Stocks (Japan)
'xyz:SOFTBANK': 'SoftBank Group',
'xyz:KIOXIA': 'Kioxia',
// xyz DEX - Pre-IPO
'xyz:SPCX': 'SpaceX',
'xyz:CBRS': 'Cerebras',
'xyz:IPOP': 'Quantinuum',
// xyz DEX - Indices
'xyz:SP500': 'S&P 500',
'xyz:JP225': 'Nikkei 225',
'xyz:KR200': 'KOSPI 200',
'xyz:VIX': 'CBOE Volatility Index',
// xyz DEX - ETFs
'xyz:EWY': 'iShares MSCI South Korea ETF',
'xyz:EWJ': 'iShares MSCI Japan ETF',
'xyz:EWT': 'iShares MSCI Taiwan ETF',
'xyz:EWZ': 'iShares MSCI Brazil ETF',
'xyz:URNM': 'Sprott Uranium Miners ETF',
'xyz:XLE': 'Energy Select Sector SPDR Fund',
// xyz DEX - Commodities
'xyz:GOLD': 'Gold',
'xyz:SILVER': 'Silver',
'xyz:CL': 'Crude Oil',
'xyz:WTIOIL': 'WTI Crude Oil',
'xyz:COPPER': 'Copper',
'xyz:ALUMINIUM': 'Aluminium',
'xyz:URANIUM': 'Uranium',
'xyz:NATGAS': 'Natural Gas',
'xyz:PLATINUM': 'Platinum',
'xyz:PALLADIUM': 'Palladium',
'xyz:BRENTOIL': 'Brent Crude Oil',
// xyz DEX - Forex
'xyz:EUR': 'Euro',
'xyz:JPY': 'Japanese Yen',
'xyz:GBP': 'British Pound',
'xyz:DXY': 'US Dollar Index',
};
/**
* Resolve the human-readable name for a HyperLiquid market.
*
* Falls back to the ticker symbol when the asset is not present in
* {@link HYPERLIQUID_ASSET_NAMES}, so callers always receive a displayable
* string and unmapped assets keep their prior behavior.
*
* @param symbol - HyperLiquid asset symbol (bare `SYMBOL` for main-DEX crypto,
* `dex:SYMBOL` for HIP-3 markets).
* @param names - Name map to look up against (defaults to the bundled
* {@link HYPERLIQUID_ASSET_NAMES}); injectable for testing/overrides.
* @returns The human-readable name, or the symbol itself when unmapped.
*/
export function getHyperLiquidAssetName(
symbol: string,
names: Record<string, string> = HYPERLIQUID_ASSET_NAMES,
): string {
return names[symbol] ?? symbol;
}
/**
* Testnet-specific HIP-3 DEX configuration
*
* On testnet, there are many HIP-3 DEXs (test deployments from various builders).
* Subscribing to all of them causes connection/subscription overload and instability.
* This configuration limits which DEXs are discovered and subscribed to on testnet.
*/
export const TESTNET_HIP3_CONFIG = {
/**
* Allowed DEX names for testnet
* Empty array = main DEX only (no HIP-3 DEXs)
* Add specific DEX names to test with particular HIP-3 DEXs: ['testdex1', 'testdex2']
*/
EnabledDexs: ['xyz'] as string[],
/**
* Set to true to enable full HIP-3 discovery on testnet (not recommended)
* When false, only DEXs in ENABLED_DEXS are used
*/
AutoDiscoverAll: false,
} as const;
/**
* Mainnet-specific HIP-3 DEX configuration
*
* On mainnet, DEX filtering is dynamically determined from the allowlist markets
* feature flag. This avoids hardcoding DEX names and ensures consistency with
* the market filtering logic.
*
* When AutoDiscoverAll is false and no allowlist is provided, only the main DEX is used.
* When an allowlist is provided, DEXs are extracted from the allowlist patterns.
*/
export const MAINNET_HIP3_CONFIG = {
/**
* Set to true to enable full HIP-3 discovery on mainnet
* When false, DEXs are filtered based on the allowlist markets feature flag
* (recommended for production to reduce subscription overhead)
*/
AutoDiscoverAll: false,
} as const;
/**
* HIP-3 margin management configuration
* Controls margin buffers and auto-rebalance behavior for HIP-3 DEXes with isolated margin
*
* Background: HyperLiquid validates spendableBalance >= totalRequiredMargin BEFORE reallocating
* existing locked margin. This requires temporary over-funding when increasing positions,
* followed by automatic cleanup to minimize locked capital.
*/
export const HIP3_MARGIN_CONFIG = {
/**
* Margin buffer multiplier for fees and slippage (0.3% = multiply by 1.003)
* Covers HyperLiquid's max taker fee (0.035%) with comfortable margin
*/
BufferMultiplier: 1.003,
/**
* Desired buffer to keep on HIP-3 DEX after auto-rebalance (USDC amount)
* Small buffer allows quick follow-up orders without transfers
*/
RebalanceDesiredBuffer: 0.1,
/**
* Minimum excess threshold to trigger auto-rebalance (USDC amount)
* Prevents unnecessary transfers for tiny amounts
*/
RebalanceMinThreshold: 0.1,
} as const;
// Progress bar constants
export const INITIAL_AMOUNT_UI_PROGRESS = 10;
export const WITHDRAWAL_PROGRESS_STAGES = [
25, 35, 45, 55, 65, 75, 85, 90, 95, 98,
];
export const PROGRESS_BAR_COMPLETION_DELAY_MS = 500;