PrimaryLendingPlatformLiquidation

Overview

License: MIT

contract PrimaryLendingPlatformLiquidation is PrimaryLendingPlatformLiquidationCore

The PrimaryLendingPlatformLiquidation contract is the contract that allows users to liquidate positions.

Contract that allows users to liquidate positions. Inherit from PrimaryLendingPlatformLiquidationCore.

Functions info

liquidate (0xaab3f868)

function liquidate(
    address _account,
    address _projectToken,
    address _lendingToken,
    uint256 _lendingTokenAmount
)
    external
    isProjectTokenListed(_projectToken)
    isLendingTokenListed(_lendingToken)
    nonReentrant

Liquidates a user's position based on the specified lending token amount.

The function to be called when a user wants to liquidate their position.

Requirements:

  • The project token is listed on the platform.

  • The lending token is listed on the platform.

  • The lending token amount must be greater than 0.

  • The user must have a position for the given project token and lending token.

  • The health factor must be less than 1.

  • _lendingTokenAmount must be within the permissible range of liquidation amount.

Effects:

  • Calculates the health factor of the position using getCurrentHealthFactor function.

  • Validates the health factor and ensures it's less than 1.

  • Calculates the permissible liquidation range using getLiquidationAmount function.

  • Validates lendingTokenAmount against the permissible range.

  • Determines the amount of project token to send to the liquidator.

  • Distributes rewards to the liquidator.

Parameters:

NameTypeDescription

_account

address

The address of the borrower

_projectToken

address

The address of the project token

_lendingToken

address

The address of the lending token

_lendingTokenAmount

uint256

The amount of lending tokens to be used for liquidation

liquidateFromModerator (0xfc879bcb)

function liquidateFromModerator(
    address _account,
    address _projectToken,
    address _lendingToken,
    uint256 _lendingTokenAmount,
    address liquidator
)
    external
    isProjectTokenListed(_projectToken)
    isLendingTokenListed(_lendingToken)
    onlyRelatedContracts
    nonReentrant
    returns (uint256)

Liquidates a user's position based on the specified lending token amount, called by a related contract.

Requirements:

  • The project token is listed on the platform.

  • The lending token is listed on the platform.

  • Called by a related contract.

  • The lending token amount must be greater than 0.

  • The user must have a position for the given project token and lending token.

  • The health factor must be less than 1.

  • _lendingTokenAmount must be within the permissible range of liquidation amount.

Effects:

  • Calculates the health factor of the position using getCurrentHealthFactor function.

  • Validates the health factor and ensures it's less than 1.

  • Calculates the permissible liquidation range using getLiquidationAmount function.

  • Validates lendingTokenAmount against the permissible range.

  • Determines the amount of project token to send to the liquidator.

  • Distributes rewards to the liquidator.

Parameters:

NameTypeDescription

_account

address

The address of the borrower

_projectToken

address

The address of the project token

_lendingToken

address

The address of the lending token

_lendingTokenAmount

uint256

The amount of lending tokens to be used for liquidation

liquidator

address

The address of the liquidator

Return values:

NameTypeDescription

[0]

uint256

The amount of project tokens received by the liquidator

Last updated