# Donation fees are sandwichable in one transaction

Flayer donates listing fees to a Uniswap V4 pool without a per-block cap, letting an attacker add JIT liquidity and sandwich the donation to steal LP fees.

- Payout: Audit contest
- Severity: high
- Program: Flayer
- Found by: 0x37
- Disclosed: 2024-08-06
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-08-flayer-judging/issues/615
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-08-flayer%3AH-20
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:source-review vuln:business-logic vuln:oracle-manipulation

**Target:** UniswapImplementation._distributeFees / Uniswap V4 poolManager.donate
**Root cause:** _distributeFees calls poolManager.donate with no per-block cap on donated amount (only a per-call donateThresholdMax), so a single transaction can donate a large fee that JIT liquidity can capture.
**Steps:**
1. Identify the tick the donated fee will land at per IPoolManager.donate semantics (slot0.tick).
2. Add heavy in-range liquidity (~100x existing) at that tick.
3. Trigger a fee-donating action: `liquidateProtectedListing`, `cancelListing`, `modifyListings`, `fillListings`, `Reserve`, or `Relist`.
4. Donation executes via `poolManager.donate(_poolKey, amount0, amount1, '')` in `_distributeFees`.
5. Remove the JIT liquidity, collecting the captured donation.
**How found:** Read Uniswap V4 IPoolManager.donate docs warning that donations can be frontrun with JIT liquidity, then traced Flayer's _distributeFees to find it calls donate with only a per-call max and no per-block limit.
**Exploitation:** Attacker supplies just-in-time in-range liquidity around the pool tick, triggers a fee-donating listing action (e.g. liquidating a protected listing where ~0.4 ETH is donated), captures the donation as LP, then withdraws liquidity in the same transaction.
**Escalation:** Can be repeated/looped per donation and applied to any user's public-mempool listing action, not just liquidations.
**Insight:** When a protocol pushes fees into an AMM via donate/distribute, check whether the amount per block is capped; a per-call max is bypassable by looping or by large single donations from liquidation flows, enabling JIT-liquidity capture.

