Gas in FlashGovernanceArbiter.assertGovernanceApproved()
: flashGovernanceConfig.asset
and flashGovernanceConfig.amount
should get cached
#336
Labels
bug
Something isn't working
G (Gas Optimization)
sponsor acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Handle
Dravee
Vulnerability details
Impact
SLOADs are expensive (~100 gas) compared to MLOADs/MSTOREs (~3 gas). Minimizing them can save gas.
Proof of Concept
The code is as such (see @Audit tags):
It's possible to save 2 SLOAD (~200 gas) by caching
flashGovernanceConfig.asset
in aaddress
variable, andflashGovernanceConfig.amount
in auint256
memory variables and use them instead of reading them repeatedly from storage.Tools Used
VS Code
Recommended Mitigation Steps
Cache the storage values in memory variables and use them instead of repeatedly reading them from storage.
The text was updated successfully, but these errors were encountered: