fix: set interest accumulation time and exit when borrows are zero (#840)

This commit is contained in:
Kevin Davis 2021-02-19 16:33:55 -07:00 committed by GitHub
parent 1ab2e9965f
commit 5cd94047a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,6 +81,10 @@ func (k Keeper) AccrueInterest(ctx sdk.Context, denom string) error {
if foundBorrowedCoinsPrior { if foundBorrowedCoinsPrior {
borrowedPrior = sdk.NewCoin(denom, borrowedCoinsPrior.AmountOf(denom)) borrowedPrior = sdk.NewCoin(denom, borrowedCoinsPrior.AmountOf(denom))
} }
if borrowedPrior.IsZero() {
k.SetPreviousAccrualTime(ctx, denom, ctx.BlockTime())
return nil
}
reservesPrior, foundReservesPrior := k.GetTotalReserves(ctx) reservesPrior, foundReservesPrior := k.GetTotalReserves(ctx)
if !foundReservesPrior { if !foundReservesPrior {