Open sasurobert opened 1 week ago
📊 MultiversX Automated Test Report: View Report
🔄 Build Details:
bdaaf5593e9f9b3ab3edf5578d1b9973903a27a6
feat/delegation-impr-v3
rc/barnard
rc/barnard
mx-chain-testing-suite Target Branch: rc/barnard
🚀 Environment Variables:
14112024-083006
0
🎉 MultiversX CI/CD Workflow Complete!📊 MultiversX Automated Test Report: View Report
🔄 Build Details:
16d3ec34175ef6019d27f5a1fb251e9bdc434efe
feat/delegation-impr-v3
rc/barnard
rc/barnard
mx-chain-testing-suite Target Branch: rc/barnard
🚀 Environment Variables:
14112024-090703
0
🎉 MultiversX CI/CD Workflow Complete!
Reasoning behind the pull request
Delegation improvements after Staking Phase 4.0:
Proposed changes
Delegation Fixes after Staking Phase 4.0:
Delegation improvements after Staking Phase 4.0: MIP-18 - Migration feature for delegated EGLD to improve the efficiency of the dynamic validator market This is a feature request asked by a lot of community members and someone has written a proposal as well. The solution I propose is to enable users to move funds from one provider to another once per 30 days. changeStakingProvider@amount@sourceSCAddress@destinationSCAddress vmInput.Caller address is the delegator, it is the user address, or the SC address in case of liquid staking contracts or DAO. vmInput.RecipientAddress is the delegation manager contract, which will forward the call to the delegation contract the user wants to move his funds. sourceSCAddress and destinationSCAddress are verified to be a system delegation contract. removeDelegationFromSource@delegatorAddress@amount: does basic checks, can be called by delegation manager address only, and removes from the user the specified amount if the user has enough delegation there. The system checks what was the last time the delegator moved funds to this contract, by checking a new storage in which the epoch was saved. If epoch == 0 or epoch + 30 < currentEpoch we can go to the next step of moving. Rewards are calculated for the user and saved into claimable rewards (this code already exists and used when user delegates more), and the new amount of delegation is computed by subtracting the amount value. moveDelegationToDestination@delegatorAddress@amount: does basic checks, can be called by delegation manager address only, adds the stated amount to the user’s delegation. It creates new storage where the current epoch is saved, the user cannot changeProvider from this place for the next 30 days.He can always unStake and unBond. It will call the internal delegate function, compute rewards for the user if the user already had delegation, increase the delegation amount for the user New function in ValidatorSC is called which makes unStake and unBond in one call for the staking provider, actually the only thing it needs to do is to change the TotalStakedAmount from the staking provider, without adding it to the unStakedFunds. Unstaking of nodes is happening at the end of the epoch if the SP does not have enough funds (this process is the existing code - which works like this even now). moveStakeFromValidatorToValidator@stakeAmount@valiadtorA@validatorB - it can be called by system delegationContracts only. The caller is the delegation contract from which the funds are moved out. This function will also increase the TotalStakedAmount for validatorB. Nothing else to do. removeDelegationFromSource, moveDelegationToDestination and moveStakeFromValidatorToValidator are called synchronously. If one of them fails, no changes are made. Process finished.
Testing procedure
Pre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
feat
branch created?feat
branch merging, do all satellite projects have a proper tag insidego.mod
?