Liquidate Borrow

A user who has negative account liquidity is subject to liquidation by other users of the protocol to return his/her account liquidity back to positive (i.e. above the collateral requirement). When a liquidation occurs, a liquidator may repay some or all of an outstanding borrow on behalf of a borrower and in return receive a discounted amount of collateral held by the borrower; this discount is defined as the liquidation incentive.

A liquidator may close up to a certain fixed percentage (i.e. close factor) of any individual outstanding borrow of the underwater account. Unlike in v1, liquidators must interact with each bToken contract in which they wish to repay a borrow and seize another asset as collateral. When collateral is seized, the liquidator is transferred bTokens, which they may redeem the same as if they had supplied the asset themselves. Users must approve each bToken contract before calling liquidate (i.e. on the borrowed asset which they are repaying), as they are transferring funds into the contract.

BErc20

function liquidateBorrow(address borrower, uint amount, address collateral) returns (uint)
  • msg.sender: The account which shall liquidate the borrower by repaying their debt and seizing their collateral.

  • borrower: The account with negative account liquidity that shall be liquidated.

  • repayAmount: The amount of the borrowed asset to be repaid and converted into collateral, specified in units of the underlying borrowed asset.

  • bTokenCollateral: The address of the bToken currently held as collateral by a borrower, that the liquidator shall seize.

  • RETURN: 0 on success, otherwise an Error code

Before supplying an asset, users must first approve the bToken to access their token balance.

CEther

function liquidateBorrow(address borrower, address bTokenCollateral) payable
  • msg.value [payable]: The amount of ether to be repaid and converted into collateral, in wei.

  • msg.sender: The account which shall liquidate the borrower by repaying their debt and seizing their collateral.

  • borrower: The account with negative account liquidity that shall be liquidated.

  • bTokenCollateral: The address of the bToken currently held as collateral by a borrower, that the liquidator shall seize.

  • RETURN: No return, reverts on error.

Solidity

CEther bToken = CEther(0x3FDB...);
BErc20 bTokenCollateral = BErc20(0x3FDA...);
require(bToken.liquidateBorrow.value(100)(0xBorrower, bTokenCollateral) == 0, "borrower underwater??");

Web3 1.0

const bToken = BErc20.at(0x3FDA...);
const bTokenCollateral = CEther.at(0x3FDB...);
await bToken.methods.liquidateBorrow(0xBorrower, 33, bTokenCollateral).send({from: 0xLiquidator});

Last updated