From 5cd94047a4a7821d5a4db7dd99398bc99572997e Mon Sep 17 00:00:00 2001 From: Kevin Davis Date: Fri, 19 Feb 2021 16:33:55 -0700 Subject: [PATCH] fix: set interest accumulation time and exit when borrows are zero (#840) --- x/hard/keeper/interest.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/x/hard/keeper/interest.go b/x/hard/keeper/interest.go index 3abe8023..9fac1a18 100644 --- a/x/hard/keeper/interest.go +++ b/x/hard/keeper/interest.go @@ -81,6 +81,10 @@ func (k Keeper) AccrueInterest(ctx sdk.Context, denom string) error { if foundBorrowedCoinsPrior { borrowedPrior = sdk.NewCoin(denom, borrowedCoinsPrior.AmountOf(denom)) } + if borrowedPrior.IsZero() { + k.SetPreviousAccrualTime(ctx, denom, ctx.BlockTime()) + return nil + } reservesPrior, foundReservesPrior := k.GetTotalReserves(ctx) if !foundReservesPrior {