|
|
|
@@ -38,13 +38,13 @@
|
|
|
|
|
//!
|
|
|
|
|
//! ## Goals
|
|
|
|
|
//!
|
|
|
|
|
//! Direct nomination on the Staking pezpallet does not scale well. Nominations pools were created to
|
|
|
|
|
//! address this by pooling delegator funds into one account and then staking it. This though had
|
|
|
|
|
//! Direct nomination on the Staking pezpallet does not scale well. Nominations pools were created
|
|
|
|
|
//! to address this by pooling delegator funds into one account and then staking it. This though had
|
|
|
|
|
//! a very critical limitation that the funds were moved from delegator account to pool account
|
|
|
|
|
//! and hence the delegator lost control over their funds for using it for other purposes such as
|
|
|
|
|
//! governance. This pezpallet aims to solve this by extending the staking pezpallet to support a new
|
|
|
|
|
//! primitive function: delegation of funds to an `agent` with the intent of staking. The agent can
|
|
|
|
|
//! then stake the delegated funds to [`Config::CoreStaking`] on behalf of the delegators.
|
|
|
|
|
//! governance. This pezpallet aims to solve this by extending the staking pezpallet to support a
|
|
|
|
|
//! new primitive function: delegation of funds to an `agent` with the intent of staking. The agent
|
|
|
|
|
//! can then stake the delegated funds to [`Config::CoreStaking`] on behalf of the delegators.
|
|
|
|
|
//!
|
|
|
|
|
//! ### Withdrawal Management
|
|
|
|
|
//! Agent unbonding does not regulate ordering of consequent withdrawal for delegators. This is upto
|
|
|
|
@@ -55,10 +55,10 @@
|
|
|
|
|
//! This pezpallet does not enforce any specific strategy for how rewards or slashes are applied. It
|
|
|
|
|
//! is upto the `agent` account to decide how to apply the rewards and slashes.
|
|
|
|
|
//!
|
|
|
|
|
//! This importantly allows clients of this pezpallet to build their own strategies for reward/slashes.
|
|
|
|
|
//! For example, an `agent` account can choose to first slash the reward pot before slashing the
|
|
|
|
|
//! delegators. Or part of the reward can go to an insurance fund that can be used to cover any
|
|
|
|
|
//! potential future slashes. The goal is to eventually allow foreign MultiLocations
|
|
|
|
|
//! This importantly allows clients of this pezpallet to build their own strategies for
|
|
|
|
|
//! reward/slashes. For example, an `agent` account can choose to first slash the reward pot before
|
|
|
|
|
//! slashing the delegators. Or part of the reward can go to an insurance fund that can be used to
|
|
|
|
|
//! cover any potential future slashes. The goal is to eventually allow foreign MultiLocations
|
|
|
|
|
//! (smart contracts or pallets on another chain) to build their own pooled staking solutions
|
|
|
|
|
//! similar to `NominationPools`.
|
|
|
|
|
|
|
|
|
@@ -78,8 +78,8 @@
|
|
|
|
|
//! One of the reasons why direct nominators on staking pezpallet cannot scale well is because all
|
|
|
|
|
//! nominators are slashed at the same time. This is expensive and needs to be bounded operation.
|
|
|
|
|
//!
|
|
|
|
|
//! This pezpallet implements a lazy slashing mechanism. Any slashes to the `agent` are posted in its
|
|
|
|
|
//! `AgentLedger` as a pending slash. Since the actual amount is held in the multiple
|
|
|
|
|
//! This pezpallet implements a lazy slashing mechanism. Any slashes to the `agent` are posted in
|
|
|
|
|
//! its `AgentLedger` as a pending slash. Since the actual amount is held in the multiple
|
|
|
|
|
//! `delegator` accounts, this pezpallet has no way to know how to apply slash. It is the `agent`'s
|
|
|
|
|
//! responsibility to apply slashes for each delegator, one at a time. Staking pezpallet ensures the
|
|
|
|
|
//! pending slash never exceeds staked amount and would freeze further withdraws until all pending
|
|
|
|
@@ -93,8 +93,8 @@
|
|
|
|
|
//!
|
|
|
|
|
//! ## Nomination Pool vs Delegation Staking
|
|
|
|
|
//! This pezpallet is not a replacement for Nomination Pool but adds a new primitive in addition to
|
|
|
|
|
//! staking pezpallet that can be used by Nomination Pool to support delegation based staking. It can
|
|
|
|
|
//! be thought of as an extension to the Staking Pezpallet in relation to Nomination Pools.
|
|
|
|
|
//! staking pezpallet that can be used by Nomination Pool to support delegation based staking. It
|
|
|
|
|
//! can be thought of as an extension to the Staking Pezpallet in relation to Nomination Pools.
|
|
|
|
|
//! Technically, these changes could be made in one of those pallets as well but that would have
|
|
|
|
|
//! meant significant refactoring and high chances of introducing a regression. With this approach,
|
|
|
|
|
//! we can keep the existing pallets with minimal changes and introduce a new pezpallet that can be
|
|
|
|
@@ -191,7 +191,8 @@ pub mod pezpallet {
|
|
|
|
|
pub trait Config: pezframe_system::Config {
|
|
|
|
|
/// The overarching event type.
|
|
|
|
|
#[allow(deprecated)]
|
|
|
|
|
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
|
|
|
|
type RuntimeEvent: From<Event<Self>>
|
|
|
|
|
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
|
|
|
|
|
|
|
|
|
/// Injected identifier for the pezpallet.
|
|
|
|
|
#[pezpallet::constant]
|
|
|
|
@@ -787,7 +788,8 @@ impl<T: Config> Pezpallet<T> {
|
|
|
|
|
ensure!(
|
|
|
|
|
matches!(
|
|
|
|
|
T::CoreStaking::status(&agent).expect("agent should be bonded"),
|
|
|
|
|
pezsp_staking::StakerStatus::Nominator(_) | pezsp_staking::StakerStatus::Idle
|
|
|
|
|
pezsp_staking::StakerStatus::Nominator(_) |
|
|
|
|
|
pezsp_staking::StakerStatus::Idle
|
|
|
|
|
),
|
|
|
|
|
"agent should be bonded and not validator"
|
|
|
|
|
);
|
|
|
|
|