How is liquidation price calculated?Last Updated: September 23, 2019
The entry price is the current price of the position token, while the exit price is the price of your position currency at which your trade will get liquidated, assuming the market currency price and margin deposit currency price remains unchanged, stop loss is at 80%, trade duration is 30 days and margin deposit is 1 ETH.
You can see the entry price and exit price on the graph, and it would be accessible to you while you place your trade.
Every trade has a Safe Region, Critical Region, and a Hard Stop. The system continuously monitors active trades to figure out when they need to be auto-liquidated. A trade, in Safe Region, cannot be auto-liquidated while a trade in Critical Region can be liquidated by one of the multiple relayers tracking active trades in order to liquidate them. Hard Stop denotes the final point after which the borrower will lose more collateral than he committed once the trade stops.
Critical region for a trade is defined by the following inequality.
collateral_currency_price * collateral_amount * stoploss <= (loan_currency_price * loan_amount * (100 + premium + buffer/initial_leverage) - trade_currency_price * trade_amount * 100)
Buffer is set at 10-15% for margin-trades depending on the token involved in the trade. You can check what is the buffer being used while creating your trade.
A trade with 1ETH collateral and 3x leverage are placed at 1% premium for 1 week at 40% stop-loss. Loan currency = DAI and trade currency = WBTC (short DAI long WBTC).
The trade was placed using best rates on partner exchanges in realtime such that
collateral amount = 1ETH,
loan amount at 3x leverage = 750DAI (@250DAI/ETH),
trade amount = 0.1WBTC (@7500DAI/WBTC)
Lets look at 2 instances in time to see if a stoploss would be triggered. Using above inequality (currency prices are with respect to DAI), we get:
T1: 1ETH = 300DAI, 1WBTC = 8000DAI
=> (300) * 1 * 40 <= (1) * 750 * (100 + 1 + 5/3)
- (8000) * 0.1 * 100
=> 12000 <= 77000 - 80000
T2: 1ETH = 200DAI, 1WBTC = 6000DAI
=> (200) * 1 * 40 <= (1) * 750 * (100 + 1 + 5/3) - (6000) * 0.1 * 100
=> 8000 <= 77000 - 60000
T1 represents a trade is Safe Region and wont be liquidated while T2 represents a trade in Critical Region and will be liquidated by workers.
This buffer prevents lenders from losing money in a volatile market by pushing a trade in critical region for on-chain liquidations to happen just before prices drop to the hard stop. Buffer is market dependent and can increase with increasing volatility in crypto markets.