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({