# Function processEpoch() in PublicVault would revert when most of the users withdraw their funds because of the underflow for new yIntercept calculation

PublicVault.processEpoch underflows when most LPs withdraw, since totalAssets() exceeds yIntercept, reverting epoch processing and locking funds.

- Payout: Contest reward
- Severity: high
- Program: Astaria
- Credited: unforgiven
- Disclosed: 2023-05-22
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2023-01-astaria-findings/issues/188
- Library page: https://bugbountylibrary.com/r/c4%3A2023-01-astaria%3AH-17
- Tags: 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:** PublicVault.processEpoch() epoch accounting
**Root cause:** processEpoch subtracts totalAssets()*liquidationWithdrawRatio from yIntercept without accruing first; totalAssets() includes slope*delta_t so it can exceed yIntercept, causing underflow.
**Steps:**
1. LPs deposit into PublicVault and later request withdrawal, minting WithdrawProxy shares.
2. At epoch end, processEpoch computes liquidationWithdrawRatio = proxySupply*1e18/totalSupply(), near 1 when most withdraw.
3. totalAssets() = slope*delta_t + yIntercept exceeds yIntercept due to accrued interest.
4. totalAssets().mulDivDown(liquidationWithdrawRatio,1e18) > yIntercept, so `s.yIntercept - ...` underflows and reverts.
5. processEpoch cannot complete; epoch never advances and withdrawing users' funds are stuck.
**How found:** Code reading of processEpoch's yIntercept update versus _totalAssets formula, noticing totalAssets includes slope*delta_t and can exceed yIntercept when liquidationWithdrawRatio approaches 1.
**Exploitation:** Any LP (e.g. the last withdrawer) triggers the revert by withdrawing most of the vault, blocking epoch progression and trapping funds; no capital beyond normal deposits needed.
**Insight:** When a contract subtracts a ratio-scaled totalAssets() from a stored yIntercept, check whether totalAssets() includes accrued slope; accrue() before the subtraction or the underflow triggers at high withdrawal ratios.
