Merge pull request #74 from drift-labs/kill-switch

kill-switch
This commit is contained in:
Nour Alharithi
2024-01-22 15:50:32 -08:00
committed by GitHub

View File

@@ -15,6 +15,8 @@ import {
l2WithBNToStrings, l2WithBNToStrings,
} from '../utils/utils'; } from '../utils/utils';
const SLOT_DIFF_KILLSWITCH_THRESHOLD = 50;
type wsMarketL2Args = { type wsMarketL2Args = {
marketIndex: number; marketIndex: number;
marketType: MarketType; marketType: MarketType;
@@ -139,6 +141,20 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
l2Args.marketIndex l2Args.marketIndex
); );
if (
Math.abs(slot - l2Formatted['marketSlot']) >
SLOT_DIFF_KILLSWITCH_THRESHOLD ||
Math.abs(slot - parseInt(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, { const l2Formatted_depth100 = Object.assign({}, l2Formatted, {
bids: l2Formatted.bids.slice(0, 100), bids: l2Formatted.bids.slice(0, 100),
asks: l2Formatted.asks.slice(0, 100), asks: l2Formatted.asks.slice(0, 100),