pass list of markets into DLOBSubscriberIO
This commit is contained in:
@@ -2,16 +2,11 @@ import {
|
||||
BN,
|
||||
DLOBSubscriber,
|
||||
DLOBSubscriptionConfig,
|
||||
DevnetPerpMarkets,
|
||||
DevnetSpotMarkets,
|
||||
L2OrderBookGenerator,
|
||||
MainnetPerpMarkets,
|
||||
MainnetSpotMarkets,
|
||||
MarketType,
|
||||
groupL2,
|
||||
isVariant,
|
||||
} from '@drift-labs/sdk';
|
||||
import { driftEnv } from '../publishers/dlobPublisher';
|
||||
import { RedisClient } from '../utils/redisClient';
|
||||
import {
|
||||
SubscriberLookup,
|
||||
@@ -33,6 +28,11 @@ type wsMarketL2Args = {
|
||||
updateOnChange?: boolean;
|
||||
};
|
||||
|
||||
export type wsMarketInfo = {
|
||||
marketIndex: number;
|
||||
marketName: string;
|
||||
};
|
||||
|
||||
export class DLOBSubscriberIO extends DLOBSubscriber {
|
||||
public marketL2Args: wsMarketL2Args[] = [];
|
||||
public lastSeenL2Formatted: Map<MarketType, Map<number, any>>;
|
||||
@@ -41,6 +41,8 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
||||
constructor(
|
||||
config: DLOBSubscriptionConfig & {
|
||||
redisClient: RedisClient;
|
||||
perpMarketsInfos: wsMarketInfo[];
|
||||
spotMarketsInfos: wsMarketInfo[];
|
||||
spotMarketSubscribers: SubscriberLookup;
|
||||
}
|
||||
) {
|
||||
@@ -52,17 +54,11 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
||||
this.lastSeenL2Formatted.set(MarketType.SPOT, new Map());
|
||||
this.lastSeenL2Formatted.set(MarketType.PERP, new Map());
|
||||
|
||||
// Add all active markets to the market L2Args
|
||||
const perpMarkets =
|
||||
driftEnv === 'devnet' ? DevnetPerpMarkets : MainnetPerpMarkets;
|
||||
const spotMarkets =
|
||||
driftEnv === 'devnet' ? DevnetSpotMarkets : MainnetSpotMarkets;
|
||||
|
||||
for (const market of perpMarkets) {
|
||||
for (const market of config.perpMarketsInfos) {
|
||||
this.marketL2Args.push({
|
||||
marketIndex: market.marketIndex,
|
||||
marketType: MarketType.PERP,
|
||||
marketName: market.symbol,
|
||||
marketName: market.marketName,
|
||||
depth: -1,
|
||||
numVammOrders: 100,
|
||||
includeVamm: true,
|
||||
@@ -70,11 +66,11 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
||||
fallbackL2Generators: [],
|
||||
});
|
||||
}
|
||||
for (const market of spotMarkets) {
|
||||
for (const market of config.spotMarketsInfos) {
|
||||
this.marketL2Args.push({
|
||||
marketIndex: market.marketIndex,
|
||||
marketType: MarketType.SPOT,
|
||||
marketName: market.symbol,
|
||||
marketName: market.marketName,
|
||||
depth: -1,
|
||||
includeVamm: false,
|
||||
updateOnChange: true,
|
||||
|
||||
Reference in New Issue
Block a user