update 'harvest' -> 'hard' (#746)

This commit is contained in:
Denali Marsh 2020-12-21 18:18:55 +01:00 committed by GitHub
parent f140d7aff6
commit a4bbea1ec4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
66 changed files with 489 additions and 471 deletions

View File

@ -38,7 +38,7 @@ import (
"github.com/kava-labs/kava/x/bep3" "github.com/kava-labs/kava/x/bep3"
"github.com/kava-labs/kava/x/cdp" "github.com/kava-labs/kava/x/cdp"
"github.com/kava-labs/kava/x/committee" "github.com/kava-labs/kava/x/committee"
"github.com/kava-labs/kava/x/harvest" "github.com/kava-labs/kava/x/hard"
"github.com/kava-labs/kava/x/incentive" "github.com/kava-labs/kava/x/incentive"
"github.com/kava-labs/kava/x/issuance" "github.com/kava-labs/kava/x/issuance"
"github.com/kava-labs/kava/x/kavadist" "github.com/kava-labs/kava/x/kavadist"
@ -84,7 +84,7 @@ var (
kavadist.AppModuleBasic{}, kavadist.AppModuleBasic{},
incentive.AppModuleBasic{}, incentive.AppModuleBasic{},
issuance.AppModuleBasic{}, issuance.AppModuleBasic{},
harvest.AppModuleBasic{}, hard.AppModuleBasic{},
) )
// module account permissions // module account permissions
@ -103,10 +103,10 @@ var (
bep3.ModuleName: {supply.Minter, supply.Burner}, bep3.ModuleName: {supply.Minter, supply.Burner},
kavadist.ModuleName: {supply.Minter}, kavadist.ModuleName: {supply.Minter},
issuance.ModuleAccountName: {supply.Minter, supply.Burner}, issuance.ModuleAccountName: {supply.Minter, supply.Burner},
harvest.LPAccount: {supply.Minter, supply.Burner}, hard.LPAccount: {supply.Minter, supply.Burner},
harvest.DelegatorAccount: {supply.Minter, supply.Burner}, hard.DelegatorAccount: {supply.Minter, supply.Burner},
harvest.ModuleAccountName: {supply.Minter, supply.Burner}, hard.ModuleAccountName: {supply.Minter, supply.Burner},
harvest.LiquidatorAccount: {supply.Minter, supply.Burner}, hard.LiquidatorAccount: {supply.Minter, supply.Burner},
} }
// module accounts that are allowed to receive tokens // module accounts that are allowed to receive tokens
@ -161,7 +161,7 @@ type App struct {
kavadistKeeper kavadist.Keeper kavadistKeeper kavadist.Keeper
incentiveKeeper incentive.Keeper incentiveKeeper incentive.Keeper
issuanceKeeper issuance.Keeper issuanceKeeper issuance.Keeper
harvestKeeper harvest.Keeper hardKeeper hard.Keeper
// the module manager // the module manager
mm *module.Manager mm *module.Manager
@ -185,7 +185,7 @@ func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts AppOptio
gov.StoreKey, params.StoreKey, upgrade.StoreKey, evidence.StoreKey, gov.StoreKey, params.StoreKey, upgrade.StoreKey, evidence.StoreKey,
validatorvesting.StoreKey, auction.StoreKey, cdp.StoreKey, pricefeed.StoreKey, validatorvesting.StoreKey, auction.StoreKey, cdp.StoreKey, pricefeed.StoreKey,
bep3.StoreKey, kavadist.StoreKey, incentive.StoreKey, issuance.StoreKey, committee.StoreKey, bep3.StoreKey, kavadist.StoreKey, incentive.StoreKey, issuance.StoreKey, committee.StoreKey,
harvest.StoreKey, hard.StoreKey,
) )
tkeys := sdk.NewTransientStoreKeys(params.TStoreKey) tkeys := sdk.NewTransientStoreKeys(params.TStoreKey)
@ -215,7 +215,7 @@ func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts AppOptio
kavadistSubspace := app.paramsKeeper.Subspace(kavadist.DefaultParamspace) kavadistSubspace := app.paramsKeeper.Subspace(kavadist.DefaultParamspace)
incentiveSubspace := app.paramsKeeper.Subspace(incentive.DefaultParamspace) incentiveSubspace := app.paramsKeeper.Subspace(incentive.DefaultParamspace)
issuanceSubspace := app.paramsKeeper.Subspace(issuance.DefaultParamspace) issuanceSubspace := app.paramsKeeper.Subspace(issuance.DefaultParamspace)
harvestSubspace := app.paramsKeeper.Subspace(harvest.DefaultParamspace) hardSubspace := app.paramsKeeper.Subspace(hard.DefaultParamspace)
// add keepers // add keepers
app.accountKeeper = auth.NewAccountKeeper( app.accountKeeper = auth.NewAccountKeeper(
@ -380,10 +380,10 @@ func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts AppOptio
app.accountKeeper, app.accountKeeper,
app.supplyKeeper, app.supplyKeeper,
) )
app.harvestKeeper = harvest.NewKeeper( app.hardKeeper = hard.NewKeeper(
app.cdc, app.cdc,
keys[harvest.StoreKey], keys[hard.StoreKey],
harvestSubspace, hardSubspace,
app.accountKeeper, app.accountKeeper,
app.supplyKeeper, app.supplyKeeper,
&stakingKeeper, &stakingKeeper,
@ -420,7 +420,7 @@ func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts AppOptio
incentive.NewAppModule(app.incentiveKeeper, app.accountKeeper, app.supplyKeeper), incentive.NewAppModule(app.incentiveKeeper, app.accountKeeper, app.supplyKeeper),
committee.NewAppModule(app.committeeKeeper, app.accountKeeper), committee.NewAppModule(app.committeeKeeper, app.accountKeeper),
issuance.NewAppModule(app.issuanceKeeper, app.accountKeeper, app.supplyKeeper), issuance.NewAppModule(app.issuanceKeeper, app.accountKeeper, app.supplyKeeper),
harvest.NewAppModule(app.harvestKeeper, app.supplyKeeper, app.pricefeedKeeper), hard.NewAppModule(app.hardKeeper, app.supplyKeeper, app.pricefeedKeeper),
) )
// During begin block slashing happens after distr.BeginBlocker so that // During begin block slashing happens after distr.BeginBlocker so that
@ -431,7 +431,7 @@ func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts AppOptio
app.mm.SetOrderBeginBlockers( app.mm.SetOrderBeginBlockers(
upgrade.ModuleName, mint.ModuleName, distr.ModuleName, slashing.ModuleName, upgrade.ModuleName, mint.ModuleName, distr.ModuleName, slashing.ModuleName,
validatorvesting.ModuleName, kavadist.ModuleName, auction.ModuleName, cdp.ModuleName, validatorvesting.ModuleName, kavadist.ModuleName, auction.ModuleName, cdp.ModuleName,
bep3.ModuleName, incentive.ModuleName, committee.ModuleName, issuance.ModuleName, harvest.ModuleName, bep3.ModuleName, incentive.ModuleName, committee.ModuleName, issuance.ModuleName, hard.ModuleName,
) )
app.mm.SetOrderEndBlockers(crisis.ModuleName, gov.ModuleName, staking.ModuleName, pricefeed.ModuleName) app.mm.SetOrderEndBlockers(crisis.ModuleName, gov.ModuleName, staking.ModuleName, pricefeed.ModuleName)
@ -442,7 +442,7 @@ func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts AppOptio
staking.ModuleName, bank.ModuleName, slashing.ModuleName, staking.ModuleName, bank.ModuleName, slashing.ModuleName,
gov.ModuleName, mint.ModuleName, evidence.ModuleName, gov.ModuleName, mint.ModuleName, evidence.ModuleName,
pricefeed.ModuleName, cdp.ModuleName, auction.ModuleName, pricefeed.ModuleName, cdp.ModuleName, auction.ModuleName,
bep3.ModuleName, kavadist.ModuleName, incentive.ModuleName, committee.ModuleName, issuance.ModuleName, harvest.ModuleName, bep3.ModuleName, kavadist.ModuleName, incentive.ModuleName, committee.ModuleName, issuance.ModuleName, hard.ModuleName,
supply.ModuleName, // calculates the total supply from account - should run after modules that modify accounts in genesis supply.ModuleName, // calculates the total supply from account - should run after modules that modify accounts in genesis
crisis.ModuleName, // runs the invariants at genesis - should run after other modules crisis.ModuleName, // runs the invariants at genesis - should run after other modules
genutil.ModuleName, // genutils must occur after staking so that pools are properly initialized with tokens from genesis accounts. genutil.ModuleName, // genutils must occur after staking so that pools are properly initialized with tokens from genesis accounts.
@ -473,7 +473,7 @@ func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts AppOptio
incentive.NewAppModule(app.incentiveKeeper, app.accountKeeper, app.supplyKeeper), incentive.NewAppModule(app.incentiveKeeper, app.accountKeeper, app.supplyKeeper),
committee.NewAppModule(app.committeeKeeper, app.accountKeeper), committee.NewAppModule(app.committeeKeeper, app.accountKeeper),
issuance.NewAppModule(app.issuanceKeeper, app.accountKeeper, app.supplyKeeper), issuance.NewAppModule(app.issuanceKeeper, app.accountKeeper, app.supplyKeeper),
harvest.NewAppModule(app.harvestKeeper, app.supplyKeeper, app.pricefeedKeeper), hard.NewAppModule(app.hardKeeper, app.supplyKeeper, app.pricefeedKeeper),
) )
app.sm.RegisterStoreDecoders() app.sm.RegisterStoreDecoders()

View File

@ -33,7 +33,7 @@ import (
"github.com/kava-labs/kava/x/bep3" "github.com/kava-labs/kava/x/bep3"
"github.com/kava-labs/kava/x/cdp" "github.com/kava-labs/kava/x/cdp"
"github.com/kava-labs/kava/x/committee" "github.com/kava-labs/kava/x/committee"
"github.com/kava-labs/kava/x/harvest" "github.com/kava-labs/kava/x/hard"
"github.com/kava-labs/kava/x/incentive" "github.com/kava-labs/kava/x/incentive"
"github.com/kava-labs/kava/x/issuance" "github.com/kava-labs/kava/x/issuance"
"github.com/kava-labs/kava/x/kavadist" "github.com/kava-labs/kava/x/kavadist"
@ -84,7 +84,7 @@ func (tApp TestApp) GetPriceFeedKeeper() pricefeed.Keeper { return tApp.pricefee
func (tApp TestApp) GetBep3Keeper() bep3.Keeper { return tApp.bep3Keeper } func (tApp TestApp) GetBep3Keeper() bep3.Keeper { return tApp.bep3Keeper }
func (tApp TestApp) GetKavadistKeeper() kavadist.Keeper { return tApp.kavadistKeeper } func (tApp TestApp) GetKavadistKeeper() kavadist.Keeper { return tApp.kavadistKeeper }
func (tApp TestApp) GetIncentiveKeeper() incentive.Keeper { return tApp.incentiveKeeper } func (tApp TestApp) GetIncentiveKeeper() incentive.Keeper { return tApp.incentiveKeeper }
func (tApp TestApp) GetHarvestKeeper() harvest.Keeper { return tApp.harvestKeeper } func (tApp TestApp) GetHardKeeper() hard.Keeper { return tApp.hardKeeper }
func (tApp TestApp) GetCommitteeKeeper() committee.Keeper { return tApp.committeeKeeper } func (tApp TestApp) GetCommitteeKeeper() committee.Keeper { return tApp.committeeKeeper }
func (tApp TestApp) GetIssuanceKeeper() issuance.Keeper { return tApp.issuanceKeeper } func (tApp TestApp) GetIssuanceKeeper() issuance.Keeper { return tApp.issuanceKeeper }

View File

@ -26,7 +26,7 @@ import (
v0_9cdp "github.com/kava-labs/kava/x/cdp/legacy/v0_9" v0_9cdp "github.com/kava-labs/kava/x/cdp/legacy/v0_9"
v0_11committee "github.com/kava-labs/kava/x/committee" v0_11committee "github.com/kava-labs/kava/x/committee"
v0_9committee "github.com/kava-labs/kava/x/committee/legacy/v0_9" v0_9committee "github.com/kava-labs/kava/x/committee/legacy/v0_9"
v0_11harvest "github.com/kava-labs/kava/x/harvest" v0_11harvest "github.com/kava-labs/kava/x/hard"
v0_11incentive "github.com/kava-labs/kava/x/incentive" v0_11incentive "github.com/kava-labs/kava/x/incentive"
v0_9incentive "github.com/kava-labs/kava/x/incentive/legacy/v0_9" v0_9incentive "github.com/kava-labs/kava/x/incentive/legacy/v0_9"
v0_11issuance "github.com/kava-labs/kava/x/issuance" v0_11issuance "github.com/kava-labs/kava/x/issuance"

View File

@ -1,4 +1,4 @@
package harvest package hard
import ( import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"

View File

@ -1,10 +1,10 @@
package harvest package hard
// DO NOT EDIT - generated by aliasgen tool (github.com/rhuairahrighairidh/aliasgen) // DO NOT EDIT - generated by aliasgen tool (github.com/rhuairahrighairidh/aliasgen)
import ( import (
"github.com/kava-labs/kava/x/harvest/keeper" "github.com/kava-labs/kava/x/hard/keeper"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
const ( const (
@ -23,12 +23,12 @@ const (
AttributeValueCategory = types.AttributeValueCategory AttributeValueCategory = types.AttributeValueCategory
DefaultParamspace = types.DefaultParamspace DefaultParamspace = types.DefaultParamspace
DelegatorAccount = types.DelegatorAccount DelegatorAccount = types.DelegatorAccount
EventTypeClaimHarvestReward = types.EventTypeClaimHarvestReward EventTypeClaimHardReward = types.EventTypeClaimHardReward
EventTypeDeleteHarvestDeposit = types.EventTypeDeleteHarvestDeposit EventTypeDeleteHardDeposit = types.EventTypeDeleteHardDeposit
EventTypeHarvestDelegatorDistribution = types.EventTypeHarvestDelegatorDistribution EventTypeHardDelegatorDistribution = types.EventTypeHardDelegatorDistribution
EventTypeHarvestDeposit = types.EventTypeHarvestDeposit EventTypeHardDeposit = types.EventTypeHardDeposit
EventTypeHarvestLPDistribution = types.EventTypeHarvestLPDistribution EventTypeHardLPDistribution = types.EventTypeHardLPDistribution
EventTypeHarvestWithdrawal = types.EventTypeHarvestWithdrawal EventTypeHardWithdrawal = types.EventTypeHardWithdrawal
LP = types.LP LP = types.LP
LPAccount = types.LPAccount LPAccount = types.LPAccount
LiquidatorAccount = types.LiquidatorAccount LiquidatorAccount = types.LiquidatorAccount

View File

@ -14,7 +14,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
supplyexported "github.com/cosmos/cosmos-sdk/x/supply/exported" supplyexported "github.com/cosmos/cosmos-sdk/x/supply/exported"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
// flags for cli queries // flags for cli queries
@ -25,17 +25,17 @@ const (
flagClaimType = "claim-type" flagClaimType = "claim-type"
) )
// GetQueryCmd returns the cli query commands for the harvest module // GetQueryCmd returns the cli query commands for the module
func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
harvestQueryCmd := &cobra.Command{ hardQueryCmd := &cobra.Command{
Use: types.ModuleName, Use: types.ModuleName,
Short: "Querying commands for the harvest module", Short: "Querying commands for the hard module",
DisableFlagParsing: true, DisableFlagParsing: true,
SuggestionsMinimumDistance: 2, SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd, RunE: client.ValidateCmd,
} }
harvestQueryCmd.AddCommand(flags.GetCommands( hardQueryCmd.AddCommand(flags.GetCommands(
queryParamsCmd(queryRoute, cdc), queryParamsCmd(queryRoute, cdc),
queryModAccountsCmd(queryRoute, cdc), queryModAccountsCmd(queryRoute, cdc),
queryDepositsCmd(queryRoute, cdc), queryDepositsCmd(queryRoute, cdc),
@ -44,15 +44,15 @@ func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
queryBorrowCmd(queryRoute, cdc), queryBorrowCmd(queryRoute, cdc),
)...) )...)
return harvestQueryCmd return hardQueryCmd
} }
func queryParamsCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { func queryParamsCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
return &cobra.Command{ return &cobra.Command{
Use: "params", Use: "params",
Short: "get the harvest module parameters", Short: "get the hard module parameters",
Long: "Get the current global harvest module parameters.", Long: "Get the current global hard module parameters.",
Args: cobra.NoArgs, Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc) cliCtx := context.NewCLIContext().WithCodec(cdc)
@ -78,12 +78,12 @@ func queryParamsCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
func queryModAccountsCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { func queryModAccountsCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
return &cobra.Command{ return &cobra.Command{
Use: "accounts", Use: "accounts",
Short: "query harvest module accounts with optional filter", Short: "query hard module accounts with optional filter",
Long: strings.TrimSpace(`Query for all harvest module accounts or a specific account using the name flag: Long: strings.TrimSpace(`Query for all hard module accounts or a specific account using the name flag:
Example: Example:
$ kvcli q harvest accounts $ kvcli q hard accounts
$ kvcli q harvest accounts --name harvest|harvest_delegator_distribution|harvest_lp_distribution`, $ kvcli q hard accounts --name hard|hard_delegator_distribution|hard_lp_distribution`,
), ),
Args: cobra.NoArgs, Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
@ -118,14 +118,14 @@ func queryModAccountsCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
func queryDepositsCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { func queryDepositsCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "deposits", Use: "deposits",
Short: "query harvest module deposits with optional filters", Short: "query hard module deposits with optional filters",
Long: strings.TrimSpace(`query for all harvest module deposits or a specific deposit using flags: Long: strings.TrimSpace(`query for all hard module deposits or a specific deposit using flags:
Example: Example:
$ kvcli q harvest deposits $ kvcli q hard deposits
$ kvcli q harvest deposits --owner kava1l0xsq2z7gqd7yly0g40y5836g0appumark77ny --deposit-denom bnb $ kvcli q hard deposits --owner kava1l0xsq2z7gqd7yly0g40y5836g0appumark77ny --deposit-denom bnb
$ kvcli q harvest deposits --deposit-denom ukava $ kvcli q hard deposits --deposit-denom ukava
$ kvcli q harvest deposits --deposit-denom btcb`, $ kvcli q hard deposits --deposit-denom btcb`,
), ),
Args: cobra.NoArgs, Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
@ -177,14 +177,14 @@ func queryDepositsCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
func queryClaimsCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { func queryClaimsCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "claims", Use: "claims",
Short: "query harvest module claims with optional filters", Short: "query hard module claims with optional filters",
Long: strings.TrimSpace(`query for all harvest module claims or a specific claim using flags: Long: strings.TrimSpace(`query for all hard module claims or a specific claim using flags:
Example: Example:
$ kvcli q harvest claims $ kvcli q hard claims
$ kvcli q harvest claims --owner kava1l0xsq2z7gqd7yly0g40y5836g0appumark77ny --claim-type lp --deposit-denom bnb $ kvcli q hard claims --owner kava1l0xsq2z7gqd7yly0g40y5836g0appumark77ny --claim-type lp --deposit-denom bnb
$ kvcli q harvest claims --claim-type stake --deposit-denom ukava $ kvcli q hard claims --claim-type stake --deposit-denom ukava
$ kvcli q harvest claims --deposit-denom btcb`, $ kvcli q hard claims --deposit-denom btcb`,
), ),
Args: cobra.NoArgs, Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
@ -246,13 +246,13 @@ func queryClaimsCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
func queryBorrowsCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { func queryBorrowsCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "borrows", Use: "borrows",
Short: "query harvest module borrows with optional filters", Short: "query hard module borrows with optional filters",
Long: strings.TrimSpace(`query for all harvest module borrows or a specific borrow using flags: Long: strings.TrimSpace(`query for all hard module borrows or a specific borrow using flags:
Example: Example:
$ kvcli q harvest borrows $ kvcli q hard borrows
$ kvcli q harvest borrows --borrower kava1l0xsq2z7gqd7yly0g40y5836g0appumark77ny $ kvcli q hard borrows --borrower kava1l0xsq2z7gqd7yly0g40y5836g0appumark77ny
$ kvcli q harvest borrows --borrow-denom bnb`, $ kvcli q hard borrows --borrow-denom bnb`,
), ),
Args: cobra.NoArgs, Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
@ -304,7 +304,7 @@ func queryBorrowedCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
return &cobra.Command{ return &cobra.Command{
Use: "borrowed", Use: "borrowed",
Short: "get total current borrowed amount", Short: "get total current borrowed amount",
Long: "get the total amount of coins currently borrowed for the Harvest protocol", Long: "get the total amount of coins currently borrowed for the Hard protocol",
Args: cobra.NoArgs, Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc) cliCtx := context.NewCLIContext().WithCodec(cdc)
@ -333,7 +333,7 @@ func queryBorrowCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
Short: "query outstanding borrow balance for a user", Short: "query outstanding borrow balance for a user",
Long: strings.TrimSpace(`query outstanding borrow balance for a user: Long: strings.TrimSpace(`query outstanding borrow balance for a user:
Example: Example:
$ kvcli q harvest borrow --owner kava1l0xsq2z7gqd7yly0g40y5836g0appumark77ny`, $ kvcli q hard borrow --owner kava1l0xsq2z7gqd7yly0g40y5836g0appumark77ny`,
), ),
Args: cobra.NoArgs, Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {

View File

@ -16,12 +16,12 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" "github.com/cosmos/cosmos-sdk/x/auth/client/utils"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
// GetTxCmd returns the transaction commands for this module // GetTxCmd returns the transaction commands for this module
func GetTxCmd(cdc *codec.Codec) *cobra.Command { func GetTxCmd(cdc *codec.Codec) *cobra.Command {
harvestTxCmd := &cobra.Command{ hardTxCmd := &cobra.Command{
Use: types.ModuleName, Use: types.ModuleName,
Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName),
DisableFlagParsing: true, DisableFlagParsing: true,
@ -29,7 +29,7 @@ func GetTxCmd(cdc *codec.Codec) *cobra.Command {
RunE: client.ValidateCmd, RunE: client.ValidateCmd,
} }
harvestTxCmd.AddCommand(flags.PostCommands( hardTxCmd.AddCommand(flags.PostCommands(
getCmdDeposit(cdc), getCmdDeposit(cdc),
getCmdWithdraw(cdc), getCmdWithdraw(cdc),
getCmdClaimReward(cdc), getCmdClaimReward(cdc),
@ -38,13 +38,13 @@ func GetTxCmd(cdc *codec.Codec) *cobra.Command {
getCmdRepay(cdc), getCmdRepay(cdc),
)...) )...)
return harvestTxCmd return hardTxCmd
} }
func getCmdDeposit(cdc *codec.Codec) *cobra.Command { func getCmdDeposit(cdc *codec.Codec) *cobra.Command {
return &cobra.Command{ return &cobra.Command{
Use: "deposit [amount]", Use: "deposit [amount]",
Short: "deposit coins to harvest", Short: "deposit coins to hard",
Example: fmt.Sprintf( Example: fmt.Sprintf(
`%s tx %s deposit 10000000bnb --from <key>`, version.ClientName, types.ModuleName, `%s tx %s deposit 10000000bnb --from <key>`, version.ClientName, types.ModuleName,
), ),
@ -68,7 +68,7 @@ func getCmdDeposit(cdc *codec.Codec) *cobra.Command {
func getCmdWithdraw(cdc *codec.Codec) *cobra.Command { func getCmdWithdraw(cdc *codec.Codec) *cobra.Command {
return &cobra.Command{ return &cobra.Command{
Use: "withdraw [amount]", Use: "withdraw [amount]",
Short: "withdraw coins from harvest", Short: "withdraw coins from hard",
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
Example: fmt.Sprintf( Example: fmt.Sprintf(
`%s tx %s withdraw 10000000bnb --from <key>`, version.ClientName, types.ModuleName, `%s tx %s withdraw 10000000bnb --from <key>`, version.ClientName, types.ModuleName,
@ -95,7 +95,7 @@ func getCmdClaimReward(cdc *codec.Codec) *cobra.Command {
Use: "claim [receiver-addr] [deposit-denom] [deposit-type] [multiplier]", Use: "claim [receiver-addr] [deposit-denom] [deposit-type] [multiplier]",
Short: "claim HARD tokens to receiver address", Short: "claim HARD tokens to receiver address",
Long: strings.TrimSpace( Long: strings.TrimSpace(
`sends accumulated HARD tokens from the harvest module account to the receiver address. `sends accumulated HARD tokens from the hard module account to the receiver address.
Note that receiver address should match the sender address, Note that receiver address should match the sender address,
unless the sender is a validator-vesting account`), unless the sender is a validator-vesting account`),
Args: cobra.ExactArgs(4), Args: cobra.ExactArgs(4),
@ -122,8 +122,8 @@ func getCmdClaimReward(cdc *codec.Codec) *cobra.Command {
func getCmdBorrow(cdc *codec.Codec) *cobra.Command { func getCmdBorrow(cdc *codec.Codec) *cobra.Command {
return &cobra.Command{ return &cobra.Command{
Use: "borrow [1000000000ukava]", Use: "borrow [1000000000ukava]",
Short: "borrow tokens from the harvest protocol", Short: "borrow tokens from the hard protocol",
Long: strings.TrimSpace(`borrows tokens from the harvest protocol`), Long: strings.TrimSpace(`borrows tokens from the hard protocol`),
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
Example: fmt.Sprintf( Example: fmt.Sprintf(
`%s tx %s borrow 1000000000ukava --from <key>`, version.ClientName, types.ModuleName, `%s tx %s borrow 1000000000ukava --from <key>`, version.ClientName, types.ModuleName,
@ -150,8 +150,8 @@ func getCmdBorrow(cdc *codec.Codec) *cobra.Command {
func getCmdRepay(cdc *codec.Codec) *cobra.Command { func getCmdRepay(cdc *codec.Codec) *cobra.Command {
return &cobra.Command{ return &cobra.Command{
Use: "repay [1000000000ukava]", Use: "repay [1000000000ukava]",
Short: "repay tokens to the harvest protocol", Short: "repay tokens to the hard protocol",
Long: strings.TrimSpace(`repay tokens to the harvest protocol`), Long: strings.TrimSpace(`repay tokens to the hard protocol`),
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
Example: fmt.Sprintf( Example: fmt.Sprintf(
`%s tx %s repay 1000000000ukava,25000000000bnb --from <key>`, version.ClientName, types.ModuleName, `%s tx %s repay 1000000000ukava,25000000000bnb --from <key>`, version.ClientName, types.ModuleName,

View File

@ -11,7 +11,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/types/rest"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router) { func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router) {

View File

@ -17,7 +17,7 @@ const (
RestName = "name" RestName = "name"
) )
// RegisterRoutes registers harvest-related REST handlers to a router // RegisterRoutes registers hard-related REST handlers to a router
func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router) { func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router) {
registerQueryRoutes(cliCtx, r) registerQueryRoutes(cliCtx, r)
registerTxRoutes(cliCtx, r) registerTxRoutes(cliCtx, r)

View File

@ -12,7 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" "github.com/cosmos/cosmos-sdk/x/auth/client/utils"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
func registerTxRoutes(cliCtx context.CLIContext, r *mux.Router) { func registerTxRoutes(cliCtx context.CLIContext, r *mux.Router) {

View File

@ -1,11 +1,11 @@
package harvest package hard
import ( import (
"fmt" "fmt"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
// InitGenesis initializes the store state from a genesis state. // InitGenesis initializes the store state from a genesis state.
@ -53,7 +53,7 @@ func InitGenesis(ctx sdk.Context, k Keeper, supplyKeeper types.SupplyKeeper, gs
} }
// ExportGenesis export genesis state for harvest module // ExportGenesis export genesis state for hard module
func ExportGenesis(ctx sdk.Context, k Keeper) GenesisState { func ExportGenesis(ctx sdk.Context, k Keeper) GenesisState {
params := k.GetParams(ctx) params := k.GetParams(ctx)
previousBlockTime, found := k.GetPreviousBlockTime(ctx) previousBlockTime, found := k.GetPreviousBlockTime(ctx)

View File

@ -1,4 +1,4 @@
package harvest package hard
import ( import (
"strings" "strings"
@ -6,11 +6,11 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/kava-labs/kava/x/harvest/keeper" "github.com/kava-labs/kava/x/hard/keeper"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
// NewHandler creates an sdk.Handler for harvest messages // NewHandler creates an sdk.Handler for hard messages
func NewHandler(k Keeper) sdk.Handler { func NewHandler(k Keeper) sdk.Handler {
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
ctx = ctx.WithEventManager(sdk.NewEventManager()) ctx = ctx.WithEventManager(sdk.NewEventManager())

View File

@ -6,7 +6,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
// Borrow funds // Borrow funds
@ -40,7 +40,7 @@ func (k Keeper) Borrow(ctx sdk.Context, borrower sdk.AccAddress, coins sdk.Coins
return err return err
} }
// Sends coins from Harvest module account to user // Sends coins from Hard module account to user
err = k.supplyKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleAccountName, borrower, coins) err = k.supplyKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleAccountName, borrower, coins)
if err != nil { if err != nil {
if strings.Contains(err.Error(), "insufficient account funds") { if strings.Contains(err.Error(), "insufficient account funds") {
@ -83,7 +83,7 @@ func (k Keeper) Borrow(ctx sdk.Context, borrower sdk.AccAddress, coins sdk.Coins
ctx.EventManager().EmitEvent( ctx.EventManager().EmitEvent(
sdk.NewEvent( sdk.NewEvent(
types.EventTypeHarvestBorrow, types.EventTypeHardBorrow,
sdk.NewAttribute(types.AttributeKeyBorrower, borrower.String()), sdk.NewAttribute(types.AttributeKeyBorrower, borrower.String()),
sdk.NewAttribute(types.AttributeKeyBorrowCoins, coins.String()), sdk.NewAttribute(types.AttributeKeyBorrowCoins, coins.String()),
), ),

View File

@ -10,8 +10,8 @@ import (
tmtime "github.com/tendermint/tendermint/types/time" tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/harvest" "github.com/kava-labs/kava/x/hard"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
"github.com/kava-labs/kava/x/pricefeed" "github.com/kava-labs/kava/x/pricefeed"
) )
@ -259,8 +259,8 @@ func (suite *KeeperTestSuite) TestBorrow() {
sdk.NewCoin("btcb", sdk.NewInt(100*BTCB_CF)), sdk.NewCoin("bnb", sdk.NewInt(100*BNB_CF)), sdk.NewCoin("btcb", sdk.NewInt(100*BTCB_CF)), sdk.NewCoin("bnb", sdk.NewInt(100*BNB_CF)),
sdk.NewCoin("xyz", sdk.NewInt(1)))}) sdk.NewCoin("xyz", sdk.NewInt(1)))})
// Harvest module genesis state // hard module genesis state
harvestGS := types.NewGenesisState(types.NewParams( hardGS := types.NewGenesisState(types.NewParams(
true, true,
types.DistributionSchedules{ types.DistributionSchedules{
types.NewDistributionSchedule(true, "usdx", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Medium, 24, sdk.OneDec())}), types.NewDistributionSchedule(true, "usdx", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Medium, 24, sdk.OneDec())}),
@ -335,15 +335,15 @@ func (suite *KeeperTestSuite) TestBorrow() {
// Initialize test application // Initialize test application
tApp.InitializeFromGenesisStates(authGS, tApp.InitializeFromGenesisStates(authGS,
app.GenesisState{pricefeed.ModuleName: pricefeed.ModuleCdc.MustMarshalJSON(pricefeedGS)}, app.GenesisState{pricefeed.ModuleName: pricefeed.ModuleCdc.MustMarshalJSON(pricefeedGS)},
app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(harvestGS)}) app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(hardGS)})
// Mint coins to Harvest module account // Mint coins to hard module account
supplyKeeper := tApp.GetSupplyKeeper() supplyKeeper := tApp.GetSupplyKeeper()
harvestMaccCoins := sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1000*KAVA_CF)), hardMaccCoins := sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1000*KAVA_CF)),
sdk.NewCoin("usdx", sdk.NewInt(200*USDX_CF)), sdk.NewCoin("busd", sdk.NewInt(100*BUSD_CF))) sdk.NewCoin("usdx", sdk.NewInt(200*USDX_CF)), sdk.NewCoin("busd", sdk.NewInt(100*BUSD_CF)))
supplyKeeper.MintCoins(ctx, types.ModuleAccountName, harvestMaccCoins) supplyKeeper.MintCoins(ctx, types.ModuleAccountName, hardMaccCoins)
keeper := tApp.GetHarvestKeeper() keeper := tApp.GetHardKeeper()
suite.app = tApp suite.app = tApp
suite.ctx = ctx suite.ctx = ctx
suite.keeper = keeper suite.keeper = keeper
@ -351,7 +351,7 @@ func (suite *KeeperTestSuite) TestBorrow() {
var err error var err error
// Run BeginBlocker once to transition MoneyMarkets // Run BeginBlocker once to transition MoneyMarkets
harvest.BeginBlocker(suite.ctx, suite.keeper) hard.BeginBlocker(suite.ctx, suite.keeper)
err = suite.keeper.Deposit(suite.ctx, tc.args.borrower, tc.args.depositCoins) err = suite.keeper.Deposit(suite.ctx, tc.args.borrower, tc.args.depositCoins)
suite.Require().NoError(err) suite.Require().NoError(err)

View File

@ -6,16 +6,16 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
validatorvesting "github.com/kava-labs/kava/x/validator-vesting" validatorvesting "github.com/kava-labs/kava/x/validator-vesting"
) )
const ( const (
// BeginningOfMonth harvest rewards that are claimed after the 15th at 14:00UTC of the month always vest on the first of the month // BeginningOfMonth hard rewards that are claimed after the 15th at 14:00UTC of the month always vest on the first of the month
BeginningOfMonth = 1 BeginningOfMonth = 1
// MidMonth harvest rewards that are claimed before the 15th at 14:00UTC of the month always vest on the 15 of the month // MidMonth hard rewards that are claimed before the 15th at 14:00UTC of the month always vest on the 15 of the month
MidMonth = 15 MidMonth = 15
// PaymentHour harvest rewards always vest at 14:00UTC // PaymentHour hard rewards always vest at 14:00UTC
PaymentHour = 14 PaymentHour = 14
) )
@ -45,7 +45,7 @@ func (k Keeper) ClaimReward(ctx sdk.Context, claimHolder sdk.AccAddress, receive
} }
ctx.EventManager().EmitEvent( ctx.EventManager().EmitEvent(
sdk.NewEvent( sdk.NewEvent(
types.EventTypeClaimHarvestReward, types.EventTypeClaimHardReward,
sdk.NewAttribute(sdk.AttributeKeyAmount, claim.Amount.String()), sdk.NewAttribute(sdk.AttributeKeyAmount, claim.Amount.String()),
sdk.NewAttribute(types.AttributeKeyClaimHolder, claimHolder.String()), sdk.NewAttribute(types.AttributeKeyClaimHolder, claimHolder.String()),
sdk.NewAttribute(types.AttributeKeyDepositDenom, depositDenom), sdk.NewAttribute(types.AttributeKeyDepositDenom, depositDenom),

View File

@ -11,7 +11,7 @@ import (
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
validatorvesting "github.com/kava-labs/kava/x/validator-vesting" validatorvesting "github.com/kava-labs/kava/x/validator-vesting"
) )
@ -254,7 +254,7 @@ func (suite *KeeperTestSuite) TestClaim() {
sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(1000)), sdk.NewCoin("btcb", sdk.NewInt(1000))), sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(1000)), sdk.NewCoin("btcb", sdk.NewInt(1000))),
}) })
loanToValue := sdk.MustNewDecFromStr("0.6") loanToValue := sdk.MustNewDecFromStr("0.6")
harvestGS := types.NewGenesisState(types.NewParams( hardGS := types.NewGenesisState(types.NewParams(
true, true,
types.DistributionSchedules{ types.DistributionSchedules{
types.NewDistributionSchedule(true, "bnb", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Large, 24, sdk.OneDec())}), types.NewDistributionSchedule(true, "bnb", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Large, 24, sdk.OneDec())}),
@ -270,7 +270,7 @@ func (suite *KeeperTestSuite) TestClaim() {
}, },
0, // LTV counter 0, // LTV counter
), types.DefaultPreviousBlockTime, types.DefaultDistributionTimes) ), types.DefaultPreviousBlockTime, types.DefaultDistributionTimes)
tApp.InitializeFromGenesisStates(authGS, app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(harvestGS)}) tApp.InitializeFromGenesisStates(authGS, app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(hardGS)})
if tc.args.validatorVesting { if tc.args.validatorVesting {
ak := tApp.GetAccountKeeper() ak := tApp.GetAccountKeeper()
acc := ak.GetAccount(ctx, tc.args.claimOwner) acc := ak.GetAccount(ctx, tc.args.claimOwner)
@ -298,7 +298,7 @@ func (suite *KeeperTestSuite) TestClaim() {
supplyKeeper := tApp.GetSupplyKeeper() supplyKeeper := tApp.GetSupplyKeeper()
supplyKeeper.MintCoins(ctx, types.LPAccount, sdk.NewCoins(sdk.NewCoin("hard", sdk.NewInt(1000)))) supplyKeeper.MintCoins(ctx, types.LPAccount, sdk.NewCoins(sdk.NewCoin("hard", sdk.NewInt(1000))))
supplyKeeper.MintCoins(ctx, types.DelegatorAccount, sdk.NewCoins(sdk.NewCoin("hard", sdk.NewInt(1000)))) supplyKeeper.MintCoins(ctx, types.DelegatorAccount, sdk.NewCoins(sdk.NewCoin("hard", sdk.NewInt(1000))))
keeper := tApp.GetHarvestKeeper() keeper := tApp.GetHardKeeper()
suite.app = tApp suite.app = tApp
suite.ctx = ctx suite.ctx = ctx
suite.keeper = keeper suite.keeper = keeper

View File

@ -7,7 +7,7 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
supplyExported "github.com/cosmos/cosmos-sdk/x/supply/exported" supplyExported "github.com/cosmos/cosmos-sdk/x/supply/exported"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
// Deposit deposit // Deposit deposit
@ -57,7 +57,7 @@ func (k Keeper) Deposit(ctx sdk.Context, depositor sdk.AccAddress, coins sdk.Coi
ctx.EventManager().EmitEvent( ctx.EventManager().EmitEvent(
sdk.NewEvent( sdk.NewEvent(
types.EventTypeHarvestDeposit, types.EventTypeHardDeposit,
sdk.NewAttribute(sdk.AttributeKeyAmount, coins.String()), sdk.NewAttribute(sdk.AttributeKeyAmount, coins.String()),
sdk.NewAttribute(types.AttributeKeyDepositor, deposit.Depositor.String()), sdk.NewAttribute(types.AttributeKeyDepositor, deposit.Depositor.String()),
), ),
@ -102,7 +102,7 @@ func (k Keeper) Withdraw(ctx sdk.Context, depositor sdk.AccAddress, coins sdk.Co
ctx.EventManager().EmitEvent( ctx.EventManager().EmitEvent(
sdk.NewEvent( sdk.NewEvent(
types.EventTypeHarvestWithdrawal, types.EventTypeHardWithdrawal,
sdk.NewAttribute(sdk.AttributeKeyAmount, coins.String()), sdk.NewAttribute(sdk.AttributeKeyAmount, coins.String()),
sdk.NewAttribute(types.AttributeKeyDepositor, depositor.String()), sdk.NewAttribute(types.AttributeKeyDepositor, depositor.String()),
), ),
@ -111,7 +111,7 @@ func (k Keeper) Withdraw(ctx sdk.Context, depositor sdk.AccAddress, coins sdk.Co
if deposit.Amount.IsEqual(coins) { if deposit.Amount.IsEqual(coins) {
ctx.EventManager().EmitEvent( ctx.EventManager().EmitEvent(
sdk.NewEvent( sdk.NewEvent(
types.EventTypeDeleteHarvestDeposit, types.EventTypeDeleteHardDeposit,
sdk.NewAttribute(types.AttributeKeyDepositor, depositor.String()), sdk.NewAttribute(types.AttributeKeyDepositor, depositor.String()),
), ),
) )

View File

@ -11,8 +11,8 @@ import (
tmtime "github.com/tendermint/tendermint/types/time" tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/harvest" "github.com/kava-labs/kava/x/hard"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
"github.com/kava-labs/kava/x/pricefeed" "github.com/kava-labs/kava/x/pricefeed"
) )
@ -105,7 +105,7 @@ func (suite *KeeperTestSuite) TestDeposit() {
ctx := tApp.NewContext(true, abci.Header{Height: 1, Time: tmtime.Now()}) ctx := tApp.NewContext(true, abci.Header{Height: 1, Time: tmtime.Now()})
authGS := app.NewAuthGenState([]sdk.AccAddress{tc.args.depositor}, []sdk.Coins{sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(1000)), sdk.NewCoin("btcb", sdk.NewInt(1000)))}) authGS := app.NewAuthGenState([]sdk.AccAddress{tc.args.depositor}, []sdk.Coins{sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(1000)), sdk.NewCoin("btcb", sdk.NewInt(1000)))})
loanToValue, _ := sdk.NewDecFromStr("0.6") loanToValue, _ := sdk.NewDecFromStr("0.6")
harvestGS := types.NewGenesisState(types.NewParams( hardGS := types.NewGenesisState(types.NewParams(
true, true,
types.DistributionSchedules{ types.DistributionSchedules{
types.NewDistributionSchedule(true, "bnb", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Medium, 24, sdk.OneDec())}), types.NewDistributionSchedule(true, "bnb", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Medium, 24, sdk.OneDec())}),
@ -164,15 +164,15 @@ func (suite *KeeperTestSuite) TestDeposit() {
tApp.InitializeFromGenesisStates(authGS, tApp.InitializeFromGenesisStates(authGS,
app.GenesisState{pricefeed.ModuleName: pricefeed.ModuleCdc.MustMarshalJSON(pricefeedGS)}, app.GenesisState{pricefeed.ModuleName: pricefeed.ModuleCdc.MustMarshalJSON(pricefeedGS)},
app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(harvestGS)}, app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(hardGS)},
) )
keeper := tApp.GetHarvestKeeper() keeper := tApp.GetHardKeeper()
suite.app = tApp suite.app = tApp
suite.ctx = ctx suite.ctx = ctx
suite.keeper = keeper suite.keeper = keeper
// Run BeginBlocker once to transition MoneyMarkets // Run BeginBlocker once to transition MoneyMarkets
harvest.BeginBlocker(suite.ctx, suite.keeper) hard.BeginBlocker(suite.ctx, suite.keeper)
// run the test // run the test
var err error var err error
@ -297,7 +297,7 @@ func (suite *KeeperTestSuite) TestWithdraw() {
ctx := tApp.NewContext(true, abci.Header{Height: 1, Time: tmtime.Now()}) ctx := tApp.NewContext(true, abci.Header{Height: 1, Time: tmtime.Now()})
authGS := app.NewAuthGenState([]sdk.AccAddress{tc.args.depositor}, []sdk.Coins{sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(1000)), sdk.NewCoin("btcb", sdk.NewInt(1000)))}) authGS := app.NewAuthGenState([]sdk.AccAddress{tc.args.depositor}, []sdk.Coins{sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(1000)), sdk.NewCoin("btcb", sdk.NewInt(1000)))})
loanToValue := sdk.MustNewDecFromStr("0.6") loanToValue := sdk.MustNewDecFromStr("0.6")
harvestGS := types.NewGenesisState(types.NewParams( hardGS := types.NewGenesisState(types.NewParams(
true, true,
types.DistributionSchedules{ types.DistributionSchedules{
types.NewDistributionSchedule(true, "bnb", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Medium, 24, sdk.OneDec())}), types.NewDistributionSchedule(true, "bnb", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Medium, 24, sdk.OneDec())}),
@ -313,8 +313,8 @@ func (suite *KeeperTestSuite) TestWithdraw() {
}, },
0, // LTV counter 0, // LTV counter
), types.DefaultPreviousBlockTime, types.DefaultDistributionTimes) ), types.DefaultPreviousBlockTime, types.DefaultDistributionTimes)
tApp.InitializeFromGenesisStates(authGS, app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(harvestGS)}) tApp.InitializeFromGenesisStates(authGS, app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(hardGS)})
keeper := tApp.GetHarvestKeeper() keeper := tApp.GetHardKeeper()
suite.app = tApp suite.app = tApp
suite.ctx = ctx suite.ctx = ctx
suite.keeper = keeper suite.keeper = keeper

View File

@ -3,7 +3,7 @@ package keeper
import ( import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
var ( var (
@ -69,7 +69,7 @@ func (k Keeper) AccrueInterest(ctx sdk.Context, denom string) error {
return nil return nil
} }
// Get available harvest module account cash on hand // Get available hard module account cash on hand
cashPrior := k.supplyKeeper.GetModuleAccount(ctx, types.ModuleName).GetCoins().AmountOf(denom) cashPrior := k.supplyKeeper.GetModuleAccount(ctx, types.ModuleName).GetCoins().AmountOf(denom)
// Get prior borrows // Get prior borrows

View File

@ -11,8 +11,8 @@ import (
tmtime "github.com/tendermint/tendermint/types/time" tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/harvest" "github.com/kava-labs/kava/x/hard"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
"github.com/kava-labs/kava/x/pricefeed" "github.com/kava-labs/kava/x/pricefeed"
) )
@ -83,7 +83,7 @@ func (suite *InterestTestSuite) TestCalculateUtilizationRatio() {
for _, tc := range testCases { for _, tc := range testCases {
suite.Run(tc.name, func() { suite.Run(tc.name, func() {
utilRatio := harvest.CalculateUtilizationRatio(tc.args.cash, tc.args.borrows, tc.args.reserves) utilRatio := hard.CalculateUtilizationRatio(tc.args.cash, tc.args.borrows, tc.args.reserves)
suite.Require().Equal(tc.args.expectedValue, utilRatio) suite.Require().Equal(tc.args.expectedValue, utilRatio)
}) })
} }
@ -195,7 +195,7 @@ func (suite *InterestTestSuite) TestCalculateBorrowRate() {
for _, tc := range testCases { for _, tc := range testCases {
suite.Run(tc.name, func() { suite.Run(tc.name, func() {
borrowRate, err := harvest.CalculateBorrowRate(tc.args.model, tc.args.cash, tc.args.borrows, tc.args.reserves) borrowRate, err := hard.CalculateBorrowRate(tc.args.model, tc.args.cash, tc.args.borrows, tc.args.reserves)
suite.Require().NoError(err) suite.Require().NoError(err)
suite.Require().Equal(tc.args.expectedValue, borrowRate) suite.Require().Equal(tc.args.expectedValue, borrowRate)
}) })
@ -302,7 +302,7 @@ func (suite *InterestTestSuite) TestCalculateInterestFactor() {
} }
for _, tc := range testCases { for _, tc := range testCases {
interestFactor := harvest.CalculateInterestFactor(tc.args.perSecondInterestRate, tc.args.timeElapsed) interestFactor := hard.CalculateInterestFactor(tc.args.perSecondInterestRate, tc.args.timeElapsed)
suite.Require().Equal(tc.args.expectedValue, interestFactor) suite.Require().Equal(tc.args.expectedValue, interestFactor)
} }
} }
@ -380,7 +380,7 @@ func (suite *InterestTestSuite) TestAPYToSPY() {
for _, tc := range testCases { for _, tc := range testCases {
suite.Run(tc.name, func() { suite.Run(tc.name, func() {
spy, err := harvest.APYToSPY(tc.args.apy) spy, err := hard.APYToSPY(tc.args.apy)
if tc.expectError { if tc.expectError {
suite.Require().Error(err) suite.Require().Error(err)
} else { } else {
@ -645,8 +645,8 @@ func (suite *KeeperTestSuite) TestInterest() {
[]sdk.Coins{tc.args.initialBorrowerCoins}, []sdk.Coins{tc.args.initialBorrowerCoins},
) )
// Harvest module genesis state // Hard module genesis state
harvestGS := types.NewGenesisState(types.NewParams( hardGS := types.NewGenesisState(types.NewParams(
true, true,
types.DistributionSchedules{ types.DistributionSchedules{
types.NewDistributionSchedule(true, "ukava", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Medium, 24, sdk.OneDec())}), types.NewDistributionSchedule(true, "ukava", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Medium, 24, sdk.OneDec())}),
@ -689,13 +689,13 @@ func (suite *KeeperTestSuite) TestInterest() {
// Initialize test application // Initialize test application
tApp.InitializeFromGenesisStates(authGS, tApp.InitializeFromGenesisStates(authGS,
app.GenesisState{pricefeed.ModuleName: pricefeed.ModuleCdc.MustMarshalJSON(pricefeedGS)}, app.GenesisState{pricefeed.ModuleName: pricefeed.ModuleCdc.MustMarshalJSON(pricefeedGS)},
app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(harvestGS)}) app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(hardGS)})
// Mint coins to Harvest module account // Mint coins to Hard module account
supplyKeeper := tApp.GetSupplyKeeper() supplyKeeper := tApp.GetSupplyKeeper()
supplyKeeper.MintCoins(ctx, types.ModuleAccountName, tc.args.initialModuleCoins) supplyKeeper.MintCoins(ctx, types.ModuleAccountName, tc.args.initialModuleCoins)
keeper := tApp.GetHarvestKeeper() keeper := tApp.GetHardKeeper()
suite.app = tApp suite.app = tApp
suite.ctx = ctx suite.ctx = ctx
suite.keeper = keeper suite.keeper = keeper
@ -703,7 +703,7 @@ func (suite *KeeperTestSuite) TestInterest() {
var err error var err error
// Run begin blocker and store initial block time // Run begin blocker and store initial block time
harvest.BeginBlocker(suite.ctx, suite.keeper) hard.BeginBlocker(suite.ctx, suite.keeper)
// Deposit 2x as many coins for each coin we intend to borrow // Deposit 2x as many coins for each coin we intend to borrow
depositCoins := sdk.NewCoins() depositCoins := sdk.NewCoins()
@ -741,14 +741,14 @@ func (suite *KeeperTestSuite) TestInterest() {
suite.Require().True(foundInterestFactorPrior) suite.Require().True(foundInterestFactorPrior)
// 2. Calculate expected interest owed // 2. Calculate expected interest owed
borrowRateApy, err := harvest.CalculateBorrowRate(tc.args.interestRateModel, sdk.NewDecFromInt(cashPrior), sdk.NewDecFromInt(borrowCoinPriorAmount), sdk.NewDecFromInt(reservesPrior.Amount)) borrowRateApy, err := hard.CalculateBorrowRate(tc.args.interestRateModel, sdk.NewDecFromInt(cashPrior), sdk.NewDecFromInt(borrowCoinPriorAmount), sdk.NewDecFromInt(reservesPrior.Amount))
suite.Require().NoError(err) suite.Require().NoError(err)
// Convert from APY to SPY, expressed as (1 + borrow rate) // Convert from APY to SPY, expressed as (1 + borrow rate)
borrowRateSpy, err := harvest.APYToSPY(sdk.OneDec().Add(borrowRateApy)) borrowRateSpy, err := hard.APYToSPY(sdk.OneDec().Add(borrowRateApy))
suite.Require().NoError(err) suite.Require().NoError(err)
interestFactor := harvest.CalculateInterestFactor(borrowRateSpy, sdk.NewInt(snapshot.elapsedTime)) interestFactor := hard.CalculateInterestFactor(borrowRateSpy, sdk.NewInt(snapshot.elapsedTime))
expectedInterest := (interestFactor.Mul(sdk.NewDecFromInt(borrowCoinPriorAmount)).TruncateInt()).Sub(borrowCoinPriorAmount) expectedInterest := (interestFactor.Mul(sdk.NewDecFromInt(borrowCoinPriorAmount)).TruncateInt()).Sub(borrowCoinPriorAmount)
expectedReserves := reservesPrior.Add(sdk.NewCoin(tc.args.borrowCoinDenom, sdk.NewDecFromInt(expectedInterest).Mul(tc.args.reserveFactor).TruncateInt())) expectedReserves := reservesPrior.Add(sdk.NewCoin(tc.args.borrowCoinDenom, sdk.NewDecFromInt(expectedInterest).Mul(tc.args.reserveFactor).TruncateInt()))
expectedInterestFactor := interestFactorPrior.Mul(interestFactor) expectedInterestFactor := interestFactorPrior.Mul(interestFactor)
@ -757,7 +757,7 @@ func (suite *KeeperTestSuite) TestInterest() {
// Set up snapshot chain context and run begin blocker // Set up snapshot chain context and run begin blocker
runAtTime := time.Unix(prevCtx.BlockTime().Unix()+(snapshot.elapsedTime), 0) runAtTime := time.Unix(prevCtx.BlockTime().Unix()+(snapshot.elapsedTime), 0)
snapshotCtx := prevCtx.WithBlockTime(runAtTime) snapshotCtx := prevCtx.WithBlockTime(runAtTime)
harvest.BeginBlocker(snapshotCtx, suite.keeper) hard.BeginBlocker(snapshotCtx, suite.keeper)
// Check that the total amount of borrowed coins has increased by expected interest amount // Check that the total amount of borrowed coins has increased by expected interest amount
expectedBorrowedCoins := borrowCoinsPrior.AmountOf(tc.args.borrowCoinDenom).Add(expectedInterest) expectedBorrowedCoins := borrowCoinsPrior.AmountOf(tc.args.borrowCoinDenom).Add(expectedInterest)

View File

@ -8,10 +8,10 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/params/subspace" "github.com/cosmos/cosmos-sdk/x/params/subspace"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
// Keeper keeper for the harvest module // Keeper keeper for the hard module
type Keeper struct { type Keeper struct {
key sdk.StoreKey key sdk.StoreKey
cdc *codec.Codec cdc *codec.Codec

View File

@ -17,8 +17,8 @@ import (
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
aucKeeper "github.com/kava-labs/kava/x/auction/keeper" aucKeeper "github.com/kava-labs/kava/x/auction/keeper"
"github.com/kava-labs/kava/x/harvest/keeper" "github.com/kava-labs/kava/x/hard/keeper"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
// Test suite used for all keeper tests // Test suite used for all keeper tests
@ -40,7 +40,7 @@ func (suite *KeeperTestSuite) SetupTest() {
ctx := tApp.NewContext(true, abci.Header{Height: 1, Time: tmtime.Now()}) ctx := tApp.NewContext(true, abci.Header{Height: 1, Time: tmtime.Now()})
tApp.InitializeFromGenesisStates() tApp.InitializeFromGenesisStates()
_, addrs := app.GeneratePrivKeyAddressPairs(1) _, addrs := app.GeneratePrivKeyAddressPairs(1)
keeper := tApp.GetHarvestKeeper() keeper := tApp.GetHardKeeper()
suite.app = tApp suite.app = tApp
suite.ctx = ctx suite.ctx = ctx
suite.keeper = keeper suite.keeper = keeper

View File

@ -6,7 +6,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
// LiqData holds liquidation-related data // LiqData holds liquidation-related data

View File

@ -11,8 +11,8 @@ import (
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
auctypes "github.com/kava-labs/kava/x/auction/types" auctypes "github.com/kava-labs/kava/x/auction/types"
"github.com/kava-labs/kava/x/harvest" "github.com/kava-labs/kava/x/hard"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
"github.com/kava-labs/kava/x/pricefeed" "github.com/kava-labs/kava/x/pricefeed"
) )
@ -69,7 +69,7 @@ func (suite *KeeperTestSuite) TestIndexLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 1, ID: 1,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("ukava", 10*KAVA_CF), Lot: sdk.NewInt64Coin("ukava", 10*KAVA_CF),
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("ukava", 0), Bid: sdk.NewInt64Coin("ukava", 0),
@ -120,8 +120,8 @@ func (suite *KeeperTestSuite) TestIndexLiquidation() {
[]sdk.Coins{tc.args.initialBorrowerCoins}, []sdk.Coins{tc.args.initialBorrowerCoins},
) )
// Harvest module genesis state // Hard module genesis state
harvestGS := types.NewGenesisState(types.NewParams( hardGS := types.NewGenesisState(types.NewParams(
true, true,
types.DistributionSchedules{ types.DistributionSchedules{
types.NewDistributionSchedule(true, "usdx", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Medium, 24, sdk.OneDec())}), types.NewDistributionSchedule(true, "usdx", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Medium, 24, sdk.OneDec())}),
@ -260,15 +260,15 @@ func (suite *KeeperTestSuite) TestIndexLiquidation() {
// Initialize test application // Initialize test application
tApp.InitializeFromGenesisStates(authGS, tApp.InitializeFromGenesisStates(authGS,
app.GenesisState{pricefeed.ModuleName: pricefeed.ModuleCdc.MustMarshalJSON(pricefeedGS)}, app.GenesisState{pricefeed.ModuleName: pricefeed.ModuleCdc.MustMarshalJSON(pricefeedGS)},
app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(harvestGS)}) app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(hardGS)})
// Mint coins to Harvest module account // Mint coins to Hard module account
supplyKeeper := tApp.GetSupplyKeeper() supplyKeeper := tApp.GetSupplyKeeper()
supplyKeeper.MintCoins(ctx, types.ModuleAccountName, tc.args.initialModuleCoins) supplyKeeper.MintCoins(ctx, types.ModuleAccountName, tc.args.initialModuleCoins)
auctionKeeper := tApp.GetAuctionKeeper() auctionKeeper := tApp.GetAuctionKeeper()
keeper := tApp.GetHarvestKeeper() keeper := tApp.GetHardKeeper()
suite.app = tApp suite.app = tApp
suite.ctx = ctx suite.ctx = ctx
suite.keeper = keeper suite.keeper = keeper
@ -277,7 +277,7 @@ func (suite *KeeperTestSuite) TestIndexLiquidation() {
var err error var err error
// Run begin blocker to set up state // Run begin blocker to set up state
harvest.BeginBlocker(suite.ctx, suite.keeper) hard.BeginBlocker(suite.ctx, suite.keeper)
// Deposit coins // Deposit coins
err = suite.keeper.Deposit(suite.ctx, tc.args.borrower, tc.args.depositCoins) err = suite.keeper.Deposit(suite.ctx, tc.args.borrower, tc.args.depositCoins)
@ -298,7 +298,7 @@ func (suite *KeeperTestSuite) TestIndexLiquidation() {
// Liquidate the borrow by running begin blocker // Liquidate the borrow by running begin blocker
runAtTime := time.Unix(suite.ctx.BlockTime().Unix()+(tc.args.beginBlockerTime), 0) runAtTime := time.Unix(suite.ctx.BlockTime().Unix()+(tc.args.beginBlockerTime), 0)
liqCtx := suite.ctx.WithBlockTime(runAtTime) liqCtx := suite.ctx.WithBlockTime(runAtTime)
harvest.BeginBlocker(liqCtx, suite.keeper) hard.BeginBlocker(liqCtx, suite.keeper)
if tc.errArgs.expectLiquidate { if tc.errArgs.expectLiquidate {
// Check borrow does not exist after liquidation // Check borrow does not exist after liquidation
@ -403,7 +403,7 @@ func (suite *KeeperTestSuite) TestFullIndexLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 1, ID: 1,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("ukava", 10*KAVA_CF), Lot: sdk.NewInt64Coin("ukava", 10*KAVA_CF),
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("ukava", 0), Bid: sdk.NewInt64Coin("ukava", 0),
@ -440,7 +440,7 @@ func (suite *KeeperTestSuite) TestFullIndexLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 1, ID: 1,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("ukava", 10*KAVA_CF), Lot: sdk.NewInt64Coin("ukava", 10*KAVA_CF),
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("ukava", 0), Bid: sdk.NewInt64Coin("ukava", 0),
@ -455,7 +455,7 @@ func (suite *KeeperTestSuite) TestFullIndexLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 2, ID: 2,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("ukava", 10*KAVA_CF), Lot: sdk.NewInt64Coin("ukava", 10*KAVA_CF),
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("ukava", 0), Bid: sdk.NewInt64Coin("ukava", 0),
@ -470,7 +470,7 @@ func (suite *KeeperTestSuite) TestFullIndexLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 3, ID: 3,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("ukava", 10*KAVA_CF), Lot: sdk.NewInt64Coin("ukava", 10*KAVA_CF),
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("ukava", 0), Bid: sdk.NewInt64Coin("ukava", 0),
@ -485,7 +485,7 @@ func (suite *KeeperTestSuite) TestFullIndexLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 4, ID: 4,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("ukava", 10*KAVA_CF), Lot: sdk.NewInt64Coin("ukava", 10*KAVA_CF),
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("ukava", 0), Bid: sdk.NewInt64Coin("ukava", 0),
@ -546,8 +546,8 @@ func (suite *KeeperTestSuite) TestFullIndexLiquidation() {
// Auth module genesis state // Auth module genesis state
authGS := app.NewAuthGenState(appAddrs, appCoins) authGS := app.NewAuthGenState(appAddrs, appCoins)
// Harvest module genesis state // Hard module genesis state
harvestGS := types.NewGenesisState(types.NewParams( hardGS := types.NewGenesisState(types.NewParams(
true, true,
types.DistributionSchedules{ types.DistributionSchedules{
types.NewDistributionSchedule(true, "usdx", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Medium, 24, sdk.OneDec())}), types.NewDistributionSchedule(true, "usdx", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Medium, 24, sdk.OneDec())}),
@ -606,15 +606,15 @@ func (suite *KeeperTestSuite) TestFullIndexLiquidation() {
// Initialize test application // Initialize test application
tApp.InitializeFromGenesisStates(authGS, tApp.InitializeFromGenesisStates(authGS,
app.GenesisState{pricefeed.ModuleName: pricefeed.ModuleCdc.MustMarshalJSON(pricefeedGS)}, app.GenesisState{pricefeed.ModuleName: pricefeed.ModuleCdc.MustMarshalJSON(pricefeedGS)},
app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(harvestGS)}) app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(hardGS)})
// Mint coins to Harvest module account // Mint coins to Hard module account
supplyKeeper := tApp.GetSupplyKeeper() supplyKeeper := tApp.GetSupplyKeeper()
supplyKeeper.MintCoins(ctx, types.ModuleAccountName, tc.args.initialModuleCoins) supplyKeeper.MintCoins(ctx, types.ModuleAccountName, tc.args.initialModuleCoins)
auctionKeeper := tApp.GetAuctionKeeper() auctionKeeper := tApp.GetAuctionKeeper()
keeper := tApp.GetHarvestKeeper() keeper := tApp.GetHardKeeper()
suite.app = tApp suite.app = tApp
suite.ctx = ctx suite.ctx = ctx
suite.keeper = keeper suite.keeper = keeper
@ -623,7 +623,7 @@ func (suite *KeeperTestSuite) TestFullIndexLiquidation() {
var err error var err error
// Run begin blocker to set up state // Run begin blocker to set up state
harvest.BeginBlocker(suite.ctx, suite.keeper) hard.BeginBlocker(suite.ctx, suite.keeper)
// ----------- Users get inserted into the LTV index ----------- // ----------- Users get inserted into the LTV index -----------
@ -664,7 +664,7 @@ func (suite *KeeperTestSuite) TestFullIndexLiquidation() {
// Liquidate the borrow by running begin blocker // Liquidate the borrow by running begin blocker
runAtTime := time.Unix(suite.ctx.BlockTime().Unix()+(tc.args.beginBlockerTime), 0) runAtTime := time.Unix(suite.ctx.BlockTime().Unix()+(tc.args.beginBlockerTime), 0)
liqCtx := suite.ctx.WithBlockTime(runAtTime) liqCtx := suite.ctx.WithBlockTime(runAtTime)
harvest.BeginBlocker(liqCtx, suite.keeper) hard.BeginBlocker(liqCtx, suite.keeper)
if tc.errArgs.expectLiquidate { if tc.errArgs.expectLiquidate {
// Check borrow does not exist after liquidation // Check borrow does not exist after liquidation
@ -805,7 +805,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 1, ID: 1,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("ukava", 9499999), Lot: sdk.NewInt64Coin("ukava", 9499999),
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("ukava", 0), Bid: sdk.NewInt64Coin("ukava", 0),
@ -843,7 +843,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 1, ID: 1,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("ukava", 11874422), Lot: sdk.NewInt64Coin("ukava", 11874422),
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("bnb", 0), Bid: sdk.NewInt64Coin("bnb", 0),
@ -858,7 +858,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 2, ID: 2,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("ukava", 11874245), Lot: sdk.NewInt64Coin("ukava", 11874245),
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("btc", 0), Bid: sdk.NewInt64Coin("btc", 0),
@ -873,7 +873,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 3, ID: 3,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("ukava", 11875155), Lot: sdk.NewInt64Coin("ukava", 11875155),
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("ukava", 0), Bid: sdk.NewInt64Coin("ukava", 0),
@ -888,7 +888,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 4, ID: 4,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("ukava", 11876178), Lot: sdk.NewInt64Coin("ukava", 11876178),
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("usdc", 0), Bid: sdk.NewInt64Coin("usdc", 0),
@ -926,7 +926,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 1, ID: 1,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("bnb", 950000000), Lot: sdk.NewInt64Coin("bnb", 950000000),
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("ukava", 0), Bid: sdk.NewInt64Coin("ukava", 0),
@ -941,7 +941,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 2, ID: 2,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("btc", 95000000), Lot: sdk.NewInt64Coin("btc", 95000000),
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("ukava", 0), Bid: sdk.NewInt64Coin("ukava", 0),
@ -956,7 +956,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 3, ID: 3,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("ukava", 47499999), Lot: sdk.NewInt64Coin("ukava", 47499999),
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("ukava", 0), Bid: sdk.NewInt64Coin("ukava", 0),
@ -995,7 +995,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 1, ID: 1,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("usdc", 95000000), // $95.00 Lot: sdk.NewInt64Coin("usdc", 95000000), // $95.00
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("bnb", 0), Bid: sdk.NewInt64Coin("bnb", 0),
@ -1010,7 +1010,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 2, ID: 2,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("usdt", 10552835), // $10.55 Lot: sdk.NewInt64Coin("usdt", 10552835), // $10.55
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("bnb", 0), Bid: sdk.NewInt64Coin("bnb", 0),
@ -1025,7 +1025,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 3, ID: 3,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("usdt", 84447165), // $84.45 Lot: sdk.NewInt64Coin("usdt", 84447165), // $84.45
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("btc", 0), Bid: sdk.NewInt64Coin("btc", 0),
@ -1040,7 +1040,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 4, ID: 4,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("usdx", 21097866), // $21.10 Lot: sdk.NewInt64Coin("usdx", 21097866), // $21.10
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("btc", 0), Bid: sdk.NewInt64Coin("btc", 0),
@ -1055,7 +1055,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 5, ID: 5,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("usdx", 73902133), //$73.90 Lot: sdk.NewInt64Coin("usdx", 73902133), //$73.90
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("ukava", 0), Bid: sdk.NewInt64Coin("ukava", 0),
@ -1093,7 +1093,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 1, ID: 1,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("dai", 263894126), Lot: sdk.NewInt64Coin("dai", 263894126),
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("usdt", 0), Bid: sdk.NewInt64Coin("usdt", 0),
@ -1108,7 +1108,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 2, ID: 2,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("dai", 68605874), Lot: sdk.NewInt64Coin("dai", 68605874),
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("usdx", 0), Bid: sdk.NewInt64Coin("usdx", 0),
@ -1123,7 +1123,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
auctypes.CollateralAuction{ auctypes.CollateralAuction{
BaseAuction: auctypes.BaseAuction{ BaseAuction: auctypes.BaseAuction{
ID: 3, ID: 3,
Initiator: "harvest_liquidator", Initiator: "hard_liquidator",
Lot: sdk.NewInt64Coin("usdc", 189999999), Lot: sdk.NewInt64Coin("usdc", 189999999),
Bidder: nil, Bidder: nil,
Bid: sdk.NewInt64Coin("usdx", 0), Bid: sdk.NewInt64Coin("usdx", 0),
@ -1178,8 +1178,8 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
[]sdk.Coins{tc.args.initialBorrowerCoins, tc.args.initialKeeperCoins}, []sdk.Coins{tc.args.initialBorrowerCoins, tc.args.initialKeeperCoins},
) )
// Harvest module genesis state // Hard module genesis state
harvestGS := types.NewGenesisState(types.NewParams( hardGS := types.NewGenesisState(types.NewParams(
true, true,
types.DistributionSchedules{ types.DistributionSchedules{
types.NewDistributionSchedule(true, "usdx", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Medium, 24, sdk.OneDec())}), types.NewDistributionSchedule(true, "usdx", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Medium, 24, sdk.OneDec())}),
@ -1318,15 +1318,15 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
// Initialize test application // Initialize test application
tApp.InitializeFromGenesisStates(authGS, tApp.InitializeFromGenesisStates(authGS,
app.GenesisState{pricefeed.ModuleName: pricefeed.ModuleCdc.MustMarshalJSON(pricefeedGS)}, app.GenesisState{pricefeed.ModuleName: pricefeed.ModuleCdc.MustMarshalJSON(pricefeedGS)},
app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(harvestGS)}) app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(hardGS)})
// Mint coins to Harvest module account // Mint coins to Hard module account
supplyKeeper := tApp.GetSupplyKeeper() supplyKeeper := tApp.GetSupplyKeeper()
supplyKeeper.MintCoins(ctx, types.ModuleAccountName, tc.args.initialModuleCoins) supplyKeeper.MintCoins(ctx, types.ModuleAccountName, tc.args.initialModuleCoins)
auctionKeeper := tApp.GetAuctionKeeper() auctionKeeper := tApp.GetAuctionKeeper()
keeper := tApp.GetHarvestKeeper() keeper := tApp.GetHardKeeper()
suite.app = tApp suite.app = tApp
suite.ctx = ctx suite.ctx = ctx
suite.keeper = keeper suite.keeper = keeper
@ -1335,7 +1335,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
var err error var err error
// Run begin blocker to set up state // Run begin blocker to set up state
harvest.BeginBlocker(suite.ctx, suite.keeper) hard.BeginBlocker(suite.ctx, suite.keeper)
// Deposit coins // Deposit coins
err = suite.keeper.Deposit(suite.ctx, tc.args.borrower, tc.args.depositCoins) err = suite.keeper.Deposit(suite.ctx, tc.args.borrower, tc.args.depositCoins)
@ -1348,7 +1348,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() {
// Set up liquidation chain context and run begin blocker // Set up liquidation chain context and run begin blocker
runAtTime := time.Unix(suite.ctx.BlockTime().Unix()+(tc.args.liquidateAfter), 0) runAtTime := time.Unix(suite.ctx.BlockTime().Unix()+(tc.args.liquidateAfter), 0)
liqCtx := suite.ctx.WithBlockTime(runAtTime) liqCtx := suite.ctx.WithBlockTime(runAtTime)
harvest.BeginBlocker(liqCtx, suite.keeper) hard.BeginBlocker(liqCtx, suite.keeper)
// Check borrow exists before liquidation // Check borrow exists before liquidation
_, foundBorrowBefore := suite.keeper.GetBorrow(liqCtx, tc.args.borrower) _, foundBorrowBefore := suite.keeper.GetBorrow(liqCtx, tc.args.borrower)

View File

@ -3,7 +3,7 @@ package keeper
import ( import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
// GetParams returns the params from the store // GetParams returns the params from the store

View File

@ -9,7 +9,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
// NewQuerier is the module level router for state queries // NewQuerier is the module level router for state queries
@ -164,17 +164,17 @@ func queryGetClaims(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, e
return false return false
}) })
case owner && claimType: case owner && claimType:
harvestParams := k.GetParams(ctx) hardParams := k.GetParams(ctx)
switch { switch {
case params.ClaimType == types.LP: case params.ClaimType == types.LP:
for _, lps := range harvestParams.LiquidityProviderSchedules { for _, lps := range hardParams.LiquidityProviderSchedules {
claim, found := k.GetClaim(ctx, params.Owner, lps.DepositDenom, params.ClaimType) claim, found := k.GetClaim(ctx, params.Owner, lps.DepositDenom, params.ClaimType)
if found { if found {
claims = append(claims, claim) claims = append(claims, claim)
} }
} }
case params.ClaimType == types.Stake: case params.ClaimType == types.Stake:
for _, dss := range harvestParams.DelegatorDistributionSchedules { for _, dss := range hardParams.DelegatorDistributionSchedules {
claim, found := k.GetClaim(ctx, params.Owner, dss.DistributionSchedule.DepositDenom, params.ClaimType) claim, found := k.GetClaim(ctx, params.Owner, dss.DistributionSchedule.DepositDenom, params.ClaimType)
if found { if found {
claims = append(claims, claim) claims = append(claims, claim)
@ -189,28 +189,28 @@ func queryGetClaims(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, e
}) })
} }
case owner: case owner:
harvestParams := k.GetParams(ctx) hardParams := k.GetParams(ctx)
for _, lps := range harvestParams.LiquidityProviderSchedules { for _, lps := range hardParams.LiquidityProviderSchedules {
claim, found := k.GetClaim(ctx, params.Owner, lps.DepositDenom, types.LP) claim, found := k.GetClaim(ctx, params.Owner, lps.DepositDenom, types.LP)
if found { if found {
claims = append(claims, claim) claims = append(claims, claim)
} }
} }
for _, dds := range harvestParams.DelegatorDistributionSchedules { for _, dds := range hardParams.DelegatorDistributionSchedules {
claim, found := k.GetClaim(ctx, params.Owner, dds.DistributionSchedule.DepositDenom, types.Stake) claim, found := k.GetClaim(ctx, params.Owner, dds.DistributionSchedule.DepositDenom, types.Stake)
if found { if found {
claims = append(claims, claim) claims = append(claims, claim)
} }
} }
case claimType: case claimType:
harvestParams := k.GetParams(ctx) hardParams := k.GetParams(ctx)
for _, lps := range harvestParams.LiquidityProviderSchedules { for _, lps := range hardParams.LiquidityProviderSchedules {
k.IterateClaimsByTypeAndDenom(ctx, params.ClaimType, lps.DepositDenom, func(claim types.Claim) (stop bool) { k.IterateClaimsByTypeAndDenom(ctx, params.ClaimType, lps.DepositDenom, func(claim types.Claim) (stop bool) {
claims = append(claims, claim) claims = append(claims, claim)
return false return false
}) })
} }
for _, dds := range harvestParams.DelegatorDistributionSchedules { for _, dds := range hardParams.DelegatorDistributionSchedules {
k.IterateClaimsByTypeAndDenom(ctx, params.ClaimType, dds.DistributionSchedule.DepositDenom, func(claim types.Claim) (stop bool) { k.IterateClaimsByTypeAndDenom(ctx, params.ClaimType, dds.DistributionSchedule.DepositDenom, func(claim types.Claim) (stop bool) {
claims = append(claims, claim) claims = append(claims, claim)
return false return false

View File

@ -4,7 +4,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
// Repay borrowed funds // Repay borrowed funds
@ -32,7 +32,7 @@ func (k Keeper) Repay(ctx sdk.Context, sender sdk.AccAddress, coins sdk.Coins) e
payment := k.CalculatePaymentAmount(borrow.Amount, coins) payment := k.CalculatePaymentAmount(borrow.Amount, coins)
// Sends coins from user to Harvest module account // Sends coins from user to Hard module account
err = k.supplyKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleAccountName, payment) err = k.supplyKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleAccountName, payment)
if err != nil { if err != nil {
return err return err
@ -49,7 +49,7 @@ func (k Keeper) Repay(ctx sdk.Context, sender sdk.AccAddress, coins sdk.Coins) e
ctx.EventManager().EmitEvent( ctx.EventManager().EmitEvent(
sdk.NewEvent( sdk.NewEvent(
types.EventTypeHarvestRepay, types.EventTypeHardRepay,
sdk.NewAttribute(types.AttributeKeySender, sender.String()), sdk.NewAttribute(types.AttributeKeySender, sender.String()),
sdk.NewAttribute(types.AttributeKeyRepayCoins, payment.String()), sdk.NewAttribute(types.AttributeKeyRepayCoins, payment.String()),
), ),

View File

@ -10,8 +10,8 @@ import (
tmtime "github.com/tendermint/tendermint/types/time" tmtime "github.com/tendermint/tendermint/types/time"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/harvest" "github.com/kava-labs/kava/x/hard"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
"github.com/kava-labs/kava/x/pricefeed" "github.com/kava-labs/kava/x/pricefeed"
) )
@ -114,8 +114,8 @@ func (suite *KeeperTestSuite) TestRepay() {
[]sdk.AccAddress{tc.args.borrower}, []sdk.AccAddress{tc.args.borrower},
[]sdk.Coins{tc.args.initialBorrowerCoins}) []sdk.Coins{tc.args.initialBorrowerCoins})
// Harvest module genesis state // Hard module genesis state
harvestGS := types.NewGenesisState(types.NewParams( hardGS := types.NewGenesisState(types.NewParams(
true, true,
types.DistributionSchedules{ types.DistributionSchedules{
types.NewDistributionSchedule(true, "usdx", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Medium, 24, sdk.OneDec())}), types.NewDistributionSchedule(true, "usdx", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Medium, 24, sdk.OneDec())}),
@ -174,14 +174,14 @@ func (suite *KeeperTestSuite) TestRepay() {
// Initialize test application // Initialize test application
tApp.InitializeFromGenesisStates(authGS, tApp.InitializeFromGenesisStates(authGS,
app.GenesisState{pricefeed.ModuleName: pricefeed.ModuleCdc.MustMarshalJSON(pricefeedGS)}, app.GenesisState{pricefeed.ModuleName: pricefeed.ModuleCdc.MustMarshalJSON(pricefeedGS)},
app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(harvestGS)}, app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(hardGS)},
) )
// Mint coins to Harvest module account // Mint coins to Hard module account
supplyKeeper := tApp.GetSupplyKeeper() supplyKeeper := tApp.GetSupplyKeeper()
supplyKeeper.MintCoins(ctx, types.ModuleAccountName, tc.args.initialModuleCoins) supplyKeeper.MintCoins(ctx, types.ModuleAccountName, tc.args.initialModuleCoins)
keeper := tApp.GetHarvestKeeper() keeper := tApp.GetHardKeeper()
suite.app = tApp suite.app = tApp
suite.ctx = ctx suite.ctx = ctx
suite.keeper = keeper suite.keeper = keeper
@ -189,13 +189,13 @@ func (suite *KeeperTestSuite) TestRepay() {
var err error var err error
// Run BeginBlocker once to transition MoneyMarkets // Run BeginBlocker once to transition MoneyMarkets
harvest.BeginBlocker(suite.ctx, suite.keeper) hard.BeginBlocker(suite.ctx, suite.keeper)
// Deposit coins to harvest // Deposit coins to hard
err = suite.keeper.Deposit(suite.ctx, tc.args.borrower, tc.args.depositCoins) err = suite.keeper.Deposit(suite.ctx, tc.args.borrower, tc.args.depositCoins)
suite.Require().NoError(err) suite.Require().NoError(err)
// Borrow coins from harvest // Borrow coins from hard
err = suite.keeper.Borrow(suite.ctx, tc.args.borrower, tc.args.borrowCoins) err = suite.keeper.Borrow(suite.ctx, tc.args.borrower, tc.args.borrowCoins)
suite.Require().NoError(err) suite.Require().NoError(err)

View File

@ -7,7 +7,7 @@ import (
stakingexported "github.com/cosmos/cosmos-sdk/x/staking/exported" stakingexported "github.com/cosmos/cosmos-sdk/x/staking/exported"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
// ApplyDepositRewards iterates over lp and gov deposits and updates the amount of rewards for each depositor // ApplyDepositRewards iterates over lp and gov deposits and updates the amount of rewards for each depositor
@ -58,7 +58,7 @@ func (k Keeper) ApplyDepositRewards(ctx sdk.Context) {
}) })
ctx.EventManager().EmitEvent( ctx.EventManager().EmitEvent(
sdk.NewEvent( sdk.NewEvent(
types.EventTypeHarvestLPDistribution, types.EventTypeHardLPDistribution,
sdk.NewAttribute(types.AttributeKeyBlockHeight, fmt.Sprintf("%d", ctx.BlockHeight())), sdk.NewAttribute(types.AttributeKeyBlockHeight, fmt.Sprintf("%d", ctx.BlockHeight())),
sdk.NewAttribute(types.AttributeKeyRewardsDistribution, rewardsDistributed.String()), sdk.NewAttribute(types.AttributeKeyRewardsDistribution, rewardsDistributed.String()),
sdk.NewAttribute(types.AttributeKeyDepositDenom, lps.DepositDenom), sdk.NewAttribute(types.AttributeKeyDepositDenom, lps.DepositDenom),
@ -154,7 +154,7 @@ func (k Keeper) ApplyDelegationRewards(ctx sdk.Context, denom string) {
ctx.EventManager().EmitEvent( ctx.EventManager().EmitEvent(
sdk.NewEvent( sdk.NewEvent(
types.EventTypeHarvestDelegatorDistribution, types.EventTypeHardDelegatorDistribution,
sdk.NewAttribute(types.AttributeKeyBlockHeight, fmt.Sprintf("%d", ctx.BlockHeight())), sdk.NewAttribute(types.AttributeKeyBlockHeight, fmt.Sprintf("%d", ctx.BlockHeight())),
sdk.NewAttribute(types.AttributeKeyRewardsDistribution, rewardsDistributed.String()), sdk.NewAttribute(types.AttributeKeyRewardsDistribution, rewardsDistributed.String()),
sdk.NewAttribute(types.AttributeKeyDepositDenom, denom), sdk.NewAttribute(types.AttributeKeyDepositDenom, denom),

View File

@ -13,8 +13,8 @@ import (
"github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/crypto/ed25519"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/harvest/keeper" "github.com/kava-labs/kava/x/hard/keeper"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
func (suite *KeeperTestSuite) TestApplyDepositRewards() { func (suite *KeeperTestSuite) TestApplyDepositRewards() {
@ -64,7 +64,7 @@ func (suite *KeeperTestSuite) TestApplyDepositRewards() {
tApp := app.NewTestApp() tApp := app.NewTestApp()
ctx := tApp.NewContext(true, abci.Header{Height: 1, Time: tc.args.blockTime}) ctx := tApp.NewContext(true, abci.Header{Height: 1, Time: tc.args.blockTime})
loanToValue, _ := sdk.NewDecFromStr("0.6") loanToValue, _ := sdk.NewDecFromStr("0.6")
harvestGS := types.NewGenesisState(types.NewParams( hardGS := types.NewGenesisState(types.NewParams(
true, true,
types.DistributionSchedules{ types.DistributionSchedules{
types.NewDistributionSchedule(true, "bnb", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), tc.args.rewardRate, time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Large, 24, sdk.OneDec())}), types.NewDistributionSchedule(true, "bnb", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), tc.args.rewardRate, time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Large, 24, sdk.OneDec())}),
@ -80,10 +80,10 @@ func (suite *KeeperTestSuite) TestApplyDepositRewards() {
}, },
0, // LTV counter 0, // LTV counter
), tc.args.previousBlockTime, types.DefaultDistributionTimes) ), tc.args.previousBlockTime, types.DefaultDistributionTimes)
tApp.InitializeFromGenesisStates(app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(harvestGS)}) tApp.InitializeFromGenesisStates(app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(hardGS)})
supplyKeeper := tApp.GetSupplyKeeper() supplyKeeper := tApp.GetSupplyKeeper()
supplyKeeper.MintCoins(ctx, types.ModuleAccountName, cs(tc.args.totalDeposits)) supplyKeeper.MintCoins(ctx, types.ModuleAccountName, cs(tc.args.totalDeposits))
keeper := tApp.GetHarvestKeeper() keeper := tApp.GetHardKeeper()
deposit := types.NewDeposit(tc.args.depositor, tc.args.depositAmount) deposit := types.NewDeposit(tc.args.depositor, tc.args.depositAmount)
keeper.SetDeposit(ctx, deposit) keeper.SetDeposit(ctx, deposit)
suite.app = tApp suite.app = tApp
@ -136,10 +136,10 @@ func (suite *DelegatorRewardsTestSuite) SetupTest() {
suite.app.InitializeFromGenesisStates( suite.app.InitializeFromGenesisStates(
equalCoinsAuthGenState(allAddrs, cs(c("ukava", 5_000_000))), equalCoinsAuthGenState(allAddrs, cs(c("ukava", 5_000_000))),
stakingGenesisState(), stakingGenesisState(),
harvestGenesisState(c("hard", suite.rewardRate)), hardGenesisState(c("hard", suite.rewardRate)),
) )
suite.keeper = suite.app.GetHarvestKeeper() suite.keeper = suite.app.GetHardKeeper()
suite.stakingKeeper = suite.app.GetStakingKeeper() suite.stakingKeeper = suite.app.GetStakingKeeper()
} }
@ -405,7 +405,7 @@ func (suite *DelegatorRewardsTestSuite) kavaClaimExists(ctx sdk.Context, owner s
return found return found
} }
func harvestGenesisState(rewardRate sdk.Coin) app.GenesisState { func hardGenesisState(rewardRate sdk.Coin) app.GenesisState {
loanToValue := sdk.MustNewDecFromStr("0.6") loanToValue := sdk.MustNewDecFromStr("0.6")
genState := types.NewGenesisState( genState := types.NewGenesisState(
types.NewParams( types.NewParams(

View File

@ -8,7 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/vesting" "github.com/cosmos/cosmos-sdk/x/auth/vesting"
supplyExported "github.com/cosmos/cosmos-sdk/x/supply/exported" supplyExported "github.com/cosmos/cosmos-sdk/x/supply/exported"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
validatorvesting "github.com/kava-labs/kava/x/validator-vesting" validatorvesting "github.com/kava-labs/kava/x/validator-vesting"
) )

View File

@ -10,7 +10,7 @@ import (
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
"github.com/kava-labs/kava/app" "github.com/kava-labs/kava/app"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
func (suite *KeeperTestSuite) TestSendTimeLockedCoinsToAccount() { func (suite *KeeperTestSuite) TestSendTimeLockedCoinsToAccount() {
@ -280,7 +280,7 @@ func (suite *KeeperTestSuite) TestSendTimeLockedCoinsToAccount() {
ctx := tApp.NewContext(true, abci.Header{Height: 1, Time: tc.args.blockTime}) ctx := tApp.NewContext(true, abci.Header{Height: 1, Time: tc.args.blockTime})
authGS := app.NewAuthGenState([]sdk.AccAddress{tc.args.accArgs.addr}, []sdk.Coins{tc.args.accArgs.coins}) authGS := app.NewAuthGenState([]sdk.AccAddress{tc.args.accArgs.addr}, []sdk.Coins{tc.args.accArgs.coins})
loanToValue := sdk.MustNewDecFromStr("0.6") loanToValue := sdk.MustNewDecFromStr("0.6")
harvestGS := types.NewGenesisState(types.NewParams( hardGS := types.NewGenesisState(types.NewParams(
true, true,
types.DistributionSchedules{ types.DistributionSchedules{
types.NewDistributionSchedule(true, "bnb", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Large, 24, sdk.OneDec())}), types.NewDistributionSchedule(true, "bnb", time.Date(2020, 10, 8, 14, 0, 0, 0, time.UTC), time.Date(2020, 11, 22, 14, 0, 0, 0, time.UTC), sdk.NewCoin("hard", sdk.NewInt(5000)), time.Date(2021, 11, 22, 14, 0, 0, 0, time.UTC), types.Multipliers{types.NewMultiplier(types.Small, 0, sdk.MustNewDecFromStr("0.33")), types.NewMultiplier(types.Medium, 6, sdk.MustNewDecFromStr("0.5")), types.NewMultiplier(types.Large, 24, sdk.OneDec())}),
@ -296,7 +296,7 @@ func (suite *KeeperTestSuite) TestSendTimeLockedCoinsToAccount() {
}, },
0, // LTV counter 0, // LTV counter
), types.DefaultPreviousBlockTime, types.DefaultDistributionTimes) ), types.DefaultPreviousBlockTime, types.DefaultDistributionTimes)
tApp.InitializeFromGenesisStates(authGS, app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(harvestGS)}) tApp.InitializeFromGenesisStates(authGS, app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(hardGS)})
if tc.args.accArgs.vestingAccountBefore { if tc.args.accArgs.vestingAccountBefore {
ak := tApp.GetAccountKeeper() ak := tApp.GetAccountKeeper()
acc := ak.GetAccount(ctx, tc.args.accArgs.addr) acc := ak.GetAccount(ctx, tc.args.accArgs.addr)
@ -308,7 +308,7 @@ func (suite *KeeperTestSuite) TestSendTimeLockedCoinsToAccount() {
} }
supplyKeeper := tApp.GetSupplyKeeper() supplyKeeper := tApp.GetSupplyKeeper()
supplyKeeper.MintCoins(ctx, types.LPAccount, sdk.NewCoins(sdk.NewCoin("hard", sdk.NewInt(1000)))) supplyKeeper.MintCoins(ctx, types.LPAccount, sdk.NewCoins(sdk.NewCoin("hard", sdk.NewInt(1000))))
keeper := tApp.GetHarvestKeeper() keeper := tApp.GetHardKeeper()
suite.app = tApp suite.app = tApp
suite.ctx = ctx suite.ctx = ctx
suite.keeper = keeper suite.keeper = keeper

View File

@ -24,7 +24,7 @@ var (
GovDenom = cdptypes.DefaultGovDenom GovDenom = cdptypes.DefaultGovDenom
) )
// Params governance parameters for harvest module // Params governance parameters for hard module
type Params struct { type Params struct {
Active bool `json:"active" yaml:"active"` Active bool `json:"active" yaml:"active"`
LiquidityProviderSchedules DistributionSchedules `json:"liquidity_provider_schedules" yaml:"liquidity_provider_schedules"` LiquidityProviderSchedules DistributionSchedules `json:"liquidity_provider_schedules" yaml:"liquidity_provider_schedules"`
@ -228,7 +228,7 @@ func NewParams(active bool, lps DistributionSchedules, dds DelegatorDistribution
} }
} }
// DefaultParams returns default params for harvest module // DefaultParams returns default params for hard module
func DefaultParams() Params { func DefaultParams() Params {
return NewParams(DefaultActive, DefaultLPSchedules, DefaultDelegatorSchedules) return NewParams(DefaultActive, DefaultLPSchedules, DefaultDelegatorSchedules)
} }
@ -342,7 +342,7 @@ func (dt DepositType) IsValid() error {
return fmt.Errorf("invalid deposit type: %s", dt) return fmt.Errorf("invalid deposit type: %s", dt)
} }
// Deposit defines an amount of coins deposited into a harvest module account // Deposit defines an amount of coins deposited into a hard module account
type Deposit struct { type Deposit struct {
Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"`
Amount sdk.Coin `json:"amount" yaml:"amount"` Amount sdk.Coin `json:"amount" yaml:"amount"`

View File

@ -1,4 +1,4 @@
package harvest package hard
import ( import (
"encoding/json" "encoding/json"
@ -15,11 +15,11 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/x/harvest/client/cli" "github.com/kava-labs/kava/x/hard/client/cli"
"github.com/kava-labs/kava/x/harvest/client/rest" "github.com/kava-labs/kava/x/hard/client/rest"
"github.com/kava-labs/kava/x/harvest/keeper" "github.com/kava-labs/kava/x/hard/keeper"
"github.com/kava-labs/kava/x/harvest/simulation" "github.com/kava-labs/kava/x/hard/simulation"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
var ( var (
@ -56,17 +56,17 @@ func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error {
return gs.Validate() return gs.Validate()
} }
// RegisterRESTRoutes registers REST routes for the harvest module. // RegisterRESTRoutes registers REST routes for the hard module.
func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router) { func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router) {
rest.RegisterRoutes(ctx, rtr) rest.RegisterRoutes(ctx, rtr)
} }
// GetTxCmd returns the root tx command for the harvest module. // GetTxCmd returns the root tx command for the hard module.
func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command { func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command {
return cli.GetTxCmd(cdc) return cli.GetTxCmd(cdc)
} }
// GetQueryCmd returns no root query command for the harvest module. // GetQueryCmd returns no root query command for the hard module.
func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command {
return cli.GetQueryCmd(types.StoreKey, cdc) return cli.GetQueryCmd(types.StoreKey, cdc)
} }
@ -147,7 +147,7 @@ func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.Valid
//____________________________________________________________________________ //____________________________________________________________________________
// GenerateGenesisState creates a randomized GenState of the harvest module // GenerateGenesisState creates a randomized GenState of the hard module
func (AppModuleBasic) GenerateGenesisState(simState *module.SimulationState) { func (AppModuleBasic) GenerateGenesisState(simState *module.SimulationState) {
simulation.RandomizedGenState(simState) simulation.RandomizedGenState(simState)
} }
@ -157,17 +157,17 @@ func (AppModuleBasic) ProposalContents(_ module.SimulationState) []sim.WeightedP
return nil return nil
} }
// RandomizedParams returns nil because harvest has no params. // RandomizedParams returns nil because hard has no params.
func (AppModuleBasic) RandomizedParams(r *rand.Rand) []sim.ParamChange { func (AppModuleBasic) RandomizedParams(r *rand.Rand) []sim.ParamChange {
return simulation.ParamChanges(r) return simulation.ParamChanges(r)
} }
// RegisterStoreDecoder registers a decoder for harvest module's types // RegisterStoreDecoder registers a decoder for hard module's types
func (AppModuleBasic) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { func (AppModuleBasic) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
sdr[StoreKey] = simulation.DecodeStore sdr[StoreKey] = simulation.DecodeStore
} }
// WeightedOperations returns the all the harvest module operations with their respective weights. // WeightedOperations returns the all the hard module operations with their respective weights.
func (am AppModule) WeightedOperations(simState module.SimulationState) []sim.WeightedOperation { func (am AppModule) WeightedOperations(simState module.SimulationState) []sim.WeightedOperation {
return nil return nil
} }

View File

@ -9,10 +9,10 @@ import (
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
// DecodeStore unmarshals the KVPair's Value to the corresponding harvest type // DecodeStore unmarshals the KVPair's Value to the corresponding hard type
func DecodeStore(cdc *codec.Codec, kvA, kvB kv.Pair) string { func DecodeStore(cdc *codec.Codec, kvA, kvB kv.Pair) string {
switch { switch {
case bytes.Equal(kvA.Key[:1], types.PreviousBlockTimeKey), bytes.Equal(kvA.Key[:1], types.PreviousDelegationDistributionKey): case bytes.Equal(kvA.Key[:1], types.PreviousBlockTimeKey), bytes.Equal(kvA.Key[:1], types.PreviousDelegationDistributionKey):

View File

@ -12,7 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
func makeTestCodec() (cdc *codec.Codec) { func makeTestCodec() (cdc *codec.Codec) {

View File

@ -6,7 +6,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/module"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
// SecondsPerYear is the number of seconds in a year // SecondsPerYear is the number of seconds in a year
@ -16,20 +16,20 @@ const (
BaseAprPadding = "0.000000003022265980" BaseAprPadding = "0.000000003022265980"
) )
// RandomizedGenState generates a random GenesisState for harvest module // RandomizedGenState generates a random GenesisState for hard module
func RandomizedGenState(simState *module.SimulationState) { func RandomizedGenState(simState *module.SimulationState) {
// params := genRandomParams(simState) // params := genRandomParams(simState)
// if err := params.Validate(); err != nil { // if err := params.Validate(); err != nil {
// panic(err) // panic(err)
// } // }
harvestGenesis := types.DefaultGenesisState() hardGenesis := types.DefaultGenesisState()
if err := harvestGenesis.Validate(); err != nil { if err := hardGenesis.Validate(); err != nil {
panic(err) panic(err)
} }
fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, codec.MustMarshalJSONIndent(simState.Cdc, harvestGenesis)) fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, codec.MustMarshalJSONIndent(simState.Cdc, hardGenesis))
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(harvestGenesis) simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(hardGenesis)
} }
// func genRandomParams(simState *module.SimulationState) types.Params { // func genRandomParams(simState *module.SimulationState) types.Params {

View File

@ -4,19 +4,19 @@ order: 1
# Concepts # Concepts
The harvest module introduces the hard token to the kava blockchain. This module distributes hard tokens to two types of ecosystem participants: The hard module introduces the hard token to the kava blockchain. This module distributes hard tokens to two types of ecosystem participants:
1. Kava stakers - any address that stakes (delegates) kava tokens will be eligible to claim hard tokens. For each delegator, hard tokens are accumulated ratably based on the total number of kava tokens staked. For example, if a user stakes 1 million KAVA tokens and there are 100 million staked KAVA, that user will accumulate 1% of hard tokens earmarked for stakers during the distribution period. Distribution periods are defined by a start date, an end date, and a number of hard tokens that are distributed per second. 1. Kava stakers - any address that stakes (delegates) kava tokens will be eligible to claim hard tokens. For each delegator, hard tokens are accumulated ratably based on the total number of kava tokens staked. For example, if a user stakes 1 million KAVA tokens and there are 100 million staked KAVA, that user will accumulate 1% of hard tokens earmarked for stakers during the distribution period. Distribution periods are defined by a start date, an end date, and a number of hard tokens that are distributed per second.
2. Depositors - any address that deposits eligible tokens to the harvest module will be eligible to claim hard tokens. For each depositor, hard tokens are accumulated ratably based on the total number of tokens staked of that denomination. For example, if a user deposits 1 million "xyz" tokens and there are 100 million xyz deposited, that user will accumulate 1% of hard tokens earmarked for depositors of that denomination during the distribution period. Distribution periods are defined by a start date, an end date, and a number of hard tokens that are distributed per second. 2. Depositors - any address that deposits eligible tokens to the hard module will be eligible to claim hard tokens. For each depositor, hard tokens are accumulated ratably based on the total number of tokens staked of that denomination. For example, if a user deposits 1 million "xyz" tokens and there are 100 million xyz deposited, that user will accumulate 1% of hard tokens earmarked for depositors of that denomination during the distribution period. Distribution periods are defined by a start date, an end date, and a number of hard tokens that are distributed per second.
Users are not air-dropped tokens, rather they accumulate `Claim` objects that they may submit a transaction in order to claim. In order to better align long term incentives, when users claim hard tokens, they have three options, called 'multipliers', for how tokens are distributed. Users are not air-dropped tokens, rather they accumulate `Claim` objects that they may submit a transaction in order to claim. In order to better align long term incentives, when users claim hard tokens, they have three options, called 'multipliers', for how tokens are distributed.
* Liquid - users can immediately receive hard tokens, but they will receive a smaller fraction of tokens than if they choose medium-term or long-term locked tokens. - Liquid - users can immediately receive hard tokens, but they will receive a smaller fraction of tokens than if they choose medium-term or long-term locked tokens.
* Medium-term locked - users can receive tokens that are medium-term transfer restricted. They will receive more tokens than users who choose liquid tokens, but fewer than those who choose long term locked tokens. - Medium-term locked - users can receive tokens that are medium-term transfer restricted. They will receive more tokens than users who choose liquid tokens, but fewer than those who choose long term locked tokens.
* Long-term locked - users can receive tokens that are long-term transfer restricted. Users choosing this option will receive more tokens than users who choose liquid or medium-term locked tokens. - Long-term locked - users can receive tokens that are long-term transfer restricted. Users choosing this option will receive more tokens than users who choose liquid or medium-term locked tokens.
The exact multipliers will be voted by governance and can be changed via a governance vote. An example multiplier schedule would be: The exact multipliers will be voted by governance and can be changed via a governance vote. An example multiplier schedule would be:
* Liquid - 10% multiplier and no lock up. Users receive 10% as many tokens as users who choose long-term locked tokens. - Liquid - 10% multiplier and no lock up. Users receive 10% as many tokens as users who choose long-term locked tokens.
* Medium-term locked - 33% multiplier and 6 month transfer restriction. Users receive 33% as many tokens as users who choose long-term locked tokens. - Medium-term locked - 33% multiplier and 6 month transfer restriction. Users receive 33% as many tokens as users who choose long-term locked tokens.
* Long-term locked - 100% multiplier and 2 year transfer restriction. Users receive 10x as many tokens as users who choose liquid tokens and 3x as many tokens as users who choose medium-term locked tokens. - Long-term locked - 100% multiplier and 2 year transfer restriction. Users receive 10x as many tokens as users who choose liquid tokens and 3x as many tokens as users who choose medium-term locked tokens.

View File

@ -9,7 +9,7 @@ order: 2
`Parameters` define the distribution schedule of hard tokens that will be distributed to delegators and depositors, respectively. `Parameters` define the distribution schedule of hard tokens that will be distributed to delegators and depositors, respectively.
```go ```go
// Params governance parameters for harvest module // Params governance parameters for hard module
type Params struct { type Params struct {
Active bool `json:"active" yaml:"active"` Active bool `json:"active" yaml:"active"`
LiquidityProviderSchedules DistributionSchedules `json:"liquidity_provider_schedules" yaml:"liquidity_provider_schedules"` LiquidityProviderSchedules DistributionSchedules `json:"liquidity_provider_schedules" yaml:"liquidity_provider_schedules"`
@ -41,7 +41,7 @@ type DelegatorDistributionSchedule struct {
type DelegatorDistributionSchedules []DelegatorDistributionSchedule type DelegatorDistributionSchedules []DelegatorDistributionSchedule
``` ```
`GenesisState` defines the state that must be persisted when the blockchain stops/restarts in order for normal function of the harvest module to resume. `GenesisState` defines the state that must be persisted when the blockchain stops/restarts in order for normal function of the hard module to resume.
```go ```go
// GenesisState is the state that must be provided at genesis. // GenesisState is the state that must be provided at genesis.

View File

@ -4,16 +4,16 @@ order: 3
# Messages # Messages
There are three messages in the harvest module. Deposit allows users to deposit assets to the harvest module. In version 2, depositors will be able to use their deposits as collateral to borrow from harvest. Withdraw removes assets from the harvest module, returning them to the user. Claim allows users to claim earned HARD tokens. There are three messages in the hard module. Deposit allows users to deposit assets to the hard module. In version 2, depositors will be able to use their deposits as collateral to borrow from hard. Withdraw removes assets from the hard module, returning them to the user. Claim allows users to claim earned HARD tokens.
```go ```go
// MsgDeposit deposit asset to the harvest module. // MsgDeposit deposit asset to the hard module.
type MsgDeposit struct { type MsgDeposit struct {
Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"`
Amount sdk.Coin `json:"amount" yaml:"amount"` Amount sdk.Coin `json:"amount" yaml:"amount"`
} }
// MsgWithdraw withdraw from the harvest module. // MsgWithdraw withdraw from the hard module.
type MsgWithdraw struct { type MsgWithdraw struct {
Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"`
Amount sdk.Coin `json:"amount" yaml:"amount"` Amount sdk.Coin `json:"amount" yaml:"amount"`

55
x/hard/spec/04_events.md Normal file
View File

@ -0,0 +1,55 @@
<!--
order: 4
-->
# Events
The hard module emits the following events:
## Handlers
### MsgDeposit
| Type | Attribute Key | Attribute Value |
| ------------ | ------------- | --------------------- |
| message | module | hard |
| message | sender | `{sender address}` |
| hard_deposit | amount | `{amount}` |
| hard_deposit | depositor | `{depositor address}` |
| hard_deposit | deposit_denom | `{deposit denom}` |
### MsgWithdraw
| Type | Attribute Key | Attribute Value |
| ------------------- | ------------- | --------------------- |
| message | module | hard |
| message | sender | `{sender address}` |
| hard_deposit | amount | `{amount}` |
| hard_deposit | depositor | `{depositor address}` |
| hard_deposit | deposit_denom | `{deposit denom}` |
| hard_deposit | deposit_type | `{deposit type}` |
| delete_hard_deposit | depositor | `{depositor address}` |
| delete_hard_deposit | deposit_denom | `{deposit denom}` |
### MsgClaimReward
| Type | Attribute Key | Attribute Value |
| ----------------- | ---------------- | ------------------------ |
| message | module | hard |
| message | sender | `{sender address}` |
| claim_hard_reward | amount | `{amount}` |
| claim_hard_reward | claim_holder | `{claim holder address}` |
| claim_hard_reward | deposit_denom | `{deposit denom}` |
| claim_hard_reward | claim_type | `{claim type}` |
| claim_hard_reward | claim_multiplier | `{claim multiplier}` |
## BeginBlock
| Type | Attribute Key | Attribute Value |
| --------------------------- | ------------------- | ----------------------- |
| hard_lp_distribution | block_height | `{block height}` |
| hard_lp_distribution | rewards_distributed | `{rewards distributed}` |
| hard_lp_distribution | deposit_denom | `{deposit denom}` |
| hard_delegator_distribution | block_height | `{block height}` |
| hard_delegator_distribution | rewards_distributed | `{rewards distributed}` |
| hard_delegator_distribution | deposit_denom | `{deposit denom}` |

46
x/hard/spec/05_params.md Normal file
View File

@ -0,0 +1,46 @@
<!--
order: 5
-->
# Parameters
The hard module has the following parameters:
| Key | Type | Example | Description |
| ------------------------------ | ------------------------------------- | ------------- | -------------------------------------------- |
| Active | bool | "true" | boolean for if token distribution is active |
| LiquidityProviderSchedules | array (LiquidityProviderSchedule) | [{see below}] | array of params for each supported asset |
| DelegatorDistributionSchedules | array (DelegatorDistributionSchedule) | [{see below}] | array of params for staking incentive assets |
Each `LiquidityProviderSchedules` has the following parameters
| Key | Type | Example | Description |
| ---------------- | ------------------ | ---------------------- | ------------------------------------------------------------- |
| Active | bool | "true" | boolean for if token distribution is active for this schedule |
| DepositDenom | string | "bnb" | coin denom of the asset which can be deposited |
| Start | time.Time | "2020-06-01T15:20:00Z" | the time when the period will end |
| End | time.Time | "2020-06-01T15:20:00Z" | the time when the period will end |
| RewardsPerSecond | Coin | "500hard" | HARD tokens per second that can be claimed by depositors |
| ClaimEnd | time.Time | "2022-06-01T15:20:00Z" | the time at which users can no longer claim HARD tokens |
| ClaimMultipliers | array (Multiplier) | [{see below}] | reward multipliers for users claiming HARD tokens |
Each `DelegatorDistributionSchedule` has the following parameters
| Key | Type | Example | Description |
| --------------------- | ------------------ | ---------------------- | ------------------------------------------------------------- |
| Active | bool | "true" | boolean for if token distribution is active for this schedule |
| DepositDenom | string | "bnb" | coin denom of the asset which can be deposited |
| Start | time.Time | "2020-06-01T15:20:00Z" | the time when the period will end |
| End | time.Time | "2020-06-01T15:20:00Z" | the time when the period will end |
| RewardsPerSecond | Coin | "500hard" | HARD tokens per second that can be claimed by depositors |
| ClaimEnd | time.Time | "2022-06-01T15:20:00Z" | the time at which users can no longer claim HARD tokens |
| ClaimMultipliers | array (Multiplier) | [{see below}] | reward multipliers for users claiming HARD tokens |
| DistributionFrequency | time.Duration | "24hr" | frequency at which delegation rewards are accumulated |
Each `ClaimMultiplier` has the following parameters
| Key | Type | Example | Description |
| ------------ | ------ | ------- | --------------------------------------------------------------- |
| Name | string | "large" | the unique name of the reward multiplier |
| MonthsLockup | int | "6" | number of months HARD tokens with this multiplier are locked |
| Factor | Dec | "0.5" | the scaling factor for HARD tokens claimed with this multiplier |

21
x/hard/spec/README.md Normal file
View File

@ -0,0 +1,21 @@
<!--
order: 0
title: "Hard Overview"
parent:
title: "hard"
-->
# `hard`
<!-- TOC -->
1. **[Concepts](01_concepts.md)**
2. **[State](02_state.md)**
3. **[Messages](03_messages.md)**
4. **[Events](04_events.md)**
5. **[Params](05_params.md)**
6. **[BeginBlock](06_begin_block.md)**
## Abstract
`x/hard` is an implementation of a Cosmos SDK Module that will serve as the basis for a cross-chain money market platform. The current version of the module defines how HARD tokens are distributed, while future versions of this module will define lending, borrowing, distribution, incentives, and governance for the money market module.

View File

@ -4,7 +4,24 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
) )
// Borrow defines an amount of coins borrowed from a harvest module account // BorrowIndexItem defines an individual borrow index
type BorrowIndexItem struct {
Denom string `json:"denom" yaml:"denom"`
Value sdk.Dec `json:"value" yaml:"value"`
}
// NewBorrowIndexItem returns a new BorrowIndexItem instance
func NewBorrowIndexItem(denom string, value sdk.Dec) BorrowIndexItem {
return BorrowIndexItem{
Denom: denom,
Value: value,
}
}
// BorrowIndexes is a slice of BorrowIndexItem, because Amino won't marshal maps
type BorrowIndexes []BorrowIndexItem
// Borrow defines an amount of coins borrowed from a hard module account
type Borrow struct { type Borrow struct {
Borrower sdk.AccAddress `json:"borrower" yaml:"borrower"` Borrower sdk.AccAddress `json:"borrower" yaml:"borrower"`
Amount sdk.Coins `json:"amount" yaml:"amount"` Amount sdk.Coins `json:"amount" yaml:"amount"`

24
x/hard/types/codec.go Normal file
View File

@ -0,0 +1,24 @@
package types
import "github.com/cosmos/cosmos-sdk/codec"
// ModuleCdc generic sealed codec to be used throughout module
var ModuleCdc *codec.Codec
func init() {
cdc := codec.New()
RegisterCodec(cdc)
codec.RegisterCrypto(cdc)
ModuleCdc = cdc.Seal()
}
// RegisterCodec registers the necessary types for hard module
func RegisterCodec(cdc *codec.Codec) {
cdc.RegisterConcrete(MsgClaimReward{}, "hard/MsgClaimReward", nil)
cdc.RegisterConcrete(MsgDeposit{}, "hard/MsgDeposit", nil)
cdc.RegisterConcrete(MsgWithdraw{}, "hard/MsgWithdraw", nil)
cdc.RegisterConcrete(MsgBorrow{}, "hard/MsgBorrow", nil)
cdc.RegisterConcrete(MsgLiquidate{}, "hard/MsgLiquidate", nil)
cdc.RegisterConcrete(MsgRepay{}, "hard/MsgRepay", nil)
cdc.RegisterConcrete(DistributionSchedule{}, "hard/DistributionSchedule", nil)
}

View File

@ -4,7 +4,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
) )
// Deposit defines an amount of coins deposited into a harvest module account // Deposit defines an amount of coins deposited into a hard module account
type Deposit struct { type Deposit struct {
Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"`
Amount sdk.Coins `json:"amount" yaml:"amount"` Amount sdk.Coins `json:"amount" yaml:"amount"`

View File

@ -1,16 +1,16 @@
package types package types
// Event types for harvest module // Event types for hard module
const ( const (
EventTypeHarvestDeposit = "harvest_deposit" EventTypeHardDeposit = "hard_deposit"
EventTypeHarvestDelegatorDistribution = "harvest_delegator_distribution" EventTypeHardDelegatorDistribution = "hard_delegator_distribution"
EventTypeHarvestLPDistribution = "harvest_lp_distribution" EventTypeHardLPDistribution = "hard_lp_distribution"
EventTypeDeleteHarvestDeposit = "delete_harvest_deposit" EventTypeDeleteHardDeposit = "delete_hard_deposit"
EventTypeHarvestWithdrawal = "harvest_withdrawal" EventTypeHardWithdrawal = "hard_withdrawal"
EventTypeClaimHarvestReward = "claim_harvest_reward" EventTypeClaimHardReward = "claim_hard_reward"
EventTypeHarvestBorrow = "harvest_borrow" EventTypeHardBorrow = "hard_borrow"
EventTypeDepositLiquidation = "harvest_liquidation" EventTypeDepositLiquidation = "hard_liquidation"
EventTypeHarvestRepay = "harvest_repay" EventTypeHardRepay = "hard_repay"
AttributeValueCategory = ModuleName AttributeValueCategory = ModuleName
AttributeKeyBlockHeight = "block_height" AttributeKeyBlockHeight = "block_height"
AttributeKeyRewardsDistribution = "rewards_distributed" AttributeKeyRewardsDistribution = "rewards_distributed"

View File

@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
type GenesisTestSuite struct { type GenesisTestSuite struct {

View File

@ -6,19 +6,19 @@ import (
const ( const (
// ModuleName name that will be used throughout the module // ModuleName name that will be used throughout the module
ModuleName = "harvest" ModuleName = "hard"
// LPAccount LP distribution module account // LPAccount LP distribution module account
LPAccount = "harvest_lp_distribution" LPAccount = "hard_lp_distribution"
// DelegatorAccount delegator distribution module account // DelegatorAccount delegator distribution module account
DelegatorAccount = "harvest_delegator_distribution" DelegatorAccount = "hard_delegator_distribution"
// LiquidatorAccount module account for liquidator // LiquidatorAccount module account for liquidator
LiquidatorAccount = "harvest_liquidator" LiquidatorAccount = "hard_liquidator"
// ModuleAccountName name of module account used to hold deposits // ModuleAccountName name of module account used to hold deposits
ModuleAccountName = "harvest" ModuleAccountName = "hard"
// StoreKey Top level store key where all module items will be stored // StoreKey Top level store key where all module items will be stored
StoreKey = ModuleName StoreKey = ModuleName

View File

@ -55,7 +55,7 @@ var (
_ sdk.Msg = &MsgBorrow{} _ sdk.Msg = &MsgBorrow{}
) )
// MsgDeposit deposit collateral to the harvest module. // MsgDeposit deposit collateral to the hard module.
type MsgDeposit struct { type MsgDeposit struct {
Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"`
Amount sdk.Coins `json:"amount" yaml:"amount"` Amount sdk.Coins `json:"amount" yaml:"amount"`
@ -73,7 +73,7 @@ func NewMsgDeposit(depositor sdk.AccAddress, amount sdk.Coins) MsgDeposit {
func (msg MsgDeposit) Route() string { return RouterKey } func (msg MsgDeposit) Route() string { return RouterKey }
// Type returns a human-readable string for the message, intended for utilization within tags. // Type returns a human-readable string for the message, intended for utilization within tags.
func (msg MsgDeposit) Type() string { return "harvest_deposit" } func (msg MsgDeposit) Type() string { return "hard_deposit" }
// ValidateBasic does a simple validation check that doesn't require access to any other information. // ValidateBasic does a simple validation check that doesn't require access to any other information.
func (msg MsgDeposit) ValidateBasic() error { func (msg MsgDeposit) ValidateBasic() error {
@ -105,7 +105,7 @@ func (msg MsgDeposit) String() string {
`, msg.Depositor, msg.Amount) `, msg.Depositor, msg.Amount)
} }
// MsgWithdraw withdraw from the harvest module. // MsgWithdraw withdraw from the hard module.
type MsgWithdraw struct { type MsgWithdraw struct {
Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"`
Amount sdk.Coins `json:"amount" yaml:"amount"` Amount sdk.Coins `json:"amount" yaml:"amount"`
@ -123,7 +123,7 @@ func NewMsgWithdraw(depositor sdk.AccAddress, amount sdk.Coins) MsgWithdraw {
func (msg MsgWithdraw) Route() string { return RouterKey } func (msg MsgWithdraw) Route() string { return RouterKey }
// Type returns a human-readable string for the message, intended for utilization within tags. // Type returns a human-readable string for the message, intended for utilization within tags.
func (msg MsgWithdraw) Type() string { return "harvest_withdraw" } func (msg MsgWithdraw) Type() string { return "hard_withdraw" }
// ValidateBasic does a simple validation check that doesn't require access to any other information. // ValidateBasic does a simple validation check that doesn't require access to any other information.
func (msg MsgWithdraw) ValidateBasic() error { func (msg MsgWithdraw) ValidateBasic() error {
@ -179,7 +179,7 @@ func NewMsgClaimReward(sender, receiver sdk.AccAddress, depositDenom, claimType,
func (msg MsgClaimReward) Route() string { return RouterKey } func (msg MsgClaimReward) Route() string { return RouterKey }
// Type returns a human-readable string for the message, intended for utilization within tags. // Type returns a human-readable string for the message, intended for utilization within tags.
func (msg MsgClaimReward) Type() string { return "claim_harvest_reward" } func (msg MsgClaimReward) Type() string { return "claim_hard_reward" }
// ValidateBasic does a simple validation check that doesn't require access to state. // ValidateBasic does a simple validation check that doesn't require access to state.
func (msg MsgClaimReward) ValidateBasic() error { func (msg MsgClaimReward) ValidateBasic() error {
@ -209,7 +209,7 @@ func (msg MsgClaimReward) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{msg.Sender} return []sdk.AccAddress{msg.Sender}
} }
// MsgBorrow borrows funds from the harvest module. // MsgBorrow borrows funds from the hard module.
type MsgBorrow struct { type MsgBorrow struct {
Borrower sdk.AccAddress `json:"borrower" yaml:"borrower"` Borrower sdk.AccAddress `json:"borrower" yaml:"borrower"`
Amount sdk.Coins `json:"amount" yaml:"amount"` Amount sdk.Coins `json:"amount" yaml:"amount"`
@ -227,7 +227,7 @@ func NewMsgBorrow(borrower sdk.AccAddress, amount sdk.Coins) MsgBorrow {
func (msg MsgBorrow) Route() string { return RouterKey } func (msg MsgBorrow) Route() string { return RouterKey }
// Type returns a human-readable string for the message, intended for utilization within tags. // Type returns a human-readable string for the message, intended for utilization within tags.
func (msg MsgBorrow) Type() string { return "harvest_borrow" } func (msg MsgBorrow) Type() string { return "hard_borrow" }
// ValidateBasic does a simple validation check that doesn't require access to any other information. // ValidateBasic does a simple validation check that doesn't require access to any other information.
func (msg MsgBorrow) ValidateBasic() error { func (msg MsgBorrow) ValidateBasic() error {
@ -259,7 +259,7 @@ func (msg MsgBorrow) String() string {
`, msg.Borrower, msg.Amount) `, msg.Borrower, msg.Amount)
} }
// MsgRepay repays funds to the harvest module. // MsgRepay repays funds to the hard module.
type MsgRepay struct { type MsgRepay struct {
Sender sdk.AccAddress `json:"sender" yaml:"sender"` Sender sdk.AccAddress `json:"sender" yaml:"sender"`
Amount sdk.Coins `json:"amount" yaml:"amount"` Amount sdk.Coins `json:"amount" yaml:"amount"`
@ -277,7 +277,7 @@ func NewMsgRepay(sender sdk.AccAddress, amount sdk.Coins) MsgRepay {
func (msg MsgRepay) Route() string { return RouterKey } func (msg MsgRepay) Route() string { return RouterKey }
// Type returns a human-readable string for the message, intended for utilization within tags. // Type returns a human-readable string for the message, intended for utilization within tags.
func (msg MsgRepay) Type() string { return "harvest_repay" } func (msg MsgRepay) Type() string { return "hard_repay" }
// ValidateBasic does a simple validation check that doesn't require access to any other information. // ValidateBasic does a simple validation check that doesn't require access to any other information.
func (msg MsgRepay) ValidateBasic() error { func (msg MsgRepay) ValidateBasic() error {

View File

@ -8,7 +8,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
type MsgTestSuite struct { type MsgTestSuite struct {

View File

@ -27,7 +27,7 @@ var (
GovDenom = cdptypes.DefaultGovDenom GovDenom = cdptypes.DefaultGovDenom
) )
// Params governance parameters for harvest module // Params governance parameters for hard module
type Params struct { type Params struct {
Active bool `json:"active" yaml:"active"` Active bool `json:"active" yaml:"active"`
LiquidityProviderSchedules DistributionSchedules `json:"liquidity_provider_schedules" yaml:"liquidity_provider_schedules"` LiquidityProviderSchedules DistributionSchedules `json:"liquidity_provider_schedules" yaml:"liquidity_provider_schedules"`
@ -437,7 +437,7 @@ func NewParams(active bool, lps DistributionSchedules, dds DelegatorDistribution
} }
} }
// DefaultParams returns default params for harvest module // DefaultParams returns default params for hard module
func DefaultParams() Params { func DefaultParams() Params {
return NewParams(DefaultActive, DefaultLPSchedules, DefaultDelegatorSchedules, return NewParams(DefaultActive, DefaultLPSchedules, DefaultDelegatorSchedules,
DefaultMoneyMarkets, DefaultCheckLtvIndexCount) DefaultMoneyMarkets, DefaultCheckLtvIndexCount)

View File

@ -9,7 +9,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/harvest/types" "github.com/kava-labs/kava/x/hard/types"
) )
type ParamTestSuite struct { type ParamTestSuite struct {

View File

@ -4,7 +4,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
) )
// Querier routes for the harvest module // Querier routes for the hard module
const ( const (
QueryGetParams = "params" QueryGetParams = "params"
QueryGetModuleAccounts = "accounts" QueryGetModuleAccounts = "accounts"

View File

@ -1,55 +0,0 @@
<!--
order: 4
-->
# Events
The harvest module emits the following events:
## Handlers
### MsgDeposit
| Type | Attribute Key | Attribute Value |
|----------------------|---------------------|-----------------------|
| message | module | harvest |
| message | sender | `{sender address}` |
| harvest_deposit | amount | `{amount}` |
| harvest_deposit | depositor | `{depositor address}` |
| harvest_deposit | deposit_denom | `{deposit denom}` |
### MsgWithdraw
| Type | Attribute Key | Attribute Value |
|------------------------|---------------------|-----------------------|
| message | module | harvest |
| message | sender | `{sender address}` |
| harvest_deposit | amount | `{amount}` |
| harvest_deposit | depositor | `{depositor address}` |
| harvest_deposit | deposit_denom | `{deposit denom}` |
| harvest_deposit | deposit_type | `{deposit type}` |
| delete_harvest_deposit | depositor | `{depositor address}` |
| delete_harvest_deposit | deposit_denom | `{deposit denom}` |
### MsgClaimReward
| Type | Attribute Key | Attribute Value |
|------------------------|---------------------|--------------------------|
| message | module | harvest |
| message | sender | `{sender address}` |
| claim_harvest_reward | amount | `{amount}` |
| claim_harvest_reward | claim_holder | `{claim holder address}` |
| claim_harvest_reward | deposit_denom | `{deposit denom}` |
| claim_harvest_reward | claim_type | `{claim type}` |
| claim_harvest_reward | claim_multiplier | `{claim multiplier}` |
## BeginBlock
| Type | Attribute Key | Attribute Value |
|--------------------------------|---------------------|--------------------------|
| harvest_lp_distribution | block_height | `{block height}` |
| harvest_lp_distribution | rewards_distributed | `{rewards distributed}` |
| harvest_lp_distribution | deposit_denom | `{deposit denom}` |
| harvest_delegator_distribution | block_height | `{block height}` |
| harvest_delegator_distribution | rewards_distributed | `{rewards distributed}` |
| harvest_delegator_distribution | deposit_denom | `{deposit denom}` |

View File

@ -1,46 +0,0 @@
<!--
order: 5
-->
# Parameters
The harvest module has the following parameters:
| Key | Type | Example | Description |
|-----------------------------------|---------------------------------------|---------------|--------------------------------------------------|
| Active | bool | "true" | boolean for if token distribution is active |
| LiquidityProviderSchedules | array (LiquidityProviderSchedule) | [{see below}] | array of params for each supported asset |
| DelegatorDistributionSchedules | array (DelegatorDistributionSchedule) | [{see below}] | array of params for staking incentive assets |
Each `LiquidityProviderSchedules` has the following parameters
| Key | Type | Example | Description |
|------------------|--------------------|--------------------------|----------------------------------------------------------------|
| Active | bool | "true" | boolean for if token distribution is active for this schedule |
| DepositDenom | string | "bnb" | coin denom of the asset which can be deposited |
| Start | time.Time | "2020-06-01T15:20:00Z" | the time when the period will end |
| End | time.Time | "2020-06-01T15:20:00Z" | the time when the period will end |
| RewardsPerSecond | Coin | "500hard" | HARD tokens per second that can be claimed by depositors |
| ClaimEnd | time.Time | "2022-06-01T15:20:00Z" | the time at which users can no longer claim HARD tokens |
| ClaimMultipliers | array (Multiplier) | [{see below}] | reward multipliers for users claiming HARD tokens |
Each `DelegatorDistributionSchedule` has the following parameters
| Key | Type | Example | Description |
|-----------------------|--------------------|--------------------------|----------------------------------------------------------------|
| Active | bool | "true" | boolean for if token distribution is active for this schedule |
| DepositDenom | string | "bnb" | coin denom of the asset which can be deposited |
| Start | time.Time | "2020-06-01T15:20:00Z" | the time when the period will end |
| End | time.Time | "2020-06-01T15:20:00Z" | the time when the period will end |
| RewardsPerSecond | Coin | "500hard" | HARD tokens per second that can be claimed by depositors |
| ClaimEnd | time.Time | "2022-06-01T15:20:00Z" | the time at which users can no longer claim HARD tokens |
| ClaimMultipliers | array (Multiplier) | [{see below}] | reward multipliers for users claiming HARD tokens |
| DistributionFrequency | time.Duration | "24hr" | frequency at which delegation rewards are accumulated |
Each `ClaimMultiplier` has the following parameters
| Key | Type | Example | Description |
|-----------------------|--------------------|--------------------------|-----------------------------------------------------------------|
| Name | string | "large" | the unique name of the reward multiplier |
| MonthsLockup | int | "6" | number of months HARD tokens with this multiplier are locked |
| Factor | Dec | "0.5" | the scaling factor for HARD tokens claimed with this multiplier |

View File

@ -1,20 +0,0 @@
<!--
order: 0
title: "Harvest Overview"
parent:
title: "harvest"
-->
# `harvest`
<!-- TOC -->
1. **[Concepts](01_concepts.md)**
2. **[State](02_state.md)**
3. **[Messages](03_messages.md)**
4. **[Events](04_events.md)**
5. **[Params](05_params.md)**
6. **[BeginBlock](06_begin_block.md)**
## Abstract
`x/harvest` is an implementation of a Cosmos SDK Module that will serve as the basis for a cross-chain money market platform. The current version of the module defines how HARD tokens are distributed, while future versions of this module will define lending, borrowing, distribution, incentives, and governance for the money market module.

View File

@ -1,24 +0,0 @@
package types
import "github.com/cosmos/cosmos-sdk/codec"
// ModuleCdc generic sealed codec to be used throughout module
var ModuleCdc *codec.Codec
func init() {
cdc := codec.New()
RegisterCodec(cdc)
codec.RegisterCrypto(cdc)
ModuleCdc = cdc.Seal()
}
// RegisterCodec registers the necessary types for harvest module
func RegisterCodec(cdc *codec.Codec) {
cdc.RegisterConcrete(MsgClaimReward{}, "harvest/MsgClaimReward", nil)
cdc.RegisterConcrete(MsgDeposit{}, "harvest/MsgDeposit", nil)
cdc.RegisterConcrete(MsgWithdraw{}, "harvest/MsgWithdraw", nil)
cdc.RegisterConcrete(MsgBorrow{}, "harvest/MsgBorrow", nil)
cdc.RegisterConcrete(MsgLiquidate{}, "harvest/MsgLiquidate", nil)
cdc.RegisterConcrete(MsgRepay{}, "harvest/MsgRepay", nil)
cdc.RegisterConcrete(DistributionSchedule{}, "harvest/DistributionSchedule", nil)
}