diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 39f0234..b7d217c 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -3091,25 +3091,27 @@ This section contains the **TOP 10 MOST CRITICAL** pitfalls that every AI agent - **Why:** JavaScript Map.delete() returns true only for first caller - **Status:** Fixed Dec 2, 2025 -**9. Smart Entry Wrong Price (#66, #68)** - Use Pyth price, not webhook +**9. Wrong Price in usdToBase() (#81 - ROOT CAUSE - Dec 10, 2025)** - CAUSED $1,000+ LOSSES +- **Bug:** Changed from `usdToBase(usd, price)` to `usdToBase(usd)` using entryPrice for ALL orders +- **Impact:** Wrong token quantities = Drift rejects orders = NULL database signatures = NO risk management +- **Example:** $8,000 at TP1 $141.20 needs 56.66 SOL, but code calculated 57.14 SOL (used $140 entry price) +- **Fix:** Reverted to original: `usdToBase(tp1USD, options.tp1Price)` - use SPECIFIC price for each order +- **Original commit:** 4cc294b (Oct 26, 2025) - "All 3 exit orders placed successfully on-chain" (100% success) +- **Status:** ✅ FIXED Dec 10, 2025 14:31 CET (commit 55d780c) + +**10. Smart Entry Wrong Price (#66, #68)** - Use Pyth price, not webhook - **Bug #66:** Symbol format mismatch ("SOLUSDT" vs "SOL-PERP") caused cache miss - **Bug #68:** Webhook `signal.price` contained percentage (70.80) not market price ($142) - **Fix:** Always use `pythClient.getPrice(symbol)` for calculations - **Status:** Fixed Dec 1-3, 2025 -**10. MFE/MAE Wrong Units (#54)** - Store percentages, not dollars -- **Bug:** Storing $64.08 when should store 0.48% (133× inflation) -- **Fix:** `trade.maxFavorableExcursion = profitPercent` not `currentPnLDollars` -- **Impact:** Analytics completely wrong for all trades -- **Status:** Fixed Nov 23, 2025 - --- ### Quick Links by Category **P&L Calculation Errors:** #11, #41, #48, #49, #54, #57, #61 **Race Conditions:** #27, #28, #59, #60, #67 -**SDK/API Issues:** #1, #2, #12, #24, #36, #45 +**SDK/API Issues:** #1, #2, #12, #24, #36, #45, #81 **Database Operations:** #29, #35, #37, #50, #58 **Configuration:** #55, #62 **Smart Entry:** #63, #66, #68, #70