Skip to content

Commit

Permalink
fix: overflow in claimBribes()
Browse files Browse the repository at this point in the history
Fixes #101.
  • Loading branch information
danielattilasimon committed Dec 11, 2024
1 parent bb863eb commit 484738a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/BribeInitiative.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,16 @@ contract BribeInitiative is IInitiative, IBribeInitiative {

assert(totalAverageTimestamp <= scaledEpochEnd);

uint240 totalVotes = governance.lqtyToVotes(totalLQTY, scaledEpochEnd, totalAverageTimestamp);
if (totalVotes != 0) {
uint120 totalAverageAge = scaledEpochEnd - totalAverageTimestamp;
if (totalLQTY != 0 && totalAverageAge != 0) {
(uint88 lqty, uint120 averageTimestamp) = _decodeLQTYAllocation(lqtyAllocation.value);
require(lqty > 0, "BribeInitiative: lqty-allocation-zero");

assert(averageTimestamp <= scaledEpochEnd);

uint240 votes = governance.lqtyToVotes(lqty, scaledEpochEnd, averageTimestamp);
boldAmount = uint256(bribe.boldAmount) * uint256(votes) / uint256(totalVotes);
bribeTokenAmount = uint256(bribe.bribeTokenAmount) * uint256(votes) / uint256(totalVotes);
uint120 averageAge = scaledEpochEnd - averageTimestamp;
boldAmount = uint256(bribe.boldAmount) * lqty / totalLQTY * averageAge / totalAverageAge;
bribeTokenAmount = uint256(bribe.bribeTokenAmount) * lqty / totalLQTY * averageAge / totalAverageAge;
}

claimedBribeAtEpoch[_user][_epoch] = true;
Expand Down

0 comments on commit 484738a

Please sign in to comment.