From a920160ca8fa089fbb13f9271b42bf669da65c8c Mon Sep 17 00:00:00 2001 From: Nour Alharithi Date: Thu, 22 Feb 2024 09:18:11 -0800 Subject: [PATCH] switching to confirmed + trades resource reduction --- src/index.ts | 2 +- src/publishers/dlobPublisher.ts | 2 +- src/publishers/tradesPublisher.ts | 29 ++++------------------------- 3 files changed, 6 insertions(+), 27 deletions(-) diff --git a/src/index.ts b/src/index.ts index 1bc9028..5092dd2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -89,7 +89,7 @@ const commitHash = process.env.COMMIT; //@ts-ignore const sdkConfig = initialize({ env: process.env.ENV }); -const stateCommitment: Commitment = 'processed'; +const stateCommitment: Commitment = 'confirmed'; const serverPort = process.env.PORT || 6969; export const ORDERBOOK_UPDATE_INTERVAL = 1000; const WS_FALLBACK_FETCH_INTERVAL = ORDERBOOK_UPDATE_INTERVAL * 10; diff --git a/src/publishers/dlobPublisher.ts b/src/publishers/dlobPublisher.ts index 4181a9b..069d5c1 100644 --- a/src/publishers/dlobPublisher.ts +++ b/src/publishers/dlobPublisher.ts @@ -42,7 +42,7 @@ import FEATURE_FLAGS from '../utils/featureFlags'; import { GeyserOrderSubscriber } from '../grpc/OrderSubscriberGRPC'; require('dotenv').config(); -const stateCommitment: Commitment = 'processed'; +const stateCommitment: Commitment = 'confirmed'; const driftEnv = (process.env.ENV || 'devnet') as DriftEnv; const commitHash = process.env.COMMIT; const REDIS_HOST = process.env.REDIS_HOST || 'localhost'; diff --git a/src/publishers/tradesPublisher.ts b/src/publishers/tradesPublisher.ts index e25e3d4..2de92c7 100644 --- a/src/publishers/tradesPublisher.ts +++ b/src/publishers/tradesPublisher.ts @@ -7,9 +7,7 @@ import { initialize, DriftEnv, SlotSubscriber, - UserMap, Wallet, - BulkAccountLoader, EventSubscriber, OrderAction, convertToNumber, @@ -38,9 +36,7 @@ const REDIS_PASSWORD = process.env.REDIS_PASSWORD; //@ts-ignore const sdkConfig = initialize({ env: process.env.ENV }); -const stateCommitment: Commitment = 'processed'; -const ORDERBOOK_UPDATE_INTERVAL = 1000; - +const stateCommitment: Commitment = 'confirmed'; let driftClient: DriftClient; const opts = program.opts(); @@ -62,19 +58,14 @@ const main = async () => { commitment: stateCommitment, }); - const bulkAccountLoader = new BulkAccountLoader( - connection, - stateCommitment, - ORDERBOOK_UPDATE_INTERVAL - ); - driftClient = new DriftClient({ connection, wallet, programID: clearingHousePublicKey, accountSubscription: { - type: 'polling', - accountLoader: bulkAccountLoader, + type: 'websocket', + commitment: stateCommitment, + resubTimeoutMs: 30_000, }, env: driftEnv, }); @@ -96,18 +87,6 @@ const main = async () => { await slotSubscriber.subscribe(); - const userMap = new UserMap({ - driftClient, - subscriptionConfig: { - type: 'websocket', - resubTimeoutMs: 30_000, - commitment: stateCommitment, - }, - skipInitialLoad: false, - includeIdle: false, - }); - await userMap.subscribe(); - const redisClient = new RedisClient(REDIS_HOST, REDIS_PORT, REDIS_PASSWORD); await redisClient.connect();