# Supply interest is earned on `accruedToTreasuryShares` resulting in higher than expected treasury fees and under rare circumstances DOSed pool withdrawals

Treasury fees stored as shares accrue supply interest, so treasury claims more than reserveFactor and can drain liquidity, DoSing supplier withdrawals.

- Payout: Audit contest
- Severity: medium
- Program: New Scope
- Found by: 0xAlix2
- Disclosed: 2024-06-27
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2024-06-new-scope-judging/issues/430
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-06-new-scope%3AM-11
- Tags: area:web3 domain:web3 impact:dos impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic vuln:dos

**Target:** Lending pool reserve accounting (accruedToTreasuryShares / executeMintToTreasury)
**Root cause:** _accrueToTreasury converts fee assets to shares at current liquidityIndex but executeMintToTreasury converts them back at a later, higher liquidityIndex, so treasury shares earn supply interest not accounted for in pool liquidity.
**Steps:**
1. Set poolFactory.setReserveFactor(1e3) (10%).
2. Bob supplies 1000e18 tokenB; Alice supplies collateral and borrows 1000e18 tokenB (100% utilization).
3. Loop 12*60*60 times: `vm.warp(block.timestamp+1); pool.forceUpdateReserves();` to compound liquidityIndex toward borrowIndex.
4. Alice repays full debt with interest.
5. Loop 60 more seconds calling `pool.forceUpdateReserves()` so treasury shares accrue interest.
6. Compute treasuryAssetsToClaim = accruedToTreasuryShares * liquidityIndex / 1e27 and bobsAssets similarly; assert treasuryAssetsToClaim > reserveFactor*interestRepaid/1e4 and bobsAssets+treasuryAssetsToClaim > poolLiquidity.
**How found:** Code reading of ReserveLogic._accrueToTreasury (fee stored as shares) versus PoolLogic.executeMintToTreasury (shares converted at later liquidityIndex), noticing the mismatch and that forceUpdateReserves is externally callable to compound the index.
**Exploitation:** No attacker profit; the flaw is triggered by normal pool operation plus frequent forceUpdateReserves() calls (permissionless) that compound the liquidityIndex, causing treasury fee shares to inflate and exceed available liquidity, blocking supplier withdrawals.
**Insight:** When fees are denominated in shares of a rebasing/index-accruing asset, check whether the conversion-back index differs from the conversion-in index; permissionless index-update functions can be spammed to amplify the drift and starve liquidity.

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

**Setup diff enabling 10% reserve factor**

```
poolFactory = new PoolFactory(address(poolImplementation));
+   poolFactory.setReserveFactor(1e3); // 10%
```

