From ee71d64e8a8a5c4b2b451162853413f3074f888f Mon Sep 17 00:00:00 2001 From: Jack Waller Date: Tue, 22 Jul 2025 12:35:01 +1000 Subject: [PATCH] chore: test out a dlob ignore list --- .../OrderSubscriberFiltered.ts | 35 +++++++++++++++++++ src/publishers/dlobPublisher.ts | 4 ++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/dlob-subscriber/OrderSubscriberFiltered.ts diff --git a/src/dlob-subscriber/OrderSubscriberFiltered.ts b/src/dlob-subscriber/OrderSubscriberFiltered.ts new file mode 100644 index 0000000..a69cfca --- /dev/null +++ b/src/dlob-subscriber/OrderSubscriberFiltered.ts @@ -0,0 +1,35 @@ +import { + OrderSubscriber, + OrderSubscriberConfig, + UserAccount, +} from '@drift-labs/sdk'; + +export class OrderSubscriberFiltered extends OrderSubscriber { + public ignoreList: string[]; + + constructor( + config: OrderSubscriberConfig & { + ignoreList?: string[]; + } + ) { + super(config); + this.ignoreList = config.ignoreList ?? []; + } + + override async tryUpdateUserAccount( + key: string, + dataType: 'raw' | 'decoded' | 'buffer', + data: string[] | UserAccount | Buffer, + slot: number + ) { + if (!this.mostRecentSlot || slot > this.mostRecentSlot) { + this.mostRecentSlot = slot; + } + + if (this.ignoreList.includes(key)) { + return; + } + + super.tryUpdateUserAccount(key, dataType, data, slot); + } +} diff --git a/src/publishers/dlobPublisher.ts b/src/publishers/dlobPublisher.ts index 4bee76a..0a4281f 100644 --- a/src/publishers/dlobPublisher.ts +++ b/src/publishers/dlobPublisher.ts @@ -47,6 +47,7 @@ import express, { Response, Request } from 'express'; import { handleHealthCheck } from '../core/middleware'; import { setGlobalDispatcher, Agent } from 'undici'; import { Metrics } from '../core/metricsV2'; +import { OrderSubscriberFiltered } from '../dlob-subscriber/OrderSubscriberFiltered'; setGlobalDispatcher( new Agent({ @@ -474,9 +475,10 @@ const main = async () => { }; } - const orderSubscriber = new OrderSubscriber({ + const orderSubscriber = new OrderSubscriberFiltered({ driftClient, subscriptionConfig, + ignoreList: ['5N1AcdftujhXWZdBaqfciaKtXn6uVBKjmgwf6aQxR1vW'] }); dlobProvider = getDLOBProviderFromOrderSubscriber(orderSubscriber);