diff --git a/config.yml b/config.yml index a8c80126b..0f1b8f680 100644 --- a/config.yml +++ b/config.yml @@ -2,8 +2,9 @@ version: 1 accounts: - name: treasury coins: - - 100000000uatom - - 100000000uusdt + - 1000000000000uatom + - 1000000000000uusdc + - 1000000000000uusdt - 9000000000000000uelys - 100000000ueden mnemonic: olympic slide park figure frost benefit deer reform fly pull price airport submit monitor silk insect uphold convince pupil project ignore roof warfare slight diff --git a/x/amm/client/cli/tx_create_pool.go b/x/amm/client/cli/tx_create_pool.go index 8348b4df3..8a491912f 100644 --- a/x/amm/client/cli/tx_create_pool.go +++ b/x/amm/client/cli/tx_create_pool.go @@ -18,7 +18,7 @@ func CmdCreatePool() *cobra.Command { cmd := &cobra.Command{ Use: "create-pool [weights] [initial-deposit] [swap-fee] [exit-fee]", Short: "create a new pool and provide the liquidity to it", - Example: `elysd tx amm create-pool 100ueden,100uelys 1000000ueden,1000000uelys 0.00 0.00 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000`, + Example: `elysd tx amm create-pool 100uatom,100uusdc 100000000000uatom,100000000000uusdc 0.00 0.00 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000`, Args: cobra.ExactArgs(4), RunE: func(cmd *cobra.Command, args []string) (err error) { argWeights, err := sdk.ParseCoinsNormalized(args[0]) diff --git a/x/amm/client/cli/tx_exit_pool.go b/x/amm/client/cli/tx_exit_pool.go index 70777ba7c..264497c7e 100644 --- a/x/amm/client/cli/tx_exit_pool.go +++ b/x/amm/client/cli/tx_exit_pool.go @@ -16,9 +16,10 @@ var _ = strconv.Itoa(0) func CmdExitPool() *cobra.Command { cmd := &cobra.Command{ - Use: "exit-pool [pool-id] [min-amounts-out] [share-amount-in]", - Short: "exit a new pool and withdraw the liquidity from it", - Args: cobra.ExactArgs(3), + Use: "exit-pool [pool-id] [min-amounts-out] [share-amount-in]", + Short: "exit a new pool and withdraw the liquidity from it", + Example: `elysd tx amm exit-pool 0 1000uatom,1000uusdc 200000000000000000 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000`, + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) (err error) { argPoolId, err := cast.ToUint64E(args[0]) if err != nil { diff --git a/x/amm/client/cli/tx_join_pool.go b/x/amm/client/cli/tx_join_pool.go index f75e4a110..c1cfc672a 100644 --- a/x/amm/client/cli/tx_join_pool.go +++ b/x/amm/client/cli/tx_join_pool.go @@ -16,9 +16,10 @@ var _ = strconv.Itoa(0) func CmdJoinPool() *cobra.Command { cmd := &cobra.Command{ - Use: "join-pool [pool-id] [max-amounts-in] [share-amount-out]", - Short: "join a new pool and provide the liquidity to it", - Args: cobra.ExactArgs(3), + Use: "join-pool [pool-id] [max-amounts-in] [share-amount-out]", + Short: "join a new pool and provide the liquidity to it", + Example: `elysd tx amm join-pool 0 2000uatom,2000uusdc 200000000000000000 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000`, + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) (err error) { argPoolId, err := cast.ToUint64E(args[0]) if err != nil { 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 8eda42de3..ae590d8b6 100644 --- a/x/amm/client/cli/tx_swap_exact_amount_in.go +++ b/x/amm/client/cli/tx_swap_exact_amount_in.go @@ -20,9 +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]", - Short: "Swap an exact amount of tokens for a minimum of another token, similar to swapping a token on the trade screen GUI.", - Args: cobra.ExactArgs(4), + 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(4), RunE: func(cmd *cobra.Command, args []string) (err error) { argTokenIn, err := sdk.ParseCoinNormalized(args[0]) if err != nil { 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 ca7a1168a..5cc374c36 100644 --- a/x/amm/client/cli/tx_swap_exact_amount_out.go +++ b/x/amm/client/cli/tx_swap_exact_amount_out.go @@ -20,9 +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]", - Short: "Swap a maximum amount of tokens for an exact amount of another token, similar to swapping a token on the trade screen GUI.", - Args: cobra.ExactArgs(4), + 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(4), RunE: func(cmd *cobra.Command, args []string) (err error) { argTokenOut, err := sdk.ParseCoinNormalized(args[0]) if err != nil { diff --git a/x/margin/client/cli/tx_close.go b/x/margin/client/cli/tx_close.go index 46c75810b..2a0fb9cec 100644 --- a/x/margin/client/cli/tx_close.go +++ b/x/margin/client/cli/tx_close.go @@ -15,8 +15,10 @@ var _ = strconv.Itoa(0) func CmdClose() *cobra.Command { cmd := &cobra.Command{ - Use: "close", - Short: "Close margin position", + Use: "close [mtp-id] [flags]", + Short: "Close margin position", + Example: `elysd tx margin close 1 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000`, + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -27,14 +29,14 @@ func CmdClose() *cobra.Command { return errors.New("signer address is missing") } - id, err := cmd.Flags().GetUint64("id") - if err != nil { - return err + argMtpId, ok := strconv.ParseUint(args[0], 10, 64) + if ok != nil { + return errors.New("invalid mtp id") } msg := types.NewMsgClose( signer.String(), - id, + argMtpId, ) if err := msg.ValidateBasic(); err != nil { return err @@ -42,8 +44,7 @@ func CmdClose() *cobra.Command { return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, } - cmd.Flags().Uint64("id", 0, "id of the position") - _ = cmd.MarkFlagRequired("id") + flags.AddTxFlagsToCmd(cmd) return cmd diff --git a/x/margin/client/cli/tx_close_test.go b/x/margin/client/cli/tx_close_test.go index 1740912cc..ee61fe448 100644 --- a/x/margin/client/cli/tx_close_test.go +++ b/x/margin/client/cli/tx_close_test.go @@ -22,7 +22,7 @@ func TestClosePosition(t *testing.T) { // Tendermint RPC calls. // ... args := []string{ - "--id=1", + "1", "--from=" + val.Address.String(), "-y", } diff --git a/x/margin/client/cli/tx_open.go b/x/margin/client/cli/tx_open.go index 17c1768df..a2ad5095a 100644 --- a/x/margin/client/cli/tx_open.go +++ b/x/margin/client/cli/tx_open.go @@ -16,8 +16,10 @@ var _ = strconv.Itoa(0) func CmdOpen() *cobra.Command { cmd := &cobra.Command{ - Use: "open", - Short: "Open margin position", + Use: "open [position] [leverage] [collateral-asset] [collateral-amount] [borrow-asset] [flags]", + Short: "Open margin position", + Example: `elysd tx margin open long 5 uusdc 100000000 uatom --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000`, + Args: cobra.ExactArgs(5), RunE: func(cmd *cobra.Command, args []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -29,49 +31,29 @@ func CmdOpen() *cobra.Command { return errors.New("signer address is missing") } - collateralAsset, err := cmd.Flags().GetString("collateral_asset") - if err != nil { - return err - } - - collateralAmount, err := cmd.Flags().GetString("collateral_amount") - if err != nil { - return err - } - - borrowAsset, err := cmd.Flags().GetString("borrow_asset") - if err != nil { - return err - } - - position, err := cmd.Flags().GetString("position") - if err != nil { - return err - } - positionEnum := types.GetPositionFromString(position) + argPosition := types.GetPositionFromString(args[0]) - leverage, err := cmd.Flags().GetString("leverage") + argLeverage, err := sdk.NewDecFromStr(args[1]) if err != nil { return err } - leverageDec, err := sdk.NewDecFromStr(leverage) - if err != nil { - return err - } + argCollateralAsset := args[2] - collateralAmt, ok := sdk.NewIntFromString(collateralAmount) + argCollateralAmount, ok := sdk.NewIntFromString(args[3]) if !ok { return errors.New("invalid collateral amount") } + argBorrowAsset := args[4] + msg := types.NewMsgOpen( - clientCtx.GetFromAddress().String(), - collateralAsset, - collateralAmt, - borrowAsset, - positionEnum, - leverageDec, + signer.String(), + argCollateralAsset, + argCollateralAmount, + argBorrowAsset, + argPosition, + argLeverage, ) if err := msg.ValidateBasic(); err != nil { @@ -80,16 +62,7 @@ func CmdOpen() *cobra.Command { return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, } - cmd.Flags().String("collateral_amount", "0", "amount of collateral asset") - cmd.Flags().String("collateral_asset", "", "symbol of asset") - cmd.Flags().String("borrow_asset", "", "symbol of asset") - cmd.Flags().String("position", "", "type of position") - cmd.Flags().String("leverage", "", "leverage of position") - _ = cmd.MarkFlagRequired("collateral_amount") - _ = cmd.MarkFlagRequired("collateral_asset") - _ = cmd.MarkFlagRequired("borrow_asset") - _ = cmd.MarkFlagRequired("position") - _ = cmd.MarkFlagRequired("leverage") + flags.AddTxFlagsToCmd(cmd) return cmd diff --git a/x/margin/client/cli/tx_open_test.go b/x/margin/client/cli/tx_open_test.go index d3b2a6806..32752e196 100644 --- a/x/margin/client/cli/tx_open_test.go +++ b/x/margin/client/cli/tx_open_test.go @@ -31,11 +31,11 @@ func TestOpenPosition(t *testing.T) { // Tendermint RPC calls. // ... args := []string{ - "--collateral_asset=" + ptypes.BaseCurrency, - "--borrow_asset=uatom", - "--collateral_amount=1000", - "--position=long", - "--leverage=1.5", + "open", + "1.5", + ptypes.BaseCurrency, + "1000", + "uatom", "--from=" + val.Address.String(), "-y", }