@@ -6,7 +6,7 @@
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@coral-xyz/anchor": "^0.29.0",
|
||||
"@drift-labs/sdk": "2.72.0-beta.1",
|
||||
"@drift-labs/sdk": "2.72.0-beta.2",
|
||||
"@opentelemetry/api": "^1.1.0",
|
||||
"@opentelemetry/auto-instrumentations-node": "^0.31.1",
|
||||
"@opentelemetry/exporter-prometheus": "^0.31.0",
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
BN,
|
||||
DLOBSubscriber,
|
||||
DLOBSubscriptionConfig,
|
||||
DriftEnv,
|
||||
L2OrderBookGenerator,
|
||||
MarketType,
|
||||
PositionDirection,
|
||||
@@ -31,6 +32,16 @@ type wsMarketArgs = {
|
||||
const PERP_MAKRET_STALENESS_THRESHOLD = 10 * 60 * 1000;
|
||||
const SPOT_MAKRET_STALENESS_THRESHOLD = 20 * 60 * 1000;
|
||||
|
||||
const PERP_MARKETS_TO_SKIP_SLOT_CHECK = {
|
||||
'mainnet-beta': [17, 21, 23, 25, 26],
|
||||
devnet: [17, 21],
|
||||
};
|
||||
|
||||
const SPOT_MARKETS_TO_SKIP_SLOT_CHECK = {
|
||||
'mainnet-beta': [6, 8, 10],
|
||||
devnet: [],
|
||||
};
|
||||
|
||||
export type wsMarketInfo = {
|
||||
marketIndex: number;
|
||||
marketName: string;
|
||||
@@ -46,10 +57,12 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
||||
Map<number, { slot: number; ts: number }>
|
||||
>;
|
||||
|
||||
public skipSlotStalenessCheckMarkets = new Set<number>();
|
||||
public skipSlotStalenessCheckMarketsPerp: number[];
|
||||
public skipSlotStalenessCheckMarketsSpot: number[];
|
||||
|
||||
constructor(
|
||||
config: DLOBSubscriptionConfig & {
|
||||
env: DriftEnv,
|
||||
redisClient: RedisClient;
|
||||
perpMarketInfos: wsMarketInfo[];
|
||||
spotMarketInfos: wsMarketInfo[];
|
||||
@@ -70,6 +83,11 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
||||
this.lastMarketSlotMap.set(MarketType.SPOT, new Map());
|
||||
this.lastMarketSlotMap.set(MarketType.PERP, new Map());
|
||||
|
||||
this.skipSlotStalenessCheckMarketsPerp =
|
||||
PERP_MARKETS_TO_SKIP_SLOT_CHECK[config.env];
|
||||
this.skipSlotStalenessCheckMarketsSpot =
|
||||
SPOT_MARKETS_TO_SKIP_SLOT_CHECK[config.env];
|
||||
|
||||
for (const market of config.perpMarketInfos) {
|
||||
const perpMarket = this.driftClient.getPerpMarketAccount(
|
||||
market.marketIndex
|
||||
@@ -77,7 +95,7 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
||||
const includeVamm = !isVariant(perpMarket.status, 'ammPaused');
|
||||
const oracleSource = perpMarket.amm.oracleSource;
|
||||
if (isVariant(oracleSource, 'prelaunch')) {
|
||||
this.skipSlotStalenessCheckMarkets.add(market.marketIndex);
|
||||
this.skipSlotStalenessCheckMarketsPerp.push(market.marketIndex);
|
||||
}
|
||||
|
||||
this.marketArgs.push({
|
||||
@@ -182,8 +200,14 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
||||
|
||||
// Check if slot diffs are too large for oracle
|
||||
const skipSlotCheck =
|
||||
marketType === 'perp' &&
|
||||
this.skipSlotStalenessCheckMarkets.has(marketArgs.marketIndex);
|
||||
(marketType === 'perp' &&
|
||||
this.skipSlotStalenessCheckMarketsPerp.includes(
|
||||
marketArgs.marketIndex
|
||||
)) ||
|
||||
(marketType === 'spot' &&
|
||||
this.skipSlotStalenessCheckMarketsSpot.includes(
|
||||
marketArgs.marketIndex
|
||||
));
|
||||
if (
|
||||
Math.abs(slot - parseInt(l2Formatted['oracleData']['slot'])) >
|
||||
this.killSwitchSlotDiffThreshold &&
|
||||
|
||||
@@ -391,6 +391,7 @@ const main = async () => {
|
||||
|
||||
const dlobSubscriber = new DLOBSubscriberIO({
|
||||
driftClient,
|
||||
env: driftEnv,
|
||||
dlobSource: dlobProvider,
|
||||
slotSource,
|
||||
updateFrequency: ORDERBOOK_UPDATE_INTERVAL,
|
||||
|
||||
@@ -81,7 +81,6 @@ const main = async () => {
|
||||
|
||||
await driftClient.subscribe();
|
||||
driftClient.eventEmitter.on('error', (e) => {
|
||||
logger.info('clearing house error');
|
||||
logger.error(e);
|
||||
});
|
||||
|
||||
|
||||
@@ -115,10 +115,10 @@
|
||||
enabled "2.0.x"
|
||||
kuler "^2.0.0"
|
||||
|
||||
"@drift-labs/sdk@2.72.0-beta.1":
|
||||
version "2.72.0-beta.1"
|
||||
resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.72.0-beta.1.tgz#bee1269f877970f10e53f651d19aced79e75a0bc"
|
||||
integrity sha512-Fgz2WFoTxFetBNBEdzPSKi6IbGnUD6zo5EqUZqW3rICJcpjvjJazKNe9NnYy6q753wnMiYcCwhn29IxcIhAl0g==
|
||||
"@drift-labs/sdk@2.72.0-beta.2":
|
||||
version "2.72.0-beta.2"
|
||||
resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.72.0-beta.2.tgz#c9ec472265636040eca5a4e77d6aed45d91c9d22"
|
||||
integrity sha512-461+Z4rwUL7IAOIUYdwl93OX8HCAyZZnu9dR9haEbEuSAtTk/LUVqQz+c+TThX6i2fLHx7HY7/tWQ9qSIjFNVA==
|
||||
dependencies:
|
||||
"@coral-xyz/anchor" "0.28.1-beta.2"
|
||||
"@ellipsis-labs/phoenix-sdk" "^1.4.2"
|
||||
|
||||
Reference in New Issue
Block a user