# remove-stake (/docs/tx/remove-stake)

Swaps the alpha position back to TAO at the current pool price and credits
it to the signing coldkey's free balance. Pass `all` to exit the entire
position on that hotkey and subnet (the build fails if nothing is staked
there). Like staking, the swap moves the pool, so large amounts incur
slippage. By default the call is slippage-protected: it fails
(`SlippageTooHigh`) instead of filling once the price falls more than
`rate_tolerance` (5%) below the price at submission — raise the tolerance
or set `slippage_protection` to False to execute at any price, or use
`remove_stake_limit` to set an explicit limit price. The hotkey and
netuid must match where the stake is actually held, and the subnet must
have subtoken trading enabled. The requested amount is capped to the
stake currently available. A partial unstake must leave a remainder
worth at least 0.002 TAO at the simulated pool price — exit the full
position instead of leaving dust (`AmountTooLow`).

On root (netuid 0), unstake returns principal only. Accrued basket yield
stays owed until `claim_root_with_hotkey`. Pass `claim=True` to redeem
this validator's whole entitlement first, then unstake, in one batch.
That is not a proportional payout: the claim pays 100% of the basket,
not a slice of the amount you unstake.

| Signer    | Origin                                 | Pallet          | Wraps                                                                                                                                                                                                                                                                                                                                                                           |
| --------- | -------------------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `coldkey` | signed account (pallet role may apply) | SubtensorModule | [`SubtensorModule.remove_stake`](/code/pallets/subtensor/src/macros/dispatches.rs#L612-L621), [`SubtensorModule.remove_stake_limit`](/code/pallets/subtensor/src/macros/dispatches.rs#L1482-L1500), [`SubtensorModule.claim_root_with_hotkey`](/code/pallets/subtensor/src/macros/dispatches.rs#L2004-L2023), [`Utility.batch_all`](/code/pallets/utility/src/lib.rs#L308-L362) |

## Parameters [#parameters]

| Parameter             | Type              | Required | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| --------------------- | ----------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `hotkey_ss58`         | string            | yes      | Hotkey the stake is held on (the validator backing the position).                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `netuid`              | integer           | yes      | Subnet the stake lives on (netuid 0 is the root network).                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `amount_alpha`        | number \| `"all"` | yes      | How much to unstake from this position, or `all`.                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `slippage_protection` | boolean           | no       | Bound the price the swap may execute at (on by default): the call fails (`SlippageTooHigh`) instead of filling once the pool price moves more than `rate_tolerance` from the price at submission. Disable to execute at any price.                                                                                                                                                                                                                                                                             |
| `rate_tolerance`      | number            | no       | Maximum price move slippage protection accepts, as a fraction (0.05 = 5%). Ignored when slippage protection is disabled.                                                                                                                                                                                                                                                                                                                                                                                       |
| `claim`               | boolean           | no       | Also redeem this validator's whole basket entitlement before unstaking, in one atomic batch. Root only (netuid 0). This is not a proportional payout: unstaking 40% still claims 100% of the basket. The chain has no proportional-claim call. Claimed yield is restaked on root, then the unstake runs — pass `all` to take principal and yield out together. Unavailable while RootStakeUnlockInterval is nonzero, because the claim starts a new hold window; claim first, wait, then unstake in that mode. |

Address parameters (`--hotkey`, `--coldkey`, `--dest`, ...) accept a raw ss58
address, an address-book or proxy-book name, or a local wallet/hotkey name.

## CLI [#cli]

Preview with `--dry-run` (shows fee, effects, and policy result without
submitting), then submit:

```bash
btcli tx remove-stake \
  --hotkey <ss58|name> \
  --netuid <int> \
  --amount-alpha <amount|all> --dry-run
btcli tx remove-stake \
  --hotkey <ss58|name> \
  --netuid <int> \
  --amount-alpha <amount|all> -w my_coldkey
```

## Python [#python]

```python
import bittensor as bt
from bittensor.wallet import Wallet

wallet = Wallet(name="my_coldkey", hotkey="my_hotkey")
intent = bt.RemoveStake(hotkey_ss58="5F...", netuid=1, amount_alpha=1.0)

sub = bt.Subtensor()
plan = sub.plan(intent, wallet)   # fee, effects, policy — no submission
result = sub.execute(intent, wallet)
if not result.success:
    print(result.error.code, result.error.remediation)
```

(`bt.Subtensor` is also the async client — `async with bt.Subtensor() as client:`
— see [The client](/docs/concepts/client).) Or build the intent by op name, as
an agent would:

```python
result = sub.execute_tool("remove_stake", {...}, wallet)
```

## On-chain implementation [#on-chain-implementation]

| Chain call                               | Source                                                                                                             |
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `SubtensorModule.remove_stake`           | [`pallets/subtensor/src/macros/dispatches.rs#L614`](/code/pallets/subtensor/src/macros/dispatches.rs#L612-L621)    |
| `SubtensorModule.remove_stake_limit`     | [`pallets/subtensor/src/macros/dispatches.rs#L1484`](/code/pallets/subtensor/src/macros/dispatches.rs#L1482-L1500) |
| `SubtensorModule.claim_root_with_hotkey` | [`pallets/subtensor/src/macros/dispatches.rs#L2008`](/code/pallets/subtensor/src/macros/dispatches.rs#L2004-L2023) |
| `Utility.batch_all`                      | [`pallets/utility/src/lib.rs#L314`](/code/pallets/utility/src/lib.rs#L308-L362)                                    |

Every file is browsable under [/code](/code) exactly as built into the runtime, or as plain text under `/code/raw/<path>` (index: [`/code/index.json`](/code/index.json)).
