Platform: Code4rena
Start Date: 28/01/2022
Pot Size: $30,000 USDC
Total HM: 4
Participants: 22
Period: 3 days
Judge: GalloDaSballo
Total Solo HM: 2
Id: 80
League: ETH
Rank: 15/22
Findings: 3
Award: $82.01
🌟 Selected for report: 1
🚀 Solo Findings: 0
0x1f8b
Unsafe oracle call.
The contract Cvx3CrvOracle
doesn't check that the data is fress, it call the method latestRoundData
, this method allow you to run some extra validations, but these validations were not made.
According to the chain.link documentation:
You can check answeredInRound against the current roundId. If answeredInRound is less than roundId, the answer is being carried over. If answeredInRound is equal to roundId, then the answer is fresh.
So it's required to check something like this:
(roundId, daiPrice, , updateTime, answeredInRound ) = DAI.latestRoundData(); require(daiPrice > 0, "Chainlink price <= 0"); require(updateTime != 0, "Incomplete round"); require(answeredInRound >= roundId, "Stale price");
Reference:
Manual review.
Apply the mentioned changes.
#0 - devtooligan
2022-02-01T02:16:05Z
dup of #2
#1 - GalloDaSballo
2022-02-14T23:42:16Z
Duplicate of #136
0x1f8b
Gas saving.
Without changing too much it's possible to save gas, in the for loops the i
variable is increased using i++, it will use less opcodes if use ++i.
Affected places:
Manual review.
Change i++ to ++i
#0 - alcueca
2022-02-02T16:11:04Z
Duplicate of #14
5.6804 USDC - $5.68
0x1f8b
Gas saving.
It's possible to avoid storage access a save gas using immutable
keyword for the following variables:
ConvexStakingWrapper:
ConvexYieldWrapper:
Gas saving
Use immutable.
#0 - devtooligan
2022-02-01T02:25:15Z
Immutable variables cannot be read during contract creation time. Making the suggested variables immutable would lead to https://github.com/code-423n4/2022-01-yield/blob/e946f40239b33812e54fafc700eb2298df1a2579/contracts/ConvexStakingWrapper.sol#L77-L78 to fail.
#1 - GalloDaSballo
2022-02-11T02:44:45Z
While you can't read immutable variables at creation time, you can use the input from the constructor _curveToken
instead of the "storage / immutable" curveToken
Inlining the approvals and using the constructor parameters would solve and save the gas.
I don't mind a nofix from the developer, (although believe there's gas to be saved) but I think the finding is valid
#2 - devtooligan
2022-02-11T02:57:17Z
@GalloDaSballo Good point. Let me talk to the team