bump sdk, new user stats map loading

This commit is contained in:
wphan
2023-11-27 14:50:32 -08:00
parent f04b9908a1
commit 58526bd9d1
4 changed files with 28 additions and 28 deletions

View File

@@ -55,8 +55,8 @@ const driftClientPublicKey = new PublicKey(sdkConfig.DRIFT_PROGRAM_ID);
let lastSeenSlot = 0; let lastSeenSlot = 0;
/********** initializing driftClient as usual **********/ /********** initializing driftClient as usual **********/
var accountSubscription: DriftClientSubscriptionConfig; let accountSubscription: DriftClientSubscriptionConfig;
var logProviderConfig: LogProviderConfig; let logProviderConfig: LogProviderConfig;
if (useWebsocket) { if (useWebsocket) {
accountSubscription = { accountSubscription = {
type: 'websocket', type: 'websocket',

View File

@@ -5,7 +5,7 @@
"main": "lib/index.js", "main": "lib/index.js",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@drift-labs/sdk": "2.48.0-beta.2", "@drift-labs/sdk": "2.48.0-beta.4",
"@opentelemetry/api": "^1.1.0", "@opentelemetry/api": "^1.1.0",
"@opentelemetry/auto-instrumentations-node": "^0.31.1", "@opentelemetry/auto-instrumentations-node": "^0.31.1",
"@opentelemetry/exporter-prometheus": "^0.31.0", "@opentelemetry/exporter-prometheus": "^0.31.0",
@@ -64,4 +64,4 @@
"lint:fix": "eslint . --ext ts --fix", "lint:fix": "eslint . --ext ts --fix",
"playground": "ts-node src/playground.ts" "playground": "ts-node src/playground.ts"
} }
} }

View File

@@ -16,7 +16,10 @@ import {
DLOBOrdersCoder, DLOBOrdersCoder,
DLOBSubscriber, DLOBSubscriber,
DriftClient, DriftClient,
DriftClientSubscriptionConfig,
DriftEnv, DriftEnv,
SlotSource,
SlotSubscriber,
UserMap, UserMap,
UserStatsMap, UserStatsMap,
Wallet, Wallet,
@@ -214,7 +217,6 @@ const main = async () => {
programID: clearingHousePublicKey, programID: clearingHousePublicKey,
accountSubscription, accountSubscription,
env: driftEnv, env: driftEnv,
userStats: true,
}); });
const dlobCoder = DLOBOrdersCoder.create(); const dlobCoder = DLOBOrdersCoder.create();
@@ -229,24 +231,22 @@ const main = async () => {
lastSlotReceived = slotSource.getSlot(); lastSlotReceived = slotSource.getSlot();
}, ORDERBOOK_UPDATE_INTERVAL); }, ORDERBOOK_UPDATE_INTERVAL);
const userStatsMap = new UserStatsMap(driftClient);
logger.info(`Initializing userMap...`); logger.info(`Initializing userMap...`);
const initUserMapStart = Date.now(); const initUserMapStart = Date.now();
const userMap = new UserMap( const userMap = new UserMap(
driftClient, driftClient,
driftClient.userAccountSubscriptionConfig, driftClient.userAccountSubscriptionConfig,
false false,
async (authorities) => {
await userStatsMap.sync(authorities);
},
{ hasOpenOrders: true }
); );
await userMap.subscribe(); await userMap.subscribe();
logger.info(`userMap initialized in ${Date.now() - initUserMapStart} ms`); logger.info(`userMap initialized in ${Date.now() - initUserMapStart} ms`);
logger.info(`Initializing userStatsMap...`);
const initUserStatsMapStart = Date.now();
const userStatsMap = new UserStatsMap(driftClient, accountSubscription);
await userStatsMap.subscribe();
logger.info(
`userStatsMap initialized in ${Date.now() - initUserStatsMapStart} ms`
);
logger.info(`Initializing DLOBSubscriber...`); logger.info(`Initializing DLOBSubscriber...`);
const initDlobSubscriberStart = Date.now(); const initDlobSubscriberStart = Date.now();
const dlobSubscriber = new DLOBSubscriber({ const dlobSubscriber = new DLOBSubscriber({
@@ -650,11 +650,11 @@ const main = async () => {
numVammOrders: parseInt((numVammOrders ?? '100') as string), numVammOrders: parseInt((numVammOrders ?? '100') as string),
fallbackL2Generators: isSpot fallbackL2Generators: isSpot
? [ ? [
`${includePhoenix}`.toLowerCase() === 'true' && `${includePhoenix}`.toLowerCase() === 'true' &&
MARKET_SUBSCRIBERS[normedMarketIndex].phoenix, MARKET_SUBSCRIBERS[normedMarketIndex].phoenix,
`${includeSerum}`.toLowerCase() === 'true' && `${includeSerum}`.toLowerCase() === 'true' &&
MARKET_SUBSCRIBERS[normedMarketIndex].serum, MARKET_SUBSCRIBERS[normedMarketIndex].serum,
].filter((a) => !!a) ].filter((a) => !!a)
: [], : [],
}); });
@@ -768,11 +768,11 @@ const main = async () => {
: `${normedParam['includeVamm']}`.toLowerCase() === 'true', : `${normedParam['includeVamm']}`.toLowerCase() === 'true',
fallbackL2Generators: isSpot fallbackL2Generators: isSpot
? [ ? [
`${normedParam['includePhoenix']}`.toLowerCase() === 'true' && `${normedParam['includePhoenix']}`.toLowerCase() === 'true' &&
MARKET_SUBSCRIBERS[normedMarketIndex].phoenix, MARKET_SUBSCRIBERS[normedMarketIndex].phoenix,
`${normedParam['includeSerum']}`.toLowerCase() === 'true' && `${normedParam['includeSerum']}`.toLowerCase() === 'true' &&
MARKET_SUBSCRIBERS[normedMarketIndex].serum, MARKET_SUBSCRIBERS[normedMarketIndex].serum,
].filter((a) => !!a) ].filter((a) => !!a)
: [], : [],
}); });

View File

@@ -80,10 +80,10 @@
enabled "2.0.x" enabled "2.0.x"
kuler "^2.0.0" kuler "^2.0.0"
"@drift-labs/sdk@2.48.0-beta.2": "@drift-labs/sdk@2.48.0-beta.4":
version "2.48.0-beta.2" version "2.48.0-beta.4"
resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.48.0-beta.2.tgz#447cdd132e99e7283eecb96adbce6709724f4e3f" resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.48.0-beta.4.tgz#80395976b04d59fa5340e5c9a7839c72b3ee3c2e"
integrity sha512-zp0OxvuwDDLoqN1GfknPuEDCwPVzLRvRVpnrJFzeTNgBS1ish0ZmqtM5URFMHuXJ9ZaEt3gezqhhlqRID917rQ== integrity sha512-gsxKL1xOAtOlybDaI+kAvA070WfqnkaGCPyAs87gILYDAVrCyoGX37EE6e3v098X3qsR0VIAjaVlCqz4nZfPwg==
dependencies: dependencies:
"@coral-xyz/anchor" "0.28.1-beta.2" "@coral-xyz/anchor" "0.28.1-beta.2"
"@ellipsis-labs/phoenix-sdk" "^1.4.2" "@ellipsis-labs/phoenix-sdk" "^1.4.2"