From 5996143a5a672c2d8a573d2426b552050cc3f478 Mon Sep 17 00:00:00 2001 From: Nour Alharithi Date: Mon, 4 Dec 2023 11:18:23 -0800 Subject: [PATCH] change publisher spot market initializer --- src/publishers/dlobPublisher.ts | 36 +++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/publishers/dlobPublisher.ts b/src/publishers/dlobPublisher.ts index 2d2aca8..03fc706 100644 --- a/src/publishers/dlobPublisher.ts +++ b/src/publishers/dlobPublisher.ts @@ -13,6 +13,7 @@ import { SlotSource, DriftClientSubscriptionConfig, SlotSubscriber, + isVariant, } from '@drift-labs/sdk'; import { logger, setLogLevel } from '../utils/logger'; @@ -70,23 +71,32 @@ const initializeAllMarketSubscribers = async (driftClient: DriftClient) => { }; if (market.phoenixMarket) { - const phoenixSubscriber = getPhoenixSubscriber( - driftClient, - market, - sdkConfig - ); - await phoenixSubscriber.subscribe(); - markets[market.marketIndex].phoenix = phoenixSubscriber; + const phoenixConfigAccount = + await driftClient.getPhoenixV1FulfillmentConfig(market.phoenixMarket); + if (isVariant(phoenixConfigAccount.status, 'enabled')) { + const phoenixSubscriber = getPhoenixSubscriber( + driftClient, + market, + sdkConfig + ); + await phoenixSubscriber.subscribe(); + markets[market.marketIndex].phoenix = phoenixSubscriber; + } } if (market.serumMarket) { - const serumSubscriber = getSerumSubscriber( - driftClient, - market, - sdkConfig + const serumConfigAccount = await driftClient.getSerumV3FulfillmentConfig( + market.serumMarket ); - await serumSubscriber.subscribe(); - markets[market.marketIndex].serum = serumSubscriber; + if (isVariant(serumConfigAccount.status, 'enabled')) { + const serumSubscriber = getSerumSubscriber( + driftClient, + market, + sdkConfig + ); + await serumSubscriber.subscribe(); + markets[market.marketIndex].serum = serumSubscriber; + } } }