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:
| Variable | Type | Meaning |
|---|---|---|
sdk | OnchainSDK | Attached Gearbox SDK instance |
liquidator | Address | Wallet supplying repayment and receiving collateral |
supportedCollateral | Address[] | Collateral assets the liquidator is willing to receive |
supportedRepaymentTokens | Address[] | 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:
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:
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"); }
| Value | Type | Meaning |
|---|---|---|
account | CreditAccountData | Fresh state of the account being liquidated |
compressor | IWithdrawalCompressorContract | SDK reader used to confirm that the account has no delayed withdrawals |
currentWithdrawals | CurrentWithdrawals | Current delayed withdrawals; partial liquidation requires both lists to be empty |
creditManager | CreditSuite | Credit Manager suite for the account |
repaymentToken | Address | Market underlying supplied by the liquidator |
preview.tokenOut | Address | Collateral selected for the liquidator to receive |
preview.repaidAmount | bigint | Amount of market underlying supplied by the liquidator |
preview.minSeizedAmount | bigint | Minimum acceptable amount of tokenOut |
preview.optimalHF | bigint | Target 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:
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.