diff --git a/x/leverage/keeper/interest.go b/x/leverage/keeper/interest.go index 4de16d4144..b9712100ff 100644 --- a/x/leverage/keeper/interest.go +++ b/x/leverage/keeper/interest.go @@ -72,10 +72,11 @@ func (k Keeper) AccrueAllInterest(ctx sdk.Context) error { } // calculate time elapsed since last interest accrual (measured in years for APR math) - yearsElapsed := sdk.NewDec(currentTime - prevInterestTime).QuoInt64(types.SecondsPerYear) - if yearsElapsed.IsNegative() { - return sdkerrors.Wrap(types.ErrNegativeTimeElapsed, yearsElapsed.String()+" years") + secondsElapsed := currentTime - prevInterestTime + if secondsElapsed < 0 { + return sdkerrors.Wrap(types.ErrNegativeTimeElapsed, fmt.Sprintf("%d seconds", secondsElapsed)) } + yearsElapsed := sdk.NewDec(secondsElapsed).QuoInt64(types.SecondsPerYear) // fetch required parameters tokens := k.GetAllRegisteredTokens(ctx)