@@ -137,109 +137,113 @@ export class DLOBSubscriberIO extends DLOBSubscriber {
|
|||||||
let indicativeOrderId = 0;
|
let indicativeOrderId = 0;
|
||||||
for (const marketArgs of this.marketArgs) {
|
for (const marketArgs of this.marketArgs) {
|
||||||
try {
|
try {
|
||||||
// if (this.indicativeQuotesRedisClient) {
|
if (this.indicativeQuotesRedisClient) {
|
||||||
// const marketType = isVariant(marketArgs.marketType, 'perp')
|
const marketType = isVariant(marketArgs.marketType, 'perp')
|
||||||
// ? 'perp'
|
? 'perp'
|
||||||
// : 'spot';
|
: 'spot';
|
||||||
|
|
||||||
// const mms = await this.indicativeQuotesRedisClient.smembers(
|
const mms = await this.indicativeQuotesRedisClient.smembers(
|
||||||
// `market_mms_${marketType}_${marketArgs.marketIndex}`
|
`market_mms_${marketType}_${marketArgs.marketIndex}`
|
||||||
// );
|
);
|
||||||
// const mmQuotes = await Promise.all(
|
const mmQuotes = await Promise.all(
|
||||||
// mms.map((mm) => {
|
mms.map((mm) => {
|
||||||
// return this.indicativeQuotesRedisClient.get(
|
return this.indicativeQuotesRedisClient.get(
|
||||||
// `mm_quotes_${marketType}_${marketArgs.marketIndex}_${mm}`
|
`mm_quotes_${marketType}_${marketArgs.marketIndex}_${mm}`
|
||||||
// );
|
);
|
||||||
// })
|
})
|
||||||
// );
|
);
|
||||||
|
|
||||||
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
this.getL2AndSendMsg(marketArgs);
|
this.getL2AndSendMsg(marketArgs);
|
||||||
this.getL3AndSendMsg(marketArgs);
|
this.getL3AndSendMsg(marketArgs);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user