diff --git a/lib/trading/position-manager.ts b/lib/trading/position-manager.ts index dae28a4..23d5036 100644 --- a/lib/trading/position-manager.ts +++ b/lib/trading/position-manager.ts @@ -508,8 +508,13 @@ export class PositionManager { trade.tp1Hit = true trade.currentSize = positionSizeUSD - // Move SL to breakeven after TP1 - trade.stopLossPrice = trade.entryPrice + // CRITICAL: Query Drift for ACTUAL entry price (more accurate than database) + // The position.entryPrice from Drift SDK is calculated from on-chain data + const actualEntryPrice = position.entryPrice || trade.entryPrice + console.log(`📊 Breakeven calculation: DB entry=$${trade.entryPrice.toFixed(4)}, Drift entry=$${actualEntryPrice.toFixed(4)}`) + + // Move SL to TRUE breakeven after TP1 + trade.stopLossPrice = actualEntryPrice trade.slMovedToBreakeven = true console.log(`🛡️ Stop loss moved to breakeven: $${trade.stopLossPrice.toFixed(4)}`)