Skip to content

Commit

Permalink
fix remove stake for Alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
camfairchild committed Dec 3, 2024
1 parent 77675ac commit 986d7c4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pallets/subtensor/src/staking/remove_stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,16 @@ impl<T: Config> Pallet<T> {
);

// Convert and unstake from the subnet.
let tao_unstaked: u64 =
let alpha_unstaked: u64 =
Self::unstake_from_subnet(&hotkey, &coldkey, netuid, alpha_unstaked);

// We add the balance to the coldkey. If the above fails we will not credit this coldkey.
Self::add_balance_to_coldkey_account(&coldkey, tao_unstaked);
Self::add_alpha_balance_to_coldkey_account(&coldkey, alpha_unstaked, netuid);

// If the stake is below the minimum, we clear the nomination from storage.
// This only applies to nominator stakes.
// If the coldkey does not own the hotkey, it's a nominator stake.
// TODO (cam): handle using top-k
let new_stake = Self::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey, &coldkey, netuid);
Self::clear_small_nomination_if_required(&hotkey, &coldkey, netuid, new_stake);

Expand All @@ -103,9 +104,9 @@ impl<T: Config> Pallet<T> {
block,
);
log::debug!(
"StakeRemoved( hotkey:{:?}, tao_unstaked:{:?} )",
"StakeRemoved( hotkey:{:?}, alpha_unstaked:{:?} )",
hotkey.clone(),
tao_unstaked
alpha_unstaked
);

// Done and ok.
Expand Down

0 comments on commit 986d7c4

Please sign in to comment.