pallet_nomination_pools_runtime_api/
lib.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// 	http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! Runtime API definition for nomination-pools pallet.
19//! Currently supports only one rpc endpoint.
20
21#![cfg_attr(not(feature = "std"), no_std)]
22
23use codec::Codec;
24use pallet_nomination_pools::PoolId;
25
26sp_api::decl_runtime_apis! {
27	/// Runtime api for accessing information about nomination pools.
28	pub trait NominationPoolsApi<AccountId, Balance>
29		where
30			AccountId: Codec,
31			Balance: Codec,
32	{
33		/// Returns the pending rewards for the member that the AccountId was given for.
34		fn pending_rewards(who: AccountId) -> Balance;
35
36		/// Returns the equivalent balance of `points` for a given pool.
37		fn points_to_balance(pool_id: PoolId, points: Balance) -> Balance;
38
39		/// Returns the equivalent points of `new_funds` for a given pool.
40		fn balance_to_points(pool_id: PoolId, new_funds: Balance) -> Balance;
41
42		/// Returns the pending slash for a given pool.
43		fn pool_pending_slash(pool_id: PoolId) -> Balance;
44
45		/// Returns the pending slash for a given pool member.
46		fn member_pending_slash(member: AccountId) -> Balance;
47
48		/// Returns true if the pool with `pool_id` needs migration.
49		///
50		/// This can happen when the `pallet-nomination-pools` has switched to using strategy
51		/// [`DelegateStake`](pallet_nomination_pools::adapter::DelegateStake) but the pool
52		/// still has funds that were staked using the older strategy
53		/// [TransferStake](pallet_nomination_pools::adapter::TransferStake). Use
54		/// [`migrate_pool_to_delegate_stake`](pallet_nomination_pools::Call::migrate_pool_to_delegate_stake)
55		/// to migrate the pool.
56		fn pool_needs_delegate_migration(pool_id: PoolId) -> bool;
57
58		/// Returns true if the delegated funds of the pool `member` needs migration.
59		///
60		/// Once a pool has successfully migrated to the strategy
61		/// [`DelegateStake`](pallet_nomination_pools::adapter::DelegateStake), the funds of the
62		/// member can be migrated from pool account to the member's account. Use
63		/// [`migrate_delegation`](pallet_nomination_pools::Call::migrate_delegation)
64		/// to migrate the funds of the pool member.
65		fn member_needs_delegate_migration(member: AccountId) -> bool;
66
67		/// Returns the total contribution of a pool member including any balance that is unbonding.
68		fn member_total_balance(who: AccountId) -> Balance;
69
70		/// Total balance contributed to the pool.
71		fn pool_balance(pool_id: PoolId) -> Balance;
72
73		/// Returns the bonded account and reward account associated with the pool_id.
74		fn pool_accounts(pool_id: PoolId) -> (AccountId, AccountId);
75	}
76}