change publisher spot market initializer

This commit is contained in:
Nour Alharithi
2023-12-04 11:18:23 -08:00
parent 1e93a55a25
commit 5996143a5a

View File

@@ -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;
}
}
}