remove market slot kill switch

This commit is contained in:
Nour Alharithi
2024-01-22 18:03:28 -08:00
parent 0cb8ada461
commit 5fd1f7172d
2 changed files with 10 additions and 5 deletions

View File

@@ -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<MarketType, Map<number, any>>;
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);
}

View File

@@ -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) {