Skip to content

Commit 46f383e

Browse files
authored
Merge pull request #539 from opentensor/fix/thewhaleking/stake-fee-calculation
change stake fee calculation
2 parents 97b291c + 4e6a49e commit 46f383e

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

bittensor_cli/src/bittensor/subtensor_interface.py

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
decode_hex_identity_dict,
3737
validate_chain_endpoint,
3838
u16_normalized_float,
39+
U16_MAX,
3940
)
4041

4142
SubstrateClass = (
@@ -1526,29 +1527,14 @@ async def get_stake_fee(
15261527
5. Moving between coldkeys
15271528
"""
15281529

1529-
origin = None
1530-
if origin_hotkey_ss58 is not None and origin_netuid is not None:
1531-
origin = (origin_hotkey_ss58, origin_netuid)
1530+
if origin_netuid is None:
1531+
origin_netuid = 0
15321532

1533-
destination = None
1534-
if destination_hotkey_ss58 is not None and destination_netuid is not None:
1535-
destination = (destination_hotkey_ss58, destination_netuid)
1533+
fee_rate = await self.query("Swap", "FeeRate", [origin_netuid])
1534+
fee = amount * (fee_rate / U16_MAX)
15361535

1537-
result_ = await self.query_runtime_api(
1538-
runtime_api="StakeInfoRuntimeApi",
1539-
method="get_stake_fee",
1540-
params=[
1541-
origin,
1542-
origin_coldkey_ss58,
1543-
destination,
1544-
destination_coldkey_ss58,
1545-
amount,
1546-
],
1547-
block_hash=block_hash,
1548-
)
1549-
result = Balance.from_rao(result_)
1550-
if isinstance(origin_netuid, int):
1551-
result.set_unit(origin_netuid)
1536+
result = Balance.from_tao(fee)
1537+
result.set_unit(origin_netuid)
15521538

15531539
return result
15541540

0 commit comments

Comments
 (0)