15,000 USDC
View results
Submission Details
Severity: gas

Cache state variables instead of rereading

Summary

Vulnerability Details

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.

More detail see this.

There are 3 instances of this issue:

Impact

Tools Used

Recommendations

Cache storage-based state variables in local memory-based variables appropriately to convert SLOADs to MLOADs and reduce gas consumption from 100 units to 3 units. than once for a function

Support

FAQs

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