Submitted by lian886, also found by pkqs90 and nnez
https://github.com/code-423n4/2024-07-loopfi/blob/57871f64bdea450c1f04c9a53dc1a78223719164/src/reward/EligibilityDataProvider.sol#L187
https://github.com/code-423n4/2024-07-loopfi/blob/57871f64bdea450c1f04c9a53dc1a78223719164/src/reward/EligibilityDataProvider.sol#L197
https://github.com/code-423n4/2024-07-loopfi/blob/57871f64bdea450c1f04c9a53dc1a78223719164/src/reward/EligibilityDataProvider.sol#L274
https://github.com/code-423n4/2024-07-loopfi/blob/57871f64bdea450c1f04c9a53dc1a78223719164/src/reward/EligibilityDataProvider.sol#L177
It does not align with the documentation and the eligibility criteria for rewards are lower than what is specified by the protocol.
Here, the value of totalNormalDebt should be calculated first, and then the requiredDepositRatio should be applied to that value.
However, in the current implementation:
Based on the lockedUsdValue function and the _lockedUsdValue() function, we know that:
This expands to:
Which further breaks down to:
This shows the step-by-step calculation of the lockedValue and requiredValue based on the total debt, deposit ratio, and price tolerances.
Thus, the comparison lockedValue >= requiredValue becomes:
Where:
This simplifies to:
So, the condition checks if the lockedLP is greater than 4.5% of the totalNormalDebt.
This contradicts the description in the documentation:
In reality, because the value of one lockedLP token is lower than the value of the debt (in ETH), the number of lockedLP tokens falls far short of the actual requirement.
In the requiredUsdValue function, the debt value is first calculated and then multiplied by the relevant ratio. In fact, Radiant Capital implements this exact approach in their code, as shown here.
Error
amarcu (LoopFi) confirmed
