flowchart TD A["Start: A liquidation agent calls requestLiquidation(account, position Id)"] --> B{Is MMA > 0 for account?} B -- Yes --> B1[Fail process] B -- No --> C{Is IS_LIQUIDATING already TRUE?} C -- Yes --> C1[Fail process] C -- No --> F[Create and populate Liquidation Auction object] F --> G[Send AUCTION_BOUNTY times MM to liquidator]
Liquidation
Efficient liquidation of undercollateralised MAs is a crucial component of a derivatives clearing system to ensure solvency of the overall market.
The AFP introduces a Dutch Auction style liquidation mechanism, where during the liquidation auction an increasing proportion of the Margin Account Equity (MAE) of the liquidating account is offered to the liquidator.
Liquidation Auction Request Process
A liquidation auction is initiated via a liquidation auction request, which is an open function that can be called by any Intent Account (an Intent Account in this instance is termed a Liquidation Agent):
function requestLiquidation(address account, bytes32 positionId) external
- If
MMA > 0
for the specified Margin Account, then the process fails. - If
IS_LIQUIDATING
is alreadyTRUE
or the Margin Account does not have any positions, the process fails. - Create a new Liquidation Auction object for the Margin Account and set
IS_LIQUIDATING
toTRUE
. - Record in the Liquidation Auction object the:
- Start block
- MAE at the block of the auction start
- MMU at the block of the auction start
- The liquidator receives
AUCTION_BOUNTY * MM[Ψ]
units of the Collateral Asset, which is subtracted from the Margin Account’s capitalC
, whereΨ
is the Product. - The auction request process succeeds.
Liquidation Auction Bid Process
Once a liquidation auction has begun, auction bids can be processed. When the liquidatable account’s position is long, the account is the sell-side of the auction and the auction’s bidders are the buy-side of the auction. When the liquidatable account’s position is short, the account is the buy-side of the auction and the auction’s bidders are the sell-side of the auction. Liquidators will provide a full list of prices and quantities for positions they are willing to take over from the liquidatable account. A liquidation bid request includes:
function bidAuction(address marginAccountID, address collateralToken, BidData[] calldata bids) external notSelf(marginAccountID)
Process:
- Perform a Liquidation Auction Bid Validation Check on the Liquidation Auction Bid. If it fails, the process fails.
- Run an MAE Check on the liquidator’s Margin Account for the corresponding Collateral Asset and the specified products and prices. In case of failure, the bid is rejected.
- Settle the Liquidation Trade for the liquidator:
- Recalculate the Cost Basis.
- Recalculate the Position Size.
- Recalculate Realized PnL (RPnL) after the Cost Basis and Position Size.
- Execute the Liquidation Auction Termination Routine.
flowchart TD H[Liquidator submits Bid with Price, Quantity, and Product ID parameters] H --> I1[Run Bid Validation] I1 -- Yes --> I2{Does Bid validation pass?} I2 -- No --> I2F[Fail process] I2 -- Yes --> I3{Does the bidder have sufficient MAE to execute the bid?} I3 -- No --> I3F[Fail process] I3 -- Yes --> I4[Bid is successful] I4 --> L[Execute Liquidation Auction Termination Routine]
Liquidation Auction Bid Validation
- Check that the productIDs that are being bid on are unique, otherwise the process fails.
- Check that the liquidatable account has sufficient position quantities in each of the specified product ID’s:
abs(Q[Ψ[i]]) >= abs(q[i])
whereΨ[i]
is thei
-th product ID in the list of product IDs in BidData,q[i]
is the quantity of thei
-th product in the proposed trade, andQ(Ψ[i])
is the liquidating account’s current position quantity. If this check fails, the process fails. These products must use the specifiedcollateralToken
. - Check that each of the product ID’s specified are in
LIVE
orTRADEOUT
state, otherwise process fails. - Check that the quantities specified are reducing the liquidatable account’s position size in the given product:
(Q[Ψ[i]] + q[i]) / Q[Ψ[i]] < 1
if this check fails, the process fails. - Check that the liquidatable account’s MAE is not decreased by more than the current Liquidation Auction MAE Offer
(dMAE): MAE - MAE' <= dMAE
whereMAE
is the liquidatable account’s MAE before bid execution, andMAE'
is the liquidatable account’s MAE after bid execution. If this check fails, the process fails.
Liquidation Auction Termination Routine
- Check that the liquidating Margin Account being checked is
TRUE
forIS_LIQUIDATING
, otherwise abort. - If
MMA <= RESTORATION_BUFFER * MAE
, then abort. - Clear up state related to the Liquidation Auction.
Liquidation Auction MAE Offer
Over the course of a liquidation, an increasing proportion of the MAE of the liquidating account is offered to the liquidator. The MAE offer is proportional to the amount of MMU that is reduced by the liquidator, however, it is capped at the MAE of the liquidating account at the time of the bid.
dMAE = min((MAE(t_0) / MMU(t_0)) * (t / τ) * dMMU, MAE(t))
where:
dMMU
is the amount of MMU that is reduced by the liquidator.dMMU = MMU - MMU'
whereMMU'
is the liquidating account’s MMU after bid execution, andMMU
is the liquidating account’s MMU before bid execution.t_0
is the start block of the liquidation auction.τ
is the liquidation auction duration (in blocks).t
is the current block at liquidation bid submission.MMU(t_0)
is the liquidating account’s MMU at the start of the liquidation auction.MMU(t)
is the liquidating account’s MMU at the time of the bid.MAE(t_0)
is the liquidating account’s MAE at the start of the liquidation auction.MAE(t)
is the liquidating account’s MAE at the block of the bid.
Since dMMU
is dependent on the specific quantities q[i]
and products Ψ[i]
of the Liquidation Auction Bid, the MAE offer is a function of these variables. So, the MAE offer can be written as:
dMAE(t, q[i], Ψ[i]) = min((MAE(t_0) / MMU(t_0)) * (t / tau) * dMMU(q[i], Ψ[i]), MAE(t))