Skip to content

Commit

Permalink
Enhance CreateSpotOrder to emit events and return OrderId on market b… (
Browse files Browse the repository at this point in the history
#1045)

Enhance CreateSpotOrder to emit events and return OrderId on market buy execution

- Updated the CreateSpotOrder function to emit an event upon successful execution of a market buy order.
- Modified the response to include the OrderId of the pending spot order, improving the feedback provided to the user.
- These changes enhance the order processing flow and provide better tracking of executed orders.
  • Loading branch information
cosmic-vagabond authored Dec 8, 2024
1 parent 8adec66 commit 5a63e49
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions x/tradeshield/keeper/msg_server_spot_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ func (k msgServer) CreateSpotOrder(goCtx context.Context, msg *types.MsgCreateSp

// if the order is market buy, execute it immediately
if msg.OrderType == types.SpotOrderType_MARKETBUY {
_, err := k.ExecuteMarketBuyOrder(ctx, pendingSpotOrder)
res, err := k.ExecuteMarketBuyOrder(ctx, pendingSpotOrder)
if err != nil {
return nil, err
}
return &types.MsgCreateSpotOrderResponse{}, nil

ctx.EventManager().EmitEvent(types.NewExecuteSpotOrderEvt(pendingSpotOrder, res))

return &types.MsgCreateSpotOrderResponse{
OrderId: pendingSpotOrder.OrderId,
}, nil
}

// add the order to the pending orders
Expand Down

0 comments on commit 5a63e49

Please sign in to comment.