Closed code423n4 closed 2 years ago
TomFrenchBlockchain
Detailed description of the impact of this finding.
In Cvx3CrvOracle._peek we SLOAD ethId and cvx3CrvId 2-3 times depending on whether we're querying ETH/cvx3Crv or vice versa.
Cvx3CrvOracle._peek
ethId
cvx3CrvId
https://github.com/code-423n4/2022-01-yield/blob/e946f40239b33812e54fafc700eb2298df1a2579/contracts/Cvx3CrvOracle.sol#L115-L141
We can then just cache these into memory once at the beginning of the function to avoid some of these SLOADs.
Load ethId and cvx3CrvId into variables in memory to avoid repeated SLOADs.
Handle
TomFrenchBlockchain
Vulnerability details
Impact
Detailed description of the impact of this finding.
Proof of Concept
In
Cvx3CrvOracle._peek
we SLOADethId
andcvx3CrvId
2-3 times depending on whether we're querying ETH/cvx3Crv or vice versa.https://github.com/code-423n4/2022-01-yield/blob/e946f40239b33812e54fafc700eb2298df1a2579/contracts/Cvx3CrvOracle.sol#L115-L141
We can then just cache these into memory once at the beginning of the function to avoid some of these SLOADs.
Recommended Mitigation Steps
Load
ethId
andcvx3CrvId
into variables in memory to avoid repeated SLOADs.