|
| 1 | +pragma solidity ^0.8.0; |
| 2 | + |
| 3 | +address constant ISTAKING_ADDRESS = 0x0000000000000000000000000000000000000805; |
| 4 | + |
| 5 | +interface IStaking { |
| 6 | + /** |
| 7 | + * @dev Adds a subtensor stake `amount` associated with the `hotkey`. |
| 8 | + * |
| 9 | + * This function allows external accounts and contracts to stake TAO into the subtensor pallet, |
| 10 | + * which effectively calls `add_stake` on the subtensor pallet with specified hotkey as a parameter |
| 11 | + * and coldkey being the hashed address mapping of H160 sender address to Substrate ss58 address as |
| 12 | + * implemented in Frontier HashedAddressMapping: |
| 13 | + * https://github.com/polkadot-evm/frontier/blob/2e219e17a526125da003e64ef22ec037917083fa/frame/evm/src/lib.rs#L739 |
| 14 | + * |
| 15 | + * @param hotkey The hotkey public key (32 bytes). |
| 16 | + * @param amount The amount to stake in rao. |
| 17 | + * @param netuid The subnet to stake to (uint256). |
| 18 | + * |
| 19 | + * Requirements: |
| 20 | + * - `hotkey` must be a valid hotkey registered on the network, ensuring that the stake is |
| 21 | + * correctly attributed. |
| 22 | + */ |
| 23 | + function addStake(bytes32 hotkey, uint256 amount, uint256 netuid) external payable; |
| 24 | + |
| 25 | + /** |
| 26 | + * @dev Removes a subtensor stake `amount` from the specified `hotkey`. |
| 27 | + * |
| 28 | + * This function allows external accounts and contracts to unstake TAO from the subtensor pallet, |
| 29 | + * which effectively calls `remove_stake` on the subtensor pallet with specified hotkey as a parameter |
| 30 | + * and coldkey being the hashed address mapping of H160 sender address to Substrate ss58 address as |
| 31 | + * implemented in Frontier HashedAddressMapping: |
| 32 | + * https://github.com/polkadot-evm/frontier/blob/2e219e17a526125da003e64ef22ec037917083fa/frame/evm/src/lib.rs#L739 |
| 33 | + * |
| 34 | + * @param hotkey The hotkey public key (32 bytes). |
| 35 | + * @param amount The amount to unstake in alpha. |
| 36 | + * @param netuid The subnet to stake to (uint256). |
| 37 | + * |
| 38 | + * Requirements: |
| 39 | + * - `hotkey` must be a valid hotkey registered on the network, ensuring that the stake is |
| 40 | + * correctly attributed. |
| 41 | + * - The existing stake amount must be not lower than specified amount |
| 42 | + */ |
| 43 | + function removeStake( |
| 44 | + bytes32 hotkey, |
| 45 | + uint256 amount, |
| 46 | + uint256 netuid |
| 47 | + ) external; |
| 48 | + |
| 49 | + /** |
| 50 | + * @dev Returns the amount of RAO staked by the coldkey. |
| 51 | + * |
| 52 | + * This function allows external accounts and contracts to query the amount of RAO staked by the coldkey |
| 53 | + * which effectively calls `get_total_coldkey_stake` on the subtensor pallet with |
| 54 | + * specified coldkey as a parameter. |
| 55 | + * |
| 56 | + * @param coldkey The coldkey public key (32 bytes). |
| 57 | + * @return The amount of RAO staked by the coldkey. |
| 58 | + */ |
| 59 | + function getTotalColdkeyStake(bytes32 coldkey) external view returns (uint256); |
| 60 | + |
| 61 | + /** |
| 62 | + * @dev Returns the total amount of stake under a hotkey (delegative or otherwise) |
| 63 | + * |
| 64 | + * This function allows external accounts and contracts to query the total amount of RAO staked under a hotkey |
| 65 | + * which effectively calls `get_total_hotkey_stake` on the subtensor pallet with |
| 66 | + * specified hotkey as a parameter. |
| 67 | + * |
| 68 | + * @param hotkey The hotkey public key (32 bytes). |
| 69 | + * @return The total amount of RAO staked under the hotkey. |
| 70 | + */ |
| 71 | + function getTotalHotkeyStake(bytes32 hotkey) external view returns (uint256); |
| 72 | + |
| 73 | + /** |
| 74 | + * @dev Returns the stake amount associated with the specified `hotkey` and `coldkey`. |
| 75 | + * |
| 76 | + * This function retrieves the current stake amount linked to a specific hotkey and coldkey pair. |
| 77 | + * It is a view function, meaning it does not modify the state of the contract and is free to call. |
| 78 | + * |
| 79 | + * @param hotkey The hotkey public key (32 bytes). |
| 80 | + * @param coldkey The coldkey public key (32 bytes). |
| 81 | + * @param netuid The subnet the stake is on (uint256). |
| 82 | + * @return The current stake amount in uint256 format. |
| 83 | + */ |
| 84 | + function getStake( |
| 85 | + bytes32 hotkey, |
| 86 | + bytes32 coldkey, |
| 87 | + uint256 netuid |
| 88 | + ) external view returns (uint256); |
| 89 | + |
| 90 | + /** |
| 91 | + * @dev Delegates staking to a proxy account. |
| 92 | + * |
| 93 | + * @param delegate The public key (32 bytes) of the delegate. |
| 94 | + */ |
| 95 | + function addProxy(bytes32 delegate) external; |
| 96 | + |
| 97 | + /** |
| 98 | + * @dev Removes staking proxy account. |
| 99 | + * |
| 100 | + * @param delegate The public key (32 bytes) of the delegate. |
| 101 | + */ |
| 102 | + function removeProxy(bytes32 delegate) external; |
| 103 | +} |
0 commit comments