Last Man Standing

First Flight #45
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

Literal Values/ Magic Numbers are being used throughout the Contract

Literal Values/ Magic Numbers are being used throughout the Contract, the contract uses hardcoded literals directly within function Calls, Defining them as a Constant Variable would:

  • Improve readability (e.g., SECONDS_IN_A_DAY instead of 86400)

  • Allow easy future adjustments

  • Slightly reduce gas costs if reused

  • A better practice.

Description

  • The Game.sol Contract uses hardcoded literals which is not a good practice , a good practice would be to declare a Constant Variable one time in the contract and use it throughout the Contract

  • Decrease readability, especially in large contracts.

  • Make the code harder to maintain or refactor.

  • Slightly increase gas usage (if the literal is reused multiple times instead of a constant).

modifier isValidPercentage(uint256 _percentage) {
require(_percentage <= 100, "Game: Percentage must be 0-100."); // <--- in this line a literal Value is being used
_;
}
require(_feeIncreasePercentage <= 100, "Game: Fee increase percentage must be 0-100."); // "line:164", <--- again being used
require(_platformFeePercentage <= 100, "Game: Platform fee percentage must be 0-100.");// <--- and again
currentPlatformFee = (sentAmount * platformFeePercentage) / 100;// "line:196", <--- again Literal Value is being used as 100.
// There are more then these 3 but this would get bigger but u get the point

Risk : Low

Impact: Low/Informational

  • affects the Readability of the code

  • Can get Confusing if Code increases in Size

  • Bad Practice!

Recommended Mitigation

Wherever u see literal 100 being used or in general literals being used u should declare a Constant Variable and use it in that place instead of Literals.

// add this Constant Variabe to the Variables Section to use it throughout the Contract
uint256 public Constant HUNDRED_PERCENT = 100;
// and use it in the Code
currentPlatformFee = (sentAmount * platformFeePercentage) / HUNDRED_PERCENT; // line: 196
claimFee = claimFee + (claimFee * feeIncreasePercentage) / HUNDRED_PERCENT; //215
require(_feeIncreasePercentage <= HUNDRED_PERCENT, "Game: Fee increase percentage must be 0-100.");//164
require(_platformFeePercentage <= HUNDRED_PERCENT, "Game: Platform fee percentage must be 0-100.");//165
// And so on.
Updates

Appeal created

inallhonesty Lead Judge about 2 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.