TempleGold

TempleDAO
Foundry
25,000 USDC
View results
Submission Details
Severity: medium
Invalid

wrong arithmetic in calculating `center` in `TempleGoldStaking.sol`

Summary

while calculating prior votes using the function getPriorVotes() the arithmetic used to calculate the center is

uint256 center = upper - (upper - lower) / 2;

this is wrong so lets assume there are couple of checkpoints
lets say 10 checkPoints

. so the formula calculates center by
10 - (10 - 0) / 2 = 0.
. this is wrong cause the center should be 5.

Vulnerability Details

The votes that will always be returned will be at checkpoint[0]

Impact

misinformation of total votes

Tools Used

manual review

Recommendations

change the arithmetic form this

- uint256 center = upper - (upper - lower) / 2;
+ uint256 center = (upper + lower) / 2;
Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.