From 8318de761d481f2e283265ce1cf904c4a41f50dc Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 15 May 2024 14:38:52 +0000 Subject: [PATCH 1/8] Bumping sdk dependency to 2.82.0-beta.17 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 92b8f42..c98df45 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "license": "Apache-2.0", "dependencies": { "@coral-xyz/anchor": "^0.29.0", - "@drift-labs/sdk": "2.82.0-beta.16", + "@drift-labs/sdk": "2.82.0-beta.17", "@opentelemetry/api": "^1.1.0", "@opentelemetry/auto-instrumentations-node": "^0.31.1", "@opentelemetry/exporter-prometheus": "^0.31.0", diff --git a/yarn.lock b/yarn.lock index 6167d7d..ec13cbb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -122,10 +122,10 @@ enabled "2.0.x" kuler "^2.0.0" -"@drift-labs/sdk@2.82.0-beta.16": - version "2.82.0-beta.16" - resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.82.0-beta.16.tgz#a1b63976cebe3ba6aeb7aa95434e56f88959460a" - integrity sha512-o762Ng4G+SohdC5h0E9GxNYKrNlpsQzdsIxaLmnP1EGQGL99ocsyLkFa3Hb3N6hKdm7eprZWf3dCwbNU8vGtaQ== +"@drift-labs/sdk@2.82.0-beta.17": + version "2.82.0-beta.17" + resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.82.0-beta.17.tgz#fffbaacb4f21aa11a2bf51bc457b8564f5b29e52" + integrity sha512-iGavtcdoOA2R8GKDgolnCjcPKQdKNC8oiryVmJI+NONkqZ7j1sz8pzfQm9V7o342ulz+zwZJVURf+v1K2ifRyw== dependencies: "@coral-xyz/anchor" "0.28.1-beta.2" "@ellipsis-labs/phoenix-sdk" "^1.4.2" From 924741c45e4c2e4d87d3242d73db0a26a9ffc96e Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 15 May 2024 20:08:16 +0000 Subject: [PATCH 2/8] Bumping sdk dependency to 2.82.0-beta.18 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index c98df45..09de989 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "license": "Apache-2.0", "dependencies": { "@coral-xyz/anchor": "^0.29.0", - "@drift-labs/sdk": "2.82.0-beta.17", + "@drift-labs/sdk": "2.82.0-beta.18", "@opentelemetry/api": "^1.1.0", "@opentelemetry/auto-instrumentations-node": "^0.31.1", "@opentelemetry/exporter-prometheus": "^0.31.0", diff --git a/yarn.lock b/yarn.lock index ec13cbb..081711f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -122,10 +122,10 @@ enabled "2.0.x" kuler "^2.0.0" -"@drift-labs/sdk@2.82.0-beta.17": - version "2.82.0-beta.17" - resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.82.0-beta.17.tgz#fffbaacb4f21aa11a2bf51bc457b8564f5b29e52" - integrity sha512-iGavtcdoOA2R8GKDgolnCjcPKQdKNC8oiryVmJI+NONkqZ7j1sz8pzfQm9V7o342ulz+zwZJVURf+v1K2ifRyw== +"@drift-labs/sdk@2.82.0-beta.18": + version "2.82.0-beta.18" + resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.82.0-beta.18.tgz#084e97be5a1bcbcf515af14f49b95d380627a40d" + integrity sha512-hdCJtSAm9Kol2FYYEwqOql6gl76Q4OfARo7Tv3C/Ek73DUiHluhV5TH7sSrftHuPD4/W9hLvvF3p6SXQwwAwaQ== dependencies: "@coral-xyz/anchor" "0.28.1-beta.2" "@ellipsis-labs/phoenix-sdk" "^1.4.2" From 3d19dd296c5321878ebb427eeb2083db9a5b5913 Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 15 May 2024 23:20:44 +0000 Subject: [PATCH 3/8] Bumping sdk dependency to 2.82.0-beta.19 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 09de989..8657400 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "license": "Apache-2.0", "dependencies": { "@coral-xyz/anchor": "^0.29.0", - "@drift-labs/sdk": "2.82.0-beta.18", + "@drift-labs/sdk": "2.82.0-beta.19", "@opentelemetry/api": "^1.1.0", "@opentelemetry/auto-instrumentations-node": "^0.31.1", "@opentelemetry/exporter-prometheus": "^0.31.0", diff --git a/yarn.lock b/yarn.lock index 081711f..bbc5692 100644 --- a/yarn.lock +++ b/yarn.lock @@ -122,10 +122,10 @@ enabled "2.0.x" kuler "^2.0.0" -"@drift-labs/sdk@2.82.0-beta.18": - version "2.82.0-beta.18" - resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.82.0-beta.18.tgz#084e97be5a1bcbcf515af14f49b95d380627a40d" - integrity sha512-hdCJtSAm9Kol2FYYEwqOql6gl76Q4OfARo7Tv3C/Ek73DUiHluhV5TH7sSrftHuPD4/W9hLvvF3p6SXQwwAwaQ== +"@drift-labs/sdk@2.82.0-beta.19": + version "2.82.0-beta.19" + resolved "https://registry.yarnpkg.com/@drift-labs/sdk/-/sdk-2.82.0-beta.19.tgz#f4e413eb8eb4b824fa62ed6c5ba46735847d9ec5" + integrity sha512-IGo6hkJn+iq5+OX68VuFjva/UYEGwr/tSTGPWqNa6+p530xeGOJnK1zvTw9kWqC5JtsdI6U+V1xHAT7wZPirFQ== dependencies: "@coral-xyz/anchor" "0.28.1-beta.2" "@ellipsis-labs/phoenix-sdk" "^1.4.2" From a8131e20c1945c949d530974d4a08ce840528c0e Mon Sep 17 00:00:00 2001 From: Nour Alharithi Date: Wed, 15 May 2024 16:31:40 -0700 Subject: [PATCH 4/8] ignore drift market --- src/dlob-subscriber/DLOBSubscriberIO.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dlob-subscriber/DLOBSubscriberIO.ts b/src/dlob-subscriber/DLOBSubscriberIO.ts index 4bb5983..11718e4 100644 --- a/src/dlob-subscriber/DLOBSubscriberIO.ts +++ b/src/dlob-subscriber/DLOBSubscriberIO.ts @@ -39,7 +39,7 @@ const PERP_MARKETS_TO_SKIP_SLOT_CHECK = { }; const SPOT_MARKETS_TO_SKIP_SLOT_CHECK = { - 'mainnet-beta': [6, 8, 10], + 'mainnet-beta': [6, 8, 10, 15], devnet: [], }; From c8405085e6b9f63d6c04de5a556c0ab7892265f1 Mon Sep 17 00:00:00 2001 From: Nour Alharithi Date: Thu, 16 May 2024 06:40:08 -0700 Subject: [PATCH 5/8] bulk account loader for phoenix --- src/index.ts | 20 +++++++++++++++----- src/publishers/dlobPublisher.ts | 19 ++++++++++++++----- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/index.ts b/src/index.ts index 377aee7..6277091 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,6 +18,8 @@ import { isVariant, OrderSubscriber, MarketType, + PhoenixSubscriber, + BulkAccountLoader, } from '@drift-labs/sdk'; import { logger, setLogLevel } from './utils/logger'; @@ -36,7 +38,6 @@ import { SubscriberLookup, addOracletoResponse, errorHandler, - getPhoenixSubscriber, getSerumSubscriber, l2WithBNToStrings, normalizeBatchQueryParams, @@ -169,11 +170,20 @@ const initializeAllMarketSubscribers = async (driftClient: DriftClient) => { const phoenixConfigAccount = await driftClient.getPhoenixV1FulfillmentConfig(market.phoenixMarket); if (isVariant(phoenixConfigAccount.status, 'enabled')) { - const phoenixSubscriber = getPhoenixSubscriber( - driftClient, - market, - sdkConfig + const bulkAccountLoader = new BulkAccountLoader( + driftClient.connection, + stateCommitment, + 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(); // Test get L2 to know if we should add try { diff --git a/src/publishers/dlobPublisher.ts b/src/publishers/dlobPublisher.ts index 08e8e78..3687e2a 100644 --- a/src/publishers/dlobPublisher.ts +++ b/src/publishers/dlobPublisher.ts @@ -17,12 +17,12 @@ import { OracleInfo, PerpMarketConfig, SpotMarketConfig, + PhoenixSubscriber, } from '@drift-labs/sdk'; import { logger, setLogLevel } from '../utils/logger'; import { SubscriberLookup, - getPhoenixSubscriber, getSerumSubscriber, parsePositiveIntArray, sleep, @@ -206,11 +206,20 @@ const initializeAllMarketSubscribers = async (driftClient: DriftClient) => { logger.info( `Loading phoenix subscriber for spot market ${market.marketIndex}` ); - const phoenixSubscriber = getPhoenixSubscriber( - driftClient, - marketConfig, - sdkConfig + const bulkAccountLoader = new BulkAccountLoader( + driftClient.connection, + stateCommitment, + 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(); // Test get L2 to know if we should add try { From c622775910ee71c9db3fe0a50b6838504d21a10d Mon Sep 17 00:00:00 2001 From: Nour Alharithi Date: Thu, 16 May 2024 06:58:38 -0700 Subject: [PATCH 6/8] tighter phoenix interval --- src/index.ts | 2 +- src/publishers/dlobPublisher.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 6277091..7b0ebe3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -173,7 +173,7 @@ const initializeAllMarketSubscribers = async (driftClient: DriftClient) => { const bulkAccountLoader = new BulkAccountLoader( driftClient.connection, stateCommitment, - 5_000 + 2_000 ); const phoenixSubscriber = new PhoenixSubscriber({ connection: driftClient.connection, diff --git a/src/publishers/dlobPublisher.ts b/src/publishers/dlobPublisher.ts index 3687e2a..b33ce9e 100644 --- a/src/publishers/dlobPublisher.ts +++ b/src/publishers/dlobPublisher.ts @@ -209,7 +209,7 @@ const initializeAllMarketSubscribers = async (driftClient: DriftClient) => { const bulkAccountLoader = new BulkAccountLoader( driftClient.connection, stateCommitment, - 5_000 + 2_000 ); const phoenixSubscriber = new PhoenixSubscriber({ connection: driftClient.connection, From e1336001ce9f0288e64075759ba03398ef0328a9 Mon Sep 17 00:00:00 2001 From: Nour Alharithi Date: Thu, 16 May 2024 16:43:06 -0700 Subject: [PATCH 7/8] socket fix --- package.json | 1 + src/index.ts | 7 +++++++ src/publishers/dlobPublisher.ts | 7 +++++++ src/publishers/priorityFeesPublisher.ts | 7 +++++++ src/publishers/tradesPublisher.ts | 7 +++++++ yarn.lock | 5 +++++ 6 files changed, 34 insertions(+) diff --git a/package.json b/package.json index 8657400..ac33388 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "rxjs": "^7.8.1", "socket.io-redis": "^6.1.1", "typescript": "4.5.4", + "undici": "^6.16.1", "winston": "^3.8.1", "ws": "^8.14.2" }, diff --git a/src/index.ts b/src/index.ts index 7b0ebe3..23f0dba 100644 --- a/src/index.ts +++ b/src/index.ts @@ -47,6 +47,13 @@ import { import FEATURE_FLAGS from './utils/featureFlags'; import { getDLOBProviderFromOrderSubscriber } from './dlobProvider'; import { RedisClient } from './utils/redisClient'; +import { setGlobalDispatcher, Agent } from 'undici'; + +setGlobalDispatcher( + new Agent({ + connections: 200, + }) +); require('dotenv').config(); diff --git a/src/publishers/dlobPublisher.ts b/src/publishers/dlobPublisher.ts index b33ce9e..587b1cb 100644 --- a/src/publishers/dlobPublisher.ts +++ b/src/publishers/dlobPublisher.ts @@ -42,6 +42,13 @@ import FEATURE_FLAGS from '../utils/featureFlags'; import { GeyserOrderSubscriber } from '../grpc/OrderSubscriberGRPC'; import express from 'express'; import { handleHealthCheck } from '../core/metrics'; +import { setGlobalDispatcher, Agent } from 'undici'; + +setGlobalDispatcher( + new Agent({ + connections: 200, + }) +); require('dotenv').config(); const stateCommitment: Commitment = 'confirmed'; diff --git a/src/publishers/priorityFeesPublisher.ts b/src/publishers/priorityFeesPublisher.ts index 2ebd136..1c2548a 100644 --- a/src/publishers/priorityFeesPublisher.ts +++ b/src/publishers/priorityFeesPublisher.ts @@ -16,6 +16,13 @@ import { sleep } from '../utils/utils'; import express from 'express'; // import { handleHealthCheck } from '../core/metrics'; import { RedisClient } from '../utils/redisClient'; +import { setGlobalDispatcher, Agent } from 'undici'; + +setGlobalDispatcher( + new Agent({ + connections: 200, + }) +); require('dotenv').config(); const stateCommitment: Commitment = 'confirmed'; diff --git a/src/publishers/tradesPublisher.ts b/src/publishers/tradesPublisher.ts index f6944b3..83b3b95 100644 --- a/src/publishers/tradesPublisher.ts +++ b/src/publishers/tradesPublisher.ts @@ -25,6 +25,13 @@ import { logger, setLogLevel } from '../utils/logger'; import { sleep } from '../utils/utils'; import { RedisClient } from '../utils/redisClient'; import { fromEvent, filter, map } from 'rxjs'; +import { setGlobalDispatcher, Agent } from 'undici'; + +setGlobalDispatcher( + new Agent({ + connections: 200, + }) +); require('dotenv').config(); const driftEnv = (process.env.ENV || 'devnet') as DriftEnv; diff --git a/yarn.lock b/yarn.lock index bbc5692..f7d1d7a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4339,6 +4339,11 @@ undici-types@~5.26.4: resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" 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: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" From 9428644d0f7b4fcf2f9bec5f8686409e71bae98f Mon Sep 17 00:00:00 2001 From: Nour Alharithi Date: Mon, 20 May 2024 18:30:57 -0700 Subject: [PATCH 8/8] move phoenix refresh interval from 2 to 5s for dlob server --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 23f0dba..89b9f61 100644 --- a/src/index.ts +++ b/src/index.ts @@ -180,7 +180,7 @@ const initializeAllMarketSubscribers = async (driftClient: DriftClient) => { const bulkAccountLoader = new BulkAccountLoader( driftClient.connection, stateCommitment, - 2_000 + 5_000 ); const phoenixSubscriber = new PhoenixSubscriber({ connection: driftClient.connection,