# The debt in EligibilityDataProvider::requiredUsdValue() needs to be converted into USD; otherwise, it is not a correct value comparison

EligibilityDataProvider compares raw debt units against USD-scaled locked LP, letting users qualify for rewards at ~4.5% instead of the required 5% deposit ratio.

- Payout: Audit contest
- Severity: medium
- Program: LoopFi
- Found by: lian886
- Disclosed: 2025-02-17
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-07-loopfi-findings/issues/156
- Library page: https://bugbountylibrary.com/r/c4%3A2024-07-loopfi%3AM-23
- Tags: area:web3 domain:web3 kind:contest platform:code4rena sev:medium tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** EligibilityDataProvider reward eligibility contract
**Root cause:** requiredUsdValue() multiplies totalNormalDebt (token units) by requiredDepositRatio without converting debt to USD, then _lockedUsdValue() applies LP price to that already-ratio'd value, mixing units in the lockedValue >= requiredValue comparison.
**Steps:**
1. Read requiredUsdValue(): `required = (totalNormalDebt * requiredDepositRatio) / RATIO_DIVISOR` then `_lockedUsdValue(required)`.
2. Note lockedUsdValue() = `_balances.locked * lpPrice / 1e18` (USD), while requiredUsdValue applies lpPrice to a debt-derived value.
3. Expand comparison: lockedLP > totalNormalDebt * 5% * 90% = 4.5% of debt.
4. Observe eligibility threshold is 4.5% not the documented 5% of position size.
**How found:** Code-reading of requiredUsdValue vs lockedUsdValue revealed the debt was never converted to USD before applying the deposit ratio, then algebraically expanded the comparison to show the effective 4.5% threshold.
**Insight:** When a ratio is applied to a debt and the result is later passed through a USD price conversion, check whether the debt itself was already USD-denominated; unit mismatches silently shift thresholds.

## Proof of concept (copied exactly from the original report)

**requiredUsdValue applies ratio to raw debt**

```
function requiredUsdValue(address user) public view returns (uint256 required) {
@>>        uint256 totalNormalDebt = vaultRegistry.getUserTotalDebt(user);
@>>        required = (totalNormalDebt * requiredDepositRatio) / RATIO_DIVISOR;
        return _lockedUsdValue(required);
    }
```

