Skip to content

Commit 64fc846

Browse files
committed
handle decrease_stake fn
1 parent 26e638c commit 64fc846

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pallets/subtensor/src/staking/recycle_alpha.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ impl<T: Config> Pallet<T> {
5555
&hotkey, &coldkey, netuid, amount,
5656
);
5757

58+
ensure!(actual_alpha_decrease <= amount, Error::<T>::PrecisionLoss);
59+
5860
// Recycle means we should decrease the alpha issuance tracker.
59-
Self::recycle_subnet_alpha(netuid, amount);
61+
Self::recycle_subnet_alpha(netuid, actual_alpha_decrease);
6062

6163
Self::deposit_event(Event::AlphaRecycled(
6264
coldkey,
@@ -120,7 +122,9 @@ impl<T: Config> Pallet<T> {
120122
&hotkey, &coldkey, netuid, amount,
121123
);
122124

123-
Self::burn_subnet_alpha(netuid, amount);
125+
ensure!(actual_alpha_decrease <= amount, Error::<T>::PrecisionLoss);
126+
127+
Self::burn_subnet_alpha(netuid, actual_alpha_decrease);
124128

125129
// Deposit event
126130
Self::deposit_event(Event::AlphaBurned(

0 commit comments

Comments
 (0)