diff --git a/lib/drift/orders.ts b/lib/drift/orders.ts index a99962f..39c1315 100644 --- a/lib/drift/orders.ts +++ b/lib/drift/orders.ts @@ -563,8 +563,11 @@ export async function closePosition( } // Place market close order using simple placePerpOrder (like v3) - console.log('🚀 Placing REAL market close order...') - const txSig = await driftClient.placePerpOrder(orderParams) + // CRITICAL: Wrap in retry logic for rate limit protection + console.log('🚀 Placing REAL market close order with retry protection...') + const txSig = await retryWithBackoff(async () => { + return await driftClient.placePerpOrder(orderParams) + }, 3, 8000) // 8s base delay, 3 max retries console.log(`✅ Close order placed! Transaction: ${txSig}`)