> ## Documentation Index
> Fetch the complete documentation index at: https://xoxno.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Withdraw assets

> Withdraw supply from a lending account; amount 0 closes the full position.

Withdraw supplied assets from an account through the controller.

## Withdrawing

1. Confirm the account’s supply position
2. Choose amount (`0` = full position for that asset)
3. Call `withdraw`
4. Re-check health factor if debt remains

### Call shape

```rust theme={"system"}
withdraw(
  caller: Address,
  account_id: u64,
  withdrawals: Vec<(HubAssetKey, i128)>,  // ({ hub_id, asset }, amount)
  to: Option<Address>,
) -> Vec<(HubAssetKey, i128)>             // amounts actually paid
```

<Note>
  **Full-position sentinel:** `amount = 0` withdraws the entire post-accrual supply
  for that asset, and the zero is sticky across duplicate legs. The **return value**
  is the resolved figure — the only way to learn what a withdraw-all actually paid.
  There is no `max_withdraw` view; simulate the call instead.
</Note>

```bash theme={"system"}
stellar contract invoke \
  --id <CONTROLLER> \
  --source-account <CALLER> \
  --network testnet \
  -- withdraw \
  --caller <CALLER> \
  --account_id 42 \
  --withdrawals '[[{"hub_id":1,"asset":"<USDC>"}, "0"]]' \
  --to null
```

### Preconditions

* Caller holds the account's position NFT, or is an active delegate on it
* Asset has a live supply position (`#121` if not)
* If debt remains: HF ≥ `1` WAD, the LTV gate holds, and LTV-weighted collateral
  stays above the minimum-borrow floor (`#100`, `#126` otherwise)
* Pool has enough cash (`#112` if not)
* A `paused` spoke asset blocks withdraw; a `frozen` one does **not** — freeze
  blocks entry only. Global protocol pause does not block withdraw either
