Skip to content

Commit

Permalink
fix: calculate reward time elapsed correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
karzak committed Feb 24, 2021
1 parent fe43c2b commit a380950
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions x/incentive/keeper/rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,12 +660,23 @@ func (k Keeper) ZeroHardLiquidityProviderClaim(ctx sdk.Context, claim types.Hard
// CalculateTimeElapsed calculates the number of reward-eligible seconds that have passed since the previous
// time rewards were accrued, taking into account the end time of the reward period
func CalculateTimeElapsed(start, end, blockTime time.Time, previousAccrualTime time.Time) sdk.Int {
if (end.Before(blockTime) &&
(end.Before(previousAccrualTime) || end.Equal(previousAccrualTime))) ||
(start.After(previousAccrualTime)) ||
(start.Equal(blockTime)) {
return sdk.ZeroInt()
flagTime := time.Date(2021, 2, 25, 6, 30, 0, 0, time.UTC)
if blockTime.Before(flagTime) {
if (end.Before(blockTime) &&
(end.Before(previousAccrualTime) || end.Equal(previousAccrualTime))) ||
(start.After(previousAccrualTime)) ||
(start.Equal(blockTime)) {
return sdk.ZeroInt()
}
} else {
if (end.Before(blockTime) &&
(end.Before(previousAccrualTime) || end.Equal(previousAccrualTime))) ||
(start.After(blockTime)) ||
(start.Equal(blockTime)) {
return sdk.ZeroInt()
}
}

if start.After(previousAccrualTime) && start.Before(blockTime) {
previousAccrualTime = start
}
Expand Down

0 comments on commit a380950

Please sign in to comment.