feat: switch from Helius to Alchemy RPC provider

Changes:
- Updated SOLANA_RPC_URL to use Alchemy (https://solana-mainnet.g.alchemy.com/v2/...)
- Migrated from Helius free tier to Alchemy free tier
- Includes previous rate limit fixes (8s backoff, 2s operation delays)

Context:
- Helius free tier: 10 req/sec sustained, 100 req/sec burst
- Alchemy free tier: 300M compute units/month (more generous)
- User hit 239 rate limit errors in 10 minutes on Helius
- User registered Alchemy account and provided API key

Impact:
- Should significantly reduce 429 rate limit errors
- Better free tier limits for trading bot operations
- Combined with delay fixes for optimal RPC usage
This commit is contained in:
mindesbunister
2025-11-14 14:01:52 +01:00
parent 3cc3f1b871
commit 7afd7d5aa1
3 changed files with 11 additions and 2 deletions

View File

@@ -299,6 +299,9 @@ export async function POST(request: NextRequest): Promise<NextResponse<ExecuteTr
console.log(` Leverage: ${leverage}x`)
console.log(` Total position: $${positionSizeUSD}`)
// Helper function for rate limit spacing
const rpcDelay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms))
// Open position
const openResult = await openPosition({
symbol: driftSymbol,
@@ -306,6 +309,9 @@ export async function POST(request: NextRequest): Promise<NextResponse<ExecuteTr
sizeUSD: positionSizeUSD,
slippageTolerance: config.slippageTolerance,
})
// Wait 2 seconds before placing exit orders to space out RPC calls
await rpcDelay(2000)
if (!openResult.success) {
return NextResponse.json(
@@ -331,6 +337,9 @@ export async function POST(request: NextRequest): Promise<NextResponse<ExecuteTr
try {
console.log(`⚠️ Closing phantom position immediately for safety...`)
// Wait 2 seconds to space out RPC calls
await rpcDelay(2000)
closeResult = await closePosition({
symbol: driftSymbol,
percentToClose: 100, // Close 100% of whatever size exists