Skip to content

Commit

Permalink
Internalize logic to stage FinalizeBlock events (#2399)
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyding committed Sep 30, 2024
1 parent 1da0c76 commit 52ca5b7
Show file tree
Hide file tree
Showing 14 changed files with 317 additions and 208 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StreamOrderbookFill, StreamOrderbookFillSDKType } from "./query";
import { StreamOrderbookFill, StreamOrderbookFillSDKType, StreamOrderbookUpdate, StreamOrderbookUpdateSDKType } from "./query";
import { StreamSubaccountUpdate, StreamSubaccountUpdateSDKType } from "../subaccounts/streaming";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
Expand All @@ -7,18 +7,21 @@ import { DeepPartial } from "../../helpers";
export interface StagedFinalizeBlockEvent {
orderFill?: StreamOrderbookFill;
subaccountUpdate?: StreamSubaccountUpdate;
orderbookUpdate?: StreamOrderbookUpdate;
}
/** StagedFinalizeBlockEvent is an event staged during `FinalizeBlock`. */

export interface StagedFinalizeBlockEventSDKType {
order_fill?: StreamOrderbookFillSDKType;
subaccount_update?: StreamSubaccountUpdateSDKType;
orderbook_update?: StreamOrderbookUpdateSDKType;
}

function createBaseStagedFinalizeBlockEvent(): StagedFinalizeBlockEvent {
return {
orderFill: undefined,
subaccountUpdate: undefined
subaccountUpdate: undefined,
orderbookUpdate: undefined
};
}

Expand All @@ -32,6 +35,10 @@ export const StagedFinalizeBlockEvent = {
StreamSubaccountUpdate.encode(message.subaccountUpdate, writer.uint32(18).fork()).ldelim();
}

if (message.orderbookUpdate !== undefined) {
StreamOrderbookUpdate.encode(message.orderbookUpdate, writer.uint32(26).fork()).ldelim();
}

return writer;
},

Expand All @@ -52,6 +59,10 @@ export const StagedFinalizeBlockEvent = {
message.subaccountUpdate = StreamSubaccountUpdate.decode(reader, reader.uint32());
break;

case 3:
message.orderbookUpdate = StreamOrderbookUpdate.decode(reader, reader.uint32());
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -65,6 +76,7 @@ export const StagedFinalizeBlockEvent = {
const message = createBaseStagedFinalizeBlockEvent();
message.orderFill = object.orderFill !== undefined && object.orderFill !== null ? StreamOrderbookFill.fromPartial(object.orderFill) : undefined;
message.subaccountUpdate = object.subaccountUpdate !== undefined && object.subaccountUpdate !== null ? StreamSubaccountUpdate.fromPartial(object.subaccountUpdate) : undefined;
message.orderbookUpdate = object.orderbookUpdate !== undefined && object.orderbookUpdate !== null ? StreamOrderbookUpdate.fromPartial(object.orderbookUpdate) : undefined;
return message;
}

Expand Down
1 change: 1 addition & 0 deletions proto/dydxprotocol/clob/streaming.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ message StagedFinalizeBlockEvent {
oneof event {
StreamOrderbookFill order_fill = 1;
dydxprotocol.subaccounts.StreamSubaccountUpdate subaccount_update = 2;
StreamOrderbookUpdate orderbook_update = 3;
}
}
6 changes: 3 additions & 3 deletions protocol/mocks/MemClobKeeper.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 52ca5b7

Please sign in to comment.