@@ -33,8 +33,8 @@ async def display_stake_movement_cross_subnets(
3333 destination_hotkey : str ,
3434 amount_to_move : Balance ,
3535 stake_fee : Balance ,
36- ) -> tuple [Balance , float , str , str ]:
37- """Calculate and display slippage information"""
36+ ) -> tuple [Balance , str ]:
37+ """Calculate and display stake movement information"""
3838
3939 if origin_netuid == destination_netuid :
4040 subnet = await subtensor .subnet (origin_netuid )
@@ -46,45 +46,32 @@ async def display_stake_movement_cross_subnets(
4646 raise ValueError
4747
4848 received_amount = subnet .tao_to_alpha (received_amount_tao )
49- slippage_pct_float = (
50- 100 * float (stake_fee ) / float (stake_fee + received_amount_tao )
51- if received_amount_tao != 0
52- else 0
53- )
54- slippage_pct = f"{ slippage_pct_float :.4f} %"
55- price = Balance .from_tao (1 ).set_unit (origin_netuid )
49+ price = subnet .price .tao
5650 price_str = (
57- str (float (price . tao ))
58- + f"{ Balance .get_unit (origin_netuid )} /{ Balance .get_unit (origin_netuid )} "
51+ str (float (price ))
52+ + f"( { Balance .get_unit (0 )} /{ Balance .get_unit (origin_netuid )} ) "
5953 )
6054 else :
6155 dynamic_origin , dynamic_destination = await asyncio .gather (
6256 subtensor .subnet (origin_netuid ),
6357 subtensor .subnet (destination_netuid ),
6458 )
65- price = (
66- float (dynamic_origin .price ) * 1 / (float (dynamic_destination .price ) or 1 )
67- )
68- received_amount_tao , _ , _ = dynamic_origin .alpha_to_tao_with_slippage (
69- amount_to_move
70- )
59+ price_origin = dynamic_origin .price .tao
60+ price_destination = dynamic_destination .price .tao
61+ rate = price_origin / (price_destination or 1 )
62+
63+ received_amount_tao = dynamic_origin .alpha_to_tao (amount_to_move )
7164 received_amount_tao -= stake_fee
72- received_amount , _ , _ = dynamic_destination .tao_to_alpha_with_slippage (
73- received_amount_tao
74- )
65+ received_amount = dynamic_destination .tao_to_alpha (received_amount_tao )
7566 received_amount .set_unit (destination_netuid )
7667
7768 if received_amount < Balance .from_tao (0 ):
7869 print_error ("Not enough Alpha to pay the transaction fee." )
7970 raise ValueError
8071
81- ideal_amount = amount_to_move * price
82- total_slippage = ideal_amount - received_amount
83- slippage_pct_float = 100 * (total_slippage .tao / ideal_amount .tao )
84- slippage_pct = f"{ slippage_pct_float :.4f} %"
8572 price_str = (
86- f"{ price :.5f} "
87- + f"{ Balance .get_unit (destination_netuid )} /{ Balance .get_unit (origin_netuid )} "
73+ f"{ rate :.5f} "
74+ + f"( { Balance .get_unit (destination_netuid )} /{ Balance .get_unit (origin_netuid )} ) "
8875 )
8976
9077 # Create and display table
@@ -141,11 +128,6 @@ async def display_stake_movement_cross_subnets(
141128 justify = "center" ,
142129 style = COLOR_PALETTE ["STAKE" ]["STAKE_AMOUNT" ],
143130 )
144- table .add_column (
145- "slippage" ,
146- justify = "center" ,
147- style = COLOR_PALETTE ["STAKE" ]["SLIPPAGE_PERCENT" ],
148- )
149131
150132 table .add_row (
151133 f"{ Balance .get_unit (origin_netuid )} ({ origin_netuid } )" ,
@@ -156,19 +138,11 @@ async def display_stake_movement_cross_subnets(
156138 price_str ,
157139 str (received_amount ),
158140 str (stake_fee ),
159- str (slippage_pct ),
160141 )
161142
162143 console .print (table )
163144
164- # Display slippage warning if necessary
165- if slippage_pct_float > 5 :
166- message = f"[{ COLOR_PALETTE ['STAKE' ]['SLIPPAGE_TEXT' ]} ]-------------------------------------------------------------------------------------------------------------------\n "
167- message += f"[bold]WARNING:\t Slippage is high: [{ COLOR_PALETTE ['STAKE' ]['SLIPPAGE_PERCENT' ]} ]{ slippage_pct } [/{ COLOR_PALETTE ['STAKE' ]['SLIPPAGE_PERCENT' ]} ], this may result in a loss of funds.[/bold] \n "
168- message += "-------------------------------------------------------------------------------------------------------------------\n "
169- console .print (message )
170-
171- return received_amount , slippage_pct_float , slippage_pct , price_str
145+ return received_amount , price_str
172146
173147
174148def prompt_stake_amount (
@@ -414,7 +388,7 @@ async def stake_swap_selection(
414388 origin_stake = hotkey_stakes [origin_netuid ]["stake" ]
415389
416390 # Ask for amount to swap
417- amount , all_balance = prompt_stake_amount (origin_stake , origin_netuid , "swap" )
391+ amount , _ = prompt_stake_amount (origin_stake , origin_netuid , "swap" )
418392
419393 all_netuids = sorted (await subtensor .get_all_subnet_netuids ())
420394 destination_choices = [
@@ -530,7 +504,7 @@ async def move_stake(
530504 amount = amount_to_move_as_balance .rao ,
531505 )
532506
533- # Slippage warning
507+ # Display stake movement details
534508 if prompt :
535509 try :
536510 await display_stake_movement_cross_subnets (
@@ -714,7 +688,7 @@ async def transfer_stake(
714688 amount = amount_to_transfer .rao ,
715689 )
716690
717- # Slippage warning
691+ # Display stake movement details
718692 if prompt :
719693 try :
720694 await display_stake_movement_cross_subnets (
@@ -883,7 +857,7 @@ async def swap_stake(
883857 amount = amount_to_swap .rao ,
884858 )
885859
886- # Slippage warning
860+ # Display stake movement details
887861 if prompt :
888862 try :
889863 await display_stake_movement_cross_subnets (
0 commit comments