mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 10:05:18 +00:00
49d62dd076
* initial feature scaffolding * implement interest keeper logic * basic AccrueInterest * accrue interest on borrow * update borrow index formula * update sample reserve factor * move AccrueInterest to begin blocker * refactor interest rate updates for accrue interest * use interest rate model from store * refactor begin blocker state machine * add reserve factor to interest model params * update comment * store money market instead of interest rate models * update test suite * use BorrowedCoins store key * update public functions and alias * unit tests, keeper test scaffolding * demo panic * address revisions * add 'normal no jump' test case * spy = 1 + borrow rate * update comment * APYToSPY unit test * per user borrow index list * interest keeper test * test: interest applied on successive borrows * varied snapshot times * test: multiple, varied snapshots * address revisions * add pending interest before validating new borrow * update makefile * address revisions * fix test
53 lines
1.5 KiB
Go
53 lines
1.5 KiB
Go
package keeper
|
|
|
|
import (
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
"github.com/kava-labs/kava/x/harvest/types"
|
|
)
|
|
|
|
// GetParams returns the params from the store
|
|
func (k Keeper) GetParams(ctx sdk.Context) types.Params {
|
|
var p types.Params
|
|
k.paramSubspace.GetParamSet(ctx, &p)
|
|
return p
|
|
}
|
|
|
|
// SetParams sets params on the store
|
|
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
|
|
k.paramSubspace.SetParamSet(ctx, ¶ms)
|
|
}
|
|
|
|
// GetLPSchedule gets the LP's schedule
|
|
func (k Keeper) GetLPSchedule(ctx sdk.Context, denom string) (types.DistributionSchedule, bool) {
|
|
params := k.GetParams(ctx)
|
|
for _, lps := range params.LiquidityProviderSchedules {
|
|
if lps.DepositDenom == denom {
|
|
return lps, true
|
|
}
|
|
}
|
|
return types.DistributionSchedule{}, false
|
|
}
|
|
|
|
// GetDelegatorSchedule gets the Delgator's schedule
|
|
func (k Keeper) GetDelegatorSchedule(ctx sdk.Context, denom string) (types.DelegatorDistributionSchedule, bool) {
|
|
params := k.GetParams(ctx)
|
|
for _, dds := range params.DelegatorDistributionSchedules {
|
|
if dds.DistributionSchedule.DepositDenom == denom {
|
|
return dds, true
|
|
}
|
|
}
|
|
return types.DelegatorDistributionSchedule{}, false
|
|
}
|
|
|
|
// GetMoneyMarketParam returns the corresponding Money Market param for a specific denom
|
|
func (k Keeper) GetMoneyMarketParam(ctx sdk.Context, denom string) (types.MoneyMarket, bool) {
|
|
params := k.GetParams(ctx)
|
|
for _, mm := range params.MoneyMarkets {
|
|
if mm.Denom == denom {
|
|
return mm, true
|
|
}
|
|
}
|
|
return types.MoneyMarket{}, false
|
|
}
|