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

Accessing storage variables already instantiated in memory

Summary

Accessing storage instead of memory on lines 262 and 263 in Lender.sol incurs extra gas costs

Vulnerability Details

pools[poolId] on lines 262 and 263 are accessing storage when they can instead access memory; the memory variable pool has been set equal to pools[poolId] in the function.

Impact

Replacing 2 warm SLOADs (100 gas) with 2 MLOADs (3 gas) saves 194 gas here. Additionally, the gas cost of reading from an array is avoided.

Tools Used

Recommendations

Change pools[poolId] to pool on lines 262 and 263

Support

FAQs

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