Skip to content

Commit

Permalink
Merge branch 'release/v0.9.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
mdyring committed Oct 31, 2020
2 parents 71706f2 + c1c2c54 commit 192018b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions x/market/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion x/market/spec/03_events.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
5 changes: 4 additions & 1 deletion x/market/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package types

import (
"fmt"
"strconv"

sdk "github.com/cosmos/cosmos-sdk/types"
)
Expand All @@ -24,6 +25,7 @@ const (
AttributeKeySourceFilled = "source_filled"
AttributeKeyDestination = "destination"
AttributeKeyDestinationFilled = "destination_filled"
AttributeKeyAggressive = "aggressive"
)

func EmitAcceptEvent(ctx sdk.Context, order Order) {
Expand Down Expand Up @@ -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)),
),
Expand Down

0 comments on commit 192018b

Please sign in to comment.