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

Scanning reads every obligation in the market. Public RPC endpoints reject it, so use a private RPC. On the SOL/BTC Market it reads over 100,000 obligations and takes about five minutes.
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

An obligation is liquidatable when its LTV reaches its liquidation LTV. The scan also tracks the obligation closest to liquidation.
loanToValue() and liquidationLtv() compute both at current prices over all deposits, the way the program checks. Don’t use the obligation’s stored values such as getUnhealthyBorrowValue(): they’re from its last on-chain refresh and can mark a healthy obligation as liquidatable.

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

Choose the Obligation

Liquidations are rare. When the scan finds none, print the closest obligation and stop before swapping anything.
2

Select the Target Pair

Seize the riskiest collateral (lowest liquidation threshold) and repay the most heavily weighted debt (highest borrow factor).

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

One liquidation can repay up to the market’s close factor share of the debt.
3

Size the SOL Swap

Price the repay in SOL with the market’s own oracle prices, plus slippage, and check the wallet holds it.
4

Define a Send Helper

5

Swap SOL into the Debt Token via KSwap

Use @kamino-finance/kswap-sdk 2.9.0, the last version on @solana/kit 2. The swap is exact-in so every KSwap router is available: exact-out routes currently come only from Jupiter-based routers.
6

Calculate Minimum Collateral

The minimum collateral to accept assumes the smallest liquidation bonus, takes off the protocol’s liquidation fee, and allows for slippage.
7

Build the Liquidation Instructions

8

Fetch Lookup Tables and Send

The debt is repaid and the collateral, including the liquidation bonus, is in the liquidator’s wallet.