MyCut

First Flight #23
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: medium
Invalid

suggest using basis points to represent managerCutPercent

Summary

suggest using basis points to represent managerCutPercent

Vulnerability Details

In Solidity, using basis points (bps) to represent percentages is a common practice to avoid precision issues associated with floating-point arithmetic. Solidity does not support floating-point operations, so all calculations must be done using integers. Basis points provide a way to represent fractional percentages using integers.

Using Basis Points

  1. Higher Precision: Using basis points allows for representing smaller percentages (e.g., 0.01% is represented as 1 basis point), providing higher precision.

  2. Avoids Rounding Errors: Since basis points use integer representation, it avoids rounding errors associated with floating-point arithmetic.

In Pot.sol,themanagerCutPercent doesn’t Using Basis Points, It makes if the remainingRewards < 10, the managerCut will be 0, so in this situation the contestManager will not get the any Cut.

uint256 private constant managerCutPercent = 10;
uint256 managerCut = remainingRewards / managerCutPercent;

Impact

Tools Used

manual

Recommendations

In Pot.sol, change the managerCutPercent represent.

-- uint256 private constant managerCutPercent = 10;
-- uint256 managerCut = remainingRewards / managerCutPercent;
++ uint256 private constant managerCutPercent = 1000;
++ uint256 managerCut = (remainingRewards * managerCutPercent) / 10000;
Updates

Lead Judging Commences

equious Lead Judge 12 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Erroneous ManagerCut calculation

Appeal created

equious Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

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