diff --git a/x/hard/keeper/interest.go b/x/hard/keeper/interest.go index 3a192120..bc28a8c8 100644 --- a/x/hard/keeper/interest.go +++ b/x/hard/keeper/interest.go @@ -120,6 +120,12 @@ func (k Keeper) AccrueInterest(ctx sdk.Context, denom string) error { // Calculate borrow interest factor and update borrowInterestFactor := CalculateBorrowInterestFactor(borrowRateSpy, sdk.NewInt(timeElapsed)) interestBorrowAccumulated := (borrowInterestFactor.Mul(sdk.NewDecFromInt(borrowedPrior.Amount)).TruncateInt()).Sub(borrowedPrior.Amount) + + if interestBorrowAccumulated.IsZero() && borrowRateApy.IsPositive() { + // don't accumulate if borrow interest is rounding to zero + return nil + } + totalBorrowInterestAccumulated := sdk.NewCoins(sdk.NewCoin(denom, interestBorrowAccumulated)) reservesNew := interestBorrowAccumulated.ToDec().Mul(mm.ReserveFactor).TruncateInt() borrowInterestFactorNew := borrowInterestFactorPrior.Mul(borrowInterestFactor)