15,000 USDC
View results
Submission Details
Severity: gas
Valid

Use constants instead of `type(uint256).max`

Summary

At the places where type(uint256).max is used it can be replaced with constant variable with the same value as this from the expression, it will save gas because constant variables are stored in the contract byte code.

Each of the recommendations below saves 24 gas (Tested in remix)

Instances

https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/main/src/DSCEngine.sol#L329

Tools Used

Manual

Recommendations

uint private constant MAX_UINT256_NUMBER = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
uint private constant MAX_UINT256_HEX = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
uint private constant MAX_UINT256_EXPONENTIATION = 2**256 - 1;

Support

FAQs

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