# Incorrect Netting Logic Leads to Excessive Withdrawal Amounts

In Burve's E4626 commit netting logic, assetsToDeposit is zeroed before subtraction, so withdrawals aren't netted against deposits, causing excess withdrawal fees.

- 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/174
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-04-burve%3AH-3
- 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:** E4626 vault commit netting logic (Solidity)
**Root cause:** In commit(), when assetsToWithdraw > assetsToDeposit, the code sets assetsToDeposit = 0 before subtracting it from assetsToWithdraw, so the subtraction is a no-op and the full withdrawal amount is used.
**Steps:**
1. Trigger trimBalance so both a deposit (reserveSharesEarned) and withdrawal (residualReal) are pending in temp.vars[1] and temp.vars[2].
2. Ensure assetsToWithdraw > assetsToDeposit.
3. Call commit(): `assetsToDeposit = 0; assetsToWithdraw -= assetsToDeposit;` leaves assetsToWithdraw unchanged.
4. Observe vault.withdraw called with full amount instead of net amount, paying withdrawal fees on the gross amount.
**How found:** Code review of the netting branch in E4626.commit; noticed assetsToDeposit zeroed before being subtracted from assetsToWithdraw.
**Insight:** When auditing netting/optimization branches, check operand ordering: zeroing a variable before using it in a subtraction silently disables the optimization and can leak fees or value.

