From 21a407c0b6e4e93e785a9423bb06657fc6e7f462 Mon Sep 17 00:00:00 2001 From: Nour Alharithi Date: Mon, 22 Jan 2024 15:24:20 -0800 Subject: [PATCH] kill-switch --- src/dlob-subscriber/DLOBSubscriberIO.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/dlob-subscriber/DLOBSubscriberIO.ts b/src/dlob-subscriber/DLOBSubscriberIO.ts index 41491e7..88e7bb3 100644 --- a/src/dlob-subscriber/DLOBSubscriberIO.ts +++ b/src/dlob-subscriber/DLOBSubscriberIO.ts @@ -15,6 +15,8 @@ import { l2WithBNToStrings, } from '../utils/utils'; +const SLOT_DIFF_KILLSWITCH_THRESHOLD = 50; + type wsMarketL2Args = { marketIndex: number; marketType: MarketType; @@ -139,6 +141,20 @@ export class DLOBSubscriberIO extends DLOBSubscriber { l2Args.marketIndex ); + if ( + Math.abs(slot - l2Formatted['marketSlot']) > + SLOT_DIFF_KILLSWITCH_THRESHOLD || + Math.abs(slot - l2Formatted['oracleData']['slot']) > + 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); + } + const l2Formatted_depth100 = Object.assign({}, l2Formatted, { bids: l2Formatted.bids.slice(0, 100), asks: l2Formatted.asks.slice(0, 100),