@@ -39,6 +39,7 @@ export class Hunter extends EventEmitter {
3939 private wsKeepAliveInterval : NodeJS . Timeout | null = null ; // WebSocket keepalive ping timer
4040 private wsInactivityTimeout : NodeJS . Timeout | null = null ; // WebSocket inactivity detector
4141 private lastLiquidationTime : number = Date . now ( ) ; // Track last liquidation received
42+ private statusLogInterval : NodeJS . Timeout | null = null ; // Periodic status logging
4243
4344 constructor ( config : Config , isHedgeMode : boolean = false ) {
4445 super ( ) ;
@@ -366,6 +367,19 @@ logWithTimestamp('Hunter: Running in paper mode without API keys - simulating li
366367
367368 // Start inactivity monitor - reconnect if no liquidations for 5 minutes
368369 this . startInactivityMonitor ( ) ;
370+
371+ // Start periodic status logging - every 2 minutes
372+ this . statusLogInterval = setInterval ( ( ) => {
373+ const timeSinceLastLiq = Date . now ( ) - this . lastLiquidationTime ;
374+ const minutesInactive = Math . floor ( timeSinceLastLiq / 60000 ) ;
375+ const secondsInactive = Math . floor ( ( timeSinceLastLiq % 60000 ) / 1000 ) ;
376+
377+ if ( minutesInactive >= 1 ) {
378+ logWithTimestamp ( `📊 Hunter: Monitoring | Last liquidation: ${ minutesInactive } m ${ secondsInactive } s ago` ) ;
379+ } else {
380+ logWithTimestamp ( `📊 Hunter: Monitoring | Last liquidation: ${ secondsInactive } s ago` ) ;
381+ }
382+ } , 120000 ) ; // Every 2 minutes
369383 } ) ;
370384
371385 this . ws . on ( 'ping' , ( ) => {
@@ -442,16 +456,7 @@ logWithTimestamp('Hunter: Running in paper mode without API keys - simulating li
442456 this . cleanupWebSocketTimers ( ) ;
443457
444458 if ( this . isRunning ) {
445- // Broadcast reconnection attempt to UI
446- if ( this . statusBroadcaster ) {
447- this . statusBroadcaster . broadcastWebSocketError (
448- 'Hunter WebSocket Closed' ,
449- 'Liquidation stream disconnected. Reconnecting in 5 seconds...' ,
450- {
451- component : 'Hunter' ,
452- }
453- ) ;
454- }
459+ // Reconnect silently - close events are often normal (like during inactivity reconnect)
455460 setTimeout ( ( ) => this . connectWebSocket ( ) , 5000 ) ;
456461 }
457462 } ) ;
@@ -468,19 +473,7 @@ logWithTimestamp('Hunter: Running in paper mode without API keys - simulating li
468473 const timeSinceLastLiq = Date . now ( ) - this . lastLiquidationTime ;
469474 const minutesInactive = Math . floor ( timeSinceLastLiq / 60000 ) ;
470475
471- logWarnWithTimestamp ( `⚠️ Hunter: No liquidations received for ${ minutesInactive } minutes. Reconnecting...` ) ;
472-
473- // Broadcast warning to UI
474- if ( this . statusBroadcaster ) {
475- this . statusBroadcaster . broadcastWebSocketError (
476- 'Hunter Stream Inactive' ,
477- `No liquidations received for ${ minutesInactive } minutes. Reconnecting to ensure stream is alive...` ,
478- {
479- component : 'Hunter' ,
480- inactiveMinutes : minutesInactive ,
481- }
482- ) ;
483- }
476+ logWarnWithTimestamp ( `⚠️ Hunter: No liquidations for ${ minutesInactive } minutes. Reconnecting stream...` ) ;
484477
485478 // Force reconnection
486479 if ( this . ws ) {
@@ -500,6 +493,10 @@ logWithTimestamp('Hunter: Running in paper mode without API keys - simulating li
500493 clearTimeout ( this . wsInactivityTimeout ) ;
501494 this . wsInactivityTimeout = null ;
502495 }
496+ if ( this . statusLogInterval ) {
497+ clearInterval ( this . statusLogInterval ) ;
498+ this . statusLogInterval = null ;
499+ }
503500 }
504501
505502 private async handleLiquidationEvent ( event : any ) : Promise < void > {
@@ -521,6 +518,10 @@ logWithTimestamp('Hunter: Running in paper mode without API keys - simulating li
521518 time : event . E , // Keep for backward compatibility
522519 } ;
523520
521+ // Log liquidation received with basic info
522+ const volumeUSDT = liquidation . qty * liquidation . price ;
523+ logWithTimestamp ( `💥 Liquidation: ${ liquidation . symbol } ${ liquidation . side } ${ liquidation . qty . toFixed ( 4 ) } @ $${ liquidation . price . toLocaleString ( ) } ($${ volumeUSDT . toFixed ( 2 ) } )` ) ;
524+
524525 // Check if threshold system is enabled globally and for this symbol
525526 const useThresholdSystem = this . config . global . useThresholdSystem === true &&
526527 this . config . symbols [ liquidation . symbol ] ?. useThreshold === true ;
@@ -537,8 +538,6 @@ logWithTimestamp('Hunter: Running in paper mode without API keys - simulating li
537538 const symbolConfig = this . config . symbols [ liquidation . symbol ] ;
538539 if ( ! symbolConfig ) return ; // Symbol not in config
539540
540- const volumeUSDT = liquidation . qty * liquidation . price ;
541-
542541 // Store liquidation in database (non-blocking)
543542 liquidationStorage . saveLiquidation ( liquidation , volumeUSDT ) . catch ( error => {
544543logErrorWithTimestamp ( 'Hunter: Failed to store liquidation:' , error ) ;
0 commit comments