✨ Features Added: - Real-time event subscription using Drift SDK EventSubscriber - Periodic fallback monitoring for position changes - Interactive UI controls for starting/stopping monitoring - Comprehensive data source status tracking - Multi-source trade aggregation and deduplication 🔧 Backend Implementation: - EventSubscriber integration with OrderActionRecord events - Fallback to periodic monitoring (30s intervals) if events fail - Real-time trade cache management (last 100 trades) - Enhanced data availability status with monitoring state - Improved trade history from 5+ different API sources 🎨 Frontend Enhancements: - Live monitoring toggle button (🔴 Start Live / 🟢 Live) - Real-time status panel showing active monitoring state - Trade counter and last activity timestamps - Clear cache functionality for real-time trades - Enhanced status modal with monitoring details 🔗 API Endpoints: - POST /api/drift/realtime-monitoring - Control monitoring - GET /api/drift/realtime-monitoring - Check status - GET /api/drift/data-status - Enhanced with monitoring state 🐳 Docker Integration: - Updated container configuration for persistent monitoring - Environment variable support for real-time features - Database persistence for captured trades 💾 Database & Storage: - Automatic storage of real-time detected trades - Deduplication logic to prevent synthetic/duplicate trades - Persistent cache across container restarts 🚀 Usage: - Click 'Start Live' button in Trading History panel - Monitor will attempt EventSubscriber, fallback to periodic checks - All future trades automatically captured and stored - Status panel shows monitoring state and trade statistics This implements comprehensive real-time trading monitoring for Drift Protocol with robust fallback mechanisms and professional UI integration.
30 lines
821 B
TypeScript
30 lines
821 B
TypeScript
import { NextRequest, NextResponse } from 'next/server'
|
|
import { driftTradingService } from '../../../../lib/drift-trading'
|
|
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
const status = await driftTradingService.getDataAvailabilityStatus()
|
|
|
|
return NextResponse.json(status)
|
|
} catch (error) {
|
|
console.error('Error getting data status:', error)
|
|
|
|
// Return fallback status
|
|
return NextResponse.json({
|
|
status: 'Error Checking Status',
|
|
sources: [
|
|
{
|
|
name: 'System Check',
|
|
available: false,
|
|
description: 'Unable to check data source availability'
|
|
}
|
|
],
|
|
recommendations: [
|
|
'Try refreshing the page',
|
|
'Check your internet connection',
|
|
'Contact support if the issue persists'
|
|
]
|
|
})
|
|
}
|
|
}
|