MCDEX
Search…
Liquidate
This guide shows how to liquidate by using the ILiquidityPoolFull interface.

Liquidate by trader

Function

function liquidateByTrader(uint256 perpetualIndex, address liquidator, address trader, int256 amount, int256 limitPrice, uint256 deadline)
parameters
type
description
perpetualIndex
uint256
index of perpetual in the liquidity pool
liquidator
address
address of liquidator to receive the liquidated position
trader
address
address of trader to be liquidated
amount
int256
amount of position to be taken from liquidated trader. The amount always use decimals 18
limitPrice
int256
worst price liquidator accepts
deadline
uint256
deadline of transaction (unix timestamp)
Return information
returns
type
description
liquidationAmount
int256
amount of positions actually liquidated in the transaction

Example

WARN: before calling getLiquidityPoolInfo(), need to sync the state by using the forceToSyncState function.
1
ILiquidityPoolFull liquidityPool = ILiquidityPoolFull(liquidityPoolAddress)
2
liquidityPool.forceToSyncState()
3
liquidityPool.liquidateByTrader(perpetualIndex, liquidator, trader, amount, limitPrice, deadline)
Copied!

Sample Code

Github
Last modified 14d ago