pub type NominationPools = Pallet<Runtime>;
Aliased Type§
struct NominationPools(/* private fields */);
Implementations
Source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
Sourcepub fn join(
origin: <T as Config>::RuntimeOrigin,
amount: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance,
pool_id: u32,
) -> Result<(), DispatchError>
pub fn join( origin: <T as Config>::RuntimeOrigin, amount: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance, pool_id: u32, ) -> Result<(), DispatchError>
Stake funds with a pool. The amount to bond is delegated (or transferred based on
adapter::StakeStrategyType
) from the member to the pool account and immediately
increases the pool’s bond.
The method of transferring the amount to the pool account is determined by
adapter::StakeStrategyType
. If the pool is configured to use
adapter::StakeStrategyType::Delegate
, the funds remain in the account of
the origin
, while the pool gains the right to use these funds for staking.
§Note
- An account can only be a member of a single pool.
- An account cannot join the same pool multiple times.
- This call will not dust the member account, so the member must have at least
existential deposit + amount
in their account. - Only a pool with
PoolState::Open
can be joined
Sourcepub fn bond_extra(
origin: <T as Config>::RuntimeOrigin,
extra: BondExtra<<<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance>,
) -> Result<(), DispatchError>
pub fn bond_extra( origin: <T as Config>::RuntimeOrigin, extra: BondExtra<<<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance>, ) -> Result<(), DispatchError>
Bond extra
more funds from origin
into the pool to which they already belong.
Additional funds can come from either the free balance of the account, of from the
accumulated rewards, see BondExtra
.
Bonding extra funds implies an automatic payout of all pending rewards as well.
See bond_extra_other
to bond pending rewards of other
members.
Sourcepub fn claim_payout(
origin: <T as Config>::RuntimeOrigin,
) -> Result<(), DispatchError>
pub fn claim_payout( origin: <T as Config>::RuntimeOrigin, ) -> Result<(), DispatchError>
A bonded member can use this to claim their payout based on the rewards that the pool has accumulated since their last claimed payout (OR since joining if this is their first time claiming rewards). The payout will be transferred to the member’s account.
The member will earn rewards pro rata based on the members stake vs the sum of the members in the pools stake. Rewards do not “expire”.
See claim_payout_other
to claim rewards on behalf of some other
pool member.
Sourcepub fn unbond(
origin: <T as Config>::RuntimeOrigin,
member_account: <<T as Config>::Lookup as StaticLookup>::Source,
unbonding_points: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance,
) -> Result<(), DispatchError>
pub fn unbond( origin: <T as Config>::RuntimeOrigin, member_account: <<T as Config>::Lookup as StaticLookup>::Source, unbonding_points: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance, ) -> Result<(), DispatchError>
Unbond up to unbonding_points
of the member_account
’s funds from the pool. It
implicitly collects the rewards one last time, since not doing so would mean some
rewards would be forfeited.
Under certain conditions, this call can be dispatched permissionlessly (i.e. by any account).
§Conditions for a permissionless dispatch.
- The pool is blocked and the caller is either the root or bouncer. This is refereed to as a kick.
- The pool is destroying and the member is not the depositor.
- The pool is destroying, the member is the depositor and no other members are in the pool.
§Conditions for permissioned dispatch (i.e. the caller is also the
member_account
):
- The caller is not the depositor.
- The caller is the depositor, the pool is destroying and no other members are in the pool.
§Note
If there are too many unlocking chunks to unbond with the pool account,
Call::pool_withdraw_unbonded
can be called to try and minimize unlocking chunks.
The StakingInterface::unbond
will implicitly call Call::pool_withdraw_unbonded
to try to free chunks if necessary (ie. if unbound was called and no unlocking chunks
are available). However, it may not be possible to release the current unlocking chunks,
in which case, the result of this call will likely be the NoMoreChunks
error from the
staking system.
Sourcepub fn pool_withdraw_unbonded(
origin: <T as Config>::RuntimeOrigin,
pool_id: u32,
num_slashing_spans: u32,
) -> Result<(), DispatchError>
pub fn pool_withdraw_unbonded( origin: <T as Config>::RuntimeOrigin, pool_id: u32, num_slashing_spans: u32, ) -> Result<(), DispatchError>
Call withdraw_unbonded
for the pools account. This call can be made by any account.
This is useful if there are too many unlocking chunks to call unbond
, and some
can be cleared by withdrawing. In the case there are too many unlocking chunks, the user
would probably see an error like NoMoreChunks
emitted from the staking system when
they attempt to unbond.
Sourcepub fn withdraw_unbonded(
origin: <T as Config>::RuntimeOrigin,
member_account: <<T as Config>::Lookup as StaticLookup>::Source,
num_slashing_spans: u32,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
pub fn withdraw_unbonded( origin: <T as Config>::RuntimeOrigin, member_account: <<T as Config>::Lookup as StaticLookup>::Source, num_slashing_spans: u32, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
Withdraw unbonded funds from member_account
. If no bonded funds can be unbonded, an
error is returned.
Under certain conditions, this call can be dispatched permissionlessly (i.e. by any account).
§Conditions for a permissionless dispatch
- The pool is in destroy mode and the target is not the depositor.
- The target is the depositor and they are the only member in the sub pools.
- The pool is blocked and the caller is either the root or bouncer.
§Conditions for permissioned dispatch
- The caller is the target and they are not the depositor.
§Note
- If the target is the depositor, the pool will be destroyed.
- If the pool has any pending slash, we also try to slash the member before letting them
withdraw. This calculation adds some weight overhead and is only defensive. In reality,
pool slashes must have been already applied via permissionless
Call::apply_slash
.
Sourcepub fn create(
origin: <T as Config>::RuntimeOrigin,
amount: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance,
root: <<T as Config>::Lookup as StaticLookup>::Source,
nominator: <<T as Config>::Lookup as StaticLookup>::Source,
bouncer: <<T as Config>::Lookup as StaticLookup>::Source,
) -> Result<(), DispatchError>
pub fn create( origin: <T as Config>::RuntimeOrigin, amount: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance, root: <<T as Config>::Lookup as StaticLookup>::Source, nominator: <<T as Config>::Lookup as StaticLookup>::Source, bouncer: <<T as Config>::Lookup as StaticLookup>::Source, ) -> Result<(), DispatchError>
Create a new delegation pool.
§Arguments
amount
- The amount of funds to delegate to the pool. This also acts of a sort of deposit since the pools creator cannot fully unbond funds until the pool is being destroyed.index
- A disambiguation index for creating the account. Likely only useful when creating multiple pools in the same extrinsic.root
- The account to set asPoolRoles::root
.nominator
- The account to set as thePoolRoles::nominator
.bouncer
- The account to set as thePoolRoles::bouncer
.
§Note
In addition to amount
, the caller will transfer the existential deposit; so the caller
needs at have at least amount + existential_deposit
transferable.
Sourcepub fn create_with_pool_id(
origin: <T as Config>::RuntimeOrigin,
amount: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance,
root: <<T as Config>::Lookup as StaticLookup>::Source,
nominator: <<T as Config>::Lookup as StaticLookup>::Source,
bouncer: <<T as Config>::Lookup as StaticLookup>::Source,
pool_id: u32,
) -> Result<(), DispatchError>
pub fn create_with_pool_id( origin: <T as Config>::RuntimeOrigin, amount: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance, root: <<T as Config>::Lookup as StaticLookup>::Source, nominator: <<T as Config>::Lookup as StaticLookup>::Source, bouncer: <<T as Config>::Lookup as StaticLookup>::Source, pool_id: u32, ) -> Result<(), DispatchError>
Create a new delegation pool with a previously used pool id
§Arguments
same as create
with the inclusion of
pool_id
- `A valid PoolId.
Sourcepub fn nominate(
origin: <T as Config>::RuntimeOrigin,
pool_id: u32,
validators: Vec<<T as Config>::AccountId>,
) -> Result<(), DispatchError>
pub fn nominate( origin: <T as Config>::RuntimeOrigin, pool_id: u32, validators: Vec<<T as Config>::AccountId>, ) -> Result<(), DispatchError>
Nominate on behalf of the pool.
The dispatch origin of this call must be signed by the pool nominator or the pool root role.
This directly forwards the call to an implementation of StakingInterface
(e.g.,
pallet-staking
) through Config::StakeAdapter
, on behalf of the bonded pool.
§Note
In addition to a root
or nominator
role of origin
, the pool’s depositor needs to
have at least depositor_min_bond
in the pool to start nominating.
Sourcepub fn set_state(
origin: <T as Config>::RuntimeOrigin,
pool_id: u32,
state: PoolState,
) -> Result<(), DispatchError>
pub fn set_state( origin: <T as Config>::RuntimeOrigin, pool_id: u32, state: PoolState, ) -> Result<(), DispatchError>
Set a new state for the pool.
If a pool is already in the Destroying
state, then under no condition can its state
change again.
The dispatch origin of this call must be either:
- signed by the bouncer, or the root role of the pool,
- if the pool conditions to be open are NOT met (as described by
ok_to_be_open
), and then the state of the pool can be permissionlessly changed toDestroying
.
Sourcepub fn set_metadata(
origin: <T as Config>::RuntimeOrigin,
pool_id: u32,
metadata: Vec<u8>,
) -> Result<(), DispatchError>
pub fn set_metadata( origin: <T as Config>::RuntimeOrigin, pool_id: u32, metadata: Vec<u8>, ) -> Result<(), DispatchError>
Set a new metadata for the pool.
The dispatch origin of this call must be signed by the bouncer, or the root role of the pool.
Sourcepub fn set_configs(
origin: <T as Config>::RuntimeOrigin,
min_join_bond: ConfigOp<<<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance>,
min_create_bond: ConfigOp<<<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance>,
max_pools: ConfigOp<u32>,
max_members: ConfigOp<u32>,
max_members_per_pool: ConfigOp<u32>,
global_max_commission: ConfigOp<Perbill>,
) -> Result<(), DispatchError>
pub fn set_configs( origin: <T as Config>::RuntimeOrigin, min_join_bond: ConfigOp<<<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance>, min_create_bond: ConfigOp<<<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance>, max_pools: ConfigOp<u32>, max_members: ConfigOp<u32>, max_members_per_pool: ConfigOp<u32>, global_max_commission: ConfigOp<Perbill>, ) -> Result<(), DispatchError>
Update configurations for the nomination pools. The origin for this call must be
Config::AdminOrigin
.
§Arguments
min_join_bond
- SetMinJoinBond
.min_create_bond
- SetMinCreateBond
.max_pools
- SetMaxPools
.max_members
- SetMaxPoolMembers
.max_members_per_pool
- SetMaxPoolMembersPerPool
.global_max_commission
- SetGlobalMaxCommission
.
Sourcepub fn update_roles(
origin: <T as Config>::RuntimeOrigin,
pool_id: u32,
new_root: ConfigOp<<T as Config>::AccountId>,
new_nominator: ConfigOp<<T as Config>::AccountId>,
new_bouncer: ConfigOp<<T as Config>::AccountId>,
) -> Result<(), DispatchError>
pub fn update_roles( origin: <T as Config>::RuntimeOrigin, pool_id: u32, new_root: ConfigOp<<T as Config>::AccountId>, new_nominator: ConfigOp<<T as Config>::AccountId>, new_bouncer: ConfigOp<<T as Config>::AccountId>, ) -> Result<(), DispatchError>
Update the roles of the pool.
The root is the only entity that can change any of the roles, including itself, excluding the depositor, who can never change.
It emits an event, notifying UIs of the role change. This event is quite relevant to most pool members and they should be informed of changes to pool roles.
Sourcepub fn chill(
origin: <T as Config>::RuntimeOrigin,
pool_id: u32,
) -> Result<(), DispatchError>
pub fn chill( origin: <T as Config>::RuntimeOrigin, pool_id: u32, ) -> Result<(), DispatchError>
Chill on behalf of the pool.
The dispatch origin of this call can be signed by the pool nominator or the pool
root role, same as Pallet::nominate
.
This directly forwards the call to an implementation of StakingInterface
(e.g.,
pallet-staking
) through Config::StakeAdapter
, on behalf of the bonded pool.
Under certain conditions, this call can be dispatched permissionlessly (i.e. by any account).
§Conditions for a permissionless dispatch:
- When pool depositor has less than
MinNominatorBond
staked, otherwise pool members are unable to unbond.
§Conditions for permissioned dispatch:
- The caller is the pool’s nominator or root.
Sourcepub fn bond_extra_other(
origin: <T as Config>::RuntimeOrigin,
member: <<T as Config>::Lookup as StaticLookup>::Source,
extra: BondExtra<<<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance>,
) -> Result<(), DispatchError>
pub fn bond_extra_other( origin: <T as Config>::RuntimeOrigin, member: <<T as Config>::Lookup as StaticLookup>::Source, extra: BondExtra<<<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance>, ) -> Result<(), DispatchError>
origin
bonds funds from extra
for some pool member member
into their respective
pools.
origin
can bond extra funds from free balance or pending rewards when origin == other
.
In the case of origin != other
, origin
can only bond extra pending rewards of
other
members assuming set_claim_permission for the given member is
PermissionlessCompound
or PermissionlessAll
.
Sourcepub fn set_claim_permission(
origin: <T as Config>::RuntimeOrigin,
permission: ClaimPermission,
) -> Result<(), DispatchError>
pub fn set_claim_permission( origin: <T as Config>::RuntimeOrigin, permission: ClaimPermission, ) -> Result<(), DispatchError>
Allows a pool member to set a claim permission to allow or disallow permissionless bonding and withdrawing.
§Arguments
origin
- Member of a pool.permission
- The permission to be applied.
Sourcepub fn claim_payout_other(
origin: <T as Config>::RuntimeOrigin,
other: <T as Config>::AccountId,
) -> Result<(), DispatchError>
pub fn claim_payout_other( origin: <T as Config>::RuntimeOrigin, other: <T as Config>::AccountId, ) -> Result<(), DispatchError>
origin
can claim payouts on some pool member other
’s behalf.
Pool member other
must have a PermissionlessWithdraw
or PermissionlessAll
claim
permission for this call to be successful.
Sourcepub fn set_commission(
origin: <T as Config>::RuntimeOrigin,
pool_id: u32,
new_commission: Option<(Perbill, <T as Config>::AccountId)>,
) -> Result<(), DispatchError>
pub fn set_commission( origin: <T as Config>::RuntimeOrigin, pool_id: u32, new_commission: Option<(Perbill, <T as Config>::AccountId)>, ) -> Result<(), DispatchError>
Set the commission of a pool.
Both a commission percentage and a commission payee must be provided in the current
tuple. Where a current
of None
is provided, any current commission will be removed.
- If a
None
is supplied tonew_commission
, existing commission will be removed.
Sourcepub fn set_commission_max(
origin: <T as Config>::RuntimeOrigin,
pool_id: u32,
max_commission: Perbill,
) -> Result<(), DispatchError>
pub fn set_commission_max( origin: <T as Config>::RuntimeOrigin, pool_id: u32, max_commission: Perbill, ) -> Result<(), DispatchError>
Set the maximum commission of a pool.
- Initial max can be set to any
Perbill
, and only smaller values thereafter. - Current commission will be lowered in the event it is higher than a new max commission.
Sourcepub fn set_commission_change_rate(
origin: <T as Config>::RuntimeOrigin,
pool_id: u32,
change_rate: CommissionChangeRate<<<T as Config>::BlockNumberProvider as BlockNumberProvider>::BlockNumber>,
) -> Result<(), DispatchError>
pub fn set_commission_change_rate( origin: <T as Config>::RuntimeOrigin, pool_id: u32, change_rate: CommissionChangeRate<<<T as Config>::BlockNumberProvider as BlockNumberProvider>::BlockNumber>, ) -> Result<(), DispatchError>
Set the commission change rate for a pool.
Initial change rate is not bounded, whereas subsequent updates can only be more restrictive than the current.
Sourcepub fn claim_commission(
origin: <T as Config>::RuntimeOrigin,
pool_id: u32,
) -> Result<(), DispatchError>
pub fn claim_commission( origin: <T as Config>::RuntimeOrigin, pool_id: u32, ) -> Result<(), DispatchError>
Claim pending commission.
The root
role of the pool is always allowed to claim the pool’s commission.
If the pool has set CommissionClaimPermission::Permissionless
, then any account can
trigger the process of claiming the pool’s commission.
If the pool has set its CommissionClaimPermission
to Account(acc)
, then only
accounts
acc
, and- the pool’s root account
may call this extrinsic on behalf of the pool.
Pending commissions are paid out and added to the total claimed commission. The total pending commission is reset to zero.
Sourcepub fn adjust_pool_deposit(
origin: <T as Config>::RuntimeOrigin,
pool_id: u32,
) -> Result<(), DispatchError>
pub fn adjust_pool_deposit( origin: <T as Config>::RuntimeOrigin, pool_id: u32, ) -> Result<(), DispatchError>
Top up the deficit or withdraw the excess ED from the pool.
When a pool is created, the pool depositor transfers ED to the reward account of the pool. ED is subject to change and over time, the deposit in the reward account may be insufficient to cover the ED deficit of the pool or vice-versa where there is excess deposit to the pool. This call allows anyone to adjust the ED deposit of the pool by either topping up the deficit or claiming the excess.
Sourcepub fn set_commission_claim_permission(
origin: <T as Config>::RuntimeOrigin,
pool_id: u32,
permission: Option<CommissionClaimPermission<<T as Config>::AccountId>>,
) -> Result<(), DispatchError>
pub fn set_commission_claim_permission( origin: <T as Config>::RuntimeOrigin, pool_id: u32, permission: Option<CommissionClaimPermission<<T as Config>::AccountId>>, ) -> Result<(), DispatchError>
Set or remove a pool’s commission claim permission.
Determines who can claim the pool’s pending commission. Only the Root
role of the pool
is able to configure commission claim permissions.
Sourcepub fn apply_slash(
origin: <T as Config>::RuntimeOrigin,
member_account: <<T as Config>::Lookup as StaticLookup>::Source,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
pub fn apply_slash( origin: <T as Config>::RuntimeOrigin, member_account: <<T as Config>::Lookup as StaticLookup>::Source, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
Apply a pending slash on a member.
Fails unless crate::pallet::Config::StakeAdapter
is of strategy type:
adapter::StakeStrategyType::Delegate
.
The pending slash amount of the member must be equal or more than ExistentialDeposit
.
This call can be dispatched permissionlessly (i.e. by any account). If the execution
is successful, fee is refunded and caller may be rewarded with a part of the slash
based on the crate::pallet::Config::StakeAdapter
configuration.
Sourcepub fn migrate_delegation(
origin: <T as Config>::RuntimeOrigin,
member_account: <<T as Config>::Lookup as StaticLookup>::Source,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
pub fn migrate_delegation( origin: <T as Config>::RuntimeOrigin, member_account: <<T as Config>::Lookup as StaticLookup>::Source, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
Migrates delegated funds from the pool account to the member_account
.
Fails unless crate::pallet::Config::StakeAdapter
is of strategy type:
adapter::StakeStrategyType::Delegate
.
This is a permission-less call and refunds any fee if claim is successful.
If the pool has migrated to delegation based staking, the staked tokens of pool members
can be moved and held in their own account. See adapter::DelegateStake
Sourcepub fn migrate_pool_to_delegate_stake(
origin: <T as Config>::RuntimeOrigin,
pool_id: u32,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
pub fn migrate_pool_to_delegate_stake( origin: <T as Config>::RuntimeOrigin, pool_id: u32, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
Migrate pool from adapter::StakeStrategyType::Transfer
to
adapter::StakeStrategyType::Delegate
.
Fails unless crate::pallet::Config::StakeAdapter
is of strategy type:
adapter::StakeStrategyType::Delegate
.
This call can be dispatched permissionlessly, and refunds any fee if successful.
If the pool has already migrated to delegation based staking, this call will fail.
Source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
Sourcepub fn depositor_min_bond() -> <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance
pub fn depositor_min_bond() -> <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance
The amount of bond that MUST REMAIN IN BONDED in ALL POOLS.
It is the responsibility of the depositor to put these funds into the pool initially. Upon unbond, they can never unbond to a value below this amount.
It is essentially max { MinNominatorBond, MinCreateBond, MinJoinBond }
, where the former
is coming from the staking pallet and the latter two are configured in this pallet.
Sourcepub fn dissolve_pool(bonded_pool: BondedPool<T>)
pub fn dissolve_pool(bonded_pool: BondedPool<T>)
Remove everything related to the given bonded pool.
Metadata and all of the sub-pools are also deleted. All accounts are dusted and the leftover of the reward account is returned to the depositor.
Sourcepub fn generate_bonded_account(id: u32) -> <T as Config>::AccountId
pub fn generate_bonded_account(id: u32) -> <T as Config>::AccountId
Create the main, bonded account of a pool with the given id.
Sourcepub fn generate_reward_account(id: u32) -> <T as Config>::AccountId
pub fn generate_reward_account(id: u32) -> <T as Config>::AccountId
Create the reward account of a pool with the given id.
Sourcepub fn unfreeze_pool_deposit(
reward_acc: &<T as Config>::AccountId,
) -> Result<(), DispatchError>
pub fn unfreeze_pool_deposit( reward_acc: &<T as Config>::AccountId, ) -> Result<(), DispatchError>
Removes the ED freeze on the reward account of pool_id
.
Sourcepub fn do_try_state(level: u8) -> Result<(), DispatchError>
pub fn do_try_state(level: u8) -> Result<(), DispatchError>
Ensure the correctness of the state of this pallet.
This should be valid before or after each state transition of this pallet.
§Invariants:
First, let’s consider pools:
BondedPools
andRewardPools
must all have the EXACT SAME key-set.SubPoolsStorage
must be a subset of the above superset.Metadata
keys must be a subset of the above superset.- the count of the above set must be less than
MaxPools
.
Then, considering members as well:
- each
BondedPool.member_counter
must be:- correct (compared to actual count of member who have
.pool_id
this pool) - less than
MaxPoolMembersPerPool
.
- correct (compared to actual count of member who have
- each
member.pool_id
must correspond to an existingBondedPool.id
(which implies the existence of the reward pool as well). - count of all members must be less than
MaxPoolMembers
. - each
BondedPool.points
must never be lower than the pool’s balance.
Then, considering unbonding members:
for each pool:
- sum of the balance that’s tracked in all unbonding pools must be the same as the unbonded balance of the main account, as reported by the staking interface.
- sum of the balance that’s tracked in all unbonding pools, plus the bonded balance of the main account should be less than or qual to the total balance of the main account.
§Sanity check level
To cater for tests that want to escape parts of these checks, this function is split into
multiple level
s, where the higher the level, the more checks we performs. So,
try_state(255)
is the strongest sanity check, and 0
performs no checks.
Sourcepub fn check_ed_imbalance() -> Result<(), DispatchError>
pub fn check_ed_imbalance() -> Result<(), DispatchError>
Check if any pool have an incorrect amount of ED frozen.
This can happen if the ED has changed since the pool was created.
Sourcepub fn fully_unbond(
origin: <T as Config>::RuntimeOrigin,
member: <T as Config>::AccountId,
) -> Result<(), DispatchError>
pub fn fully_unbond( origin: <T as Config>::RuntimeOrigin, member: <T as Config>::AccountId, ) -> Result<(), DispatchError>
Fully unbond the shares of member
, when executed from origin
.
This is useful for backwards compatibility with the majority of tests that only deal with full unbonding, not partial unbonding.
Source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
Sourcepub fn api_pending_rewards(
who: <T as Config>::AccountId,
) -> Option<<<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance>
pub fn api_pending_rewards( who: <T as Config>::AccountId, ) -> Option<<<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance>
Returns the pending rewards for the specified who
account.
In the case of error, None
is returned. Used by runtime API.
Sourcepub fn api_points_to_balance(
pool_id: u32,
points: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance,
) -> <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance
pub fn api_points_to_balance( pool_id: u32, points: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance, ) -> <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance
Returns the points to balance conversion for a specified pool.
If the pool ID does not exist, it returns 0 ratio points to balance. Used by runtime API.
Sourcepub fn api_balance_to_points(
pool_id: u32,
new_funds: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance,
) -> <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance
pub fn api_balance_to_points( pool_id: u32, new_funds: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance, ) -> <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance
Returns the equivalent new_funds
balance to point conversion for a specified pool.
If the pool ID does not exist, returns 0 ratio balance to points. Used by runtime API.
Sourcepub fn api_pool_pending_slash(
pool_id: u32,
) -> <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance
pub fn api_pool_pending_slash( pool_id: u32, ) -> <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance
Returns the unapplied slash of the pool.
Pending slash is only applicable with adapter::DelegateStake
strategy.
Sourcepub fn api_member_pending_slash(
who: <T as Config>::AccountId,
) -> <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance
pub fn api_member_pending_slash( who: <T as Config>::AccountId, ) -> <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance
Returns the unapplied slash of a member.
Pending slash is only applicable with adapter::DelegateStake
strategy.
If pending slash of the member exceeds ExistentialDeposit
, it can be reported on
chain via Call::apply_slash
.
Sourcepub fn api_pool_needs_delegate_migration(pool_id: u32) -> bool
pub fn api_pool_needs_delegate_migration(pool_id: u32) -> bool
Checks whether pool needs to be migrated to adapter::StakeStrategyType::Delegate
. Only
applicable when the Config::StakeAdapter
is adapter::DelegateStake
.
Useful to check this before calling Call::migrate_pool_to_delegate_stake
.
Sourcepub fn api_member_needs_delegate_migration(
who: <T as Config>::AccountId,
) -> bool
pub fn api_member_needs_delegate_migration( who: <T as Config>::AccountId, ) -> bool
Checks whether member delegation needs to be migrated to
adapter::StakeStrategyType::Delegate
. Only applicable when the Config::StakeAdapter
is adapter::DelegateStake
.
Useful to check this before calling Call::migrate_delegation
.
Sourcepub fn api_member_total_balance(
who: <T as Config>::AccountId,
) -> <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance
pub fn api_member_total_balance( who: <T as Config>::AccountId, ) -> <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance
Contribution of the member in the pool.
Includes balance that is unbonded from staking but not claimed yet from the pool, therefore this balance can be higher than the staked funds.
Trait Implementations
Source§impl<T> BeforeAllRuntimeMigrations for Pallet<T>where
T: Config,
impl<T> BeforeAllRuntimeMigrations for Pallet<T>where
T: Config,
Source§fn before_all_runtime_migrations() -> Weight
fn before_all_runtime_migrations() -> Weight
Source§impl<T> DispatchViewFunction for Pallet<T>where
T: Config,
impl<T> DispatchViewFunction for Pallet<T>where
T: Config,
fn dispatch_view_function<O>(
id: &ViewFunctionId,
input: &mut &[u8],
output: &mut O,
) -> Result<(), ViewFunctionDispatchError>where
O: Output,
Source§impl<T> GetStorageVersion for Pallet<T>where
T: Config,
impl<T> GetStorageVersion for Pallet<T>where
T: Config,
Source§fn in_code_storage_version() -> <Pallet<T> as GetStorageVersion>::InCodeStorageVersion
fn in_code_storage_version() -> <Pallet<T> as GetStorageVersion>::InCodeStorageVersion
storage_version
attribute, or
NoStorageVersionSet
if the attribute is missing.Source§fn on_chain_storage_version() -> StorageVersion
fn on_chain_storage_version() -> StorageVersion
Source§fn current_storage_version() -> Self::InCodeStorageVersion
fn current_storage_version() -> Self::InCodeStorageVersion
in_code_storage_version
and will be removed after March 2024.Self::current_storage_version
instead. Read moreSource§impl<T> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§fn try_state(
_n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number,
) -> Result<(), DispatchError>
fn try_state( _n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, ) -> Result<(), DispatchError>
Source§fn integrity_test()
fn integrity_test()
Source§fn on_initialize(_n: BlockNumber) -> Weight
fn on_initialize(_n: BlockNumber) -> Weight
Source§fn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
Source§fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
Hooks::on_finalize
). Read moreSource§fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)
fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)
Source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Executive
pallet. Read moreSource§fn pre_upgrade() -> Result<Vec<u8>, DispatchError>
fn pre_upgrade() -> Result<Vec<u8>, DispatchError>
Source§fn post_upgrade(_state: Vec<u8>) -> Result<(), DispatchError>
fn post_upgrade(_state: Vec<u8>) -> Result<(), DispatchError>
Source§fn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
Source§impl<T> IntegrityTest for Pallet<T>where
T: Config,
impl<T> IntegrityTest for Pallet<T>where
T: Config,
Source§impl<T> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§impl<T> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§fn on_finalize(
n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number,
)
fn on_finalize( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, )
Hooks::on_finalize
.Source§impl<T> OnGenesis for Pallet<T>where
T: Config,
impl<T> OnGenesis for Pallet<T>where
T: Config,
Source§fn on_genesis()
fn on_genesis()
Source§impl<T> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§impl<T> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§fn on_initialize(
n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number,
) -> Weight
fn on_initialize( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, ) -> Weight
Hooks::on_initialize
.Source§impl<T> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§impl<T> OnRuntimeUpgrade for Pallet<T>where
T: Config,
impl<T> OnRuntimeUpgrade for Pallet<T>where
T: Config,
Source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Source§fn pre_upgrade() -> Result<Vec<u8>, DispatchError>
fn pre_upgrade() -> Result<Vec<u8>, DispatchError>
Hooks::pre_upgrade
.Source§fn post_upgrade(state: Vec<u8>) -> Result<(), DispatchError>
fn post_upgrade(state: Vec<u8>) -> Result<(), DispatchError>
Hooks::post_upgrade
.Source§fn try_on_runtime_upgrade(checks: bool) -> Result<Weight, DispatchError>
fn try_on_runtime_upgrade(checks: bool) -> Result<Weight, DispatchError>
pre_upgrade
->
on_runtime_upgrade
-> post_upgrade
hooks for a migration. Read moreSource§impl<T> OnStakingUpdate<<T as Config>::AccountId, <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance> for Pallet<T>where
T: Config,
impl<T> OnStakingUpdate<<T as Config>::AccountId, <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance> for Pallet<T>where
T: Config,
Source§fn on_slash(
pool_account: &<T as Config>::AccountId,
slashed_bonded: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance,
slashed_unlocking: &BTreeMap<u32, <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance>,
total_slashed: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance,
)
fn on_slash( pool_account: &<T as Config>::AccountId, slashed_bonded: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance, slashed_unlocking: &BTreeMap<u32, <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance>, total_slashed: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance, )
Reduces the balances of the SubPools
, that belong to the pool involved in the
slash, to the amount that is defined in the slashed_unlocking
field of
sp_staking::OnStakingUpdate::on_slash
Emits the PoolsSlashed
event.
Source§fn on_withdraw(
pool_account: &<T as Config>::AccountId,
amount: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance,
)
fn on_withdraw( pool_account: &<T as Config>::AccountId, amount: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance, )
Reduces the overall TotalValueLocked
if a withdrawal happened for a pool involved in the
staking withdraw.
Source§fn on_stake_update(_who: &AccountId, _prev_stake: Option<Stake<Balance>>)
fn on_stake_update(_who: &AccountId, _prev_stake: Option<Stake<Balance>>)
Source§fn on_nominator_add(_who: &AccountId)
fn on_nominator_add(_who: &AccountId)
Source§fn on_nominator_update(_who: &AccountId, _prev_nominations: Vec<AccountId>)
fn on_nominator_update(_who: &AccountId, _prev_nominations: Vec<AccountId>)
Source§fn on_nominator_remove(_who: &AccountId, _nominations: Vec<AccountId>)
fn on_nominator_remove(_who: &AccountId, _nominations: Vec<AccountId>)
Source§fn on_validator_add(_who: &AccountId)
fn on_validator_add(_who: &AccountId)
Source§fn on_validator_update(_who: &AccountId)
fn on_validator_update(_who: &AccountId)
Source§fn on_validator_remove(_who: &AccountId)
fn on_validator_remove(_who: &AccountId)
Source§fn on_unstake(_who: &AccountId)
fn on_unstake(_who: &AccountId)
Source§impl<T> PalletInfoAccess for Pallet<T>where
T: Config,
impl<T> PalletInfoAccess for Pallet<T>where
T: Config,
Source§fn module_name() -> &'static str
fn module_name() -> &'static str
Source§fn crate_version() -> CrateVersion
fn crate_version() -> CrateVersion
Source§impl<T> PalletsInfoAccess for Pallet<T>where
T: Config,
impl<T> PalletsInfoAccess for Pallet<T>where
T: Config,
Source§impl<T> StorageInfoTrait for Pallet<T>where
T: Config,
impl<T> StorageInfoTrait for Pallet<T>where
T: Config,
fn storage_info() -> Vec<StorageInfo>
Source§impl<T> TryDecodeEntireStorage for Pallet<T>where
T: Config,
impl<T> TryDecodeEntireStorage for Pallet<T>where
T: Config,
Source§fn try_decode_entire_state() -> Result<usize, Vec<TryDecodeEntireStorageError>>
fn try_decode_entire_state() -> Result<usize, Vec<TryDecodeEntireStorageError>>
Ok(bytes_decoded)
if success.Source§impl<T> TryState<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> TryState<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§impl<T> WhitelistedStorageKeys for Pallet<T>where
T: Config,
impl<T> WhitelistedStorageKeys for Pallet<T>where
T: Config,
Source§fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
Vec<TrackedStorageKey>
indicating the storage keys that
should be whitelisted during benchmarking. This means that those keys
will be excluded from the benchmarking performance calculation.