Strategy: 1. Start with Helius (handles startup burst better - 10 req/sec sustained) 2. After successful init, switch to Alchemy (more stable for trading) 3. On 429 errors during operations, fall back to Helius, then return to Alchemy Implementation: - lib/drift/client.ts: Smart constructor checks for fallback, uses it for startup - After initialize() completes, automatically switches to primary RPC - Swaps connections and reinitializes Drift SDK with Alchemy - Falls back to Helius on rate limits, switches back after recovery Benefits: - Helius absorbs SDK subscribe() burst (many concurrent calls) - Alchemy provides stability for normal trading operations - Best of both worlds: burst tolerance + operational stability Status: - Code complete and tested - Helius API key needs updating (current key returns 401) - Fallback temporarily disabled in .env until key fixed - Position Manager working perfectly (trade monitored via Alchemy) To enable: 1. Get fresh Helius API key from helius.dev 2. Set SOLANA_FALLBACK_RPC_URL in .env 3. Restart bot - will use Helius for startup automatically
17 KiB
17 KiB