Merge pull request #79 from drift-labs/master
consolidate conditions for killswitch
This commit is contained in:
@@ -15,8 +15,6 @@ import {
|
||||
l2WithBNToStrings,
|
||||
} from '../utils/utils';
|
||||
|
||||
const SLOT_DIFF_KILLSWITCH_THRESHOLD = 200;
|
||||
|
||||
type wsMarketL2Args = {
|
||||
marketIndex: number;
|
||||
marketType: MarketType;
|
||||
@@ -38,7 +36,7 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
||||
public marketL2Args: wsMarketL2Args[] = [];
|
||||
public lastSeenL2Formatted: Map<MarketType, Map<number, any>>;
|
||||
redisClient: RedisClient;
|
||||
public marketKillSwitchSlotDiffThreshold: number;
|
||||
public killSwitchSlotDiffThreshold: number;
|
||||
|
||||
constructor(
|
||||
config: DLOBSubscriptionConfig & {
|
||||
@@ -46,13 +44,13 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
||||
perpMarketInfos: wsMarketInfo[];
|
||||
spotMarketInfos: wsMarketInfo[];
|
||||
spotMarketSubscribers: SubscriberLookup;
|
||||
marketKillSwitchSlotDiffThreshold?: number;
|
||||
killSwitchSlotDiffThreshold?: number;
|
||||
}
|
||||
) {
|
||||
super(config);
|
||||
this.redisClient = config.redisClient;
|
||||
this.marketKillSwitchSlotDiffThreshold =
|
||||
config.marketKillSwitchSlotDiffThreshold || 200;
|
||||
this.killSwitchSlotDiffThreshold =
|
||||
config.killSwitchSlotDiffThreshold || 200;
|
||||
|
||||
// Set up appropriate maps
|
||||
this.lastSeenL2Formatted = new Map();
|
||||
@@ -147,7 +145,9 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
||||
|
||||
if (
|
||||
Math.abs(slot - parseInt(l2Formatted['oracleData']['slot'])) >
|
||||
SLOT_DIFF_KILLSWITCH_THRESHOLD
|
||||
this.killSwitchSlotDiffThreshold ||
|
||||
Math.abs(slot - l2Formatted['marketSlot']) >
|
||||
this.killSwitchSlotDiffThreshold
|
||||
) {
|
||||
console.log(`Killing process due to slot diffs:
|
||||
dlobProvider slot: ${slot}
|
||||
|
||||
@@ -71,8 +71,8 @@ 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;
|
||||
const KILLSWITCH_SLOT_DIFF_THRESHOLD =
|
||||
parseInt(process.env.KILLSWITCH_SLOT_DIFF_THRESHOLD) || 200;
|
||||
|
||||
// comma separated list of perp market indexes to load: i.e. 0,1,2,3
|
||||
const PERP_MARKETS_TO_LOAD =
|
||||
@@ -398,7 +398,7 @@ const main = async () => {
|
||||
spotMarketSubscribers: MARKET_SUBSCRIBERS,
|
||||
perpMarketInfos,
|
||||
spotMarketInfos,
|
||||
marketKillSwitchSlotDiffThreshold: MARKET_KILLSWITCH_SLOT_DIFF_THRESHOLD,
|
||||
killSwitchSlotDiffThreshold: KILLSWITCH_SLOT_DIFF_THRESHOLD,
|
||||
});
|
||||
await dlobSubscriber.subscribe();
|
||||
if (useWebsocket && !FEATURE_FLAGS.DISABLE_GPA_REFRESH) {
|
||||
|
||||
Reference in New Issue
Block a user