Skip to content

Commit 589f9f2

Browse files
committed
Revert move fee
1 parent ef9a7af commit 589f9f2

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

pallets/subtensor/src/staking/stake_utils.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,13 +1075,21 @@ impl<T: Config> Pallet<T> {
10751075
pub(crate) fn calculate_staking_fee(
10761076
origin: Option<(&T::AccountId, u16)>,
10771077
_origin_coldkey: &T::AccountId,
1078-
_destination: Option<(&T::AccountId, u16)>,
1078+
destination: Option<(&T::AccountId, u16)>,
10791079
_destination_coldkey: &T::AccountId,
10801080
alpha_estimate: I96F32,
10811081
) -> u64 {
10821082
match origin {
10831083
// If origin is defined, we are removing/moving stake
10841084
Some((origin_hotkey, origin_netuid)) => {
1085+
if let Some((_destination_hotkey, destination_netuid)) = destination {
1086+
// This is a stake move/swap/transfer
1087+
if destination_netuid == origin_netuid {
1088+
// If destination is on the same subnet, use the default fee
1089+
return DefaultStakingFee::<T>::get();
1090+
}
1091+
}
1092+
10851093
if origin_netuid == Self::get_root_netuid()
10861094
|| SubnetMechanism::<T>::get(origin_netuid) == 0
10871095
{

pallets/subtensor/src/tests/staking2.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,5 +914,35 @@ fn test_stake_fee_calculation() {
914914
I96F32::from_num(stake_amount),
915915
); // Charged a dynamic fee
916916
assert_ne!(stake_fee_5, default_fee);
917+
918+
// Test stake fee for move between hotkeys on non-root
919+
let stake_fee_6 = SubtensorModule::calculate_staking_fee(
920+
Some((&hotkey1, netuid0)),
921+
&coldkey1,
922+
Some((&hotkey2, netuid0)),
923+
&coldkey1,
924+
I96F32::from_num(stake_amount),
925+
); // Charge the default fee
926+
assert_eq!(stake_fee_6, default_fee);
927+
928+
// Test stake fee for move between coldkeys on non-root
929+
let stake_fee_7 = SubtensorModule::calculate_staking_fee(
930+
Some((&hotkey1, netuid0)),
931+
&coldkey1,
932+
Some((&hotkey1, netuid0)),
933+
&coldkey2,
934+
I96F32::from_num(stake_amount),
935+
); // Charge the default fee; stake did not leave the subnet.
936+
assert_eq!(stake_fee_7, default_fee);
937+
938+
// Test stake fee for *swap* from non-root to non-root
939+
let stake_fee_8 = SubtensorModule::calculate_staking_fee(
940+
Some((&hotkey1, netuid0)),
941+
&coldkey1,
942+
Some((&hotkey1, netuid1)),
943+
&coldkey1,
944+
I96F32::from_num(stake_amount),
945+
); // Charged a dynamic fee
946+
assert_ne!(stake_fee_8, default_fee);
917947
});
918948
}

0 commit comments

Comments
 (0)