HotkeySwapStakeRetained

Event v479 → current #157

Emitted during a single-subnet hotkey swap for each staker whose position stays on the old hotkey because the staker's StakingHotkeys list cannot admit the new one.

View events on chain
Useful for: delegatorsstakersvalidatorsanalyticswallets

The Big Picture

Every stake exit walks the coldkey StakingHotkeys list, so a hotkey swap must not lengthen a delegator list beyond the bounds the delegator controls. Rather than fail the whole swap, the validator moves on and the blocked positions stay where they were. A swap across all subnets renames every entry instead and never emits this. Source: pallets/subtensor/src/swap/swap_hotkey.rs perform_hotkey_swap_on_one_subnet_prepared and retained_swap_stakers, and pallets/subtensor/src/staking/stake_utils.rs hotkey_swap_stake_can_follow, at release-479.

Why This Matters

Your validator swapped to a new hotkey but your stake did not follow. It still earns under the old hotkey and you can move or unstake it as usual.

Example Scenario

You staked to validator hotkey A on subnet 5 and set set_reject_staking_hotkey_growth(true). The validator swaps A to B on subnet 5 only. Your list has no B and A cannot be renamed because you also stake to A on subnet 7, so your subnet 5 position stays on A and this event names you.

Common Questions

How do I follow the validator?
Move the stake to the new hotkey yourself. Your own move uses the owner cap of 256 and ignores the third-party opt-out.

Use Cases

  • Explain why a delegator still holds stake on a hotkey its validator swapped away from
  • Reconcile per-hotkey stake after a swap without assuming every position moved
  • Find root positions that left a claimable basket credit

How to Use This Event

  • → Keep the retained (coldkey, old_hotkey, netuid) position in the index instead of moving it to new_hotkey
  • → Pair with HotkeySwappedOnSubnet in the same extrinsic

From Chain Metadata

The validator swapped, but this delegator's stake could not follow without growing its staking list. On root, basket credits follow the new hotkey.

Triggers

Preconditions

  • A single-subnet hotkey swap moving stake (keep_stake false) is executing
  • The staker holds non-zero alpha on that subnet under old_hotkey and is not the swapping coldkey
  • The staker list holds neither new_hotkey nor an old_hotkey entry that can be renamed (one that no other position, other-subnet auto-stake or non-root basket claim still needs)
  • The staker list is already at 128 entries, or the staker set set_reject_staking_hotkey_growth

Effects

Postconditions

  • The staker position on netuid stays on old_hotkey, and its stake lock and auto-stake destination stay with it
  • On root (netuid 0), the staker BasketClaimed against old_hotkey is reduced by its gross claimable shares, and a negative result inserts (coldkey, old_hotkey) into HotkeySwapBasketCredits

Side Effects

  • No other swap event names the staker, so this is the only record that the position did not move
  • A coldkey retained only through an auto-stake destination, with no stake on the subnet, keeps that destination on old_hotkey and gets no event
  • A retained root credit is claimable through claim_root even though the staker list does not grow

Event Data

#NameTypeDescription
0
coldkey
AccountId coldkey: Account address (32 bytes, SS58-encoded) (hex -> SS58)
1
old_hotkey
AccountId old_hotkey: Account address (32 bytes, SS58-encoded) (hex -> SS58)
2
new_hotkey
AccountId new_hotkey: Account address (32 bytes, SS58-encoded) (hex -> SS58)
3
netuid
NetUid netuid: Subnet ID (u16, 0-65535)

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);

// Subscribe to HotkeySwapStakeRetained events
client.finalizedBlock$.subscribe(async (block) => {
  const events = await api.event.SubtensorModule.HotkeySwapStakeRetained.get(block.hash);
  for (const evt of events) {
    console.log("HotkeySwapStakeRetained:", evt.payload);
  }
});

Runtime Info

View Source
Pallet Index
7
Event Index
157
First Version
v479
Current Version
v490