Merge branch 'master' into jack/redis-migration

This commit is contained in:
Jack Waller
2024-05-23 14:24:14 +10:00
7 changed files with 64 additions and 11 deletions

View File

@@ -18,6 +18,8 @@ import {
isVariant,
OrderSubscriber,
MarketType,
PhoenixSubscriber,
BulkAccountLoader,
} from '@drift-labs/sdk';
import { RedisClient, RedisClientPrefix } from '@drift/common';
@@ -37,7 +39,6 @@ import {
SubscriberLookup,
addOracletoResponse,
errorHandler,
getPhoenixSubscriber,
getSerumSubscriber,
l2WithBNToStrings,
normalizeBatchQueryParams,
@@ -47,6 +48,13 @@ import {
} from './utils/utils';
import FEATURE_FLAGS from './utils/featureFlags';
import { getDLOBProviderFromOrderSubscriber } from './dlobProvider';
import { setGlobalDispatcher, Agent } from 'undici';
setGlobalDispatcher(
new Agent({
connections: 200,
})
);
require('dotenv').config();
@@ -143,11 +151,20 @@ const initializeAllMarketSubscribers = async (driftClient: DriftClient) => {
const phoenixConfigAccount =
await driftClient.getPhoenixV1FulfillmentConfig(market.phoenixMarket);
if (isVariant(phoenixConfigAccount.status, 'enabled')) {
const phoenixSubscriber = getPhoenixSubscriber(
driftClient,
market,
sdkConfig
const bulkAccountLoader = new BulkAccountLoader(
driftClient.connection,
stateCommitment,
5_000
);
const phoenixSubscriber = new PhoenixSubscriber({
connection: driftClient.connection,
programId: new PublicKey(sdkConfig.PHOENIX),
marketAddress: phoenixConfigAccount.phoenixMarket,
accountSubscription: {
type: 'polling',
accountLoader: bulkAccountLoader,
},
});
await phoenixSubscriber.subscribe();
// Test get L2 to know if we should add
try {