Skip to content

Commit

Permalink
fix: Return nil if negative time elapsed from last block happens (#1018)
Browse files Browse the repository at this point in the history
* fix: return nil if the current time < privous interest time

* add 1018 to changelog

* add todo to fix when tendermint solves #8773
  • Loading branch information
RafilxTenfen authored Jun 15, 2022
1 parent 5871953 commit ac8cc02
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
- [987](https://github.com/umee-network/umee/pull/987) Streamline x/leverage CLI tests
- [1012](https://github.com/umee-network/umee/pull/1012) Improve negative time elapsed error message

### Bug Fixes

- [1018](https://github.com/umee-network/umee/pull/1018) Return nil if negative time elapsed from the last block happens.

## [v2.0.2](https://github.com/umee-network/umee/releases/tag/v2.0.2) - 2022-05-13

### Features
Expand Down
10 changes: 9 additions & 1 deletion x/leverage/keeper/interest.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,15 @@ func (k Keeper) AccrueAllInterest(ctx sdk.Context) error {

// calculate time elapsed since last interest accrual (measured in years for APR math)
if currentTime < prevInterestTime {
return types.ErrNegativeTimeElapsed.Wrap(fmt.Sprintf("current: %d, prev: %d", currentTime, prevInterestTime))
// @todo fix this when tendermint solves #8773
// https://github.com/tendermint/tendermint/issues/8773
k.Logger(ctx).With("AccrueAllInterest will wait for block time > prevInterestTime").Error(
types.ErrNegativeTimeElapsed.Error(),
"current", currentTime,
"prev", prevInterestTime,
)

return nil
}
yearsElapsed := sdk.NewDec(currentTime - prevInterestTime).QuoInt64(types.SecondsPerYear)

Expand Down

0 comments on commit ac8cc02

Please sign in to comment.