The debt in EligibilityDataProvider::requiredUsdValue() needs to be converted into USD; otherwise, it is not a correct value comparison. #156
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
M-23
primary issue
Highest quality submission among a set of duplicates
🤖_19_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
sufficient quality report
This report is of sufficient quality
Lines of code
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
Vulnerability details
Impact
It does not align with the documentation, and the eligibility criteria for rewards are lower than what is specified by the protocol.
Proof of Concept
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.
Tools Used
Manual Review
Recommended Mitigation Steps
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:
https://github.com/radiant-capital/v2/blob/cd618877151896415705468f1b2a43c4b75b3c5b/contracts/radiant/eligibility/EligibilityDataProvider.sol#L186
Assessed type
Error
The text was updated successfully, but these errors were encountered: