By generating stablecoins in response to a user posting collateral, the way Equilibrium operates allows for leverage. Consider this example: given a current collateralization ratio (СR) of 130%, when a user deposits X dollars of EOS, the maximum dollar amount of EOSDT he may generate is X / CR. This EOSDT may be then used to buy additional EOS, which can in turn be used as additional collateral to generate more EOSDT — you get the idea!
You might remember the idea of an infinite geometric series from middle school geometry. But do you remember the formula for its sum when the common ratio R is less than one? In our case R = 1 / CR, so the maximum theoretical achievable leverage L is equal to: 1/(1-1/CR)
The following table shows the maximum achievable leverage given a level of collateralization:
Critical collateralization ratio (CR)
Maximum possible leverage
With current system parameters, users can enjoy a maximum leverage around 4.33. This is of course the theoretical maximum — in reality, the numbers will be lower as it’s unreasonable to collateralize the position around the critical level. There has to be some safety margin above 130%.
From the user’s perspective, the mechanism works the following way:
The user picks the desired safety margin (SM).
Based on the SM, the user is offered a choice of leverage (L) from 1 to L_max, where L_max = 1/(1-1/(CR + SM)).
The user supplies X amount of EOS.
To achieve desired leverage L, the system needs to buy (1 - L) * X EOS on the exchange. This may be done in several iterations in the loop according to the following algo:
generate X * oracle price / (CR + SM) EOSDTamount_to_buy = (L-1)*X EOSwhile amount_to_buy >= 0buy Q EOS on exchangedeposit Q EOS to eosdtcntractgenerate Q * Oracle price / (CR + SM) EOSDTamount_to_buy = amount_to_buy - Qend
All the above logic is implemented within a new contract called eosdtlevrage.
ID of the operation, PK.
The ratio of EOS collateral to EOST generated for a given position_id.
The amount of EOS necessary to buy in order to achieve desired leverage (see the algo above). Changes on every loop iteration. Initially calculated using rates from eosdtoracliz.orarates
actual amount of EOS received from DEX when generated EOSDT was sold. used in actual leverage calculations.
deposit deposit EOS to the eosdtlevrage contract, specifying desired leverage L and safety margin (SM)
When missing signature of caller.
When L 1/(1- 1/(critical_ltv + safety_margin).
When SM= critical_ltv.
When there is not enough liquidity on DEX on any of the loop iterations.