Skip to content

Commit

Permalink
bump sdk, new user stats map loading
Browse files Browse the repository at this point in the history
  • Loading branch information
wphan committed Nov 27, 2023
1 parent f04b990 commit 58526bd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions example/clientWithSlot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ const driftClientPublicKey = new PublicKey(sdkConfig.DRIFT_PROGRAM_ID);
let lastSeenSlot = 0;

/********** initializing driftClient as usual **********/
var accountSubscription: DriftClientSubscriptionConfig;
var logProviderConfig: LogProviderConfig;
let accountSubscription: DriftClientSubscriptionConfig;
let logProviderConfig: LogProviderConfig;
if (useWebsocket) {
accountSubscription = {
type: 'websocket',
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "lib/index.js",
"license": "Apache-2.0",
"dependencies": {
"@drift-labs/sdk": "2.48.0-beta.2",
"@drift-labs/sdk": "2.48.0-beta.4",
"@opentelemetry/api": "^1.1.0",
"@opentelemetry/auto-instrumentations-node": "^0.31.1",
"@opentelemetry/exporter-prometheus": "^0.31.0",
Expand Down Expand Up @@ -64,4 +64,4 @@
"lint:fix": "eslint . --ext ts --fix",
"playground": "ts-node src/playground.ts"
}
}
}
40 changes: 20 additions & 20 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import {
DLOBOrdersCoder,
DLOBSubscriber,
DriftClient,
DriftClientSubscriptionConfig,
DriftEnv,
SlotSource,
SlotSubscriber,
UserMap,
UserStatsMap,
Wallet,
Expand Down Expand Up @@ -214,7 +217,6 @@ const main = async () => {
programID: clearingHousePublicKey,
accountSubscription,
env: driftEnv,
userStats: true,
});

const dlobCoder = DLOBOrdersCoder.create();
Expand All @@ -229,24 +231,22 @@ const main = async () => {
lastSlotReceived = slotSource.getSlot();
}, ORDERBOOK_UPDATE_INTERVAL);

const userStatsMap = new UserStatsMap(driftClient);

logger.info(`Initializing userMap...`);
const initUserMapStart = Date.now();
const userMap = new UserMap(
driftClient,
driftClient.userAccountSubscriptionConfig,
false
false,
async (authorities) => {
await userStatsMap.sync(authorities);
},
{ hasOpenOrders: true }
);
await userMap.subscribe();
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...`);
const initDlobSubscriberStart = Date.now();
const dlobSubscriber = new DLOBSubscriber({
Expand Down Expand Up @@ -650,11 +650,11 @@ const main = async () => {
numVammOrders: parseInt((numVammOrders ?? '100') as string),
fallbackL2Generators: isSpot
? [
`${includePhoenix}`.toLowerCase() === 'true' &&
MARKET_SUBSCRIBERS[normedMarketIndex].phoenix,
`${includeSerum}`.toLowerCase() === 'true' &&
MARKET_SUBSCRIBERS[normedMarketIndex].serum,
].filter((a) => !!a)
`${includePhoenix}`.toLowerCase() === 'true' &&
MARKET_SUBSCRIBERS[normedMarketIndex].phoenix,
`${includeSerum}`.toLowerCase() === 'true' &&
MARKET_SUBSCRIBERS[normedMarketIndex].serum,
].filter((a) => !!a)
: [],
});

Expand Down Expand Up @@ -768,11 +768,11 @@ const main = async () => {
: `${normedParam['includeVamm']}`.toLowerCase() === 'true',
fallbackL2Generators: isSpot
? [
`${normedParam['includePhoenix']}`.toLowerCase() === 'true' &&
MARKET_SUBSCRIBERS[normedMarketIndex].phoenix,
`${normedParam['includeSerum']}`.toLowerCase() === 'true' &&
MARKET_SUBSCRIBERS[normedMarketIndex].serum,
].filter((a) => !!a)
`${normedParam['includePhoenix']}`.toLowerCase() === 'true' &&
MARKET_SUBSCRIBERS[normedMarketIndex].phoenix,
`${normedParam['includeSerum']}`.toLowerCase() === 'true' &&
MARKET_SUBSCRIBERS[normedMarketIndex].serum,
].filter((a) => !!a)
: [],
});

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@
enabled "2.0.x"
kuler "^2.0.0"

"@drift-labs/[email protected].2":
version "2.48.0-beta.2"
resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.48.0-beta.2.tgz#447cdd132e99e7283eecb96adbce6709724f4e3f"
integrity sha512-zp0OxvuwDDLoqN1GfknPuEDCwPVzLRvRVpnrJFzeTNgBS1ish0ZmqtM5URFMHuXJ9ZaEt3gezqhhlqRID917rQ==
"@drift-labs/[email protected].4":
version "2.48.0-beta.4"
resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.48.0-beta.4.tgz#80395976b04d59fa5340e5c9a7839c72b3ee3c2e"
integrity sha512-gsxKL1xOAtOlybDaI+kAvA070WfqnkaGCPyAs87gILYDAVrCyoGX37EE6e3v098X3qsR0VIAjaVlCqz4nZfPwg==
dependencies:
"@coral-xyz/anchor" "0.28.1-beta.2"
"@ellipsis-labs/phoenix-sdk" "^1.4.2"
Expand Down

0 comments on commit 58526bd

Please sign in to comment.