# Most users won't be able to claim their share of Uniswap fees

ILOPool.claim() collects all pool fees via type(uint128).max, sending other users' Uniswap fees to the fee taker and bricking subsequent claims.

- Payout: Audit contest
- Severity: high
- Program: Vultisig
- Found by: juancito
- Disclosed: 2024-08-05
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2024-06-vultisig-findings/issues/43
- Library page: https://bugbountylibrary.com/r/c4%3A2024-06-vultisig%3AH-01
- Tags: area:web3 domain:web3 impact:dos impact:funds-loss kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:dos

**Target:** ILOPool.sol claim() / Uniswap V3 pool.collect
**Root cause:** claim() calls pool.collect with type(uint128).max for both tokens, pulling all accumulated fees across all positions rather than only the claiming tokenId's liquidity and fee share; the excess is forwarded to feeTaker.
**Steps:**
1. Deploy ILOPool via _launch(), warp past VEST_START_0.
2. INVESTOR and INVESTOR_2 each call claim(tokenId) to burn liquidity.
3. Generate fees via uniV3Pool.flash(1e8,1e8) and repay in callback.
4. INVESTOR calls claim(tokenId): pool.collect pulls all fees, excess sent to feeTaker.
5. INVESTOR_2 calls claim(tokenId2): reverts with `ST` (SafeTransfer) since contract lacks tokens.
6. Generate more fees via flash(1e6,1e6); INVESTOR_2 claim still reverts `ST`.
**How found:** Code review of claim()'s pool.collect call using type(uint128).max, noticing it collects fees for ALL positions rather than the specific tokenId, then confirming with a Foundry PoC using flash-loan-generated fees.
**Exploitation:** First claimer after fee accrual triggers pool.collect(type(uint128).max, type(uint128).max); the contract receives all fees, pays the claimer their share, and forwards the remainder (other users' fees) to feeTaker. Subsequent claimers' transactions revert on SafeTransfer because the contract no longer holds the fee tokens.
**Escalation:** As fees accumulate beyond platform fees, even vesting claims with burnable liquidity revert, potentially permanently locking claims for all other NFT IDs in the same tick range.
**Insight:** When auditing fee-collecting wrappers around Uniswap V3 positions, check whether pool.collect uses type(uint128).max instead of the per-position owed amounts (liquidity burn + feeGrowthInside delta); max-collect sweeps sibling positions' fees and can brick multi-user claims.

## Proof of concept (copied exactly from the original report)

**Foundry test proving second claimer reverts**

```
function testClaimFeesRevert() external {
    _launch();
    vm.warp(VEST_START_0 + 10);

    uint256 tokenId = IILOPool(iloPool).tokenOfOwnerByIndex(INVESTOR, 0);
    uint256 tokenId2 = IILOPool(iloPool).tokenOfOwnerByIndex(INVESTOR_2, 0);

    IUniswapV3Pool uniV3Pool = IUniswapV3Pool(projectId);

    // INVESTOR and INVESTOR_2 burn their liquidity and obtain their tokens

    vm.prank(INVESTOR);
    IILOPool(iloPool).claim(tokenId);

    vm.prank(INVESTOR_2);
    IILOPool(iloPool).claim(tokenId2);

    // Generate some fees via a flash loan
    uniV3Pool.flash(address(this), 1e8, 1e8, "");

    // INVESTOR claims their corresponding part of the fees
    // Only the first one to claim has better odds of claiming successfully
    vm.prank(INVESTOR);
    IILOPool(iloPool).claim(tokenId);

    // INVESTOR_2 can't claim their part of the fees as the transaction will revert
    // It reverts with ST (SafeTransfer) as it is trying to transfer tokens the contract doesn't have
    // The fees for INVESTOR_2 were already taken
    vm.prank(INVESTOR_2);
    vm.expectRevert(bytes("ST"));
    IILOPool(iloPool).claim(tokenId2);

    // Generate more fees
    uniV3Pool.flash(address(this), 1e6, 1e6, "");

    // Even if some new fees are available, they might not be enough to pay back the owed ones to INVESTOR_2
    vm.prank(INVESTOR_2);
    vm.expectRevert(bytes("ST"));
    IILOPool(iloPool).claim(tokenId2);
}
```

**Flash callback generating Uniswap fees**

```
function uniswapV3FlashCallback(uint256, uint256, bytes memory) external {
    deal(USDC, address(this), IERC20(USDC).balanceOf(address(this)) * 2);
    deal(SALE_TOKEN, address(this), IERC20(SALE_TOKEN).balanceOf(address(this)) * 2);

    IERC20(USDC).transfer(projectId, IERC20(USDC).balanceOf(address(this)));
    IERC20(SALE_TOKEN).transfer(projectId, IERC20(SALE_TOKEN).balanceOf(address(this)));
}
```

