openbook integration (#208)
This commit is contained in:
@@ -22,7 +22,12 @@ import {
|
||||
import { RedisClient, RedisClientPrefix } from '@drift/common';
|
||||
|
||||
import { logger, setLogLevel } from '../utils/logger';
|
||||
import { SubscriberLookup, parsePositiveIntArray, sleep } from '../utils/utils';
|
||||
import {
|
||||
SubscriberLookup,
|
||||
getOpenbookSubscriber,
|
||||
parsePositiveIntArray,
|
||||
sleep,
|
||||
} from '../utils/utils';
|
||||
import {
|
||||
DLOBSubscriberIO,
|
||||
wsMarketInfo,
|
||||
@@ -233,6 +238,34 @@ const initializeAllMarketSubscribers = async (driftClient: DriftClient) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (marketConfig.openbookMarket) {
|
||||
const openbookMarketAccount =
|
||||
await driftClient.getOpenbookV2FulfillmentConfig(
|
||||
marketConfig.openbookMarket
|
||||
);
|
||||
|
||||
if (isVariant(openbookMarketAccount.status, 'enabled')) {
|
||||
logger.info(
|
||||
`Loading openbook subscriber for spot market ${market.marketIndex}`
|
||||
);
|
||||
const openbookSubscriber = getOpenbookSubscriber(
|
||||
driftClient,
|
||||
marketConfig,
|
||||
sdkConfig
|
||||
);
|
||||
await openbookSubscriber.subscribe();
|
||||
try {
|
||||
openbookSubscriber.getL2Asks();
|
||||
openbookSubscriber.getL2Bids();
|
||||
markets[market.marketIndex].openbook = openbookSubscriber;
|
||||
} catch (e) {
|
||||
logger.info(
|
||||
`Excluding openbook for ${market.marketIndex}, error: ${e}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return markets;
|
||||
|
||||
@@ -212,6 +212,10 @@ const main = async () => {
|
||||
pubkeysForMarket.push(market.phoenixMarket.toString());
|
||||
}
|
||||
|
||||
if (market.openbookMarket) {
|
||||
pubkeysForMarket.push(market.openbookMarket.toString());
|
||||
}
|
||||
|
||||
spotMarketPubkeys.push({
|
||||
marketIndex: market.marketIndex,
|
||||
pubkeys: pubkeysForMarket,
|
||||
|
||||
Reference in New Issue
Block a user