feat: Hybrid RPC strategy - Helius for init, Alchemy for trades
CRITICAL FIX: Rate limiting causing unprotected positions
Root Cause:
- Rate limit errors preventing exit order placement after opening positions
- Positions opened with NO on-chain TP/SL protection
- If container crashes, position has unlimited risk exposure
Hybrid RPC Solution:
- Helius RPC: Drift SDK initialization (handles burst subscriptions perfectly)
- Alchemy RPC: Trade operations - open, close, confirmations (better sustained rate limits)
- Graceful fallback: If Alchemy not configured, uses Helius for everything
Implementation:
- DriftService: Dual connections (connection + tradeConnection)
- getTradeConnection() returns Alchemy if configured, else Helius
- openPosition() and closePosition() use tradeConnection for confirmTransaction()
- Added ALCHEMY_RPC_URL to .env (optional)
Configuration:
- SOLANA_RPC_URL: Helius (existing)
- ALCHEMY_RPC_URL: Added with your Alchemy key
Files:
- lib/drift/client.ts: Dual connection support + getTradeConnection()
- lib/drift/orders.ts: Use getTradeConnection() for all confirmations
- .env: Added ALCHEMY_RPC_URL
Logs show: '🔀 Hybrid RPC mode: Helius for init, Alchemy for trades'
Next: Test with new trade to verify orders place successfully
This commit is contained in:
@@ -444,13 +444,6 @@ export class DriftService {
|
||||
return this.driftClient!
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Solana connection instance
|
||||
*/
|
||||
getConnection(): Connection {
|
||||
return this.connection
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user instance
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user