From 47d0969e516df8c4b6322ab00e3d02b1e39cd5a6 Mon Sep 17 00:00:00 2001 From: mindesbunister Date: Fri, 14 Nov 2025 21:08:47 +0100 Subject: [PATCH] docs: Complete Common Pitfall #1 with full Alchemy testing timeline DEFINITIVE CONCLUSION: - Alchemy 'breakthrough' at 14:25 was NOT sustainable - First trade appeared perfect, subsequent trades consistently fail - Multiple attempts with pure Alchemy config = same failures - Helius is the ONLY reliable RPC provider for Drift SDK Timeline documented: - 14:01: Switched to Alchemy - 14:25: First trade perfect (false breakthrough) - 15:00-20:00: Hybrid/fallback attempts (all failed) - 20:00: Pure Alchemy retry (still broke) - 20:05: Helius final revert (works reliably) User confirmations: - 'SO IT WAS THE FUCKING RPC...' (initial discovery) - 'after changing back the settings it started to act up again' (Alchemy breaks) - 'telegram works again' (Helius works) This is the complete story for future reference. --- .github/copilot-instructions.md | 42 +++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 6ad37b7..e20a962 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -994,22 +994,34 @@ ORDER BY MIN(adx) DESC; ## Common Pitfalls 1. **WRONG RPC PROVIDER (CRITICAL - CATASTROPHIC SYSTEM FAILURE):** - - **UPDATED Nov 14, 2025:** Alchemy RPC is INCOMPATIBLE with Drift SDK despite high throughput - - **Symptom #1 (Helius free tier):** 239+ rate limit errors in 10 minutes, trades hit SL immediately, duplicate closes, Position Manager loses tracking - - **Symptom #2 (Alchemy):** 100+ accountSubscribe errors during init, SDK claims "initialized successfully" but hangs on subsequent calls, positions open WITHOUT TP/SL orders (no risk management), Position Manager doesn't track positions - - **Root Cause #1:** Helius free tier (10 req/sec sustained) TOO LOW for trade execution + Position Manager monitoring - - **Root Cause #2:** Alchemy RPC does NOT support WebSocket subscriptions (accountSubscribe method) which Drift SDK REQUIRES - - **CORRECT SOLUTION:** Use Helius RPC with proper rate limit handling (5s exponential backoff retries) - - **Why Helius:** Supports ALL Solana RPC methods including WebSocket subscriptions, Drift SDK functions correctly - - **Why NOT Alchemy:** Despite 10,000 CU/s throughput (Growth plan), lacks WebSocket support = Drift SDK malfunction - - **Impact:** With Helius + retries: System fully operational, TP1/TP2/SL work correctly, Position Manager tracks properly - - **Date discovered:** Nov 12, 2025 (Helius limits), Nov 14, 2025 (Alchemy incompatibility confirmed by user) - - **User quote:** "after changing back the settings it started to act up again" (referring to Alchemy) + - **FINAL CONCLUSION Nov 14, 2025 (after extensive testing):** Helius is the ONLY reliable RPC provider for Drift SDK + - **Alchemy "breakthrough" was NOT sustainable:** First trade appeared perfect (14:25 CET), but Alchemy consistently fails on subsequent trades + - **Symptom #1 (Helius rate limits):** 239+ rate limit errors in 10 minutes → led to initial Alchemy switch + - **Symptom #2 (Alchemy incompatibility):** + * 100+ accountSubscribe errors during init + * SDK claims "initialized successfully" but is fundamentally broken + * First trade might work, then SDK gets into bad state + * Timeouts on subsequent execute calls (60+ seconds) + * Positions open WITHOUT TP/SL orders (NO RISK MANAGEMENT) + * Position Manager doesn't track positions + * Database saves fail silently + - **Root Cause:** Alchemy RPC does NOT support WebSocket subscriptions (accountSubscribe method) which Drift SDK REQUIRES for proper operation + - **ONLY WORKING SOLUTION:** Use Helius RPC with proper rate limit handling (5s exponential backoff retries) + - **Why Helius works:** Supports ALL Solana RPC methods including WebSocket subscriptions, Drift SDK functions correctly + - **Why Alchemy fails:** Despite 10,000 CU/s throughput (Growth plan), lacks WebSocket support = Drift SDK malfunction after first operation + - **Impact with Helius:** System fully operational, TP1/TP2/SL work correctly, Position Manager tracks properly + - **User confirmations:** + * "SO IT WAS THE FUCKING RPC THAT WAS CAUSING ALL THE ISSUES!!!!!!!!!!!!" (referring to Helius rate limits) + * "after changing back the settings it started to act up again" (Alchemy breaks again) + * "telegram works again" (after reverting to Helius final time) + - **Testing timeline Nov 14, 2025:** + * 14:01 - Switched to Alchemy + * 14:25 - First trade perfect (appeared to be breakthrough) + * 15:00-20:00 - Added hybrid/fallback code (broke everything) + * 20:00 - Reverted to pure Alchemy from working commit (still broke - timeouts, no TP/SL) + * 20:05 - Reverted to Helius (works reliably) - **Critical:** NEVER use RPC provider without WebSocket subscription support for Drift Protocol trading - - **Date Fixed:** Nov 14, 2025 - Switched to Alchemy, EVERYTHING started working immediately - - **Rule:** NEVER use Helius free tier for production trading - rate limits destroy trade execution - - **Evidence:** First trade on Alchemy: ZERO rate limit errors, clean TP1 hit, runner activated successfully - - **This was the root cause of ALL Position Manager issues for weeks** + - **This is definitive:** Helius only, no alternatives work reliably 2. **Prisma not generated in Docker:** Must run `npx prisma generate` in Dockerfile BEFORE `npm run build`