# Missing lower<upper check in mint_position

mint_position lacks lower<upper check; equal ticks let attacker mint arbitrary liquidity for zero tokens and farm inflated swap fees.

- Payout: Audit contest
- Severity: high
- Program: Superposition
- Found by: Q7
- Disclosed: 2024-10-18
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2024-08-superposition-findings/issues/149
- Library page: https://bugbountylibrary.com/r/c4%3A2024-08-superposition%3AH-03
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:solidity technique:source-review vuln:accounting-error vuln:business-logic vuln:reward-distribution

**Target:** Seawater AMM pool contract mint_position
**Root cause:** mint_position does not validate lower < upper, while downstream tick math (get_amount_0/1_delta, get_fee_growth_inside) assumes a valid ordered range, so equal or inverted ticks produce zero token amounts or wrong fee math.
**Steps:**
1. Create pool and enable it via create_pool/enable_pool.
2. Mint a normal position to establish liquidity.
3. Loop mint_position(token, tick, tick) with lower==upper for many ticks.
4. Call update_position with large liquidity; assert amount0==0 && amount1==0 (no tokens paid).
5. Victim swaps; attacker's empty positions accrue fees, inflating owed fees from ~6 to ~1605.
**How found:** Noticed mint_position omits the lower<upper invariant that other functions rely on, then reasoned about the branch logic in pool.rs where sqrt_ratio_a_x_96 differences collapse to zero when lower==upper.
**Exploitation:** Attacker mints many zero-cost positions with lower==upper spanning their range, then collects outsized swap fees from users trading through the pool, draining value from real LPs.
**Escalation:** Scaling number of empty positions (2000 in PoC) amplifies fee capture.
**Insight:** When a contract has an implicit invariant (ordered range) enforced in some functions but not the entry point, check the boundary cases (equal/inverted) against the math branches that assume ordering; zero-delta price math yields free liquidity.

