# IndexPool initial LP supply computation is wrong

IndexPool mints 1e20 LP to zero address and computes first-mint amountIn independent of token decimals/value, letting second LPs pay half for same LP tokens.

- Payout: Audit contest
- Severity: high
- Program: Sushi
- Found by: cmichel
- Disclosed: 2021-11-22
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2021-09-sushitrident-findings/issues/78
- Library page: https://bugbountylibrary.com/r/c4%3A2021-09-sushitrident%3AH-10
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** IndexPool.sol constructor and mint()
**Root cause:** Constructor pre-mints INIT_POOL_SUPPLY=1e20 LP to zero address, and first mint uses amountIn=ratio regardless of token decimals/value, so ratio is derived from total supply including the pre-minted amount.
**Steps:**
1. Deploy IndexPool; constructor mints 1e20 LP to address(0), totalSupply=1e20.
2. First minter calls `mint(toMint=1e20)`; ratio = 1e20*1e18/1e20 = 1e18; amountIn = ratio = 1e18 (reserve==0 branch); totalSupply becomes 2e20.
3. Second minter calls `mint(toMint=1e20)`; ratio = 1e20*1e18/2e20 = 0.5e18; amountIn = ratio*reserve/1e18 = 0.5e18, half the first minter's cost for same LP.
4. For mixed-decimal pools (DAI/WBTC), first mint requires equal raw amounts (1e20 of each), making initialization economically impossible.
**How found:** Code reading of constructor pre-mint and the reserve==0 branch of mint(), noticing amountIn is independent of token decimals/value and that totalSupply includes the zero-address mint.
**Exploitation:** Second LP mints the same LP amount at half the token cost, then burns to redeem a disproportionate share, draining value from the initial LP provider.
**Insight:** When a pool pre-mints dead LP supply in the constructor, check whether first-mint ratio math divides by totalSupply including that dead supply — it skews the first real minter's cost and lets subsequent minters underpay.

