pub type DelegatedStaking = Pallet<Runtime>;
Aliased Type§
struct DelegatedStaking(/* private fields */);
Implementations
Source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
Sourcepub fn register_agent(
origin: <T as Config>::RuntimeOrigin,
reward_account: <T as Config>::AccountId,
) -> Result<(), DispatchError>
pub fn register_agent( origin: <T as Config>::RuntimeOrigin, reward_account: <T as Config>::AccountId, ) -> Result<(), DispatchError>
Register an account to become a stake Agent
. Sometimes also called a Delegatee
.
Delegators can authorize Agent
s to stake on their behalf by delegating their funds to
them. The Agent
can then use the delegated funds to stake to Config::CoreStaking
.
An account that is directly staked to Config::CoreStaking
cannot become an Agent
.
However, they can migrate to become an agent using Self::migrate_to_agent
.
Implementation note: This function allows any account to become an agent. It is
important though that accounts that call StakingUnchecked::virtual_bond
are keyless
accounts. This is not a problem for now since this is only used by other pallets in the
runtime which use keyless account as agents. If we later want to expose this as a
dispatchable call, we should derive a sub-account from the caller and use that as the
agent account.
Sourcepub fn remove_agent(
origin: <T as Config>::RuntimeOrigin,
) -> Result<(), DispatchError>
pub fn remove_agent( origin: <T as Config>::RuntimeOrigin, ) -> Result<(), DispatchError>
Remove an account from being an Agent
.
This can only be called if the agent has no delegated funds, no pending slashes and no unclaimed withdrawals.
Sourcepub fn migrate_to_agent(
origin: <T as Config>::RuntimeOrigin,
reward_account: <T as Config>::AccountId,
) -> Result<(), DispatchError>
pub fn migrate_to_agent( origin: <T as Config>::RuntimeOrigin, reward_account: <T as Config>::AccountId, ) -> Result<(), DispatchError>
Migrate from a Nominator
account to Agent
account.
The origin needs to
- be a
Nominator
withConfig::CoreStaking
, - not already an
Agent
,
This function will create a proxy account to the agent called proxy_delegator
and
transfer the directly staked amount by the agent to it. The proxy_delegator
delegates
the funds to the origin making origin an Agent
account. The real delegator
accounts of the origin can later migrate their funds using Self::migrate_delegation to
claim back their share of delegated funds from proxy_delegator
to self.
Any free fund in the agent’s account will be marked as unclaimed withdrawal.
Sourcepub fn release_delegation(
origin: <T as Config>::RuntimeOrigin,
delegator: <T as Config>::AccountId,
amount: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance,
num_slashing_spans: u32,
) -> Result<(), DispatchError>
pub fn release_delegation( origin: <T as Config>::RuntimeOrigin, delegator: <T as Config>::AccountId, amount: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance, num_slashing_spans: u32, ) -> Result<(), DispatchError>
Release previously delegated funds by delegator to origin.
Only agents can call this.
Tries to withdraw unbonded funds from CoreStaking
if needed and release amount to
delegator
.
Sourcepub fn migrate_delegation(
origin: <T as Config>::RuntimeOrigin,
delegator: <T as Config>::AccountId,
amount: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance,
) -> Result<(), DispatchError>
pub fn migrate_delegation( origin: <T as Config>::RuntimeOrigin, delegator: <T as Config>::AccountId, amount: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance, ) -> Result<(), DispatchError>
Migrate delegated funds that are held in proxy_delegator
to the claiming delegator
’s
account. If successful, the specified funds will be moved and delegated from delegator
account to the agent.
This can be called by agent
accounts that were previously a direct Nominator
with
Config::CoreStaking
and has some remaining unclaimed delegations.
Internally, it moves some delegations from proxy_delegator
account to delegator
account and reapplying the holds.
Sourcepub fn delegate_to_agent(
origin: <T as Config>::RuntimeOrigin,
agent: <T as Config>::AccountId,
amount: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance,
) -> Result<(), DispatchError>
pub fn delegate_to_agent( origin: <T as Config>::RuntimeOrigin, agent: <T as Config>::AccountId, amount: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance, ) -> Result<(), DispatchError>
Delegate given amount
of tokens to an Agent
account.
If origin
is the first time delegator, we add them to state. If they are already
delegating, we increase the delegation.
Conditions:
- Delegators cannot delegate to more than one agent.
- The
agent
account should already be registered as such. SeeSelf::register_agent
.
Source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
Sourcepub fn generate_proxy_delegator(
agent: Agent<<T as Config>::AccountId>,
) -> Delegator<<T as Config>::AccountId>
pub fn generate_proxy_delegator( agent: Agent<<T as Config>::AccountId>, ) -> Delegator<<T as Config>::AccountId>
Derive an account from the migrating agent account where the unclaimed delegation funds are held.
Sourcepub fn do_slash(
agent: Agent<<T as Config>::AccountId>,
delegator: Delegator<<T as Config>::AccountId>,
amount: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance,
maybe_reporter: Option<<T as Config>::AccountId>,
) -> Result<(), DispatchError>
pub fn do_slash( agent: Agent<<T as Config>::AccountId>, delegator: Delegator<<T as Config>::AccountId>, amount: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance, maybe_reporter: Option<<T as Config>::AccountId>, ) -> Result<(), DispatchError>
Take slash amount
from agent’s pending_slash
counter and apply it to delegator
account.
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> DelegationInterface for Pallet<T>where
T: Config,
impl<T> DelegationInterface for Pallet<T>where
T: Config,
Source§fn agent_balance(
agent: Agent<<Pallet<T> as DelegationInterface>::AccountId>,
) -> Option<<Pallet<T> as DelegationInterface>::Balance>
fn agent_balance( agent: Agent<<Pallet<T> as DelegationInterface>::AccountId>, ) -> Option<<Pallet<T> as DelegationInterface>::Balance>
Effective balance of the Agent
account.
Source§fn register_agent(
agent: Agent<<Pallet<T> as DelegationInterface>::AccountId>,
reward_account: &<Pallet<T> as DelegationInterface>::AccountId,
) -> Result<(), DispatchError>
fn register_agent( agent: Agent<<Pallet<T> as DelegationInterface>::AccountId>, reward_account: &<Pallet<T> as DelegationInterface>::AccountId, ) -> Result<(), DispatchError>
Delegate funds to an Agent
.
Source§fn remove_agent(
agent: Agent<<Pallet<T> as DelegationInterface>::AccountId>,
) -> Result<(), DispatchError>
fn remove_agent( agent: Agent<<Pallet<T> as DelegationInterface>::AccountId>, ) -> Result<(), DispatchError>
Remove Agent
registration.
Source§fn delegate(
who: Delegator<<Pallet<T> as DelegationInterface>::AccountId>,
agent: Agent<<Pallet<T> as DelegationInterface>::AccountId>,
amount: <Pallet<T> as DelegationInterface>::Balance,
) -> Result<(), DispatchError>
fn delegate( who: Delegator<<Pallet<T> as DelegationInterface>::AccountId>, agent: Agent<<Pallet<T> as DelegationInterface>::AccountId>, amount: <Pallet<T> as DelegationInterface>::Balance, ) -> Result<(), DispatchError>
Add more delegation to the Agent
account.
Source§fn withdraw_delegation(
delegator: Delegator<<Pallet<T> as DelegationInterface>::AccountId>,
agent: Agent<<Pallet<T> as DelegationInterface>::AccountId>,
amount: <Pallet<T> as DelegationInterface>::Balance,
num_slashing_spans: u32,
) -> Result<(), DispatchError>
fn withdraw_delegation( delegator: Delegator<<Pallet<T> as DelegationInterface>::AccountId>, agent: Agent<<Pallet<T> as DelegationInterface>::AccountId>, amount: <Pallet<T> as DelegationInterface>::Balance, num_slashing_spans: u32, ) -> Result<(), DispatchError>
Withdraw delegation of delegator
to Agent
.
If there are funds in Agent
account that can be withdrawn, then those funds would be
unlocked/released in the delegator’s account.
Source§fn pending_slash(
agent: Agent<<Pallet<T> as DelegationInterface>::AccountId>,
) -> Option<<Pallet<T> as DelegationInterface>::Balance>
fn pending_slash( agent: Agent<<Pallet<T> as DelegationInterface>::AccountId>, ) -> Option<<Pallet<T> as DelegationInterface>::Balance>
Returns pending slash of the agent
.
Source§type Balance = <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance
type Balance = <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance
Source§fn agent_transferable_balance(
agent: Agent<<Pallet<T> as DelegationInterface>::AccountId>,
) -> Option<<Pallet<T> as DelegationInterface>::Balance>
fn agent_transferable_balance( agent: Agent<<Pallet<T> as DelegationInterface>::AccountId>, ) -> Option<<Pallet<T> as DelegationInterface>::Balance>
Agent
account. None
if not an Agent
.Source§fn delegator_balance(
delegator: Delegator<<Pallet<T> as DelegationInterface>::AccountId>,
) -> Option<<Pallet<T> as DelegationInterface>::Balance>
fn delegator_balance( delegator: Delegator<<Pallet<T> as DelegationInterface>::AccountId>, ) -> Option<<Pallet<T> as DelegationInterface>::Balance>
None
if not a Delegator
.Source§fn delegator_slash(
agent: Agent<<Pallet<T> as DelegationInterface>::AccountId>,
delegator: Delegator<<Pallet<T> as DelegationInterface>::AccountId>,
value: <Pallet<T> as DelegationInterface>::Balance,
maybe_reporter: Option<<Pallet<T> as DelegationInterface>::AccountId>,
) -> Result<(), DispatchError>
fn delegator_slash( agent: Agent<<Pallet<T> as DelegationInterface>::AccountId>, delegator: Delegator<<Pallet<T> as DelegationInterface>::AccountId>, value: <Pallet<T> as DelegationInterface>::Balance, maybe_reporter: Option<<Pallet<T> as DelegationInterface>::AccountId>, ) -> Result<(), DispatchError>
Source§impl<T> DelegationMigrator for Pallet<T>where
T: Config,
impl<T> DelegationMigrator for Pallet<T>where
T: Config,
Source§fn force_kill_agent(agent: Agent<<Pallet<T> as DelegationMigrator>::AccountId>)
fn force_kill_agent(agent: Agent<<Pallet<T> as DelegationMigrator>::AccountId>)
Only used for testing.
Source§type Balance = <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance
type Balance = <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance
Source§fn migrate_nominator_to_agent(
agent: Agent<<Pallet<T> as DelegationMigrator>::AccountId>,
reward_account: &<Pallet<T> as DelegationMigrator>::AccountId,
) -> Result<(), DispatchError>
fn migrate_nominator_to_agent( agent: Agent<<Pallet<T> as DelegationMigrator>::AccountId>, reward_account: &<Pallet<T> as DelegationMigrator>::AccountId, ) -> Result<(), DispatchError>
Source§fn migrate_delegation(
agent: Agent<<Pallet<T> as DelegationMigrator>::AccountId>,
delegator: Delegator<<Pallet<T> as DelegationMigrator>::AccountId>,
value: <Pallet<T> as DelegationMigrator>::Balance,
) -> Result<(), DispatchError>
fn migrate_delegation( agent: Agent<<Pallet<T> as DelegationMigrator>::AccountId>, delegator: Delegator<<Pallet<T> as DelegationMigrator>::AccountId>, value: <Pallet<T> as DelegationMigrator>::Balance, ) -> Result<(), DispatchError>
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 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§fn integrity_test()
fn integrity_test()
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(
who: &<T as Config>::AccountId,
_slashed_active: <<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>,
slashed_total: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance,
)
fn on_slash( who: &<T as Config>::AccountId, _slashed_active: <<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>, slashed_total: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance, )
Source§fn on_withdraw(
stash: &<T as Config>::AccountId,
amount: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance,
)
fn on_withdraw( stash: &<T as Config>::AccountId, amount: <<T as Config>::Currency as Inspect<<T as Config>::AccountId>>::Balance, )
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.