Design Notes Calculating Liquidation This page describes how liquidation trade parameters are calculated by a liquidator
The Challenge
When an account appears in margin call state, a liquidation trade could be initiated by a liquidator. Such trade has several important restrictions, so the liquidator needs to calculate peroper trade parameters in order to make the protocol not to reject the trade.
No Write-off Case
In this section a normal, i.e. no write-off, liquidation is considered.
Let's assume that the j -th j\text{-th} j -th account is in margin call state, its position in the i 1 -th i_1\text{-th} i 1 -th asset is long, and its position in the i 2 -th i_2\text{-th} i 2 -th asset is short:
μ j < 0 v i 1 , j > 0 v i 2 , j < 0 \begin{array}{rcl}
\mu_j & < & 0 \\
v_{i_1,j} & > & 0 \\
v_{i_2, j} & < & 0
\end{array} μ j v i 1 , j v i 2 , j < > < 0 0 0 During the liquidation trade, the liquidator sells the x i 1 x_{i_1} x i 1 amount of the i ! -th i_!\text{-th} i ! -th asset for the x i 2 x_{i_2} x i 2 amount of the i 2 -th i_2\text{-th} i 2 -th asset.
Here a no write-off case is considered:
p i 1 x i 1 ν j + ⩽ ( 1 − ϕ b ) p i 2 x i 2 ν j − \frac{p_{i_1}x_{i_1}}{\nu^+_j} \leqslant \frac{(1 - \phi_b)p_{i_2}x_{i_2}}{\nu^-_j} ν j + p i 1 x i 1 ⩽ ν j − ( 1 − ϕ b ) p i 2 x i 2 The trade price p p p is:
p = x i 2 ( 1 − ϕ s ) x i 1 ≈ p i 1 p i 2 p = \frac{x_{i_2}}{(1 - \phi_s)x_{i_1}} \approx \frac{p_{i_1}}{p_{i_2}} p = ( 1 − ϕ s ) x i 1 x i 2 ≈ p i 2 p i 1 The approximation sign is here, because the asset prices p i 1 p_{i_1} p i 1 and p i 2 p_{i_2} p i 2 are obtained from price oracles and may be slightly differ from the actual market prices. Thus:
x i 2 ≈ ( 1 − ϕ s ) p i 1 x i 1 p i 2 x_{i_2} \approx \frac{(1 - \phi_s)p_{i_1}x_{i_1}}{p_{i_2}} x i 2 ≈ p i 2 ( 1 − ϕ s ) p i 1 x i 1 The liquidation trade is restricted by the following constraints:
v i 1 , j ′ = v i 1 , j − x i 1 ⩾ 0 v i 2 , j ′ = v i 2 , j + ( 1 − ϕ b ) x i 2 ⩽ 0 μ j ′ = μ j − p i 1 x i 1 1 + m i 1 + ( 1 + m i 2 ) ( 1 − ϕ b ) p i 2 x i 2 ⩽ 0 \begin{array}{rcccl}
v'_{i_1,j} & = & v_{i_1,j} - x_{i_1} & \geqslant & 0 \\[1em]
v'_{i_2,j} & = & v_{i_2,j} + (1 - \phi_b)x_{i_2} & \leqslant & 0 \\[1em]
\mu'_j & = & \mu_j - \frac{p_{i_1} x_{i_1}}{1 + m_{i_1}} + (1 + m_{i_2})(1 - \phi_b)p_{i_2} x_{i_2} & \leqslant & 0
\end{array} v i 1 , j ′ v i 2 , j ′ μ j ′ = = = v i 1 , j − x i 1 v i 2 , j + ( 1 − ϕ b ) x i 2 μ j − 1 + m i 1 p i 1 x i 1 + ( 1 + m i 2 ) ( 1 − ϕ b ) p i 2 x i 2 ⩾ ⩽ ⩽ 0 0 0 By substituting the approximated expression for x i 2 x_{i_2} x i 2 we have:
v i 1 , j − x i 1 ⩾ 0 v i 2 , j + ( 1 − ϕ b ) ( 1 − ϕ s ) p i 1 x i 1 p i 2 ≲ 0 μ j − p i 1 x i 1 1 + m i 1 + ( 1 + m i 2 ) ( 1 − ϕ b ) p i 2 ( 1 − ϕ s ) p i 1 x i 1 p i 2 ≲ 0 \begin{array}{rcl}
v_{i_1,j} - x_{i_1} & \geqslant & 0 \\[1em]
v_{i_2,j} + (1 - \phi_b)\frac{(1 - \phi_s)p_{i_1}x_{i_1}}{p_{i_2}} & \lesssim & 0 \\[1em]
\mu_j - \frac{p_{i_1} x_{i_1}}{1 + m_{i_1}} + (1 + m_{i_2})(1 - \phi_b)p_{i_2} \frac{(1 - \phi_s)p_{i_1}x_{i_1}}{p_{i_2}} & \lesssim & 0
\end{array} v i 1 , j − x i 1 v i 2 , j + ( 1 − ϕ b ) p i 2 ( 1 − ϕ s ) p i 1 x i 1 μ j − 1 + m i 1 p i 1 x i 1 + ( 1 + m i 2 ) ( 1 − ϕ b ) p i 2 p i 2 ( 1 − ϕ s ) p i 1 x i 1 ⩾ ≲ ≲ 0 0 0 and then:
x i 1 ⩽ v i 1 , j x i 1 ≲ − p i 2 v i 2 , j ( 1 − ϕ s ) ( 1 − ϕ b ) p i 1 x i 1 ≲ ( 1 + m i 1 ) μ j p i 1 ( 1 − ( 1 + m i 1 ) ( 1 + m i 2 ) ( 1 − ϕ s ) ( 1 − ϕ b ) ) \begin{array}{rcl}
x_{i_1} & \leqslant & v_{i_1,j} \\[1em]
x_{i_1} & \lesssim & \frac{-p_{i_2}v_{i_2,j}}{(1 - \phi_s)(1 - \phi_b)p_{i_1}} \\[1em]
x_{i_1} & \lesssim & \frac{(1 + m_{i_1})\mu_j}{p_{i_1}\left( 1 - (1 + m_{i_1})(1 + m_{i_2})(1 - \phi_s)(1 - \phi_b) \right)}
\end{array} x i 1 x i 1 x i 1 ⩽ ≲ ≲ v i 1 , j ( 1 − ϕ s ) ( 1 − ϕ b ) p i 1 − p i 2 v i 2 , j p i 1 ( 1 − ( 1 + m i 1 ) ( 1 + m i 2 ) ( 1 − ϕ s ) ( 1 − ϕ b ) ) ( 1 + m i 1 ) μ j In order to satisfy these requirements, the liquidator chooses the x i 1 x_{i_1} x i 1 value like this:
x i 1 = min ( v i 1 , j , − ( 1 − ε ) p i 2 v i 2 , j ( 1 − ϕ s ) ( 1 − ϕ b ) p i 1 , ( 1 − δ ) ( 1 + m i 1 ) μ j p i 1 ( 1 − ( 1 + m i 1 ) ( 1 + m i 2 ) ( 1 − ϕ s ) ( 1 − ϕ b ) ) ) x_{i_1} = \min \left( v_{i_1,j}, \frac{-(1 - \varepsilon)p_{i_2}v_{i_2,j}}{(1 - \phi_s)(1 - \phi_b)p_{i_1}}, \frac{(1 - \delta)(1 + m_{i_1})\mu_j}{p_{i_1} \left( 1 - (1 + m_{i_1})(1 + m_{i_2}) (1 - \phi_s)(1 - \phi_b) \right)} \right) x i 1 = min ( v i 1 , j , ( 1 − ϕ s ) ( 1 − ϕ b ) p i 1 − ( 1 − ε ) p i 2 v i 2 , j , p i 1 ( 1 − ( 1 + m i 1 ) ( 1 + m i 2 ) ( 1 − ϕ s ) ( 1 − ϕ b ) ) ( 1 − δ ) ( 1 + m i 1 ) μ j ) Here ε \varepsilon ε and δ \delta δ are small positive numbers, empirically chosen to address imperfection of the asset prices obtained from price oracles.
Write-off Case
In this case a write-off case is considered:
p i 1 x i 1 ν j + > ( 1 − ϕ b ) p i 2 x i 2 ν j − \frac{p_{i_1}x_{i_1}}{\nu^+_j} > \frac{(1 - \phi_b)p_{i_2}x_{i_2}}{\nu^-_j} ν j + p i 1 x i 1 > ν j − ( 1 − ϕ b ) p i 2 x i 2 In such case the constraits are:
v i 1 , j ′ = v i 1 , j − x i 1 ⩾ 0 v i 2 , j ′ = v i 2 , j + p i 1 x i 1 ν j − p i 2 ν j + ⩽ 0 μ j ′ = μ j − p i 1 x i 1 1 + m i 1 + ( 1 + m i 2 ) p i 1 x i 1 ν j − ν j + ⩽ 0 \begin{array}{rcccl}
v'_{i_1,j} & = & v_{i_1,j} - x_{i_1} & \geqslant & 0 \\[1em]
v'_{i_2,j} & = & v_{i_2,j} + \frac{p_{i_1}x_{i_1}\nu^-_j}{p_{i_2}\nu^+_{j}} & \leqslant & 0 \\[1em]
\mu'_j & = & \mu_j - \frac{p_{i_1} x_{i_1}}{1 + m_{i_1}} + (1 + m_{i_2}) \frac{p_{i_1}x_{i_1}\nu^-_j}{\nu^+_{j}} & \leqslant & 0
\end{array} v i 1 , j ′ v i 2 , j ′ μ j ′ = = = v i 1 , j − x i 1 v i 2 , j + p i 2 ν j + p i 1 x i 1 ν j − μ j − 1 + m i 1 p i 1 x i 1 + ( 1 + m i 2 ) ν j + p i 1 x i 1 ν j − ⩾ ⩽ ⩽ 0 0 0 And then:
x i 1 ⩽ v i 1 , j x i 1 ⩽ − p i 2 v i 2 , j ν j + p i 1 ν j − x i 1 ⩽ ( 1 + m i 1 ) μ j ν j + p i 1 ( ν j + − ( 1 + m i 1 ) ( 1 + m i 2 ) ν j − ) \begin{array}{rcl}
x_{i_1} & \leqslant & v_{i_1,j} \\[1em]
x_{i_1} & \leqslant & \frac{-p_{i_2}v_{i_2,j}\nu^+_{j}}{p_{i_1}\nu^-_j} \\[1em]
x_{i_1} & \leqslant & \frac{(1 + m_{i_1})\mu_j\nu^+_{j}}{p_{i_1} \left( \nu^+_{j} - (1 + m_{i_1})(1 + m_{i_2}) \nu^-_j \right)}
\end{array} x i 1 x i 1 x i 1 ⩽ ⩽ ⩽ v i 1 , j p i 1 ν j − − p i 2 v i 2 , j ν j + p i 1 ( ν j + − ( 1 + m i 1 ) ( 1 + m i 2 ) ν j − ) ( 1 + m i 1 ) μ j ν j + So the liquidator choses the x i 1 x_{i_1} x i 1 amout like this:
x i 1 = min ( v i 1 , j , − p i 2 v i 2 , j ν j + p i 1 ν j − , ( 1 + m i 1 ) μ j ν j + p i 1 ( ν j + − ( 1 + m i 1 ) ( 1 + m i 2 ) ν j − ) ) x_{i_1} = \min \left(
v_{i_1,j},
\frac{-p_{i_2}v_{i_2,j}\nu^+_{j}}{p_{i_1}\nu^-_j},
\frac{(1 + m_{i_1})\mu_j\nu^+_{j}}{p_{i_1} \left( \nu^+_{j} - (1 + m_{i_1})(1 + m_{i_2}) \nu^-_j \right)} \right) x i 1 = min ( v i 1 , j , p i 1 ν j − − p i 2 v i 2 , j ν j + , p i 1 ( ν j + − ( 1 + m i 1 ) ( 1 + m i 2 ) ν j − ) ( 1 + m i 1 ) μ j ν j + )