According to the Yearn v3 docs, the _harvestAndReport
function:
Called during every report. This should harvest and sell any rewards, reinvest any proceeds, perform any position maintenance and return a full accounting of a trusted amount denominated in the underlying asset the strategy holds.
However, this is not the case. The claimAndSwap
function which claims the available WETH
and reinvests the profit is a different function. Not having both the functions executed in the same call can create issues with the totalAssets
of the vault as they are not accurate at all times.
This is the same _harvestAndReport
function throughout the 3 strategies:
This function is called every time the Keepers
call the report()
function lying in the TokenizedStrategy.sol
. This function is repsonsible to correctly update the totalAssets
of the vault so the shares
get minted/burnt correctly. As we can see the claimable
amount is not accounted for. This means that this function should always get called in the same call exactly after claimAndSwap
.
As we can see, calling claimAndSwap
doesn't update the totalAssets
of the vault.
Let's consider a scenario:
Vault gets deployed, bob deposits 2 alETH
, receives 2e18 shares
and the vault has unexchanged = 2 alETH
and claimable = 0 WETH
.
Time passes, now vault has unexchanged = 1 alETH
and claimable = 1 WETH
and report()
gets called, so _harvestAndReport
returns 1e18
. Alice sees this transaction and it's always profitable for her to backrun and deposit her 1 alETH
after the report()
and get more shares than intended. While with 1 alETH
should get 1/3 of the total vault shares, she will actually receive 1/2 of the total vault shares and she does that and gets 2e18 shares
.
Having the claiming of the profits and the accounting of the totalAssets
of the vault on different functions is very dangerous. The totalAssets
can be wrongly reported and all the vault's convertToShares
and convertToAssets
functions will return inaccurate results.
Manual review
As per the yearn v3 docs, include the claiming and reinvesting of the tokens in the _harvestAndReport
function.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.