Fixed Position Manager incorrectly treating position.size as USD when Drift SDK actually returns base asset tokens (SOL, ETH, BTC). Impact: - FALSE TP1 detections (12.28 SOL misinterpreted as 2.28 USD) - Stop loss moved to breakeven prematurely - Runner system activated incorrectly - Positions stuck in wrong state Changes: - Line 322: Convert position.size to USD: position.size * currentPrice - Line 519: Calculate positionSizeUSD before comparison - Line 558: Use positionSizeUSD directly (already in USD) - Line 591: Save positionSizeUSD (no price multiplication needed) Before: Compared 12.28 tokens < 1950 USD = 99.4% reduction = FALSE TP1 This was causing current trade to think TP1 hit when position is still 100% open.
42 KiB
42 KiB