MyCut

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

informational findings in Pot.sol

Summary

Some informational findings in Pot.sol:

  1. Error: Pot__InsufficientFunds();
    This error is declared but not used anywhere in the contract.

  2. Variables should be immutable: i_players and i_rewards should be marked as immutable since they do not change after initialization. They are already prefixed with i_, which suggests immutability, but they are not actually declared as such.

    address[] private i_players;
    uint256[] private i_rewards;
  3. Unused commented line in the constructor: There is a commented-out line in the constructor that is not being used and should be removed for clarity.

    // i_token.transfer(address(this), i_totalRewards);
  4. Magic number in closePot: The value 90 days is a magic number and should be replaced with a named constant for better readability and maintainability.

  5. Incorrect formula for managerCutPercent: The current formula for calculating the manager's cut only works correctly when managerCutPercent is 10%. It will not produce correct results for other values.

Recommendations

  1. Delete the unused error declaration:

    Remove the Pot__InsufficientFunds(); line if it's not being used in the contract.

  2. Make variables immutable:

    Since i_players and i_rewards do not change after they are initialized, mark them as immutable:

    - address[] private i_players;
    - uint256[] private i_rewards;
    + address[] private immutable i_players;
    + uint256[] private immutable i_rewards;
  3. Remove the unused commented line:

    Delete the line // i_token.transfer(address(this), i_totalRewards); from the constructor to keep the code clean and readable.

  4. Use a named constant instead of a magic number:

    Replace 90 days with a named constant to make the code more understandable:

    uint32 private constant DEADLINE = 90 days;
  5. Correct the formula for the manager's cut:

    Update the formula to correctly calculate the manager's cut for any percentage, not just 10%:

    - uint256 managerCut = remainingRewards / managerCutPercent;
    + uint256 managerCut = (remainingRewards * managerCutPercent) / 100;

    This formula ensures that the manager's cut is correctly calculated as a percentage of the remaining unclaimed rewards.

Updates

Lead Judging Commences

equious Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Appeal created

fels21 Submitter
about 1 year ago
equious Lead Judge
about 1 year ago
equious Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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