File tree Expand file tree Collapse file tree 3 files changed +25
-4
lines changed Expand file tree Collapse file tree 3 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -1490,6 +1490,15 @@ async def get_owned_hotkeys(
1490
1490
return [decode_account_id (hotkey [0 ]) for hotkey in owned_hotkeys or []]
1491
1491
1492
1492
async def get_extrinsic_fee (self , call : GenericCall , keypair : Keypair ) -> Balance :
1493
+ """
1494
+ Determines the fee for the extrinsic call.
1495
+ Args:
1496
+ call: Created extrinsic call
1497
+ keypair: The keypair that would sign the extrinsic (usually you would just want to use the *pub for this)
1498
+
1499
+ Returns:
1500
+ Balance object representing the fee for this extrinsic.
1501
+ """
1493
1502
fee_dict = await self .substrate .get_payment_info (call , keypair )
1494
1503
return Balance .from_rao (fee_dict ["partial_fee" ])
1495
1504
Original file line number Diff line number Diff line change @@ -72,6 +72,18 @@ async def get_stake_extrinsic_fee(
72
72
safe_staking_ : bool ,
73
73
price_limit : Optional [Balance ] = None ,
74
74
):
75
+ """
76
+ Quick method to get the extrinsic fee for adding stake depending on the args supplied.
77
+ Args:
78
+ netuid_: The netuid where the stake will be added
79
+ amount_: the amount of stake to add
80
+ staking_address_: the hotkey ss58 to stake to
81
+ safe_staking_: whether to use safe staking
82
+ price_limit: rate with tolerance
83
+
84
+ Returns:
85
+ Balance object representing the extrinsic fee for adding stake.
86
+ """
75
87
call_fn = "add_stake" if not safe_staking_ else "add_stake_limit"
76
88
call_params = {
77
89
"hotkey" : staking_address_ ,
Original file line number Diff line number Diff line change @@ -215,19 +215,19 @@ async def unstake(
215
215
if subnet_info .is_dynamic :
216
216
price_with_tolerance = current_price * (1 - rate_tolerance )
217
217
rate_with_tolerance = price_with_tolerance
218
- price_with_tolerance = Balance .from_tao (
218
+ price_limit = Balance .from_tao (
219
219
rate_with_tolerance
220
- ). rao # Actual price to pass to extrinsic
220
+ ) # Actual price to pass to extrinsic
221
221
else :
222
- price_with_tolerance = 1
222
+ price_limit = Balance . from_rao ( 1 )
223
223
extrinsic_fee = await _get_extrinsic_fee (
224
224
"unstake_safe" ,
225
225
wallet ,
226
226
subtensor ,
227
227
hotkey_ss58 = staking_address_ss58 ,
228
228
amount = amount_to_unstake_as_balance ,
229
229
netuid = netuid ,
230
- price_limit = price_with_tolerance ,
230
+ price_limit = price_limit ,
231
231
allow_partial_stake = allow_partial_stake ,
232
232
)
233
233
else :
You can’t perform that action at this time.
0 commit comments