Skip to content

Commit

Permalink
chore: clarify negative interest time error message (#711) (#713)
Browse files Browse the repository at this point in the history
(cherry picked from commit 7ccbcab)

Co-authored-by: Adam Moser <63419657+toteki@users.noreply.github.com>
Co-authored-by: Adam Wozniak <29418299+adamewozniak@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 27, 2022
1 parent 3fbc77a commit 0cdc3ba
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions x/leverage/keeper/interest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0cdc3ba

Please sign in to comment.