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

`++i/i++` should be `unchecked{++i}/unchecked{i++}` when it is not possible for them to overflow, as is the case when used in for- and while-loops

Summary

Use unchecked where applicable

Vulnerability Details

The unchecked is a solidity 0.8 feature. This can save 30-40 gas per loop

233 for (uint256 i = 0; i < borrows.length; i++) {
293 for (uint256 i = 0; i < loanIds.length; i++) {
359 for (uint256 i = 0; i < loanIds.length; i++) {
438 for (uint256 i = 0; i < loanIds.length; i++) {
549 for (uint256 i = 0; i < loanIds.length; i++) {
592 for (uint256 i = 0; i < refinances.length; i++) {

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol

Impact

Gas savings

Tools Used

Manual review

Recommendations

Use unchecked where applicable

Support

FAQs

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