# First depositor can break minting of shares

First depositor mints 1 wei LP then donates large reserves directly, so later depositors' LP shares round to zero and their funds are stolen.

- Payout: Contest reward
- Severity: high
- Program: Caviar
- Credited: minhquanym
- Disclosed: 2023-01-26
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2022-12-caviar-findings/issues/442
- Library page: https://bugbountylibrary.com/r/c4%3A2022-12-caviar%3AH-03
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:share-inflation

**Target:** Pair.add() LP share minting in Caviar AMM
**Root cause:** LP share math divides by reserves that can be inflated by direct token transfers without minting shares, and minted amount is not required to be non-zero.
**Steps:**
1. Attacker calls add with 1 wei baseToken and 1 wei fractionalToken; sqrt(1*1)=1 LP wei minted.
2. Attacker transfers e.g. 1e9 baseToken and 1e9 fractionalToken directly to the pair, inflating reserves without minting LP.
3. Victim calls add with X,Y < 1e9; baseTokenShare=(X*1)/1e9 and fractionalTokenShare=(Y*1)/1e9 round to 0, so victim receives 0 LP tokens while tokens stay in pool.
**How found:** Recognized the classic Yearn/Uniswap first-depositor donation attack (TOB-YEARN-003) applied to Pair.add()'s share formula and rounding division.
**Exploitation:** Attacker seeds minimal liquidity to own 1 wei LP, donates large amounts to inflate reserves, then victims' deposits mint zero shares; attacker redeems the single LP wei to capture donated plus victim funds.
**Insight:** Any AMM/vault share formula using totalSupply/reserves is donation-inflatable; check whether minted shares can round to zero and whether initial LP is locked/burned.
