# Fee Bypass in `ValueFacet.removeValueSingle`

In Burve's ValueFacet.removeValueSingle, realTax is computed from uninitialized removedBalance (zero), so single-token removals pay zero protocol fee.

- Payout: Audit contest
- Severity: high
- Program: Burve
- Found by: 0L5S6W
- Disclosed: 2025-04-17
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2025-04-burve-judging/issues/311
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-04-burve%3AH-6
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:solidity technique:source-review vuln:accounting-error vuln:fee-bypass

**Target:** Solidity smart contract (ValueFacet)
**Root cause:** realTax is computed with removedBalance, which is still zero at that point, instead of realRemoved, so the prorated fee always evaluates to zero.
**Steps:**
1. Call `ValueFacet.removeValueSingle(recipient, closureId, value, bgtValue, token, minReceive)`
2. Observe `realTax = FullMath.mulDiv(removedBalance, nominalTax, removedNominal)` where removedBalance is unassigned (0)
3. realTax == 0, so `c.addEarnings(vid, 0)` and full realRemoved is transferred to recipient
4. Repeat for every single-token removal to avoid all fees
**How found:** Code reading of removeValueSingle: noticed removedBalance is used in the realTax computation before being assigned, making the numerator zero.
**Exploitation:** Any user performing a single-token removal via removeValueSingle pays no protocol fee; the fee is silently zeroed and the full removed amount is transferred to the recipient.
**Insight:** In Solidity, named return variables default to zero; audit any use of a return variable before its assignment, especially in fee/tax proration math where a zero numerator silently disables the fee.

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

**removeValueSingle function with zero removedBalance fee bug**

```
function removeValueSingle(
    address recipient,
    uint16 _closureId,
    uint128 value,
    uint128 bgtValue,
    address token,
    uint128 minReceive
) external nonReentrant returns (uint256 removedBalance) {
    …
    (uint256 removedNominal, uint256 nominalTax) = c.removeValueSingle(
        value,
        bgtValue,
        vid
    );
    uint256 realRemoved = AdjustorLib.toReal(token, removedNominal, false);
    Store.vertex(vid).withdraw(cid, realRemoved, false);
    // BUG: removedBalance is still zero here
    uint256 realTax = FullMath.mulDiv(
        removedBalance,        // ← should be realRemoved
        nominalTax,
        removedNominal
    );
    c.addEarnings(vid, realTax);
    removedBalance = realRemoved - realTax;
    require(removedBalance >= minReceive, PastSlippageBounds());
    TransferHelper.safeTransfer(token, recipient, removedBalance);
}
```

