@@ -33,12 +33,15 @@ async def display_stake_movement_cross_subnets(
33
33
destination_hotkey : str ,
34
34
amount_to_move : Balance ,
35
35
stake_fee : Balance ,
36
+ extrinsic_fee : Balance ,
36
37
) -> tuple [Balance , str ]:
37
38
"""Calculate and display stake movement information"""
38
39
39
40
if origin_netuid == destination_netuid :
40
41
subnet = await subtensor .subnet (origin_netuid )
41
- received_amount_tao = subnet .alpha_to_tao (amount_to_move - stake_fee )
42
+ received_amount_tao = (
43
+ subnet .alpha_to_tao (amount_to_move - stake_fee ) - extrinsic_fee
44
+ )
42
45
received_amount = subnet .tao_to_alpha (received_amount_tao )
43
46
44
47
if received_amount < Balance .from_tao (0 ).set_unit (destination_netuid ):
@@ -62,7 +65,9 @@ async def display_stake_movement_cross_subnets(
62
65
price_destination = dynamic_destination .price .tao
63
66
rate = price_origin / (price_destination or 1 )
64
67
65
- received_amount_tao = dynamic_origin .alpha_to_tao (amount_to_move - stake_fee )
68
+ received_amount_tao = (
69
+ dynamic_origin .alpha_to_tao (amount_to_move - stake_fee ) - extrinsic_fee
70
+ )
66
71
received_amount = dynamic_destination .tao_to_alpha (received_amount_tao )
67
72
received_amount .set_unit (destination_netuid )
68
73
@@ -81,14 +86,14 @@ async def display_stake_movement_cross_subnets(
81
86
# Create and display table
82
87
table = Table (
83
88
title = (
84
- f"\n [{ COLOR_PALETTE [ 'GENERAL' ][ ' HEADER' ] } ]"
89
+ f"\n [{ COLOR_PALETTE . G . HEADER } ]"
85
90
f"Moving stake from: "
86
- f"[{ COLOR_PALETTE [ 'GENERAL' ][ 'SUBHEADING' ] } ]{ Balance .get_unit (origin_netuid )} (Netuid: { origin_netuid } )"
87
- f"[/{ COLOR_PALETTE [ 'GENERAL' ][ 'SUBHEADING' ] } ] "
91
+ f"[{ COLOR_PALETTE . G . SUBHEAD } ]{ Balance .get_unit (origin_netuid )} (Netuid: { origin_netuid } )"
92
+ f"[/{ COLOR_PALETTE . G . SUBHEAD } ] "
88
93
f"to: "
89
- f"[{ COLOR_PALETTE [ 'GENERAL' ][ 'SUBHEADING' ] } ]{ Balance .get_unit (destination_netuid )} (Netuid: { destination_netuid } )"
90
- f"[/{ COLOR_PALETTE [ 'GENERAL' ][ 'SUBHEADING' ] } ]\n Network: { subtensor .network } \n "
91
- f"[/{ COLOR_PALETTE [ 'GENERAL' ][ ' HEADER' ] } ]"
94
+ f"[{ COLOR_PALETTE . G . SUBHEAD } ]{ Balance .get_unit (destination_netuid )} (Netuid: { destination_netuid } )"
95
+ f"[/{ COLOR_PALETTE . G . SUBHEAD } ]\n Network: { subtensor .network } \n "
96
+ f"[/{ COLOR_PALETTE . G . HEADER } ]"
92
97
),
93
98
show_footer = True ,
94
99
show_edge = False ,
@@ -132,6 +137,9 @@ async def display_stake_movement_cross_subnets(
132
137
justify = "center" ,
133
138
style = COLOR_PALETTE ["STAKE" ]["STAKE_AMOUNT" ],
134
139
)
140
+ table .add_column (
141
+ "Extrinsic Fee (τ)" , justify = "center" , style = COLOR_PALETTE .STAKE .TAO
142
+ )
135
143
136
144
table .add_row (
137
145
f"{ Balance .get_unit (origin_netuid )} ({ origin_netuid } )" ,
@@ -142,6 +150,7 @@ async def display_stake_movement_cross_subnets(
142
150
price_str ,
143
151
str (received_amount ),
144
152
str (stake_fee .set_unit (origin_netuid )),
153
+ str (extrinsic_fee ),
145
154
)
146
155
147
156
console .print (table )
@@ -165,10 +174,10 @@ def prompt_stake_amount(
165
174
while True :
166
175
amount_input = Prompt .ask (
167
176
f"\n Enter the amount to { action_name } "
168
- f"[{ COLOR_PALETTE [ 'STAKE' ][ ' STAKE_AMOUNT' ] } ]{ Balance .get_unit (netuid )} [/{ COLOR_PALETTE [ 'STAKE' ][ ' STAKE_AMOUNT' ] } ] "
169
- f"[{ COLOR_PALETTE [ 'STAKE' ][ ' STAKE_AMOUNT' ] } ](max: { current_balance } )[/{ COLOR_PALETTE [ 'STAKE' ][ ' STAKE_AMOUNT' ] } ] "
177
+ f"[{ COLOR_PALETTE . S . STAKE_AMOUNT } ]{ Balance .get_unit (netuid )} [/{ COLOR_PALETTE . S . STAKE_AMOUNT } ] "
178
+ f"[{ COLOR_PALETTE . S . STAKE_AMOUNT } ](max: { current_balance } )[/{ COLOR_PALETTE . S . STAKE_AMOUNT } ] "
170
179
f"or "
171
- f"[{ COLOR_PALETTE [ 'STAKE' ][ ' STAKE_AMOUNT' ] } ]'all'[/{ COLOR_PALETTE [ 'STAKE' ][ ' STAKE_AMOUNT' ] } ] "
180
+ f"[{ COLOR_PALETTE . S . STAKE_AMOUNT } ]'all'[/{ COLOR_PALETTE . S . STAKE_AMOUNT } ] "
172
181
f"for entire balance"
173
182
)
174
183
@@ -183,7 +192,7 @@ def prompt_stake_amount(
183
192
if amount > current_balance .tao :
184
193
console .print (
185
194
f"[red]Amount exceeds available balance of "
186
- f"[{ COLOR_PALETTE [ 'STAKE' ][ ' STAKE_AMOUNT' ] } ]{ current_balance } [/{ COLOR_PALETTE [ 'STAKE' ][ ' STAKE_AMOUNT' ] } ]"
195
+ f"[{ COLOR_PALETTE . S . STAKE_AMOUNT } ]{ current_balance } [/{ COLOR_PALETTE . S . STAKE_AMOUNT } ]"
187
196
f"[/red]"
188
197
)
189
198
continue
@@ -270,16 +279,16 @@ async def stake_move_transfer_selection(
270
279
271
280
# Display available netuids for selected hotkey
272
281
table = Table (
273
- title = f"\n [{ COLOR_PALETTE [ 'GENERAL' ][ ' HEADER' ] } ]Available Stakes for Hotkey\n [/{ COLOR_PALETTE [ 'GENERAL' ][ ' HEADER' ] } ]"
274
- f"[{ COLOR_PALETTE [ 'GENERAL' ][ 'HOTKEY' ] } ]{ origin_hotkey_ss58 } [/{ COLOR_PALETTE [ 'GENERAL' ][ 'HOTKEY' ] } ]\n " ,
282
+ title = f"\n [{ COLOR_PALETTE . G . HEADER } ]Available Stakes for Hotkey\n [/{ COLOR_PALETTE . G . HEADER } ]"
283
+ f"[{ COLOR_PALETTE . G . HK } ]{ origin_hotkey_ss58 } [/{ COLOR_PALETTE . G . HK } ]\n " ,
275
284
show_edge = False ,
276
285
header_style = "bold white" ,
277
286
border_style = "bright_black" ,
278
287
title_justify = "center" ,
279
288
width = len (origin_hotkey_ss58 ) + 20 ,
280
289
)
281
290
table .add_column ("Netuid" , style = "cyan" )
282
- table .add_column ("Stake Amount" , style = COLOR_PALETTE [ " STAKE" ][ " STAKE_AMOUNT" ] )
291
+ table .add_column ("Stake Amount" , style = COLOR_PALETTE . STAKE . STAKE_AMOUNT )
283
292
284
293
available_netuids = []
285
294
for netuid in origin_hotkey_info ["netuids" ]:
@@ -347,8 +356,8 @@ async def stake_swap_selection(
347
356
348
357
# Display available stakes
349
358
table = Table (
350
- title = f"\n [{ COLOR_PALETTE [ 'GENERAL' ][ ' HEADER' ] } ]Available Stakes for Hotkey\n [/{ COLOR_PALETTE [ 'GENERAL' ][ ' HEADER' ] } ]"
351
- f"[{ COLOR_PALETTE [ 'GENERAL' ][ 'HOTKEY' ] } ]{ wallet .hotkey_str } : { wallet .hotkey .ss58_address } [/{ COLOR_PALETTE [ 'GENERAL' ][ 'HOTKEY' ] } ]\n " ,
359
+ title = f"\n [{ COLOR_PALETTE . G . HEADER } ]Available Stakes for Hotkey\n [/{ COLOR_PALETTE . G . HEADER } ]"
360
+ f"[{ COLOR_PALETTE . G . HK } ]{ wallet .hotkey_str } : { wallet .hotkey .ss58_address } [/{ COLOR_PALETTE . G . HK } ]\n " ,
352
361
show_edge = False ,
353
362
header_style = "bold white" ,
354
363
border_style = "bright_black" ,
@@ -366,7 +375,7 @@ async def stake_swap_selection(
366
375
for idx , (netuid , stake_info ) in enumerate (sorted (hotkey_stakes .items ())):
367
376
subnet_info = subnet_dict [netuid ]
368
377
subnet_name_cell = (
369
- f"[{ COLOR_PALETTE [ 'GENERAL' ][ 'SYMBOL' ] } ]{ subnet_info .symbol if netuid != 0 else 'τ' } [/{ COLOR_PALETTE [ 'GENERAL' ][ 'SYMBOL' ] } ]"
378
+ f"[{ COLOR_PALETTE . G . SYM } ]{ subnet_info .symbol if netuid != 0 else 'τ' } [/{ COLOR_PALETTE . G . SYM } ]"
370
379
f" { get_subnet_name (subnet_info )} "
371
380
)
372
381
@@ -498,14 +507,28 @@ async def move_stake(
498
507
)
499
508
return False
500
509
501
- stake_fee = await subtensor .get_stake_fee (
502
- origin_hotkey_ss58 = origin_hotkey ,
503
- origin_netuid = origin_netuid ,
504
- origin_coldkey_ss58 = wallet .coldkeypub .ss58_address ,
505
- destination_hotkey_ss58 = destination_hotkey ,
506
- destination_netuid = destination_netuid ,
507
- destination_coldkey_ss58 = wallet .coldkeypub .ss58_address ,
508
- amount = amount_to_move_as_balance .rao ,
510
+ call = await subtensor .substrate .compose_call (
511
+ call_module = "SubtensorModule" ,
512
+ call_function = "move_stake" ,
513
+ call_params = {
514
+ "origin_hotkey" : origin_hotkey ,
515
+ "origin_netuid" : origin_netuid ,
516
+ "destination_hotkey" : destination_hotkey ,
517
+ "destination_netuid" : destination_netuid ,
518
+ "alpha_amount" : amount_to_move_as_balance .rao ,
519
+ },
520
+ )
521
+ stake_fee , extrinsic_fee = await asyncio .gather (
522
+ subtensor .get_stake_fee (
523
+ origin_hotkey_ss58 = origin_hotkey ,
524
+ origin_netuid = origin_netuid ,
525
+ origin_coldkey_ss58 = wallet .coldkeypub .ss58_address ,
526
+ destination_hotkey_ss58 = destination_hotkey ,
527
+ destination_netuid = destination_netuid ,
528
+ destination_coldkey_ss58 = wallet .coldkeypub .ss58_address ,
529
+ amount = amount_to_move_as_balance .rao ,
530
+ ),
531
+ subtensor .get_extrinsic_fee (call , wallet .coldkeypub ),
509
532
)
510
533
511
534
# Display stake movement details
@@ -519,6 +542,7 @@ async def move_stake(
519
542
destination_hotkey = destination_hotkey ,
520
543
amount_to_move = amount_to_move_as_balance ,
521
544
stake_fee = stake_fee ,
545
+ extrinsic_fee = extrinsic_fee ,
522
546
)
523
547
except ValueError :
524
548
return False
@@ -529,20 +553,10 @@ async def move_stake(
529
553
if not unlock_key (wallet ).success :
530
554
return False
531
555
with console .status (
532
- f"\n :satellite: Moving [blue]{ amount_to_move_as_balance } [/blue] from [blue]{ origin_hotkey } [/blue] on netuid: [blue]{ origin_netuid } [/blue] \n to "
556
+ f"\n :satellite: Moving [blue]{ amount_to_move_as_balance } [/blue] from [blue]{ origin_hotkey } [/blue] on netuid: "
557
+ f"[blue]{ origin_netuid } [/blue] \n to "
533
558
f"[blue]{ destination_hotkey } [/blue] on netuid: [blue]{ destination_netuid } [/blue] ..."
534
559
):
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
560
extrinsic = await subtensor .substrate .create_signed_extrinsic (
547
561
call = call , keypair = wallet .coldkey , era = {"period" : era }
548
562
)
@@ -677,19 +691,33 @@ async def transfer_stake(
677
691
if amount_to_transfer > current_stake :
678
692
err_console .print (
679
693
f"[red]Not enough stake to transfer[/red]:\n "
680
- f"Stake balance: [{ COLOR_PALETTE [ 'STAKE' ][ ' STAKE_AMOUNT' ] } ]{ current_stake } [/{ COLOR_PALETTE [ 'STAKE' ][ ' STAKE_AMOUNT' ] } ] < "
681
- f"Transfer amount: [{ COLOR_PALETTE [ 'STAKE' ][ ' STAKE_AMOUNT' ] } ]{ amount_to_transfer } [/{ COLOR_PALETTE [ 'STAKE' ][ ' STAKE_AMOUNT' ] } ]"
694
+ f"Stake balance: [{ COLOR_PALETTE . S . STAKE_AMOUNT } ]{ current_stake } [/{ COLOR_PALETTE . S . STAKE_AMOUNT } ] < "
695
+ f"Transfer amount: [{ COLOR_PALETTE . S . STAKE_AMOUNT } ]{ amount_to_transfer } [/{ COLOR_PALETTE . S . STAKE_AMOUNT } ]"
682
696
)
683
697
return False
684
698
685
- stake_fee = await subtensor .get_stake_fee (
686
- origin_hotkey_ss58 = origin_hotkey ,
687
- origin_netuid = origin_netuid ,
688
- origin_coldkey_ss58 = wallet .coldkeypub .ss58_address ,
689
- destination_hotkey_ss58 = origin_hotkey ,
690
- destination_netuid = dest_netuid ,
691
- destination_coldkey_ss58 = dest_coldkey_ss58 ,
692
- amount = amount_to_transfer .rao ,
699
+ call = await subtensor .substrate .compose_call (
700
+ call_module = "SubtensorModule" ,
701
+ call_function = "transfer_stake" ,
702
+ call_params = {
703
+ "destination_coldkey" : dest_coldkey_ss58 ,
704
+ "hotkey" : origin_hotkey ,
705
+ "origin_netuid" : origin_netuid ,
706
+ "destination_netuid" : dest_netuid ,
707
+ "alpha_amount" : amount_to_transfer .rao ,
708
+ },
709
+ )
710
+ stake_fee , extrinsic_fee = await asyncio .gather (
711
+ subtensor .get_stake_fee (
712
+ origin_hotkey_ss58 = origin_hotkey ,
713
+ origin_netuid = origin_netuid ,
714
+ origin_coldkey_ss58 = wallet .coldkeypub .ss58_address ,
715
+ destination_hotkey_ss58 = origin_hotkey ,
716
+ destination_netuid = dest_netuid ,
717
+ destination_coldkey_ss58 = dest_coldkey_ss58 ,
718
+ amount = amount_to_transfer .rao ,
719
+ ),
720
+ subtensor .get_extrinsic_fee (call , wallet .coldkeypub ),
693
721
)
694
722
695
723
# Display stake movement details
@@ -703,6 +731,7 @@ async def transfer_stake(
703
731
destination_hotkey = origin_hotkey ,
704
732
amount_to_move = amount_to_transfer ,
705
733
stake_fee = stake_fee ,
734
+ extrinsic_fee = extrinsic_fee ,
706
735
)
707
736
except ValueError :
708
737
return False
@@ -715,18 +744,6 @@ async def transfer_stake(
715
744
return False
716
745
717
746
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
747
extrinsic = await subtensor .substrate .create_signed_extrinsic (
731
748
call = call , keypair = wallet .coldkey , era = {"period" : era }
732
749
)
@@ -846,19 +863,32 @@ async def swap_stake(
846
863
if amount_to_swap > current_stake :
847
864
err_console .print (
848
865
f"[red]Not enough stake to swap[/red]:\n "
849
- f"Stake balance: [{ COLOR_PALETTE [ 'STAKE' ][ ' STAKE_AMOUNT' ] } ]{ current_stake } [/{ COLOR_PALETTE [ 'STAKE' ][ ' STAKE_AMOUNT' ] } ] < "
850
- f"Swap amount: [{ COLOR_PALETTE [ 'STAKE' ][ ' STAKE_AMOUNT' ] } ]{ amount_to_swap } [/{ COLOR_PALETTE [ 'STAKE' ][ ' STAKE_AMOUNT' ] } ]"
866
+ f"Stake balance: [{ COLOR_PALETTE . S . STAKE_AMOUNT } ]{ current_stake } [/{ COLOR_PALETTE . S . STAKE_AMOUNT } ] < "
867
+ f"Swap amount: [{ COLOR_PALETTE . S . STAKE_AMOUNT } ]{ amount_to_swap } [/{ COLOR_PALETTE . S . STAKE_AMOUNT } ]"
851
868
)
852
869
return False
853
870
854
- stake_fee = await subtensor .get_stake_fee (
855
- origin_hotkey_ss58 = hotkey_ss58 ,
856
- origin_netuid = origin_netuid ,
857
- origin_coldkey_ss58 = wallet .coldkeypub .ss58_address ,
858
- destination_hotkey_ss58 = hotkey_ss58 ,
859
- destination_netuid = destination_netuid ,
860
- destination_coldkey_ss58 = wallet .coldkeypub .ss58_address ,
861
- amount = amount_to_swap .rao ,
871
+ call = await subtensor .substrate .compose_call (
872
+ call_module = "SubtensorModule" ,
873
+ call_function = "swap_stake" ,
874
+ call_params = {
875
+ "hotkey" : hotkey_ss58 ,
876
+ "origin_netuid" : origin_netuid ,
877
+ "destination_netuid" : destination_netuid ,
878
+ "alpha_amount" : amount_to_swap .rao ,
879
+ },
880
+ )
881
+ stake_fee , extrinsic_fee = await asyncio .gather (
882
+ subtensor .get_stake_fee (
883
+ origin_hotkey_ss58 = hotkey_ss58 ,
884
+ origin_netuid = origin_netuid ,
885
+ origin_coldkey_ss58 = wallet .coldkeypub .ss58_address ,
886
+ destination_hotkey_ss58 = hotkey_ss58 ,
887
+ destination_netuid = destination_netuid ,
888
+ destination_coldkey_ss58 = wallet .coldkeypub .ss58_address ,
889
+ amount = amount_to_swap .rao ,
890
+ ),
891
+ subtensor .get_extrinsic_fee (call , wallet .coldkeypub ),
862
892
)
863
893
864
894
# Display stake movement details
@@ -872,6 +902,7 @@ async def swap_stake(
872
902
destination_hotkey = hotkey_ss58 ,
873
903
amount_to_move = amount_to_swap ,
874
904
stake_fee = stake_fee ,
905
+ extrinsic_fee = extrinsic_fee ,
875
906
)
876
907
except ValueError :
877
908
return False
@@ -887,17 +918,6 @@ async def swap_stake(
887
918
f"\n :satellite: Swapping stake from netuid [blue]{ origin_netuid } [/blue] "
888
919
f"to netuid [blue]{ destination_netuid } [/blue]..."
889
920
):
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
921
extrinsic = await subtensor .substrate .create_signed_extrinsic (
902
922
call = call , keypair = wallet .coldkey , era = {"period" : era }
903
923
)
0 commit comments