@@ -1769,10 +1769,10 @@ mod dispatches {
1769
1769
/// - The amount of stake to be added to the hotkey staking account.
1770
1770
///
1771
1771
/// * 'limit_price' (u64):
1772
- /// - The limit price expressed in units of RAO per one Alpha.
1772
+ /// - The limit price expressed in units of RAO per one Alpha.
1773
1773
///
1774
1774
/// * 'allow_partial' (bool):
1775
- /// - Allows partial execution of the amount. If set to false, this becomes
1775
+ /// - Allows partial execution of the amount. If set to false, this becomes
1776
1776
/// fill or kill type or order.
1777
1777
///
1778
1778
/// # Event:
@@ -1811,5 +1811,52 @@ mod dispatches {
1811
1811
allow_partial,
1812
1812
)
1813
1813
}
1814
+
1815
+ /// Swaps a specified amount of stake from one subnet to another, while keeping the same coldkey and hotkey.
1816
+ ///
1817
+ /// # Arguments
1818
+ /// * `origin` - The origin of the transaction, which must be signed by the coldkey that owns the `hotkey`.
1819
+ /// * `hotkey` - The hotkey whose stake is being swapped.
1820
+ /// * `origin_netuid` - The network/subnet ID from which stake is removed.
1821
+ /// * `destination_netuid` - The network/subnet ID to which stake is added.
1822
+ /// * `alpha_amount` - The amount of stake to swap.
1823
+ /// * `limit_price` - The limit price expressed in units of RAO per one Alpha.
1824
+ /// * `allow_partial` - Allows partial execution of the amount. If set to false, this becomes fill or kill type or order.
1825
+ ///
1826
+ /// # Errors
1827
+ /// Returns an error if:
1828
+ /// * The transaction is not signed by the correct coldkey (i.e., `coldkey_owns_hotkey` fails).
1829
+ /// * Either `origin_netuid` or `destination_netuid` does not exist.
1830
+ /// * The hotkey does not exist.
1831
+ /// * There is insufficient stake on `(coldkey, hotkey, origin_netuid)`.
1832
+ /// * The swap amount is below the minimum stake requirement.
1833
+ ///
1834
+ /// # Events
1835
+ /// May emit a `StakeSwapped` event on success.
1836
+ #[ pallet:: call_index( 90 ) ]
1837
+ #[ pallet:: weight( (
1838
+ Weight :: from_parts( 3_000_000 , 0 ) . saturating_add( T :: DbWeight :: get( ) . writes( 1 ) ) ,
1839
+ DispatchClass :: Operational ,
1840
+ Pays :: No
1841
+ ) ) ]
1842
+ pub fn swap_stake_limit (
1843
+ origin : T :: RuntimeOrigin ,
1844
+ hotkey : T :: AccountId ,
1845
+ origin_netuid : u16 ,
1846
+ destination_netuid : u16 ,
1847
+ alpha_amount : u64 ,
1848
+ limit_price : u64 ,
1849
+ allow_partial : bool ,
1850
+ ) -> DispatchResult {
1851
+ Self :: do_swap_stake_limit (
1852
+ origin,
1853
+ hotkey,
1854
+ origin_netuid,
1855
+ destination_netuid,
1856
+ alpha_amount,
1857
+ limit_price,
1858
+ allow_partial,
1859
+ )
1860
+ }
1814
1861
}
1815
1862
}
0 commit comments