Skip to content

Commit 990912f

Browse files
committed
Update logic flow.
1 parent 66389e6 commit 990912f

File tree

1 file changed

+23
-27
lines changed
  • bittensor_cli/src/commands/stake

1 file changed

+23
-27
lines changed

bittensor_cli/src/commands/stake/add.py

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -359,19 +359,6 @@ async def stake_extrinsic(
359359
# Temporary workaround - calculations without slippage
360360
current_price_float = float(subnet_info.price.tao)
361361
rate = 1.0 / current_price_float
362-
received_amount = rate * amount_to_stake
363-
364-
# Add rows for the table
365-
base_row = [
366-
str(netuid), # netuid
367-
f"{hotkey[1]}", # hotkey
368-
str(amount_to_stake), # amount
369-
str(rate)
370-
+ f" {Balance.get_unit(netuid)}/{Balance.get_unit(0)} ", # rate
371-
str(received_amount.set_unit(netuid)), # received
372-
str(stake_fee), # fee
373-
# str(slippage_pct), # slippage
374-
]
375362

376363
# If we are staking safe, add price tolerance
377364
if safe_staking:
@@ -395,24 +382,33 @@ async def stake_extrinsic(
395382
price_limit=price_with_tolerance,
396383
)
397384
prices_with_tolerance.append(price_with_tolerance)
398-
base_row.extend(
399-
[
400-
str(extrinsic_fee),
401-
f"{rate_with_tolerance} {Balance.get_unit(netuid)}/{Balance.get_unit(0)} ",
402-
f"[{'dark_sea_green3' if allow_partial_stake else 'red'}]"
403-
# safe staking
404-
f"{allow_partial_stake}[/{'dark_sea_green3' if allow_partial_stake else 'red'}]",
405-
]
406-
)
385+
row_extension = [
386+
f"{rate_with_tolerance} {Balance.get_unit(netuid)}/{Balance.get_unit(0)} ",
387+
f"[{'dark_sea_green3' if allow_partial_stake else 'red'}]"
388+
# safe staking
389+
f"{allow_partial_stake}[/{'dark_sea_green3' if allow_partial_stake else 'red'}]",
390+
]
407391
else:
408392
extrinsic_fee = await get_stake_extrinsic_fee(
409393
netuid_=netuid,
410394
amount_=amount_to_stake,
411395
staking_address_=hotkey[1],
412396
safe_staking_=safe_staking,
413397
)
414-
base_row.append(str(extrinsic_fee))
415-
398+
row_extension = []
399+
received_amount = rate * (amount_to_stake - stake_fee - extrinsic_fee)
400+
# Add rows for the table
401+
base_row = [
402+
str(netuid), # netuid
403+
f"{hotkey[1]}", # hotkey
404+
str(amount_to_stake), # amount
405+
str(rate)
406+
+ f" {Balance.get_unit(netuid)}/{Balance.get_unit(0)} ", # rate
407+
str(received_amount.set_unit(netuid)), # received
408+
str(stake_fee), # fee
409+
str(extrinsic_fee),
410+
# str(slippage_pct), # slippage
411+
] + row_extension
416412
rows.append(tuple(base_row))
417413

418414
# Define and print stake table + slippage warning
@@ -611,17 +607,17 @@ def _define_stake_table(
611607
"Hotkey", justify="center", style=COLOR_PALETTE["GENERAL"]["HOTKEY"]
612608
)
613609
table.add_column(
614-
f"Amount ({Balance.get_unit(0)})",
610+
"Amount (τ)",
615611
justify="center",
616612
style=COLOR_PALETTE["POOLS"]["TAO"],
617613
)
618614
table.add_column(
619-
f"Rate (per {Balance.get_unit(0)})",
615+
"Rate (per τ)",
620616
justify="center",
621617
style=COLOR_PALETTE["POOLS"]["RATE"],
622618
)
623619
table.add_column(
624-
"Received",
620+
"Est. Received",
625621
justify="center",
626622
style=COLOR_PALETTE["POOLS"]["TAO_EQUIV"],
627623
)

0 commit comments

Comments
 (0)