From 9728073be9a8fc2b7f63b15ccecfce690b0aeb6b Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sun, 28 Jul 2024 04:49:51 +0800 Subject: [PATCH] DIP-7 (#21) * DIP-7 * Fill contract part * Typo * Update --------- Co-authored-by: echo --- DIPs/dip-1.md | 2 +- DIPs/dip-5.md | 4 +-- DIPs/dip-6.md | 2 +- DIPs/dip-7.md | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 DIPs/dip-7.md diff --git a/DIPs/dip-1.md b/DIPs/dip-1.md index d2763dc..6b27598 100644 --- a/DIPs/dip-1.md +++ b/DIPs/dip-1.md @@ -1,7 +1,7 @@ --- dip: 1 title: Staking Commission Specification -authors: Darwinia Network (@AurevoirXavier, @hujw77, @hackfisher, @xiaoch05) +authors: Darwinia Network (@AurevoirXavier, @hackfisher, @hujw77, @xiaoch05) discussions-to: https://github.com/orgs/darwinia-network/discussions/1238, https://github.com/orgs/darwinia-network/discussions/1272 status: Final type: Economic diff --git a/DIPs/dip-5.md b/DIPs/dip-5.md index be8370f..e8dae94 100644 --- a/DIPs/dip-5.md +++ b/DIPs/dip-5.md @@ -1,7 +1,7 @@ --- dip: 5 title: KTON Staking -authors: Darwinia Network (@AurevoirXavier, @hujw77, @hackfisher) +authors: Darwinia Network (@AurevoirXavier, @hackfisher, @hujw77) discussions-to: https://github.com/orgs/darwinia-network/discussions/1393 status: Final type: Economic @@ -63,7 +63,7 @@ These changes are designed to streamline the staking process and enhance their e These amendments aim to fortify the transparency and simplicity of the staking mechanism, ensuring that stakeholders can engage with the system with greater clarity and confidence. ### Additional -#### Migration strategy +#### Migration Strategy To ensure a smooth protocol update, we've implemented a migration curve. Our goal is to minimize any impact on the rights of current staking users as much as possible. Users have **1** month to transition from V1 to V2. diff --git a/DIPs/dip-6.md b/DIPs/dip-6.md index 7832e61..b2e6c3c 100644 --- a/DIPs/dip-6.md +++ b/DIPs/dip-6.md @@ -4,7 +4,7 @@ title: Flexible and Secure Staking System authors: Darwinia Network (@AurevoirXavier, @hackfisher) discussions-to: https://github.com/orgs/darwinia-network/discussions/1455 status: Final -type: Security +type: Economic created: 2024-04-10 --- diff --git a/DIPs/dip-7.md b/DIPs/dip-7.md new file mode 100644 index 0000000..360da30 --- /dev/null +++ b/DIPs/dip-7.md @@ -0,0 +1,74 @@ +--- +dip: 7 +title: EVM Staking +authors: Darwinia Network (@AurevoirXavier, @hackfisher, @hujw77) +discussions-to: https://github.com/orgs/darwinia-network/discussions/1481 +status: Final +type: Core +created: 2024-06-30 +--- + +# DIP-7 + +## Abstract +This proposal aims to migrate the original collator staking and deposit functionalities from pallets to EVM contracts. + +## Rationale +1. **Standardization**: Standardizing Collator Staking and Deposit ensures better compatibility with ERC20 and ERC721 standards. This integration will enhance our infrastructure and ecosystem interactions, making the system more accommodating to Liquidity Staking Tokens (LSTs). Additionally, it allows transforming deposits into NFTs, which can be transferred and traded in the NFT market. +2. **Governance**: As a prerequisite to the next-generation governance system, transitioning Collator Staking and Deposit to smart contracts will facilitate the adoption of standardized governance models like those provided by Tally/OpenZeppelin Governor contracts. This shift will make on-chain governance more intelligent and standardized. + +## Specification +- **RING Staking Contract**: Implement a RING staking contract where users can stake/unstake RING and nominate collators. + - Users can engage in staking/unstaking through this contract, which will issue an ERC20 token with the ERC20Votes extension upon staking. This token cannot be transferred but serves as the governance token of RingDAO. +- **Deposit Contract**: Implement a deposit contract that replicates the functionality of the original deposit pallet, converting deposits into ERC721 NFT tokens. Users can use this NFT for further staking/unstaking in the RING staking contract. + - The Deposit NFT can be transferred. +- **Governance Integration**: RING, Deposit NFTs, staked RING, and Deposit NFTs in the staking contract can participate in the governance of RingDAO. +- **Runtime**: Due to the limitations of the Polkadot-SDK framework, session rotation and reward distribution logic will still need to remain on the runtime pallet side. + +### Details +#### RING Staking Pallet +- Add a `RewardToRing` interface to transfer the runtime-minted/distributed reward to the contract. +- Add an `ElectionResultProvider` interface to receive the election result from the contract. + - Apply the election result to the session pallet. + - Handle zero addresses as described in the RING staking contract section. +- During the migration stage, rewards need to be distributed to both the runtime and the contract. + - Proper handling is required to distinguish whether the collator comes from the runtime or the contract. + +#### RING Staking Contract +- Provide a `createNominationPool()` interface for collators to create a nomination pool. + - Each collator can create only one pool to participate in staking. +- Provide `stake()` and `unstake()` interfaces for users to participate in staking and nominate a collator. + - Support RING and Deposit NFT. +- Provide a `claim()` interface for users to withdraw staking rewards. +- Provide a `collate()` interface for collators to change the commission. +- Provide a `distributeReward()` interface to distribute staking rewards to collators and nominators. + - Only the runtime can call this function. +- Provide a `getTopCollators(n)` interface for the runtime to query the top `n` collators based on stakers' votes. + - The election result will be yielded in `[H160; n]`. If `n` is greater than the actual collator count, the result will be padded with zero addresses, which the runtime needs to filter out. + +#### Deposit Contract +- Provide a `migrate()` interface for users to migrate deposits from the old deposit pallet to this contract. + - Only the runtime can call this function. +- Provide a `deposit()` interface for users to deposit RING with a specified duration. + - In return, users will receive a set number of KTONs as a reward. + - As a voucher, the user will receive a Deposit NFT. +- Provide a `claim()` interface for users to withdraw RING. + - If on time, the Deposit NFT will be burned. + - If prematurely, a penalty of 3x KTON is required. + +#### Governance Integration +- Implement an ERC20 token that includes the ERC20Votes extension. + - Grant `Minter Role` and `Burner Role` to the RING Staking Contract. + - Wrap RING and Deposit NFTs into this token. + - The token cannot be transferred. +- Create a flexible DAO using the Aragon DAO framework. + +### Additional +#### EVM Transaction Fee +Any call that needs to be dispatched inside the pallet to the EVM contract requires a transaction fee due to the Frontier framework limitation. To prevent the transaction fee from affecting the original pallet accounts' balance, the Treasury pallet account will be used as the EVM transaction sender. All fees will be paid by the Treasury as a system expenditure. + +#### Migration Strategy +To ensure a smooth protocol update, a migration curve has been implemented. Our goal is to minimize any impact on the rights of current staking users. Users have **2** months to transition from runtime staking to EVM staking. During this period, staking will operate in a hybrid mode. We will gradually decrease the runtime staker seats and increase the EVM staker seats following this curve. Over time, all stakers will be elected from the EVM side. + +## Copyright +Copyright and related rights waived via [CC0](../LICENSE).