mirror of
https://github.com/0glabs/0g-chain.git
synced 2025-01-15 01:35:21 +00:00
e1ad9569a7
* add interest rate models to params * move interest rate models to money market param * add interest rate models to store * update store interest rate models from params * refactor money market init function, update tests * use cmp package for optimized comparison * implement equal function, remove gocmp dep * delete unseen interest rate model param from store
32 lines
845 B
Go
32 lines
845 B
Go
package keeper
|
|
|
|
import (
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/kava-labs/kava/x/harvest/types"
|
|
)
|
|
|
|
// ApplyInterestRateUpdates translates the current interest rate models from the params to the store
|
|
func (k Keeper) ApplyInterestRateUpdates(ctx sdk.Context) {
|
|
denomSet := map[string]bool{}
|
|
|
|
params := k.GetParams(ctx)
|
|
for _, mm := range params.MoneyMarkets {
|
|
model, found := k.GetInterestRateModel(ctx, mm.Denom)
|
|
if !found {
|
|
k.SetInterestRateModel(ctx, mm.Denom, mm.InterestRateModel)
|
|
continue
|
|
}
|
|
if !model.Equal(mm.InterestRateModel) {
|
|
k.SetInterestRateModel(ctx, mm.Denom, mm.InterestRateModel)
|
|
}
|
|
denomSet[mm.Denom] = true
|
|
}
|
|
|
|
k.IterateInterestRateModels(ctx, func(denom string, i types.InterestRateModel) bool {
|
|
if !denomSet[denom] {
|
|
k.DeleteInterestRateModel(ctx, denom)
|
|
}
|
|
return false
|
|
})
|
|
}
|