Fast check proof
In this article, we prove the safety of fast checks to ensure protocol overcollateralization.
Assumptions
-
Health factor Hf is more than 1
-
Credit account has debt (loan plus interest) D and c1 units of asset 1. It's liquidity threshold is LT1, price p1.
-
Liquidation thresholds are calculated for both assets as
LT=1−dP−fL−fp,
where dP is max price drop during liquidation time, fL - liquidation fee (goes to liquidator), fp - liquidation premium (goes to DAO treasury).
-
User swaps Δc1 units of asset 1 to Δc2 asset 2 with liquidation threshold LT2 and price p2.
-
During swap protocol calculates fast check
1−LT1Δc1p1LT2Δc2p2≤fp
and allows trade if and only if fast check is successful
- Gearbox is enough overcollateralized if in case of liquidation protocol can ensure repaying debt D and paying liquidation fee fLD.
Problem formalization / Theorem
To ensure Gearbox protocol's overcollateralization after a financial transaction, it is enough to perform fast checks.
Proof
Our theorem can be written as optimization problem:
Let's define
V=Δc1∈[0,c1],Δc2≥0,dp∈[0,dP2]min{(c1−Δc1)p1+Δc2p2(1−dp)}
as Credit Account's Total Value after trade. Here dp means possible price drop during swap (or immediately after it).
It is necessary to proof that V≥D/(1−fL) under conditions of described in Assumptions section. If this equation is true, than gearbox has enough overcollaterization even in case of liquidations happens next.
Let's find minimum for V equation. We can find minimum using linear programming methods:
V=Δc1∈[0,c1]min{c1p1−Δc1p1+(1−fp)(1−dP2)Δc1p1LT2LT1}:
-
If (1−fp)(1−dP2)LT2LT1>1, then minimum is reached at Δc1=0. In this case system stays overcollateralized as there is no any trades/actions.
-
If (1−fp)(1−dP2)LT2LT1=1, then V=c1p1. Taking into account that at start health factor Hf≥1 we get V=c1p1=DHf/LT1≥D/LT1≥D/(1−dP1−fp−fL)≥D/(1−fL), so system is overcollateralized.
-
If (1−fp)(1−dP2)LT2LT1<1, then Δc1=c1 and
V=(1−fp)(1−dP2)c1p1LT2LT1=(1−fp)(1−dP2)LT2DHf
Let's compare this equation with D/(1−fL):
(1−fp)(1−dP2)LT2DHf⋀1−fLD
Which is equal to
(1−fp)(1−fL)(1−dP2)Hf⋀1−dP2−fp−fL
As Hf≥1 and
(1−fp−fL+fpfL)−dP2(1−fp−fL+fpfL)≥1−dP2−fp−fL
(as
fpfL+dP2(fp+fL−fpfL)≥0
for any fp,fL∈[0,1]), we get that
So we get that for case 3 inequality V≥D/(1−fL) is also true.
Then this inequality is true for all cases and system is always overcollateralized.