ROOT CAUSE IDENTIFIED (Dec 10, 2025): - Original working implementation (4cc294b, Oct 26): Used SPECIFIC price for each order - Broken implementation: Used entryPrice for ALL orders - Impact: Wrong token quantities = orders rejected/failed = NULL database signatures THE FIX: - Reverted usdToBase(usd) to usdToBase(usd, price) - TP1: Now uses options.tp1Price (not entryPrice) - TP2: Now uses options.tp2Price (not entryPrice) - SL: Now uses options.stopLossPrice (not entryPrice) WHY THIS FIXES IT: - To close 60% at TP1 price $141.20, need DIFFERENT token quantity than at entry $140.00 - Using wrong price = wrong size = Drift rejects order OR creates wrong size - Correct price = correct token quantity = orders placed successfully ORIGINAL COMMIT MESSAGE (4cc294b): "All 3 exit orders placed successfully on-chain" FILES CHANGED: - lib/drift/orders.ts: Fixed usdToBase() function signature + all 3 call sites This fix restores the proven working implementation that had 100% success rate. User lost $1,000+ from this bug causing positions without risk management.
37 KiB
37 KiB