From d9317c8157a31bb05bf882896c35c1a2a68dbe78 Mon Sep 17 00:00:00 2001 From: Nour Alharithi Date: Tue, 6 Feb 2024 12:06:35 -0800 Subject: [PATCH] new market staleness --- src/dlob-subscriber/DLOBSubscriberIO.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/dlob-subscriber/DLOBSubscriberIO.ts b/src/dlob-subscriber/DLOBSubscriberIO.ts index bc3ce64..2ef863f 100644 --- a/src/dlob-subscriber/DLOBSubscriberIO.ts +++ b/src/dlob-subscriber/DLOBSubscriberIO.ts @@ -27,7 +27,8 @@ type wsMarketL2Args = { updateOnChange?: boolean; }; -const MAKRET_STALENESS_THRESHOLD = 10 * 60 * 1000; +const PERP_MAKRET_STALENESS_THRESHOLD = 10 * 60 * 1000; +const SPOT_MAKRET_STALENESS_THRESHOLD = 20 * 60 * 1000; export type wsMarketInfo = { marketIndex: number; @@ -180,6 +181,10 @@ export class DLOBSubscriberIO extends DLOBSubscriber { } // Check if times and slots are too different for market + const MAKRET_STALENESS_THRESHOLD = + marketType === 'perp' + ? PERP_MAKRET_STALENESS_THRESHOLD + : SPOT_MAKRET_STALENESS_THRESHOLD; if ( lastMarketSlotAndTime && l2Formatted['marketSlot'] === lastMarketSlotAndTime.slot && @@ -197,12 +202,10 @@ export class DLOBSubscriberIO extends DLOBSubscriber { console.log( `Updating market slot for ${l2Args.marketName} with slot ${l2Formatted['marketSlot']}` ); - this.lastMarketSlotMap - .get(l2Args.marketType) - .set(l2Args.marketIndex, { - slot: l2Formatted['marketSlot'], - ts: Date.now(), - }); + this.lastMarketSlotMap.get(l2Args.marketType).set(l2Args.marketIndex, { + slot: l2Formatted['marketSlot'], + ts: Date.now(), + }); } const l2Formatted_depth100 = Object.assign({}, l2Formatted, {