DocumentationOpen App
On this page1. Find liquidatable accounts

Partial Liquidation

A partial liquidation repays part of a Credit Account's debt and transfers one selected collateral asset to the liquidator at the liquidation discount. The account remains open and must finish with a health factor of at least 1.0.

This flow is only for immediately receivable collateral. It does not transfer redeemers or liquidate delayed-redemption positions. Use Full Liquidation when an account has delayed withdrawals.

Before continuing, install and attach the Gearbox SDK. The caller supplies these inputs:

VariableTypeMeaning
sdkOnchainSDKAttached Gearbox SDK instance
liquidatorAddressWallet supplying repayment and receiving collateral
supportedCollateralAddress[]Collateral assets the liquidator is willing to receive
supportedRepaymentTokensAddress[]Market underlyings the liquidator is willing to repay

1. Find liquidatable accounts

Use the same discovery service as full liquidation, but exclude every account that holds a delayed-withdrawal position:

TypeScript
const candidates = await sdk.liquidations.getLiquidatableAccounts({ assets: supportedCollateral, delayed: false, });

delayed: false is the boundary between the two liquidation processes. Partial liquidation does not assign redeemers to the liquidator.

The assets filter matches each account's main collateral. The selected output is checked again during preview.

2. Inspect one candidate

Load a fresh account snapshot, confirm that no delayed withdrawal has appeared, and calculate the default partial-liquidation parameters:

TypeScript
import { isAddressEqual } from "viem"; const candidate = candidates[0]; if (!candidate) throw new Error("No supported liquidation candidates"); if (candidate.paused) throw new Error("Credit Facade is paused"); const account = await sdk.accounts.getCreditAccountData( candidate.creditAccount, ); if (!account) throw new Error("Credit Account not found"); if (!account.success) throw new Error("Collateral computation failed"); const compressor = sdk.withdrawalCompressor; if (!compressor) throw new Error("Delayed-withdrawal state unavailable"); const currentWithdrawals = await compressor.getCurrentWithdrawals( account.creditAccount, ); if ( currentWithdrawals.pending.length > 0 || currentWithdrawals.claimable.length > 0 ) { throw new Error("Use full liquidation for delayed withdrawals"); } const creditManager = sdk.marketRegister.findCreditManager( account.creditManager, ); const repaymentToken = creditManager.underlying; if ( !supportedRepaymentTokens.some(token => isAddressEqual(token, repaymentToken), ) ) { throw new Error("Unsupported repayment token"); } const preview = sdk.accounts.defaultPartialLiquidationParams(account); if ( !supportedCollateral.some(token => isAddressEqual(token, preview.tokenOut), ) ) { throw new Error("Unsupported collateral token"); }
ValueTypeMeaning
accountCreditAccountDataFresh state of the account being liquidated
compressorIWithdrawalCompressorContractSDK reader used to confirm that the account has no delayed withdrawals
currentWithdrawalsCurrentWithdrawalsCurrent delayed withdrawals; partial liquidation requires both lists to be empty
creditManagerCreditSuiteCredit Manager suite for the account
repaymentTokenAddressMarket underlying supplied by the liquidator
preview.tokenOutAddressCollateral selected for the liquidator to receive
preview.repaidAmountbigintAmount of market underlying supplied by the liquidator
preview.minSeizedAmountbigintMinimum acceptable amount of tokenOut
preview.optimalHFbigintTarget post-liquidation health factor, where 10000 is 100%

The SDK selects the most valuable enabled non-underlying collateral and calculates a repayment intended to restore the account to its optimal health factor. Pass the preview values explicitly when building so the transaction matches the inspected parameters.

3. Obtain the execution payload

Build immediately before execution:

TypeScript
const transaction = await sdk.accounts.partiallyLiquidate({ account, to: liquidator, ...preview, });

Approve repaymentToken for account.creditManager with an allowance of at least preview.repaidAmount. The Credit Manager is the spender.

transaction contains the unsigned partiallyLiquidateCreditAccount() call with current on-demand price updates. Pass the approval requirement and transaction to the operator's existing transaction pipeline.

Execution reverts if the account is no longer liquidatable, the seized amount is below preview.minSeizedAmount, or the account would remain below a health factor of 1.0.

Integration boundary

This page provides Gearbox discovery, delayed-position exclusion, parameter calculation, approval requirements, and unsigned liquidation calldata. The operator's existing infrastructure owns execution and service operation.

Sources