20,000 USDC
View results
Submission Details
Severity: gas

## [G-14] Can make the variable outside the loop to save gas

Summary

[G-14] Can make the variable outside the loop to save gas

Consider making the stack variables before the loop which gonna save gas

file: /src/Lender.sol
234 bytes32 poolId = borrows[i].poolId;
235 uint256 debt = borrows[i].debt;
236 uint256 collateral = borrows[i].collateral;
237 // get the pool info
238 Pool memory pool = pools[poolId];

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

file: /src/Lender.sol
294 uint256 loanId = loanIds[i];
// get the loan info
296 Loan memory loan = loans[loanId];

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

file: /src/Lender.sol
260 uint256 loanId = loanIds[i];
261 bytes32 poolId = poolIds[i];
// get the loan info
263 Loan memory loan = loans[loanId];

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

Support

FAQs

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