MsgLiquidatePosition function to liquidate underwater positions.
Before proceeding, ensure you understand the following:
- Liquidation Mechanics: Injective employs a dynamic liquidation mechanism where positions exceeding a specific collateralization ratio (i.e. below threshold) become eligible for liquidation by any market participant. There are benefits for performing liquidations, which requires substantial upfront capital.
- MsgLiquidatePosition Function: This function allows traders to initiate liquidations on eligible positions, offering them an opportunity to capture a liquidation fee.
1) Position has Positive or Zero Equity
The position will be sold using a market order with a worst price equal to the bankruptcy price. The liquidator only needs to submit a limit order if the entire position cannot be liquidated using the bankruptcy price as the worst price. Benefits- Guaranteed zero loss to the insurance fund when position is not bankrupt.
- Existing orderbook liquidity is used and the liquidator still has an incentive to liquidate by getting a potential discount on the position up to bankruptcy (arbitrage).
- Taking over at bankruptcy price may not be attractive enough for liquidators, especially when the mark price is very close to the bankruptcy price.
- This concern is mitigated if one assumes there will always be at least one “white knight” liquidator, as there currently is on Injective.
| Quantity | Entry Price | Margin | Liquidation Price | Bankruptcy Price |
|---|---|---|---|---|
| 1 | 10 | 2 | 8.42 | 8 |
2) Position has Negative Equity
The position will be sold using a market order with a worst price equal to the oracle price. The liquidator only needs to submit a limit order if the entire position cannot be liquidated using the oracle price as the worst price. Benefits- The insurance fund will never suffer an uncontrollable loss from market selling the position at an extreme price. Instead the insurance fund only loses capital based on the oracle price movements.
- Similar to the positive equity case (but even worse), taking over the position at oracle price may not be attractive at all for liquidators, especially now since there is no implicit arbitrage. This can result in liquidations being delayed.
| Quantity | Entry Price | Margin | Liquidation Price | Bankruptcy Price |
|---|---|---|---|---|
| 1 | 10 | 2 | 8.42 | 8 |
-
Identify Liquidatable Positions: Utilize Injective’s
LiquidablePositionsendpoint to identify positions with a collateralization ratio below the liquidation threshold. Relevant data points include:- Collateral: Total value of tokens deposited as collateral for the position.
- Liabilities: Total value of borrowed tokens in the position.
- Liquidation Threshold: Minimum collateralization ratio required to avoid liquidation.
-
Prepare Liquidation Transaction: Construct an order transaction using the
MsgLiquidatePositionfunction, specifying the parameters listed in the API docs. While not compulsory, a limit transaction is highly recommended over a market transaction.
MsgLiquidatePosition function to participate in Injective’s liquidation mechanism and capture potential profit opportunities.