try catch in mmQuotes loop

This commit is contained in:
Nick Caradonna
2025-06-15 10:53:19 -04:00
parent 48c0b3ba75
commit c6c1ef2838

View File

@@ -155,88 +155,92 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
const nowMinus1000Ms = Date.now() - 1000; const nowMinus1000Ms = Date.now() - 1000;
for (const quote of mmQuotes) { for (const quote of mmQuotes) {
if (Number(quote['ts']) > nowMinus1000Ms) { try {
const indicativeBaseOrder: Order = { if (Number(quote['ts']) > nowMinus1000Ms) {
status: OrderStatus.OPEN, const indicativeBaseOrder: Order = {
orderType: OrderType.LIMIT, status: OrderStatus.OPEN,
orderId: 0, orderType: OrderType.LIMIT,
slot: new BN(this.slotSource.getSlot()), orderId: 0,
marketIndex: marketArgs.marketIndex, slot: new BN(this.slotSource.getSlot()),
marketType: marketArgs.marketType, marketIndex: marketArgs.marketIndex,
baseAssetAmount: ZERO, marketType: marketArgs.marketType,
immediateOrCancel: false, baseAssetAmount: ZERO,
direction: PositionDirection.LONG, immediateOrCancel: false,
oraclePriceOffset: 0, direction: PositionDirection.LONG,
maxTs: new BN(quote['ts'] + 1000), oraclePriceOffset: 0,
reduceOnly: false, maxTs: new BN(quote['ts'] + 1000),
triggerCondition: OrderTriggerCondition.ABOVE, reduceOnly: false,
price: ZERO, triggerCondition: OrderTriggerCondition.ABOVE,
userOrderId: 0, price: ZERO,
postOnly: true, userOrderId: 0,
auctionDuration: 0, postOnly: true,
auctionStartPrice: ZERO, auctionDuration: 0,
auctionEndPrice: ZERO, auctionStartPrice: ZERO,
// Rest are not necessary and set for type conforming auctionEndPrice: ZERO,
existingPositionDirection: PositionDirection.LONG, // Rest are not necessary and set for type conforming
triggerPrice: ZERO, existingPositionDirection: PositionDirection.LONG,
baseAssetAmountFilled: ZERO, triggerPrice: ZERO,
quoteAssetAmountFilled: ZERO, baseAssetAmountFilled: ZERO,
quoteAssetAmount: ZERO, quoteAssetAmountFilled: ZERO,
bitFlags: 0, quoteAssetAmount: ZERO,
postedSlotTail: 0, bitFlags: 0,
}; postedSlotTail: 0,
};
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
const indicativeBid: Order = Object.assign( const indicativeBid: Order = Object.assign(
{}, {},
indicativeBaseOrder, indicativeBaseOrder,
{ {
orderId: indicativeOrderId, orderId: indicativeOrderId,
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']), baseAssetAmount: new BN(quote['bid_size']),
direction: PositionDirection.LONG, direction: PositionDirection.LONG,
} }
); );
this.dlob.insertOrder( this.dlob.insertOrder(
indicativeBid, indicativeBid,
INDICATIVE_QUOTES_PUBKEY, INDICATIVE_QUOTES_PUBKEY,
this.slotSource.getSlot(), this.slotSource.getSlot(),
false false
); );
indicativeOrderId += 1; indicativeOrderId += 1;
} }
if (quote['ask_size'] && quote['ask_price'] != null) { if (quote['ask_size'] && quote['ask_price'] != null) {
const indicativeAsk: Order = Object.assign( const indicativeAsk: Order = Object.assign(
{}, {},
indicativeBaseOrder, indicativeBaseOrder,
{ {
orderId: indicativeOrderId, orderId: indicativeOrderId,
oraclePriceOffset: quote['is_oracle_offset'] oraclePriceOffset: quote['is_oracle_offset']
? quote['ask_price'] ? quote['ask_price']
: 0, : 0,
price: quote['is_oracle_offset'] price: quote['is_oracle_offset']
? 0 ? 0
: new BN(quote['ask_price']), : new BN(quote['ask_price']),
baseAssetAmount: new BN(quote['ask_size']), baseAssetAmount: new BN(quote['ask_size']),
direction: PositionDirection.SHORT, direction: PositionDirection.SHORT,
} }
); );
this.dlob.insertOrder( this.dlob.insertOrder(
indicativeAsk, indicativeAsk,
INDICATIVE_QUOTES_PUBKEY, INDICATIVE_QUOTES_PUBKEY,
this.slotSource.getSlot(), this.slotSource.getSlot(),
false false
); );
indicativeOrderId += 1; indicativeOrderId += 1;
}
} }
} catch (error) {
console.log('skipping mmQuote: ', error);
} }
} }
} }