# Optimal Liquidations via Convex Optimization

**URL:** <https://research.vest.xyz/t/optimal-liquidations-via-convex-optimization/201>\
**Category:** Research\
**Tags:** risk-indifference, convex-optimization\
**Created:** [April 4, 2023, 6:18pm UTC](https://research.vest.xyz/t/optimal-liquidations-via-convex-optimization/201 "2023-04-04T18:18:09Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![max](https://avatars.discourse-cdn.com/v4/letter/m/e5b9ba/32.png) [@max](https://research.vest.xyz/u/max)\
**Post date:** [April 4, 2023, 6:18pm UTC](https://research.vest.xyz/t/optimal-liquidations-via-convex-optimization/201/1 "2023-04-04T18:18:09Z")

</div>

# TLDR

We propose a convex optimization approach for determining the optimal liquidation order in cross-margined AMM-based exchanges, minimizing the negative impact on exchange solvency.

# Motivation

Liquidation is crucial in maintaining an exchange’s solvency. In cross-margined exchanges, determining the optimal combination of liquidation orders can be complex. Current permissionless liquidation mechanisms in a competitive setting may not be ideal for AMM-based protocols.

# Problem Formalization
We simplify the problem with these assumptions:
1. Liquidations in the context of a risk-indifferent AMM
2. Liquidations are atomic operations executing at uniform prices within a block
3. No liquidation penalties or fees

We define an optimal liquidation order as the minimizer of the total notional amount liquidated while satisfying the maintenance margin and the risk-indifference invariant. We represent the liquidation of a portfolio as a convex optimization problem:

\begin{align\*} \min\_\mathbf{w}. \quad &(\mathbf{p} \otimes |\mathbf{q}\_i|)^T \mathbf{w} \\ \text{subject to} \quad &\mathbf{0} \preceq \mathbf{w} \preceq \mathbf{1} \\ & (r + \epsilon)(\mathbf{p}\otimes|\mathbf{q}\_i|)^T(\mathbf{1} - \mathbf{w}) \leq c\_i - \pi + \mathbf{q}\_i^T(\mathbf{p} - \mathbf{p}\_{i}) \\ &\pi = \rho(X(\mathbf{q}-\mathbf{w}\otimes \mathbf{q}\_i))-\rho(X(\mathbf{q})) \end{align\*}

See the full write-up [here](https://github.com/VestProtocol/papers/blob/main/Optimal_Liquidations_via_Convex_Optimization.pdf) for more details on the notation.

In words, the problem solves for an optimal partial liquidation for each position such that the portfolio’s margin post-liquidation (RHS of the second constraint) is at least the maintenance margin determined by total notional size post-liquidation (LHS of the second constraint). Note that if the problem is infeasible, the portfolio will be fully liquidated.

# Simulations

We use entropic value-at-risk with a confidence level of 0.99 and assume the price vector follows a normal distribution. We use GO-GARCH to forecast the covariance matrix. See our simulation code [here](https://github.com/VestProtocol/liquidation-cvx).

 ![bar](https://canada1.discourse-cdn.com/flex032/uploads/vest/original/1X/b7cd76626d76f24e0c9768ca9e7f46742415b90f.png)

 ![pie](https://canada1.discourse-cdn.com/flex032/uploads/vest/original/1X/f44e34679842aae654f327215ae8cb2fb1eabb65.png)

# Future Research

We can extend the framework to include liquidation penalties, although it may lead to more infeasible solutions and full liquidations.

# Questions

1. What alternative objectives could better reflect the needs for specific protocols?
2. Are there reward mechanisms that incentivize optimal liquidations in a decentralized setting (e.g. liquidation reward is maximized as the distance between the liquidation strategy and an optimal liquidation strategy is minimized)?

---

_[View the full topic](https://research.vest.xyz/t/optimal-liquidations-via-convex-optimization/201)._
