- account margin = sum(collateral value * Liquidation Threshold).
- let's say the vault has $10,000 worth of APT and $20,000 worth of USDC. APT liquidation threshold = 74% while USDC liquidation threshold = 82%. The account's margin = 10k * 74% + 20k * 82% = $23,800.
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.