Skip to main content
Liquidations on Kamino are permissionless. Any wallet can liquidate an unhealthy obligation and earn a bonus. Bots continuously monitor all obligations and execute when one crosses its health limit.

Scanning for Unhealthy Positions

The first step is loading every obligation in a market and checking which ones have breached their health limit.
1

Import Dependencies

2

Set Up RPC and Load Market

Kamino operates multiple markets (SOL/BTC, JLP, Altcoins, Prime). A production bot should scan all of them. See Markets for the full list.
3

Scan Obligations in Batches

Scan obligations in batches of 100 to avoid out-of-memory on large markets. Use the on-chain LTV methods, not refreshedStats.loanToValue, to match the program’s liquidation check.

Picking the Most Profitable Pair

An obligation can have multiple collateral deposits and multiple borrows. The liquidator must choose one debt token to repay and one collateral token to seize. The program enforces priority rules: target the lowest-threshold collateral and the highest-borrow-factor debt first.
1

Load the Obligation

2

Sort by Priority

Sort deposits by liquidationThresholdPct ascending (weakest collateral first) and borrows by borrowFactorPct descending (riskiest debt first).
3

Select the Target Pair

The first entry in each sorted list is the priority target. Reserves with loanToValuePct == 0 are deposit-only and cannot be seized.

Executing the Liquidation

Once an unhealthy obligation and target pair have been identified, build and send the liquidation transaction.
1

Import Transaction Utilities

2

Calculate Repay Amount

Calculate the maximum repayable amount from the obligation’s debt position and the market’s close factor.
3

Swap into Debt Token via KSwap

If the liquidator does not hold the debt token, swap into it using the KSwap REST API. The swap amount is converted from debt USD value to SOL lamports.
KSwap is also available as the @kamino-finance/kswap-sdk TypeScript package for building swap instructions on the client.
4

Calculate Slippage Protection

Calculate the minimum collateral to receive based on the repay value, expected liquidation bonus, protocol fee, collateral price, and a 2% haircut.
5

Build the Liquidation Transaction

buildLiquidateTxns constructs the full transaction including reserve refreshes, obligation refresh, ATA creation, compute budget, and the liquidation instruction.
6

Assemble Instructions

7

Sign and Send