# Incorrect protocol fee implementation results in outstandingValues to be mis-accounted in Pool.sol

LiquidationDistributor hardcodes protocol fee to 0 in loanLiquidation, inflating netApr and corrupting Pool's outstandingValues.sumApr accounting.

- Payout: Audit contest
- Severity: high
- Program: Gondi
- Found by: oakcobalt
- Disclosed: 2024-07-25
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-04-gondi-findings/issues/33
- Library page: https://bugbountylibrary.com/r/c4%3A2024-04-gondi%3AH-11
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** Pool.sol / LiquidationDistributor.sol loan liquidation accounting
**Root cause:** LiquidationDistributor._handleLoanManagerCall passes 0 instead of the actual protocol fee fraction to LoanManager.loanLiquidation, so netApr is computed without the fee deduction.
**Steps:**
1. Liquidation proceeds flow through AuctionLoanLiquidator into LiquidationDistributor._handleLoanManagerCall
2. Observe `LoanManager(_tranche.lender).loanLiquidation(..., 0, _sent, ...)` hardcodes protocol fee as 0
3. Pool.loanLiquidation computes netApr without subtracting protocol fee, inflating _apr
4. Inflated _apr is subtracted from __outstandingValues.sumApr, understating it
5. Compare with loan creation path (validateOffer) which passes protocolFee.fraction and adds post-fee apr
**How found:** Code review comparing the liquidation path's protocol fee argument against the loan-creation path's protocolFee.fraction usage, spotting the hardcoded 0.
**Exploitation:** No direct theft path described; incorrect sumApr state corrupts interest accounting across all flows consuming outstandingValues, causing mis-accounted interest for lenders/borrowers.
**Insight:** When auditing fee/accounting code, diff the same parameter across all call sites of a shared function (loan creation vs liquidation); a hardcoded 0 or stale value in one path silently skews derived state like sumApr.

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

**Hardcoded 0 protocol fee in loanLiquidation call**

```
function _handleLoanManagerCall(IMultiSourceLoan.Tranche calldata _tranche, uint256 _sent) private {
        if (getLoanManagerRegistry.isLoanManager(_tranche.lender)) {
            LoanManager(_tranche.lender).loanLiquidation(
                _tranche.loanId,
                _tranche.principalAmount,
                _tranche.aprBps,
                _tranche.accruedInterest,
   |>           0,  //@audit this should be the actual protocol fee fraction
                _sent,
                _tranche.startTime
            );
        }
    }
```

