🤖Running a Liquidator Bot

Guide on setting up a liquidator bot to participate in the open-source liquidation process

Background & Reference

Echelons liquidation accounting is inspired by Compound V2, so most Compound V2 concepts apply.

How Liquidations work on Echelon

A vault is composed of collaterals and liabilities.

A vault becomes liquidatable when:

- 100% > health factor = borrowing power / liability value.

- borrowing power = sum(collateral value * collateral factor (AKA max LTV)).

- let's say the vault has $10k worth of APT and $20k worth of USDC. APT collateral factor = 70% while USDC collateral factor = 80%. The account's borrowing power = 10k * 70% + 20k * 80% = 23k.

- All asset price are quoted from Oracles

Liquidators are encouraged to call liquidate to repay part of the liability and seize collateral at discount (close_factor determines the max one can repay, and liquidation_incentives determines the discount).

Given a vault could have M collateral assets and N liability assets, it is up to liquidators to decide what asset to repay and what asset to seize (M*N combinations). Hence the interface:

public fun liquidate<CoinType>
    liquidator: &signer,
    borrower_addr: address,
    borrow_market_obj: Object<Market>,
    collateral_market_obj: Object<Market>,
    repay_asset: Coin<CoinType>,
    min_shares_out: u64) { ... }

Note that min_shares_out is a liquidator-friendly check that guarantees the minimal shares to seize, which otherwise aborts the liqudation transaction.

Parameters and Data

Protocol parameters

- close factor: 50%

- liquidation incentives: 107%

- liquidation fee: 2.5%

Market addresses

- zUSDT: 0x447b3b516546f28e8c4f6825a6287b09161659e7c500c599c29c28a8492844b8

- zUSDC: 0xa9c51ca3bcd93978d0c4aada7c4cf47c0791caced3cdc4e15f2c8e0797d1f93c

- MOD: 0xef2ae89796725d0eb363326ecb7df159feb949f6d1f400f76deeeebccbac00f1

- THL: 0x127ea5b4c450be695e488da1c3bc013e2e93d8cf00270ef90385189844bc9755

- APT: 0x761a97787fa8b3ae0cef91ebc2d96e56cc539df5bc88dadabee98ae00363a831

- sthAPT: 0xed6bf9fe7e3f42c6831ffac91824a545c4b8bfcb40a59b3f4ccfe203cafb7f42

- whUSDC:0xa76ebfb432982c864783fdb33cdf5a9edb18ac1b950deb8037f5cf8c984da3d2

- zWETH: 0x548cf587bd918a0005b3372a1d23e64b18ace3c61962f087a21eac52cf228504

- whWETH:0x114ee519ffa1e8697784bd1a350822cb37601a1476289051b8295165597a4538

- CAKE: 0x41b039e5518b1a3786ee798d895e0ddf3141fbbc20009284323fa51ea279c819

- stAPT: 0xc3c9cc885a52004e0490f6a8291b3bc5854f0e42d931fb124736bd189c9f0f45

Market parameters

You can check market-level parameters in the above address by looking into a Market resource. For example: APT market parameters

Vault addresses

Index SupplyEvent and account_addr is the vault address.

Last updated