Skip to content

Commit

Permalink
[CT-712] send order update when short term order state fill amounts a…
Browse files Browse the repository at this point in the history
…re pruned
  • Loading branch information
jayy04 committed Mar 26, 2024
1 parent 82c2dec commit ac31868
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion protocol/x/clob/keeper/order_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,22 @@ func (k Keeper) PruneStateFillAmountsForShortTermOrders(
blockHeight := lib.MustConvertIntegerToUint32(ctx.BlockHeight())

// Prune all fill amounts from state which have a pruneable block height of the current `blockHeight`.
k.PruneOrdersForBlockHeight(ctx, blockHeight)
prunedOrderIds := k.PruneOrdersForBlockHeight(ctx, blockHeight)

// Send an orderbook update for each pruned order for grpc streams.
// This is needed because short term orders are pruned in PrepareCheckState using
// keeper.MemClob.openOrders.blockExpirationsForOrders, which can fall out of sync with state fill amount
// pruning when there's replacement.
// Long-term fix would be to add logic to keep them in sync.
// TODO(CT-722): add logic to keep state fill amount pruning and order pruning in sync.
if k.GetGrpcStreamingManager().Enabled() {
allUpdates := types.NewOffchainUpdates()
for _, orderId := range prunedOrderIds {
if _, exists := k.MemClob.GetOrder(ctx, orderId); exists {
orderbookUpdate := k.MemClob.GetOrderbookUpdatesForOrderUpdate(ctx, orderId)
allUpdates.Append(orderbookUpdate)
}
}
k.SendOrderbookUpdates(allUpdates, false)
}
}

0 comments on commit ac31868

Please sign in to comment.