# One pair can steal another pair's Uniswap liquidity during reallocate() call if both pairs operate on the same Uniswap pool and both have the same upper and lower tick during reallocation

Predy reallocate() pulls all Uniswap V3 range liquidity, so a second pair sharing the same pool and tick range steals the first pair's gamma liquidity, breaking accounting.

- Payout: Audit contest
- Severity: high
- Program: Predy
- Found by: eeyore
- Disclosed: 2024-07-16
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2024-05-predy-findings/issues/49
- Library page: https://bugbountylibrary.com/r/c4%3A2024-05-predy%3AH-03
- Tags: area:web3 domain:web3 impact:funds-loss impact:integrity kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** PredyPool reallocate() / Uniswap V3 liquidity range
**Root cause:** reallocate() assumes all liquidity within the pair's tick range belongs to that pair, without tracking per-pair liquidity ownership, so overlapping ranges on the same Uniswap pool share the same liquidity.
**Steps:**
1. Register two pairs on the same Uniswap pool with different quote tokens but identical lower/upper ticks.
2. User opens a gamma position on pair 1 via `tradeMarket.trade(TradeParams(1,0,-90000,100000,...))`.
3. Move price so it exits pair 2's threshold.
4. Call `tradeMarket.reallocate(2, settlementData)` — pair 2 withdraws the liquidity pair 1 deposited.
5. Call `reallocate(1, ...)` — pair 1 now has zero liquidity; user cannot close the gamma position.
**How found:** Observed that reallocate() reads total liquidity in the tick range rather than per-pair tracked liquidity; hypothesized two pairs sharing a pool and tick range would collide, confirmed with a Foundry PoC.
**Exploitation:** Any user triggers reallocate() on the second pair after price moves outside its threshold; the function withdraws the entire tick-range liquidity, which actually belongs to the first pair's gamma position, diverting it and corrupting internal accounting so positions cannot be closed or liquidated.
**Escalation:** Cross-pair accounting corruption makes gamma positions unclosable/unliquidatable on the victim pair.
**Insight:** When a protocol manages Uniswap V3 positions, check whether liquidity ownership is tracked per position or inferred from the shared tick range — any two positions with identical ranges on the same pool will collide.

