@@ -1575,6 +1575,72 @@ async def get_stake(
1575
1575
1576
1576
return Balance .from_rao (int (stake )).set_unit (netuid = netuid )
1577
1577
1578
+ async def get_stake_fee (
1579
+ self ,
1580
+ origin_hotkey_ss58 : Optional [str ],
1581
+ origin_netuid : Optional [int ],
1582
+ origin_coldkey_ss58 : str ,
1583
+ destination_hotkey_ss58 : Optional [str ],
1584
+ destination_netuid : Optional [int ],
1585
+ destination_coldkey_ss58 : str ,
1586
+ amount : int ,
1587
+ block_hash : Optional [str ] = None ,
1588
+ ) -> Balance :
1589
+ """
1590
+ Calculates the fee for a staking operation.
1591
+
1592
+ :param origin_hotkey_ss58: SS58 address of source hotkey (None for new stake)
1593
+ :param origin_netuid: Netuid of source subnet (None for new stake)
1594
+ :param origin_coldkey_ss58: SS58 address of source coldkey
1595
+ :param destination_hotkey_ss58: SS58 address of destination hotkey (None for removing stake)
1596
+ :param destination_netuid: Netuid of destination subnet (None for removing stake)
1597
+ :param destination_coldkey_ss58: SS58 address of destination coldkey
1598
+ :param amount: Amount of stake to transfer in RAO
1599
+ :param block_hash: Optional block hash at which to perform the calculation
1600
+
1601
+ :return: The calculated stake fee as a Balance object
1602
+
1603
+ When to use None:
1604
+
1605
+ 1. Adding new stake (default fee):
1606
+ - origin_hotkey_ss58 = None
1607
+ - origin_netuid = None
1608
+ - All other fields required
1609
+
1610
+ 2. Removing stake (default fee):
1611
+ - destination_hotkey_ss58 = None
1612
+ - destination_netuid = None
1613
+ - All other fields required
1614
+
1615
+ For all other operations, no None values - provide all parameters:
1616
+ 3. Moving between subnets
1617
+ 4. Moving between hotkeys
1618
+ 5. Moving between coldkeys
1619
+ """
1620
+
1621
+ origin = None
1622
+ if origin_hotkey_ss58 is not None and origin_netuid is not None :
1623
+ origin = (origin_hotkey_ss58 , origin_netuid )
1624
+
1625
+ destination = None
1626
+ if destination_hotkey_ss58 is not None and destination_netuid is not None :
1627
+ destination = (destination_hotkey_ss58 , destination_netuid )
1628
+
1629
+ result = await self .query_runtime_api (
1630
+ runtime_api = "StakeInfoRuntimeApi" ,
1631
+ method = "get_stake_fee" ,
1632
+ params = [
1633
+ origin ,
1634
+ origin_coldkey_ss58 ,
1635
+ destination ,
1636
+ destination_coldkey_ss58 ,
1637
+ amount ,
1638
+ ],
1639
+ block_hash = block_hash ,
1640
+ )
1641
+
1642
+ return Balance .from_rao (result if result is not None else 0 )
1643
+
1578
1644
async def get_stake_for_coldkey_and_hotkey (
1579
1645
self ,
1580
1646
coldkey_ss58 : str ,
0 commit comments