# Liquidating a turned solvent Party A does not credit the profits to Party A

In Symmetrical liquidation, a Party A that turns solvent mid-liquidation has its realized profits retained by the protocol instead of credited, while Party B's losses are deducted.

- Payout: Contest reward
- Severity: medium
- Program: Symmetrical
- Credited: berndartmueller
- Disclosed: 2023-06-05
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-06-symmetrical-judging/issues/290
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-06-symmetrical%3AM-20
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:solidity technique:source-review vuln:accounting-error vuln:business-logic vuln:liquidation

**Target:** LiquidationFacetImpl.sol (setSymbolsPrice / liquidatePositionsPartyA)
**Root cause:** setSymbolsPrice sets liquidationType=NORMAL when availableBalance>=0, but liquidatePositionsPartyA only deducts Party B's allocated balance for Party A's profitable positions and then resets Party A's allocated balance to 0, never crediting the profit.
**Steps:**
1. Party A is liquidatable; liquidator calls liquidatePartyA then setSymbolsPrice with a priceSig where availableBalance >= 0, setting liquidationType = NORMAL and liquidationFee = remaining lf.
2. Call liquidatePositionsPartyA with Party A's quoteIds; for profitable quotes, `accountLayout.partyBAllocatedBalances[quote.partyB][partyA] -= amount` deducts Party B's balance.
3. When partyAPositionsCount hits 0, line 216 sets `accountLayout.allocatedBalances[partyA] = 0`, discarding Party A's realized profit.
4. Result: Party B loses the amount, liquidators get lf/2 each, and the profit remains stuck in the protocol contract.
**How found:** Code review of the multi-step liquidation flow: noticed setSymbolsPrice allows NORMAL liquidation when availableBalance>=0, then traced liquidatePositionsPartyA to see Party B debited but Party A never credited before allocatedBalances reset to 0.
**Exploitation:** Liquidator triggers liquidation while Party A is momentarily solvent (e.g. pnl moves from -201 to -199); Party B's allocated balance is reduced by the profit amount and Party A's balance is zeroed, leaving the difference unaccounted in the protocol.
**Insight:** In multi-step liquidation designs, check every branch where a party can flip from insolvent to solvent between the price-setting step and the position-liquidation step; verify accounting symmetry (who is debited vs credited) across those steps, not just the insolvent path.
