// Network constants
export const ARBITRUM_MAINNET_CHAIN_ID_HEX = '0xa4b1';
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';
export const HYPERLIQUID_TESTNET_CAIP_CHAIN_ID = 'eip155:998';
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;
export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
export const ZERO_BALANCE = '0x0';
// 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 = {
    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 = {
    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 = {
    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 = {
    timeout: 10000,
    keepAlive: { interval: 30000 },
    reconnect: {
        maxRetries: 5,
        connectionTimeout: 10000,
    },
};
// Trading configuration constants
export const TRADING_DEFAULTS = {
    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 = {
    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,
};
const BUILDER_FEE_MAX_FEE_DECIMAL = 0.001;
// Builder fee configuration
export const BUILDER_FEE_CONFIG = {
    // Test builder wallet
    TestnetBuilder: '0x724e57771ba749650875bd8adb2e29a85d0cacfa',
    // Production builder wallet
    MainnetBuilder: '0xe95a5e31904e005066614247d309e00d8ad753aa',
    // 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: 150000, // 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
// Configuration helpers
export function getWebSocketEndpoint(isTestnet) {
    return isTestnet
        ? HYPERLIQUID_ENDPOINTS.testnet
        : HYPERLIQUID_ENDPOINTS.mainnet;
}
export function getChainId(isTestnet) {
    return isTestnet ? ARBITRUM_TESTNET_CHAIN_ID : ARBITRUM_MAINNET_CHAIN_ID;
}
export function getCaipChainId(isTestnet) {
    const network = isTestnet ? 'testnet' : 'mainnet';
    return HYPERLIQUID_BRIDGE_CONTRACTS[network].chainId;
}
export function getBridgeInfo(isTestnet) {
    const network = isTestnet ? 'testnet' : 'mainnet';
    return HYPERLIQUID_BRIDGE_CONTRACTS[network];
}
export function getSupportedAssets(isTestnet) {
    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',
};
/**
 * 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',
};
/**
 * 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,
};
/**
 * 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;
/**
 * 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:
 * - 'equity': STOCK badge (stocks like TSLA, NVDA)
 * - 'commodity': COMMODITY badge (commodities like GOLD)
 * - 'forex': FOREX badge (forex pairs)
 * - undefined: No badge for crypto or 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 = {
    // xyz DEX - Equities
    'xyz:TSLA': 'equity',
    'xyz:NVDA': 'equity',
    'xyz:XYZ100': 'equity',
    'xyz:INTC': 'equity',
    'xyz:MU': 'equity',
    'xyz:CRCL': 'equity',
    'xyz:HOOD': 'equity',
    'xyz:SNDK': 'equity',
    'xyz:GOOGL': 'equity',
    'xyz:COIN': 'equity',
    'xyz:ORCL': 'equity',
    'xyz:AMZN': 'equity',
    'xyz:PLTR': 'equity',
    'xyz:AAPL': 'equity',
    'xyz:META': 'equity',
    'xyz:AMD': 'equity',
    'xyz:MSFT': 'equity',
    'xyz:BABA': 'equity',
    'xyz:RIVN': 'equity',
    'xyz:NFLX': 'equity',
    'xyz:COST': 'equity',
    'xyz:LLY': 'equity',
    'xyz:TSM': 'equity',
    'xyz:SKHX': 'equity',
    'xyz:MSTR': 'equity',
    'xyz:CRWV': 'equity',
    'xyz:SMSN': 'equity',
    // xyz DEX - Commodities
    'xyz:GOLD': 'commodity',
    'xyz:SILVER': 'commodity',
    'xyz:CL': 'commodity',
    'xyz:COPPER': 'commodity',
    'xyz:ALUMINIUM': 'commodity',
    'xyz:URANIUM': 'commodity',
    'xyz:USAR': 'commodity',
    'xyz:NATGAS': 'commodity',
    'xyz:PLATINUM': 'commodity',
    // xyz DEX - Forex
    'xyz:EUR': 'forex',
    'xyz:JPY': 'forex',
};
/**
 * 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'],
    /**
     * Set to true to enable full HIP-3 discovery on testnet (not recommended)
     * When false, only DEXs in ENABLED_DEXS are used
     */
    AutoDiscoverAll: false,
};
/**
 * 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,
};
/**
 * HIP-3 margin management configuration
 * Controls margin buffers and auto-rebalance behavior for HIP-3 DEXes with isolated margin
 *
 * Background: HyperLiquid validates availableBalance >= 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,
};
/**
 * Configuration for USDH collateral handling on HIP-3 DEXs
 * Per HyperLiquid docs: USDH DEXs pull collateral from spot balance automatically
 *
 * USDH is HyperLiquid's native stablecoin pegged 1:1 to USDC
 */
export const USDH_CONFIG = {
    /** Token name for USDH collateral */
    TokenName: 'USDH',
    /**
     * Maximum slippage for USDC→USDH spot swap in basis points
     * USDH is pegged 1:1 to USDC so slippage should be minimal
     * 10 bps (0.1%) provides small buffer for spread
     */
    SwapSlippageBps: 10,
};
// 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;
//# sourceMappingURL=hyperLiquidConfig.mjs.map