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

## [G-12] State variables should be cached in stack variables rather than re-reading them from storage

Summary

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

The instances below point to the second+ access of a state variable within a function.
Caching of a state variable replace 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.
Most of the times this if statement will be true and we will save 100 gas at a small possibility of 3 gas loss ,

file: /src/Fees.sol
/// @audit ' WETH ' on lines 27 , 43 ,43 inside in a single function
33 tokenOut: WETH,

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Fees.sol#L33

Support

FAQs

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