Beatland Festival

First Flight #44
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Impact: low
Likelihood: high
Invalid

Use of magic numbers for VIP and BACKSTAGE pass bonuses not recommended

Use of magic numbers for VIP and BACKSTAGE pass bonuses reduces readability and maintainability and hence not recommended

Description

  • The contract uses hardcoded numeric literals such as 5e18 and 15e18 to represent the bonus values for VIP and BACKSTAGE passes, respectively.

  • Makes it harder to maintain or adjust parameters without digging into contract logic

@> uint256 bonus = (collectionId == VIP_PASS) ? 5e18 : (collectionId == BACKSTAGE_PASS) ? 15e18 : 0;

Risk

Likelihood:

  • High: It's there right in the contract

Impact:

  • Low: Reduces clarity for developers and auditors, as the meaning behind the values isn't immediately obvious.

  • Makes it harder to maintain or adjust parameters.

Recommended Mitigation

Define appropriately named constant variables for all bonus-related values:

+ uint256 public constant VIP_BONUS = 5e18;
+ uint256 public constant BACKSTAGE_BONUS = 15e18;
- uint256 bonus = (collectionId == VIP_PASS) ? 5e18 : (collectionId == BACKSTAGE_PASS) ? 15e18 : 0;
+ uint256 bonus = (collectionId == VIP_PASS) ? VIP_BONUS : (collectionId == BACKSTAGE_PASS) ? BACKSTAGE_BONUS : 0;
Updates

Lead Judging Commences

inallhonesty Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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