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

Function "bondedTargetRewardUnlock" returns wrong values in the wrong range #10

Open
ghost opened this issue Jan 9, 2020 · 0 comments

Comments

@ghost
Copy link

ghost commented Jan 9, 2020

What's the issue?

You communicated that rewards are locked for either 6 months or until 80% of the network is staked. The bonded ratio starts at 80% and should decrease by 1% each week (so after e.g. 8 weeks it should be at ~72%).

Current Implementation

This function should return values from 80 down to 0. What it actually does is returning values from 100 down to 0.

function bondedTargetRewardUnlock() public view returns (uint256) {
  uint256 passedTime = block.timestamp.sub(unbondingStartDate());
  uint256 passedPercents = PERCENT_UNIT.mul(passedTime).div(unbondingPeriod()); // total duration from 0% to 100% is unbondingPeriod
  if (passedPercents > PERCENT_UNIT) {
    return 0;
  }
  return PERCENT_UNIT - passedPercents;
}

New implementation

So I'd suggest the following changes:

function bondedTargetStart() public pure returns (uint256) {
  return 80;
}

// ...

function bondedTargetRewardUnlock() public view returns (uint256) {
  uint256 passedTime = block.timestamp.sub(unbondingStartDate());
  uint256 passedPercents = PERCENT_UNIT.mul(passedTime).div(unbondingPeriod());
  if (passedPercents > bondedTargetStart()) {
    // Limit passed percents to bondedTargetStart() as this is the maximum value
    passedPercents = bondedTargetStart();
  }
  return bondedTargetStart() - passedPercents;
}
@ghost ghost changed the title bondedTargetRewardUnlock starts at 100% instead of 80% Rewards are not unlocked as communicated Jan 27, 2020
@ghost ghost changed the title Rewards are not unlocked as communicated "bondedTargetRewardUnlock" function returns wrong values in the wrong range Jan 27, 2020
@ghost ghost changed the title "bondedTargetRewardUnlock" function returns wrong values in the wrong range Function "bondedTargetRewardUnlock" returns wrong values in the wrong range Jan 27, 2020
@ghost ghost mentioned this issue Feb 18, 2020
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

0 participants