Skip to content

Commit 96a3813

Browse files
committed
PR suggestions
1 parent 396c9f1 commit 96a3813

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

bittensor_cli/src/bittensor/subtensor_interface.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,15 @@ async def get_owned_hotkeys(
14901490
return [decode_account_id(hotkey[0]) for hotkey in owned_hotkeys or []]
14911491

14921492
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+
"""
14931502
fee_dict = await self.substrate.get_payment_info(call, keypair)
14941503
return Balance.from_rao(fee_dict["partial_fee"])
14951504

bittensor_cli/src/commands/stake/add.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ async def get_stake_extrinsic_fee(
7272
safe_staking_: bool,
7373
price_limit: Optional[Balance] = None,
7474
):
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+
"""
7587
call_fn = "add_stake" if not safe_staking_ else "add_stake_limit"
7688
call_params = {
7789
"hotkey": staking_address_,

bittensor_cli/src/commands/stake/remove.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,19 +215,19 @@ async def unstake(
215215
if subnet_info.is_dynamic:
216216
price_with_tolerance = current_price * (1 - rate_tolerance)
217217
rate_with_tolerance = price_with_tolerance
218-
price_with_tolerance = Balance.from_tao(
218+
price_limit = Balance.from_tao(
219219
rate_with_tolerance
220-
).rao # Actual price to pass to extrinsic
220+
) # Actual price to pass to extrinsic
221221
else:
222-
price_with_tolerance = 1
222+
price_limit = Balance.from_rao(1)
223223
extrinsic_fee = await _get_extrinsic_fee(
224224
"unstake_safe",
225225
wallet,
226226
subtensor,
227227
hotkey_ss58=staking_address_ss58,
228228
amount=amount_to_unstake_as_balance,
229229
netuid=netuid,
230-
price_limit=price_with_tolerance,
230+
price_limit=price_limit,
231231
allow_partial_stake=allow_partial_stake,
232232
)
233233
else:

0 commit comments

Comments
 (0)