# CLP Strategy & Configuration Log This document detailed information about clp position (6153292) + auto hedge on Hyperliquide. --- ## 1. Low Volatility / Weekend Optimization (Narrow Range) **Date:** 2025-12-29 **Status:** Active **Objective:** Further optimalization of hedging on Hyperliquide. ### 🔍 Context * **Market Condition:** Monday, th 29th of Dec * **Capital:** $1,000 USDC * **Range:** +/- 1.5% (Narrow) ### ⚙️ Configuration of scripts (See original file for full config dump) ### test results 1. clp position: { "type": "AUTOMATIC", "token_id": 6153292, "status": "CLOSED", "target_value": 993.31, "entry_price": 869.418, "amount0_initial": 500.0094, "amount1_initial": 0.5674, "liquidity": "2284728345715808667084", "range_upper": 882.4136, "range_lower": 856.6782, "token0_decimals": 18, "token1_decimals": 18, "timestamp_open": 1766982584, "target_value_end": 982.48, "timestamp_close": 1767000734 } 2. hedge transactions (from Hyperliquide) (See original file for table) ## results of tests are not satisfactional: 1. the main problem is that the hedge doesn't cover lost value of clp pool (without earned fees) -> **-$2.23** --- ### 🚀 Analysis & Diagnosis (2025-12-29) After reviewing the logs and transaction history, here is the breakdown of the PnL and the root cause of the slippage. #### **1. PnL Breakdown (The "Missing" $2.23)** * **LP Position Value Change:** * Initial Value: ~$993.31 * Final Value: ~$982.50 * **LP Loss:** **-$10.81** (This is the Impermanent Loss + Delta Loss from holding BNB as it dropped). * **Hedge Compensation:** * Hedge Gross Profit: **+$10.61** (from your table). * **Net Delta Efficiency:** The hedge covered the LP loss almost perfectly (Diff: -$0.20). * *Conclusion:* The **Delta Calculation is CORRECT**. The math effectively neutralized the market move. * **The Costs (The Real Leak):** * **Trading Fees:** You paid ~$0.79 in fees on Hyperliquid (mostly from the initial Taker entry and the final Taker exit). * **Funding Fees:** Since you were Shorting BNB for ~5 hours, and rates might have been negative (Shorts pay Longs) or just the cost of carry, the remaining discrepancy (~$1.20) is likely **Funding Costs** or slight slippage between LP exit price and Hedge exit price. **Total Net:** -$0.20 (Delta Slippage) - $0.79 (Fees) - $1.24 (Funding/Execution Slippage) = **-$2.23** #### **2. Execution Inefficiency (The "Panic Loop")** The logs reveal a flaw in the execution strategy during trending moves: 1. **Drift:** Price drops, Delta drift exceeds threshold (`0.05`). 2. **Maker Attempt:** Bot places an `ALO` (Maker) order at the Bid. 3. **Timeout:** Market moves down faster than the order fills. The order sits pending (`[WAIT]`). 4. **Cancel:** Bot cancels the stale order. 5. **Drift Worsens:** The drift continues to grow as price drops further. 6. **Panic:** Eventually, `Drift > 5x Threshold` (Large Hedge). 7. **Taker Smash:** Bot forces an `IOC` (Taker) trade, paying high fees (0.035%) and eating slippage. **Evidence:** * Initial Entry: `[WARN] LARGE HEDGE` -> Taker (Fee: $0.21). * Final Exit: `[URGENT] ... Force Taker Exit` -> Taker (Fee: $0.45). * These two trades alone account for ~85% of your fee costs. --- ### 🛠️ Answers to Questions **1. Is the calculation of hedge wrong?** **No.** The Delta calculation is accurate. The gross profit of the hedge (+$10.61) almost exactly matched the raw value loss of the LP (-$10.81). The math works. **2. How we can proactively fix it?** We need to fix the **Execution Strategy** to avoid the "Wait -> Cancel -> Panic Taker" loop. * **Soft Taker Fallback:** If a Maker order times out (e.g., after 30s), retry as Taker immediately *before* the drift becomes huge. * **Asymmetric Compensation:** Increase the "Over-Hedge" factor. Since V3 LP accumulates "Long" exposure as price drops (Negative Gamma), we should short *more* aggressively early on. **3. What we can do with configuration?** We need to tune for **Narrow Ranges** (High Gamma). #### **Recommended Config Changes** | Parameter | Current | Recommended | Reason | | :--- | :--- | :--- | :--- | | `MIN_HEDGE_THRESHOLD` | `0.05` | **0.02** | Hedge smaller deviations sooner to prevent runaway gamma. | | `LARGE_HEDGE_MULTIPLIER` | `5.0` | **2.5** | Trigger Taker/Urgent correction sooner, before the hole gets too deep. | | `MAKER_ORDER_TIMEOUT` | `600` | **60** | Don't let orders rot for 10 minutes. Cancel and retry faster. | | `SHADOW_ORDER_TIMEOUT` | `600` | **30** | Same as above. | | `BASE_REBALANCE_THRESHOLD_PCT` | `0.25` | **0.15** | Tighten the percentage-based trigger. | #### **Code Change Recommendation (Unified Hedger)** We should update `unified_hedger.py` to: 1. **Persist Realized PnL:** Fix the bug where `_status.json` isn't updated with hedge PnL, so your logs reflect reality. 2. **Execution Fallback:** If an `ALO` order fails/cancels, decrement a counter. If it fails twice, force `IOC`. --- ### 📝 Action Plan 1. Apply the **Config Changes** above to `clp_config.py`. 2. (Optional) I can patch `unified_hedger.py` to fix the PnL logging and execution logic if you approve.