import os from decimal import Decimal # --- GLOBAL SETTINGS --- # Use environment variables to switch profiles TARGET_DEX = os.environ.get("TARGET_DEX", "UNISWAP_V3") STATUS_FILE = os.environ.get("STATUS_FILE", f"{TARGET_DEX}_status.json") # --- DEFAULT STRATEGY --- DEFAULT_STRATEGY = { "MONITOR_INTERVAL_SECONDS": 60, # How often the Manager checks for range status "CLOSE_POSITION_ENABLED": True, # Allow the bot to automatically close out-of-range positions "OPEN_POSITION_ENABLED": True, # Allow the bot to automatically open new positions "REBALANCE_ON_CLOSE_BELOW_RANGE": True, # Strategy flag for specific closing behavior # Investment Settings "TARGET_INVESTMENT_AMOUNT": 2000, # Total USD value to deploy into the LP position "INITIAL_HEDGE_CAPITAL": 1000, # Capital reserved on Hyperliquid for hedging "VALUE_REFERENCE": "USD", # Base currency for all calculations # Range Settings "RANGE_WIDTH_PCT": Decimal("0.01"), # LP width (e.g. 0.05 = +/- 5% from current price) "SLIPPAGE_TOLERANCE": Decimal("0.02"), # Max allowed slippage for swaps and minting "TRANSACTION_TIMEOUT_SECONDS": 30, # Timeout for blockchain transactions # Hedging Settings "MIN_HEDGE_THRESHOLD": Decimal("0.012"), # Minimum delta change (in coins) required to trigger a trade # Unified Hedger Settings "CHECK_INTERVAL": 1, # Loop speed for the hedger (seconds) "LEVERAGE": 5, # Leverage to use on Hyperliquid "ZONE_BOTTOM_HEDGE_LIMIT": Decimal("1.0"), # Multiplier limit at the bottom of the range "ZONE_CLOSE_START": Decimal("10.0"), # Distance (pct) from edge to start closing logic "ZONE_CLOSE_END": Decimal("11.0"), # Distance (pct) from edge to finish closing logic "ZONE_TOP_HEDGE_START": Decimal("10.0"), # Distance (pct) from top edge to adjust hedging "PRICE_BUFFER_PCT": Decimal("0.0015"), # Buffer for limit order pricing (0.15%) "MIN_ORDER_VALUE_USD": Decimal("10.0"), # Minimum order size allowed by Hyperliquid "DYNAMIC_THRESHOLD_MULTIPLIER": Decimal("1.2"), # Expansion factor for thresholds "MIN_TIME_BETWEEN_TRADES": 60, # Cooldown (seconds) between rebalance trades "MAX_HEDGE_MULTIPLIER": Decimal("1.25"), # Max allowed hedge size relative to calculated target "BASE_REBALANCE_THRESHOLD_PCT": Decimal("0.25"), # Base tolerance for delta drift (20%) "EDGE_PROXIMITY_PCT": Decimal("0.04"), # Distance to range edge where protection activates "VELOCITY_THRESHOLD_PCT": Decimal("0.0005"), # Minimum price velocity to trigger volatility logic "POSITION_OPEN_EDGE_PROXIMITY_PCT": Decimal("0.06"), # Safety margin when opening new positions "POSITION_CLOSED_EDGE_PROXIMITY_PCT": Decimal("0.025"), # Safety margin for closing positions "LARGE_HEDGE_MULTIPLIER": Decimal("5.0"), # Multiplier to bypass trade cooldown for big moves "ENABLE_EDGE_CLEANUP": True, # Force rebalances when price is at range boundaries "EDGE_CLEANUP_MARGIN_PCT": Decimal("0.02"), # % of range width used for edge detection "MAKER_ORDER_TIMEOUT": 600, # Timeout for resting Maker orders (seconds) "SHADOW_ORDER_TIMEOUT": 600, # Timeout for theoretical shadow order tracking "ENABLE_FISHING": False, # Use passive maker orders for rebalancing (advanced) "FISHING_ORDER_SIZE_PCT": Decimal("0.10"), # Size of individual fishing orders "FISHING_TIMEOUT_FALLBACK": 30, # Seconds before converting fishing order to taker # EAC (Enhanced Asymmetric Compensation) "EAC_NARROW_RANGE_THRESHOLD": Decimal("0.02"), # <2% = narrow "EAC_MEDIUM_RANGE_THRESHOLD": Decimal("0.05"), # <5% = medium "EAC_NARROW_BOOST": Decimal("0.15"), # 15% boost "EAC_MEDIUM_BOOST": Decimal("0.10"), # 10% boost "EAC_WIDE_BOOST": Decimal("0.075"), # 7.5% boost } # --- CLP PROFILES --- CLP_PROFILES = { "UNISWAP_V3": { "NAME": "Uniswap V3 (Arbitrum) - ETH/USDC", "COIN_SYMBOL": "ETH", "RPC_ENV_VAR": "MAINNET_RPC_URL", "NPM_ADDRESS": "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", "ROUTER_ADDRESS": "0xE592427A0AEce92De3Edee1F18E0157C05861564", "TOKEN_A_ADDRESS": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", # WETH "TOKEN_B_ADDRESS": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", # USDC "WRAPPED_NATIVE_ADDRESS": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", "POOL_FEE": 500, }, "UNISWAP_wide": { "NAME": "Uniswap V3 (Arbitrum) - ETH/USDC Wide", "COIN_SYMBOL": "ETH", "RPC_ENV_VAR": "MAINNET_RPC_URL", "NPM_ADDRESS": "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", "ROUTER_ADDRESS": "0xE592427A0AEce92De3Edee1F18E0157C05861564", "TOKEN_A_ADDRESS": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", # WETH "TOKEN_B_ADDRESS": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", # USDC "WRAPPED_NATIVE_ADDRESS": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", "POOL_FEE": 500, "RANGE_WIDTH_PCT": Decimal("0.05"), "TARGET_INVESTMENT_AMOUNT": 2000, "MIN_HEDGE_THRESHOLD": Decimal("0.01"), "BASE_REBALANCE_THRESHOLD_PCT": Decimal("0.15"), }, "PANCAKESWAP_BNB": { "NAME": "PancakeSwap V3 (BNB Chain) - BNB/USDT", "COIN_SYMBOL": "BNB", "RPC_ENV_VAR": "BNB_RPC_URL", "NPM_ADDRESS": "0x46A15B0b27311cedF172AB29E4f4766fbE7F4364", "ROUTER_ADDRESS": "0x1b81D678ffb9C0263b24A97847620C99d213eB14", "TOKEN_A_ADDRESS": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", # WBNB "TOKEN_B_ADDRESS": "0x55d398326f99059fF775485246999027B3197955", # USDT "WRAPPED_NATIVE_ADDRESS": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", "POOL_FEE": 100, "RANGE_WIDTH_PCT": Decimal("0.004"), "TARGET_INVESTMENT_AMOUNT": 1000, "MIN_HEDGE_THRESHOLD": Decimal("0.015"), "BASE_REBALANCE_THRESHOLD_PCT": Decimal("0.10"), "EDGE_PROXIMITY_PCT": Decimal("0.015"), "DYNAMIC_THRESHOLD_MULTIPLIER": Decimal("1.1"), "MIN_TIME_BETWEEN_TRADES": 20, "ENABLE_FISHING": False, "FISHING_ORDER_SIZE_PCT": Decimal("0.05"), "MAKER_ORDER_TIMEOUT": 180, "FISHING_TIMEOUT_FALLBACK": 60, }, "WETH_CBBTC_BASE": { "NAME": "Aerodrome/Uni (Base) - WETH/cbBTC", "COIN_SYMBOL": "ETH", "RPC_ENV_VAR": "BASE_RPC_URL", "NPM_ADDRESS": "0x0000000000000000000000000000000000000000", # Placeholder "ROUTER_ADDRESS": "0x0000000000000000000000000000000000000000", # Placeholder "TOKEN_A_ADDRESS": "0x4200000000000000000000000000000000000006", # WETH (Base) "TOKEN_B_ADDRESS": "0xcbB7C915AB58735a1391B9fE18541b4d8926D412", # cbBTC (Base) "WRAPPED_NATIVE_ADDRESS": "0x4200000000000000000000000000000000000006", "POOL_FEE": 3000, "TARGET_INVESTMENT_AMOUNT": 200, "VALUE_REFERENCE": "USD", "RANGE_WIDTH_PCT": Decimal("0.10") } } # --- HELPER TO GET ACTIVE CONFIG --- def get_current_config(): profile = CLP_PROFILES.get(TARGET_DEX) if not profile: raise ValueError(f"Unknown CLP profile: {TARGET_DEX}") # Merge Default Strategy with Profile (Profile wins) config = DEFAULT_STRATEGY.copy() config.update(profile) return config