From 5fd1f7172dc3dbfb6757f3b1008405350c10b4d8 Mon Sep 17 00:00:00 2001 From: Nour Alharithi Date: Mon, 22 Jan 2024 18:03:28 -0800 Subject: [PATCH] remove market slot kill switch --- src/dlob-subscriber/DLOBSubscriberIO.ts | 11 ++++++----- src/publishers/dlobPublisher.ts | 4 ++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/dlob-subscriber/DLOBSubscriberIO.ts b/src/dlob-subscriber/DLOBSubscriberIO.ts index 4cf1d96..9d7fa0c 100644 --- a/src/dlob-subscriber/DLOBSubscriberIO.ts +++ b/src/dlob-subscriber/DLOBSubscriberIO.ts @@ -15,7 +15,7 @@ import { l2WithBNToStrings, } from '../utils/utils'; -const SLOT_DIFF_KILLSWITCH_THRESHOLD = 50; +const SLOT_DIFF_KILLSWITCH_THRESHOLD = 100; type wsMarketL2Args = { marketIndex: number; @@ -38,6 +38,7 @@ export class DLOBSubscriberIO extends DLOBSubscriber { public marketL2Args: wsMarketL2Args[] = []; public lastSeenL2Formatted: Map>; redisClient: RedisClient; + public marketKillSwitchSlotDiffThreshold: number; constructor( config: DLOBSubscriptionConfig & { @@ -45,10 +46,13 @@ export class DLOBSubscriberIO extends DLOBSubscriber { perpMarketInfos: wsMarketInfo[]; spotMarketInfos: wsMarketInfo[]; spotMarketSubscribers: SubscriberLookup; + marketKillSwitchSlotDiffThreshold?: number; } ) { super(config); this.redisClient = config.redisClient; + this.marketKillSwitchSlotDiffThreshold = + config.marketKillSwitchSlotDiffThreshold || 200; // Set up appropriate maps this.lastSeenL2Formatted = new Map(); @@ -142,15 +146,12 @@ export class DLOBSubscriberIO extends DLOBSubscriber { ); if ( - Math.abs(slot - l2Formatted['marketSlot']) > - SLOT_DIFF_KILLSWITCH_THRESHOLD || Math.abs(slot - parseInt(l2Formatted['oracleData']['slot'])) > - SLOT_DIFF_KILLSWITCH_THRESHOLD + SLOT_DIFF_KILLSWITCH_THRESHOLD ) { console.log(`Killing process due to slot diffs: dlobProvider slot: ${slot} oracle slot: ${l2Formatted['oracleData']['slot']} - market slot: ${l2Formatted['marketSlot']} `); process.exit(1); } diff --git a/src/publishers/dlobPublisher.ts b/src/publishers/dlobPublisher.ts index 10d9504..caa45ef 100644 --- a/src/publishers/dlobPublisher.ts +++ b/src/publishers/dlobPublisher.ts @@ -71,6 +71,9 @@ const ORDERBOOK_UPDATE_INTERVAL = parseInt(process.env.ORDERBOOK_UPDATE_INTERVAL) || 1000; const WS_FALLBACK_FETCH_INTERVAL = 10_000; +const MARKET_KILLSWITCH_SLOT_DIFF_THRESHOLD = + parseInt(process.env.MARKET_KILLSWITCH_SLOT_DIFF_THRESHOLD) || 300; + // comma separated list of perp market indexes to load: i.e. 0,1,2,3 const PERP_MARKETS_TO_LOAD = process.env.PERP_MARKETS_TO_LOAD !== undefined @@ -395,6 +398,7 @@ const main = async () => { spotMarketSubscribers: MARKET_SUBSCRIBERS, perpMarketInfos, spotMarketInfos, + marketKillSwitchSlotDiffThreshold: MARKET_KILLSWITCH_SLOT_DIFF_THRESHOLD, }); await dlobSubscriber.subscribe(); if (useWebsocket && !FEATURE_FLAGS.DISABLE_GPA_REFRESH) {