tested
This commit is contained in:
@@ -41,8 +41,8 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
constructor(
|
constructor(
|
||||||
config: DLOBSubscriptionConfig & {
|
config: DLOBSubscriptionConfig & {
|
||||||
redisClient: RedisClient;
|
redisClient: RedisClient;
|
||||||
perpMarketsInfos: wsMarketInfo[];
|
perpMarketInfos: wsMarketInfo[];
|
||||||
spotMarketsInfos: wsMarketInfo[];
|
spotMarketInfos: wsMarketInfo[];
|
||||||
spotMarketSubscribers: SubscriberLookup;
|
spotMarketSubscribers: SubscriberLookup;
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
@@ -54,7 +54,7 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
this.lastSeenL2Formatted.set(MarketType.SPOT, new Map());
|
this.lastSeenL2Formatted.set(MarketType.SPOT, new Map());
|
||||||
this.lastSeenL2Formatted.set(MarketType.PERP, new Map());
|
this.lastSeenL2Formatted.set(MarketType.PERP, new Map());
|
||||||
|
|
||||||
for (const market of config.perpMarketsInfos) {
|
for (const market of config.perpMarketInfos) {
|
||||||
this.marketL2Args.push({
|
this.marketL2Args.push({
|
||||||
marketIndex: market.marketIndex,
|
marketIndex: market.marketIndex,
|
||||||
marketType: MarketType.PERP,
|
marketType: MarketType.PERP,
|
||||||
@@ -66,7 +66,7 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
fallbackL2Generators: [],
|
fallbackL2Generators: [],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
for (const market of config.spotMarketsInfos) {
|
for (const market of config.spotMarketInfos) {
|
||||||
this.marketL2Args.push({
|
this.marketL2Args.push({
|
||||||
marketIndex: market.marketIndex,
|
marketIndex: market.marketIndex,
|
||||||
marketType: MarketType.SPOT,
|
marketType: MarketType.SPOT,
|
||||||
@@ -88,7 +88,7 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
try {
|
try {
|
||||||
this.getL2AndSendMsg(l2Args);
|
this.getL2AndSendMsg(l2Args);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
console.error(error);
|
||||||
console.log(`Error getting L2 ${l2Args.marketName}`);
|
console.log(`Error getting L2 ${l2Args.marketName}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
isVariant,
|
isVariant,
|
||||||
OracleInfo,
|
OracleInfo,
|
||||||
PerpMarketConfig,
|
PerpMarketConfig,
|
||||||
|
SpotMarketConfig,
|
||||||
} from '@drift-labs/sdk';
|
} from '@drift-labs/sdk';
|
||||||
|
|
||||||
import { logger, setLogLevel } from '../utils/logger';
|
import { logger, setLogLevel } from '../utils/logger';
|
||||||
@@ -98,8 +99,11 @@ const getMarketsAndOraclesToLoad = (
|
|||||||
const perpMarketInfos: wsMarketInfo[] = [];
|
const perpMarketInfos: wsMarketInfo[] = [];
|
||||||
const spotMarketInfos: wsMarketInfo[] = [];
|
const spotMarketInfos: wsMarketInfo[] = [];
|
||||||
|
|
||||||
if (PERP_MARKETS_TO_LOAD!.length > 0) {
|
const perpIndexes = PERP_MARKETS_TO_LOAD
|
||||||
for (const idx of PERP_MARKETS_TO_LOAD) {
|
? PERP_MARKETS_TO_LOAD
|
||||||
|
: sdkConfig.PERP_MARKETS.map((m) => m.marketIndex);
|
||||||
|
if (perpIndexes.length > 0) {
|
||||||
|
for (const idx of perpIndexes) {
|
||||||
const perpMarketConfig = sdkConfig.PERP_MARKETS[idx] as PerpMarketConfig;
|
const perpMarketConfig = sdkConfig.PERP_MARKETS[idx] as PerpMarketConfig;
|
||||||
if (!perpMarketConfig) {
|
if (!perpMarketConfig) {
|
||||||
throw new Error(`Perp market config for ${idx} not found`);
|
throw new Error(`Perp market config for ${idx} not found`);
|
||||||
@@ -123,9 +127,12 @@ const getMarketsAndOraclesToLoad = (
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SPOT_MARKETS_TO_LOAD!.length > 0) {
|
const spotIndexes = SPOT_MARKETS_TO_LOAD
|
||||||
for (const idx of SPOT_MARKETS_TO_LOAD) {
|
? SPOT_MARKETS_TO_LOAD
|
||||||
const spotMarketConfig = sdkConfig.PERP_MARKETS[idx] as PerpMarketConfig;
|
: sdkConfig.SPOT_MARKETS.map((m) => m.marketIndex);
|
||||||
|
if (spotIndexes.length > 0) {
|
||||||
|
for (const idx of spotIndexes) {
|
||||||
|
const spotMarketConfig = sdkConfig.SPOT_MARKETS[idx] as SpotMarketConfig;
|
||||||
if (!spotMarketConfig) {
|
if (!spotMarketConfig) {
|
||||||
throw new Error(`Spot market config for ${idx} not found`);
|
throw new Error(`Spot market config for ${idx} not found`);
|
||||||
}
|
}
|
||||||
@@ -369,8 +376,8 @@ const main = async () => {
|
|||||||
updateFrequency: ORDERBOOK_UPDATE_INTERVAL,
|
updateFrequency: ORDERBOOK_UPDATE_INTERVAL,
|
||||||
redisClient,
|
redisClient,
|
||||||
spotMarketSubscribers: MARKET_SUBSCRIBERS,
|
spotMarketSubscribers: MARKET_SUBSCRIBERS,
|
||||||
perpMarketsInfos,
|
perpMarketInfos,
|
||||||
spotMarketsInfos,
|
spotMarketInfos,
|
||||||
});
|
});
|
||||||
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