Skip to content

Commit 97b291c

Browse files
authored
Merge pull request #538 from opentensor/fix/thewhaleking/another-fucking-table
Updates stake move table with rate applied correctly.
2 parents 312a25c + 20d5d68 commit 97b291c

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

bittensor_cli/cli.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,6 @@ def edit_help(cls, option_name: str, help_text: str):
277277
)
278278
rate_tolerance = typer.Option(
279279
None,
280-
"--slippage",
281-
"--slippage-tolerance",
282280
"--tolerance",
283281
"--rate-tolerance",
284282
help="Set the rate tolerance percentage for transactions (default: 0.05 for 5%).",
@@ -1257,8 +1255,6 @@ def set_config(
12571255
),
12581256
rate_tolerance: Optional[float] = typer.Option(
12591257
None,
1260-
"--slippage",
1261-
"--slippage-tolerance",
12621258
"--tolerance",
12631259
help="Set the rate tolerance percentage for transactions (e.g. 0.1 for 0.1%).",
12641260
),
@@ -1404,9 +1400,7 @@ def del_config(
14041400
wallet_hotkey: bool = typer.Option(False, *Options.wallet_hotkey.param_decls),
14051401
network: bool = typer.Option(False, *Options.network.param_decls),
14061402
use_cache: bool = typer.Option(False, "--cache"),
1407-
rate_tolerance: bool = typer.Option(
1408-
False, "--slippage", "--slippage-tolerance", "--tolerance"
1409-
),
1403+
rate_tolerance: bool = typer.Option(False, "--tolerance"),
14101404
safe_staking: bool = typer.Option(
14111405
False, "--safe-staking/--no-safe-staking", "--safe/--unsafe"
14121406
),

bittensor_cli/src/bittensor/subtensor_interface.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,7 @@ async def get_stake_fee(
15341534
if destination_hotkey_ss58 is not None and destination_netuid is not None:
15351535
destination = (destination_hotkey_ss58, destination_netuid)
15361536

1537-
result = await self.query_runtime_api(
1537+
result_ = await self.query_runtime_api(
15381538
runtime_api="StakeInfoRuntimeApi",
15391539
method="get_stake_fee",
15401540
params=[
@@ -1546,8 +1546,11 @@ async def get_stake_fee(
15461546
],
15471547
block_hash=block_hash,
15481548
)
1549+
result = Balance.from_rao(result_)
1550+
if isinstance(origin_netuid, int):
1551+
result.set_unit(origin_netuid)
15491552

1550-
return Balance.from_rao(result)
1553+
return result
15511554

15521555
async def get_scheduled_coldkey_swap(
15531556
self,

bittensor_cli/src/commands/stake/move.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ async def display_stake_movement_cross_subnets(
3838

3939
if origin_netuid == destination_netuid:
4040
subnet = await subtensor.subnet(origin_netuid)
41-
received_amount_tao = subnet.alpha_to_tao(amount_to_move)
42-
received_amount_tao -= stake_fee
41+
received_amount_tao = subnet.alpha_to_tao(amount_to_move - stake_fee)
42+
received_amount = subnet.tao_to_alpha(received_amount_tao)
4343

44-
if received_amount_tao < Balance.from_tao(0):
45-
print_error("Not enough Alpha to pay the transaction fee.")
44+
if received_amount < Balance.from_tao(0).set_unit(destination_netuid):
45+
print_error(
46+
f"Not enough Alpha to pay the transaction fee. The fee is {stake_fee}, "
47+
f"which would set the total received to {received_amount}."
48+
)
4649
raise ValueError
4750

48-
received_amount = subnet.tao_to_alpha(received_amount_tao)
4951
price = subnet.price.tao
5052
price_str = (
5153
str(float(price))
@@ -60,13 +62,15 @@ async def display_stake_movement_cross_subnets(
6062
price_destination = dynamic_destination.price.tao
6163
rate = price_origin / (price_destination or 1)
6264

63-
received_amount_tao = dynamic_origin.alpha_to_tao(amount_to_move)
64-
received_amount_tao -= stake_fee
65+
received_amount_tao = dynamic_origin.alpha_to_tao(amount_to_move - stake_fee)
6566
received_amount = dynamic_destination.tao_to_alpha(received_amount_tao)
6667
received_amount.set_unit(destination_netuid)
6768

68-
if received_amount < Balance.from_tao(0):
69-
print_error("Not enough Alpha to pay the transaction fee.")
69+
if received_amount < Balance.from_tao(0).set_unit(destination_netuid):
70+
print_error(
71+
f"Not enough Alpha to pay the transaction fee. The fee is {stake_fee}, "
72+
f"which would set the total received to {received_amount}."
73+
)
7074
raise ValueError
7175

7276
price_str = (

tests/e2e_tests/test_unstaking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def test_unstaking(local_chain, wallet_setup):
231231
"144",
232232
],
233233
)
234-
assert "✅ Finalized" in stake_result.stdout
234+
assert "✅ Finalized" in stake_result.stdout, stake_result.stderr
235235

236236
stake_list = exec_command_bob(
237237
command="stake",

0 commit comments

Comments
 (0)