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-02-15 15:29:00 +00:00
|
|
|
Use: "claim-cdp [multiplier]",
|
|
|
|
Short: "claim CDP rewards using a given multiplier",
|
2020-04-24 15:20:34 +00:00
|
|
|
Long: strings.TrimSpace(
|
2021-02-15 15:29:00 +00:00
|
|
|
fmt.Sprintf(`Claim sender's outstanding CDP rewards using a given multiplier
|
2020-04-24 15:20:34 +00:00
|
|
|
|
|
|
|
Example:
|
2021-02-15 15:29:00 +00:00
|
|
|
$ %s tx %s claim-cdp large
|
2020-04-24 15:20:34 +00:00
|
|
|
`, version.ClientName, types.ModuleName),
|
|
|
|
),
|
2021-02-15 15:29:00 +00:00
|
|
|
Args: cobra.ExactArgs(1),
|
2020-04-24 15:20:34 +00:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
inBuf := bufio.NewReader(cmd.InOrStdin())
|
2021-02-15 15:29:00 +00:00
|
|
|
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
2020-04-24 15:20:34 +00:00
|
|
|
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc))
|
2021-02-10 14:58:05 +00:00
|
|
|
|
|
|
|
sender := cliCtx.GetFromAddress()
|
2021-02-15 15:29:00 +00:00
|
|
|
multiplier := args[0]
|
2021-02-10 14:58:05 +00:00
|
|
|
|
2021-02-15 15:29:00 +00:00
|
|
|
msg := types.NewMsgClaimUSDXMintingReward(sender, multiplier)
|
|
|
|
err := msg.ValidateBasic()
|
2020-04-24 15:20:34 +00:00
|
|
|
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{
|
2021-02-15 15:29:00 +00:00
|
|
|
Use: "claim-hard [multiplier]",
|
|
|
|
Short: "claim sender's Hard module rewards using a given multiplier",
|
2021-01-26 11:52:34 +00:00
|
|
|
Long: strings.TrimSpace(
|
2021-02-15 15:29:00 +00:00
|
|
|
fmt.Sprintf(`Claim sender's outstanding Hard rewards for deposit/borrow/delegate using given multiplier
|
2021-01-26 11:52:34 +00:00
|
|
|
|
|
|
|
Example:
|
2021-02-15 15:29:00 +00:00
|
|
|
$ %s tx %s claim-hard large
|
2021-01-26 11:52:34 +00:00
|
|
|
`, version.ClientName, types.ModuleName),
|
|
|
|
),
|
2021-02-15 15:29:00 +00:00
|
|
|
Args: cobra.ExactArgs(1),
|
2021-01-26 11:52:34 +00:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
inBuf := bufio.NewReader(cmd.InOrStdin())
|
2021-02-15 15:29:00 +00:00
|
|
|
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
2021-01-26 11:52:34 +00:00
|
|
|
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc))
|
2021-02-10 14:58:05 +00:00
|
|
|
|
|
|
|
sender := cliCtx.GetFromAddress()
|
2021-02-15 15:29:00 +00:00
|
|
|
multiplier := args[0]
|
2021-02-10 14:58:05 +00:00
|
|
|
|
2021-03-15 18:03:15 +00:00
|
|
|
msg := types.NewMsgClaimHardReward(sender, multiplier)
|
2021-02-15 15:29:00 +00:00
|
|
|
err := msg.ValidateBasic()
|
2021-01-26 11:52:34 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|