Liquidation
Last updated
Last updated
When a user's borrowings, including accrued interest, exceed their borrow limit, he will be liquidated. In other words, liquidations take place when a user's health factor falls below 1. The health factor is calculated using the following formula: During the liquidation process, liquidators repay a portion of the borrower's loan on their behalf in order to restore the borrower's health factor to a value greater than 1. The largest proportion of the loan repaid is determined by close factor, which by default is set at 50%. The close factor can be adjusted through governance.
In return for repaying the loan, liquidators receive a discounted amount of the borrower's collateral, represented by tToken.The formula to calculate the discounted tToken amount is as follows:
discounted tToken amount = repay amount * liquidation incentive * (price of borrowed token / price of collateral token) / exchange rate
The liquidators is then transferred tTokens, which they may redeem the same as if they had supplied the asset themselves. Now, liquidation incentive is 1.08.
function liquidateBorrow(address borrower, uint amount, address tTokenCollateral) returns (uint)
msg.sender:
The account which shall liquidate the borrower by repaying their debt and seizing their collateral.borrower: The account with a health factor less than 1 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.
tTokenCollateral:
The address of the tToken currently held as collateral by a borrower, that the liquidator shall seize.RETURN: 0 on success. Before supplying an asset, users must first approve the tToken to access their token balance.
function liquidateBorrow(address borrower, address tTokenCollateral) payable
msg.value:
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 a heath factor less than 1 that shall be liquidated.
tTokenCollateral:
The address of the tToken currently held as collateral by a borrower, that the liquidator shall seize.RETURN: No return, reverts on error.
// Instantiate an instance of the tEther contract with the specified addressITEther tEther = ITEther(0xTEther);
// Instantiate an instance of the tToken contract with the specified addressIErc20 tToken = ITToken(0xTToken);
// Repay the borrowed amount of tEther to liquidate the borrower and obtain collateraltEther.liquidateBorrow{value: repayAmount}(borrower, collateral);
// Repay the borrowed amount of tToken to liquidate the borrower and obtain collateraltToken.liquidateBorrow(borrower, repayAmount, collateral);
const tEther = TEther.at(0xTEther...);await tEther.methods.liquidateBorrow(borrower, collateral).send({from: myAccount, value: repayAmount};
const tToken = TErc20.at(0xTToken...);await tToken.methods.liquidateBorrow(borrower, repayAmount, collateral).send({from: myAccount});