# Wrong design/implementation of addLiquidity() allows attacker to steal funds from the liquidity pool

Vader pool's addLiquidity accepts arbitrary deposit ratios, letting an attacker skew pool price, arbitrage swaps, and drain ~8.1k USDV from LPs.

- Payout: Audit contest
- Severity: high
- Program: Vader Protocol
- Found by: WatchPug
- Disclosed: 2022-02-10
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2021-11-vader-findings/issues/212
- Library page: https://bugbountylibrary.com/r/c4%3A2021-11-vader%3AH-24
- 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 vuln:oracle-manipulation

**Target:** VaderPoolV2.mintFungible / addLiquidity AMM pool
**Root cause:** mintFungible computes liquidity units from arbitrary nativeDeposit/foreignDeposit without enforcing the current reserve ratio, so a depositor can shift the pool price in a single call.
**Steps:**
1. Pool state: 100,000 USDV + 1 BTC, totalPoolUnits=100.
2. `addLiquidity(100000 USDV, 0 BTC)` -> 50 liquidityUnits (~1/3 of pool).
3. Swap `0.1 BTC` -> USDV five times (total 0.5 BTC spent, 62163.36 USDV received).
4. `removeLiquidity` -> 45945.54 USDV + 0.5 BTC.
5. Net profit: 62163.36 + 45945.54 - 100000 = 8108.9 USDV.
**How found:** Compared Vader's addLiquidity to Uni v2's fixed-ratio minting; noticed arbitrary deposit amounts let a single depositor move pool price, then modeled a deposit/swap/withdraw sequence to quantify LP loss.
**Exploitation:** Attacker deposits a lopsided amount to acquire LP shares cheaply, then performs repeated swaps against the now-skewed pool to extract value, then withdraws; profit comes from other LPs' reserves.
**Insight:** When an AMM lets LPs mint at arbitrary ratios (Thorchain CLP-style), the mint itself is a price-moving trade; check whether a single-tx deposit+swap+withdraw cycle nets positive against existing LPs.
