From bd520a4c6228fa534e6f22185566e6770560987c Mon Sep 17 00:00:00 2001 From: Nour Alharithi Date: Sat, 11 Nov 2023 09:28:19 -0800 Subject: [PATCH 1/3] patch --- src/index.ts | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/index.ts b/src/index.ts index b817de1..03f6c1c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -165,17 +165,22 @@ const main = async () => { commitment: stateCommitment, }); - driftClient = new DriftClient({ - connection, - wallet, - programID: clearingHousePublicKey, - accountSubscription: { - type: 'websocket', - resubTimeoutMs: 60000, - }, - env: driftEnv, - userStats: true, - }); + const bulkAccountLoader = new BulkAccountLoader( + connection, + stateCommitment, + ORDERBOOK_UPDATE_INTERVAL * 10 + ), + driftClient = new DriftClient({ + connection, + wallet, + programID: clearingHousePublicKey, + accountSubscription: { + type: 'polling', + accountLoader: bulkAccountLoader, + }, + env: driftEnv, + userStats: true, + }); const dlobCoder = DLOBOrdersCoder.create(); const slotSubscriber = new SlotSubscriber(connection, {}); @@ -208,11 +213,7 @@ const main = async () => { await userMap.subscribe(); const userStatsMap = new UserStatsMap(driftClient, { type: 'polling', - accountLoader: new BulkAccountLoader( - connection, - stateCommitment, - ORDERBOOK_UPDATE_INTERVAL * 10 - ), + accountLoader: bulkAccountLoader, }); await userStatsMap.subscribe(); From d18952572a203b9d97b6e3d41660bac7047b84b9 Mon Sep 17 00:00:00 2001 From: Nour Alharithi Date: Sat, 11 Nov 2023 09:34:21 -0800 Subject: [PATCH 2/3] update every second --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 03f6c1c..678ea36 100644 --- a/src/index.ts +++ b/src/index.ts @@ -168,7 +168,7 @@ const main = async () => { const bulkAccountLoader = new BulkAccountLoader( connection, stateCommitment, - ORDERBOOK_UPDATE_INTERVAL * 10 + ORDERBOOK_UPDATE_INTERVAL ), driftClient = new DriftClient({ connection, From 76d9791ae8b056cf1ee587c831ffca3fd02994f0 Mon Sep 17 00:00:00 2001 From: Nour Alharithi Date: Sat, 11 Nov 2023 09:37:33 -0800 Subject: [PATCH 3/3] fix drift client --- src/index.ts | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/index.ts b/src/index.ts index 678ea36..6b16267 100644 --- a/src/index.ts +++ b/src/index.ts @@ -166,21 +166,22 @@ const main = async () => { }); const bulkAccountLoader = new BulkAccountLoader( - connection, - stateCommitment, - ORDERBOOK_UPDATE_INTERVAL - ), - driftClient = new DriftClient({ - connection, - wallet, - programID: clearingHousePublicKey, - accountSubscription: { - type: 'polling', - accountLoader: bulkAccountLoader, - }, - env: driftEnv, - userStats: true, - }); + connection, + stateCommitment, + ORDERBOOK_UPDATE_INTERVAL + ); + + driftClient = new DriftClient({ + connection, + wallet, + programID: clearingHousePublicKey, + accountSubscription: { + type: 'polling', + accountLoader: bulkAccountLoader, + }, + env: driftEnv, + userStats: true, + }); const dlobCoder = DLOBOrdersCoder.create(); const slotSubscriber = new SlotSubscriber(connection, {}); @@ -213,7 +214,11 @@ const main = async () => { await userMap.subscribe(); const userStatsMap = new UserStatsMap(driftClient, { type: 'polling', - accountLoader: bulkAccountLoader, + accountLoader: new BulkAccountLoader( + connection, + stateCommitment, + ORDERBOOK_UPDATE_INTERVAL * 10 + ), }); await userStatsMap.subscribe();