The debt in EligibilityDataProvider::requiredUsdValue() needs to be converted into USD; otherwise, it is not a correct value comparison
The reward eligibility check compares a USD value of locked LP tokens against a required value that is calculated by applying a ratio to a raw debt amount without first converting that debt to USD. As a result, the effective threshold is about 4.5% of total debt instead of the documented 5%, so users can qualify for rewards with less locked value than intended.
Submitted by lian886, also found by pkqs90 and nnez
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
function requiredUsdValue(address user) public view returns (uint256 required) {
@>> uint256 totalNormalDebt = vaultRegistry.getUserTotalDebt(user);
@>> required = (totalNormalDebt * requiredDepositRatio) / RATIO_DIVISOR;
return _lockedUsdValue(required);
}
Here, the value of totalNormalDebt should be calculated first, and then the requiredDepositRatio should be applied to that value.
However, in the current implementation:
function isEligibleForRewards(address _user) public view returns (bool) {
uint256 lockedValue = lockedUsdValue(_user);
uint256 requiredValue = (requiredUsdValue(_user) * priceToleranceRatio) / RATIO_DIVISOR;
return requiredValue != 0 && lockedValue >= requiredValue;
}
function lockedUsdValue(address user) public view returns (uint256) {
Balances memory _balances = IMultiFeeDistribution(multiFeeDistribution).getBalances(user);
return _lockedUsdValue(_balances.locked);
}
function _lockedUsdValue(uint256 lockedLP) internal view returns (uint256) {
uint256 lpPrice = priceProvider.getLpTokenPriceUsd();
return (lockedLP * lpPrice) / 10 ** 18;
}
Based on the lockedUsdValue function and the _lockedUsdValue() function, we know that:
lockedValue = _lockedUsdValue(_balances.locked) = (_balances.locked * lpPrice) / 10**18;
uint256 requiredValue = (requiredUsdValue(_user) * priceToleranceRatio) / RATIO_DIVISOR;
This expands to:
requiredValue = _lockedUsdValue((totalNormalDebt * requiredDepositRatio) / RATIO_DIVISOR) * priceToleranceRatio / RATIO_DIVISOR;
Which further breaks down to:
requiredValue = (((totalNormalDebt * requiredDepositRatio) / RATIO_DIVISOR) * lpPrice / 10**18) * (priceToleranceRatio / RATIO_DIVISOR);
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:
lockedLP > totalNormalDebt * (requiredDepositRatio / RATIO_DIVISOR) * (priceToleranceRatio / RATIO_DIVISOR)
Where:
requiredDepositRatio / RATIO_DIVISOR= 5%priceToleranceRatio / RATIO_DIVISOR= 90%
This simplifies to:
lockedLP > totalNormalDebt * 5% * 90% = 4.5% * totalNormalDebt
So, the condition checks if the lockedLP is greater than 4.5% of the totalNormalDebt.
This contradicts the description in the documentation:
“Loopers maintaining a dLP value exceeding 5% of their Total Position Size qualify for LOOP token emissions to offset borrowing costs incurred from leveraging.”
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.
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.
Assessed type
Error
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the required USD value is computed by multiplying a raw debt amount by a ratio before converting the debt to USD, so the comparison mixes units and understates the requirement.
Impact
The eligibility threshold is effectively about 4.5% instead of the documented 5%, so more users may qualify for rewards than intended.
What the attacker needed
None
The fix
The required USD value should be calculated by first converting the total debt to USD and then applying the required deposit ratio.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This is a smart contract that decides who earns rewards. It compares two numbers: the value of tokens a user has locked and a required value based on their debt. The bug is that one of those numbers is not converted into the same units (US dollars) before the comparison, so the test is too lenient and lets people qualify with less locked value than the rules say.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.