Merge branch 'master' into jack/redis-migration
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
"rxjs": "^7.8.1",
|
"rxjs": "^7.8.1",
|
||||||
"socket.io-redis": "^6.1.1",
|
"socket.io-redis": "^6.1.1",
|
||||||
"typescript": "4.5.4",
|
"typescript": "4.5.4",
|
||||||
|
"undici": "^6.16.1",
|
||||||
"winston": "^3.8.1",
|
"winston": "^3.8.1",
|
||||||
"ws": "^8.14.2"
|
"ws": "^8.14.2"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ const PERP_MARKETS_TO_SKIP_SLOT_CHECK = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const SPOT_MARKETS_TO_SKIP_SLOT_CHECK = {
|
const SPOT_MARKETS_TO_SKIP_SLOT_CHECK = {
|
||||||
'mainnet-beta': [6, 8, 10],
|
'mainnet-beta': [6, 8, 10, 15],
|
||||||
devnet: [],
|
devnet: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
27
src/index.ts
27
src/index.ts
@@ -18,6 +18,8 @@ import {
|
|||||||
isVariant,
|
isVariant,
|
||||||
OrderSubscriber,
|
OrderSubscriber,
|
||||||
MarketType,
|
MarketType,
|
||||||
|
PhoenixSubscriber,
|
||||||
|
BulkAccountLoader,
|
||||||
} from '@drift-labs/sdk';
|
} from '@drift-labs/sdk';
|
||||||
import { RedisClient, RedisClientPrefix } from '@drift/common';
|
import { RedisClient, RedisClientPrefix } from '@drift/common';
|
||||||
|
|
||||||
@@ -37,7 +39,6 @@ import {
|
|||||||
SubscriberLookup,
|
SubscriberLookup,
|
||||||
addOracletoResponse,
|
addOracletoResponse,
|
||||||
errorHandler,
|
errorHandler,
|
||||||
getPhoenixSubscriber,
|
|
||||||
getSerumSubscriber,
|
getSerumSubscriber,
|
||||||
l2WithBNToStrings,
|
l2WithBNToStrings,
|
||||||
normalizeBatchQueryParams,
|
normalizeBatchQueryParams,
|
||||||
@@ -47,6 +48,13 @@ import {
|
|||||||
} from './utils/utils';
|
} from './utils/utils';
|
||||||
import FEATURE_FLAGS from './utils/featureFlags';
|
import FEATURE_FLAGS from './utils/featureFlags';
|
||||||
import { getDLOBProviderFromOrderSubscriber } from './dlobProvider';
|
import { getDLOBProviderFromOrderSubscriber } from './dlobProvider';
|
||||||
|
import { setGlobalDispatcher, Agent } from 'undici';
|
||||||
|
|
||||||
|
setGlobalDispatcher(
|
||||||
|
new Agent({
|
||||||
|
connections: 200,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
|
|
||||||
@@ -143,11 +151,20 @@ const initializeAllMarketSubscribers = async (driftClient: DriftClient) => {
|
|||||||
const phoenixConfigAccount =
|
const phoenixConfigAccount =
|
||||||
await driftClient.getPhoenixV1FulfillmentConfig(market.phoenixMarket);
|
await driftClient.getPhoenixV1FulfillmentConfig(market.phoenixMarket);
|
||||||
if (isVariant(phoenixConfigAccount.status, 'enabled')) {
|
if (isVariant(phoenixConfigAccount.status, 'enabled')) {
|
||||||
const phoenixSubscriber = getPhoenixSubscriber(
|
const bulkAccountLoader = new BulkAccountLoader(
|
||||||
driftClient,
|
driftClient.connection,
|
||||||
market,
|
stateCommitment,
|
||||||
sdkConfig
|
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();
|
await phoenixSubscriber.subscribe();
|
||||||
// Test get L2 to know if we should add
|
// Test get L2 to know if we should add
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ import {
|
|||||||
OracleInfo,
|
OracleInfo,
|
||||||
PerpMarketConfig,
|
PerpMarketConfig,
|
||||||
SpotMarketConfig,
|
SpotMarketConfig,
|
||||||
|
PhoenixSubscriber,
|
||||||
} from '@drift-labs/sdk';
|
} from '@drift-labs/sdk';
|
||||||
import { RedisClient, RedisClientPrefix } from '@drift/common';
|
import { RedisClient, RedisClientPrefix } from '@drift/common';
|
||||||
|
|
||||||
import { logger, setLogLevel } from '../utils/logger';
|
import { logger, setLogLevel } from '../utils/logger';
|
||||||
import {
|
import {
|
||||||
SubscriberLookup,
|
SubscriberLookup,
|
||||||
getPhoenixSubscriber,
|
|
||||||
getSerumSubscriber,
|
getSerumSubscriber,
|
||||||
parsePositiveIntArray,
|
parsePositiveIntArray,
|
||||||
sleep,
|
sleep,
|
||||||
@@ -42,6 +42,13 @@ import FEATURE_FLAGS from '../utils/featureFlags';
|
|||||||
import { GeyserOrderSubscriber } from '../grpc/OrderSubscriberGRPC';
|
import { GeyserOrderSubscriber } from '../grpc/OrderSubscriberGRPC';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { handleHealthCheck } from '../core/metrics';
|
import { handleHealthCheck } from '../core/metrics';
|
||||||
|
import { setGlobalDispatcher, Agent } from 'undici';
|
||||||
|
|
||||||
|
setGlobalDispatcher(
|
||||||
|
new Agent({
|
||||||
|
connections: 200,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
const stateCommitment: Commitment = 'confirmed';
|
const stateCommitment: Commitment = 'confirmed';
|
||||||
@@ -205,11 +212,20 @@ const initializeAllMarketSubscribers = async (driftClient: DriftClient) => {
|
|||||||
logger.info(
|
logger.info(
|
||||||
`Loading phoenix subscriber for spot market ${market.marketIndex}`
|
`Loading phoenix subscriber for spot market ${market.marketIndex}`
|
||||||
);
|
);
|
||||||
const phoenixSubscriber = getPhoenixSubscriber(
|
const bulkAccountLoader = new BulkAccountLoader(
|
||||||
driftClient,
|
driftClient.connection,
|
||||||
marketConfig,
|
stateCommitment,
|
||||||
sdkConfig
|
2_000
|
||||||
);
|
);
|
||||||
|
const phoenixSubscriber = new PhoenixSubscriber({
|
||||||
|
connection: driftClient.connection,
|
||||||
|
programId: new PublicKey(sdkConfig.PHOENIX),
|
||||||
|
marketAddress: phoenixConfigAccount.phoenixMarket,
|
||||||
|
accountSubscription: {
|
||||||
|
type: 'polling',
|
||||||
|
accountLoader: bulkAccountLoader,
|
||||||
|
},
|
||||||
|
});
|
||||||
await phoenixSubscriber.subscribe();
|
await phoenixSubscriber.subscribe();
|
||||||
// Test get L2 to know if we should add
|
// Test get L2 to know if we should add
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -16,6 +16,13 @@ import { logger, setLogLevel } from '../utils/logger';
|
|||||||
import { sleep } from '../utils/utils';
|
import { sleep } from '../utils/utils';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
// import { handleHealthCheck } from '../core/metrics';
|
// import { handleHealthCheck } from '../core/metrics';
|
||||||
|
import { setGlobalDispatcher, Agent } from 'undici';
|
||||||
|
|
||||||
|
setGlobalDispatcher(
|
||||||
|
new Agent({
|
||||||
|
connections: 200,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
const stateCommitment: Commitment = 'confirmed';
|
const stateCommitment: Commitment = 'confirmed';
|
||||||
|
|||||||
@@ -25,6 +25,13 @@ import { RedisClient, RedisClientPrefix } from '@drift/common';
|
|||||||
import { logger, setLogLevel } from '../utils/logger';
|
import { logger, setLogLevel } from '../utils/logger';
|
||||||
import { sleep } from '../utils/utils';
|
import { sleep } from '../utils/utils';
|
||||||
import { fromEvent, filter, map } from 'rxjs';
|
import { fromEvent, filter, map } from 'rxjs';
|
||||||
|
import { setGlobalDispatcher, Agent } from 'undici';
|
||||||
|
|
||||||
|
setGlobalDispatcher(
|
||||||
|
new Agent({
|
||||||
|
connections: 200,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
const driftEnv = (process.env.ENV || 'devnet') as DriftEnv;
|
const driftEnv = (process.env.ENV || 'devnet') as DriftEnv;
|
||||||
|
|||||||
@@ -5769,6 +5769,11 @@ undici-types@~5.26.4:
|
|||||||
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
|
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
|
||||||
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==
|
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==
|
||||||
|
|
||||||
|
undici@^6.16.1:
|
||||||
|
version "6.16.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/undici/-/undici-6.16.1.tgz#ff8f49c56e5a8629f92ad2ce00d4841b9619b19e"
|
||||||
|
integrity sha512-NeNiTT7ixpeiL1qOIU/xTVpHpVP0svmI6PwoCKaMGaI5AsHOaRdwqU/f7Fi9eyU4u03nd5U/BC8wmRMnS9nqoA==
|
||||||
|
|
||||||
unpipe@1.0.0, unpipe@~1.0.0:
|
unpipe@1.0.0, unpipe@~1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
|
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
|
||||||
|
|||||||
Reference in New Issue
Block a user