Trait sp_staking::StakingInterface
source · pub trait StakingInterface {
type Balance;
type AccountId;
fn minimum_bond() -> Self::Balance;
fn bonding_duration() -> EraIndex;
fn current_era() -> EraIndex;
fn active_stake(stash: &Self::AccountId) -> Option<Self::Balance>;
fn total_stake(stash: &Self::AccountId) -> Option<Self::Balance>;
fn bond(
stash: Self::AccountId,
controller: Self::AccountId,
value: Self::Balance,
payee: Self::AccountId
) -> DispatchResult;
fn nominate(
controller: Self::AccountId,
validators: Vec<Self::AccountId>
) -> DispatchResult;
fn chill(controller: Self::AccountId) -> DispatchResult;
fn bond_extra(stash: Self::AccountId, extra: Self::Balance) -> DispatchResult;
fn unbond(stash: Self::AccountId, value: Self::Balance) -> DispatchResult;
fn withdraw_unbonded(
stash: Self::AccountId,
num_slashing_spans: u32
) -> Result<bool, DispatchError>;
fn nominations(who: Self::AccountId) -> Option<Vec<Self::AccountId>>;
}
Expand description
Trait for communication with the staking pallet.
Required Associated Types§
Required Methods§
sourcefn minimum_bond() -> Self::Balance
fn minimum_bond() -> Self::Balance
The minimum amount required to bond in order to be a nominator. This does not necessarily mean the nomination will be counted in an election, but instead just enough to be stored as a nominator. In other words, this is the minimum amount to register the intention to nominate.
sourcefn bonding_duration() -> EraIndex
fn bonding_duration() -> EraIndex
Number of eras that staked funds must remain bonded for.
Note
This must be strictly greater than the staking systems slash deffer duration.
sourcefn current_era() -> EraIndex
fn current_era() -> EraIndex
The current era index.
This should be the latest planned era that the staking system knows about.
sourcefn active_stake(stash: &Self::AccountId) -> Option<Self::Balance>
fn active_stake(stash: &Self::AccountId) -> Option<Self::Balance>
The amount of active stake that stash
has in the staking system.
sourcefn total_stake(stash: &Self::AccountId) -> Option<Self::Balance>
fn total_stake(stash: &Self::AccountId) -> Option<Self::Balance>
The total stake that stash
has in the staking system. This includes the
Self::active_stake
, and any funds currently in the process of unbonding via
Self::unbond
.
Note
This is only guaranteed to reflect the amount locked by the staking system. If there are non-staking locks on the bonded pair’s balance this may not be accurate.
sourcefn bond(
stash: Self::AccountId,
controller: Self::AccountId,
value: Self::Balance,
payee: Self::AccountId
) -> DispatchResult
fn bond(
stash: Self::AccountId,
controller: Self::AccountId,
value: Self::Balance,
payee: Self::AccountId
) -> DispatchResult
Bond (lock) value
of stash
’s balance. controller
will be set as the account
controlling stash
. This creates what is referred to as “bonded pair”.
sourcefn nominate(
controller: Self::AccountId,
validators: Vec<Self::AccountId>
) -> DispatchResult
fn nominate(
controller: Self::AccountId,
validators: Vec<Self::AccountId>
) -> DispatchResult
Have controller
nominate validators
.
sourcefn chill(controller: Self::AccountId) -> DispatchResult
fn chill(controller: Self::AccountId) -> DispatchResult
Chill stash
.
sourcefn bond_extra(stash: Self::AccountId, extra: Self::Balance) -> DispatchResult
fn bond_extra(stash: Self::AccountId, extra: Self::Balance) -> DispatchResult
Bond some extra amount in the Stash’s free balance against the active bonded balance of the account. The amount extra actually bonded will never be more than the Stash’s free balance.
sourcefn unbond(stash: Self::AccountId, value: Self::Balance) -> DispatchResult
fn unbond(stash: Self::AccountId, value: Self::Balance) -> DispatchResult
Schedule a portion of the active bonded balance to be unlocked at era
Self::current_era + Self::bonding_duration
.
Once the unlock era has been reached, Self::withdraw_unbonded
can be called to unlock
the funds.
The amount of times this can be successfully called is limited based on how many distinct
eras funds are schedule to unlock in. Calling Self::withdraw_unbonded
after some unlock
schedules have reached their unlocking era should allow more calls to this function.
sourcefn withdraw_unbonded(
stash: Self::AccountId,
num_slashing_spans: u32
) -> Result<bool, DispatchError>
fn withdraw_unbonded(
stash: Self::AccountId,
num_slashing_spans: u32
) -> Result<bool, DispatchError>
Unlock any funds schedule to unlock before or at the current era.
Returns whether the stash was killed because of this withdraw or not.