# Withdraw stake safely

> Partial and full withdrawals through request_unbond, the unbonding delay, cancel_unbond, withdraw, and what remains slashable, with the exact contract rules.

*LOPW documentation · Guides.* Canonical page: https://lopw.com/docs/guides/unbonding.html · This Markdown twin: https://lopw.com/docs/guides/unbonding.md · Index of all pages: https://lopw.com/llms.txt · Everything in one file: https://lopw.com/llms-full.txt

Stake leaves only through an unbonding delay, so every receipt you issued can still be claimed. The delay is the largest claim window the service has ever registered plus one hour.

1. Call `request_unbond(service_id, amount)` from `Active` or `Suspended`. If `stake − amount ≥ min_stake` the service **stays Active** and only `amount` is pending (partial withdrawal). Otherwise the **whole stake** becomes pending, `full_exit` is set and the service moves to `Unbonding`, which stops new offers.
2. Wait until `unlock_at = now + max_claim_window + 3600`. The pending amount remains fully slashable throughout, and a slash reduces it if stake falls below it.
3. Call `withdraw(service_id)`. It pays `min(pending, stake)`; a full exit pays the whole stake and closes the service. Before `unlock_at` it fails with `StillLocked`.

*Bond Registry*

```text
request_unbond(service_id, amount)   // Active | Suspended; one pending withdrawal at a time (WithdrawalPending otherwise)
cancel_unbond(service_id)            // clears the pending amount; Unbonding -> Active (stake >= min) or Suspended
withdraw(service_id) -> amount       // after unlock_at; a Pending service withdraws at once (no receipts can exist)
```

Changed your mind? `cancel_unbond(service_id)` clears the pending amount and returns an `Unbonding` service to `Active`, or to `Suspended` if stake is below the minimum. Terms cannot be updated while a service is `Unbonding`.

> **Two side effects to plan for**
>
> - Fees are collected whenever stake moves (`deposit`, `request_unbond`, `withdraw`, `slash`). A partial withdrawal that leaves exactly `min_stake` can therefore end below it after the fee, which suspends the service. Stake a little above the minimum.
> - A `Pending` service (never funded to its minimum) can call `withdraw` immediately: no offer could have existed, so there is nothing to wait for.

Try the numbers in the [unbonding and fee calculator](https://lopw.com/docs/protocol/bond-registry.html#calculator).
