# MultiInvoker liquidation action will revert due to incorrect closable amount calculation for invalid oracle versions

MultiInvoker's _latest mis-settles invalid oracle versions, zeroing closableAmount so LIQUIDATE actions revert and liquidators lose fees.

- Payout: Contest reward
- Severity: medium
- Program: Perennial
- Credited: panprog
- Disclosed: 2023-09-14
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2023-09-perennial-judging/issues/45
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-09-perennial%3AM-5
- Tags: domain:web3 impact:dos kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:incomplete-fix technique:source-review vuln:accounting-error vuln:business-logic

**Target:** MultiInvoker.sol liquidation action / position settlement
**Root cause:** MultiInvoker._latest invalidates latestPosition then unconditionally updates it to pendingPosition, unlike Market which adjusts pendingPosition by the invalidation before updating, so latestPosition magnitude (and closableAmount) becomes wrong for invalid oracle versions.
**Steps:**
1. Set latestPosition.market=10, pendingPosition.market=0 with an invalid oracle version.
2. Call MultiInvoker LIQUIDATE action; _latest invalidates latestPosition (invalidation.market=10) then sets latestPosition=pendingPosition (market=0).
3. closableAmount=latestPosition.magnitude()=0 instead of 10.
4. market.update subtracts closable=0, leaving closableAmount nonzero, tripping Market._invariant's !closableAmount.isZero() check and reverting MarketInvalidProtectionError.
**How found:** Compared MultiInvoker._latest's virtual settlement logic against Market._settle/_processPositionLocal line by line, spotting the missing adjust() before update() on the invalid-oracle branch.
**Insight:** When a helper contract re-implements a core contract's settlement math, diff the two implementations branch by branch; the invalid-oracle branch is where copies typically diverge because it mutates invalidation state before updating position.
