bittensor-cli 9.8.7__py3-none-any.whl → 9.10.0__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/cli.py +229 -55
- bittensor_cli/src/bittensor/extrinsics/registration.py +29 -25
- bittensor_cli/src/bittensor/extrinsics/root.py +6 -5
- bittensor_cli/src/bittensor/extrinsics/transfer.py +35 -18
- bittensor_cli/src/bittensor/subtensor_interface.py +34 -15
- bittensor_cli/src/bittensor/utils.py +13 -1
- bittensor_cli/src/commands/stake/add.py +86 -30
- bittensor_cli/src/commands/stake/children_hotkeys.py +16 -14
- bittensor_cli/src/commands/stake/move.py +106 -84
- bittensor_cli/src/commands/stake/remove.py +119 -11
- bittensor_cli/src/commands/subnets/price.py +126 -30
- bittensor_cli/src/commands/subnets/subnets.py +3 -2
- bittensor_cli/src/commands/sudo.py +13 -11
- bittensor_cli/src/commands/wallets.py +159 -19
- bittensor_cli/src/commands/weights.py +2 -1
- {bittensor_cli-9.8.7.dist-info → bittensor_cli-9.10.0.dist-info}/METADATA +14 -6
- {bittensor_cli-9.8.7.dist-info → bittensor_cli-9.10.0.dist-info}/RECORD +20 -20
- {bittensor_cli-9.8.7.dist-info → bittensor_cli-9.10.0.dist-info}/WHEEL +0 -0
- {bittensor_cli-9.8.7.dist-info → bittensor_cli-9.10.0.dist-info}/entry_points.txt +0 -0
- {bittensor_cli-9.8.7.dist-info → bittensor_cli-9.10.0.dist-info}/top_level.txt +0 -0
@@ -21,6 +21,7 @@ from bittensor_cli.src.bittensor.utils import (
|
|
21
21
|
format_error_message,
|
22
22
|
unlock_key,
|
23
23
|
json_console,
|
24
|
+
get_hotkey_pub_ss58,
|
24
25
|
)
|
25
26
|
|
26
27
|
|
@@ -464,7 +465,7 @@ async def get_children(
|
|
464
465
|
netuid_children_tuples = []
|
465
466
|
for netuid_ in netuids:
|
466
467
|
success, children, err_mg = await subtensor.get_children(
|
467
|
-
wallet
|
468
|
+
get_hotkey_pub_ss58(wallet), netuid_
|
468
469
|
)
|
469
470
|
if children:
|
470
471
|
netuid_children_tuples.append((netuid_, children))
|
@@ -472,16 +473,16 @@ async def get_children(
|
|
472
473
|
err_console.print(
|
473
474
|
f"Failed to get children from subtensor {netuid_}: {err_mg}"
|
474
475
|
)
|
475
|
-
await _render_table(wallet
|
476
|
+
await _render_table(get_hotkey_pub_ss58(wallet), netuid_children_tuples)
|
476
477
|
else:
|
477
478
|
success, children, err_mg = await subtensor.get_children(
|
478
|
-
wallet
|
479
|
+
get_hotkey_pub_ss58(wallet), netuid
|
479
480
|
)
|
480
481
|
if not success:
|
481
482
|
err_console.print(f"Failed to get children from subtensor: {err_mg}")
|
482
483
|
if children:
|
483
484
|
netuid_children_tuples = [(netuid, children)]
|
484
|
-
await _render_table(wallet
|
485
|
+
await _render_table(get_hotkey_pub_ss58(wallet), netuid_children_tuples)
|
485
486
|
|
486
487
|
return children
|
487
488
|
|
@@ -500,12 +501,12 @@ async def set_children(
|
|
500
501
|
"""Set children hotkeys."""
|
501
502
|
# Validate children SS58 addresses
|
502
503
|
# TODO check to see if this should be allowed to be specified by user instead of pulling from wallet
|
503
|
-
hotkey = wallet
|
504
|
+
hotkey = get_hotkey_pub_ss58(wallet)
|
504
505
|
for child in children:
|
505
506
|
if not is_valid_ss58_address(child):
|
506
507
|
err_console.print(f":cross_mark:[red] Invalid SS58 address: {child}[/red]")
|
507
508
|
return
|
508
|
-
if child ==
|
509
|
+
if child == hotkey:
|
509
510
|
err_console.print(":cross_mark:[red] Cannot set yourself as a child.[/red]")
|
510
511
|
return
|
511
512
|
|
@@ -608,7 +609,7 @@ async def revoke_children(
|
|
608
609
|
subtensor=subtensor,
|
609
610
|
wallet=wallet,
|
610
611
|
netuid=netuid,
|
611
|
-
hotkey=wallet
|
612
|
+
hotkey=get_hotkey_pub_ss58(wallet),
|
612
613
|
children_with_proportions=[],
|
613
614
|
prompt=prompt,
|
614
615
|
wait_for_inclusion=wait_for_inclusion,
|
@@ -647,7 +648,7 @@ async def revoke_children(
|
|
647
648
|
subtensor=subtensor,
|
648
649
|
wallet=wallet,
|
649
650
|
netuid=netuid,
|
650
|
-
hotkey=wallet
|
651
|
+
hotkey=get_hotkey_pub_ss58(wallet),
|
651
652
|
children_with_proportions=[],
|
652
653
|
prompt=prompt,
|
653
654
|
wait_for_inclusion=True,
|
@@ -746,7 +747,7 @@ async def childkey_take(
|
|
746
747
|
subtensor=subtensor,
|
747
748
|
wallet=wallet,
|
748
749
|
netuid=subnet,
|
749
|
-
hotkey=wallet
|
750
|
+
hotkey=get_hotkey_pub_ss58(wallet),
|
750
751
|
take=chk_take,
|
751
752
|
prompt=prompt,
|
752
753
|
wait_for_inclusion=wait_for_inclusion,
|
@@ -756,7 +757,7 @@ async def childkey_take(
|
|
756
757
|
if success:
|
757
758
|
console.print(":white_heavy_check_mark: [green]Set childkey take.[/green]")
|
758
759
|
console.print(
|
759
|
-
f"The childkey take for {wallet
|
760
|
+
f"The childkey take for {get_hotkey_pub_ss58(wallet)} is now set to {take * 100:.2f}%."
|
760
761
|
)
|
761
762
|
return True
|
762
763
|
else:
|
@@ -766,9 +767,10 @@ async def childkey_take(
|
|
766
767
|
return False
|
767
768
|
|
768
769
|
# Print childkey take for other user and return (dont offer to change take rate)
|
769
|
-
|
770
|
-
|
771
|
-
|
770
|
+
wallet_hk = get_hotkey_pub_ss58(wallet)
|
771
|
+
if not hotkey or hotkey == wallet_hk:
|
772
|
+
hotkey = wallet_hk
|
773
|
+
if hotkey != wallet_hk or not take:
|
772
774
|
# display childkey take for other users
|
773
775
|
if netuid:
|
774
776
|
await display_chk_take(hotkey, netuid)
|
@@ -826,7 +828,7 @@ async def childkey_take(
|
|
826
828
|
subtensor=subtensor,
|
827
829
|
wallet=wallet,
|
828
830
|
netuid=netuid_,
|
829
|
-
hotkey=
|
831
|
+
hotkey=wallet_hk,
|
830
832
|
take=take,
|
831
833
|
prompt=prompt,
|
832
834
|
wait_for_inclusion=True,
|
@@ -16,6 +16,7 @@ from bittensor_cli.src.bittensor.utils import (
|
|
16
16
|
group_subnets,
|
17
17
|
get_subnet_name,
|
18
18
|
unlock_key,
|
19
|
+
get_hotkey_pub_ss58,
|
19
20
|
)
|
20
21
|
|
21
22
|
if TYPE_CHECKING:
|
@@ -33,12 +34,15 @@ async def display_stake_movement_cross_subnets(
|
|
33
34
|
destination_hotkey: str,
|
34
35
|
amount_to_move: Balance,
|
35
36
|
stake_fee: Balance,
|
37
|
+
extrinsic_fee: Balance,
|
36
38
|
) -> tuple[Balance, str]:
|
37
39
|
"""Calculate and display stake movement information"""
|
38
40
|
|
39
41
|
if origin_netuid == destination_netuid:
|
40
42
|
subnet = await subtensor.subnet(origin_netuid)
|
41
|
-
received_amount_tao =
|
43
|
+
received_amount_tao = (
|
44
|
+
subnet.alpha_to_tao(amount_to_move - stake_fee) - extrinsic_fee
|
45
|
+
)
|
42
46
|
received_amount = subnet.tao_to_alpha(received_amount_tao)
|
43
47
|
|
44
48
|
if received_amount < Balance.from_tao(0).set_unit(destination_netuid):
|
@@ -62,7 +66,9 @@ async def display_stake_movement_cross_subnets(
|
|
62
66
|
price_destination = dynamic_destination.price.tao
|
63
67
|
rate = price_origin / (price_destination or 1)
|
64
68
|
|
65
|
-
received_amount_tao =
|
69
|
+
received_amount_tao = (
|
70
|
+
dynamic_origin.alpha_to_tao(amount_to_move - stake_fee) - extrinsic_fee
|
71
|
+
)
|
66
72
|
received_amount = dynamic_destination.tao_to_alpha(received_amount_tao)
|
67
73
|
received_amount.set_unit(destination_netuid)
|
68
74
|
|
@@ -81,14 +87,14 @@ async def display_stake_movement_cross_subnets(
|
|
81
87
|
# Create and display table
|
82
88
|
table = Table(
|
83
89
|
title=(
|
84
|
-
f"\n[{COLOR_PALETTE
|
90
|
+
f"\n[{COLOR_PALETTE.G.HEADER}]"
|
85
91
|
f"Moving stake from: "
|
86
|
-
f"[{COLOR_PALETTE
|
87
|
-
f"[/{COLOR_PALETTE
|
92
|
+
f"[{COLOR_PALETTE.G.SUBHEAD}]{Balance.get_unit(origin_netuid)}(Netuid: {origin_netuid})"
|
93
|
+
f"[/{COLOR_PALETTE.G.SUBHEAD}] "
|
88
94
|
f"to: "
|
89
|
-
f"[{COLOR_PALETTE
|
90
|
-
f"[/{COLOR_PALETTE
|
91
|
-
f"[/{COLOR_PALETTE
|
95
|
+
f"[{COLOR_PALETTE.G.SUBHEAD}]{Balance.get_unit(destination_netuid)}(Netuid: {destination_netuid})"
|
96
|
+
f"[/{COLOR_PALETTE.G.SUBHEAD}]\nNetwork: {subtensor.network}\n"
|
97
|
+
f"[/{COLOR_PALETTE.G.HEADER}]"
|
92
98
|
),
|
93
99
|
show_footer=True,
|
94
100
|
show_edge=False,
|
@@ -132,6 +138,9 @@ async def display_stake_movement_cross_subnets(
|
|
132
138
|
justify="center",
|
133
139
|
style=COLOR_PALETTE["STAKE"]["STAKE_AMOUNT"],
|
134
140
|
)
|
141
|
+
table.add_column(
|
142
|
+
"Extrinsic Fee (τ)", justify="center", style=COLOR_PALETTE.STAKE.TAO
|
143
|
+
)
|
135
144
|
|
136
145
|
table.add_row(
|
137
146
|
f"{Balance.get_unit(origin_netuid)}({origin_netuid})",
|
@@ -142,6 +151,7 @@ async def display_stake_movement_cross_subnets(
|
|
142
151
|
price_str,
|
143
152
|
str(received_amount),
|
144
153
|
str(stake_fee.set_unit(origin_netuid)),
|
154
|
+
str(extrinsic_fee),
|
145
155
|
)
|
146
156
|
|
147
157
|
console.print(table)
|
@@ -165,10 +175,10 @@ def prompt_stake_amount(
|
|
165
175
|
while True:
|
166
176
|
amount_input = Prompt.ask(
|
167
177
|
f"\nEnter the amount to {action_name} "
|
168
|
-
f"[{COLOR_PALETTE
|
169
|
-
f"[{COLOR_PALETTE
|
178
|
+
f"[{COLOR_PALETTE.S.STAKE_AMOUNT}]{Balance.get_unit(netuid)}[/{COLOR_PALETTE.S.STAKE_AMOUNT}] "
|
179
|
+
f"[{COLOR_PALETTE.S.STAKE_AMOUNT}](max: {current_balance})[/{COLOR_PALETTE.S.STAKE_AMOUNT}] "
|
170
180
|
f"or "
|
171
|
-
f"[{COLOR_PALETTE
|
181
|
+
f"[{COLOR_PALETTE.S.STAKE_AMOUNT}]'all'[/{COLOR_PALETTE.S.STAKE_AMOUNT}] "
|
172
182
|
f"for entire balance"
|
173
183
|
)
|
174
184
|
|
@@ -183,7 +193,7 @@ def prompt_stake_amount(
|
|
183
193
|
if amount > current_balance.tao:
|
184
194
|
console.print(
|
185
195
|
f"[red]Amount exceeds available balance of "
|
186
|
-
f"[{COLOR_PALETTE
|
196
|
+
f"[{COLOR_PALETTE.S.STAKE_AMOUNT}]{current_balance}[/{COLOR_PALETTE.S.STAKE_AMOUNT}]"
|
187
197
|
f"[/red]"
|
188
198
|
)
|
189
199
|
continue
|
@@ -270,8 +280,8 @@ async def stake_move_transfer_selection(
|
|
270
280
|
|
271
281
|
# Display available netuids for selected hotkey
|
272
282
|
table = Table(
|
273
|
-
title=f"\n[{COLOR_PALETTE
|
274
|
-
f"[{COLOR_PALETTE
|
283
|
+
title=f"\n[{COLOR_PALETTE.G.HEADER}]Available Stakes for Hotkey\n[/{COLOR_PALETTE.G.HEADER}]"
|
284
|
+
f"[{COLOR_PALETTE.G.HK}]{origin_hotkey_ss58}[/{COLOR_PALETTE.G.HK}]\n",
|
275
285
|
show_edge=False,
|
276
286
|
header_style="bold white",
|
277
287
|
border_style="bright_black",
|
@@ -279,7 +289,7 @@ async def stake_move_transfer_selection(
|
|
279
289
|
width=len(origin_hotkey_ss58) + 20,
|
280
290
|
)
|
281
291
|
table.add_column("Netuid", style="cyan")
|
282
|
-
table.add_column("Stake Amount", style=COLOR_PALETTE
|
292
|
+
table.add_column("Stake Amount", style=COLOR_PALETTE.STAKE.STAKE_AMOUNT)
|
283
293
|
|
284
294
|
available_netuids = []
|
285
295
|
for netuid in origin_hotkey_info["netuids"]:
|
@@ -334,8 +344,9 @@ async def stake_swap_selection(
|
|
334
344
|
|
335
345
|
# Filter stakes for this hotkey
|
336
346
|
hotkey_stakes = {}
|
347
|
+
hotkey_ss58 = get_hotkey_pub_ss58(wallet)
|
337
348
|
for stake in stakes:
|
338
|
-
if stake.hotkey_ss58 ==
|
349
|
+
if stake.hotkey_ss58 == hotkey_ss58 and stake.stake.tao > 0:
|
339
350
|
hotkey_stakes[stake.netuid] = {
|
340
351
|
"stake": stake.stake,
|
341
352
|
"is_registered": stake.is_registered,
|
@@ -347,13 +358,13 @@ async def stake_swap_selection(
|
|
347
358
|
|
348
359
|
# Display available stakes
|
349
360
|
table = Table(
|
350
|
-
title=f"\n[{COLOR_PALETTE
|
351
|
-
f"[{COLOR_PALETTE
|
361
|
+
title=f"\n[{COLOR_PALETTE.G.HEADER}]Available Stakes for Hotkey\n[/{COLOR_PALETTE.G.HEADER}]"
|
362
|
+
f"[{COLOR_PALETTE.G.HK}]{wallet.hotkey_str}: {hotkey_ss58}[/{COLOR_PALETTE.G.HK}]\n",
|
352
363
|
show_edge=False,
|
353
364
|
header_style="bold white",
|
354
365
|
border_style="bright_black",
|
355
366
|
title_justify="center",
|
356
|
-
width=len(
|
367
|
+
width=len(hotkey_ss58) + 20,
|
357
368
|
)
|
358
369
|
|
359
370
|
table.add_column("Index", justify="right", style="cyan")
|
@@ -366,7 +377,7 @@ async def stake_swap_selection(
|
|
366
377
|
for idx, (netuid, stake_info) in enumerate(sorted(hotkey_stakes.items())):
|
367
378
|
subnet_info = subnet_dict[netuid]
|
368
379
|
subnet_name_cell = (
|
369
|
-
f"[{COLOR_PALETTE
|
380
|
+
f"[{COLOR_PALETTE.G.SYM}]{subnet_info.symbol if netuid != 0 else 'τ'}[/{COLOR_PALETTE.G.SYM}]"
|
370
381
|
f" {get_subnet_name(subnet_info)}"
|
371
382
|
)
|
372
383
|
|
@@ -498,14 +509,28 @@ async def move_stake(
|
|
498
509
|
)
|
499
510
|
return False
|
500
511
|
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
512
|
+
call = await subtensor.substrate.compose_call(
|
513
|
+
call_module="SubtensorModule",
|
514
|
+
call_function="move_stake",
|
515
|
+
call_params={
|
516
|
+
"origin_hotkey": origin_hotkey,
|
517
|
+
"origin_netuid": origin_netuid,
|
518
|
+
"destination_hotkey": destination_hotkey,
|
519
|
+
"destination_netuid": destination_netuid,
|
520
|
+
"alpha_amount": amount_to_move_as_balance.rao,
|
521
|
+
},
|
522
|
+
)
|
523
|
+
stake_fee, extrinsic_fee = await asyncio.gather(
|
524
|
+
subtensor.get_stake_fee(
|
525
|
+
origin_hotkey_ss58=origin_hotkey,
|
526
|
+
origin_netuid=origin_netuid,
|
527
|
+
origin_coldkey_ss58=wallet.coldkeypub.ss58_address,
|
528
|
+
destination_hotkey_ss58=destination_hotkey,
|
529
|
+
destination_netuid=destination_netuid,
|
530
|
+
destination_coldkey_ss58=wallet.coldkeypub.ss58_address,
|
531
|
+
amount=amount_to_move_as_balance.rao,
|
532
|
+
),
|
533
|
+
subtensor.get_extrinsic_fee(call, wallet.coldkeypub),
|
509
534
|
)
|
510
535
|
|
511
536
|
# Display stake movement details
|
@@ -519,6 +544,7 @@ async def move_stake(
|
|
519
544
|
destination_hotkey=destination_hotkey,
|
520
545
|
amount_to_move=amount_to_move_as_balance,
|
521
546
|
stake_fee=stake_fee,
|
547
|
+
extrinsic_fee=extrinsic_fee,
|
522
548
|
)
|
523
549
|
except ValueError:
|
524
550
|
return False
|
@@ -529,20 +555,10 @@ async def move_stake(
|
|
529
555
|
if not unlock_key(wallet).success:
|
530
556
|
return False
|
531
557
|
with console.status(
|
532
|
-
f"\n:satellite: Moving [blue]{amount_to_move_as_balance}[/blue] from [blue]{origin_hotkey}[/blue] on netuid:
|
558
|
+
f"\n:satellite: Moving [blue]{amount_to_move_as_balance}[/blue] from [blue]{origin_hotkey}[/blue] on netuid: "
|
559
|
+
f"[blue]{origin_netuid}[/blue] \nto "
|
533
560
|
f"[blue]{destination_hotkey}[/blue] on netuid: [blue]{destination_netuid}[/blue] ..."
|
534
561
|
):
|
535
|
-
call = await subtensor.substrate.compose_call(
|
536
|
-
call_module="SubtensorModule",
|
537
|
-
call_function="move_stake",
|
538
|
-
call_params={
|
539
|
-
"origin_hotkey": origin_hotkey,
|
540
|
-
"origin_netuid": origin_netuid,
|
541
|
-
"destination_hotkey": destination_hotkey,
|
542
|
-
"destination_netuid": destination_netuid,
|
543
|
-
"alpha_amount": amount_to_move_as_balance.rao,
|
544
|
-
},
|
545
|
-
)
|
546
562
|
extrinsic = await subtensor.substrate.create_signed_extrinsic(
|
547
563
|
call=call, keypair=wallet.coldkey, era={"period": era}
|
548
564
|
)
|
@@ -677,19 +693,33 @@ async def transfer_stake(
|
|
677
693
|
if amount_to_transfer > current_stake:
|
678
694
|
err_console.print(
|
679
695
|
f"[red]Not enough stake to transfer[/red]:\n"
|
680
|
-
f"Stake balance: [{COLOR_PALETTE
|
681
|
-
f"Transfer amount: [{COLOR_PALETTE
|
696
|
+
f"Stake balance: [{COLOR_PALETTE.S.STAKE_AMOUNT}]{current_stake}[/{COLOR_PALETTE.S.STAKE_AMOUNT}] < "
|
697
|
+
f"Transfer amount: [{COLOR_PALETTE.S.STAKE_AMOUNT}]{amount_to_transfer}[/{COLOR_PALETTE.S.STAKE_AMOUNT}]"
|
682
698
|
)
|
683
699
|
return False
|
684
700
|
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
701
|
+
call = await subtensor.substrate.compose_call(
|
702
|
+
call_module="SubtensorModule",
|
703
|
+
call_function="transfer_stake",
|
704
|
+
call_params={
|
705
|
+
"destination_coldkey": dest_coldkey_ss58,
|
706
|
+
"hotkey": origin_hotkey,
|
707
|
+
"origin_netuid": origin_netuid,
|
708
|
+
"destination_netuid": dest_netuid,
|
709
|
+
"alpha_amount": amount_to_transfer.rao,
|
710
|
+
},
|
711
|
+
)
|
712
|
+
stake_fee, extrinsic_fee = await asyncio.gather(
|
713
|
+
subtensor.get_stake_fee(
|
714
|
+
origin_hotkey_ss58=origin_hotkey,
|
715
|
+
origin_netuid=origin_netuid,
|
716
|
+
origin_coldkey_ss58=wallet.coldkeypub.ss58_address,
|
717
|
+
destination_hotkey_ss58=origin_hotkey,
|
718
|
+
destination_netuid=dest_netuid,
|
719
|
+
destination_coldkey_ss58=dest_coldkey_ss58,
|
720
|
+
amount=amount_to_transfer.rao,
|
721
|
+
),
|
722
|
+
subtensor.get_extrinsic_fee(call, wallet.coldkeypub),
|
693
723
|
)
|
694
724
|
|
695
725
|
# Display stake movement details
|
@@ -703,6 +733,7 @@ async def transfer_stake(
|
|
703
733
|
destination_hotkey=origin_hotkey,
|
704
734
|
amount_to_move=amount_to_transfer,
|
705
735
|
stake_fee=stake_fee,
|
736
|
+
extrinsic_fee=extrinsic_fee,
|
706
737
|
)
|
707
738
|
except ValueError:
|
708
739
|
return False
|
@@ -715,18 +746,6 @@ async def transfer_stake(
|
|
715
746
|
return False
|
716
747
|
|
717
748
|
with console.status("\n:satellite: Transferring stake ..."):
|
718
|
-
call = await subtensor.substrate.compose_call(
|
719
|
-
call_module="SubtensorModule",
|
720
|
-
call_function="transfer_stake",
|
721
|
-
call_params={
|
722
|
-
"destination_coldkey": dest_coldkey_ss58,
|
723
|
-
"hotkey": origin_hotkey,
|
724
|
-
"origin_netuid": origin_netuid,
|
725
|
-
"destination_netuid": dest_netuid,
|
726
|
-
"alpha_amount": amount_to_transfer.rao,
|
727
|
-
},
|
728
|
-
)
|
729
|
-
|
730
749
|
extrinsic = await subtensor.substrate.create_signed_extrinsic(
|
731
750
|
call=call, keypair=wallet.coldkey, era={"period": era}
|
732
751
|
)
|
@@ -800,7 +819,7 @@ async def swap_stake(
|
|
800
819
|
Returns:
|
801
820
|
bool: True if the swap was successful, False otherwise.
|
802
821
|
"""
|
803
|
-
hotkey_ss58 = wallet
|
822
|
+
hotkey_ss58 = get_hotkey_pub_ss58(wallet)
|
804
823
|
if interactive_selection:
|
805
824
|
try:
|
806
825
|
selection = await stake_swap_selection(subtensor, wallet)
|
@@ -846,19 +865,32 @@ async def swap_stake(
|
|
846
865
|
if amount_to_swap > current_stake:
|
847
866
|
err_console.print(
|
848
867
|
f"[red]Not enough stake to swap[/red]:\n"
|
849
|
-
f"Stake balance: [{COLOR_PALETTE
|
850
|
-
f"Swap amount: [{COLOR_PALETTE
|
868
|
+
f"Stake balance: [{COLOR_PALETTE.S.STAKE_AMOUNT}]{current_stake}[/{COLOR_PALETTE.S.STAKE_AMOUNT}] < "
|
869
|
+
f"Swap amount: [{COLOR_PALETTE.S.STAKE_AMOUNT}]{amount_to_swap}[/{COLOR_PALETTE.S.STAKE_AMOUNT}]"
|
851
870
|
)
|
852
871
|
return False
|
853
872
|
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
873
|
+
call = await subtensor.substrate.compose_call(
|
874
|
+
call_module="SubtensorModule",
|
875
|
+
call_function="swap_stake",
|
876
|
+
call_params={
|
877
|
+
"hotkey": hotkey_ss58,
|
878
|
+
"origin_netuid": origin_netuid,
|
879
|
+
"destination_netuid": destination_netuid,
|
880
|
+
"alpha_amount": amount_to_swap.rao,
|
881
|
+
},
|
882
|
+
)
|
883
|
+
stake_fee, extrinsic_fee = await asyncio.gather(
|
884
|
+
subtensor.get_stake_fee(
|
885
|
+
origin_hotkey_ss58=hotkey_ss58,
|
886
|
+
origin_netuid=origin_netuid,
|
887
|
+
origin_coldkey_ss58=wallet.coldkeypub.ss58_address,
|
888
|
+
destination_hotkey_ss58=hotkey_ss58,
|
889
|
+
destination_netuid=destination_netuid,
|
890
|
+
destination_coldkey_ss58=wallet.coldkeypub.ss58_address,
|
891
|
+
amount=amount_to_swap.rao,
|
892
|
+
),
|
893
|
+
subtensor.get_extrinsic_fee(call, wallet.coldkeypub),
|
862
894
|
)
|
863
895
|
|
864
896
|
# Display stake movement details
|
@@ -872,6 +904,7 @@ async def swap_stake(
|
|
872
904
|
destination_hotkey=hotkey_ss58,
|
873
905
|
amount_to_move=amount_to_swap,
|
874
906
|
stake_fee=stake_fee,
|
907
|
+
extrinsic_fee=extrinsic_fee,
|
875
908
|
)
|
876
909
|
except ValueError:
|
877
910
|
return False
|
@@ -887,17 +920,6 @@ async def swap_stake(
|
|
887
920
|
f"\n:satellite: Swapping stake from netuid [blue]{origin_netuid}[/blue] "
|
888
921
|
f"to netuid [blue]{destination_netuid}[/blue]..."
|
889
922
|
):
|
890
|
-
call = await subtensor.substrate.compose_call(
|
891
|
-
call_module="SubtensorModule",
|
892
|
-
call_function="swap_stake",
|
893
|
-
call_params={
|
894
|
-
"hotkey": hotkey_ss58,
|
895
|
-
"origin_netuid": origin_netuid,
|
896
|
-
"destination_netuid": destination_netuid,
|
897
|
-
"alpha_amount": amount_to_swap.rao,
|
898
|
-
},
|
899
|
-
)
|
900
|
-
|
901
923
|
extrinsic = await subtensor.substrate.create_signed_extrinsic(
|
902
924
|
call=call, keypair=wallet.coldkey, era={"period": era}
|
903
925
|
)
|