diff --git a/x/market/keeper/keeper.go b/x/market/keeper/keeper.go index 92748408..0fffcf98 100644 --- a/x/market/keeper/keeper.go +++ b/x/market/keeper/keeper.go @@ -282,7 +282,7 @@ func (k *Keeper) NewOrderSingle(ctx sdk.Context, aggressiveOrder types.Order) (* panic(err) } - types.EmitFillEvent(ctx, *passiveOrder, stepSourceFilled.RoundInt(), stepDestinationFilled.RoundInt()) + types.EmitFillEvent(ctx, *passiveOrder, false, stepSourceFilled.RoundInt(), stepDestinationFilled.RoundInt()) if passiveOrder.IsFilled() { k.deleteOrder(ctx, passiveOrder) @@ -298,7 +298,7 @@ func (k *Keeper) NewOrderSingle(ctx sdk.Context, aggressiveOrder types.Order) (* stepDestinationFilled = stepSourceFilled } - types.EmitFillEvent(ctx, aggressiveOrder, aggressiveSourceFilled, aggressiveDestinationFilled) + types.EmitFillEvent(ctx, aggressiveOrder, true, aggressiveSourceFilled, aggressiveDestinationFilled) if aggressiveOrder.IsFilled() { break } diff --git a/x/market/spec/03_events.md b/x/market/spec/03_events.md index 6d80a77f..44c8154a 100644 --- a/x/market/spec/03_events.md +++ b/x/market/spec/03_events.md @@ -54,10 +54,11 @@ average_fill_price = destination_filled / source_filled | market | order_id | {uniqueOrderId} | | market | owner | {ownerAddress} | | market | client_order_id | {clientOrderId} | +| market | aggressive | {aggressive} | | market | source_filled | {sourceFilledAmount} | | market | destination_filled | {destinationFilledAmount} | -When the market module executes a trade, the orders on each side of the trade receive a fill event. +When the market module executes a trade, the orders on each side of the trade receive a fill event. The order that initiated the trade will have `aggressive` set to true. Both `source_filled` and `destination_filled` are specific to a single trade, i.e. in contrast to the [Order Expired](#order-expired) event they are non-cumulative. diff --git a/x/market/types/events.go b/x/market/types/events.go index 7a59b949..c5e9bd64 100644 --- a/x/market/types/events.go +++ b/x/market/types/events.go @@ -6,6 +6,7 @@ package types import ( "fmt" + "strconv" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -24,6 +25,7 @@ const ( AttributeKeySourceFilled = "source_filled" AttributeKeyDestination = "destination" AttributeKeyDestinationFilled = "destination_filled" + AttributeKeyAggressive = "aggressive" ) func EmitAcceptEvent(ctx sdk.Context, order Order) { @@ -55,13 +57,14 @@ func EmitExpireEvent(ctx sdk.Context, order Order) { ) } -func EmitFillEvent(ctx sdk.Context, order Order, sourceFilled sdk.Int, destinationFilled sdk.Int) { +func EmitFillEvent(ctx sdk.Context, order Order, aggressive bool, sourceFilled sdk.Int, destinationFilled sdk.Int) { ctx.EventManager().EmitEvent( sdk.NewEvent(EventTypeMarket, sdk.NewAttribute(AttributeKeyAction, "fill"), sdk.NewAttribute(AttributeKeyOrderID, fmt.Sprintf("%d", order.ID)), sdk.NewAttribute(AttributeKeyOwner, order.Owner.String()), sdk.NewAttribute(AttributeKeyClientOrderID, order.ClientOrderID), + sdk.NewAttribute(AttributeKeyAggressive, strconv.FormatBool(aggressive)), sdk.NewAttribute(AttributeKeySourceFilled, fmt.Sprintf("%v%v", sourceFilled.String(), order.Source.Denom)), sdk.NewAttribute(AttributeKeyDestinationFilled, fmt.Sprintf("%v%v", destinationFilled.String(), order.Destination.Denom)), ),