From 2f88b80700200541ae1bc4c51950030cb06a5a76 Mon Sep 17 00:00:00 2001 From: Jay Yu <103467857+jayy04@users.noreply.github.com> Date: Tue, 26 Mar 2024 13:37:11 -0400 Subject: [PATCH] [CT-712] send fill amount updates for reverted operations --- protocol/x/clob/abci.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/protocol/x/clob/abci.go b/protocol/x/clob/abci.go index 27f4492589..f7e371c82f 100644 --- a/protocol/x/clob/abci.go +++ b/protocol/x/clob/abci.go @@ -169,7 +169,26 @@ func PrepareCheckState( // For orders that are filled in the last block, send an orderbook update to the grpc streams. if keeper.GetGrpcStreamingManager().Enabled() { allUpdates := types.NewOffchainUpdates() + orderIdsToSend := make(map[types.OrderId]bool) + + // Send an update for reverted local operations. + for _, operation := range localValidatorOperationsQueue { + if match := operation.GetMatch(); match != nil { + orderIdsToSend[match.GetMatchOrders().TakerOrderId] = true + + for _, fill := range match.GetMatchOrders().Fills { + orderIdsToSend[fill.MakerOrderId] = true + } + } + } + + // Send an update for orders that were proposed. for _, orderId := range processProposerMatchesEvents.OrderIdsFilledInLastBlock { + orderIdsToSend[orderId] = true + } + + // Send update. + for orderId := range orderIdsToSend { if _, exists := keeper.MemClob.GetOrder(ctx, orderId); exists { orderbookUpdate := keeper.MemClob.GetOrderbookUpdatesForOrderUpdate(ctx, orderId) allUpdates.Append(orderbookUpdate)