AccountManager.liquidate() to clear all outstanding debt and recover any remaining collateral value. The protocol blocks this call when the account is healthy - it is an emergency exit only.
The Liquidation Guard
Liquidation is gated by the sameis_account_healthy() function described in Health Factor:
The liquidate() function calls the Risk Engine directly before taking any action:
is_account_healthy() returns false.
Authorization
Theliquidate() function requires the account owner’s authorization:
require_auth() on the trader address means the transaction must include a valid authorization entry from the account owner. This is not a permissionless operation - it requires the trader’s direct participation or a pre-signed delegation. The protocol uses this model because the collateral is swept back to the owner, not to an external caller.
Debt Repayment
For every token the account has borrowed, the Account Manager:-
Reads the full outstanding balance from the Lending Pool:
Unlike the health check (which uses raw borrow shares), liquidation uses
get_borrow_balance()- the full outstanding amount including all accrued interest settled as of the current state. -
Clears the debt on the Lending Pool side:
-
Transfers the corresponding tokens from the Smart Account to the pool and updates internal accounting:
- Removes the token from the account’s borrowed token list if the debt is fully cleared.
Collateral Sweep
After all debt is cleared, the Account Manager calls:sweep_to() iterates over every token in the Smart Account’s collateral list and transfers the full balance to the specified address - in this case, the account owner.
Tokens covered by sweep
sweep_to() calls remove_collateral_token_bal_internal() for each collateral token. This function contains explicit handlers for XLM and USDC, which transfer the actual token balances:
BLEND_XLM, BLEND_USDC) and Aquarius LP tracking positions (AQ_XLM_USDC), the internal collateral balance is zeroed and the token is removed from the collateral list. However, no token transfer occurs for these positions - the underlying b-tokens held in Blend’s pool and LP positions in Aquarius are not unwound. Their tracking records are cleared from the Smart Account but the assets remain in the external protocols.
No Liquidation Fee
The current implementation contains no fee mechanism. Thecollect_from() call transfers exactly the amount needed to repay the debt. The sweep_to() call transfers the full remaining collateral balance to the trader. No percentage is deducted for any party.
Account State After Liquidation
Theliquidate() function does not call deactivate_account() or registry.close_account(). After liquidation completes:
- All borrowed token entries are removed from the Smart Account
has_debtis set to false when the last borrowed token is removed- All collateral balances are zeroed
- The Smart Account remains in its current activation state in the registry
close_account(), which explicitly deactivates the Smart Account and updates the Registry. liquidate() is not an account closure - it is a position clear.
settle_account() - The Voluntary Alternative
settle_account() provides a voluntary path to repay all debt without sweeping collateral:
settle_account() calls repay() for each borrowed token. Unlike liquidate(), it does not check whether the account is healthy or unhealthy - it can be called at any time. Collateral remains in the Smart Account after settlement; the owner must then call close_account() to recover it.
liquidate() | settle_account() | |
|---|---|---|
| Health check | Account must be unhealthy | No check |
| Debt cleared | All borrowed tokens | All borrowed tokens |
| Collateral returned | Swept to owner immediately | Stays in Smart Account |
| Account deactivated | No | No |
Full Execution Flow

Related
- Health Factor - the invariant that determines when liquidation becomes possible
- Smart Accounts - the isolated contract that holds collateral and debt
- Lending Pools - where borrow shares are stored and debt is cleared on repayment
- Liquidation Guide - user-facing explanation of what liquidation means for a position

