Merge pull request #75 from drift-labs/master

kill switch slot diff
This commit is contained in:
Nour Alharithi
2024-01-22 16:15:27 -08:00
committed by GitHub

View File

@@ -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 - 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, {
bids: l2Formatted.bids.slice(0, 100),
asks: l2Formatted.asks.slice(0, 100),