# Enabling governance participation for pool members ## Problem Statement When a staker directly stakes on pallet-staking, their funds are locked in their account and stakers can use their locked funds for participating in governance. For delegators in Nomination Pool, their funds are transferred to a pool account (pallet sub account) instead. This means they lose access to their locked funds and cannot use it for governance. We could fix this if NominationPool instead held funds in the user accounts itself and somehow conveyed to Staking Pallet that the pool account represents the locked amount of all its delegators. #### How Nomination Pools work currently: 1) transfer tokens from delegator to pool account, and 2) stake from pool account as a direct nominator. Tokens are locked in the pool account. ![image](https://github.com/paritytech/polkadot-sdk/assets/10196091/4ea23bb6-b9e9-45a2-bb4e-3322eba540c3) #### How we want it to work: 1) delegate fund from delegator to pool account with tokens locked in delegator account itself. 2) stake from pool account as if all delegated funds to pool account are its own. ![image](https://github.com/paritytech/polkadot-sdk/assets/10196091/c9cbca09-5783-427f-b8dd-5ba404f3fa1c) This is what we try to achieve with `pallet-delegated-staking`. It is a wrapper implementation on top of staking-pallet that adds a new primitive of `Delegation` to staking. ## Other design goals and challenges - Both nomination pool and staking are already big codebases and we want to minimise changes to each of this pallet to avoid adding regression. - Delegation based staking is configurable and runtimes can choose to enable or disable it. - Avoid greedy slashing of delegators of an `Agent` account to keep slashing event bounded. ## Pallet Delegation Staking ### Introducing Delegators and Agents Agents are accounts who receive delegation from other accounts (delegators) and stakes on behalf of them. The funds are held in delegator accounts. ![6-delegatee](https://hackmd.io/_uploads/rkZsy-O1R.svg) ## Nomination Pools Extracts out all pool specific staking interaction into a new trait `StakeStrategy` and implements two strategies: - Transfer and Stake: Same as current. - Delegate and Stake: Uses the new primitives introduced by `DelegationStakeInterface`. ![9-stake-adapter](https://hackmd.io/_uploads/Hya0GbdkR.svg) ### Migration of existing pools There are migration functions exposed by `pallet-delegated-staking` to convert a `Nominator` into an `Agent` and a way for old Pool members to migrate their funds and be locked in their own accounts. Following are the steps of how an existing nomination pool would migrate to `DelegateStake` strategy. 1) Initial state of pool account ![image](https://github.com/paritytech/polkadot-sdk/assets/10196091/d98f7a81-96fb-477a-8fd5-fa242d24ece8) 2) Migrate pool account into an agent account For this step, we create a `proxy_delegator` account that is a keyless account derived using the actual pool account by `pallet-delegated-staking`. All funds are moved to this account and delegated to pool account. Pool account is now an `Agent`. ![image](https://github.com/paritytech/polkadot-sdk/assets/10196091/9d3b5cfe-1d67-4ac0-8587-eec57a5bbce1) 3) Delegator migrates their fund as DelegateStake Step 1 and 2 needs to be done in a single migration. This step can be done async, one delegator at a time permissionlessly. Each nominator can migrate their funds from proxy delegator to their own account. ![image](https://github.com/paritytech/polkadot-sdk/assets/10196091/11d2faa6-5fb1-4b7f-a94f-f3b649928ec5) 4) Once all funds are migrated When all delegators to a pool have migrated their funds, `proxy_delegator` account is dusted. ![image](https://github.com/paritytech/polkadot-sdk/assets/10196091/03597ad9-ffc1-4b07-adc1-58941138efdd)