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

Constants should be defined rather than using magic numbers

Summary

Constants should be defined rather than using magic numbers

Vulnerability Details

Even assembly
can benefit from using readable constants instead of hex/numeric literals

File: src/Beedle.sol
12: _mint(msg.sender, 1_000_000_000 * 1e18);
12: _mint(msg.sender, 1_000_000_000 * 1e18);

Link to code - https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Beedle.sol

File: src/Lender.sol
85: if (_fee > 5000) revert FeeTooHigh();
93: if (_fee > 500) revert FeeTooHigh();
246: uint256 loanRatio = (debt * 10 ** 18) / collateral;
246: uint256 loanRatio = (debt * 10 ** 18) / collateral;
265: uint256 fees = (debt * borrowerFee) / 10000;
384: uint256 loanRatio = (totalDebt * 10 ** 18) / loan.collateral;
384: uint256 loanRatio = (totalDebt * 10 ** 18) / loan.collateral;
561: uint256 govFee = (borrowerFee * loan.collateral) / 10000;
618: uint256 loanRatio = (debt * 10 ** 18) / collateral;
618: uint256 loanRatio = (debt * 10 ** 18) / collateral;
650: uint256 fee = (borrowerFee * (debt - debtToPay)) / 10000;
724: interest = (l.interestRate * l.debt * timeElapsed) / 10000 / 365 days;
724: interest = (l.interestRate * l.debt * timeElapsed) / 10000 / 365 days;
725: fees = (lenderFee * interest) / 10000;

Link to code - https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol

File: src/Staking.sol
68: uint256 _ratio = _diff * 1e18 / totalSupply;
88: uint256 _share = _supplied * _delta / 1e18;

Link to code - https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Staking.sol

Tools Used

Code Review

Recommendations

Constants should be defined

Auditor

NeoCrao

Support

FAQs

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