@@ -36,6 +36,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 killSwitchSlotDiffThreshold: number;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
config: DLOBSubscriptionConfig & {
|
config: DLOBSubscriptionConfig & {
|
||||||
@@ -43,10 +44,13 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
perpMarketInfos: wsMarketInfo[];
|
perpMarketInfos: wsMarketInfo[];
|
||||||
spotMarketInfos: wsMarketInfo[];
|
spotMarketInfos: wsMarketInfo[];
|
||||||
spotMarketSubscribers: SubscriberLookup;
|
spotMarketSubscribers: SubscriberLookup;
|
||||||
|
killSwitchSlotDiffThreshold?: number;
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
super(config);
|
super(config);
|
||||||
this.redisClient = config.redisClient;
|
this.redisClient = config.redisClient;
|
||||||
|
this.killSwitchSlotDiffThreshold =
|
||||||
|
config.killSwitchSlotDiffThreshold || 200;
|
||||||
|
|
||||||
// Set up appropriate maps
|
// Set up appropriate maps
|
||||||
this.lastSeenL2Formatted = new Map();
|
this.lastSeenL2Formatted = new Map();
|
||||||
@@ -139,6 +143,18 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
l2Args.marketIndex
|
l2Args.marketIndex
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (
|
||||||
|
Math.abs(slot - parseInt(l2Formatted['oracleData']['slot'])) >
|
||||||
|
this.killSwitchSlotDiffThreshold
|
||||||
|
) {
|
||||||
|
console.log(`Killing process due to slot diffs for market ${marketName}:
|
||||||
|
dlobProvider slot: ${slot}
|
||||||
|
oracle slot: ${l2Formatted['oracleData']['slot']}
|
||||||
|
market slot: ${l2Formatted['marketSlot']}
|
||||||
|
`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
const l2Formatted_depth100 = Object.assign({}, l2Formatted, {
|
const l2Formatted_depth100 = Object.assign({}, l2Formatted, {
|
||||||
bids: l2Formatted.bids.slice(0, 100),
|
bids: l2Formatted.bids.slice(0, 100),
|
||||||
asks: l2Formatted.asks.slice(0, 100),
|
asks: l2Formatted.asks.slice(0, 100),
|
||||||
|
|||||||
@@ -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 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
|
// 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,
|
||||||
|
killSwitchSlotDiffThreshold: 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