referrerpolicy=no-referrer-when-downgrade

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		///
47		/// If pending slash of the member exceeds `ExistentialDeposit`, it can be reported on
48		/// chain.
49		fn member_pending_slash(member: AccountId) -> Balance;
50
51		/// Returns true if the pool with `pool_id` needs migration.
52		///
53		/// This can happen when the `pallet-nomination-pools` has switched to using strategy
54		/// [`DelegateStake`](pallet_nomination_pools::adapter::DelegateStake) but the pool
55		/// still has funds that were staked using the older strategy
56		/// [TransferStake](pallet_nomination_pools::adapter::TransferStake). Use
57		/// [`migrate_pool_to_delegate_stake`](pallet_nomination_pools::Call::migrate_pool_to_delegate_stake)
58		/// to migrate the pool.
59		fn pool_needs_delegate_migration(pool_id: PoolId) -> bool;
60
61		/// Returns true if the delegated funds of the pool `member` needs migration.
62		///
63		/// Once a pool has successfully migrated to the strategy
64		/// [`DelegateStake`](pallet_nomination_pools::adapter::DelegateStake), the funds of the
65		/// member can be migrated from pool account to the member's account. Use
66		/// [`migrate_delegation`](pallet_nomination_pools::Call::migrate_delegation)
67		/// to migrate the funds of the pool member.
68		fn member_needs_delegate_migration(member: AccountId) -> bool;
69
70		/// Returns the total contribution of a pool member including any balance that is unbonding.
71		fn member_total_balance(who: AccountId) -> Balance;
72
73		/// Total balance contributed to the pool.
74		fn pool_balance(pool_id: PoolId) -> Balance;
75
76		/// Returns the bonded account and reward account associated with the pool_id.
77		fn pool_accounts(pool_id: PoolId) -> (AccountId, AccountId);
78	}
79}