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

[GAS-2] State variables should be cached in stack variables rather than re-reading them from storage

Summary

The instances below point to the second+ access of a state variable within a function. Caching of a state variable replaces each Gwarmaccess (100 gas) with a much cheaper stack read. Other less obvious fixes/optimizations include having local memory caches of state variable structs, or having local caches of state variable contracts/addresses.

Vulnerability Details

Instances (2):

File: src/Lender.sol
656: IERC20(loan.loanToken).transfer(feeReceiver, protocolInterest);
File: src/Staking.sol
92: supplyIndex[recipient] = index;

Impact

Tools Used

Recommendations

Support

FAQs

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