The voting power calculation in the contract is flawed due to improper handling of the bias value, which is cast to uint128 before being used. This can lead to precision loss or incorrect voting power calculations if the bias value exceeds the range of uint128.
The issue arises in the lock function, where the bias value is cast to uint128 before being used to calculate voting power:
Deploy the veRAACToken contract with the RAAC token address.
User A locks 10 million RAAC tokens for 4 years (MAX_LOCK_DURATION).
Observe the bias value calculated for User A.
Verify that the bias value exceeds the range of uint128.
Observe the voting power calculated for User A after casting bias to uint128.
Verify that the voting power is incorrect due to precision loss.
The voting power calculation should use the full precision of the bias value without truncation.
Actual Behavior
The bias value is truncated when cast to uint128, leading to incorrect voting power.
The bias value exceeds the range of uint128 and is truncated when cast to uint128.
The calculated voting power for User A is incorrect due to precision loss.
Users may receive incorrect voting power, undermining the fairness of the governance system.
Large bias values could be truncated, leading to significant discrepancies in voting power.
Incorrect voting power calculations could distort voting outcomes, reducing trust in the governance mechanism.
Manual Code Review
Use int256 or uint256 for the bias value instead of int128 to avoid precision loss.
Add checks to ensure that the bias value does not exceed the range of uint128 before casting.
Emit an event when voting power is calculated to improve transparency and facilitate debugging
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.