From c205d266fcfc1dc0f2a08ec334e0a7a9a83363f4 Mon Sep 17 00:00:00 2001 From: ibraheem-latent Date: Wed, 14 Jan 2026 10:58:44 -0800 Subject: [PATCH 1/4] add print_protection_warnings --- bittensor_cli/src/bittensor/utils.py | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/bittensor_cli/src/bittensor/utils.py b/bittensor_cli/src/bittensor/utils.py index d6375927..53a4e419 100644 --- a/bittensor_cli/src/bittensor/utils.py +++ b/bittensor_cli/src/bittensor/utils.py @@ -167,6 +167,42 @@ def print_success(message: str, status=None): print_console(success_message, "green", console) +def print_protection_warnings( + mev_protection: bool, + safe_staking: Optional[bool] = None, + command_name: str = "", +) -> None: + """ + Print warnings about missing MEV protection and/or limit price protection. + + Args: + mev_protection: Whether MEV protection is enabled. + safe_staking: Whether safe staking (limit price protection) is enabled. + None if limit price protection is not available for this command. + command_name: Name of the command (e.g., "stake add") for context. + """ + warnings = [] + + if not mev_protection: + warnings.append( + "⚠️ [dim][yellow]Warning:[/yellow] MEV protection is disabled. " + "This transaction may be exposed to MEV attacks.[/dim]" + ) + + if safe_staking is not None and not safe_staking: + warnings.append( + "⚠️ [dim][yellow]Warning:[/yellow] Limit price protection (safe staking) is disabled. " + "This transaction may be subject to slippage.[/dim]" + ) + + if warnings: + if command_name: + console.print(f"\n[dim]Protection status for '{command_name}':[/dim]") + for warning in warnings: + console.print(warning) + console.print() + + RAO_PER_TAO = 1e9 U16_MAX = 65535 U64_MAX = 18446744073709551615 From 9481b4078fb0bfbd7884d587f7aaad8384435b5b Mon Sep 17 00:00:00 2001 From: ibraheem-latent Date: Wed, 14 Jan 2026 10:59:07 -0800 Subject: [PATCH 2/4] adds protection warnings to cmds --- bittensor_cli/cli.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/bittensor_cli/cli.py b/bittensor_cli/cli.py index c0a2c155..380fddeb 100755 --- a/bittensor_cli/cli.py +++ b/bittensor_cli/cli.py @@ -74,6 +74,7 @@ ProxyAddressBook, ProxyAnnouncements, confirm_action, + print_protection_warnings, ) from bittensor_cli.src.commands import sudo, wallets, view from bittensor_cli.src.commands import weights as weights_cmds @@ -4699,7 +4700,12 @@ def stake_add( if safe_staking: rate_tolerance = self.ask_rate_tolerance(rate_tolerance) allow_partial_stake = self.ask_partial_stake(allow_partial_stake) - console.print("\n") + + print_protection_warnings( + mev_protection=mev_protection, + safe_staking=safe_staking, + command_name="stake add", + ) if netuids: netuids = parse_to_list( @@ -5016,8 +5022,12 @@ def stake_remove( if safe_staking: rate_tolerance = self.ask_rate_tolerance(rate_tolerance) allow_partial_stake = self.ask_partial_stake(allow_partial_stake) - console.print("\n") + print_protection_warnings( + mev_protection=mev_protection, + safe_staking=safe_staking, + command_name="stake remove", + ) if interactive and any( [hotkey_ss58_address, include_hotkeys, exclude_hotkeys, all_hotkeys] ): @@ -5353,6 +5363,11 @@ def stake_move( """ self.verbosity_handler(quiet, verbose, json_output, prompt, decline) proxy = self.is_valid_proxy_name_or_ss58(proxy, announce_only) + print_protection_warnings( + mev_protection=mev_protection, + safe_staking=None, + command_name="stake move", + ) if prompt: if not confirm_action( "This transaction will [bold]move stake[/bold] to another hotkey while keeping the same " @@ -7598,6 +7613,11 @@ def subnets_create( """ self.verbosity_handler(quiet, verbose, json_output, prompt) proxy = self.is_valid_proxy_name_or_ss58(proxy, announce_only) + print_protection_warnings( + mev_protection=mev_protection, + safe_staking=None, + command_name="subnets create", + ) wallet = self.wallet_ask( wallet_name, wallet_path, From ec9331ce2dd34f0127a0ccacbeb0bd24e6c8fe4c Mon Sep 17 00:00:00 2001 From: ibraheem-latent Date: Wed, 14 Jan 2026 11:06:03 -0800 Subject: [PATCH 3/4] add warning to stake swap --- bittensor_cli/cli.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bittensor_cli/cli.py b/bittensor_cli/cli.py index 380fddeb..59e242f0 100755 --- a/bittensor_cli/cli.py +++ b/bittensor_cli/cli.py @@ -5795,6 +5795,15 @@ def stake_swap( "[dim]This command moves stake from one subnet to another subnet while keeping " "the same coldkey-hotkey pair.[/dim]" ) + safe_staking = self.ask_safe_staking(safe_staking) + if safe_staking: + rate_tolerance = self.ask_rate_tolerance(rate_tolerance) + allow_partial_stake = self.ask_partial_stake(allow_partial_stake) + print_protection_warnings( + mev_protection=mev_protection, + safe_staking=safe_staking, + command_name="stake swap", + ) wallet = self.wallet_ask( wallet_name, @@ -5818,10 +5827,6 @@ def stake_swap( ) if not amount and not swap_all: amount = FloatPrompt.ask("Enter the [blue]amount[/blue] to swap") - safe_staking = self.ask_safe_staking(safe_staking) - if safe_staking: - rate_tolerance = self.ask_rate_tolerance(rate_tolerance) - allow_partial_stake = self.ask_partial_stake(allow_partial_stake) logger.debug( "args:\n" From 575a3a2d91aa60714e35bc55151a711ffaa5e0e5 Mon Sep 17 00:00:00 2001 From: ibraheem-latent Date: Wed, 14 Jan 2026 11:06:35 -0800 Subject: [PATCH 4/4] add to stake transfer --- bittensor_cli/cli.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bittensor_cli/cli.py b/bittensor_cli/cli.py index 59e242f0..302e56be 100755 --- a/bittensor_cli/cli.py +++ b/bittensor_cli/cli.py @@ -5589,6 +5589,11 @@ def stake_transfer( """ self.verbosity_handler(quiet, verbose, json_output, prompt, decline) proxy = self.is_valid_proxy_name_or_ss58(proxy, announce_only) + print_protection_warnings( + mev_protection=mev_protection, + safe_staking=None, + command_name="stake transfer", + ) if prompt: if not confirm_action( "This transaction will [bold]transfer ownership[/bold] from one coldkey to another, in subnets "