# Entrance fees are distributed wrongly in loans with multiple lenders

Entrance fees in multi-lender loans are pooled and split pro-rata by debt, so later lenders overpay and earlier lenders collect fees they didn't earn.

- Payout: Contest reward
- Severity: medium
- Program: Leverage Contracts
- Credited: 0xDetermination
- Disclosed: 2024-02-22
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-02-leverage-contracts-judging/issues/39
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-02-leverage-contracts%3AM-1
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:solidity technique:source-review vuln:business-logic vuln:precision-loss vuln:reward-distribution

**Target:** LiquidityBorrowingManager.sol fee accounting (harvest/borrow)
**Root cause:** Entrance fees are added to the borrower's aggregate feesOwed and later distributed to each lender proportional to holdTokenDebt/borrowedAmount, rather than credited to the lender who funded that specific loan.
**Steps:**
1. Borrower takes 100-token loan from lender A, pays 10-token entrance fee added to feesOwed.
2. Lender A harvests fees; feesOwed reset to zero.
3. Borrower immediately takes another 100-token loan from lender B, pays 10-token entrance fee.
4. On next harvest, `feesAmt = mulDiv(feesOwed, holdTokenDebt, borrowedAmount)` splits the 10 tokens 5/5 between A and B.
5. Lender A has 15, lender B has 5 despite equal loan sizes; same occurs when entrance fee is raised between loans.
**How found:** Code reading of the harvest fee-distribution formula `mulDiv(feesOwed, holdTokenDebt, borrowedAmount)` and noticing entrance fees are lumped into feesOwed rather than tracked per-loan.
**Exploitation:** A borrower (or colluding lender) can borrow from themselves then from another lender to shift entrance-fee value; profitability limited by platform fees (20% of interest) and low default 0.1% entrance fee.
**Escalation:** Net loss accumulates across every multi-lender loan over time; entrance fee can be configured up to 10%.
**Insight:** When a protocol pools fees into a single accumulator and splits pro-rata by current debt, any fee type that is charged per-event (entrance, fixed) rather than time-accrued will be misallocated across lenders who joined at different times or rates.
