diff --git a/x/amm/client/cli/tx.go b/x/amm/client/cli/tx.go index d7540d077..e7256a93b 100644 --- a/x/amm/client/cli/tx.go +++ b/x/amm/client/cli/tx.go @@ -17,6 +17,7 @@ var ( const ( FlagDiscount = "discount" + FlagRecipient = "recipient" flagPacketTimeoutTimestamp = "packet-timeout-timestamp" listSeparator = "," ) diff --git a/x/amm/client/cli/tx_swap_by_denom.go b/x/amm/client/cli/tx_swap_by_denom.go index f309368ce..ace22572a 100644 --- a/x/amm/client/cli/tx_swap_by_denom.go +++ b/x/amm/client/cli/tx_swap_by_denom.go @@ -20,10 +20,10 @@ const ( func CmdSwapByDenom() *cobra.Command { cmd := &cobra.Command{ - Use: "swap-by-denom [amount] [denom-in] [denom-out] [recipient]", + Use: "swap-by-denom [amount] [denom-in] [denom-out]", Short: "Swap an exact amount of tokens for a minimum of another token or a maximum amount of tokens for an exact amount on another token, similar to swapping a token on the trade screen GUI.", Example: "elysd tx amm swap-by-denom 1000000000uatom uatom uusd --min-amount=1000000000uatom --max-amount=1000000000uatom --discount=0.1 --from jack --keyring-backend test", - Args: cobra.ExactArgs(4), + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) (err error) { argAmount, err := sdk.ParseCoinNormalized(args[0]) if err != nil { @@ -31,7 +31,6 @@ func CmdSwapByDenom() *cobra.Command { } argDenomIn := args[1] argDenomOut := args[2] - argRecipient := args[3] minAmountStr, err := cmd.Flags().GetString(FlagMinAmount) if err != nil { @@ -66,6 +65,11 @@ func CmdSwapByDenom() *cobra.Command { return err } + recipient, err := cmd.Flags().GetString(FlagRecipient) + if err != nil { + return err + } + clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err @@ -73,7 +77,7 @@ func CmdSwapByDenom() *cobra.Command { msg := types.NewMsgSwapByDenom( clientCtx.GetFromAddress().String(), - argRecipient, + recipient, argAmount, minAmount, maxAmount, @@ -93,6 +97,7 @@ func CmdSwapByDenom() *cobra.Command { cmd.Flags().String(FlagMinAmount, "", "minimum amount of tokens to receive") cmd.Flags().String(FlagMaxAmount, "", "maximum amount of tokens to send") cmd.Flags().String(FlagDiscount, "0.0", "discount to apply to the swap fee (only smart contract broker can apply the discount)") + cmd.Flags().String(FlagRecipient, "", "optional recipient field for the tokens swapped to be sent to") return cmd } diff --git a/x/amm/client/cli/tx_swap_exact_amount_in.go b/x/amm/client/cli/tx_swap_exact_amount_in.go index 6e09cf482..c8e89f96c 100644 --- a/x/amm/client/cli/tx_swap_exact_amount_in.go +++ b/x/amm/client/cli/tx_swap_exact_amount_in.go @@ -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] [recipient]", + Use: "swap-exact-amount-in [token-in] [token-out-min-amount] [swap-route-pool-ids] [swap-route-denoms]", 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(5), + Args: cobra.ExactArgs(4), RunE: func(cmd *cobra.Command, args []string) (err error) { argTokenIn, err := sdk.ParseCoinNormalized(args[0]) if err != nil { @@ -53,7 +53,10 @@ func CmdSwapExactAmountIn() *cobra.Command { return err } - argRecipient := args[4] + recipient, err := cmd.Flags().GetString(FlagRecipient) + if err != nil { + return err + } clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -62,7 +65,7 @@ func CmdSwapExactAmountIn() *cobra.Command { msg := types.NewMsgSwapExactAmountIn( clientCtx.GetFromAddress().String(), - argRecipient, + recipient, argTokenIn, argTokenOutMinAmount, argSwapRoutePoolIds, @@ -79,6 +82,7 @@ func CmdSwapExactAmountIn() *cobra.Command { flags.AddTxFlagsToCmd(cmd) cmd.Flags().String(FlagDiscount, "0.0", "discount to apply to the swap fee (only smart contract broker can apply the discount)") + cmd.Flags().String(FlagRecipient, "", "optional recipient field for the tokens swapped to be sent to") return cmd } diff --git a/x/amm/client/cli/tx_swap_exact_amount_out.go b/x/amm/client/cli/tx_swap_exact_amount_out.go index 306f58677..8eff032e3 100644 --- a/x/amm/client/cli/tx_swap_exact_amount_out.go +++ b/x/amm/client/cli/tx_swap_exact_amount_out.go @@ -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] [recipient]", + Use: "swap-exact-amount-out [token-out] [token-out-max-amount] [swap-route-pool-ids] [swap-route-denoms]", 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(5), + Args: cobra.ExactArgs(4), RunE: func(cmd *cobra.Command, args []string) (err error) { argTokenOut, err := sdk.ParseCoinNormalized(args[0]) if err != nil { @@ -53,7 +53,10 @@ func CmdSwapExactAmountOut() *cobra.Command { return err } - argRecipient := args[4] + recipient, err := cmd.Flags().GetString(FlagRecipient) + if err != nil { + return err + } clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -62,7 +65,7 @@ func CmdSwapExactAmountOut() *cobra.Command { msg := types.NewMsgSwapExactAmountOut( clientCtx.GetFromAddress().String(), - argRecipient, + recipient, argTokenOut, argTokenOutMaxAmount, argSwapRoutePoolIds, @@ -79,6 +82,7 @@ func CmdSwapExactAmountOut() *cobra.Command { flags.AddTxFlagsToCmd(cmd) cmd.Flags().String(FlagDiscount, "0.0", "discount to apply to the swap fee (only smart contract broker can apply the discount)") + cmd.Flags().String(FlagRecipient, "", "optional recipient field for the tokens swapped to be sent to") return cmd }