Liquidate Position

Liquidating unhealthy positions.

Liquidator can liquidate a position if its health factor falls below 1 (unhealthy). The liquidator pays some position debt and, in return, receives inToken from the position's collateral. Liquidation can be partial – partially repays the debt and receives a portion of the position's collateral.

Liquidation incentive differs for each pair of repaid debt token and inToken to receive.

A position can only be liquidated up to a certain health factor to prevent over-liquidation. After the liquidation, the position's health factor cannot be over MAX_HEALTH_AFTER_LIQ.

// Example liquidate function
function liquidate(uint256 posId, address lendingPoolToRepay, uint256 repayShares, address lendingPoolCollateralToReceive, uint256 minInCollateralTokenOut) external {
    // 0. .. pull repay tokens from the caller ..
    
    // 1. approve repay tokens to InitCore
    IERC20(lendingPoolToRepay).safeApprove(INIT_CORE, repayShares);

    // 2. liquidate
    IInitCore(INIT_CORE).liquidate(posId, lendingPoolToRepay, repayShares, lendingPoolCollateralToReceive, minInCollateralTokenOut);
}

Last updated