@@ -65,6 +65,33 @@ async def stake_add(
6565 bool: True if stake operation is successful, False otherwise
6666 """
6767
68+ async def get_stake_extrinsic_fee (
69+ netuid_ : int ,
70+ amount_ : Balance ,
71+ staking_address_ : str ,
72+ safe_staking_ : bool ,
73+ price_limit : Optional [Balance ] = None ,
74+ ):
75+ call_fn = "add_stake" if not safe_staking_ else "add_stake_limit"
76+ call_params = {
77+ "hotkey" : staking_address_ ,
78+ "netuid" : netuid_ ,
79+ "amount_staked" : amount_ .rao ,
80+ }
81+ if safe_staking_ :
82+ call_params .update (
83+ {
84+ "limit_price" : price_limit ,
85+ "allow_partial" : allow_partial_stake ,
86+ }
87+ )
88+ call = await subtensor .substrate .compose_call (
89+ call_module = "SubtensorModule" ,
90+ call_function = call_fn ,
91+ call_params = call_params ,
92+ )
93+ return await subtensor .get_extrinsic_fee (call , wallet .coldkeypub )
94+
6895 async def safe_stake_extrinsic (
6996 netuid_ : int ,
7097 amount_ : Balance ,
@@ -87,7 +114,7 @@ async def safe_stake_extrinsic(
87114 "hotkey" : hotkey_ss58_ ,
88115 "netuid" : netuid_ ,
89116 "amount_staked" : amount_ .rao ,
90- "limit_price" : price_limit ,
117+ "limit_price" : price_limit . rao ,
91118 "allow_partial" : allow_partial_stake ,
92119 },
93120 ),
@@ -356,20 +383,35 @@ async def stake_extrinsic(
356383 rate_with_tolerance = f"{ _rate_with_tolerance :.4f} "
357384 price_with_tolerance = Balance .from_tao (
358385 price_with_tolerance
359- ). rao # Actual price to pass to extrinsic
386+ ) # Actual price to pass to extrinsic
360387 else :
361388 rate_with_tolerance = "1"
362389 price_with_tolerance = Balance .from_rao (1 )
390+ extrinsic_fee = await get_stake_extrinsic_fee (
391+ netuid_ = netuid ,
392+ amount_ = amount_to_stake ,
393+ staking_address_ = hotkey [1 ],
394+ safe_staking_ = safe_staking ,
395+ price_limit = price_with_tolerance ,
396+ )
363397 prices_with_tolerance .append (price_with_tolerance )
364-
365398 base_row .extend (
366399 [
400+ str (extrinsic_fee ),
367401 f"{ rate_with_tolerance } { Balance .get_unit (netuid )} /{ Balance .get_unit (0 )} " ,
368402 f"[{ 'dark_sea_green3' if allow_partial_stake else 'red' } ]"
369403 # safe staking
370404 f"{ allow_partial_stake } [/{ 'dark_sea_green3' if allow_partial_stake else 'red' } ]" ,
371405 ]
372406 )
407+ else :
408+ extrinsic_fee = await get_stake_extrinsic_fee (
409+ netuid_ = netuid ,
410+ amount_ = amount_to_stake ,
411+ staking_address_ = hotkey [1 ],
412+ safe_staking_ = safe_staking ,
413+ )
414+ base_row .append (str (extrinsic_fee ))
373415
374416 rows .append (tuple (base_row ))
375417
@@ -588,6 +630,11 @@ def _define_stake_table(
588630 justify = "center" ,
589631 style = COLOR_PALETTE ["STAKE" ]["STAKE_AMOUNT" ],
590632 )
633+ table .add_column (
634+ "Extrinsic Fee (τ)" ,
635+ justify = "center" ,
636+ style = COLOR_PALETTE ["STAKE" ]["STAKE_AMOUNT" ],
637+ )
591638 # TODO: Uncomment when slippage is reimplemented for v3
592639 # table.add_column(
593640 # "Slippage", justify="center", style=COLOR_PALETTE["STAKE"]["SLIPPAGE_PERCENT"]
0 commit comments