# Growing of totalSupply after successive lock/unlockCapital can freeze protection pools by uint overflow

Repeated lock/unlockCapital cycles shrink _getExchangeRate toward zero, exponentially inflating totalSupply until deposits revert, freezing the protection pool.

- Payout: Contest reward
- Severity: medium
- Program: Carapace
- Credited: clems4ever
- Disclosed: 2023-02-01
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-02-carapace-judging/issues/118
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-02-carapace%3AM-7
- Tags: domain:web3 impact:dos kind:contest platform:sherlock sev:medium tech:solidity technique:source-review vuln:accounting-error vuln:dos vuln:share-inflation

**Target:** ProtectionPool.sol convertToSToken / _getExchangeRate share accounting
**Root cause:** _getExchangeRate divides totalSTokenUnderlying by totalSupply; locking capital removes underlying, so the rate drops and each new deposit mints exponentially more shares, growing totalSupply until the rate rounds to zero and deposits revert.
**Steps:**
1. Pool holds 1M USDC (10**12 units); totalSupply S, rate = 10**12/S.
2. A lock event leaves dust (e.g. 1 wei) in totalSTokenUnderlying, so rate becomes ~1/S.
3. New deposit of 1M USDC calls convertToSToken, minting ~10**12 * S shares, multiplying totalSupply by 10**12.
4. Repeat lock/deposit cycles; totalSupply grows exponentially.
5. Eventually _getExchangeRate() rounds to 0, division/mint reverts, and all further deposits are blocked.
**How found:** Code review of convertToSToken/_getExchangeRate: noticed locked funds are subtracted from totalSTokenUnderlying, making the exchange rate arbitrarily small, and reasoned that new depositors then receive disproportionately many shares, growing totalSupply.
**Escalation:** Repeated lock/unlockCapital cycles compound the share multiplication until the exchange rate truncates to zero, permanently blocking deposits (pool DoS).
**Insight:** In vault/share designs where the exchange rate can be driven very low (e.g. by removing underlying on lock), check whether minted shares can inflate totalSupply to overflow or truncate the rate to zero, blocking deposits.
