code-423n4 / 2022-01-yield-findings

1 stars 0 forks source link

Extra SLOADs in _peek #80

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

TomFrenchBlockchain

Vulnerability details

Impact

Detailed description of the impact of this finding.

Proof of Concept

In Cvx3CrvOracle._peek we SLOAD ethId and cvx3CrvId 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 and cvx3CrvId into variables in memory to avoid repeated SLOADs.

iamsahu commented 2 years ago

70