# Force Actions Facet

The ForceActions Facet provides PartyA with mechanisms to force the cancellation or closure of quotes and positions when PartyB is unresponsive. These are safety-valve functions that protect users from being locked into positions indefinitely. The underlying logic is implemented in the `ForceActionsFacetImpl` library.

**Note:** In v0.8.5, the legacy single-transaction `forceClosePosition` on this facet **explicitly rejects cross-mode PartyBs**. For cross-mode PartyBs, use the step-based flow on `ForceCloseStepsFacet` instead, which supports `UnifiedSettlementSig` and handles cross-mode solvency correctly. See the [ForceCloseStepsFacet](https://docs.symm.io/contract-documentation/symmio-perps-v0.8.5/diamond-core-facets/forceclosesteps) documentation for details.

***

### Overview

The ForceActions Facet provides the following key functionalities:

* **Force Cancel Quote:** Cancels a quote when PartyB has not responded within the `ForceCancelCooldown` period.
* **Force Cancel Close Request:** Cancels a pending close request when PartyB has not responded within the `ForceCancelCloseCooldown` period.
* **Force Close Position:** Forces a position closed using a Muon high/low price signature. Only works for isolated-mode (non-cross) PartyBs. If PartyB is insolvent after the close, falls back to the reserve vault or triggers PartyB liquidation.
* **Settle and Force Close (Deprecated):** Combines settlement with force close in a single transaction. Deprecated in favor of `forceCloseAndSettlePositionsUnified` on the `ForceCloseStepsFacet`, which supports `UnifiedSettlementSig` for multi-PartyB coordination.

***

### forceCancelQuote()

Forces the cancellation of a quote when PartyB has not responded within the configured `ForceCancelCooldown` period. This allows PartyA to reclaim funds locked in a pending quote that PartyB has failed to act on.

**Function Signature:**

```solidity
function forceCancelQuote(uint256 quoteId) external notLiquidated(quoteId) whenNotPartyAActionsPaused;
```

**Parameters:**

* `quoteId`: The ID of the quote to cancel.

**Events Emitted:**

* `ForceCancelQuote(uint256 quoteId, QuoteStatus status)`

***

### forceCancelCloseRequest()

Forces the cancellation of a pending close request when PartyB has not responded within the configured `ForceCancelCloseCooldown` period. The position remains open and the close request is removed.

**Function Signature:**

```solidity
function forceCancelCloseRequest(uint256 quoteId) external notLiquidated(quoteId) whenNotPartyAActionsPaused;
```

**Parameters:**

* `quoteId`: The ID of the quote whose close request should be cancelled.

**Example:**

```solidity
// Force cancel a close request that PartyB hasn't responded to
symmioDiamond.forceCancelCloseRequest(quoteId);
```

**Events Emitted:**

* `ForceCancelCloseRequest(uint256 quoteId, QuoteStatus status, uint256 closeId)`

***

### forceClosePosition()

Forces the closure of a position when PartyB has not filled a close request within the allowed timeframe. Uses a Muon `HighLowPriceSig` to determine the close price with penalty. The quote must be in `CLOSE_PENDING` status with a LIMIT order type, and the close price must have been reached within the signature's price range.

This function rejects cross-mode PartyBs. For cross-mode force closes, use `ForceCloseStepsFacet.initializeForceClose` → `settleUpnlForForceClose` → `finalizeForceClose` (or alternatively  `forceCloseAndSettlePositionsUnified`).

If the close succeeds normally, a `ForceClosePosition` event is emitted. If PartyB becomes insolvent after the close, the function attempts to cover the deficit from PartyB's reserve vault. If the reserve vault is insufficient, PartyB liquidation is triggered and a `LiquidatePartyB` event is emitted instead.

**Function Signature:**

```solidity
function forceClosePosition(uint256 quoteId, HighLowPriceSig memory sig) external notLiquidated(quoteId) whenNotPartyAActionsPaused;
```

**Parameters:**

* `quoteId`: The ID of the quote whose position should be force-closed.
* `sig`: The Muon `HighLowPriceSig` containing high/low prices used to calculate the close price.

**Events Emitted (success):**

* `ForceClosePosition(uint256 quoteId, address partyA, address partyB, uint256 filledAmount, uint256 closePrice, QuoteStatus status, uint256 closeId)`

**Events Emitted (PartyB insolvent):**

* `LiquidatePartyB(address liquidator, address partyB, address partyA, uint256 partyBAllocatedBalance, int256 upnlPartyB)`

***

### settleAndForceClosePosition()

> **DEPRECATED:** Use `forceCloseAndSettlePositionsUnified` on the `ForceCloseStepsFacet` instead, which supports `UnifiedSettlementSig` for better multi-PartyB coordination.

Settles unrealized PnL across positions and then force-closes the specified position in a single transaction. This was used when PartyA or PartyB lacked sufficient available balance to execute the close — settlement realizes PnL from other positions to fund the close.

**Function Signature:**

```solidity
function settleAndForceClosePosition(
    uint256 quoteId,
    HighLowPriceSig memory sig,
    SettlementSig memory settleSig,
    uint256[] memory updatedPrices
) external notLiquidated(quoteId) whenNotPartyAActionsPaused;
```

**Parameters:**

* `quoteId`: The ID of the quote whose position should be force-closed.
* `sig`: The Muon `HighLowPriceSig` for calculating the close price.
* `settleSig`: The Muon `SettlementSig` containing quote IDs, uPNL of both parties, and market prices for settlement.
* `updatedPrices`: New prices to set as `openedPrice` for the settled quotes.

**Events Emitted:**

* `SettleUpnl(...)` — after settlement completes
* `ForceClosePosition(...)` or `LiquidatePartyB(...)` after the force close attempt
