Understanding the Liquidation Process in the Cross-Chain Lending Protocol


Understanding these functions is essential for developers interacting with Pike protocol.

Hub Contract on Base

 * @notice Calculates and returns the health factor for a given borrower.
 * @dev The health factor is calculated similar to Aave as the ratio of the total value of the borrower's collateral
 * to the total value of the borrower's borrowings. It is used to assess the riskiness of the borrower's position.
 * If the health factor is below 1, it means that the borrower's position is undercollateralized and can be liquidated.
 * @param borrower The address of the borrower whose health factor is to be calculated.
 * @return healthFactor The health factor of the borrower, scaled by 1e18.
function getHealthFactor(address borrower)
    payable // for pyth testnet 1 wei update
    returns (uint256 healthFactor);
event HealthFactorUpdated(address indexed borrower, uint256 healthFactor);

Spoke Contract on Base

 * @notice Initiates the liquidation process for a borrower's position
 * @param chainId ID of the chain where the borrower's position is held
 * @param borrower Address of the borrower whose position is being liquidated
 * @param repayAmount Amount the liquidator is repaying on behalf of borrower
 * @dev repayAmount should be equal to the amount of value sent with the call
function liquidate(
    uint16 chainId,
    address borrower,
    uint256 repayAmount

Contract deploys

Base contract addresses for interaction are listed at Protocol Contracts. Also, you can find extended description with respective ABI files in JSON format at Contract Overview.

Liquidation flow description

When a borrower defaults or fails to meet their loan obligations, a liquidation bot can initiate the liquidation process via the relevant Spoke contract. This contract constructs and encodes a message payload, which is then sent to the Hub contract through the Gateway contract by means of the Wormhole relayer on that chain.

Upon receiving the liquidation request, the Hub contract validates it, carries out necessary checks, and calculates the reward for the liquidator. It also updates the global state to reflect the changes brought about by the liquidation.

The Hub contract then creates a confirmation message, encodes it, and sends it back to the Spoke contract. Upon receipt, the Spoke contract performs additional checks and transfers the liquidation reward to the wallet address that initiated the liquidation process.

Last updated