-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New staking v3 dev #429
base: pushContracts-v3.0-dev
Are you sure you want to change the base?
New staking v3 dev #429
Conversation
Tests/staking v3
tests: Added decreaseWalletShares test cases
Test/add claim tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Staking Moves out of Push Core V3, then a lot of staking-specific state variables in v3 will be UNUSED
The current CoreStorage file doesn't mark it accordingly. should be done for doc purposes. @Zartaj0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Arrange state variables based on their category.
For instance
- All token holder specific staking variable should be grouped together
- Wallet Holder Staking variables should be grouped together.
makes it readable.
event Staked(address indexed user, uint256 indexed amountStaked); | ||
event Unstaked(address indexed user, uint256 indexed amountUnstaked); | ||
event RewardsHarvested(address indexed user, uint256 indexed rewardAmount, uint256 fromEpoch, uint256 tillEpoch); | ||
event NewSharesIssued(address indexed Wallet, uint256 indexed Shares); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove upper-case in event argument to make it follow the standard coding-style overall. @Zartaj0
* 1. removes the shares from a wallet completely | ||
* 2. Can be called by governance. | ||
* 3. Updates WALLET_TOTAL_SHARES | ||
* 4. Emits out an event. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Natspec Suggestions:
- Remove serial number before every comment unless indicating options/types
- Replace all CamelCase with low camel case - TotalShare becomes totalShare ( following coding style of the project)
- Replace "Emits out an event" with Emits EVENT_NAME.
* 1. Internal helper function | ||
* 2. helps in getting the shares to be assigned for a wallet based on params passed in this function | ||
*/ | ||
function getSharesAmount( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emit SharesRemoved(_walletAddress, sharesToBeRemoved); | ||
} | ||
|
||
function decreaseWalletShare( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Important:
- Decrement of Wallet Share should follow the procedure mentioned in this doc - https://www.notion.so/pushprotocol/On-Removal-Decrement-of-Wallet-Shares-12f188aea7f480b0b505f8c6d506b347
- Ideally all relinquished shares should just go to foundation and no change in share percentage should occur in existing wallets. @0xNilesh @Zartaj0
rewards = rewards + claimableReward; | ||
} | ||
|
||
usersRewardsClaimed[msg.sender] = usersRewardsClaimed[msg.sender] + rewards; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Medium Issue:
- The contract uses the same mapping ( usersRewardsClaimed ) for updating the claimed rewards for both Token Holder and Wallet Holder.
- It is possible that 0xABC is a Wallet Address assigned by the governance to addShares() but then 0xABC also becomes a staker as it holds the token.
- In such a case, the usersRewardsClaimed mapping holds rewards from two different incentive-sources and different reward criteras, which isn't ideal
- Note: The only reason this is medium or low for now is coz the usersRewardsClaimed is not used for any other logic other than just read-only purpose. If in future upgrades, this map plays a role in some logic or validation, it becomes critical.
* 4. Emits out an event. | ||
*/ | ||
|
||
function removeWalletShare(address _walletAddress) public onlyGovernance { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ToDo:
- Add a check that governance cannot remove a wallet from the system before at least 1 epoch ends.
- Although this is rare scenario, an added layer ensures this is always followed. similar to token holder staking.
/ epochToTotalShares[_epochId]; | ||
} | ||
|
||
function claimShareRewards() external returns (uint256 rewards) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.