patch indicative liquidity filtering

This commit is contained in:
Nour Alharithi
2025-07-10 11:50:59 -07:00
parent ae0f9a4889
commit 6f9873676e

View File

@@ -227,20 +227,20 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
};
if (quote['bid_size'] && quote['bid_price'] != null) {
// Sanity check bid price and size
const indicativeBid: Order = Object.assign(
// Sanity check bid price and size and change to top of book if necessary
let indicativeBid: Order = Object.assign(
{},
indicativeBaseOrder,
{
orderId: indicativeOrderId,
direction: PositionDirection.LONG,
baseAssetAmount: new BN(quote['bid_size']),
oraclePriceOffset: quote['is_oracle_offset']
? quote['bid_price']
: 0,
price: quote['is_oracle_offset']
? 0
: new BN(quote['bid_price']),
baseAssetAmount: new BN(quote['bid_size']),
direction: PositionDirection.LONG,
}
);
const limitPrice = getLimitPrice(
@@ -248,7 +248,12 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
oraclePriceData,
this.slotSource.getSlot()
);
if (limitPrice.lte(bestBid)) {
if (limitPrice.gt(bestBid)) {
indicativeBid = Object.assign({}, indicativeBid, {
price: bestBid,
oraclePriceOffset: 0,
});
}
this.dlob.insertOrder(
indicativeBid,
INDICATIVE_QUOTES_PUBKEY,
@@ -257,9 +262,8 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
);
indicativeOrderId += 1;
}
}
if (quote['ask_size'] && quote['ask_price'] != null) {
const indicativeAsk: Order = Object.assign(
let indicativeAsk: Order = Object.assign(
{},
indicativeBaseOrder,
{
@@ -279,7 +283,12 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
oraclePriceData,
this.slotSource.getSlot()
);
if (limitPrice.gte(bestAsk)) {
if (limitPrice.lt(bestAsk)) {
indicativeAsk = Object.assign({}, indicativeAsk, {
price: bestAsk,
oraclePriceOffset: 0,
});
}
this.dlob.insertOrder(
indicativeAsk,
INDICATIVE_QUOTES_PUBKEY,
@@ -290,7 +299,6 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
}
}
}
}
} catch (error) {
console.log('skipping mmQuote: ', error);
}