Submodule drift-common updated: 5797c05073...011075d877
@@ -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,
|
||||
|
||||
12
src/index.ts
12
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<void> => {
|
||||
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<void> => {
|
||||
.getRestingLimitBids(
|
||||
normedMarketIndex,
|
||||
dlobProvider.getSlot(),
|
||||
normedMarketType,
|
||||
isVariant(normedMarketType, 'perp')
|
||||
? MarketType.PERP
|
||||
: MarketType.SPOT,
|
||||
oracle
|
||||
)
|
||||
);
|
||||
@@ -480,7 +484,9 @@ const main = async (): Promise<void> => {
|
||||
.getRestingLimitAsks(
|
||||
normedMarketIndex,
|
||||
dlobProvider.getSlot(),
|
||||
normedMarketType,
|
||||
isVariant(normedMarketType, 'perp')
|
||||
? MarketType.PERP
|
||||
: MarketType.SPOT,
|
||||
oracle
|
||||
)
|
||||
);
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user