diff --git a/pallets/subtensor/src/staking/helpers.rs b/pallets/subtensor/src/staking/helpers.rs index 0328d94e6..0def48407 100644 --- a/pallets/subtensor/src/staking/helpers.rs +++ b/pallets/subtensor/src/staking/helpers.rs @@ -305,7 +305,7 @@ impl Pallet { hotkey: &T::AccountId, coldkey: &T::AccountId, stake: u64, - ) { + ) -> u64 { // Verify if the account is a nominator account by checking ownership of the hotkey by the coldkey. if !Self::coldkey_owns_hotkey(coldkey, hotkey) { // If the stake is below the minimum required, it's considered a small nomination and needs to be cleared. @@ -315,8 +315,10 @@ impl Pallet { let cleared_stake = Self::empty_stake_on_coldkey_hotkey_account(coldkey, hotkey); // Add the stake to the coldkey account. Self::add_balance_to_coldkey_account(coldkey, cleared_stake); + return cleared_stake; } } + 0 } /// Clears small nominations for all accounts. diff --git a/pallets/subtensor/src/staking/remove_stake.rs b/pallets/subtensor/src/staking/remove_stake.rs index 4118e8d07..aec6bdb34 100644 --- a/pallets/subtensor/src/staking/remove_stake.rs +++ b/pallets/subtensor/src/staking/remove_stake.rs @@ -83,7 +83,8 @@ impl Pallet { // This only applies to nominator stakes. // If the coldkey does not own the hotkey, it's a nominator stake. let new_stake = Self::get_stake_for_coldkey_and_hotkey(&coldkey, &hotkey); - Self::clear_small_nomination_if_required(&hotkey, &coldkey, new_stake); + let cleared_stake = Self::clear_small_nomination_if_required(&hotkey, &coldkey, new_stake); + let stake_removed = stake_to_be_removed.saturating_add(cleared_stake); // Set last block for rate limiting let block: u64 = Self::get_current_block_as_u64(); @@ -97,11 +98,12 @@ impl Pallet { block, ); log::debug!( - "StakeRemoved( hotkey:{:?}, stake_to_be_removed:{:?} )", + "StakeRemoved( hotkey:{:?}, stake_to_be_removed:{:?} stake_removed:{:?} )", hotkey, - stake_to_be_removed + stake_to_be_removed, + stake_removed ); - Self::deposit_event(Event::StakeRemoved(hotkey, stake_to_be_removed)); + Self::deposit_event(Event::StakeRemoved(hotkey, stake_removed)); // Done and ok. Ok(())