pub trait StakeStrategy {
type Balance: Balance;
type AccountId: Clone + Debug;
type CoreStaking: StakingInterface<Balance = Self::Balance, AccountId = Self::AccountId>;
Show 23 methods
// Required methods
fn strategy_type() -> StakeStrategyType;
fn transferable_balance(
pool_account: Pool<Self::AccountId>,
member_account: Member<Self::AccountId>,
) -> Self::Balance;
fn total_balance(
pool_account: Pool<Self::AccountId>,
) -> Option<Self::Balance>;
fn member_delegation_balance(
member_account: Member<Self::AccountId>,
) -> Option<Self::Balance>;
fn pledge_bond(
who: Member<Self::AccountId>,
pool_account: Pool<Self::AccountId>,
reward_account: &Self::AccountId,
amount: Self::Balance,
bond_type: BondType,
) -> DispatchResult;
fn member_withdraw(
who: Member<Self::AccountId>,
pool_account: Pool<Self::AccountId>,
amount: Self::Balance,
num_slashing_spans: u32,
) -> DispatchResult;
fn dissolve(pool_account: Pool<Self::AccountId>) -> DispatchResult;
fn pending_slash(pool_account: Pool<Self::AccountId>) -> Self::Balance;
fn member_slash(
who: Member<Self::AccountId>,
pool_account: Pool<Self::AccountId>,
amount: Self::Balance,
maybe_reporter: Option<Self::AccountId>,
) -> DispatchResult;
fn migrate_nominator_to_agent(
pool_account: Pool<Self::AccountId>,
reward_account: &Self::AccountId,
) -> DispatchResult;
fn migrate_delegation(
pool: Pool<Self::AccountId>,
delegator: Member<Self::AccountId>,
value: Self::Balance,
) -> DispatchResult;
// Provided methods
fn bonding_duration() -> EraIndex { ... }
fn current_era() -> EraIndex { ... }
fn minimum_nominator_bond() -> Self::Balance { ... }
fn active_stake(pool_account: Pool<Self::AccountId>) -> Self::Balance { ... }
fn total_stake(pool_account: Pool<Self::AccountId>) -> Self::Balance { ... }
fn pool_strategy(pool_account: Pool<Self::AccountId>) -> StakeStrategyType { ... }
fn nominate(
pool_account: Pool<Self::AccountId>,
validators: Vec<Self::AccountId>,
) -> DispatchResult { ... }
fn chill(pool_account: Pool<Self::AccountId>) -> DispatchResult { ... }
fn unbond(
pool_account: Pool<Self::AccountId>,
amount: Self::Balance,
) -> DispatchResult { ... }
fn withdraw_unbonded(
pool_account: Pool<Self::AccountId>,
num_slashing_spans: u32,
) -> Result<bool, DispatchError> { ... }
fn nominations(
pool_account: Pool<Self::AccountId>,
) -> Option<Vec<Self::AccountId>> { ... }
fn remove_as_agent(_pool: Pool<Self::AccountId>) { ... }
}
Expand description
An adapter trait that can support multiple staking strategies.
Depending on which staking strategy we want to use, the staking logic can be slightly
different. Refer the two possible strategies currently: TransferStake
and
DelegateStake
for more detail.
Required Associated Types§
type Balance: Balance
type AccountId: Clone + Debug
type CoreStaking: StakingInterface<Balance = Self::Balance, AccountId = Self::AccountId>
Required Methods§
sourcefn strategy_type() -> StakeStrategyType
fn strategy_type() -> StakeStrategyType
The type of staking strategy of the current adapter.
sourcefn transferable_balance(
pool_account: Pool<Self::AccountId>,
member_account: Member<Self::AccountId>,
) -> Self::Balance
fn transferable_balance( pool_account: Pool<Self::AccountId>, member_account: Member<Self::AccountId>, ) -> Self::Balance
Balance that can be transferred from pool account to member.
This is part of the pool balance that can be withdrawn.
sourcefn total_balance(pool_account: Pool<Self::AccountId>) -> Option<Self::Balance>
fn total_balance(pool_account: Pool<Self::AccountId>) -> Option<Self::Balance>
Total balance of the pool including amount that is actively staked.
sourcefn member_delegation_balance(
member_account: Member<Self::AccountId>,
) -> Option<Self::Balance>
fn member_delegation_balance( member_account: Member<Self::AccountId>, ) -> Option<Self::Balance>
Amount of tokens delegated by the member.
sourcefn pledge_bond(
who: Member<Self::AccountId>,
pool_account: Pool<Self::AccountId>,
reward_account: &Self::AccountId,
amount: Self::Balance,
bond_type: BondType,
) -> DispatchResult
fn pledge_bond( who: Member<Self::AccountId>, pool_account: Pool<Self::AccountId>, reward_account: &Self::AccountId, amount: Self::Balance, bond_type: BondType, ) -> DispatchResult
Pledge amount
towards pool_account
and update the pool bond. Also see
[StakingInterface::bond
].
sourcefn member_withdraw(
who: Member<Self::AccountId>,
pool_account: Pool<Self::AccountId>,
amount: Self::Balance,
num_slashing_spans: u32,
) -> DispatchResult
fn member_withdraw( who: Member<Self::AccountId>, pool_account: Pool<Self::AccountId>, amount: Self::Balance, num_slashing_spans: u32, ) -> DispatchResult
Withdraw funds from pool account to member account.
sourcefn pending_slash(pool_account: Pool<Self::AccountId>) -> Self::Balance
fn pending_slash(pool_account: Pool<Self::AccountId>) -> Self::Balance
Check if there is any pending slash for the pool.
sourcefn member_slash(
who: Member<Self::AccountId>,
pool_account: Pool<Self::AccountId>,
amount: Self::Balance,
maybe_reporter: Option<Self::AccountId>,
) -> DispatchResult
fn member_slash( who: Member<Self::AccountId>, pool_account: Pool<Self::AccountId>, amount: Self::Balance, maybe_reporter: Option<Self::AccountId>, ) -> DispatchResult
Slash the member account with amount
against pending slashes for the pool.
sourcefn migrate_nominator_to_agent(
pool_account: Pool<Self::AccountId>,
reward_account: &Self::AccountId,
) -> DispatchResult
fn migrate_nominator_to_agent( pool_account: Pool<Self::AccountId>, reward_account: &Self::AccountId, ) -> DispatchResult
Migrate pool account from being a direct nominator to a delegated agent.
This is useful for migrating a pool account from StakeStrategyType::Transfer
to
StakeStrategyType::Delegate
.
sourcefn migrate_delegation(
pool: Pool<Self::AccountId>,
delegator: Member<Self::AccountId>,
value: Self::Balance,
) -> DispatchResult
fn migrate_delegation( pool: Pool<Self::AccountId>, delegator: Member<Self::AccountId>, value: Self::Balance, ) -> DispatchResult
Migrate member balance from pool account to member account.
This is useful for a pool account that migrated from StakeStrategyType::Transfer
to
StakeStrategyType::Delegate
. Its members can then migrate their delegated balance
back to their account.
Internally, the member funds that are locked in the pool account are transferred back and locked in the member account.
Provided Methods§
sourcefn bonding_duration() -> EraIndex
fn bonding_duration() -> EraIndex
See [StakingInterface::bonding_duration
].
sourcefn current_era() -> EraIndex
fn current_era() -> EraIndex
See [StakingInterface::current_era
].
sourcefn minimum_nominator_bond() -> Self::Balance
fn minimum_nominator_bond() -> Self::Balance
See [StakingInterface::minimum_nominator_bond
].
sourcefn active_stake(pool_account: Pool<Self::AccountId>) -> Self::Balance
fn active_stake(pool_account: Pool<Self::AccountId>) -> Self::Balance
See [StakingInterface::active_stake
].
sourcefn total_stake(pool_account: Pool<Self::AccountId>) -> Self::Balance
fn total_stake(pool_account: Pool<Self::AccountId>) -> Self::Balance
See [StakingInterface::total_stake
].
sourcefn pool_strategy(pool_account: Pool<Self::AccountId>) -> StakeStrategyType
fn pool_strategy(pool_account: Pool<Self::AccountId>) -> StakeStrategyType
Which strategy the pool account is using.
This can be different from the Self::strategy_type
of the adapter if the pool has not
migrated to the new strategy yet.
sourcefn nominate(
pool_account: Pool<Self::AccountId>,
validators: Vec<Self::AccountId>,
) -> DispatchResult
fn nominate( pool_account: Pool<Self::AccountId>, validators: Vec<Self::AccountId>, ) -> DispatchResult
See [StakingInterface::nominate
].
sourcefn unbond(
pool_account: Pool<Self::AccountId>,
amount: Self::Balance,
) -> DispatchResult
fn unbond( pool_account: Pool<Self::AccountId>, amount: Self::Balance, ) -> DispatchResult
See [StakingInterface::unbond
].
sourcefn withdraw_unbonded(
pool_account: Pool<Self::AccountId>,
num_slashing_spans: u32,
) -> Result<bool, DispatchError>
fn withdraw_unbonded( pool_account: Pool<Self::AccountId>, num_slashing_spans: u32, ) -> Result<bool, DispatchError>
See [StakingInterface::withdraw_unbonded
].
sourcefn nominations(
pool_account: Pool<Self::AccountId>,
) -> Option<Vec<Self::AccountId>>
fn nominations( pool_account: Pool<Self::AccountId>, ) -> Option<Vec<Self::AccountId>>
List of validators nominated by the pool account.
sourcefn remove_as_agent(_pool: Pool<Self::AccountId>)
fn remove_as_agent(_pool: Pool<Self::AccountId>)
Remove the pool account as agent.
Useful for migrating pool account from a delegated agent to a direct nominator. Only used in tests and benchmarks.