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

Allow Owner To Update Token Reward Value #1

Open
slavakurilyak opened this issue Mar 29, 2022 · 2 comments
Open

Allow Owner To Update Token Reward Value #1

slavakurilyak opened this issue Mar 29, 2022 · 2 comments

Comments

@slavakurilyak
Copy link

As an admin of the staking system (aka owner of contracts), I want to update the token reward using the onlyOwner function so that I can change incentive at any time and incentivize early users differently from later-stage users.

@net2devcrypto
Copy link
Owner

Im coding a struct to create vaults in the smartcontract. This will include a vault update feature that will allow the reward math to be updated. Stay tuned.

@WiseBigDan721
Copy link

WiseBigDan721 commented May 24, 2022

Proposed Solution

As it's been a while since @slavakurilyak asked this question, I thought I would add the code here in case anyone wishes to add this function themselves.

@net2devcrypto you may have a better way of implementing this however I thought this would be the simplest and easiest.

You will require a new global variable underneath the totalStaked variable:

uint256 public tokenRewards = 100000;

Change the following within the _claim and earningInfo functions:

rewardmath = 100000 ether * (block.timestamp - stakedAt) / 86400;

to

rewardmath = (tokenRewards * 1e18) * (block.timestamp - stakedAt) / 86400;

Finally, add a new function underneath the tokensOfOwner function:

function setTokenRewards(uint256 _tokenRewards) public onlyOwner {
  tokenRewards = _tokenRewards;
}

The above will allow the owner of the contract to update the token rewards whenever they require.

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

No branches or pull requests

3 participants