Skip to content
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

Draft
wants to merge 47 commits into
base: pushContracts-v3.0-dev
Choose a base branch
from
Draft

Conversation

Zartaj0
Copy link
Member

@Zartaj0 Zartaj0 commented Sep 30, 2024

No description provided.

Copy link
Collaborator

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

Copy link
Collaborator

@zaryab2000 zaryab2000 Oct 29, 2024

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);
Copy link
Collaborator

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.
Copy link
Collaborator

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(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should getSharesAmount() be public or internal ? @Zartaj0 @0xNilesh

emit SharesRemoved(_walletAddress, sharesToBeRemoved);
}

function decreaseWalletShare(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important:

rewards = rewards + claimableReward;
}

usersRewardsClaimed[msg.sender] = usersRewardsClaimed[msg.sender] + rewards;
Copy link
Collaborator

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 {
Copy link
Collaborator

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical To-Do:

  • As previously discussed, let's ensure a wallet cannot claim or get rewards for the same epoch when they were added.
  • Instead, if a Wallet is added at Epoch N, then the reward eligibility starts from Epoch N+1. @0xNilesh @Zartaj0

@Zartaj0 Zartaj0 mentioned this pull request Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

😈 [Feature Enhancement] - <Combine reward claiming mechanism for Wallet Fee Share and token holders>
3 participants