swap_stake

Call v233 → v277, v290 → v292, v297 → v385, v391 → v424, v432 → current #87

Swaps stake between subnets for the same coldkey -hotkey pair.

View calls on chain

Click items to navigate. Pan and zoom to explore.

Used by: stakersvalidatorsanalyticswallets

The Big Picture

Your stake is spread across subnets, each with its own Alpha token. swap_stake lets you rebalance between subnets while keeping the same validator (hotkey). Unlike move_stake which changes validators, this changes subnets. Think of it as choosing which markets your validator operates in.

Why This Matters

Subnet performance varies. Last month's top subnet might be this month's laggard. swap_stake lets you chase better returns without abandoning your trusted validator.

Example Scenario

You have 100 TAO staked to ValidatorX on subnet 1, but subnet 3 has better emissions. ValidatorX is registered on both. Call swap_stake(hotkey=ValidatorX, origin_netuid=1, dest_netuid=3, amount=50). Half your stake moves to subnet 3, still with ValidatorX.

Common Questions

How is this different from move_stake?
move_stake changes the hotkey (validator), swap_stake changes the subnet. Use swap_stake when you trust your validator but want different subnet exposure.
Is there slippage when swapping between subnets?
Yes - you're exchanging one subnet's Alpha for another's. The exchange rate depends on each subnet's Alpha pool. Use swap_stake_limit for slippage protection.

Use Cases

  • Move stake to a better-performing subnet
  • Rebalance exposure across subnets
  • Follow validator to new subnet without changing delegation
  • Respond to emission changes by shifting subnet allocation

From Chain Metadata

Swaps a specified amount of stake from one subnet to another, while keeping the same coldkey and hotkey.

Migration Notes

v424 v432 Breaking

origin_netuid changed from u16 to NetUid; destination_netuid changed from u16 to NetUid; alpha_amount changed from u64 to AlphaBalance

Update decoders: SCALE encoding is positional, so any signature change (added, removed, or type-changed fields, or storage shape changes) shifts byte offsets and existing decoders will misparse this item. Re-derive types from the new metadata.

Input Parameters

#NameTypeDescription
0
hotkey
AccountId hotkey: Account address (32 bytes, SS58-encoded) (hex -> SS58)
1
origin_netuid
NetUid origin_netuid: Subnet ID (u16, 0-65535)
2
destination_netuid
NetUid destination_netuid: Subnet ID (u16, 0-65535)
3
alpha_amount
AlphaBalance alpha_amount: Alpha amount in alpha-RAO (÷10⁹ for alpha)

Permissions

Origin
Signed
Required Role

Permission data inferred from metadata. May be incomplete.

Requirements

  • Coldkey-hotkey has stake on origin subnet
  • Hotkey is registered on destination subnet
  • Both subnets exist
  • From v488, when the origin or the destination is netuid 0: the queued basket dividend credits of the validator settle, or are snapshotted to its current root stakers, before the stake changes; it fails with BasketDepositPending when neither completes in this call (pallets/subtensor/src/staking/stake_utils.rs L1227-L1234 and L1334-L1337 and staking/basket_flush.rs L204-L225 at d967d1358, runtime v490)

Effects

Postconditions

  • Stake moved from origin to destination subnet
  • Same coldkey-hotkey ownership preserved

Side Effects

  • Alpha exchanged between subnet pools

Possible Errors

Code Examples

import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Build swap_stake call (typed, named args)
const hotkey = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const origin_netuid = 1;
const destination_netuid = 1;
const alpha_amount = 1_000_000_000n;

const tx = api.tx.SubtensorModule.swap_stake({
  hotkey,
  origin_netuid,
  destination_netuid,
  alpha_amount,
});

On-Chain Activity

Usage Frequency
●●●●○○ Active 100K–1M extrinsics

Significant regular use

#35 most used call

Success Rate Moderate

50–80% of submissions succeed

As of block 9,385,000

Version History

v233 block 4,920,350 4 args
v290 block 5,947,548 4 args
v297 block 6,067,943 4 args
v391 block 7,782,857 4 args
v432 block 8,636,190 4 args Current

Runtime Info

View Source
Pallet Index
7
Call Index
87
First Version
v233
Current Version
v490