PartyB Emergency Actions
The PartyB Emergency Actions Facet provides PartyB with mechanisms to close positions outside the normal close flow — either through emergency close (when the symbol is delisted or PartyB is in emergency status) or through ADL (Auto-Deleveraging), a new mechanism that allows controlled position reduction without requiring emergency mode. The underlying logic is implemented in the PartyBEmergencyActionsFacetImpl library.
In v0.8.5, ADL Close (Auto-Deleveraging) was implemented:
The
adlClosefunction allows PartyB to forcibly close positions to reduce risk exposure. Unlike emergency close, ADL does not require emergency mode activation, PartyB emergency status, or delisted symbols. ADL must be explicitly enabled per PartyB by an admin, and requires PartyB to have deposited pledge collateral as a guarantee against misuse. ADL skips solvency checks, allowing PartyB to close positions even when their available balance would normally block it.
Overview
The PartyB Emergency Actions Facet provides the following key functionalities:
Emergency Close Position: Closes a position when the symbol has been delisted or PartyB has been placed in emergency status. Requires a Muon signature.
ADL Close: PartyB forcibly closes (or partially closes) a position at a specified price without solvency checks or emergency mode requirements. Emits mock events that mirror the normal close flow for off-chain compatibility.
emergencyClosePosition()
Allows PartyB to emergency close a position. This is used when the symbol has been delisted or when PartyB has been placed in emergency status by an admin. The position is closed at the price provided in the Muon signature, and the full remaining open amount is closed.
Function Signature:
function emergencyClosePosition(
uint256 quoteId,
PairUpnlAndPriceSig memory upnlSig
) external whenNotPartyBActionsPaused onlyPartyBOfQuote(quoteId) notLiquidated(quoteId);Parameters:
quoteId: The ID of the quote to emergency close.upnlSig: The Muon signature containing the uPnL of both parties and the closing price.
Access: Only callable by the PartyB of the quote. Neither party can be in liquidation.
Events Emitted:
EmergencyClosePosition(uint256 quoteId, address partyA, address partyB, uint256 filledAmount, uint256 closePrice, QuoteStatus status, uint256 closeId)
adlClose()
Performs an ADL (Auto-Deleveraging) close on a position. PartyB can forcibly close all or part of a position at a specified price without solvency checks. This provides a controlled mechanism to reduce risk exposure when needed.
Prerequisites:
ADL must be enabled for the PartyB by an admin via
ControlFacet.setADLEnabled(partyB, true).PartyB must have deposited pledge collateral (a separate collateral pool that can be slashed if ADL is misused).
Key characteristics:
No solvency checks — PartyB can close even when their available balance would otherwise block it.
Supports partial closes —
amountcan be less than the full open amount.Preserves pending close requests — if the position has a pending close request from PartyA, ADL temporarily cancels it, executes the close, and restores the original request with adjusted quantity if the position remains open.
Function Signature:
Parameters:
quoteId: The ID of the quote to ADL close.amount: The quantity to close (must be ≤ the open amount).price: The execution price.
Access: Only callable by the PartyB of the quote. ADL must be enabled for the PartyB.
Events Emitted:
ADLClose(uint256 quoteId, uint256 amount, uint256 price)
Additionally, mock events are emitted that mirror the normal close flow for off-chain compatibility:
ADL on an OPENED position:
RequestToClosePosition(orderType: MARKET, with ADL closeId)FillCloseRequest(with ADL closeId)
ADL on a CLOSE_PENDING position:
RequestToCancelCloseRequest(mock: as if PartyA requested cancel)AcceptCancelCloseRequest(mock: as if PartyB accepted)RequestToClosePosition(ADL close request)FillCloseRequest(ADL fill)RequestToClosePosition(restore original close request, if position remains open)
ADL on a CANCEL_CLOSE_PENDING position:
AcceptCancelCloseRequest(mock: accept the pending cancel)RequestToClosePosition(ADL close request)FillCloseRequest(ADL fill)RequestToClosePosition(restore original close request, if position remains open)RequestToCancelCloseRequest(restore cancel-pending status)
These mock events ensure that indexers, UIs, and analytics correctly track position state without needing special ADL handling.
Batched ADL Close
The SymmioPartyB helper contract (external to the diamond) provides a batched adlClose method that processes multiple quotes in a single transaction with best-effort semantics — if an individual ADL close fails, it emits an ADLSkip event with the revert data and continues processing the remaining quotes, rather than reverting the entire transaction.
Last updated

