The smart contract responsible for updating the zethYieldRate
is susceptible to precision loss, especially when the yield is a small value relative to the collateral. This is due to the use of fixed-point arithmetic with a precision of 1e18
. When the yield is small, the division result can be so minuscule that, even after scaling by 1e18, it effectively becomes 0 when added to the zethYieldRate
.
In the provided code, the zethYieldRate
is updated using the following logic:
If the yield is significantly smaller than zethCollateral
, the result of the division can be a very small fraction. When this fraction is multiplied by 1e18
(since the underlying math library uses this precision), the result can still be less than 1. This means that the addition to zethYieldRate
would effectively be 0, leading to a loss of precision and potentially causing the yield to be underrepresented in the system.
It's worth noting that the updateYield
can be called by anyone which increases the issue's likelihood since anyone can call it after each rebasing to grief the shorters.
Underrepresentation of Yield: Users might not receive the yield they are entitled to, leading to potential financial losses.
The system might not operate at its optimal economic efficiency due to the misrepresentation of yield.
Economic Inefficiencies: The system might not operate at its optimal economic efficiency due to the misrepresentation of yield.
Manual Review
Increase Precision: Consider increasing the precision from 1e18 to a higher value, such as 1e27 or 1e36. This would allow for more granularity in the calculations. However, ensure all other calculations in the contract are updated to match this new precision.
Accumulate Small Values: Instead of immediately updating the zethYieldRate
, accumulate small yield values until they reach a threshold where the precision loss is minimal. Once this threshold is reached, update the zethYieldRate
.
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.