Liquidation Execution Guide
The health of NAVI Protocol depends on the health of the loans within the system, measured by the Health Factor. When an account’s health factor falls below 1, anyone can call execute_liquidation on the LendingPool contract. This repays part of the debt and grants discounted collateral to the liquidator.
This mechanism aligns incentives, encouraging third parties to maintain the protocol’s safety while earning a bonus.
Ways to Participate in Liquidations
Direct Calls: Call
execute_liquidationon the LendingPool contract.Automated Bots: Create a system to monitor accounts and liquidate loans automatically.
Note: Profitable liquidation requires factoring in gas costs. High gas fees can make a liquidation unprofitable. See Calculating Profitability vs Gas Cost below.
Prerequisites
When making a execute_liquidation call, you must:
Know the account (i.e. the Sui address:
user) whose health factor is below 1.Know the valid debt amount (
debt_to_cover) and debt asset (debt) that can be paid.The close factor is 0.35, which means that only a maximum of 35% of the debt can be liquidated per valid
execute_liquidation.You can set the
debt_to_covertouint(-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
execute_liquidationto 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'.
1. Getting accounts to liquidate
Only accounts with health factor < 1 are eligible.
On-Chain Monitoring:
Track protocol events (deposit, repay, borrow, etc.) to maintain an up-to-date local index of user accounts.
Call
get_user_account_datawith a user’s address to read their currenthealth factor. If thehealth_factoris below 1, then the account can be liquidated.
“Users” in NAVI Protocol refers to a single Sui address interacting with the protocol (EOA or contract).
2. Executing the liquidation call
Calculate the amount of collateral that can be liquidated:
Call
get_user_reserve_dataon the LendingPool Lens contract.Maximum liquidation is limited by the close factor (0.35).
debtToCover=userVariableDebt∗LiquidationCloseFactorPercent
For reserves with
usage_as_collateral_enabled = true:Use
current_atoken_balanceand current liquidation bonus to determine the maximum collateral receivable.maxAmountOfCollateralToLiquidate=(debtAssetPrice∗currentATokenBalance∗liquidationBonus)/collateralPrice
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:
Store and retrieve each collateral's relevant details such as address, decimals used, and liquidation bonus as listed here.
Get the user's collateral balance (n
TokenBalance).Get the asset's price according to the Navi's oracle contract (
getAssetPrice()).Maximum collateral bonus you can receive = collateral balance × liquidation bonus × asset price. Note that for assets such as USDC, the number of decimals are different from other assets.
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
estimateGasvia your web3 provider.Your approximate profit will be the value of the collateral bonus (4) minus the cost of your transaction (5).
Example Liquidation Scenario
Initial Position:
User deposits: $100 worth of SUI (70% LTV)
User borrows: $50 worth of BTC
Health Factor: 100 × 0.7 ÷ 50 = 1.4 → Safe
Market Change:
wBTC price rises by 50%
Borrow balance increases to $75
Health Factor: 100 × 0.7 ÷ 75 = 0.933 → Liquidatable
Liquidation Process:
When Health Factor < 1, liquidators can repay part or all of the outstanding debt.
In return, liquidators receive discounted collateral (the liquidation bonus).
Liquidators can choose to receive collateral as either aTokens or the underlying asset.
After successful liquidation, the borrower’s Health Factor increases above 1.
Close Factor Limitation:
Maximum liquidation per transaction is determined by the close factor (currently 0.35).
This means liquidators can only liquidate up to 35% of the debt in a single call.
The liquidation discount applies only to this portion.
In most scenarios, profitable liquidators will choose to liquidate as much as they can (50% of the user position).
To check a user's health factor, use get_user_account_data
Last updated