dlobsubscriberio can do devnet or mainnet

This commit is contained in:
Nour Alharithi
2023-10-27 15:03:41 -07:00
parent 87d79abb57
commit d907d9869f

View File

@@ -2,6 +2,8 @@ import {
BN, BN,
DLOBSubscriber, DLOBSubscriber,
DLOBSubscriptionConfig, DLOBSubscriptionConfig,
DevnetPerpMarkets,
DevnetSpotMarkets,
L2OrderBookGenerator, L2OrderBookGenerator,
MainnetPerpMarkets, MainnetPerpMarkets,
MainnetSpotMarkets, MainnetSpotMarkets,
@@ -10,6 +12,7 @@ import {
} from '@drift-labs/sdk'; } from '@drift-labs/sdk';
import { getOracleForMarket, l2WithBNToStrings } from '../utils/utils'; import { getOracleForMarket, l2WithBNToStrings } from '../utils/utils';
import { RedisClient } from '../utils/redisClient'; import { RedisClient } from '../utils/redisClient';
import { driftEnv } from '../wsPublish';
type wsMarketL2Args = { type wsMarketL2Args = {
marketIndex: number; marketIndex: number;
@@ -38,7 +41,12 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
this.lastSeenL2Formatted.set(MarketType.PERP, new Map()); this.lastSeenL2Formatted.set(MarketType.PERP, new Map());
// Add all active markets to the market L2Args // Add all active markets to the market L2Args
for (const market of MainnetPerpMarkets) { const perpMarkets =
driftEnv === 'devnet' ? DevnetPerpMarkets : MainnetPerpMarkets;
const spotMarkets =
driftEnv === 'devnet' ? DevnetSpotMarkets : MainnetSpotMarkets;
for (const market of perpMarkets) {
this.marketL2Args.push({ this.marketL2Args.push({
marketIndex: market.marketIndex, marketIndex: market.marketIndex,
marketType: MarketType.PERP, marketType: MarketType.PERP,
@@ -50,7 +58,7 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
fallbackL2Generators: [], fallbackL2Generators: [],
}); });
} }
for (const market of MainnetSpotMarkets) { for (const market of spotMarkets) {
this.marketL2Args.push({ this.marketL2Args.push({
marketIndex: market.marketIndex, marketIndex: market.marketIndex,
marketType: MarketType.SPOT, marketType: MarketType.SPOT,