Skip to content

Commit

Permalink
[1658]: Add the market id to severl order-related events.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpicyLemon committed Oct 13, 2023
1 parent 6a5d479 commit d1373c0
Show file tree
Hide file tree
Showing 5 changed files with 303 additions and 61 deletions.
5 changes: 5 additions & 0 deletions docs/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,7 @@ EventOrderCancelled is an event emitted when an order is cancelled.
| ----- | ---- | ----- | ----------- |
| `order_id` | [uint64](#uint64) | | order_id is the numerical identifier of the order cancelled. |
| `cancelled_by` | [string](#string) | | cancelled_by is the account that triggered the cancellation of the order. |
| `market_id` | [uint32](#uint32) | | market_id is the numerical identifier of the market. |
| `external_id` | [string](#string) | | external_id is the order's external id. |


Expand All @@ -1546,6 +1547,7 @@ EventOrderCreated is an event emitted when an order is created.
| ----- | ---- | ----- | ----------- |
| `order_id` | [uint64](#uint64) | | order_id is the numerical identifier of the order created. |
| `order_type` | [string](#string) | | order_type is the type of order, e.g. "ask" or "bid". |
| `market_id` | [uint32](#uint32) | | market_id is the numerical identifier of the market. |
| `external_id` | [string](#string) | | external_id is the order's external id. |


Expand All @@ -1562,6 +1564,7 @@ EventOrderExternalIDUpdated is an event emitted when an order's external id is u
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `order_id` | [uint64](#uint64) | | order_id is the numerical identifier of the order partially filled. |
| `market_id` | [uint32](#uint32) | | market_id is the numerical identifier of the market. |
| `external_id` | [string](#string) | | external_id is the order's new external id. |


Expand All @@ -1582,6 +1585,7 @@ This event is also used for orders that were previously partially filled, but ha
| `assets` | [string](#string) | | assets is the coins amount string of assets bought/sold for this order. |
| `price` | [string](#string) | | price is the coins amount string of the price payed/received for this order. |
| `fees` | [string](#string) | | fees is the coins amount string of settlement fees paid with this order. |
| `market_id` | [uint32](#uint32) | | market_id is the numerical identifier of the market. |
| `external_id` | [string](#string) | | external_id is the order's external id. |


Expand All @@ -1601,6 +1605,7 @@ EventOrderPartiallyFilled is an event emitted when an order filled in part and s
| `assets` | [string](#string) | | assets is the coins amount string of assets that were filled and removed from the order. |
| `price` | [string](#string) | | price is the coins amount string of the price payed/received for this order. For ask orders, this might be more than the amount that was removed from the order's price. |
| `fees` | [string](#string) | | fees is the coins amount string of settlement fees paid with this partial order. For ask orders, this might be more than the amount that was removed from the order's settlement fees. |
| `market_id` | [uint32](#uint32) | | market_id is the numerical identifier of the market. |
| `external_id` | [string](#string) | | external_id is the order's external id. |


Expand Down
18 changes: 14 additions & 4 deletions proto/provenance/exchange/v1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ message EventOrderCreated {
uint64 order_id = 1;
// order_type is the type of order, e.g. "ask" or "bid".
string order_type = 2;
// market_id is the numerical identifier of the market.
uint32 market_id = 3;
// external_id is the order's external id.
string external_id = 3;
string external_id = 4;
}

// EventOrderCancelled is an event emitted when an order is cancelled.
Expand All @@ -24,8 +26,10 @@ message EventOrderCancelled {
uint64 order_id = 1;
// cancelled_by is the account that triggered the cancellation of the order.
string cancelled_by = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// market_id is the numerical identifier of the market.
uint32 market_id = 3;
// external_id is the order's external id.
string external_id = 3;
string external_id = 4;
}

// EventOrderFilled is an event emitted when an order has been filled in full.
Expand All @@ -39,8 +43,10 @@ message EventOrderFilled {
string price = 3;
// fees is the coins amount string of settlement fees paid with this order.
string fees = 4;
// market_id is the numerical identifier of the market.
uint32 market_id = 5;
// external_id is the order's external id.
string external_id = 5;
string external_id = 6;
}

// EventOrderPartiallyFilled is an event emitted when an order filled in part and still has more left to fill.
Expand All @@ -55,14 +61,18 @@ message EventOrderPartiallyFilled {
// fees is the coins amount string of settlement fees paid with this partial order.
// For ask orders, this might be more than the amount that was removed from the order's settlement fees.
string fees = 4;
// market_id is the numerical identifier of the market.
uint32 market_id = 5;
// external_id is the order's external id.
string external_id = 5;
string external_id = 6;
}

// EventOrderExternalIDUpdated is an event emitted when an order's external id is updated.
message EventOrderExternalIDUpdated {
// order_id is the numerical identifier of the order partially filled.
uint64 order_id = 1;
// market_id is the numerical identifier of the market.
uint32 market_id = 2;
// external_id is the order's new external id.
string external_id = 3;
}
Expand Down
5 changes: 5 additions & 0 deletions x/exchange/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ func NewEventOrderCreated(order OrderI) *EventOrderCreated {
return &EventOrderCreated{
OrderId: order.GetOrderID(),
OrderType: order.GetOrderType(),
MarketId: order.GetMarketID(),
ExternalId: order.GetExternalID(),
}
}
Expand All @@ -18,6 +19,7 @@ func NewEventOrderCancelled(order OrderI, cancelledBy sdk.AccAddress) *EventOrde
return &EventOrderCancelled{
OrderId: order.GetOrderID(),
CancelledBy: cancelledBy.String(),
MarketId: order.GetMarketID(),
ExternalId: order.GetExternalID(),
}
}
Expand All @@ -28,6 +30,7 @@ func NewEventOrderFilled(order OrderI) *EventOrderFilled {
Assets: order.GetAssets().String(),
Price: order.GetPrice().String(),
Fees: order.GetSettlementFees().String(),
MarketId: order.GetMarketID(),
ExternalId: order.GetExternalID(),
}
}
Expand All @@ -38,13 +41,15 @@ func NewEventOrderPartiallyFilled(order OrderI) *EventOrderPartiallyFilled {
Assets: order.GetAssets().String(),
Price: order.GetPrice().String(),
Fees: order.GetSettlementFees().String(),
MarketId: order.GetMarketID(),
ExternalId: order.GetExternalID(),
}
}

func NewEventOrderExternalIDUpdated(order OrderI) *EventOrderExternalIDUpdated {
return &EventOrderExternalIDUpdated{
OrderId: order.GetOrderID(),
MarketId: order.GetMarketID(),
ExternalId: order.GetExternalID(),
}
}
Expand Down
Loading

0 comments on commit d1373c0

Please sign in to comment.