@@ -65,6 +65,33 @@ async def stake_add(
65
65
bool: True if stake operation is successful, False otherwise
66
66
"""
67
67
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
+
68
95
async def safe_stake_extrinsic (
69
96
netuid_ : int ,
70
97
amount_ : Balance ,
@@ -87,7 +114,7 @@ async def safe_stake_extrinsic(
87
114
"hotkey" : hotkey_ss58_ ,
88
115
"netuid" : netuid_ ,
89
116
"amount_staked" : amount_ .rao ,
90
- "limit_price" : price_limit ,
117
+ "limit_price" : price_limit . rao ,
91
118
"allow_partial" : allow_partial_stake ,
92
119
},
93
120
),
@@ -356,20 +383,35 @@ async def stake_extrinsic(
356
383
rate_with_tolerance = f"{ _rate_with_tolerance :.4f} "
357
384
price_with_tolerance = Balance .from_tao (
358
385
price_with_tolerance
359
- ). rao # Actual price to pass to extrinsic
386
+ ) # Actual price to pass to extrinsic
360
387
else :
361
388
rate_with_tolerance = "1"
362
389
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
+ )
363
397
prices_with_tolerance .append (price_with_tolerance )
364
-
365
398
base_row .extend (
366
399
[
400
+ str (extrinsic_fee ),
367
401
f"{ rate_with_tolerance } { Balance .get_unit (netuid )} /{ Balance .get_unit (0 )} " ,
368
402
f"[{ 'dark_sea_green3' if allow_partial_stake else 'red' } ]"
369
403
# safe staking
370
404
f"{ allow_partial_stake } [/{ 'dark_sea_green3' if allow_partial_stake else 'red' } ]" ,
371
405
]
372
406
)
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 ))
373
415
374
416
rows .append (tuple (base_row ))
375
417
@@ -588,6 +630,11 @@ def _define_stake_table(
588
630
justify = "center" ,
589
631
style = COLOR_PALETTE ["STAKE" ]["STAKE_AMOUNT" ],
590
632
)
633
+ table .add_column (
634
+ "Extrinsic Fee (τ)" ,
635
+ justify = "center" ,
636
+ style = COLOR_PALETTE ["STAKE" ]["STAKE_AMOUNT" ],
637
+ )
591
638
# TODO: Uncomment when slippage is reimplemented for v3
592
639
# table.add_column(
593
640
# "Slippage", justify="center", style=COLOR_PALETTE["STAKE"]["SLIPPAGE_PERCENT"]
0 commit comments