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 + β β )