2020-04-24 15:20:34 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
2020-04-30 14:23:41 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
2020-04-24 15:20:34 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/client/context"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
"github.com/cosmos/cosmos-sdk/version"
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/auth/client/utils"
|
2020-04-30 14:13:31 +00:00
|
|
|
|
|
|
|
"github.com/kava-labs/kava/x/incentive/types"
|
2020-04-24 15:20:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// GetTxCmd returns the transaction cli commands for the incentive module
|
|
|
|
func GetTxCmd(cdc *codec.Codec) *cobra.Command {
|
|
|
|
incentiveTxCmd := &cobra.Command{
|
|
|
|
Use: types.ModuleName,
|
|
|
|
Short: "transaction commands for the incentive module",
|
|
|
|
}
|
|
|
|
|
|
|
|
incentiveTxCmd.AddCommand(flags.PostCommands(
|
2021-01-26 11:52:34 +00:00
|
|
|
getCmdClaimCdp(cdc),
|
|
|
|
getCmdClaimHard(cdc),
|
2020-04-24 15:20:34 +00:00
|
|
|
)...)
|
|
|
|
|
|
|
|
return incentiveTxCmd
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-01-26 11:52:34 +00:00
|
|
|
func getCmdClaimCdp(cdc *codec.Codec) *cobra.Command {
|
2020-04-24 15:20:34 +00:00
|
|
|
return &cobra.Command{
|
2021-01-26 11:52:34 +00:00
|
|
|
Use: "claim-cdp [owner] [multiplier]",
|
|
|
|
Short: "claim CDP rewards for cdp owner and collateral-type",
|
2020-04-24 15:20:34 +00:00
|
|
|
Long: strings.TrimSpace(
|
2021-01-26 11:52:34 +00:00
|
|
|
fmt.Sprintf(`Claim any outstanding CDP rewards owned by owner for the input collateral-type and multiplier,
|
2020-04-24 15:20:34 +00:00
|
|
|
|
|
|
|
Example:
|
2021-01-26 11:52:34 +00:00
|
|
|
$ %s tx %s claim-cdp kava15qdefkmwswysgg4qxgqpqr35k3m49pkx2jdfnw large
|
2020-04-24 15:20:34 +00:00
|
|
|
`, version.ClientName, types.ModuleName),
|
|
|
|
),
|
2021-01-18 19:12:37 +00:00
|
|
|
Args: cobra.ExactArgs(2),
|
2020-04-24 15:20:34 +00:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
inBuf := bufio.NewReader(cmd.InOrStdin())
|
2020-10-16 19:42:09 +00:00
|
|
|
cliCtx := context.NewCLIContextWithInputAndFrom(inBuf, args[0]).WithCodec(cdc)
|
2020-04-24 15:20:34 +00:00
|
|
|
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc))
|
|
|
|
owner, err := sdk.AccAddressFromBech32(args[0])
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-01-18 19:12:37 +00:00
|
|
|
msg := types.NewMsgClaimUSDXMintingReward(owner, args[1])
|
2020-04-24 15:20:34 +00:00
|
|
|
err = msg.ValidateBasic()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2021-01-26 11:52:34 +00:00
|
|
|
|
|
|
|
func getCmdClaimHard(cdc *codec.Codec) *cobra.Command {
|
|
|
|
return &cobra.Command{
|
|
|
|
Use: "claim-hard [owner] [multiplier]",
|
|
|
|
Short: "claim Hard rewards for deposit/borrow and delegating",
|
|
|
|
Long: strings.TrimSpace(
|
|
|
|
fmt.Sprintf(`Claim owner's outstanding Hard rewards using given multiplier multiplier,
|
|
|
|
|
|
|
|
Example:
|
|
|
|
$ %s tx %s claim-hard kava15qdefkmwswysgg4qxgqpqr35k3m49pkx2jdfnw large
|
|
|
|
`, version.ClientName, types.ModuleName),
|
|
|
|
),
|
|
|
|
Args: cobra.ExactArgs(2),
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
inBuf := bufio.NewReader(cmd.InOrStdin())
|
|
|
|
cliCtx := context.NewCLIContextWithInputAndFrom(inBuf, args[0]).WithCodec(cdc)
|
|
|
|
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc))
|
|
|
|
owner, err := sdk.AccAddressFromBech32(args[0])
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
msg := types.NewMsgClaimHardLiquidityProviderReward(owner, args[1])
|
|
|
|
err = msg.ValidateBasic()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|