Skip to content

Commit

Permalink
fix: divide by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
r3v4s committed Dec 30, 2024
1 parent 8809793 commit 94a34f3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions staker/reward_calculation_pool_tier.gno
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ func (self *PoolTier) TierDenominatorUpdates(tier uint64, startHeight, endHeight
return false
})

if currentRatio == 0 {
lastHeight = height
return false
}
currentCount = value.(uint64)
heights = append(heights, height)
updates = append(updates, currentCount*(TierRatioLCM/currentRatio))
Expand Down Expand Up @@ -333,6 +337,7 @@ func (self *PoolTier) cacheTierReward(tier uint64, startHeight, endHeight uint64
}

heights, updates = self.TierDenominatorUpdates(tier, currentEmissionUpdateHeight, endHeight)

for j := 0; j < len(heights); j++ {
if updates[j] == 0 {
rewardCache.Set(heights[j], uint64(0))
Expand All @@ -342,6 +347,7 @@ func (self *PoolTier) cacheTierReward(tier uint64, startHeight, endHeight uint64
reward := (currentEmissionUpdate * TierRatioLCM) / denominator
rewardCache.Set(heights[j], reward)
}

}

func (self *PoolTier) cacheReward(endHeight uint64, emissionUpdateHeights []uint64, emissionUpdates []uint64) {
Expand Down

0 comments on commit 94a34f3

Please sign in to comment.