The calculation of the Ditto rewards earned by shorters does not take into account that the changes in the Ditto shorter rate will impact retroactively, inflating or deflating the new Ditto rewards of the users.
YieldFacet.sol:distributeYield()
calculates and credits ZETH and Ditto rewards earned from short records by msg.sender
.
The distribution of the rewards is performed in the _claimYield()
function:
Focusing on the Ditto rewards, we can see that the function receives the number of yield shares earned by the user (dittoYieldShares
) and in line 138 calculates the Ditto reward by multiplying this amount by the total amount of rewards of the protocol (dittoRewardShortersTotal
) and dividing it by the total amount of yield shares of the protocol (dittoYieldSharesTotal
).
If we take a look in line 135 at how the dittoRewardShortersTotal
is calculated, we can see that it is the product of the Ditto shorter rate and total time elapsed since the protocol deployment.
This last calculation is wrong, as it is assumed that the Ditto shorter rate is constant, but this parameter can be changed by the admin or the DAO. This means that the changes in the Ditto shorter rate will impact retroactively, inflating or deflating the new Ditto rewards of the users. Also, users that have yielded the same number of shares during the same period, will receive different rewards depending on whether they claim their rewards before or after the Ditto shorter rate change.
Add the following code snippet into test/Yield.t.sol
and run forge test --mt testYieldRateChange
.
Changes in the Ditto shorter rate will impact retroactively, inflating or deflating the new Ditto rewards of the users. Users might not be incentivized to claim their rewards, as they might receive more rewards if they wait for the Ditto shorter rate to change.
Manual review.
Create two new state variables that keep track of the timestamp of the last Ditto shorter rate update and the total Ditto rewards accrued at that time. Then the calculation of dittoRewardShortersTotal
would be:
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.