# Stableswap pool can be skewed free of fees

MANTRA stableswap liquidity addition omits Curve-style skew fee, letting a user single-side deposit to skew pool ratio for ~0.16% cost, causing slippage losses for others.

- Payout: Audit contest
- Severity: high
- Program: MANTRA
- Credited: carrotsmuggler
- Disclosed: 2025-03-31
- Write-up quality: 7/10
- Original: https://code4rena.com/reports/2024-11-mantra-dex#h-08
- Library page: https://bugbountylibrary.com/r/c4%3A2024-11-mantra-dex%3AH-08
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:solidity technique:chained technique:source-review vuln:accounting-error vuln:fee-bypass vuln:oracle-manipulation

**Target:** stableswap pool liquidity provision
**Root cause:** provide_liquidity mints LP based only on D1/D0 ratio without computing per-asset ideal_balance difference, so imbalanced deposits incur no swap fee unlike Curve.
**Steps:**
1. Create 2-token stableswap pool (uwhale/uluna, amp=100, swap_fee 0.1%).
2. Add balanced liquidity 1e6 uwhale + 1e6 uluna.
3. Single-sided deposit 2e6 uwhale, 0 uluna via `provide_liquidity` — no skew fee charged.
4. Withdraw all LP shares; receive ~1.497e6 uwhale + 0.499e6 uluna, skewing pool to ~1:0.33 ratio.
**How found:** Compared MANTRA stableswap liquidity math against Curve's implementation, noticing Curve computes ideal_balance vs new_balance difference and charges dynamic fee on skew, while MANTRA's compute_d ratio check charges nothing; wrote PoC to confirm.
**Exploitation:** Attacker deposits large single-sided liquidity to skew stableswap ratio at near-zero cost (only slippage ~0.16%), then withdraws; pool price reported incorrectly and subsequent swappers/LPs suffer high slippage, enabling cheap price manipulation.
**Insight:** When auditing stableswap forks, diff the liquidity-add fee logic against Curve's `_dynamic_fee * difference` skew penalty — ratio-only D1/D0 minting silently drops the imbalance fee.
