Skip to content

Commit

Permalink
add custom recipient field for amm module
Browse files Browse the repository at this point in the history
  • Loading branch information
jelysn committed Nov 27, 2023
1 parent 6335130 commit fe1904b
Show file tree
Hide file tree
Showing 25 changed files with 248 additions and 148 deletions.
7 changes: 4 additions & 3 deletions proto/elys/amm/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ message MsgSwapExactAmountIn {
cosmos.base.v1beta1.Coin token_in = 3 [(gogoproto.nullable) = false ] ;
string token_out_min_amount = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string discount = 5 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];

string recipient = 6;
}

message MsgSwapExactAmountInResponse {
string token_out_amount = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string discount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
string discount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
}

message MsgSwapExactAmountOut {
Expand All @@ -77,11 +77,12 @@ message MsgSwapExactAmountOut {
cosmos.base.v1beta1.Coin token_out = 3 [(gogoproto.nullable) = false ] ;
string token_in_max_amount = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string discount = 5 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
string recipient = 6;
}

message MsgSwapExactAmountOutResponse {
string token_in_amount = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string discount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
string discount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
}

message MsgFeedMultipleExternalLiquidity {
Expand Down
7 changes: 5 additions & 2 deletions x/amm/client/cli/tx_swap_exact_amount_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ var _ = strconv.Itoa(0)

func CmdSwapExactAmountIn() *cobra.Command {
cmd := &cobra.Command{
Use: "swap-exact-amount-in [token-in] [token-out-min-amount] [swap-route-pool-ids] [swap-route-denoms]",
Use: "swap-exact-amount-in [token-in] [token-out-min-amount] [swap-route-pool-ids] [swap-route-denoms] [recipient]",
Short: "Swap an exact amount of tokens for a minimum of another token, similar to swapping a token on the trade screen GUI.",
Example: `elysd tx amm swap-exact-amount-in 100000uusdc 10000 0 uatom --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000`,
Args: cobra.ExactArgs(4),
Args: cobra.ExactArgs(5),
RunE: func(cmd *cobra.Command, args []string) (err error) {
argTokenIn, err := sdk.ParseCoinNormalized(args[0])
if err != nil {
Expand Down Expand Up @@ -53,13 +53,16 @@ func CmdSwapExactAmountIn() *cobra.Command {
return err
}

argRecipient := args[4]

clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

msg := types.NewMsgSwapExactAmountIn(
clientCtx.GetFromAddress().String(),
argRecipient,
argTokenIn,
argTokenOutMinAmount,
argSwapRoutePoolIds,
Expand Down
7 changes: 5 additions & 2 deletions x/amm/client/cli/tx_swap_exact_amount_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ var _ = strconv.Itoa(0)

func CmdSwapExactAmountOut() *cobra.Command {
cmd := &cobra.Command{
Use: "swap-exact-amount-out [token-out] [token-out-max-amount] [swap-route-pool-ids] [swap-route-denoms]",
Use: "swap-exact-amount-out [token-out] [token-out-max-amount] [swap-route-pool-ids] [swap-route-denoms] [recipient]",
Short: "Swap a maximum amount of tokens for an exact amount of another token, similar to swapping a token on the trade screen GUI.",
Example: `elysd tx amm swap-exact-amount-out 100000uatom 200000 0 uusdc --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000`,
Args: cobra.ExactArgs(4),
Args: cobra.ExactArgs(5),
RunE: func(cmd *cobra.Command, args []string) (err error) {
argTokenOut, err := sdk.ParseCoinNormalized(args[0])
if err != nil {
Expand Down Expand Up @@ -53,13 +53,16 @@ func CmdSwapExactAmountOut() *cobra.Command {
return err
}

argRecipient := args[4]

clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

msg := types.NewMsgSwapExactAmountOut(
clientCtx.GetFromAddress().String(),
argRecipient,
argTokenOut,
argTokenOutMaxAmount,
argSwapRoutePoolIds,
Expand Down
12 changes: 10 additions & 2 deletions x/amm/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ func (k Keeper) ApplySwapRequest(ctx sdk.Context, msg sdk.Msg) error {
if err != nil {
return err
}
_, err = k.RouteExactAmountIn(ctx, sender, msg.Routes, msg.TokenIn, math.Int(msg.TokenOutMinAmount), msg.Discount)
recipient, err := sdk.AccAddressFromBech32(msg.Recipient)
if err != nil {
recipient = sender
}
_, err = k.RouteExactAmountIn(ctx, sender, recipient, msg.Routes, msg.TokenIn, math.Int(msg.TokenOutMinAmount), msg.Discount)
if err != nil {
return err
}
Expand All @@ -38,7 +42,11 @@ func (k Keeper) ApplySwapRequest(ctx sdk.Context, msg sdk.Msg) error {
if err != nil {
return err
}
_, err = k.RouteExactAmountOut(ctx, sender, msg.Routes, msg.TokenInMaxAmount, msg.TokenOut, msg.Discount)
recipient, err := sdk.AccAddressFromBech32(msg.Recipient)
if err != nil {
recipient = sender
}
_, err = k.RouteExactAmountOut(ctx, sender, recipient, msg.Routes, msg.TokenInMaxAmount, msg.TokenOut, msg.Discount)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion x/amm/keeper/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (k Keeper) SwapFeesToRevenueToken(ctx sdk.Context, pool types.Pool, fee sdk

// Settles balances between the tx sender and the pool to match the swap that was executed earlier.
// Also emits a swap event and updates related liquidity metrics.
err, _ = k.UpdatePoolForSwap(ctx, pool, poolRevenueAddress, tokenIn, tokenOutCoin, sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec())
err, _ = k.UpdatePoolForSwap(ctx, pool, poolRevenueAddress, poolRevenueAddress, tokenIn, tokenOutCoin, sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec())
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion x/amm/keeper/keeper_swap_exact_amount_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
func (k Keeper) SwapExactAmountIn(
ctx sdk.Context,
sender sdk.AccAddress,
recipient sdk.AccAddress,
pool types.Pool,
tokenIn sdk.Coin,
tokenOutDenom string,
Expand Down Expand Up @@ -61,7 +62,7 @@ func (k Keeper) SwapExactAmountIn(

// Settles balances between the tx sender and the pool to match the swap that was executed earlier.
// Also emits a swap event and updates related liquidity metrics.
err, swapOutFee := k.UpdatePoolForSwap(ctx, pool, sender, tokenIn, tokenOutCoin, sdk.ZeroDec(), swapFee, weightBalanceBonus)
err, swapOutFee := k.UpdatePoolForSwap(ctx, pool, sender, recipient, tokenIn, tokenOutCoin, sdk.ZeroDec(), swapFee, weightBalanceBonus)
if err != nil {
return math.Int{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion x/amm/keeper/keeper_swap_exact_amount_in_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (suite *KeeperTestSuite) TestSwapExactAmountIn() {
TotalWeight: sdk.ZeroInt(),
}

tokenOut, err := suite.app.AmmKeeper.SwapExactAmountIn(suite.ctx, sender, pool, tc.tokenIn, tc.tokenOut.Denom, tc.tokenOutMin, tc.swapFeeIn)
tokenOut, err := suite.app.AmmKeeper.SwapExactAmountIn(suite.ctx, sender, sender, pool, tc.tokenIn, tc.tokenOut.Denom, tc.tokenOutMin, tc.swapFeeIn)
if !tc.expPass {
suite.Require().Error(err)
} else {
Expand Down
3 changes: 2 additions & 1 deletion x/amm/keeper/keeper_swap_exact_amount_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
func (k Keeper) SwapExactAmountOut(
ctx sdk.Context,
sender sdk.AccAddress,
recipient sdk.AccAddress,
pool types.Pool,
tokenInDenom string,
tokenInMaxAmount math.Int,
Expand Down Expand Up @@ -54,7 +55,7 @@ func (k Keeper) SwapExactAmountOut(
return math.Int{}, sdkerrors.Wrapf(types.ErrLimitMaxAmount, "swap requires %s, which is greater than the amount %s", tokenIn, tokenInMaxAmount)
}

err, _ = k.UpdatePoolForSwap(ctx, pool, sender, tokenIn, tokenOut, swapFee, sdk.ZeroDec(), weightBalanceBonus)
err, _ = k.UpdatePoolForSwap(ctx, pool, sender, recipient, tokenIn, tokenOut, swapFee, sdk.ZeroDec(), weightBalanceBonus)
if err != nil {
return math.Int{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion x/amm/keeper/keeper_swap_exact_amount_out_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (suite *KeeperTestSuite) TestSwapExactAmountOut() {
TotalWeight: sdk.ZeroInt(),
}

tokenInAmount, err := suite.app.AmmKeeper.SwapExactAmountOut(suite.ctx, sender, pool, tc.tokenIn.Denom, tc.tokenInMax, tc.tokenOut, tc.swapFeeOut)
tokenInAmount, err := suite.app.AmmKeeper.SwapExactAmountOut(suite.ctx, sender, sender, pool, tc.tokenIn.Denom, tc.tokenInMax, tc.tokenOut, tc.swapFeeOut)
if !tc.expPass {
suite.Require().Error(err)
} else {
Expand Down
6 changes: 5 additions & 1 deletion x/amm/keeper/msg_server_swap_exact_amount_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ func (k msgServer) SwapExactAmountIn(goCtx context.Context, msg *types.MsgSwapEx
return nil, err
}

recipient, err := sdk.AccAddressFromBech32(msg.Recipient)
if err != nil {
recipient = sender
}
// Try executing the tx on cached context environment, to filter invalid transactions out
cacheCtx, _ := ctx.CacheContext()
tokenOutAmount, err := k.RouteExactAmountIn(cacheCtx, sender, msg.Routes, msg.TokenIn, math.Int(msg.TokenOutMinAmount), msg.Discount)
tokenOutAmount, err := k.RouteExactAmountIn(cacheCtx, sender, recipient, msg.Routes, msg.TokenIn, math.Int(msg.TokenOutMinAmount), msg.Discount)
if err != nil {
return nil, err
}
Expand Down
7 changes: 5 additions & 2 deletions x/amm/keeper/msg_server_swap_exact_amount_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ func (k msgServer) SwapExactAmountOut(goCtx context.Context, msg *types.MsgSwapE
if err != nil {
return nil, err
}

recipient, err := sdk.AccAddressFromBech32(msg.Recipient)
if err != nil {
recipient = sender
}
// Try executing the tx on cached context environment, to filter invalid transactions out
cacheCtx, _ := ctx.CacheContext()
tokenInAmount, err := k.RouteExactAmountOut(cacheCtx, sender, msg.Routes, msg.TokenInMaxAmount, msg.TokenOut, msg.Discount)
tokenInAmount, err := k.RouteExactAmountOut(cacheCtx, sender, recipient, msg.Routes, msg.TokenInMaxAmount, msg.TokenOut, msg.Discount)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion x/amm/keeper/route_exact_amount_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
func (k Keeper) RouteExactAmountIn(
ctx sdk.Context,
sender sdk.AccAddress,
recipient sdk.AccAddress,
routes []types.SwapAmountInRoute,
tokenIn sdk.Coin,
tokenOutMinAmount math.Int,
Expand Down Expand Up @@ -79,7 +80,7 @@ func (k Keeper) RouteExactAmountIn(
return math.Int{}, err
}

tokenOutAmount, err = k.SwapExactAmountIn(ctx, sender, pool, tokenIn, route.TokenOutDenom, _outMinAmount, swapFee)
tokenOutAmount, err = k.SwapExactAmountIn(ctx, sender, recipient, pool, tokenIn, route.TokenOutDenom, _outMinAmount, swapFee)
if err != nil {
ctx.Logger().Error(err.Error())
return math.Int{}, err
Expand Down
1 change: 1 addition & 0 deletions x/amm/keeper/route_exact_amount_in_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ func (suite *KeeperTestSuite) TestRouteExactAmountIn() {
tokenOut, err := suite.app.AmmKeeper.RouteExactAmountIn(
suite.ctx,
sender,
sender,
[]types.SwapAmountInRoute{
{
PoolId: 1,
Expand Down
3 changes: 2 additions & 1 deletion x/amm/keeper/route_exact_amount_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
// Transaction succeeds if the calculated tokenInAmount of the first pool is less than the defined tokenInMaxAmount defined.
func (k Keeper) RouteExactAmountOut(ctx sdk.Context,
sender sdk.AccAddress,
recipient sdk.AccAddress,
routes []types.SwapAmountOutRoute,
tokenInMaxAmount math.Int,
tokenOut sdk.Coin,
Expand Down Expand Up @@ -100,7 +101,7 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context,
return math.Int{}, err
}

_tokenInAmount, swapErr := k.SwapExactAmountOut(ctx, sender, pool, route.TokenInDenom, insExpected[i], _tokenOut, swapFee)
_tokenInAmount, swapErr := k.SwapExactAmountOut(ctx, sender, recipient, pool, route.TokenInDenom, insExpected[i], _tokenOut, swapFee)
if swapErr != nil {
return math.Int{}, swapErr
}
Expand Down
2 changes: 1 addition & 1 deletion x/amm/keeper/route_exact_amount_out_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (suite *KeeperTestSuite) TestRouteExactAmountOut() {
// TODO: add invalid route case
// TODO: add Elys token involved route case
tokenInAmount, err := suite.app.AmmKeeper.RouteExactAmountOut(
suite.ctx, sender, []types.SwapAmountOutRoute{
suite.ctx, sender, sender, []types.SwapAmountOutRoute{
{
PoolId: pool.PoolId,
TokenInDenom: tc.tokenIn.Denom,
Expand Down
12 changes: 7 additions & 5 deletions x/amm/keeper/update_pool_for_swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func (k Keeper) UpdatePoolForSwap(
ctx sdk.Context,
pool types.Pool,
sender sdk.AccAddress,
recipient sdk.AccAddress,
tokenIn sdk.Coin,
tokenOut sdk.Coin,
swapFeeIn sdk.Dec,
Expand Down Expand Up @@ -50,7 +51,8 @@ func (k Keeper) UpdatePoolForSwap(
}
}

err = k.bankKeeper.SendCoins(ctx, poolAddr, sender, sdk.Coins{tokenOut})
// Send coins to recipient
err = k.bankKeeper.SendCoins(ctx, poolAddr, recipient, sdk.Coins{tokenOut})
if err != nil {
return err, sdk.ZeroInt()
}
Expand All @@ -62,7 +64,7 @@ func (k Keeper) UpdatePoolForSwap(
}
if swapFeeOutCoins.IsAllPositive() {
rebalanceTreasury := sdk.MustAccAddressFromBech32(pool.GetRebalanceTreasury())
err = k.bankKeeper.SendCoins(ctx, sender, rebalanceTreasury, swapFeeOutCoins)
err = k.bankKeeper.SendCoins(ctx, recipient, rebalanceTreasury, swapFeeOutCoins)
if err != nil {
return err, sdk.ZeroInt()
}
Expand All @@ -82,16 +84,16 @@ func (k Keeper) UpdatePoolForSwap(
bonusTokenAmount = treasuryTokenAmount
}

// send bonus tokens to sender if positive
// send bonus tokens to recipient if positive
if weightBalanceBonus.IsPositive() && bonusTokenAmount.IsPositive() {
bonusToken := sdk.NewCoin(tokenOut.Denom, bonusTokenAmount)
err = k.bankKeeper.SendCoins(ctx, rebalanceTreasuryAddr, sender, sdk.Coins{bonusToken})
err = k.bankKeeper.SendCoins(ctx, rebalanceTreasuryAddr, recipient, sdk.Coins{bonusToken})
if err != nil {
return err, sdk.ZeroInt()
}
}

types.EmitSwapEvent(ctx, sender, pool.GetPoolId(), tokensIn, tokensOut)
types.EmitSwapEvent(ctx, sender, recipient, pool.GetPoolId(), tokensIn, tokensOut)
if k.hooks != nil {
k.hooks.AfterSwap(ctx, sender, pool, tokensIn, tokensOut)
}
Expand Down
2 changes: 1 addition & 1 deletion x/amm/keeper/update_pool_for_swap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (suite *KeeperTestSuite) TestUpdatePoolForSwap() {
},
TotalWeight: sdk.ZeroInt(),
}
err, _ = suite.app.AmmKeeper.UpdatePoolForSwap(suite.ctx, pool, sender, tc.tokenIn, tc.tokenOut, tc.swapFeeIn, tc.swapFeeOut, tc.weightBalanceBonus)
err, _ = suite.app.AmmKeeper.UpdatePoolForSwap(suite.ctx, pool, sender, sender, tc.tokenIn, tc.tokenOut, tc.swapFeeIn, tc.swapFeeOut, tc.weightBalanceBonus)
if !tc.expPass {
suite.Require().Error(err)
} else {
Expand Down
8 changes: 5 additions & 3 deletions x/amm/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ const (
AttributeKeyPoolId = "pool_id"
AttributeKeyTokensIn = "tokens_in"
AttributeKeyTokensOut = "tokens_out"
AttributeKeyRecipient = "recipient"
)

func EmitSwapEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) {
func EmitSwapEvent(ctx sdk.Context, sender, recipient sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) {
ctx.EventManager().EmitEvents(sdk.Events{
NewSwapEvent(sender, poolId, input, output),
NewSwapEvent(sender, recipient, poolId, input, output),
})
}

Expand All @@ -36,11 +37,12 @@ func EmitRemoveLiquidityEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uin
})
}

func NewSwapEvent(sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) sdk.Event {
func NewSwapEvent(sender, recipient sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) sdk.Event {
return sdk.NewEvent(
TypeEvtTokenSwapped,
sdk.NewAttribute(sdk.AttributeKeyModule, AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeySender, sender.String()),
sdk.NewAttribute(AttributeKeyRecipient, recipient.String()),
sdk.NewAttribute(AttributeKeyPoolId, strconv.FormatUint(poolId, 10)),
sdk.NewAttribute(AttributeKeyTokensIn, input.String()),
sdk.NewAttribute(AttributeKeyTokensOut, output.String()),
Expand Down
3 changes: 2 additions & 1 deletion x/amm/types/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ func TestEvents(t *testing.T) {
input := sdk.NewCoins(sdk.NewInt64Coin("token1", 100))
output := sdk.NewCoins(sdk.NewInt64Coin("token2", 50))

swapEvent := types.NewSwapEvent(sender, poolID, input, output)
swapEvent := types.NewSwapEvent(sender, sender, poolID, input, output)
expectedSwapEvent := sdk.NewEvent(
types.TypeEvtTokenSwapped,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeySender, sender.String()),
sdk.NewAttribute(types.AttributeKeyRecipient, sender.String()),
sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(poolID, 10)),
sdk.NewAttribute(types.AttributeKeyTokensIn, input.String()),
sdk.NewAttribute(types.AttributeKeyTokensOut, output.String()),
Expand Down
3 changes: 2 additions & 1 deletion x/amm/types/message_swap_exact_amount_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const TypeMsgSwapExactAmountIn = "swap_exact_amount_in"

var _ sdk.Msg = &MsgSwapExactAmountIn{}

func NewMsgSwapExactAmountIn(sender string, tokenIn sdk.Coin, tokenOutMinAmount math.Int, swapRoutePoolIds []uint64, swapRouteDenoms []string, discount sdk.Dec) *MsgSwapExactAmountIn {
func NewMsgSwapExactAmountIn(sender, recipient string, tokenIn sdk.Coin, tokenOutMinAmount math.Int, swapRoutePoolIds []uint64, swapRouteDenoms []string, discount sdk.Dec) *MsgSwapExactAmountIn {
if len(swapRoutePoolIds) != len(swapRouteDenoms) {
return nil // or raise an error as the input lists should have the same length
}
Expand All @@ -26,6 +26,7 @@ func NewMsgSwapExactAmountIn(sender string, tokenIn sdk.Coin, tokenOutMinAmount

return &MsgSwapExactAmountIn{
Sender: sender,
Recipient: recipient,
Routes: routes,
TokenIn: tokenIn,
TokenOutMinAmount: tokenOutMinAmount,
Expand Down
3 changes: 2 additions & 1 deletion x/amm/types/message_swap_exact_amount_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const TypeMsgSwapExactAmountOut = "swap_exact_amount_out"

var _ sdk.Msg = &MsgSwapExactAmountOut{}

func NewMsgSwapExactAmountOut(sender string, tokenOut sdk.Coin, tokenInMaxAmount math.Int, swapRoutePoolIds []uint64, swapRouteDenoms []string, discount sdk.Dec) *MsgSwapExactAmountOut {
func NewMsgSwapExactAmountOut(sender, recipient string, tokenOut sdk.Coin, tokenInMaxAmount math.Int, swapRoutePoolIds []uint64, swapRouteDenoms []string, discount sdk.Dec) *MsgSwapExactAmountOut {
if len(swapRoutePoolIds) != len(swapRouteDenoms) {
return nil // or raise an error as the input lists should have the same length
}
Expand All @@ -26,6 +26,7 @@ func NewMsgSwapExactAmountOut(sender string, tokenOut sdk.Coin, tokenInMaxAmount

return &MsgSwapExactAmountOut{
Sender: sender,
Recipient: recipient,
Routes: routes,
TokenOut: tokenOut,
TokenInMaxAmount: tokenInMaxAmount,
Expand Down
Loading

0 comments on commit fe1904b

Please sign in to comment.