From a4bbea1ec449d9a41da04b3034653ddb8e8eba4d Mon Sep 17 00:00:00 2001 From: Denali Marsh Date: Mon, 21 Dec 2020 18:18:55 +0100 Subject: [PATCH] update 'harvest' -> 'hard' (#746) --- app/app.go | 32 +++---- app/test_common.go | 4 +- migrate/v0_11/migrate.go | 2 +- x/{harvest => hard}/abci.go | 2 +- x/{harvest => hard}/alias.go | 80 ++++++++--------- x/{harvest => hard}/client/cli/query.go | 62 ++++++------- x/{harvest => hard}/client/cli/tx.go | 22 ++--- x/{harvest => hard}/client/rest/query.go | 2 +- x/{harvest => hard}/client/rest/rest.go | 2 +- x/{harvest => hard}/client/rest/tx.go | 2 +- x/{harvest => hard}/genesis.go | 6 +- x/{harvest => hard}/handler.go | 8 +- x/{harvest => hard}/keeper/borrow.go | 6 +- x/{harvest => hard}/keeper/borrow_test.go | 20 ++--- x/{harvest => hard}/keeper/claim.go | 10 +-- x/{harvest => hard}/keeper/claim_test.go | 8 +- x/{harvest => hard}/keeper/deposit.go | 8 +- x/{harvest => hard}/keeper/deposit_test.go | 18 ++-- x/{harvest => hard}/keeper/interest.go | 4 +- x/{harvest => hard}/keeper/interest_test.go | 32 +++---- x/{harvest => hard}/keeper/keeper.go | 4 +- x/{harvest => hard}/keeper/keeper_test.go | 6 +- x/{harvest => hard}/keeper/liquidation.go | 2 +- .../keeper/liquidation_test.go | 90 +++++++++---------- x/{harvest => hard}/keeper/params.go | 2 +- x/{harvest => hard}/keeper/querier.go | 20 ++--- x/{harvest => hard}/keeper/repay.go | 6 +- x/{harvest => hard}/keeper/repay_test.go | 20 ++--- x/{harvest => hard}/keeper/rewards.go | 6 +- x/{harvest => hard}/keeper/rewards_test.go | 16 ++-- x/{harvest => hard}/keeper/timelock.go | 2 +- x/{harvest => hard}/keeper/timelock_test.go | 8 +- x/{harvest => hard}/legacy/v0_12/types.go | 6 +- x/{harvest => hard}/module.go | 26 +++--- x/{harvest => hard}/simulation/decoder.go | 4 +- .../simulation/decoder_test.go | 2 +- x/{harvest => hard}/simulation/genesis.go | 12 +-- x/{harvest => hard}/simulation/params.go | 0 x/{harvest => hard}/spec/01_concepts.md | 16 ++-- x/{harvest => hard}/spec/02_state.md | 4 +- x/{harvest => hard}/spec/03_messages.md | 6 +- x/hard/spec/04_events.md | 55 ++++++++++++ x/hard/spec/05_params.md | 46 ++++++++++ x/{harvest => hard}/spec/06_begin_block.md | 0 x/hard/spec/README.md | 21 +++++ x/{harvest => hard}/types/borrow.go | 19 +++- x/{harvest => hard}/types/claim.go | 0 x/hard/types/codec.go | 24 +++++ x/{harvest => hard}/types/deposit.go | 2 +- x/{harvest => hard}/types/errors.go | 0 x/{harvest => hard}/types/events.go | 20 ++--- x/{harvest => hard}/types/expected_keepers.go | 0 x/{harvest => hard}/types/genesis.go | 0 x/{harvest => hard}/types/genesis_test.go | 2 +- x/{harvest => hard}/types/keys.go | 10 +-- x/{harvest => hard}/types/liquidation.go | 0 x/{harvest => hard}/types/msg.go | 18 ++-- x/{harvest => hard}/types/msg_test.go | 2 +- x/{harvest => hard}/types/params.go | 4 +- x/{harvest => hard}/types/params_test.go | 2 +- x/{harvest => hard}/types/period.go | 0 x/{harvest => hard}/types/querier.go | 2 +- x/harvest/spec/04_events.md | 55 ------------ x/harvest/spec/05_params.md | 46 ---------- x/harvest/spec/README.md | 20 ----- x/harvest/types/codec.go | 24 ----- 66 files changed, 489 insertions(+), 471 deletions(-) rename x/{harvest => hard}/abci.go (97%) rename x/{harvest => hard}/alias.go (66%) rename x/{harvest => hard}/client/cli/query.go (83%) rename x/{harvest => hard}/client/cli/tx.go (91%) rename x/{harvest => hard}/client/rest/query.go (99%) rename x/{harvest => hard}/client/rest/rest.go (96%) rename x/{harvest => hard}/client/rest/tx.go (98%) rename x/{harvest => hard}/genesis.go (95%) rename x/{harvest => hard}/handler.go (95%) rename x/{harvest => hard}/keeper/borrow.go (98%) rename x/{harvest => hard}/keeper/borrow_test.go (97%) rename x/{harvest => hard}/keeper/claim.go (92%) rename x/{harvest => hard}/keeper/claim_test.go (98%) rename x/{harvest => hard}/keeper/deposit.go (95%) rename x/{harvest => hard}/keeper/deposit_test.go (97%) rename x/{harvest => hard}/keeper/interest.go (98%) rename x/{harvest => hard}/keeper/interest_test.go (95%) rename x/{harvest => hard}/keeper/keeper.go (99%) rename x/{harvest => hard}/keeper/keeper_test.go (98%) rename x/{harvest => hard}/keeper/liquidation.go (99%) rename x/{harvest => hard}/keeper/liquidation_test.go (97%) rename x/{harvest => hard}/keeper/params.go (97%) rename x/{harvest => hard}/keeper/querier.go (94%) rename x/{harvest => hard}/keeper/repay.go (94%) rename x/{harvest => hard}/keeper/repay_test.go (96%) rename x/{harvest => hard}/keeper/rewards.go (97%) rename x/{harvest => hard}/keeper/rewards_test.go (97%) rename x/{harvest => hard}/keeper/timelock.go (99%) rename x/{harvest => hard}/keeper/timelock_test.go (98%) rename x/{harvest => hard}/legacy/v0_12/types.go (98%) rename x/{harvest => hard}/module.go (85%) rename x/{harvest => hard}/simulation/decoder.go (94%) rename x/{harvest => hard}/simulation/decoder_test.go (97%) rename x/{harvest => hard}/simulation/genesis.go (88%) rename x/{harvest => hard}/simulation/params.go (100%) rename x/{harvest => hard}/spec/01_concepts.md (61%) rename x/{harvest => hard}/spec/02_state.md (96%) rename x/{harvest => hard}/spec/03_messages.md (65%) create mode 100644 x/hard/spec/04_events.md create mode 100644 x/hard/spec/05_params.md rename x/{harvest => hard}/spec/06_begin_block.md (100%) create mode 100644 x/hard/spec/README.md rename x/{harvest => hard}/types/borrow.go (63%) rename x/{harvest => hard}/types/claim.go (100%) create mode 100644 x/hard/types/codec.go rename x/{harvest => hard}/types/deposit.go (83%) rename x/{harvest => hard}/types/errors.go (100%) rename x/{harvest => hard}/types/events.go (59%) rename x/{harvest => hard}/types/expected_keepers.go (100%) rename x/{harvest => hard}/types/genesis.go (100%) rename x/{harvest => hard}/types/genesis_test.go (99%) rename x/{harvest => hard}/types/keys.go (92%) rename x/{harvest => hard}/types/liquidation.go (100%) rename x/{harvest => hard}/types/msg.go (95%) rename x/{harvest => hard}/types/msg_test.go (99%) rename x/{harvest => hard}/types/params.go (99%) rename x/{harvest => hard}/types/params_test.go (98%) rename x/{harvest => hard}/types/period.go (100%) rename x/{harvest => hard}/types/querier.go (98%) delete mode 100644 x/harvest/spec/04_events.md delete mode 100644 x/harvest/spec/05_params.md delete mode 100644 x/harvest/spec/README.md delete mode 100644 x/harvest/types/codec.go diff --git a/app/app.go b/app/app.go index 9b25f93f..cf25dbec 100644 --- a/app/app.go +++ b/app/app.go @@ -38,7 +38,7 @@ import ( "github.com/kava-labs/kava/x/bep3" "github.com/kava-labs/kava/x/cdp" "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/issuance" "github.com/kava-labs/kava/x/kavadist" @@ -84,7 +84,7 @@ var ( kavadist.AppModuleBasic{}, incentive.AppModuleBasic{}, issuance.AppModuleBasic{}, - harvest.AppModuleBasic{}, + hard.AppModuleBasic{}, ) // module account permissions @@ -103,10 +103,10 @@ var ( bep3.ModuleName: {supply.Minter, supply.Burner}, kavadist.ModuleName: {supply.Minter}, issuance.ModuleAccountName: {supply.Minter, supply.Burner}, - harvest.LPAccount: {supply.Minter, supply.Burner}, - harvest.DelegatorAccount: {supply.Minter, supply.Burner}, - harvest.ModuleAccountName: {supply.Minter, supply.Burner}, - harvest.LiquidatorAccount: {supply.Minter, supply.Burner}, + hard.LPAccount: {supply.Minter, supply.Burner}, + hard.DelegatorAccount: {supply.Minter, supply.Burner}, + hard.ModuleAccountName: {supply.Minter, supply.Burner}, + hard.LiquidatorAccount: {supply.Minter, supply.Burner}, } // module accounts that are allowed to receive tokens @@ -161,7 +161,7 @@ type App struct { kavadistKeeper kavadist.Keeper incentiveKeeper incentive.Keeper issuanceKeeper issuance.Keeper - harvestKeeper harvest.Keeper + hardKeeper hard.Keeper // the 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, validatorvesting.StoreKey, auction.StoreKey, cdp.StoreKey, pricefeed.StoreKey, bep3.StoreKey, kavadist.StoreKey, incentive.StoreKey, issuance.StoreKey, committee.StoreKey, - harvest.StoreKey, + hard.StoreKey, ) 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) incentiveSubspace := app.paramsKeeper.Subspace(incentive.DefaultParamspace) issuanceSubspace := app.paramsKeeper.Subspace(issuance.DefaultParamspace) - harvestSubspace := app.paramsKeeper.Subspace(harvest.DefaultParamspace) + hardSubspace := app.paramsKeeper.Subspace(hard.DefaultParamspace) // add keepers app.accountKeeper = auth.NewAccountKeeper( @@ -380,10 +380,10 @@ func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts AppOptio app.accountKeeper, app.supplyKeeper, ) - app.harvestKeeper = harvest.NewKeeper( + app.hardKeeper = hard.NewKeeper( app.cdc, - keys[harvest.StoreKey], - harvestSubspace, + keys[hard.StoreKey], + hardSubspace, app.accountKeeper, app.supplyKeeper, &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), committee.NewAppModule(app.committeeKeeper, app.accountKeeper), 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 @@ -431,7 +431,7 @@ func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts AppOptio app.mm.SetOrderBeginBlockers( upgrade.ModuleName, mint.ModuleName, distr.ModuleName, slashing.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) @@ -442,7 +442,7 @@ func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts AppOptio staking.ModuleName, bank.ModuleName, slashing.ModuleName, gov.ModuleName, mint.ModuleName, evidence.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 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. @@ -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), committee.NewAppModule(app.committeeKeeper, app.accountKeeper), 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() diff --git a/app/test_common.go b/app/test_common.go index 86d2e6f7..e6932331 100644 --- a/app/test_common.go +++ b/app/test_common.go @@ -33,7 +33,7 @@ import ( "github.com/kava-labs/kava/x/bep3" "github.com/kava-labs/kava/x/cdp" "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/issuance" "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) GetKavadistKeeper() kavadist.Keeper { return tApp.kavadistKeeper } 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) GetIssuanceKeeper() issuance.Keeper { return tApp.issuanceKeeper } diff --git a/migrate/v0_11/migrate.go b/migrate/v0_11/migrate.go index 951799ff..b0250962 100644 --- a/migrate/v0_11/migrate.go +++ b/migrate/v0_11/migrate.go @@ -26,7 +26,7 @@ import ( v0_9cdp "github.com/kava-labs/kava/x/cdp/legacy/v0_9" v0_11committee "github.com/kava-labs/kava/x/committee" 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_9incentive "github.com/kava-labs/kava/x/incentive/legacy/v0_9" v0_11issuance "github.com/kava-labs/kava/x/issuance" diff --git a/x/harvest/abci.go b/x/hard/abci.go similarity index 97% rename from x/harvest/abci.go rename to x/hard/abci.go index d0e9453e..e1a4f519 100644 --- a/x/harvest/abci.go +++ b/x/hard/abci.go @@ -1,4 +1,4 @@ -package harvest +package hard import ( sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/harvest/alias.go b/x/hard/alias.go similarity index 66% rename from x/harvest/alias.go rename to x/hard/alias.go index fc82098a..4c038d07 100644 --- a/x/harvest/alias.go +++ b/x/hard/alias.go @@ -1,50 +1,50 @@ -package harvest +package hard // DO NOT EDIT - generated by aliasgen tool (github.com/rhuairahrighairidh/aliasgen) import ( - "github.com/kava-labs/kava/x/harvest/keeper" - "github.com/kava-labs/kava/x/harvest/types" + "github.com/kava-labs/kava/x/hard/keeper" + "github.com/kava-labs/kava/x/hard/types" ) const ( - BeginningOfMonth = keeper.BeginningOfMonth - MidMonth = keeper.MidMonth - PaymentHour = keeper.PaymentHour - AttributeKeyBlockHeight = types.AttributeKeyBlockHeight - AttributeKeyClaimAmount = types.AttributeKeyClaimAmount - AttributeKeyClaimHolder = types.AttributeKeyClaimHolder - AttributeKeyClaimMultiplier = types.AttributeKeyClaimMultiplier - AttributeKeyClaimType = types.AttributeKeyClaimType - AttributeKeyDeposit = types.AttributeKeyDeposit - AttributeKeyDepositDenom = types.AttributeKeyDepositDenom - AttributeKeyDepositor = types.AttributeKeyDepositor - AttributeKeyRewardsDistribution = types.AttributeKeyRewardsDistribution - AttributeValueCategory = types.AttributeValueCategory - DefaultParamspace = types.DefaultParamspace - DelegatorAccount = types.DelegatorAccount - EventTypeClaimHarvestReward = types.EventTypeClaimHarvestReward - EventTypeDeleteHarvestDeposit = types.EventTypeDeleteHarvestDeposit - EventTypeHarvestDelegatorDistribution = types.EventTypeHarvestDelegatorDistribution - EventTypeHarvestDeposit = types.EventTypeHarvestDeposit - EventTypeHarvestLPDistribution = types.EventTypeHarvestLPDistribution - EventTypeHarvestWithdrawal = types.EventTypeHarvestWithdrawal - LP = types.LP - LPAccount = types.LPAccount - LiquidatorAccount = types.LiquidatorAccount - Large = types.Large - Medium = types.Medium - ModuleAccountName = types.ModuleAccountName - ModuleName = types.ModuleName - QuerierRoute = types.QuerierRoute - QueryGetClaims = types.QueryGetClaims - QueryGetDeposits = types.QueryGetDeposits - QueryGetModuleAccounts = types.QueryGetModuleAccounts - QueryGetParams = types.QueryGetParams - RouterKey = types.RouterKey - Small = types.Small - Stake = types.Stake - StoreKey = types.StoreKey + BeginningOfMonth = keeper.BeginningOfMonth + MidMonth = keeper.MidMonth + PaymentHour = keeper.PaymentHour + AttributeKeyBlockHeight = types.AttributeKeyBlockHeight + AttributeKeyClaimAmount = types.AttributeKeyClaimAmount + AttributeKeyClaimHolder = types.AttributeKeyClaimHolder + AttributeKeyClaimMultiplier = types.AttributeKeyClaimMultiplier + AttributeKeyClaimType = types.AttributeKeyClaimType + AttributeKeyDeposit = types.AttributeKeyDeposit + AttributeKeyDepositDenom = types.AttributeKeyDepositDenom + AttributeKeyDepositor = types.AttributeKeyDepositor + AttributeKeyRewardsDistribution = types.AttributeKeyRewardsDistribution + AttributeValueCategory = types.AttributeValueCategory + DefaultParamspace = types.DefaultParamspace + DelegatorAccount = types.DelegatorAccount + EventTypeClaimHardReward = types.EventTypeClaimHardReward + EventTypeDeleteHardDeposit = types.EventTypeDeleteHardDeposit + EventTypeHardDelegatorDistribution = types.EventTypeHardDelegatorDistribution + EventTypeHardDeposit = types.EventTypeHardDeposit + EventTypeHardLPDistribution = types.EventTypeHardLPDistribution + EventTypeHardWithdrawal = types.EventTypeHardWithdrawal + LP = types.LP + LPAccount = types.LPAccount + LiquidatorAccount = types.LiquidatorAccount + Large = types.Large + Medium = types.Medium + ModuleAccountName = types.ModuleAccountName + ModuleName = types.ModuleName + QuerierRoute = types.QuerierRoute + QueryGetClaims = types.QueryGetClaims + QueryGetDeposits = types.QueryGetDeposits + QueryGetModuleAccounts = types.QueryGetModuleAccounts + QueryGetParams = types.QueryGetParams + RouterKey = types.RouterKey + Small = types.Small + Stake = types.Stake + StoreKey = types.StoreKey ) var ( diff --git a/x/harvest/client/cli/query.go b/x/hard/client/cli/query.go similarity index 83% rename from x/harvest/client/cli/query.go rename to x/hard/client/cli/query.go index 6a75ac06..4b1ea65a 100644 --- a/x/harvest/client/cli/query.go +++ b/x/hard/client/cli/query.go @@ -14,7 +14,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" 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 @@ -25,17 +25,17 @@ const ( 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 { - harvestQueryCmd := &cobra.Command{ + hardQueryCmd := &cobra.Command{ Use: types.ModuleName, - Short: "Querying commands for the harvest module", + Short: "Querying commands for the hard module", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, } - harvestQueryCmd.AddCommand(flags.GetCommands( + hardQueryCmd.AddCommand(flags.GetCommands( queryParamsCmd(queryRoute, cdc), queryModAccountsCmd(queryRoute, cdc), queryDepositsCmd(queryRoute, cdc), @@ -44,15 +44,15 @@ func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { queryBorrowCmd(queryRoute, cdc), )...) - return harvestQueryCmd + return hardQueryCmd } func queryParamsCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { return &cobra.Command{ Use: "params", - Short: "get the harvest module parameters", - Long: "Get the current global harvest module parameters.", + Short: "get the hard module parameters", + Long: "Get the current global hard module parameters.", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { 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 { return &cobra.Command{ Use: "accounts", - Short: "query harvest module accounts with optional filter", - Long: strings.TrimSpace(`Query for all harvest module accounts or a specific account using the name flag: + Short: "query hard module accounts with optional filter", + Long: strings.TrimSpace(`Query for all hard module accounts or a specific account using the name flag: Example: - $ kvcli q harvest accounts - $ kvcli q harvest accounts --name harvest|harvest_delegator_distribution|harvest_lp_distribution`, + $ kvcli q hard accounts + $ kvcli q hard accounts --name hard|hard_delegator_distribution|hard_lp_distribution`, ), Args: cobra.NoArgs, 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 { cmd := &cobra.Command{ Use: "deposits", - Short: "query harvest module deposits with optional filters", - Long: strings.TrimSpace(`query for all harvest module deposits or a specific deposit using flags: + Short: "query hard module deposits with optional filters", + Long: strings.TrimSpace(`query for all hard module deposits or a specific deposit using flags: Example: - $ kvcli q harvest deposits - $ kvcli q harvest deposits --owner kava1l0xsq2z7gqd7yly0g40y5836g0appumark77ny --deposit-denom bnb - $ kvcli q harvest deposits --deposit-denom ukava - $ kvcli q harvest deposits --deposit-denom btcb`, + $ kvcli q hard deposits + $ kvcli q hard deposits --owner kava1l0xsq2z7gqd7yly0g40y5836g0appumark77ny --deposit-denom bnb + $ kvcli q hard deposits --deposit-denom ukava + $ kvcli q hard deposits --deposit-denom btcb`, ), Args: cobra.NoArgs, 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 { cmd := &cobra.Command{ Use: "claims", - Short: "query harvest module claims with optional filters", - Long: strings.TrimSpace(`query for all harvest module claims or a specific claim using flags: + Short: "query hard module claims with optional filters", + Long: strings.TrimSpace(`query for all hard module claims or a specific claim using flags: Example: - $ kvcli q harvest claims - $ kvcli q harvest claims --owner kava1l0xsq2z7gqd7yly0g40y5836g0appumark77ny --claim-type lp --deposit-denom bnb - $ kvcli q harvest claims --claim-type stake --deposit-denom ukava - $ kvcli q harvest claims --deposit-denom btcb`, + $ kvcli q hard claims + $ kvcli q hard claims --owner kava1l0xsq2z7gqd7yly0g40y5836g0appumark77ny --claim-type lp --deposit-denom bnb + $ kvcli q hard claims --claim-type stake --deposit-denom ukava + $ kvcli q hard claims --deposit-denom btcb`, ), Args: cobra.NoArgs, 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 { cmd := &cobra.Command{ Use: "borrows", - Short: "query harvest module borrows with optional filters", - Long: strings.TrimSpace(`query for all harvest module borrows or a specific borrow using flags: + Short: "query hard module borrows with optional filters", + Long: strings.TrimSpace(`query for all hard module borrows or a specific borrow using flags: Example: - $ kvcli q harvest borrows - $ kvcli q harvest borrows --borrower kava1l0xsq2z7gqd7yly0g40y5836g0appumark77ny - $ kvcli q harvest borrows --borrow-denom bnb`, + $ kvcli q hard borrows + $ kvcli q hard borrows --borrower kava1l0xsq2z7gqd7yly0g40y5836g0appumark77ny + $ kvcli q hard borrows --borrow-denom bnb`, ), Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { @@ -304,7 +304,7 @@ func queryBorrowedCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { return &cobra.Command{ Use: "borrowed", 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, RunE: func(cmd *cobra.Command, args []string) error { 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", Long: strings.TrimSpace(`query outstanding borrow balance for a user: Example: - $ kvcli q harvest borrow --owner kava1l0xsq2z7gqd7yly0g40y5836g0appumark77ny`, + $ kvcli q hard borrow --owner kava1l0xsq2z7gqd7yly0g40y5836g0appumark77ny`, ), Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { diff --git a/x/harvest/client/cli/tx.go b/x/hard/client/cli/tx.go similarity index 91% rename from x/harvest/client/cli/tx.go rename to x/hard/client/cli/tx.go index c74df74f..86bf1cc3 100644 --- a/x/harvest/client/cli/tx.go +++ b/x/hard/client/cli/tx.go @@ -16,12 +16,12 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth" "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 func GetTxCmd(cdc *codec.Codec) *cobra.Command { - harvestTxCmd := &cobra.Command{ + hardTxCmd := &cobra.Command{ Use: types.ModuleName, Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), DisableFlagParsing: true, @@ -29,7 +29,7 @@ func GetTxCmd(cdc *codec.Codec) *cobra.Command { RunE: client.ValidateCmd, } - harvestTxCmd.AddCommand(flags.PostCommands( + hardTxCmd.AddCommand(flags.PostCommands( getCmdDeposit(cdc), getCmdWithdraw(cdc), getCmdClaimReward(cdc), @@ -38,13 +38,13 @@ func GetTxCmd(cdc *codec.Codec) *cobra.Command { getCmdRepay(cdc), )...) - return harvestTxCmd + return hardTxCmd } func getCmdDeposit(cdc *codec.Codec) *cobra.Command { return &cobra.Command{ Use: "deposit [amount]", - Short: "deposit coins to harvest", + Short: "deposit coins to hard", Example: fmt.Sprintf( `%s tx %s deposit 10000000bnb --from `, version.ClientName, types.ModuleName, ), @@ -68,7 +68,7 @@ func getCmdDeposit(cdc *codec.Codec) *cobra.Command { func getCmdWithdraw(cdc *codec.Codec) *cobra.Command { return &cobra.Command{ Use: "withdraw [amount]", - Short: "withdraw coins from harvest", + Short: "withdraw coins from hard", Args: cobra.ExactArgs(1), Example: fmt.Sprintf( `%s tx %s withdraw 10000000bnb --from `, version.ClientName, types.ModuleName, @@ -95,7 +95,7 @@ func getCmdClaimReward(cdc *codec.Codec) *cobra.Command { Use: "claim [receiver-addr] [deposit-denom] [deposit-type] [multiplier]", Short: "claim HARD tokens to receiver address", 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, unless the sender is a validator-vesting account`), Args: cobra.ExactArgs(4), @@ -122,8 +122,8 @@ func getCmdClaimReward(cdc *codec.Codec) *cobra.Command { func getCmdBorrow(cdc *codec.Codec) *cobra.Command { return &cobra.Command{ Use: "borrow [1000000000ukava]", - Short: "borrow tokens from the harvest protocol", - Long: strings.TrimSpace(`borrows tokens from the harvest protocol`), + Short: "borrow tokens from the hard protocol", + Long: strings.TrimSpace(`borrows tokens from the hard protocol`), Args: cobra.ExactArgs(1), Example: fmt.Sprintf( `%s tx %s borrow 1000000000ukava --from `, version.ClientName, types.ModuleName, @@ -150,8 +150,8 @@ func getCmdBorrow(cdc *codec.Codec) *cobra.Command { func getCmdRepay(cdc *codec.Codec) *cobra.Command { return &cobra.Command{ Use: "repay [1000000000ukava]", - Short: "repay tokens to the harvest protocol", - Long: strings.TrimSpace(`repay tokens to the harvest protocol`), + Short: "repay tokens to the hard protocol", + Long: strings.TrimSpace(`repay tokens to the hard protocol`), Args: cobra.ExactArgs(1), Example: fmt.Sprintf( `%s tx %s repay 1000000000ukava,25000000000bnb --from `, version.ClientName, types.ModuleName, diff --git a/x/harvest/client/rest/query.go b/x/hard/client/rest/query.go similarity index 99% rename from x/harvest/client/rest/query.go rename to x/hard/client/rest/query.go index 4e6be97a..dc6a33c8 100644 --- a/x/harvest/client/rest/query.go +++ b/x/hard/client/rest/query.go @@ -11,7 +11,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "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) { diff --git a/x/harvest/client/rest/rest.go b/x/hard/client/rest/rest.go similarity index 96% rename from x/harvest/client/rest/rest.go rename to x/hard/client/rest/rest.go index b49a93d3..95ea3b93 100644 --- a/x/harvest/client/rest/rest.go +++ b/x/hard/client/rest/rest.go @@ -17,7 +17,7 @@ const ( 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) { registerQueryRoutes(cliCtx, r) registerTxRoutes(cliCtx, r) diff --git a/x/harvest/client/rest/tx.go b/x/hard/client/rest/tx.go similarity index 98% rename from x/harvest/client/rest/tx.go rename to x/hard/client/rest/tx.go index 4c988b2a..aced599a 100644 --- a/x/harvest/client/rest/tx.go +++ b/x/hard/client/rest/tx.go @@ -12,7 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/rest" "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) { diff --git a/x/harvest/genesis.go b/x/hard/genesis.go similarity index 95% rename from x/harvest/genesis.go rename to x/hard/genesis.go index baf01ca5..3f61e7b9 100644 --- a/x/harvest/genesis.go +++ b/x/hard/genesis.go @@ -1,11 +1,11 @@ -package harvest +package hard import ( "fmt" 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. @@ -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 { params := k.GetParams(ctx) previousBlockTime, found := k.GetPreviousBlockTime(ctx) diff --git a/x/harvest/handler.go b/x/hard/handler.go similarity index 95% rename from x/harvest/handler.go rename to x/hard/handler.go index bb83c62d..490c11ae 100644 --- a/x/harvest/handler.go +++ b/x/hard/handler.go @@ -1,4 +1,4 @@ -package harvest +package hard import ( "strings" @@ -6,11 +6,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/kava-labs/kava/x/harvest/keeper" - "github.com/kava-labs/kava/x/harvest/types" + "github.com/kava-labs/kava/x/hard/keeper" + "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 { return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) diff --git a/x/harvest/keeper/borrow.go b/x/hard/keeper/borrow.go similarity index 98% rename from x/harvest/keeper/borrow.go rename to x/hard/keeper/borrow.go index a0b246f4..ff8458f6 100644 --- a/x/harvest/keeper/borrow.go +++ b/x/hard/keeper/borrow.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" 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 @@ -40,7 +40,7 @@ func (k Keeper) Borrow(ctx sdk.Context, borrower sdk.AccAddress, coins sdk.Coins 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) if err != nil { 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( sdk.NewEvent( - types.EventTypeHarvestBorrow, + types.EventTypeHardBorrow, sdk.NewAttribute(types.AttributeKeyBorrower, borrower.String()), sdk.NewAttribute(types.AttributeKeyBorrowCoins, coins.String()), ), diff --git a/x/harvest/keeper/borrow_test.go b/x/hard/keeper/borrow_test.go similarity index 97% rename from x/harvest/keeper/borrow_test.go rename to x/hard/keeper/borrow_test.go index 5179e753..772d4509 100644 --- a/x/harvest/keeper/borrow_test.go +++ b/x/hard/keeper/borrow_test.go @@ -10,8 +10,8 @@ import ( tmtime "github.com/tendermint/tendermint/types/time" "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/x/harvest" - "github.com/kava-labs/kava/x/harvest/types" + "github.com/kava-labs/kava/x/hard" + "github.com/kava-labs/kava/x/hard/types" "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("xyz", sdk.NewInt(1)))}) - // Harvest module genesis state - harvestGS := types.NewGenesisState(types.NewParams( + // hard module genesis state + hardGS := types.NewGenesisState(types.NewParams( true, 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())}), @@ -335,15 +335,15 @@ func (suite *KeeperTestSuite) TestBorrow() { // Initialize test application tApp.InitializeFromGenesisStates(authGS, 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() - 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))) - supplyKeeper.MintCoins(ctx, types.ModuleAccountName, harvestMaccCoins) + supplyKeeper.MintCoins(ctx, types.ModuleAccountName, hardMaccCoins) - keeper := tApp.GetHarvestKeeper() + keeper := tApp.GetHardKeeper() suite.app = tApp suite.ctx = ctx suite.keeper = keeper @@ -351,7 +351,7 @@ func (suite *KeeperTestSuite) TestBorrow() { var err error // 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) suite.Require().NoError(err) diff --git a/x/harvest/keeper/claim.go b/x/hard/keeper/claim.go similarity index 92% rename from x/harvest/keeper/claim.go rename to x/hard/keeper/claim.go index 7bbe50ee..61f641d8 100644 --- a/x/harvest/keeper/claim.go +++ b/x/hard/keeper/claim.go @@ -6,16 +6,16 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" 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" ) 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 - // 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 - // PaymentHour harvest rewards always vest at 14:00UTC + // PaymentHour hard rewards always vest at 14:00UTC PaymentHour = 14 ) @@ -45,7 +45,7 @@ func (k Keeper) ClaimReward(ctx sdk.Context, claimHolder sdk.AccAddress, receive } ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypeClaimHarvestReward, + types.EventTypeClaimHardReward, sdk.NewAttribute(sdk.AttributeKeyAmount, claim.Amount.String()), sdk.NewAttribute(types.AttributeKeyClaimHolder, claimHolder.String()), sdk.NewAttribute(types.AttributeKeyDepositDenom, depositDenom), diff --git a/x/harvest/keeper/claim_test.go b/x/hard/keeper/claim_test.go similarity index 98% rename from x/harvest/keeper/claim_test.go rename to x/hard/keeper/claim_test.go index ccee4432..7f00ad44 100644 --- a/x/harvest/keeper/claim_test.go +++ b/x/hard/keeper/claim_test.go @@ -11,7 +11,7 @@ import ( "github.com/tendermint/tendermint/crypto" "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" ) @@ -254,7 +254,7 @@ func (suite *KeeperTestSuite) TestClaim() { sdk.NewCoins(sdk.NewCoin("bnb", sdk.NewInt(1000)), sdk.NewCoin("btcb", sdk.NewInt(1000))), }) loanToValue := sdk.MustNewDecFromStr("0.6") - harvestGS := types.NewGenesisState(types.NewParams( + hardGS := types.NewGenesisState(types.NewParams( true, 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())}), @@ -270,7 +270,7 @@ func (suite *KeeperTestSuite) TestClaim() { }, 0, // LTV counter ), 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 { ak := tApp.GetAccountKeeper() acc := ak.GetAccount(ctx, tc.args.claimOwner) @@ -298,7 +298,7 @@ func (suite *KeeperTestSuite) TestClaim() { supplyKeeper := tApp.GetSupplyKeeper() 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)))) - keeper := tApp.GetHarvestKeeper() + keeper := tApp.GetHardKeeper() suite.app = tApp suite.ctx = ctx suite.keeper = keeper diff --git a/x/harvest/keeper/deposit.go b/x/hard/keeper/deposit.go similarity index 95% rename from x/harvest/keeper/deposit.go rename to x/hard/keeper/deposit.go index 9c56a9d5..0ee522bf 100644 --- a/x/harvest/keeper/deposit.go +++ b/x/hard/keeper/deposit.go @@ -7,7 +7,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" 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 @@ -57,7 +57,7 @@ func (k Keeper) Deposit(ctx sdk.Context, depositor sdk.AccAddress, coins sdk.Coi ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypeHarvestDeposit, + types.EventTypeHardDeposit, sdk.NewAttribute(sdk.AttributeKeyAmount, coins.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( sdk.NewEvent( - types.EventTypeHarvestWithdrawal, + types.EventTypeHardWithdrawal, sdk.NewAttribute(sdk.AttributeKeyAmount, coins.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) { ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypeDeleteHarvestDeposit, + types.EventTypeDeleteHardDeposit, sdk.NewAttribute(types.AttributeKeyDepositor, depositor.String()), ), ) diff --git a/x/harvest/keeper/deposit_test.go b/x/hard/keeper/deposit_test.go similarity index 97% rename from x/harvest/keeper/deposit_test.go rename to x/hard/keeper/deposit_test.go index ce2eb2a3..1a749849 100644 --- a/x/harvest/keeper/deposit_test.go +++ b/x/hard/keeper/deposit_test.go @@ -11,8 +11,8 @@ import ( tmtime "github.com/tendermint/tendermint/types/time" "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/x/harvest" - "github.com/kava-labs/kava/x/harvest/types" + "github.com/kava-labs/kava/x/hard" + "github.com/kava-labs/kava/x/hard/types" "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()}) 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") - harvestGS := types.NewGenesisState(types.NewParams( + hardGS := types.NewGenesisState(types.NewParams( true, 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())}), @@ -164,15 +164,15 @@ func (suite *KeeperTestSuite) TestDeposit() { tApp.InitializeFromGenesisStates(authGS, 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.ctx = ctx suite.keeper = keeper // Run BeginBlocker once to transition MoneyMarkets - harvest.BeginBlocker(suite.ctx, suite.keeper) + hard.BeginBlocker(suite.ctx, suite.keeper) // run the test var err error @@ -297,7 +297,7 @@ func (suite *KeeperTestSuite) TestWithdraw() { 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)))}) loanToValue := sdk.MustNewDecFromStr("0.6") - harvestGS := types.NewGenesisState(types.NewParams( + hardGS := types.NewGenesisState(types.NewParams( true, 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())}), @@ -313,8 +313,8 @@ func (suite *KeeperTestSuite) TestWithdraw() { }, 0, // LTV counter ), types.DefaultPreviousBlockTime, types.DefaultDistributionTimes) - tApp.InitializeFromGenesisStates(authGS, app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(harvestGS)}) - keeper := tApp.GetHarvestKeeper() + tApp.InitializeFromGenesisStates(authGS, app.GenesisState{types.ModuleName: types.ModuleCdc.MustMarshalJSON(hardGS)}) + keeper := tApp.GetHardKeeper() suite.app = tApp suite.ctx = ctx suite.keeper = keeper diff --git a/x/harvest/keeper/interest.go b/x/hard/keeper/interest.go similarity index 98% rename from x/harvest/keeper/interest.go rename to x/hard/keeper/interest.go index 7fd4bce7..44b64f29 100644 --- a/x/harvest/keeper/interest.go +++ b/x/hard/keeper/interest.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" 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 ( @@ -69,7 +69,7 @@ func (k Keeper) AccrueInterest(ctx sdk.Context, denom string) error { 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) // Get prior borrows diff --git a/x/harvest/keeper/interest_test.go b/x/hard/keeper/interest_test.go similarity index 95% rename from x/harvest/keeper/interest_test.go rename to x/hard/keeper/interest_test.go index e10dfd16..de186e9f 100644 --- a/x/harvest/keeper/interest_test.go +++ b/x/hard/keeper/interest_test.go @@ -11,8 +11,8 @@ import ( tmtime "github.com/tendermint/tendermint/types/time" "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/x/harvest" - "github.com/kava-labs/kava/x/harvest/types" + "github.com/kava-labs/kava/x/hard" + "github.com/kava-labs/kava/x/hard/types" "github.com/kava-labs/kava/x/pricefeed" ) @@ -83,7 +83,7 @@ func (suite *InterestTestSuite) TestCalculateUtilizationRatio() { for _, tc := range testCases { 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) }) } @@ -195,7 +195,7 @@ func (suite *InterestTestSuite) TestCalculateBorrowRate() { for _, tc := range testCases { 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().Equal(tc.args.expectedValue, borrowRate) }) @@ -302,7 +302,7 @@ func (suite *InterestTestSuite) TestCalculateInterestFactor() { } 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) } } @@ -380,7 +380,7 @@ func (suite *InterestTestSuite) TestAPYToSPY() { for _, tc := range testCases { suite.Run(tc.name, func() { - spy, err := harvest.APYToSPY(tc.args.apy) + spy, err := hard.APYToSPY(tc.args.apy) if tc.expectError { suite.Require().Error(err) } else { @@ -645,8 +645,8 @@ func (suite *KeeperTestSuite) TestInterest() { []sdk.Coins{tc.args.initialBorrowerCoins}, ) - // Harvest module genesis state - harvestGS := types.NewGenesisState(types.NewParams( + // Hard module genesis state + hardGS := types.NewGenesisState(types.NewParams( true, 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())}), @@ -689,13 +689,13 @@ func (suite *KeeperTestSuite) TestInterest() { // Initialize test application tApp.InitializeFromGenesisStates(authGS, 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.MintCoins(ctx, types.ModuleAccountName, tc.args.initialModuleCoins) - keeper := tApp.GetHarvestKeeper() + keeper := tApp.GetHardKeeper() suite.app = tApp suite.ctx = ctx suite.keeper = keeper @@ -703,7 +703,7 @@ func (suite *KeeperTestSuite) TestInterest() { var err error // 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 depositCoins := sdk.NewCoins() @@ -741,14 +741,14 @@ func (suite *KeeperTestSuite) TestInterest() { suite.Require().True(foundInterestFactorPrior) // 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) // 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) - 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) expectedReserves := reservesPrior.Add(sdk.NewCoin(tc.args.borrowCoinDenom, sdk.NewDecFromInt(expectedInterest).Mul(tc.args.reserveFactor).TruncateInt())) expectedInterestFactor := interestFactorPrior.Mul(interestFactor) @@ -757,7 +757,7 @@ func (suite *KeeperTestSuite) TestInterest() { // Set up snapshot chain context and run begin blocker runAtTime := time.Unix(prevCtx.BlockTime().Unix()+(snapshot.elapsedTime), 0) 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 expectedBorrowedCoins := borrowCoinsPrior.AmountOf(tc.args.borrowCoinDenom).Add(expectedInterest) diff --git a/x/harvest/keeper/keeper.go b/x/hard/keeper/keeper.go similarity index 99% rename from x/harvest/keeper/keeper.go rename to x/hard/keeper/keeper.go index 325e33df..2613ffa5 100644 --- a/x/harvest/keeper/keeper.go +++ b/x/hard/keeper/keeper.go @@ -8,10 +8,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "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 { key sdk.StoreKey cdc *codec.Codec diff --git a/x/harvest/keeper/keeper_test.go b/x/hard/keeper/keeper_test.go similarity index 98% rename from x/harvest/keeper/keeper_test.go rename to x/hard/keeper/keeper_test.go index 3bc0e270..31dc7de7 100644 --- a/x/harvest/keeper/keeper_test.go +++ b/x/hard/keeper/keeper_test.go @@ -17,8 +17,8 @@ import ( "github.com/kava-labs/kava/app" aucKeeper "github.com/kava-labs/kava/x/auction/keeper" - "github.com/kava-labs/kava/x/harvest/keeper" - "github.com/kava-labs/kava/x/harvest/types" + "github.com/kava-labs/kava/x/hard/keeper" + "github.com/kava-labs/kava/x/hard/types" ) // 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()}) tApp.InitializeFromGenesisStates() _, addrs := app.GeneratePrivKeyAddressPairs(1) - keeper := tApp.GetHarvestKeeper() + keeper := tApp.GetHardKeeper() suite.app = tApp suite.ctx = ctx suite.keeper = keeper diff --git a/x/harvest/keeper/liquidation.go b/x/hard/keeper/liquidation.go similarity index 99% rename from x/harvest/keeper/liquidation.go rename to x/hard/keeper/liquidation.go index 4d93cf62..236d048b 100644 --- a/x/harvest/keeper/liquidation.go +++ b/x/hard/keeper/liquidation.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" 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 diff --git a/x/harvest/keeper/liquidation_test.go b/x/hard/keeper/liquidation_test.go similarity index 97% rename from x/harvest/keeper/liquidation_test.go rename to x/hard/keeper/liquidation_test.go index a0626603..db8e2f6d 100644 --- a/x/harvest/keeper/liquidation_test.go +++ b/x/hard/keeper/liquidation_test.go @@ -11,8 +11,8 @@ import ( "github.com/kava-labs/kava/app" auctypes "github.com/kava-labs/kava/x/auction/types" - "github.com/kava-labs/kava/x/harvest" - "github.com/kava-labs/kava/x/harvest/types" + "github.com/kava-labs/kava/x/hard" + "github.com/kava-labs/kava/x/hard/types" "github.com/kava-labs/kava/x/pricefeed" ) @@ -69,7 +69,7 @@ func (suite *KeeperTestSuite) TestIndexLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 1, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("ukava", 10*KAVA_CF), Bidder: nil, Bid: sdk.NewInt64Coin("ukava", 0), @@ -120,8 +120,8 @@ func (suite *KeeperTestSuite) TestIndexLiquidation() { []sdk.Coins{tc.args.initialBorrowerCoins}, ) - // Harvest module genesis state - harvestGS := types.NewGenesisState(types.NewParams( + // Hard module genesis state + hardGS := types.NewGenesisState(types.NewParams( true, 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())}), @@ -260,15 +260,15 @@ func (suite *KeeperTestSuite) TestIndexLiquidation() { // Initialize test application tApp.InitializeFromGenesisStates(authGS, 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.MintCoins(ctx, types.ModuleAccountName, tc.args.initialModuleCoins) auctionKeeper := tApp.GetAuctionKeeper() - keeper := tApp.GetHarvestKeeper() + keeper := tApp.GetHardKeeper() suite.app = tApp suite.ctx = ctx suite.keeper = keeper @@ -277,7 +277,7 @@ func (suite *KeeperTestSuite) TestIndexLiquidation() { var err error // Run begin blocker to set up state - harvest.BeginBlocker(suite.ctx, suite.keeper) + hard.BeginBlocker(suite.ctx, suite.keeper) // Deposit coins 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 runAtTime := time.Unix(suite.ctx.BlockTime().Unix()+(tc.args.beginBlockerTime), 0) liqCtx := suite.ctx.WithBlockTime(runAtTime) - harvest.BeginBlocker(liqCtx, suite.keeper) + hard.BeginBlocker(liqCtx, suite.keeper) if tc.errArgs.expectLiquidate { // Check borrow does not exist after liquidation @@ -403,7 +403,7 @@ func (suite *KeeperTestSuite) TestFullIndexLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 1, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("ukava", 10*KAVA_CF), Bidder: nil, Bid: sdk.NewInt64Coin("ukava", 0), @@ -440,7 +440,7 @@ func (suite *KeeperTestSuite) TestFullIndexLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 1, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("ukava", 10*KAVA_CF), Bidder: nil, Bid: sdk.NewInt64Coin("ukava", 0), @@ -455,7 +455,7 @@ func (suite *KeeperTestSuite) TestFullIndexLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 2, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("ukava", 10*KAVA_CF), Bidder: nil, Bid: sdk.NewInt64Coin("ukava", 0), @@ -470,7 +470,7 @@ func (suite *KeeperTestSuite) TestFullIndexLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 3, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("ukava", 10*KAVA_CF), Bidder: nil, Bid: sdk.NewInt64Coin("ukava", 0), @@ -485,7 +485,7 @@ func (suite *KeeperTestSuite) TestFullIndexLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 4, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("ukava", 10*KAVA_CF), Bidder: nil, Bid: sdk.NewInt64Coin("ukava", 0), @@ -546,8 +546,8 @@ func (suite *KeeperTestSuite) TestFullIndexLiquidation() { // Auth module genesis state authGS := app.NewAuthGenState(appAddrs, appCoins) - // Harvest module genesis state - harvestGS := types.NewGenesisState(types.NewParams( + // Hard module genesis state + hardGS := types.NewGenesisState(types.NewParams( true, 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())}), @@ -606,15 +606,15 @@ func (suite *KeeperTestSuite) TestFullIndexLiquidation() { // Initialize test application tApp.InitializeFromGenesisStates(authGS, 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.MintCoins(ctx, types.ModuleAccountName, tc.args.initialModuleCoins) auctionKeeper := tApp.GetAuctionKeeper() - keeper := tApp.GetHarvestKeeper() + keeper := tApp.GetHardKeeper() suite.app = tApp suite.ctx = ctx suite.keeper = keeper @@ -623,7 +623,7 @@ func (suite *KeeperTestSuite) TestFullIndexLiquidation() { var err error // 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 ----------- @@ -664,7 +664,7 @@ func (suite *KeeperTestSuite) TestFullIndexLiquidation() { // Liquidate the borrow by running begin blocker runAtTime := time.Unix(suite.ctx.BlockTime().Unix()+(tc.args.beginBlockerTime), 0) liqCtx := suite.ctx.WithBlockTime(runAtTime) - harvest.BeginBlocker(liqCtx, suite.keeper) + hard.BeginBlocker(liqCtx, suite.keeper) if tc.errArgs.expectLiquidate { // Check borrow does not exist after liquidation @@ -805,7 +805,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 1, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("ukava", 9499999), Bidder: nil, Bid: sdk.NewInt64Coin("ukava", 0), @@ -843,7 +843,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 1, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("ukava", 11874422), Bidder: nil, Bid: sdk.NewInt64Coin("bnb", 0), @@ -858,7 +858,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 2, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("ukava", 11874245), Bidder: nil, Bid: sdk.NewInt64Coin("btc", 0), @@ -873,7 +873,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 3, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("ukava", 11875155), Bidder: nil, Bid: sdk.NewInt64Coin("ukava", 0), @@ -888,7 +888,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 4, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("ukava", 11876178), Bidder: nil, Bid: sdk.NewInt64Coin("usdc", 0), @@ -926,7 +926,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 1, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("bnb", 950000000), Bidder: nil, Bid: sdk.NewInt64Coin("ukava", 0), @@ -941,7 +941,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 2, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("btc", 95000000), Bidder: nil, Bid: sdk.NewInt64Coin("ukava", 0), @@ -956,7 +956,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 3, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("ukava", 47499999), Bidder: nil, Bid: sdk.NewInt64Coin("ukava", 0), @@ -995,7 +995,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 1, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("usdc", 95000000), // $95.00 Bidder: nil, Bid: sdk.NewInt64Coin("bnb", 0), @@ -1010,7 +1010,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 2, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("usdt", 10552835), // $10.55 Bidder: nil, Bid: sdk.NewInt64Coin("bnb", 0), @@ -1025,7 +1025,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 3, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("usdt", 84447165), // $84.45 Bidder: nil, Bid: sdk.NewInt64Coin("btc", 0), @@ -1040,7 +1040,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 4, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("usdx", 21097866), // $21.10 Bidder: nil, Bid: sdk.NewInt64Coin("btc", 0), @@ -1055,7 +1055,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 5, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("usdx", 73902133), //$73.90 Bidder: nil, Bid: sdk.NewInt64Coin("ukava", 0), @@ -1093,7 +1093,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 1, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("dai", 263894126), Bidder: nil, Bid: sdk.NewInt64Coin("usdt", 0), @@ -1108,7 +1108,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 2, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("dai", 68605874), Bidder: nil, Bid: sdk.NewInt64Coin("usdx", 0), @@ -1123,7 +1123,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() { auctypes.CollateralAuction{ BaseAuction: auctypes.BaseAuction{ ID: 3, - Initiator: "harvest_liquidator", + Initiator: "hard_liquidator", Lot: sdk.NewInt64Coin("usdc", 189999999), Bidder: nil, Bid: sdk.NewInt64Coin("usdx", 0), @@ -1178,8 +1178,8 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() { []sdk.Coins{tc.args.initialBorrowerCoins, tc.args.initialKeeperCoins}, ) - // Harvest module genesis state - harvestGS := types.NewGenesisState(types.NewParams( + // Hard module genesis state + hardGS := types.NewGenesisState(types.NewParams( true, 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())}), @@ -1318,15 +1318,15 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() { // Initialize test application tApp.InitializeFromGenesisStates(authGS, 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.MintCoins(ctx, types.ModuleAccountName, tc.args.initialModuleCoins) auctionKeeper := tApp.GetAuctionKeeper() - keeper := tApp.GetHarvestKeeper() + keeper := tApp.GetHardKeeper() suite.app = tApp suite.ctx = ctx suite.keeper = keeper @@ -1335,7 +1335,7 @@ func (suite *KeeperTestSuite) TestKeeperLiquidation() { var err error // Run begin blocker to set up state - harvest.BeginBlocker(suite.ctx, suite.keeper) + hard.BeginBlocker(suite.ctx, suite.keeper) // Deposit coins 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 runAtTime := time.Unix(suite.ctx.BlockTime().Unix()+(tc.args.liquidateAfter), 0) liqCtx := suite.ctx.WithBlockTime(runAtTime) - harvest.BeginBlocker(liqCtx, suite.keeper) + hard.BeginBlocker(liqCtx, suite.keeper) // Check borrow exists before liquidation _, foundBorrowBefore := suite.keeper.GetBorrow(liqCtx, tc.args.borrower) diff --git a/x/harvest/keeper/params.go b/x/hard/keeper/params.go similarity index 97% rename from x/harvest/keeper/params.go rename to x/hard/keeper/params.go index a6381cc7..6ec62eb3 100644 --- a/x/harvest/keeper/params.go +++ b/x/hard/keeper/params.go @@ -3,7 +3,7 @@ package keeper import ( 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 diff --git a/x/harvest/keeper/querier.go b/x/hard/keeper/querier.go similarity index 94% rename from x/harvest/keeper/querier.go rename to x/hard/keeper/querier.go index 782b523a..9f12abb9 100644 --- a/x/harvest/keeper/querier.go +++ b/x/hard/keeper/querier.go @@ -9,7 +9,7 @@ import ( 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 @@ -164,17 +164,17 @@ func queryGetClaims(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, e return false }) case owner && claimType: - harvestParams := k.GetParams(ctx) + hardParams := k.GetParams(ctx) switch { 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) if found { claims = append(claims, claim) } } 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) if found { claims = append(claims, claim) @@ -189,28 +189,28 @@ func queryGetClaims(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, e }) } case owner: - harvestParams := k.GetParams(ctx) - for _, lps := range harvestParams.LiquidityProviderSchedules { + hardParams := k.GetParams(ctx) + for _, lps := range hardParams.LiquidityProviderSchedules { claim, found := k.GetClaim(ctx, params.Owner, lps.DepositDenom, types.LP) if found { 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) if found { claims = append(claims, claim) } } case claimType: - harvestParams := k.GetParams(ctx) - for _, lps := range harvestParams.LiquidityProviderSchedules { + hardParams := k.GetParams(ctx) + for _, lps := range hardParams.LiquidityProviderSchedules { k.IterateClaimsByTypeAndDenom(ctx, params.ClaimType, lps.DepositDenom, func(claim types.Claim) (stop bool) { claims = append(claims, claim) 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) { claims = append(claims, claim) return false diff --git a/x/harvest/keeper/repay.go b/x/hard/keeper/repay.go similarity index 94% rename from x/harvest/keeper/repay.go rename to x/hard/keeper/repay.go index a20b9349..c1f5822a 100644 --- a/x/harvest/keeper/repay.go +++ b/x/hard/keeper/repay.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" 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 @@ -32,7 +32,7 @@ func (k Keeper) Repay(ctx sdk.Context, sender sdk.AccAddress, coins sdk.Coins) e 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) if err != nil { return err @@ -49,7 +49,7 @@ func (k Keeper) Repay(ctx sdk.Context, sender sdk.AccAddress, coins sdk.Coins) e ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypeHarvestRepay, + types.EventTypeHardRepay, sdk.NewAttribute(types.AttributeKeySender, sender.String()), sdk.NewAttribute(types.AttributeKeyRepayCoins, payment.String()), ), diff --git a/x/harvest/keeper/repay_test.go b/x/hard/keeper/repay_test.go similarity index 96% rename from x/harvest/keeper/repay_test.go rename to x/hard/keeper/repay_test.go index d2c2416a..f124dabe 100644 --- a/x/harvest/keeper/repay_test.go +++ b/x/hard/keeper/repay_test.go @@ -10,8 +10,8 @@ import ( tmtime "github.com/tendermint/tendermint/types/time" "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/x/harvest" - "github.com/kava-labs/kava/x/harvest/types" + "github.com/kava-labs/kava/x/hard" + "github.com/kava-labs/kava/x/hard/types" "github.com/kava-labs/kava/x/pricefeed" ) @@ -114,8 +114,8 @@ func (suite *KeeperTestSuite) TestRepay() { []sdk.AccAddress{tc.args.borrower}, []sdk.Coins{tc.args.initialBorrowerCoins}) - // Harvest module genesis state - harvestGS := types.NewGenesisState(types.NewParams( + // Hard module genesis state + hardGS := types.NewGenesisState(types.NewParams( true, 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())}), @@ -174,14 +174,14 @@ func (suite *KeeperTestSuite) TestRepay() { // Initialize test application tApp.InitializeFromGenesisStates(authGS, 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.MintCoins(ctx, types.ModuleAccountName, tc.args.initialModuleCoins) - keeper := tApp.GetHarvestKeeper() + keeper := tApp.GetHardKeeper() suite.app = tApp suite.ctx = ctx suite.keeper = keeper @@ -189,13 +189,13 @@ func (suite *KeeperTestSuite) TestRepay() { var err error // 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) suite.Require().NoError(err) - // Borrow coins from harvest + // Borrow coins from hard err = suite.keeper.Borrow(suite.ctx, tc.args.borrower, tc.args.borrowCoins) suite.Require().NoError(err) diff --git a/x/harvest/keeper/rewards.go b/x/hard/keeper/rewards.go similarity index 97% rename from x/harvest/keeper/rewards.go rename to x/hard/keeper/rewards.go index 0e1039a5..3aa0a73e 100644 --- a/x/harvest/keeper/rewards.go +++ b/x/hard/keeper/rewards.go @@ -7,7 +7,7 @@ import ( stakingexported "github.com/cosmos/cosmos-sdk/x/staking/exported" 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 @@ -58,7 +58,7 @@ func (k Keeper) ApplyDepositRewards(ctx sdk.Context) { }) ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypeHarvestLPDistribution, + types.EventTypeHardLPDistribution, sdk.NewAttribute(types.AttributeKeyBlockHeight, fmt.Sprintf("%d", ctx.BlockHeight())), sdk.NewAttribute(types.AttributeKeyRewardsDistribution, rewardsDistributed.String()), sdk.NewAttribute(types.AttributeKeyDepositDenom, lps.DepositDenom), @@ -154,7 +154,7 @@ func (k Keeper) ApplyDelegationRewards(ctx sdk.Context, denom string) { ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypeHarvestDelegatorDistribution, + types.EventTypeHardDelegatorDistribution, sdk.NewAttribute(types.AttributeKeyBlockHeight, fmt.Sprintf("%d", ctx.BlockHeight())), sdk.NewAttribute(types.AttributeKeyRewardsDistribution, rewardsDistributed.String()), sdk.NewAttribute(types.AttributeKeyDepositDenom, denom), diff --git a/x/harvest/keeper/rewards_test.go b/x/hard/keeper/rewards_test.go similarity index 97% rename from x/harvest/keeper/rewards_test.go rename to x/hard/keeper/rewards_test.go index 6e06db49..133deb1d 100644 --- a/x/harvest/keeper/rewards_test.go +++ b/x/hard/keeper/rewards_test.go @@ -13,8 +13,8 @@ import ( "github.com/tendermint/tendermint/crypto/ed25519" "github.com/kava-labs/kava/app" - "github.com/kava-labs/kava/x/harvest/keeper" - "github.com/kava-labs/kava/x/harvest/types" + "github.com/kava-labs/kava/x/hard/keeper" + "github.com/kava-labs/kava/x/hard/types" ) func (suite *KeeperTestSuite) TestApplyDepositRewards() { @@ -64,7 +64,7 @@ func (suite *KeeperTestSuite) TestApplyDepositRewards() { tApp := app.NewTestApp() ctx := tApp.NewContext(true, abci.Header{Height: 1, Time: tc.args.blockTime}) loanToValue, _ := sdk.NewDecFromStr("0.6") - harvestGS := types.NewGenesisState(types.NewParams( + hardGS := types.NewGenesisState(types.NewParams( true, 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())}), @@ -80,10 +80,10 @@ func (suite *KeeperTestSuite) TestApplyDepositRewards() { }, 0, // LTV counter ), 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.MintCoins(ctx, types.ModuleAccountName, cs(tc.args.totalDeposits)) - keeper := tApp.GetHarvestKeeper() + keeper := tApp.GetHardKeeper() deposit := types.NewDeposit(tc.args.depositor, tc.args.depositAmount) keeper.SetDeposit(ctx, deposit) suite.app = tApp @@ -136,10 +136,10 @@ func (suite *DelegatorRewardsTestSuite) SetupTest() { suite.app.InitializeFromGenesisStates( equalCoinsAuthGenState(allAddrs, cs(c("ukava", 5_000_000))), 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() } @@ -405,7 +405,7 @@ func (suite *DelegatorRewardsTestSuite) kavaClaimExists(ctx sdk.Context, owner s return found } -func harvestGenesisState(rewardRate sdk.Coin) app.GenesisState { +func hardGenesisState(rewardRate sdk.Coin) app.GenesisState { loanToValue := sdk.MustNewDecFromStr("0.6") genState := types.NewGenesisState( types.NewParams( diff --git a/x/harvest/keeper/timelock.go b/x/hard/keeper/timelock.go similarity index 99% rename from x/harvest/keeper/timelock.go rename to x/hard/keeper/timelock.go index cfadde34..72678b9a 100644 --- a/x/harvest/keeper/timelock.go +++ b/x/hard/keeper/timelock.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/vesting" 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" ) diff --git a/x/harvest/keeper/timelock_test.go b/x/hard/keeper/timelock_test.go similarity index 98% rename from x/harvest/keeper/timelock_test.go rename to x/hard/keeper/timelock_test.go index 5615c20b..16e0f393 100644 --- a/x/harvest/keeper/timelock_test.go +++ b/x/hard/keeper/timelock_test.go @@ -10,7 +10,7 @@ import ( "github.com/tendermint/tendermint/crypto" "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() { @@ -280,7 +280,7 @@ func (suite *KeeperTestSuite) TestSendTimeLockedCoinsToAccount() { 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}) loanToValue := sdk.MustNewDecFromStr("0.6") - harvestGS := types.NewGenesisState(types.NewParams( + hardGS := types.NewGenesisState(types.NewParams( true, 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())}), @@ -296,7 +296,7 @@ func (suite *KeeperTestSuite) TestSendTimeLockedCoinsToAccount() { }, 0, // LTV counter ), 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 { ak := tApp.GetAccountKeeper() acc := ak.GetAccount(ctx, tc.args.accArgs.addr) @@ -308,7 +308,7 @@ func (suite *KeeperTestSuite) TestSendTimeLockedCoinsToAccount() { } supplyKeeper := tApp.GetSupplyKeeper() supplyKeeper.MintCoins(ctx, types.LPAccount, sdk.NewCoins(sdk.NewCoin("hard", sdk.NewInt(1000)))) - keeper := tApp.GetHarvestKeeper() + keeper := tApp.GetHardKeeper() suite.app = tApp suite.ctx = ctx suite.keeper = keeper diff --git a/x/harvest/legacy/v0_12/types.go b/x/hard/legacy/v0_12/types.go similarity index 98% rename from x/harvest/legacy/v0_12/types.go rename to x/hard/legacy/v0_12/types.go index 80553bab..211ced01 100644 --- a/x/harvest/legacy/v0_12/types.go +++ b/x/hard/legacy/v0_12/types.go @@ -24,7 +24,7 @@ var ( GovDenom = cdptypes.DefaultGovDenom ) -// Params governance parameters for harvest module +// Params governance parameters for hard module type Params struct { Active bool `json:"active" yaml:"active"` 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 { return NewParams(DefaultActive, DefaultLPSchedules, DefaultDelegatorSchedules) } @@ -342,7 +342,7 @@ func (dt DepositType) IsValid() error { 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 { Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` Amount sdk.Coin `json:"amount" yaml:"amount"` diff --git a/x/harvest/module.go b/x/hard/module.go similarity index 85% rename from x/harvest/module.go rename to x/hard/module.go index 13ee93a5..53f120ab 100644 --- a/x/harvest/module.go +++ b/x/hard/module.go @@ -1,4 +1,4 @@ -package harvest +package hard import ( "encoding/json" @@ -15,11 +15,11 @@ import ( abci "github.com/tendermint/tendermint/abci/types" - "github.com/kava-labs/kava/x/harvest/client/cli" - "github.com/kava-labs/kava/x/harvest/client/rest" - "github.com/kava-labs/kava/x/harvest/keeper" - "github.com/kava-labs/kava/x/harvest/simulation" - "github.com/kava-labs/kava/x/harvest/types" + "github.com/kava-labs/kava/x/hard/client/cli" + "github.com/kava-labs/kava/x/hard/client/rest" + "github.com/kava-labs/kava/x/hard/keeper" + "github.com/kava-labs/kava/x/hard/simulation" + "github.com/kava-labs/kava/x/hard/types" ) var ( @@ -56,17 +56,17 @@ func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { 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) { 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 { 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 { 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) { simulation.RandomizedGenState(simState) } @@ -157,17 +157,17 @@ func (AppModuleBasic) ProposalContents(_ module.SimulationState) []sim.WeightedP 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 { 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) { 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 { return nil } diff --git a/x/harvest/simulation/decoder.go b/x/hard/simulation/decoder.go similarity index 94% rename from x/harvest/simulation/decoder.go rename to x/hard/simulation/decoder.go index 6bde9400..63469e31 100644 --- a/x/harvest/simulation/decoder.go +++ b/x/hard/simulation/decoder.go @@ -9,10 +9,10 @@ import ( "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 { switch { case bytes.Equal(kvA.Key[:1], types.PreviousBlockTimeKey), bytes.Equal(kvA.Key[:1], types.PreviousDelegationDistributionKey): diff --git a/x/harvest/simulation/decoder_test.go b/x/hard/simulation/decoder_test.go similarity index 97% rename from x/harvest/simulation/decoder_test.go rename to x/hard/simulation/decoder_test.go index e7047e92..007afd23 100644 --- a/x/harvest/simulation/decoder_test.go +++ b/x/hard/simulation/decoder_test.go @@ -12,7 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" 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) { diff --git a/x/harvest/simulation/genesis.go b/x/hard/simulation/genesis.go similarity index 88% rename from x/harvest/simulation/genesis.go rename to x/hard/simulation/genesis.go index 29ef3f6b..15328118 100644 --- a/x/harvest/simulation/genesis.go +++ b/x/hard/simulation/genesis.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "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 @@ -16,20 +16,20 @@ const ( BaseAprPadding = "0.000000003022265980" ) -// RandomizedGenState generates a random GenesisState for harvest module +// RandomizedGenState generates a random GenesisState for hard module func RandomizedGenState(simState *module.SimulationState) { // params := genRandomParams(simState) // if err := params.Validate(); err != nil { // panic(err) // } - harvestGenesis := types.DefaultGenesisState() - if err := harvestGenesis.Validate(); err != nil { + hardGenesis := types.DefaultGenesisState() + if err := hardGenesis.Validate(); err != nil { panic(err) } - fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, codec.MustMarshalJSONIndent(simState.Cdc, harvestGenesis)) - simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(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(hardGenesis) } // func genRandomParams(simState *module.SimulationState) types.Params { diff --git a/x/harvest/simulation/params.go b/x/hard/simulation/params.go similarity index 100% rename from x/harvest/simulation/params.go rename to x/hard/simulation/params.go diff --git a/x/harvest/spec/01_concepts.md b/x/hard/spec/01_concepts.md similarity index 61% rename from x/harvest/spec/01_concepts.md rename to x/hard/spec/01_concepts.md index 7dc4a5d2..90d15d6f 100644 --- a/x/harvest/spec/01_concepts.md +++ b/x/hard/spec/01_concepts.md @@ -4,19 +4,19 @@ order: 1 # 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. -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. -* 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. -* 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. +- 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. +- 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: -* 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. -* 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. +- 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. +- 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. diff --git a/x/harvest/spec/02_state.md b/x/hard/spec/02_state.md similarity index 96% rename from x/harvest/spec/02_state.md rename to x/hard/spec/02_state.md index 1dfbea63..189159d2 100644 --- a/x/harvest/spec/02_state.md +++ b/x/hard/spec/02_state.md @@ -9,7 +9,7 @@ order: 2 `Parameters` define the distribution schedule of hard tokens that will be distributed to delegators and depositors, respectively. ```go -// Params governance parameters for harvest module +// Params governance parameters for hard module type Params struct { Active bool `json:"active" yaml:"active"` LiquidityProviderSchedules DistributionSchedules `json:"liquidity_provider_schedules" yaml:"liquidity_provider_schedules"` @@ -41,7 +41,7 @@ type DelegatorDistributionSchedule struct { 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 // GenesisState is the state that must be provided at genesis. diff --git a/x/harvest/spec/03_messages.md b/x/hard/spec/03_messages.md similarity index 65% rename from x/harvest/spec/03_messages.md rename to x/hard/spec/03_messages.md index 9cff41e3..ba91ef57 100644 --- a/x/harvest/spec/03_messages.md +++ b/x/hard/spec/03_messages.md @@ -4,16 +4,16 @@ order: 3 # 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 -// MsgDeposit deposit asset to the harvest module. +// MsgDeposit deposit asset to the hard module. type MsgDeposit struct { Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` Amount sdk.Coin `json:"amount" yaml:"amount"` } -// MsgWithdraw withdraw from the harvest module. +// MsgWithdraw withdraw from the hard module. type MsgWithdraw struct { Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` Amount sdk.Coin `json:"amount" yaml:"amount"` diff --git a/x/hard/spec/04_events.md b/x/hard/spec/04_events.md new file mode 100644 index 00000000..cd87e79c --- /dev/null +++ b/x/hard/spec/04_events.md @@ -0,0 +1,55 @@ + + +# 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}` | diff --git a/x/hard/spec/05_params.md b/x/hard/spec/05_params.md new file mode 100644 index 00000000..29713868 --- /dev/null +++ b/x/hard/spec/05_params.md @@ -0,0 +1,46 @@ + + +# 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 | diff --git a/x/harvest/spec/06_begin_block.md b/x/hard/spec/06_begin_block.md similarity index 100% rename from x/harvest/spec/06_begin_block.md rename to x/hard/spec/06_begin_block.md diff --git a/x/hard/spec/README.md b/x/hard/spec/README.md new file mode 100644 index 00000000..1b60195c --- /dev/null +++ b/x/hard/spec/README.md @@ -0,0 +1,21 @@ + + +# `hard` + + + +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. diff --git a/x/harvest/types/borrow.go b/x/hard/types/borrow.go similarity index 63% rename from x/harvest/types/borrow.go rename to x/hard/types/borrow.go index fd6e2658..cec6e4d1 100644 --- a/x/harvest/types/borrow.go +++ b/x/hard/types/borrow.go @@ -4,7 +4,24 @@ import ( 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 { Borrower sdk.AccAddress `json:"borrower" yaml:"borrower"` Amount sdk.Coins `json:"amount" yaml:"amount"` diff --git a/x/harvest/types/claim.go b/x/hard/types/claim.go similarity index 100% rename from x/harvest/types/claim.go rename to x/hard/types/claim.go diff --git a/x/hard/types/codec.go b/x/hard/types/codec.go new file mode 100644 index 00000000..ea0c1868 --- /dev/null +++ b/x/hard/types/codec.go @@ -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) +} diff --git a/x/harvest/types/deposit.go b/x/hard/types/deposit.go similarity index 83% rename from x/harvest/types/deposit.go rename to x/hard/types/deposit.go index db491659..cf531165 100644 --- a/x/harvest/types/deposit.go +++ b/x/hard/types/deposit.go @@ -4,7 +4,7 @@ import ( 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 { Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` Amount sdk.Coins `json:"amount" yaml:"amount"` diff --git a/x/harvest/types/errors.go b/x/hard/types/errors.go similarity index 100% rename from x/harvest/types/errors.go rename to x/hard/types/errors.go diff --git a/x/harvest/types/events.go b/x/hard/types/events.go similarity index 59% rename from x/harvest/types/events.go rename to x/hard/types/events.go index c568d56f..b0a80582 100644 --- a/x/harvest/types/events.go +++ b/x/hard/types/events.go @@ -1,16 +1,16 @@ package types -// Event types for harvest module +// Event types for hard module const ( - EventTypeHarvestDeposit = "harvest_deposit" - EventTypeHarvestDelegatorDistribution = "harvest_delegator_distribution" - EventTypeHarvestLPDistribution = "harvest_lp_distribution" - EventTypeDeleteHarvestDeposit = "delete_harvest_deposit" - EventTypeHarvestWithdrawal = "harvest_withdrawal" - EventTypeClaimHarvestReward = "claim_harvest_reward" - EventTypeHarvestBorrow = "harvest_borrow" - EventTypeDepositLiquidation = "harvest_liquidation" - EventTypeHarvestRepay = "harvest_repay" + EventTypeHardDeposit = "hard_deposit" + EventTypeHardDelegatorDistribution = "hard_delegator_distribution" + EventTypeHardLPDistribution = "hard_lp_distribution" + EventTypeDeleteHardDeposit = "delete_hard_deposit" + EventTypeHardWithdrawal = "hard_withdrawal" + EventTypeClaimHardReward = "claim_hard_reward" + EventTypeHardBorrow = "hard_borrow" + EventTypeDepositLiquidation = "hard_liquidation" + EventTypeHardRepay = "hard_repay" AttributeValueCategory = ModuleName AttributeKeyBlockHeight = "block_height" AttributeKeyRewardsDistribution = "rewards_distributed" diff --git a/x/harvest/types/expected_keepers.go b/x/hard/types/expected_keepers.go similarity index 100% rename from x/harvest/types/expected_keepers.go rename to x/hard/types/expected_keepers.go diff --git a/x/harvest/types/genesis.go b/x/hard/types/genesis.go similarity index 100% rename from x/harvest/types/genesis.go rename to x/hard/types/genesis.go diff --git a/x/harvest/types/genesis_test.go b/x/hard/types/genesis_test.go similarity index 99% rename from x/harvest/types/genesis_test.go rename to x/hard/types/genesis_test.go index f2f48010..6eed15bd 100644 --- a/x/harvest/types/genesis_test.go +++ b/x/hard/types/genesis_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/suite" - "github.com/kava-labs/kava/x/harvest/types" + "github.com/kava-labs/kava/x/hard/types" ) type GenesisTestSuite struct { diff --git a/x/harvest/types/keys.go b/x/hard/types/keys.go similarity index 92% rename from x/harvest/types/keys.go rename to x/hard/types/keys.go index 44989e53..b7aaac29 100644 --- a/x/harvest/types/keys.go +++ b/x/hard/types/keys.go @@ -6,19 +6,19 @@ import ( const ( // ModuleName name that will be used throughout the module - ModuleName = "harvest" + ModuleName = "hard" // LPAccount LP distribution module account - LPAccount = "harvest_lp_distribution" + LPAccount = "hard_lp_distribution" // DelegatorAccount delegator distribution module account - DelegatorAccount = "harvest_delegator_distribution" + DelegatorAccount = "hard_delegator_distribution" // LiquidatorAccount module account for liquidator - LiquidatorAccount = "harvest_liquidator" + LiquidatorAccount = "hard_liquidator" // 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 = ModuleName diff --git a/x/harvest/types/liquidation.go b/x/hard/types/liquidation.go similarity index 100% rename from x/harvest/types/liquidation.go rename to x/hard/types/liquidation.go diff --git a/x/harvest/types/msg.go b/x/hard/types/msg.go similarity index 95% rename from x/harvest/types/msg.go rename to x/hard/types/msg.go index fb773c0d..5da01394 100644 --- a/x/harvest/types/msg.go +++ b/x/hard/types/msg.go @@ -55,7 +55,7 @@ var ( _ sdk.Msg = &MsgBorrow{} ) -// MsgDeposit deposit collateral to the harvest module. +// MsgDeposit deposit collateral to the hard module. type MsgDeposit struct { Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` 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 } // 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. func (msg MsgDeposit) ValidateBasic() error { @@ -105,7 +105,7 @@ func (msg MsgDeposit) String() string { `, msg.Depositor, msg.Amount) } -// MsgWithdraw withdraw from the harvest module. +// MsgWithdraw withdraw from the hard module. type MsgWithdraw struct { Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` 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 } // 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. func (msg MsgWithdraw) ValidateBasic() error { @@ -179,7 +179,7 @@ func NewMsgClaimReward(sender, receiver sdk.AccAddress, depositDenom, claimType, func (msg MsgClaimReward) Route() string { return RouterKey } // 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. func (msg MsgClaimReward) ValidateBasic() error { @@ -209,7 +209,7 @@ func (msg MsgClaimReward) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Sender} } -// MsgBorrow borrows funds from the harvest module. +// MsgBorrow borrows funds from the hard module. type MsgBorrow struct { Borrower sdk.AccAddress `json:"borrower" yaml:"borrower"` 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 } // 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. func (msg MsgBorrow) ValidateBasic() error { @@ -259,7 +259,7 @@ func (msg MsgBorrow) String() string { `, msg.Borrower, msg.Amount) } -// MsgRepay repays funds to the harvest module. +// MsgRepay repays funds to the hard module. type MsgRepay struct { Sender sdk.AccAddress `json:"sender" yaml:"sender"` 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 } // 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. func (msg MsgRepay) ValidateBasic() error { diff --git a/x/harvest/types/msg_test.go b/x/hard/types/msg_test.go similarity index 99% rename from x/harvest/types/msg_test.go rename to x/hard/types/msg_test.go index b25030b5..931c5d29 100644 --- a/x/harvest/types/msg_test.go +++ b/x/hard/types/msg_test.go @@ -8,7 +8,7 @@ import ( 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 { diff --git a/x/harvest/types/params.go b/x/hard/types/params.go similarity index 99% rename from x/harvest/types/params.go rename to x/hard/types/params.go index 9f2d12c9..ee839a95 100644 --- a/x/harvest/types/params.go +++ b/x/hard/types/params.go @@ -27,7 +27,7 @@ var ( GovDenom = cdptypes.DefaultGovDenom ) -// Params governance parameters for harvest module +// Params governance parameters for hard module type Params struct { Active bool `json:"active" yaml:"active"` 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 { return NewParams(DefaultActive, DefaultLPSchedules, DefaultDelegatorSchedules, DefaultMoneyMarkets, DefaultCheckLtvIndexCount) diff --git a/x/harvest/types/params_test.go b/x/hard/types/params_test.go similarity index 98% rename from x/harvest/types/params_test.go rename to x/hard/types/params_test.go index 10f75fae..33a5ddfc 100644 --- a/x/harvest/types/params_test.go +++ b/x/hard/types/params_test.go @@ -9,7 +9,7 @@ import ( 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 { diff --git a/x/harvest/types/period.go b/x/hard/types/period.go similarity index 100% rename from x/harvest/types/period.go rename to x/hard/types/period.go diff --git a/x/harvest/types/querier.go b/x/hard/types/querier.go similarity index 98% rename from x/harvest/types/querier.go rename to x/hard/types/querier.go index 22ec8495..eab8bad0 100644 --- a/x/harvest/types/querier.go +++ b/x/hard/types/querier.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// Querier routes for the harvest module +// Querier routes for the hard module const ( QueryGetParams = "params" QueryGetModuleAccounts = "accounts" diff --git a/x/harvest/spec/04_events.md b/x/harvest/spec/04_events.md deleted file mode 100644 index e84209f4..00000000 --- a/x/harvest/spec/04_events.md +++ /dev/null @@ -1,55 +0,0 @@ - - -# 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}` | diff --git a/x/harvest/spec/05_params.md b/x/harvest/spec/05_params.md deleted file mode 100644 index 1d04e499..00000000 --- a/x/harvest/spec/05_params.md +++ /dev/null @@ -1,46 +0,0 @@ - - -# 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 | diff --git a/x/harvest/spec/README.md b/x/harvest/spec/README.md deleted file mode 100644 index 49e05f6c..00000000 --- a/x/harvest/spec/README.md +++ /dev/null @@ -1,20 +0,0 @@ - - -# `harvest` - - -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. diff --git a/x/harvest/types/codec.go b/x/harvest/types/codec.go deleted file mode 100644 index 8858491d..00000000 --- a/x/harvest/types/codec.go +++ /dev/null @@ -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) -}