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}
|
||||
|
||||
Reference in New Issue
Block a user