22from typing import Optional , TYPE_CHECKING
33
44from async_substrate_interface .errors import SubstrateRequestException
5-
5+ from bittensor . core . extrinsics . asyncex . utils import get_extrinsic_fee
66from bittensor .core .extrinsics .utils import get_old_stakes
77from bittensor .utils import unlock_key , format_error_message
88from bittensor .utils .balance import Balance
@@ -114,14 +114,14 @@ async def unstake_extrinsic(
114114 else :
115115 price_with_tolerance = base_price * (1 - rate_tolerance )
116116
117- logging . info (
117+ logging_info = (
118118 f":satellite: [magenta]Safe Unstaking from:[/magenta] "
119119 f"netuid: [green]{ netuid } [/green], amount: [green]{ unstaking_balance } [/green], "
120120 f"tolerance percentage: [green]{ rate_tolerance * 100 } %[/green], "
121121 f"price limit: [green]{ price_with_tolerance } [/green], "
122122 f"original price: [green]{ base_price } [/green], "
123123 f"with partial unstake: [green]{ allow_partial_stake } [/green] "
124- f"on [blue]{ subtensor .network } [/blue][magenta]...[/magenta] "
124+ f"on [blue]{ subtensor .network } [/blue]"
125125 )
126126
127127 limit_price = Balance .from_tao (price_with_tolerance ).rao
@@ -133,10 +133,10 @@ async def unstake_extrinsic(
133133 )
134134 call_function = "remove_stake_limit"
135135 else :
136- logging . info (
136+ logging_info = (
137137 f":satellite: [magenta]Unstaking from:[/magenta] "
138138 f"netuid: [green]{ netuid } [/green], amount: [green]{ unstaking_balance } [/green] "
139- f"on [blue]{ subtensor .network } [/blue][magenta]...[/magenta] "
139+ f"on [blue]{ subtensor .network } [/blue]"
140140 )
141141 call_function = "remove_stake"
142142
@@ -145,6 +145,10 @@ async def unstake_extrinsic(
145145 call_function = call_function ,
146146 call_params = call_params ,
147147 )
148+ fee = await get_extrinsic_fee (
149+ subtensor = subtensor , call = call , keypair = wallet .coldkeypub , netuid = netuid
150+ )
151+ logging .info (f"{ logging_info } for fee [blue]{ fee } [/blue][magenta]...[/magenta]" )
148152 success , message = await subtensor .sign_and_send_extrinsic (
149153 call = call ,
150154 wallet = wallet ,
@@ -381,10 +385,6 @@ async def unstake_multiple_extrinsic(
381385 continue
382386
383387 try :
384- logging .info (
385- f"Unstaking [blue]{ unstaking_balance } [/blue] from hotkey: [magenta]{ hotkey_ss58 } [/magenta] on netuid: "
386- f"[blue]{ netuid } [/blue]"
387- )
388388 call = await subtensor .substrate .compose_call (
389389 call_module = "SubtensorModule" ,
390390 call_function = "remove_stake" ,
@@ -394,6 +394,13 @@ async def unstake_multiple_extrinsic(
394394 "netuid" : netuid ,
395395 },
396396 )
397+ fee = await get_extrinsic_fee (
398+ subtensor = subtensor , call = call , keypair = wallet .coldkeypub , netuid = netuid
399+ )
400+ logging .info (
401+ f"Unstaking [blue]{ unstaking_balance } [/blue] from hotkey: [magenta]{ hotkey_ss58 } [/magenta] on netuid: "
402+ f"[blue]{ netuid } [/blue] for fee [blue]{ fee } [/blue]"
403+ )
397404
398405 staking_response , err_msg = await subtensor .sign_and_send_extrinsic (
399406 call = call ,
0 commit comments