Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CT-712] send order update when short term order state fill amounts a… #1241

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok if i'm understanding properly:

  • place short term order A gtb 20
  • fill 1 is created and expires at 20
  • replace short term order A' gtb 23
  • fill 2 is created and expires at 23
    [fill 1 is pruned at 20, fill 2 pruned at 23, and st order is pruned at 23]

and this will basically send an orderbook update indicating the order has 0 fill since it's been pruned?

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)
}
}
Loading