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