GammaSwap Docs
Search
K

How Liquidations Work

Liquidating under collateralized loans
Liquidations occur when the Liquidity Debt of a loan exceeds the Liquidity Collateral beyond the Liquidation Threshold of 99.5%.

Liquidation Threshold

Since the liquidation threshold LTV ratio is 99.5%, then liquidation happens when the liquidity loan is greater than the liquidity collateral multiplied by 99.5%.
liquidity debt > liquidity collateral * LTV_threshold
This threshold can be modified when opening a leveraged perpetual trade in the platform.

Liquidation Penalty

The penalty paid to the liquidator is the remaining collateral. For example, if liquidation happened right at the point that the liquidity debt crossed the liquidity collateral * LTV_Threshold and the LTV_Threshold is 99.5%, that means the liquidation penalty fee is 0.5% of the liquidity collateral.
The penalty fee will never be lower than 0.25% of the liquidity collateral. Therefore if there's less than 0.25% available as collateral after paying for the liquidity debt, then the rest of the debt is written down and passed as a loss to LPs.
Liquidation Penalty = max{collateral * penalty fee, collateral - liquidity debt}

Liquidation Functions

Liquidation functions are called directly from the GammaPool contract. They are not available to be called from the periphery (PositionManager) contract.
liquidateWithLP(uint256 tokenId) - the tokenId refers to the loan that is subject to liquidation. The liquidator must first pass the LP Tokens required to pay the debt either partially or in full. That means that the collateral tokens of the loan are not used. If an excessive amount of LP tokens are passed, the excess amount is refunded to the liquidator. The liquidator receives the collateral, which is in reserve tokens.
liquidate(uint256 tokenId, int256[] calldata deltas) - the tokenId refers to the loan that is subject to liquidation. The liquidator can use the collateral tokens of the loan to liquidate with this function. A loan can only be liquidated in full with this function. Therefore, if the collateral is deficient on one side to retrieve the required LP token, the liquidator can use the delta's array to rebalance the position. Optionally, the liquidator can also deposit reserve tokens to rebalance the position so that he can retrieve the required LP Token debt. The liquidator receives the remaining collateral of the loan. If the liquidator deposited collateral in excess, he will receive back this excess collateral too.
batchLiquidations(uint256[] calldata tokenIds) - the tokenIds of loans to be liquidated are passed in this function. The purpose of this function is to liquidate multiple loans at the same time. There may be occasions where a loan is not economically viable to liquidate on its own due to transaction fees, but in batch it is economically feasible to liquidate. The liquidator must pass the required amount of LP Tokens to pay for the debts of all the loans that are to be liquidated. All loans must be liquidated in full. If an excess amount of LP tokens is passed, this excess amount will be refunded to the liquidator. The liquidator receives the collateral of the loans that are to be liquidated.