From e8f435848f6d079cc6a16bbcd94ec62ffee27f03 Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Thu, 10 Jul 2025 15:38:37 +0200 Subject: [PATCH 1/5] Updates stake move table with rate applied correctly. --- bittensor_cli/src/commands/stake/move.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bittensor_cli/src/commands/stake/move.py b/bittensor_cli/src/commands/stake/move.py index 578c9f0a0..5e10e8080 100644 --- a/bittensor_cli/src/commands/stake/move.py +++ b/bittensor_cli/src/commands/stake/move.py @@ -38,8 +38,7 @@ async def display_stake_movement_cross_subnets( if origin_netuid == destination_netuid: subnet = await subtensor.subnet(origin_netuid) - received_amount_tao = subnet.alpha_to_tao(amount_to_move) - received_amount_tao -= stake_fee + received_amount_tao = subnet.alpha_to_tao(amount_to_move - stake_fee) if received_amount_tao < Balance.from_tao(0): print_error("Not enough Alpha to pay the transaction fee.") @@ -60,8 +59,7 @@ async def display_stake_movement_cross_subnets( price_destination = dynamic_destination.price.tao rate = price_origin / (price_destination or 1) - received_amount_tao = dynamic_origin.alpha_to_tao(amount_to_move) - received_amount_tao -= stake_fee + received_amount_tao = dynamic_origin.alpha_to_tao(amount_to_move - stake_fee) received_amount = dynamic_destination.tao_to_alpha(received_amount_tao) received_amount.set_unit(destination_netuid) From da29bd83f26736c24afda3d3a5946462674cd8f0 Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Thu, 10 Jul 2025 19:20:01 +0200 Subject: [PATCH 2/5] Ensure stake fee is correctly applied netuid unit --- bittensor_cli/src/bittensor/subtensor_interface.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bittensor_cli/src/bittensor/subtensor_interface.py b/bittensor_cli/src/bittensor/subtensor_interface.py index e5b5eac12..50fc443c0 100644 --- a/bittensor_cli/src/bittensor/subtensor_interface.py +++ b/bittensor_cli/src/bittensor/subtensor_interface.py @@ -1534,7 +1534,7 @@ async def get_stake_fee( if destination_hotkey_ss58 is not None and destination_netuid is not None: destination = (destination_hotkey_ss58, destination_netuid) - result = await self.query_runtime_api( + result_ = await self.query_runtime_api( runtime_api="StakeInfoRuntimeApi", method="get_stake_fee", params=[ @@ -1546,8 +1546,10 @@ async def get_stake_fee( ], block_hash=block_hash, ) + result = Balance.from_rao(result_) + result.set_unit(origin_netuid) - return Balance.from_rao(result) + return result async def get_scheduled_coldkey_swap( self, From 14aad33be4e730d1c9129b8c947df94b3ffd3898 Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Thu, 10 Jul 2025 19:20:10 +0200 Subject: [PATCH 3/5] Improve error message --- bittensor_cli/src/commands/stake/move.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bittensor_cli/src/commands/stake/move.py b/bittensor_cli/src/commands/stake/move.py index 5e10e8080..ede380597 100644 --- a/bittensor_cli/src/commands/stake/move.py +++ b/bittensor_cli/src/commands/stake/move.py @@ -39,12 +39,15 @@ async def display_stake_movement_cross_subnets( if origin_netuid == destination_netuid: subnet = await subtensor.subnet(origin_netuid) received_amount_tao = subnet.alpha_to_tao(amount_to_move - stake_fee) + received_amount = subnet.tao_to_alpha(received_amount_tao) - if received_amount_tao < Balance.from_tao(0): - print_error("Not enough Alpha to pay the transaction fee.") + if received_amount < Balance.from_tao(0).set_unit(destination_netuid): + print_error( + f"Not enough Alpha to pay the transaction fee. The fee is {stake_fee}, " + f"which would set the total received to {received_amount}." + ) raise ValueError - received_amount = subnet.tao_to_alpha(received_amount_tao) price = subnet.price.tao price_str = ( str(float(price)) @@ -63,8 +66,11 @@ async def display_stake_movement_cross_subnets( received_amount = dynamic_destination.tao_to_alpha(received_amount_tao) received_amount.set_unit(destination_netuid) - if received_amount < Balance.from_tao(0): - print_error("Not enough Alpha to pay the transaction fee.") + if received_amount < Balance.from_tao(0).set_unit(destination_netuid): + print_error( + f"Not enough Alpha to pay the transaction fee. The fee is {stake_fee}, " + f"which would set the total received to {received_amount}." + ) raise ValueError price_str = ( From 79bcb7f10fdf64733e93641d56f2ed860eae28b5 Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Thu, 10 Jul 2025 22:34:00 +0200 Subject: [PATCH 4/5] Remove `--slippage` alias --- bittensor_cli/cli.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/bittensor_cli/cli.py b/bittensor_cli/cli.py index bb1c5126a..fdf7ce2a2 100755 --- a/bittensor_cli/cli.py +++ b/bittensor_cli/cli.py @@ -277,8 +277,6 @@ def edit_help(cls, option_name: str, help_text: str): ) rate_tolerance = typer.Option( None, - "--slippage", - "--slippage-tolerance", "--tolerance", "--rate-tolerance", help="Set the rate tolerance percentage for transactions (default: 0.05 for 5%).", @@ -1257,8 +1255,6 @@ def set_config( ), rate_tolerance: Optional[float] = typer.Option( None, - "--slippage", - "--slippage-tolerance", "--tolerance", help="Set the rate tolerance percentage for transactions (e.g. 0.1 for 0.1%).", ), @@ -1404,9 +1400,7 @@ def del_config( wallet_hotkey: bool = typer.Option(False, *Options.wallet_hotkey.param_decls), network: bool = typer.Option(False, *Options.network.param_decls), use_cache: bool = typer.Option(False, "--cache"), - rate_tolerance: bool = typer.Option( - False, "--slippage", "--slippage-tolerance", "--tolerance" - ), + rate_tolerance: bool = typer.Option(False, "--tolerance"), safe_staking: bool = typer.Option( False, "--safe-staking/--no-safe-staking", "--safe/--unsafe" ), From 20d5d68b0a0f1d093b55100d63f82e4f669a6f8a Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Thu, 10 Jul 2025 22:38:57 +0200 Subject: [PATCH 5/5] Fix tests --- bittensor_cli/src/bittensor/subtensor_interface.py | 3 ++- tests/e2e_tests/test_unstaking.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bittensor_cli/src/bittensor/subtensor_interface.py b/bittensor_cli/src/bittensor/subtensor_interface.py index 50fc443c0..4ae3861a1 100644 --- a/bittensor_cli/src/bittensor/subtensor_interface.py +++ b/bittensor_cli/src/bittensor/subtensor_interface.py @@ -1547,7 +1547,8 @@ async def get_stake_fee( block_hash=block_hash, ) result = Balance.from_rao(result_) - result.set_unit(origin_netuid) + if isinstance(origin_netuid, int): + result.set_unit(origin_netuid) return result diff --git a/tests/e2e_tests/test_unstaking.py b/tests/e2e_tests/test_unstaking.py index e28c54df6..68af71087 100644 --- a/tests/e2e_tests/test_unstaking.py +++ b/tests/e2e_tests/test_unstaking.py @@ -231,7 +231,7 @@ def test_unstaking(local_chain, wallet_setup): "144", ], ) - assert "✅ Finalized" in stake_result.stdout + assert "✅ Finalized" in stake_result.stdout, stake_result.stderr stake_list = exec_command_bob( command="stake",