bittensor-cli 9.0.1__py3-none-any.whl → 9.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bittensor_cli/__init__.py +2 -3
- bittensor_cli/cli.py +79 -33
- bittensor_cli/src/__init__.py +1 -1
- bittensor_cli/src/bittensor/balances.py +1 -1
- bittensor_cli/src/bittensor/chain_data.py +17 -7
- bittensor_cli/src/bittensor/subtensor_interface.py +37 -26
- bittensor_cli/src/commands/stake/add.py +4 -10
- bittensor_cli/src/commands/stake/children_hotkeys.py +3 -1
- bittensor_cli/src/commands/stake/list.py +36 -61
- bittensor_cli/src/commands/stake/move.py +14 -21
- bittensor_cli/src/commands/stake/remove.py +217 -107
- bittensor_cli/src/commands/subnets/subnets.py +9 -12
- bittensor_cli/src/commands/sudo.py +131 -37
- bittensor_cli/src/commands/wallets.py +48 -10
- bittensor_cli/version.py +19 -0
- {bittensor_cli-9.0.1.dist-info → bittensor_cli-9.0.3.dist-info}/METADATA +3 -3
- bittensor_cli-9.0.3.dist-info/RECORD +35 -0
- bittensor_cli-9.0.1.dist-info/RECORD +0 -34
- {bittensor_cli-9.0.1.dist-info → bittensor_cli-9.0.3.dist-info}/WHEEL +0 -0
- {bittensor_cli-9.0.1.dist-info → bittensor_cli-9.0.3.dist-info}/entry_points.txt +0 -0
- {bittensor_cli-9.0.1.dist-info → bittensor_cli-9.0.3.dist-info}/top_level.txt +0 -0
@@ -58,7 +58,6 @@ async def stake_list(
|
|
58
58
|
def define_table(
|
59
59
|
hotkey_name: str,
|
60
60
|
rows: list[list[str]],
|
61
|
-
total_tao_ownership: Balance,
|
62
61
|
total_tao_value: Balance,
|
63
62
|
total_swapped_tao_value: Balance,
|
64
63
|
live: bool = False,
|
@@ -130,6 +129,11 @@ async def stake_list(
|
|
130
129
|
style=COLOR_PALETTE["POOLS"]["EMISSION"],
|
131
130
|
justify="right",
|
132
131
|
)
|
132
|
+
table.add_column(
|
133
|
+
f"[white]Emission \n({Balance.get_unit(0)}/block)",
|
134
|
+
style=COLOR_PALETTE["POOLS"]["EMISSION"],
|
135
|
+
justify="right",
|
136
|
+
)
|
133
137
|
return table
|
134
138
|
|
135
139
|
def create_table(hotkey_: str, substakes: list[StakeInfo]):
|
@@ -139,7 +143,6 @@ async def stake_list(
|
|
139
143
|
else hotkey_
|
140
144
|
)
|
141
145
|
rows = []
|
142
|
-
total_tao_ownership = Balance(0)
|
143
146
|
total_tao_value = Balance(0)
|
144
147
|
total_swapped_tao_value = Balance(0)
|
145
148
|
root_stakes = [s for s in substakes if s.netuid == 0]
|
@@ -155,14 +158,6 @@ async def stake_list(
|
|
155
158
|
netuid = substake_.netuid
|
156
159
|
pool = dynamic_info[netuid]
|
157
160
|
symbol = f"{Balance.get_unit(netuid)}\u200e"
|
158
|
-
# TODO: what is this price var for?
|
159
|
-
price = (
|
160
|
-
"{:.4f}{}".format(
|
161
|
-
pool.price.__float__(), f" τ/{Balance.get_unit(netuid)}\u200e"
|
162
|
-
)
|
163
|
-
if pool.is_dynamic
|
164
|
-
else (f" 1.0000 τ/{symbol} ")
|
165
|
-
)
|
166
161
|
|
167
162
|
# Alpha value cell
|
168
163
|
alpha_value = Balance.from_rao(int(substake_.stake.rao)).set_unit(netuid)
|
@@ -192,30 +187,11 @@ async def stake_list(
|
|
192
187
|
else f"{swapped_tao_value} ({slippage_percentage})"
|
193
188
|
)
|
194
189
|
|
195
|
-
# TAO locked cell
|
196
|
-
tao_locked = pool.tao_in
|
197
|
-
|
198
|
-
# Issuance cell
|
199
|
-
issuance = pool.alpha_out if pool.is_dynamic else tao_locked
|
200
|
-
|
201
190
|
# Per block emission cell
|
202
191
|
per_block_emission = substake_.emission.tao / (pool.tempo or 1)
|
192
|
+
per_block_tao_emission = substake_.tao_emission.tao / (pool.tempo or 1)
|
203
193
|
# Alpha ownership and TAO ownership cells
|
204
194
|
if alpha_value.tao > 0.00009:
|
205
|
-
if issuance.tao != 0:
|
206
|
-
# TODO figure out why this alpha_ownership does nothing
|
207
|
-
alpha_ownership = "{:.4f}".format(
|
208
|
-
(alpha_value.tao / issuance.tao) * 100
|
209
|
-
)
|
210
|
-
tao_ownership = Balance.from_tao(
|
211
|
-
(alpha_value.tao / issuance.tao) * tao_locked.tao
|
212
|
-
)
|
213
|
-
total_tao_ownership += tao_ownership
|
214
|
-
else:
|
215
|
-
# TODO what's this var for?
|
216
|
-
alpha_ownership = "0.0000"
|
217
|
-
tao_ownership = Balance.from_tao(0)
|
218
|
-
|
219
195
|
stake_value = (
|
220
196
|
millify_tao(substake_.stake.tao)
|
221
197
|
if not verbose
|
@@ -243,15 +219,14 @@ async def stake_list(
|
|
243
219
|
# Removing this flag for now, TODO: Confirm correct values are here w.r.t CHKs
|
244
220
|
# if substake_.is_registered
|
245
221
|
# else f"[{COLOR_PALETTE['STAKE']['NOT_REGISTERED']}]N/A", # Emission(α/block)
|
222
|
+
str(Balance.from_tao(per_block_tao_emission)),
|
246
223
|
]
|
247
224
|
)
|
248
|
-
table = define_table(
|
249
|
-
name, rows, total_tao_ownership, total_tao_value, total_swapped_tao_value
|
250
|
-
)
|
225
|
+
table = define_table(name, rows, total_tao_value, total_swapped_tao_value)
|
251
226
|
for row in rows:
|
252
227
|
table.add_row(*row)
|
253
228
|
console.print(table)
|
254
|
-
return
|
229
|
+
return total_tao_value, total_swapped_tao_value
|
255
230
|
|
256
231
|
def create_live_table(
|
257
232
|
substakes: list,
|
@@ -263,7 +238,6 @@ async def stake_list(
|
|
263
238
|
rows = []
|
264
239
|
current_data = {}
|
265
240
|
|
266
|
-
total_tao_ownership = Balance(0)
|
267
241
|
total_tao_value = Balance(0)
|
268
242
|
total_swapped_tao_value = Balance(0)
|
269
243
|
|
@@ -324,17 +298,6 @@ async def stake_list(
|
|
324
298
|
)
|
325
299
|
total_swapped_tao_value += swapped_tao_value
|
326
300
|
|
327
|
-
# Calculate TAO ownership
|
328
|
-
tao_locked = pool.tao_in
|
329
|
-
issuance = pool.alpha_out if pool.is_dynamic else tao_locked
|
330
|
-
if alpha_value.tao > 0.00009 and issuance.tao != 0:
|
331
|
-
tao_ownership = Balance.from_tao(
|
332
|
-
(alpha_value.tao / issuance.tao) * tao_locked.tao
|
333
|
-
)
|
334
|
-
total_tao_ownership += tao_ownership
|
335
|
-
else:
|
336
|
-
tao_ownership = Balance.from_tao(0)
|
337
|
-
|
338
301
|
# Store current values for future delta tracking
|
339
302
|
current_data[netuid] = {
|
340
303
|
"stake": alpha_value.tao,
|
@@ -342,7 +305,7 @@ async def stake_list(
|
|
342
305
|
"tao_value": tao_value.tao,
|
343
306
|
"swapped_value": swapped_tao_value.tao,
|
344
307
|
"emission": substake.emission.tao / (pool.tempo or 1),
|
345
|
-
"
|
308
|
+
"tao_emission": substake.tao_emission.tao / (pool.tempo or 1),
|
346
309
|
}
|
347
310
|
|
348
311
|
# Get previous values for delta tracking
|
@@ -399,6 +362,16 @@ async def stake_list(
|
|
399
362
|
unit_first=unit_first,
|
400
363
|
precision=4,
|
401
364
|
)
|
365
|
+
|
366
|
+
tao_emission_value = substake.tao_emission.tao / (pool.tempo or 1)
|
367
|
+
tao_emission_cell = format_cell(
|
368
|
+
tao_emission_value,
|
369
|
+
prev.get("tao_emission"),
|
370
|
+
unit="τ",
|
371
|
+
unit_first=unit_first,
|
372
|
+
precision=4,
|
373
|
+
)
|
374
|
+
|
402
375
|
subnet_name_cell = (
|
403
376
|
f"[{COLOR_PALETTE['GENERAL']['SYMBOL']}]{symbol if netuid != 0 else 'τ'}[/{COLOR_PALETTE['GENERAL']['SYMBOL']}]"
|
404
377
|
f" {get_subnet_name(dynamic_info[netuid])}"
|
@@ -416,13 +389,13 @@ async def stake_list(
|
|
416
389
|
if substake.is_registered
|
417
390
|
else f"[{COLOR_PALETTE['STAKE']['NOT_REGISTERED']}]NO", # Registration status
|
418
391
|
emission_cell, # Emission rate
|
392
|
+
tao_emission_cell, # TAO emission rate
|
419
393
|
]
|
420
394
|
)
|
421
395
|
|
422
396
|
table = define_table(
|
423
397
|
hotkey_name,
|
424
398
|
rows,
|
425
|
-
total_tao_ownership,
|
426
399
|
total_tao_value,
|
427
400
|
total_swapped_tao_value,
|
428
401
|
live=True,
|
@@ -458,7 +431,7 @@ async def stake_list(
|
|
458
431
|
raise typer.Exit()
|
459
432
|
|
460
433
|
if live:
|
461
|
-
# Select one
|
434
|
+
# Select one hotkey for live monitoring
|
462
435
|
if len(hotkeys_to_substakes) > 1:
|
463
436
|
console.print(
|
464
437
|
"\n[bold]Multiple hotkeys found. Please select one for live monitoring:[/bold]"
|
@@ -562,27 +535,29 @@ async def stake_list(
|
|
562
535
|
# Iterate over each hotkey and make a table
|
563
536
|
counter = 0
|
564
537
|
num_hotkeys = len(hotkeys_to_substakes)
|
565
|
-
|
566
|
-
|
538
|
+
all_hks_swapped_tao_value = Balance(0)
|
539
|
+
all_hks_tao_value = Balance(0)
|
567
540
|
for hotkey in hotkeys_to_substakes.keys():
|
568
541
|
counter += 1
|
569
|
-
|
570
|
-
|
571
|
-
|
542
|
+
tao_value, swapped_tao_value = create_table(
|
543
|
+
hotkey, hotkeys_to_substakes[hotkey]
|
544
|
+
)
|
545
|
+
all_hks_tao_value += tao_value
|
546
|
+
all_hks_swapped_tao_value += swapped_tao_value
|
572
547
|
|
573
548
|
if num_hotkeys > 1 and counter < num_hotkeys and prompt:
|
574
549
|
console.print("\nPress Enter to continue to the next hotkey...")
|
575
550
|
input()
|
576
551
|
|
577
552
|
total_tao_value = (
|
578
|
-
f"τ {millify_tao(
|
553
|
+
f"τ {millify_tao(all_hks_tao_value.tao)}"
|
579
554
|
if not verbose
|
580
|
-
else
|
555
|
+
else all_hks_tao_value
|
581
556
|
)
|
582
|
-
|
583
|
-
f"τ {millify_tao(
|
557
|
+
total_swapped_tao_value = (
|
558
|
+
f"τ {millify_tao(all_hks_swapped_tao_value.tao)}"
|
584
559
|
if not verbose
|
585
|
-
else
|
560
|
+
else all_hks_swapped_tao_value
|
586
561
|
)
|
587
562
|
|
588
563
|
console.print("\n\n")
|
@@ -590,8 +565,8 @@ async def stake_list(
|
|
590
565
|
f"Wallet:\n"
|
591
566
|
f" Coldkey SS58: [{COLOR_PALETTE['GENERAL']['COLDKEY']}]{coldkey_address}[/{COLOR_PALETTE['GENERAL']['COLDKEY']}]\n"
|
592
567
|
f" Free Balance: [{COLOR_PALETTE['GENERAL']['BALANCE']}]{balance}[/{COLOR_PALETTE['GENERAL']['BALANCE']}]\n"
|
593
|
-
f" Total TAO ({Balance.unit}): [{COLOR_PALETTE['GENERAL']['BALANCE']}]{
|
594
|
-
f" Total Value ({Balance.unit}): [{COLOR_PALETTE['GENERAL']['BALANCE']}]{
|
568
|
+
f" Total TAO Value ({Balance.unit}): [{COLOR_PALETTE['GENERAL']['BALANCE']}]{total_tao_value}[/{COLOR_PALETTE['GENERAL']['BALANCE']}]\n"
|
569
|
+
f" Total TAO Swapped Value ({Balance.unit}): [{COLOR_PALETTE['GENERAL']['BALANCE']}]{total_swapped_tao_value}[/{COLOR_PALETTE['GENERAL']['BALANCE']}]"
|
595
570
|
)
|
596
571
|
if not sub_stakes:
|
597
572
|
console.print(
|
@@ -17,6 +17,7 @@ from bittensor_cli.src.bittensor.utils import (
|
|
17
17
|
format_error_message,
|
18
18
|
group_subnets,
|
19
19
|
get_subnet_name,
|
20
|
+
unlock_key,
|
20
21
|
)
|
21
22
|
|
22
23
|
if TYPE_CHECKING:
|
@@ -621,10 +622,7 @@ async def move_stake(
|
|
621
622
|
raise typer.Exit()
|
622
623
|
|
623
624
|
# Perform moving operation.
|
624
|
-
|
625
|
-
wallet.unlock_coldkey()
|
626
|
-
except KeyFileError:
|
627
|
-
err_console.print("Error decrypting coldkey (possibly incorrect password)")
|
625
|
+
if not unlock_key(wallet).success:
|
628
626
|
return False
|
629
627
|
with console.status(
|
630
628
|
f"\n:satellite: Moving [blue]{amount_to_move_as_balance}[/blue] from [blue]{origin_hotkey}[/blue] on netuid: [blue]{origin_netuid}[/blue] \nto "
|
@@ -697,6 +695,7 @@ async def transfer_stake(
|
|
697
695
|
wallet: Wallet,
|
698
696
|
subtensor: "SubtensorInterface",
|
699
697
|
amount: float,
|
698
|
+
origin_hotkey: str,
|
700
699
|
origin_netuid: int,
|
701
700
|
dest_netuid: int,
|
702
701
|
dest_coldkey_ss58: str,
|
@@ -709,6 +708,7 @@ async def transfer_stake(
|
|
709
708
|
wallet (Wallet): Bittensor wallet object.
|
710
709
|
subtensor (SubtensorInterface): Subtensor interface instance.
|
711
710
|
amount (float): Amount to transfer.
|
711
|
+
origin_hotkey (str): The hotkey SS58 to transfer the stake from.
|
712
712
|
origin_netuid (int): The netuid to transfer stake from.
|
713
713
|
dest_netuid (int): The netuid to transfer stake to.
|
714
714
|
dest_coldkey_ss58 (str): The destination coldkey to transfer stake to.
|
@@ -739,16 +739,15 @@ async def transfer_stake(
|
|
739
739
|
return False
|
740
740
|
|
741
741
|
# Get current stake balances
|
742
|
-
hotkey_ss58 = wallet.hotkey.ss58_address
|
743
742
|
with console.status(f"Retrieving stake data from {subtensor.network}..."):
|
744
743
|
current_stake = await subtensor.get_stake(
|
745
744
|
coldkey_ss58=wallet.coldkeypub.ss58_address,
|
746
|
-
hotkey_ss58=
|
745
|
+
hotkey_ss58=origin_hotkey,
|
747
746
|
netuid=origin_netuid,
|
748
747
|
)
|
749
748
|
current_dest_stake = await subtensor.get_stake(
|
750
749
|
coldkey_ss58=dest_coldkey_ss58,
|
751
|
-
hotkey_ss58=
|
750
|
+
hotkey_ss58=origin_hotkey,
|
752
751
|
netuid=dest_netuid,
|
753
752
|
)
|
754
753
|
amount_to_transfer = Balance.from_tao(amount).set_unit(origin_netuid)
|
@@ -768,8 +767,8 @@ async def transfer_stake(
|
|
768
767
|
subtensor=subtensor,
|
769
768
|
origin_netuid=origin_netuid,
|
770
769
|
destination_netuid=dest_netuid,
|
771
|
-
origin_hotkey=
|
772
|
-
destination_hotkey=
|
770
|
+
origin_hotkey=origin_hotkey,
|
771
|
+
destination_hotkey=origin_hotkey,
|
773
772
|
amount_to_move=amount_to_transfer,
|
774
773
|
)
|
775
774
|
|
@@ -777,10 +776,7 @@ async def transfer_stake(
|
|
777
776
|
raise typer.Exit()
|
778
777
|
|
779
778
|
# Perform transfer operation
|
780
|
-
|
781
|
-
wallet.unlock_coldkey()
|
782
|
-
except KeyFileError:
|
783
|
-
err_console.print("Error decrypting coldkey (possibly incorrect password)")
|
779
|
+
if not unlock_key(wallet).success:
|
784
780
|
return False
|
785
781
|
|
786
782
|
with console.status("\n:satellite: Transferring stake ..."):
|
@@ -789,7 +785,7 @@ async def transfer_stake(
|
|
789
785
|
call_function="transfer_stake",
|
790
786
|
call_params={
|
791
787
|
"destination_coldkey": dest_coldkey_ss58,
|
792
|
-
"hotkey":
|
788
|
+
"hotkey": origin_hotkey,
|
793
789
|
"origin_netuid": origin_netuid,
|
794
790
|
"destination_netuid": dest_netuid,
|
795
791
|
"alpha_amount": amount_to_transfer.rao,
|
@@ -820,12 +816,12 @@ async def transfer_stake(
|
|
820
816
|
new_stake, new_dest_stake = await asyncio.gather(
|
821
817
|
subtensor.get_stake(
|
822
818
|
coldkey_ss58=wallet.coldkeypub.ss58_address,
|
823
|
-
hotkey_ss58=
|
819
|
+
hotkey_ss58=origin_hotkey,
|
824
820
|
netuid=origin_netuid,
|
825
821
|
),
|
826
822
|
subtensor.get_stake(
|
827
823
|
coldkey_ss58=dest_coldkey_ss58,
|
828
|
-
hotkey_ss58=
|
824
|
+
hotkey_ss58=origin_hotkey,
|
829
825
|
netuid=dest_netuid,
|
830
826
|
),
|
831
827
|
)
|
@@ -905,7 +901,7 @@ async def swap_stake(
|
|
905
901
|
)
|
906
902
|
|
907
903
|
if swap_all:
|
908
|
-
amount_to_swap =
|
904
|
+
amount_to_swap = current_stake.set_unit(origin_netuid)
|
909
905
|
else:
|
910
906
|
amount_to_swap = Balance.from_tao(amount).set_unit(origin_netuid)
|
911
907
|
|
@@ -933,10 +929,7 @@ async def swap_stake(
|
|
933
929
|
raise typer.Exit()
|
934
930
|
|
935
931
|
# Perform swap operation
|
936
|
-
|
937
|
-
wallet.unlock_coldkey()
|
938
|
-
except KeyFileError:
|
939
|
-
err_console.print("Error decrypting coldkey (possibly incorrect password)")
|
932
|
+
if not unlock_key(wallet).success:
|
940
933
|
return False
|
941
934
|
|
942
935
|
with console.status(
|