2022-07-20 22:57:56 +00:00
|
|
|
package keeper
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
2023-04-04 00:08:45 +00:00
|
|
|
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
2022-07-20 22:57:56 +00:00
|
|
|
"github.com/kava-labs/kava/x/earn/types"
|
|
|
|
|
|
|
|
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Keeper keeper for the earn module
|
|
|
|
type Keeper struct {
|
2023-04-04 00:08:45 +00:00
|
|
|
key storetypes.StoreKey
|
2022-07-20 22:57:56 +00:00
|
|
|
cdc codec.Codec
|
|
|
|
paramSubspace paramtypes.Subspace
|
2022-09-12 17:50:35 +00:00
|
|
|
hooks types.EarnHooks
|
2022-07-20 22:57:56 +00:00
|
|
|
accountKeeper types.AccountKeeper
|
|
|
|
bankKeeper types.BankKeeper
|
2022-09-20 18:52:40 +00:00
|
|
|
liquidKeeper types.LiquidKeeper
|
2022-07-28 16:39:57 +00:00
|
|
|
|
|
|
|
// Keepers used for strategies
|
|
|
|
hardKeeper types.HardKeeper
|
|
|
|
savingsKeeper types.SavingsKeeper
|
2022-09-29 17:01:06 +00:00
|
|
|
|
2023-01-26 17:01:28 +00:00
|
|
|
// Keeper for community pool transfers
|
|
|
|
distKeeper types.DistributionKeeper
|
2022-07-20 22:57:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewKeeper creates a new keeper
|
|
|
|
func NewKeeper(
|
|
|
|
cdc codec.Codec,
|
2023-04-04 00:08:45 +00:00
|
|
|
key storetypes.StoreKey,
|
2022-07-20 22:57:56 +00:00
|
|
|
paramstore paramtypes.Subspace,
|
|
|
|
accountKeeper types.AccountKeeper,
|
|
|
|
bankKeeper types.BankKeeper,
|
2022-09-20 18:52:40 +00:00
|
|
|
liquidKeeper types.LiquidKeeper,
|
2022-07-28 16:39:57 +00:00
|
|
|
hardKeeper types.HardKeeper,
|
|
|
|
savingsKeeper types.SavingsKeeper,
|
2023-01-26 17:01:28 +00:00
|
|
|
distKeeper types.DistributionKeeper,
|
2022-07-20 22:57:56 +00:00
|
|
|
) Keeper {
|
|
|
|
if !paramstore.HasKeyTable() {
|
|
|
|
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
|
|
|
|
}
|
|
|
|
|
|
|
|
return Keeper{
|
|
|
|
key: key,
|
|
|
|
cdc: cdc,
|
|
|
|
paramSubspace: paramstore,
|
|
|
|
accountKeeper: accountKeeper,
|
|
|
|
bankKeeper: bankKeeper,
|
2022-09-20 18:52:40 +00:00
|
|
|
liquidKeeper: liquidKeeper,
|
2022-07-28 16:39:57 +00:00
|
|
|
hardKeeper: hardKeeper,
|
|
|
|
savingsKeeper: savingsKeeper,
|
2023-01-26 17:01:28 +00:00
|
|
|
distKeeper: distKeeper,
|
2022-07-20 22:57:56 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-12 17:50:35 +00:00
|
|
|
|
|
|
|
// SetHooks adds hooks to the keeper.
|
|
|
|
func (k *Keeper) SetHooks(sh types.EarnHooks) *Keeper {
|
|
|
|
if k.hooks != nil {
|
|
|
|
panic("cannot set earn hooks twice")
|
|
|
|
}
|
|
|
|
k.hooks = sh
|
|
|
|
return k
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearHooks clears the hooks on the keeper
|
|
|
|
func (k *Keeper) ClearHooks() {
|
|
|
|
k.hooks = nil
|
|
|
|
}
|