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

Moves part of a position from the origin subnet to the destination subnet
while staying on the same hotkey: the alpha is swapped to TAO in the
origin pool and then to alpha in the destination pool, so both legs can
incur slippage. The two netuids must differ (`SameNetuid`). Use
`move_stake` when the hotkey should change too, and `remove_stake`
plus `add_stake` only if you want to control each leg separately.

| Signer    | Pallet          | Wraps                        |
| --------- | --------------- | ---------------------------- |
| `coldkey` | SubtensorModule | `SubtensorModule.swap_stake` |

## Parameters [#parameters]

| Parameter       | Type              | Required | Description                                                                                                                                            |
| --------------- | ----------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `hotkey_ss58`   | string            | yes      | Hotkey the stake is held on (the validator backing the position).                                                                                      |
| `origin_netuid` | integer           | yes      | Subnet the stake currently sits on.                                                                                                                    |
| `dest_netuid`   | integer           | yes      | Subnet the stake ends up on. When it differs from the origin, the position is swapped through both subnet pools, which can incur slippage on each leg. |
| `amount_alpha`  | number \| `"all"` | yes      | How much of the origin position to swap across (an explicit amount; `all` is not accepted).                                                            |

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 swap-stake \
  --hotkey <ss58|name> \
  --origin-netuid <int> \
  --dest-netuid <int> \
  --amount-alpha <amount|all> --dry-run
btcli tx swap-stake \
  --hotkey <ss58|name> \
  --origin-netuid <int> \
  --dest-netuid <int> \
  --amount-alpha <amount|all> -w my_coldkey
```

## Python [#python]

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

wallet = Wallet(name="my_coldkey", hotkey="my_hotkey")
intent = sub.SwapStake(hotkey_ss58="5F...", origin_netuid=0, dest_netuid=0, amount_alpha=1.0)

async with sub.Client("finney") as client:
    plan = await client.plan(intent, wallet)   # fee, effects, policy — no submission
    result = await client.execute(intent, wallet)
    if not result.success:
        print(result.error.code, result.error.remediation)
```

Or build it by op name, as an agent would:

```python
await client.execute_tool("swap_stake", {...}, wallet)
```
