Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jonfung-dydx committed May 6, 2024
1 parent 245ab88 commit ec32bd3
Showing 1 changed file with 13 additions and 63 deletions.
76 changes: 13 additions & 63 deletions protocol/x/clob/memclob/memclob.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,25 +390,6 @@ func (m *MemClobPriceTimePriority) mustUpdateMemclobStateWithMatches(

// If orderbook updates are on, send an orderbook update with the fill to grpc streams.
if m.generateOrderbookUpdates {
if takerOrder.IsLiquidation() {
log.InfoLog(
ctx,
"emitting a match",
"order", takerOrder,
"liquidation", true,
"mode", ctx.ExecMode(),
)
} else {
order := takerOrder.MustGetOrder()
log.InfoLog(
ctx,
"emitting a match",
"order", takerOrder.MustGetOrder(),
"orderId", order.OrderId.String(),
"mode", ctx.ExecMode(),
)
}

// Collect all maker orders.
makerOrders := lib.MapSlice(
makerFillWithOrders,
Expand Down Expand Up @@ -910,36 +891,19 @@ func (m *MemClobPriceTimePriority) matchOrder(
offchainUpdates.Append(matchOffchainUpdates)
writeCache()
} else {
// allUpdates := types.NewOffchainUpdates()
// // try sending updates for all things involved since state reverted
// if order.IsLiquidation() {
// log.InfoLog(
// ctx,
// "reverted state",
// "order", order,
// "liquidation", true,
// "mode", ctx.ExecMode(),
// )
// } else {
// normalOrder := order.MustGetOrder()
// log.InfoLog(
// ctx,
// "reverted state",
// "order", normalOrder,
// "orderId", normalOrder.OrderId.String(),
// "mode", ctx.ExecMode(),
// "matching_err", matchingErr,
// "len_maker_fills", len(newMakerFills),
// )
// updates := m.GetOrderbookUpdatesForOrderUpdate(ctx, normalOrder.OrderId)
// allUpdates.Append(updates)
// }
// // revert all maker fills
// for _, fill := range newMakerFills {
// updates := m.GetOrderbookUpdatesForOrderUpdate(ctx, fill.MakerOrderId)
// allUpdates.Append(updates)
// }
// m.clobKeeper.SendOrderbookUpdates(ctx, allUpdates, false)
// If state was not written to, re-send grpc stream updates for all orders
// involved in the match to "reset" fill amounts.
allUpdates := types.NewOffchainUpdates()
if !order.IsLiquidation() {
normalOrder := order.MustGetOrder()
updates := m.GetOrderbookUpdatesForOrderUpdate(ctx, normalOrder.OrderId)
allUpdates.Append(updates)
}
for _, fill := range newMakerFills {
updates := m.GetOrderbookUpdatesForOrderUpdate(ctx, fill.MakerOrderId)
allUpdates.Append(updates)
}
m.clobKeeper.SendOrderbookUpdates(ctx, allUpdates, false)
}

return takerOrderStatus, offchainUpdates, makerOrdersToRemove, matchingErr
Expand Down Expand Up @@ -1585,12 +1549,6 @@ func (m *MemClobPriceTimePriority) mustAddOrderToOrderbook(

if m.generateOrderbookUpdates {
// Send an orderbook update to grpc streams.
log.InfoLog(
ctx,
"emitting updates loc 1",
"orderId", newOrder.OrderId.String(),
"order", newOrder,
)
orderbookUpdate := m.GetOrderbookUpdatesForOrderPlacement(ctx, newOrder)
m.clobKeeper.SendOrderbookUpdates(ctx, orderbookUpdate, false)
}
Expand Down Expand Up @@ -2034,8 +1992,6 @@ func (m *MemClobPriceTimePriority) mustRemoveOrder(
// Send an orderbook update to grpc streams.
orderbookUpdate := m.GetOrderbookUpdatesForOrderRemoval(ctx, order.OrderId)
allUpdates.Append(orderbookUpdate)
// orderbookUpdate = m.GetOrderbookUpdatesForOrderUpdate(ctx, order.OrderId)
// allUpdates.Append(orderbookUpdate)
m.clobKeeper.SendOrderbookUpdates(ctx, orderbookUpdate, false)
}
}
Expand All @@ -2055,12 +2011,6 @@ func (m *MemClobPriceTimePriority) mustUpdateOrderbookStateWithMatchedMakerOrder
panic("Total filled size of maker order greater than the order size")
}

// // Send an orderbook update for the order's new total filled amount.
// if m.generateOrderbookUpdates {
// orderbookUpdate := m.GetOrderbookUpdatesForOrderUpdate(ctx, makerOrder.OrderId)
// m.clobKeeper.SendOrderbookUpdates(ctx, orderbookUpdate, false)
// }

// If the order is fully filled, remove it from the orderbook.
// Note we shouldn't remove Short-Term order hashes from `ShortTermOrderTxBytes` here since
// the order was matched.
Expand Down

0 comments on commit ec32bd3

Please sign in to comment.