The closePot()
function in the Pot contract uses integer division to calculate the manager's cut of the remaining rewards. This method can lead to rounding errors, potentially resulting in the manager receiving less than the intended percentage, especially for small reward amounts.
The vulnerable code is located in the closePot()
function of the Pot contract:
Where managerCutPercent
is defined as:
This calculation uses integer division, which always rounds down to the nearest integer. As a result:
For remainingRewards
< 10, managerCut
will always be 0.
For values not divisible by 10, some fraction of a token will always be lost to rounding.
The impact of this vulnerability includes:
Loss of funds for the manager: For small pot sizes, the manager might receive no cut at all, despite being entitled to 10%.
Inconsistent reward distribution: The actual percentage the manager receives will vary depending on the total reward amount, leading to inconsistencies across different contests.
Manual code review.
AI for report text and formatting.
To address this vulnerability, consider the following recommendations:
Use percentage multiplication instead of division:
This allows for more precise percentages and minimizes rounding errors.
Implement a minimum cut for the manager to ensure they always receive something:
For high-precision tokens, consider using fixed-point arithmetic:
Where managerCutPercent
would be represented as a percentage multiplied by 1e18 (e.g., 10% would be 1e17).
Add checks to ensure the calculated cut is within expected bounds:
By implementing these recommendations, the contract will provide a more accurate and consistent calculation of the manager's cut, reducing the potential for fund loss and manipulation.
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.