# `SuperPool` fails to correctly deposit into pools

SuperPool._supplyToPools compares only its own per-pool cap, not the BasePool's global cap, so deposits revert and free space is skipped.

- Payout: Audit contest
- Severity: medium
- Program: Sentiment
- Found by: 0xDazai
- Disclosed: 2024-08-07
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-08-sentiment-v2-judging/issues/178
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-08-sentiment-v2%3AM-8
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** SuperPool._supplyToPools deposit routing in Solidity lending protocol
**Root cause:** _supplyToPools computes supplyAmt from poolCapFor[poolId] minus SuperPool's own assets in the pool, ignoring the BasePool's global poolCap and other depositors' assets, so it can request more than the remaining BasePool capacity.
**Steps:**
1. Owner creates BasePool poolId=1 with poolCap=2000 USDC.
2. SuperPool owner adds poolId=1 with poolCapFor[poolId]=1500.
3. Alice calls SuperPool.deposit(1000) -> 1000 USDC in poolId=1; SuperPool cap space 500, BasePool cap space 1000.
4. Bob calls Pool.deposit(poolId=1, 600) directly; BasePool cap space now 400.
5. John calls SuperPool.deposit(500): _supplyToPools computes supplyAmt=500 (poolCapFor space), POOL.deposit reverts on BasePool cap, catch skips poolId=1 leaving 400 USDC unused.
**How found:** Code reading of _supplyToPools: noticed the cap check uses POOL.getAssetsOf(poolId, address(this)) (SuperPool's own balance) against poolCapFor rather than the BasePool's total assets against its poolCap, then reasoned through a multi-depositor scenario where the BasePool cap is hit by a direct depositor.
**Insight:** When a router/aggregator enforces its own per-target cap, also check the target's global cap minus total target assets; a per-caller balance check diverges once other actors deposit directly into the same target.

