📚
INIT Capital Developer Docs
  • Overview
  • Core Contracts
  • Guides
    • Basic Interaction
      • Deposit and Withdraw
      • Create Position
      • Add and Remove Collateral
      • Borrow and Repay
      • Changing Position Mode
    • Advanced Interaction
      • Liquidate Position
      • Flashloan
      • Multicall
      • Callback
    • Liquidity Hook
      • Multicall with Callback
      • Money Market Hook
      • Looping Hook
      • Margin Trading Hook
  • Contract References
    • InitCore
    • PosManager
    • LendingPool
    • Config
    • RiskManager
    • InitOracle
    • LiqIncentiveCalculator
    • DoubleSlopeIRM
    • InitErrors
    • MoneyMarketHook
    • LoopingHook
    • MarginTradingHook
  • Contract Addresses
    • Blast
    • Mantle
Powered by GitBook
On this page
  1. Guides
  2. Advanced Interaction

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);
}
PreviousAdvanced InteractionNextFlashloan

Last updated 1 year ago