From ceb253d8eca793bc02cdd090fe305550eb797b20 Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 13 Aug 2025 21:05:55 +0000 Subject: [PATCH 1/6] Bumping drift-common to 1d27a790787cbb586e8d82f919528b59e5c8bc00 --- drift-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drift-common b/drift-common index 5797c05..1d27a79 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit 5797c05073274e5a57ccc636f3b09cab2bc980c7 +Subproject commit 1d27a790787cbb586e8d82f919528b59e5c8bc00 From 8dc81fd23f3ffd190c4ae9e4c957b1a166fab397 Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 13 Aug 2025 23:32:10 +0000 Subject: [PATCH 2/6] Bumping drift-common to 0e2b23d7a9d88a9f272659c897d78fd1ce9cb54d --- drift-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drift-common b/drift-common index 1d27a79..0e2b23d 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit 1d27a790787cbb586e8d82f919528b59e5c8bc00 +Subproject commit 0e2b23d7a9d88a9f272659c897d78fd1ce9cb54d From 72172ae9ced52981e0fd155befe8ce5327c10160 Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 07:18:46 +0000 Subject: [PATCH 3/6] Bumping drift-common to 22cf80902560715132a0b5ac011592dfc3a4e583 --- drift-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drift-common b/drift-common index 0e2b23d..22cf809 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit 0e2b23d7a9d88a9f272659c897d78fd1ce9cb54d +Subproject commit 22cf80902560715132a0b5ac011592dfc3a4e583 From c5dac71b824b068ef80bcd1d995023b663945981 Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 07:24:03 +0000 Subject: [PATCH 4/6] Bumping drift-common to 23d63f68561dae3d6b53d2e2f192d430767e9e6e --- drift-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drift-common b/drift-common index 22cf809..23d63f6 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit 22cf80902560715132a0b5ac011592dfc3a4e583 +Subproject commit 23d63f68561dae3d6b53d2e2f192d430767e9e6e From 262f6fc9086e9ea3ba8ff3b564aa769fe6b4f9ca Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 16:22:42 +0000 Subject: [PATCH 5/6] Bumping drift-common to 011075d877e9c99a927bb19490d0b960d48048b7 --- drift-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drift-common b/drift-common index 23d63f6..011075d 160000 --- a/drift-common +++ b/drift-common @@ -1 +1 @@ -Subproject commit 23d63f68561dae3d6b53d2e2f192d430767e9e6e +Subproject commit 011075d877e9c99a927bb19490d0b960d48048b7 From f6fc7ede42c0da9be4ac19b3686036eb93040d38 Mon Sep 17 00:00:00 2001 From: Nour Alharithi Date: Mon, 18 Aug 2025 09:27:00 -0700 Subject: [PATCH 6/6] update sdk to use mm oracle --- src/dlob-subscriber/DLOBSubscriberIO.ts | 28 +++++++++++++++++-------- src/index.ts | 12 ++++++++--- src/publishers/dlobPublisher.ts | 6 ++---- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/dlob-subscriber/DLOBSubscriberIO.ts b/src/dlob-subscriber/DLOBSubscriberIO.ts index fe72fd3..5c726c1 100644 --- a/src/dlob-subscriber/DLOBSubscriberIO.ts +++ b/src/dlob-subscriber/DLOBSubscriberIO.ts @@ -13,7 +13,7 @@ import { PerpOperation, PositionDirection, ZERO, - calculateAMMBidAskPrice, + calculateBidAskPrice, getLimitPrice, isOperationPaused, isVariant, @@ -151,7 +151,7 @@ export class DLOBSubscriberIO extends DLOBSubscriber { try { if (this.indicativeQuotesRedisClient) { const oraclePriceData = isVariant(marketArgs.marketType, 'perp') - ? this.driftClient.getOracleDataForPerpMarket( + ? this.driftClient.getMMOracleDataForPerpMarket( marketArgs.marketIndex ) : this.driftClient.getOracleDataForSpotMarket( @@ -160,13 +160,17 @@ export class DLOBSubscriberIO extends DLOBSubscriber { const bestDlobBid = dlob.getBestBid( marketArgs.marketIndex, this.slotSource.getSlot(), - marketArgs.marketType, + isVariant(marketArgs.marketType, 'perp') + ? MarketType.PERP + : MarketType.SPOT, oraclePriceData ); const bestDlobAsk = dlob.getBestAsk( marketArgs.marketIndex, this.slotSource.getSlot(), - marketArgs.marketType, + isVariant(marketArgs.marketType, 'perp') + ? MarketType.PERP + : MarketType.SPOT, oraclePriceData ); @@ -177,7 +181,7 @@ export class DLOBSubscriberIO extends DLOBSubscriber { let bestBid = bestDlobBid; let bestAsk = bestDlobAsk; if (marketType === 'perp') { - const [bestVammBid, bestVammAsk] = calculateAMMBidAskPrice( + const [bestVammBid, bestVammAsk] = calculateBidAskPrice( this.driftClient.getPerpMarketAccount(marketArgs.marketIndex).amm, this.driftClient.getMMOracleDataForPerpMarket( marketArgs.marketIndex @@ -269,7 +273,8 @@ export class DLOBSubscriberIO extends DLOBSubscriber { indicativeBid, INDICATIVE_QUOTES_PUBKEY, this.slotSource.getSlot(), - false + false, + indicativeBid.baseAssetAmount ); indicativeOrderId += 1; } @@ -304,7 +309,8 @@ export class DLOBSubscriberIO extends DLOBSubscriber { indicativeAsk, INDICATIVE_QUOTES_PUBKEY, this.slotSource.getSlot(), - false + false, + indicativeAsk.baseAssetAmount ); indicativeOrderId += 1; } @@ -471,7 +477,9 @@ export class DLOBSubscriberIO extends DLOBSubscriber { const bids = this.dlob .getBestMakers({ marketIndex: marketArgs.marketIndex, - marketType: marketArgs.marketType, + marketType: isVariant(marketArgs.marketType, 'perp') + ? MarketType.PERP + : MarketType.SPOT, direction: PositionDirection.LONG, slot: slot, oraclePriceData: oracleData, @@ -481,7 +489,9 @@ export class DLOBSubscriberIO extends DLOBSubscriber { const asks = this.dlob .getBestMakers({ marketIndex: marketArgs.marketIndex, - marketType: marketArgs.marketType, + marketType: isVariant(marketArgs.marketType, 'perp') + ? MarketType.PERP + : MarketType.SPOT, direction: PositionDirection.SHORT, slot, oraclePriceData: oracleData, diff --git a/src/index.ts b/src/index.ts index fea69fc..9651ee5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,6 +22,7 @@ import { PRICE_PRECISION_EXP, MarketTypeStr, AssetType, + MarketType, } from '@drift-labs/sdk'; import { RedisClient, RedisClientPrefix } from '@drift/common/clients'; @@ -384,7 +385,8 @@ const main = async (): Promise => { return; } const normedSide = (side as string).toLowerCase(); - const oracle = driftClient.getOracleDataForPerpMarket(normedMarketIndex); + const oracle = + driftClient.getMMOracleDataForPerpMarket(normedMarketIndex); let normedLimit = undefined; if (limit) { @@ -469,7 +471,9 @@ const main = async (): Promise => { .getRestingLimitBids( normedMarketIndex, dlobProvider.getSlot(), - normedMarketType, + isVariant(normedMarketType, 'perp') + ? MarketType.PERP + : MarketType.SPOT, oracle ) ); @@ -480,7 +484,9 @@ const main = async (): Promise => { .getRestingLimitAsks( normedMarketIndex, dlobProvider.getSlot(), - normedMarketType, + isVariant(normedMarketType, 'perp') + ? MarketType.PERP + : MarketType.SPOT, oracle ) ); diff --git a/src/publishers/dlobPublisher.ts b/src/publishers/dlobPublisher.ts index 65cbd2d..680747e 100644 --- a/src/publishers/dlobPublisher.ts +++ b/src/publishers/dlobPublisher.ts @@ -1,5 +1,3 @@ -import { program } from 'commander'; - import { Connection, Commitment, PublicKey, Keypair } from '@solana/web3.js'; import { @@ -101,7 +99,6 @@ metricsV2.finalizeObservables(); const sdkConfig = initialize({ env: process.env.ENV }); let driftClient: DriftClient; -const opts = program.opts(); setLogLevel('debug'); const useGrpc = process.env.USE_GRPC?.toLowerCase() === 'true'; @@ -709,7 +706,8 @@ const main = async () => { const dlob = await dlobProvider.getDLOB(slot); // Get oracle data for the market - const oracleData = driftClient.getOracleDataForPerpMarket(marketIndex); + const oracleData = + driftClient.getMMOracleDataForPerpMarket(marketIndex); // Get L3 orderbook to check TOB const l3OrderBook = dlob.getL3({