# `VaultPoolLib::reserve()` will store the `Pa` not attributed to user withdrawals incorrectly and leave in untracked once it expires again

VaultPoolLib.reserve() misattributes PA to withdrawal pool instead of AMM, leaving PA permanently stuck and untracked after expiry.

- Payout: Audit contest
- Severity: high
- Program: Cork Protocol
- Found by: 0x73696d616f
- Disclosed: 2024-08-22
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-08-cork-protocol-judging/issues/191
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-08-cork-protocol%3AH-11
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error

**Target:** VaultPoolLib library / Vault LP liquidation
**Root cause:** reserve() stores the PA attributed to withdrawals in stagnatedPaBalance instead of the amount attributedToAmm, and rationedToAmm() only reads Ra balance, so the AMM-attributed PA is never rationed again and stays untracked.
**Steps:**
1. Call VaultLib::_liquidatedLP() via redeeming expired LV shares or admin new issuance, which invokes VaultPoolLib::reserve()
2. Observe reserve() writes withdrawal-attributed PA into self.withdrawalPool.stagnatedPaBalance rather than the attributedToAmm amount
3. Inspect VaultPoolLib::rationedToAmm() (line 170): it only uses self.ammLiquidityPool.balance (Ra), never PA
4. Confirm the AMM-attributed PA is never redistributed at next expiry and remains stuck in the Vault
**How found:** Code reading of reserve() and rationedToAmm(); noticed the FIXME comment claiming PA 'will just sit there until rationed again at next expiry' contradicts rationedToAmm() only consuming Ra balance.
**Insight:** When a code comment promises future handling ('rationed again at next expiry'), verify the referenced function actually reads that asset; here rationedToAmm only touches Ra, so any PA path is dead and funds strand.

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

**rationedToAmm ignores Pa balance**

```
function rationedToAmm(VaultPool storage self, uint256 ratio) internal view returns (uint256 ra, uint256 ct) {
    uint256 amount = self.ammLiquidityPool.balance;

    (ra, ct) = MathHelper.calculateProvideLiquidityAmountBasedOnCtPrice(amount, ratio);
}
```

