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) { if (quote['bid_size'] && quote['bid_price'] != null) {
// Sanity check bid price and size // Sanity check bid price and size and change to top of book if necessary
const indicativeBid: Order = Object.assign( let indicativeBid: Order = Object.assign(
{}, {},
indicativeBaseOrder, indicativeBaseOrder,
{ {
orderId: indicativeOrderId, orderId: indicativeOrderId,
direction: PositionDirection.LONG,
baseAssetAmount: new BN(quote['bid_size']),
oraclePriceOffset: quote['is_oracle_offset'] oraclePriceOffset: quote['is_oracle_offset']
? quote['bid_price'] ? quote['bid_price']
: 0, : 0,
price: quote['is_oracle_offset'] price: quote['is_oracle_offset']
? 0 ? 0
: new BN(quote['bid_price']), : new BN(quote['bid_price']),
baseAssetAmount: new BN(quote['bid_size']),
direction: PositionDirection.LONG,
} }
); );
const limitPrice = getLimitPrice( const limitPrice = getLimitPrice(
@@ -248,18 +248,22 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
oraclePriceData, oraclePriceData,
this.slotSource.getSlot() this.slotSource.getSlot()
); );
if (limitPrice.lte(bestBid)) { if (limitPrice.gt(bestBid)) {
this.dlob.insertOrder( indicativeBid = Object.assign({}, indicativeBid, {
indicativeBid, price: bestBid,
INDICATIVE_QUOTES_PUBKEY, oraclePriceOffset: 0,
this.slotSource.getSlot(), });
false
);
indicativeOrderId += 1;
} }
this.dlob.insertOrder(
indicativeBid,
INDICATIVE_QUOTES_PUBKEY,
this.slotSource.getSlot(),
false
);
indicativeOrderId += 1;
} }
if (quote['ask_size'] && quote['ask_price'] != null) { if (quote['ask_size'] && quote['ask_price'] != null) {
const indicativeAsk: Order = Object.assign( let indicativeAsk: Order = Object.assign(
{}, {},
indicativeBaseOrder, indicativeBaseOrder,
{ {
@@ -279,15 +283,19 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
oraclePriceData, oraclePriceData,
this.slotSource.getSlot() this.slotSource.getSlot()
); );
if (limitPrice.gte(bestAsk)) { if (limitPrice.lt(bestAsk)) {
this.dlob.insertOrder( indicativeAsk = Object.assign({}, indicativeAsk, {
indicativeAsk, price: bestAsk,
INDICATIVE_QUOTES_PUBKEY, oraclePriceOffset: 0,
this.slotSource.getSlot(), });
false
);
indicativeOrderId += 1;
} }
this.dlob.insertOrder(
indicativeAsk,
INDICATIVE_QUOTES_PUBKEY,
this.slotSource.getSlot(),
false
);
indicativeOrderId += 1;
} }
} }
} }