Skip to content

Commit

Permalink
[CT-853] Generate order replacement protos (#1551)
Browse files Browse the repository at this point in the history
* Generate order replacement protos
  • Loading branch information
chenyaoy authored May 20, 2024
1 parent 56501d6 commit 722ec24
Show file tree
Hide file tree
Showing 6 changed files with 997 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ export interface StatefulOrderEventV1 {
conditionalOrderPlacement?: StatefulOrderEventV1_ConditionalOrderPlacementV1;
conditionalOrderTriggered?: StatefulOrderEventV1_ConditionalOrderTriggeredV1;
longTermOrderPlacement?: StatefulOrderEventV1_LongTermOrderPlacementV1;
orderReplace?: StatefulOrderEventV1_LongTermOrderReplacementV1;
}
/**
* StatefulOrderEvent message contains information about a change to a stateful
Expand All @@ -640,6 +641,7 @@ export interface StatefulOrderEventV1SDKType {
conditional_order_placement?: StatefulOrderEventV1_ConditionalOrderPlacementV1SDKType;
conditional_order_triggered?: StatefulOrderEventV1_ConditionalOrderTriggeredV1SDKType;
long_term_order_placement?: StatefulOrderEventV1_LongTermOrderPlacementV1SDKType;
order_replace?: StatefulOrderEventV1_LongTermOrderReplacementV1SDKType;
}
/**
* A stateful order placement contains an order.
Expand Down Expand Up @@ -717,6 +719,16 @@ export interface StatefulOrderEventV1_LongTermOrderPlacementV1 {
export interface StatefulOrderEventV1_LongTermOrderPlacementV1SDKType {
order?: IndexerOrderSDKType;
}
/** A long term order placement contains an order. */

export interface StatefulOrderEventV1_LongTermOrderReplacementV1 {
order?: IndexerOrder;
}
/** A long term order placement contains an order. */

export interface StatefulOrderEventV1_LongTermOrderReplacementV1SDKType {
order?: IndexerOrderSDKType;
}
/**
* AssetCreateEventV1 message contains all the information about an new Asset on
* the dYdX chain.
Expand Down Expand Up @@ -2395,7 +2407,8 @@ function createBaseStatefulOrderEventV1(): StatefulOrderEventV1 {
orderRemoval: undefined,
conditionalOrderPlacement: undefined,
conditionalOrderTriggered: undefined,
longTermOrderPlacement: undefined
longTermOrderPlacement: undefined,
orderReplace: undefined
};
}

Expand All @@ -2421,6 +2434,10 @@ export const StatefulOrderEventV1 = {
StatefulOrderEventV1_LongTermOrderPlacementV1.encode(message.longTermOrderPlacement, writer.uint32(58).fork()).ldelim();
}

if (message.orderReplace !== undefined) {
StatefulOrderEventV1_LongTermOrderReplacementV1.encode(message.orderReplace, writer.uint32(66).fork()).ldelim();
}

return writer;
},

Expand Down Expand Up @@ -2453,6 +2470,10 @@ export const StatefulOrderEventV1 = {
message.longTermOrderPlacement = StatefulOrderEventV1_LongTermOrderPlacementV1.decode(reader, reader.uint32());
break;

case 8:
message.orderReplace = StatefulOrderEventV1_LongTermOrderReplacementV1.decode(reader, reader.uint32());
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -2469,6 +2490,7 @@ export const StatefulOrderEventV1 = {
message.conditionalOrderPlacement = object.conditionalOrderPlacement !== undefined && object.conditionalOrderPlacement !== null ? StatefulOrderEventV1_ConditionalOrderPlacementV1.fromPartial(object.conditionalOrderPlacement) : undefined;
message.conditionalOrderTriggered = object.conditionalOrderTriggered !== undefined && object.conditionalOrderTriggered !== null ? StatefulOrderEventV1_ConditionalOrderTriggeredV1.fromPartial(object.conditionalOrderTriggered) : undefined;
message.longTermOrderPlacement = object.longTermOrderPlacement !== undefined && object.longTermOrderPlacement !== null ? StatefulOrderEventV1_LongTermOrderPlacementV1.fromPartial(object.longTermOrderPlacement) : undefined;
message.orderReplace = object.orderReplace !== undefined && object.orderReplace !== null ? StatefulOrderEventV1_LongTermOrderReplacementV1.fromPartial(object.orderReplace) : undefined;
return message;
}

Expand Down Expand Up @@ -2709,6 +2731,51 @@ export const StatefulOrderEventV1_LongTermOrderPlacementV1 = {

};

function createBaseStatefulOrderEventV1_LongTermOrderReplacementV1(): StatefulOrderEventV1_LongTermOrderReplacementV1 {
return {
order: undefined
};
}

export const StatefulOrderEventV1_LongTermOrderReplacementV1 = {
encode(message: StatefulOrderEventV1_LongTermOrderReplacementV1, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.order !== undefined) {
IndexerOrder.encode(message.order, writer.uint32(10).fork()).ldelim();
}

return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): StatefulOrderEventV1_LongTermOrderReplacementV1 {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseStatefulOrderEventV1_LongTermOrderReplacementV1();

while (reader.pos < end) {
const tag = reader.uint32();

switch (tag >>> 3) {
case 1:
message.order = IndexerOrder.decode(reader, reader.uint32());
break;

default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(object: DeepPartial<StatefulOrderEventV1_LongTermOrderReplacementV1>): StatefulOrderEventV1_LongTermOrderReplacementV1 {
const message = createBaseStatefulOrderEventV1_LongTermOrderReplacementV1();
message.order = object.order !== undefined && object.order !== null ? IndexerOrder.fromPartial(object.order) : undefined;
return message;
}

};

function createBaseAssetCreateEventV1(): AssetCreateEventV1 {
return {
id: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,20 @@ export interface OrderUpdateV1SDKType {
order_id?: IndexerOrderIdSDKType;
total_filled_quantums: Long;
}
/** OrderReplace messages contain the replacement order. */

export interface OrderReplaceV1 {
order?: IndexerOrder;
placementStatus: OrderPlaceV1_OrderPlacementStatus;
timeStamp?: Date;
}
/** OrderReplace messages contain the replacement order. */

export interface OrderReplaceV1SDKType {
order?: IndexerOrderSDKType;
placement_status: OrderPlaceV1_OrderPlacementStatusSDKType;
time_stamp?: Date;
}
/**
* An OffChainUpdate message is the message type which will be sent on Kafka to
* the Indexer.
Expand All @@ -287,6 +301,7 @@ export interface OffChainUpdateV1 {
orderPlace?: OrderPlaceV1;
orderRemove?: OrderRemoveV1;
orderUpdate?: OrderUpdateV1;
orderReplace?: OrderReplaceV1;
}
/**
* An OffChainUpdate message is the message type which will be sent on Kafka to
Expand All @@ -297,6 +312,7 @@ export interface OffChainUpdateV1SDKType {
order_place?: OrderPlaceV1SDKType;
order_remove?: OrderRemoveV1SDKType;
order_update?: OrderUpdateV1SDKType;
order_replace?: OrderReplaceV1SDKType;
}

function createBaseOrderPlaceV1(): OrderPlaceV1 {
Expand Down Expand Up @@ -494,11 +510,77 @@ export const OrderUpdateV1 = {

};

function createBaseOrderReplaceV1(): OrderReplaceV1 {
return {
order: undefined,
placementStatus: 0,
timeStamp: undefined
};
}

export const OrderReplaceV1 = {
encode(message: OrderReplaceV1, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.order !== undefined) {
IndexerOrder.encode(message.order, writer.uint32(10).fork()).ldelim();
}

if (message.placementStatus !== 0) {
writer.uint32(16).int32(message.placementStatus);
}

if (message.timeStamp !== undefined) {
Timestamp.encode(toTimestamp(message.timeStamp), writer.uint32(26).fork()).ldelim();
}

return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): OrderReplaceV1 {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseOrderReplaceV1();

while (reader.pos < end) {
const tag = reader.uint32();

switch (tag >>> 3) {
case 1:
message.order = IndexerOrder.decode(reader, reader.uint32());
break;

case 2:
message.placementStatus = (reader.int32() as any);
break;

case 3:
message.timeStamp = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
break;

default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(object: DeepPartial<OrderReplaceV1>): OrderReplaceV1 {
const message = createBaseOrderReplaceV1();
message.order = object.order !== undefined && object.order !== null ? IndexerOrder.fromPartial(object.order) : undefined;
message.placementStatus = object.placementStatus ?? 0;
message.timeStamp = object.timeStamp ?? undefined;
return message;
}

};

function createBaseOffChainUpdateV1(): OffChainUpdateV1 {
return {
orderPlace: undefined,
orderRemove: undefined,
orderUpdate: undefined
orderUpdate: undefined,
orderReplace: undefined
};
}

Expand All @@ -516,6 +598,10 @@ export const OffChainUpdateV1 = {
OrderUpdateV1.encode(message.orderUpdate, writer.uint32(26).fork()).ldelim();
}

if (message.orderReplace !== undefined) {
OrderReplaceV1.encode(message.orderReplace, writer.uint32(34).fork()).ldelim();
}

return writer;
},

Expand All @@ -540,6 +626,10 @@ export const OffChainUpdateV1 = {
message.orderUpdate = OrderUpdateV1.decode(reader, reader.uint32());
break;

case 4:
message.orderReplace = OrderReplaceV1.decode(reader, reader.uint32());
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -554,6 +644,7 @@ export const OffChainUpdateV1 = {
message.orderPlace = object.orderPlace !== undefined && object.orderPlace !== null ? OrderPlaceV1.fromPartial(object.orderPlace) : undefined;
message.orderRemove = object.orderRemove !== undefined && object.orderRemove !== null ? OrderRemoveV1.fromPartial(object.orderRemove) : undefined;
message.orderUpdate = object.orderUpdate !== undefined && object.orderUpdate !== null ? OrderUpdateV1.fromPartial(object.orderUpdate) : undefined;
message.orderReplace = object.orderReplace !== undefined && object.orderReplace !== null ? OrderReplaceV1.fromPartial(object.orderReplace) : undefined;
return message;
}

Expand Down
6 changes: 6 additions & 0 deletions proto/dydxprotocol/indexer/events/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ message StatefulOrderEventV1 {
ConditionalOrderPlacementV1 conditional_order_placement = 5;
ConditionalOrderTriggeredV1 conditional_order_triggered = 6;
LongTermOrderPlacementV1 long_term_order_placement = 7;
LongTermOrderReplacementV1 order_replace = 8;
}

// A stateful order placement contains an order.
Expand Down Expand Up @@ -280,6 +281,11 @@ message StatefulOrderEventV1 {
message LongTermOrderPlacementV1 {
dydxprotocol.indexer.protocol.v1.IndexerOrder order = 1;
}

// A long term order placement contains an order.
message LongTermOrderReplacementV1 {
dydxprotocol.indexer.protocol.v1.IndexerOrder order = 1;
}
}

// AssetCreateEventV1 message contains all the information about an new Asset on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,25 @@ message OrderUpdateV1 {
uint64 total_filled_quantums = 2;
}

// OrderReplace messages contain the replacement order.
message OrderReplaceV1 {
dydxprotocol.indexer.protocol.v1.IndexerOrder order = 1;
dydxprotocol.indexer.off_chain_updates.OrderPlaceV1.OrderPlacementStatus
placement_status = 2;

google.protobuf.Timestamp time_stamp = 3
[ (gogoproto.nullable) = true, (gogoproto.stdtime) = true ];
}

// An OffChainUpdate message is the message type which will be sent on Kafka to
// the Indexer.
message OffChainUpdateV1 {
// Contains one of an OrderPlaceV1, OrderRemoveV1, and OrderUpdateV1 message.
// Contains one of an OrderPlaceV1, OrderRemoveV1, OrderUpdateV1, and
// OrderReplaceV1 message.
oneof update_message {
OrderPlaceV1 order_place = 1;
OrderRemoveV1 order_remove = 2;
OrderUpdateV1 order_update = 3;
OrderReplaceV1 order_replace = 4;
}
}
Loading

0 comments on commit 722ec24

Please sign in to comment.