# supply in the zerolocker.sol is incorrectly increased during merge_type actions

ZeroLocker's _depositFor increments supply on MERGE_TYPE deposits that transfer no tokens, inflating supply and breaking the accounting invariant.

- Payout: Contest reward
- Severity: medium
- Program: Zerolend
- Credited: osmanozdemir1
- Disclosed: 2024-09-16
- Write-up quality: 6/10
- Original: https://cdn.cantina.xyz/reports/cantina_competition_zerolend_jan2024.pdf#3.2.8
- Library page: https://bugbountylibrary.com/r/cantina%3Azerolend_jan2024%3A3.2.8
- Tags: domain:web3 impact:integrity kind:contest platform:cantina sev:medium tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** ZeroLocker.sol lock/merge accounting contract
**Root cause:** _depositFor unconditionally does supply = supplyBefore + _value, but MERGE_TYPE deposits move no underlying tokens, so supply is double-counted on every merge.
**Steps:**
1. Deploy fixture with locker and token; fund user and approve locker.
2. `createLock(AMOUNT, 4y)` then `createLock(AMOUNT, 2y)`; supply and balance both equal 2*AMOUNT.
3. Call `merge(1, 2)`; merge reads value0 = locked[1].amount and calls `_depositFor(_to, value0, end, _locked1, MERGE_TYPE)`.
4. Observe `supply()` == 3*AMOUNT while `token.balanceOf(locker)` == 2*AMOUNT.
**How found:** Code reading of _depositFor: noticed supply increment happens before the depositType check that guards the transferFrom, so MERGE_TYPE skips the transfer but still bumps supply.
**Exploitation:** Any user can repeatedly merge positions to arbitrarily inflate the supply state variable; no token transfer occurs, so the mismatch grows unbounded. Impact limited because supply is not used in critical calculations in current code.
**Escalation:** Repeated merges scale the discrepancy; risk grows if supply/totalSupplyWithoutDecay is consumed by core contracts or integrators.
**Insight:** When a shared internal accounting function branches on an enum/type, check whether state mutations (supply, totals, checkpoints) sit outside the branch that guards the actual asset movement — merge/consolidation paths that reuse deposit logic are prime spots for double-counting.
