How to participate in the liquidations ecosystem

Yes, liquidations are open to anyone. Liquidators can develop their own solutions and bots to be the first ones liquidating loans to get the liquidation bonus.When the 'Health factor' of an account's total loans is below 1, anyone can make a liquidationCall() to the LendingPool contract, paying back part of the debt owed and receiving discounted collateral in return (also known as the liquidation bonus.)This incentivizes third parties to participate in the health of the overall protocol, by acting in their own interest (to receive the discounted collateral) and as a result, ensure loans are sufficiently collateralised.There are multiple ways to participate in liquidations:

  1. 1.By calling the liquidationCall() directly in the LendingPool contract.

  2. 2.By creating your own automated bot or system to liquidate loans.


When making a liquidationCall(), you must:

  • Know the account (i.e. the Telos EVM address: user) whose health factor is below 1.

  • Know the valid debt amount (debtToCover) and debt asset (debt) that can be paid.

    • The close factor is 0.5, which means that only a maximum of 50% of the debt can be liquidated per valid liquidationCall().

    • You can set the debtToCover to uint(-1) and the protocol will proceed with the highest possible liquidation allowed by the close factor.

    • You must already have a sufficient balance of the debt asset, which will be used by the liquidationCall() to pay back the debts.

  • Know the collateral asset (collateral) you are closing. I.e. the collateral asset that the user has 'backing' their outstanding loan that you will partly receive as a 'bonus'.

  • Whether you want to receive oTokens or the underlying asset (receiveOToken) after a successful liquidationCall().

1. Getting accounts to liquidate

Only user accounts that have a health factor below 1 can be liquidated. There are multiple ways you can get the health factor, with most of them involving 'user account data'."Users" in the OmniLend Protocol refer to a single Telos EVM address that has interacted with the protocol. This can be an externally owned account or contract.


  1. 1.To gather user account data from on-chain data, one way would be to monitor emitted events from the protocol and keep an up to date index of user data locally.

    1. 1.Events are emitted each time a user interacts with the protocol (deposit, repay, borrow, etc). See the contract source code for relevant events.

  2. 2.When you have the user's address, you can simply call getUserAccountData() to read the user's current healthFactor. If the healthFactor is below 1, then the account can be liquidated.


A similar call can be made with a package such as Web3.js/ The account making the call must already have at least the debtToCover of debt.

import UsdcTokenABI from "./USDCtoken.json"
import LendingPoolAddressesProviderABI from "./LendingPoolAddressesProvider.json"
import LendingPoolABI from "./LendingPool.json"

// ... The rest of your code ...

// Input variables
const collateralAddress = 'THE_COLLATERAL_ASSET_ADDRESS'
const usdcAmountInWei = web3.utils.toWei("1000", "ether").toString()
const usdcAddress = '0x818ec0a7fe18ff94269904fced6ae3dae6d6dc0b' // mainnet USDC
const user = 'USER_ACCOUNT'
const receiveOTokens = true

const lpAddressProviderAddress = '0x87F27B0DEE1Fd97A60dD5e5436c8068b805770E4' // mainnet
const lpAddressProviderContract = new web3.eth.Contract(LendingPoolAddressesProviderABI, lpAddressProviderAddress)

// Get the latest LendingPool contract address
const lpAddress = await lpAddressProviderContract.methods
    .catch((e) => {
        throw Error(`Error getting lendingPool address: ${e.message}`)

// Approve the LendingPool address with the USDC contract
const usdcContract = new web3.eth.Contract(USDCTokenABI, usdcAddress)
await usdcContract.methods
    .catch((e) => {
        throw Error(`Error approving USDC allowance: ${e.message}`)

// Make the deposit transaction via LendingPool contract
const lpContract = new web3.eth.Contract(LendingPoolABI, lpAddress)
await lpContract.methods
    .catch((e) => {
        throw Error(`Error liquidating user with error: ${e.message}`)

You can find the relevant ABIs for liquidations here.

3. Setting up a bot

Depending on your environment, preferred programming tools and languages, your bot should:

  • Ensure it has enough (or access to enough) funds when liquidating.

  • Calculate the profitability of liquidating loans vs gas costs, taking into account the most lucrative collateral to liquidate.

  • Ensure it has access to the latest protocol user data.

  • Have the usual fail-safes and security you'd expect for any production service.

Calculating profitability vs gas cost

One way to calculate the profitability is the following:

  1. Store and retrieve each collateral's relevant details such as an address, decimals used, and liquidation bonus as listed here.

  2. Get the user's collateral balance (oTokenBalance).

  3. Get the asset's price according to the OmniLend oracle contract(getAssetPrice()).

  4. The maximum collateral bonus you can receive will be the collateral balance (2) multiplied by the liquidation bonus (1) multiplied by the collateral asset's price in TLOS (3). Note that for assets such as USDC, the number of decimals are different from other assets.

  5. The maximum cost of your transaction will be your gas price multiplied by the amount of gas used. You should be able to get a good estimation of the gas amount used by calling estimateGas via your web3 provider.

  6. Your approximate profit will be the value of the collateral bonus (4) minus the cost of your transaction (5).


How is health factor calculated?

The health factor is calculated from: the user's collateral balance (in TLOS) multiplied by the current liquidation threshold for all the user's outstanding assets, divided by 100, divided by the user's borrow balance and fees (in TLOS).

This can be both calculated off-chain and on-chain, see GenericLogic library contract to see how it is calculated on-chain.

How is the liquidation bonus determined?

At the moment, liquidation bonuses are evaluated and determined by the risk team based on liquidity risk.

This will change in the future with OmniLend Protocol Governance.

Last updated