mindesbunister
d602744938
critical: Fix 1-minute signal price logging - query Drift oracle directly
Problem:
- 1-minute signals logged wrong prices (4-55 vs actual 41-144 SOL)
- Pyth price cache empty for 1-minute signals
- Fallback to body.signalPrice (from n8n) contained pricePosition value
- signalPrice === pricePosition in every request (39.29 = 39.29)
Failed Attempts (5):
1. Added @ close to TradingView indicator (commit 212a36f)
2. Added signalPrice regex to n8n (commit 99a5223)
3. Fixed regex to avoid POS collision (commit ff402ed)
4. Added DEBUG logging to n8n (no output visible)
5. FINAL FIX: Query Drift oracle directly
Solution:
- Bypass Pyth cache and n8n signalPrice entirely
- Query Drift Protocol oracle directly for real-time price
- Lines 145-149 in execute/route.ts:
* OLD: latestPrice?.price || body.signalPrice || 0
* NEW: await driftService.getOraclePrice(marketConfig.driftMarketIndex)
- Drift oracle is source of truth (on-chain), no caching issues
- Added getMarketConfig import to resolve marketConfig
Impact:
- Logs will show actual SOL price ($141.XX) instead of indicator values ($24-55)
- Accurate price logging critical for REAL MONEY system P&L tracking
- BlockedSignal database records will have correct signalPrice values
Files Changed:
- app/api/trading/execute/route.ts (lines 11, 145-149)
* Added getMarketConfig to imports
* Replaced Pyth cache fallback with direct Drift oracle query