gas

Constants should be be used for hardcoded values

Reward

Total

9.87 USDC

0.95 USDC
0.95 USDC
0.95 USDC
0.95 USDC
Selected
1.33 USDC
0.95 USDC
0.95 USDC
0.95 USDC
0.95 USDC
0.95 USDC
Selected Submission

Constants should be be used for hardcoded values

Severity

Gas Optimization / Informational

Relevant GitHub Links

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

Description

Constants should be be used for hardcoded values, especially if the constants already exist, as it is in this case in DSCEngine.

    uint256 private constant PRECISION = 1e18;

In DSCEngine::_calculateHealthFactor the 1e18 can be safely (and contextually) replaced with the already declared PRECISION constant.

        return (collateralAdjustedForThreshold * 1e18) / totalDscMinted;

Recommend Mitigation

Use the PRECISION constant instead of 1e18.