liquidate_obligation_and_redeem_reserve_collateral
Liquidate an unhealthy obligation by repaying some of its debt and receiving collateral at a discount.Signature
Use the v2 variant which includes farming support. The v1 variant is deprecated.
Parameters
The amount of debt to repay. The actual amount may be reduced based on liquidation rules and available collateral.
The minimum amount of collateral liquidity the liquidator is willing to receive. Protects against slippage.
LTV override percentage. Only used in staging environment when liquidator is the obligation owner. Set to 0 normally.
Accounts
The liquidator performing the liquidation.
The unhealthy obligation to liquidate.
- Must be mutable
The lending market.
PDA authority for the lending market.
The reserve for the debt being repaid.
- Must be mutable
The repay reserve’s liquidity token mint.
The repay reserve’s liquidity supply vault.
- Must be mutable
The reserve for the collateral being liquidated.
- Must be mutable
The withdraw reserve’s liquidity token mint.
The withdraw reserve’s collateral token mint.
- Must be mutable
The withdraw reserve’s collateral supply vault.
- Must be mutable
The withdraw reserve’s liquidity supply vault.
- Must be mutable
The withdraw reserve’s fee receiver vault.
- Must be mutable
The liquidator’s source liquidity token account (for repayment).
- Must be mutable
The liquidator’s destination collateral token account (receives collateral).
- Must be mutable
The liquidator’s destination liquidity token account (receives redeemed liquidity).
- Must be mutable
The SPL Token program.
The token program for repay liquidity.
The token program for withdraw liquidity.
The Solana instructions sysvar.
Optional farming accounts for collateral (v2 only).
Optional farming accounts for debt (v2 only).
The Kamino Farms program (v2 only).
Remaining Accounts
All deposit reserves for the obligation (to calculate total collateral value).Returns
ReturnsOk(()) on success.
Errors
GlobalEmergencyMode: Emergency mode is enabledObligationHealthy: Cannot liquidate a healthy obligationLiquidationTooSmall: Liquidation amount is too smallLiquidationRewardTooSmall: Received amount is less than minimum acceptableCollateralNonLiquidatable: The collateral has LTV=0 and cannot be liquidatedLiquidationBorrowFactorPriority: Must prioritize debt with highest borrow factorLiquidationLowestLiquidationLtvPriority: Must prioritize collateral with lowest liquidation LTVInsufficientRepayAmount: Repay amount is less than required by liquidation rules
Liquidation Rules
The instruction enforces several rules:- Obligation must be unhealthy: LTV exceeds liquidation threshold
- Borrow factor priority: Must liquidate the debt with the highest borrow factor first (can be bypassed with
min_value_skip_liquidation_bf_checks) - Collateral LTV priority: Must liquidate the collateral with the lowest liquidation LTV first (can be bypassed with
min_value_skip_liquidation_ltv_checks) - Close factor: Can only liquidate up to a percentage of total debt (configured in market)
- Full liquidation threshold: If debt value is below threshold, must fully liquidate
- Liquidation bonus: Liquidator receives collateral at a discount based on configuration
mark_obligation_for_deleveraging
Mark an unhealthy obligation for automatic deleveraging. Only callable by the lending market owner.Signature
Parameters
The target LTV percentage to deleverage the obligation down to (1-100).
Accounts
The owner of the lending market.
The obligation to mark for deleveraging.
- Must be mutable
The lending market.
- Must have
lending_market_ownermatching signer - Must have
autodeleverage_enabledset to true
Returns
ReturnsOk(()) on success. The obligation is marked with a timestamp and target LTV for deleveraging.
Errors
ObligationHealthy: Obligation is not unhealthy enough to deleverageObligationCurrentlyMarkedForDeleveraging: Obligation is already marked for deleveraging- Market owner validation errors if signer is not the market owner