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

Generic contract for rewards distribution logic #228

Open
GoldenSylph opened this issue Mar 9, 2022 · 1 comment
Open

Generic contract for rewards distribution logic #228

GoldenSylph opened this issue Mar 9, 2022 · 1 comment
Assignees

Comments

@GoldenSylph
Copy link
Contributor

GoldenSylph commented Mar 9, 2022

  • create a generic StakingRewardsPerEpoch contract (vs the standard StakingRewardsPerBlock)
  • Use baseshare field the synthetix as baseline. the baseshare field has a "multiplier" feature, that we dont need.
  • All rewards contracts follow a similar structure
    • when user performs an action like stake/withdraw his state + global accumulated rewards is updated.
    • in our case, since rewards are not per block, plus they are not in the original staking token, the global accumulator needs to be updated once collectUBI is called and fuse are swapped to G$
  • Because a user might stake just before collectUBI is called, in this case he would get a "free launch" of the rewards accumulated between the two last calls of collectUBI. So we need a little bit more complication
    • when user stake we
      • add the amount to "pendingStakes"
      • we mark that user staked after collectUBI event #X
    • when collectUBI is called
      • we distribute the rewards per share (synthetix rewardPerToken())
      • we then increase number of shares by "pendingStakes" (synthetix totalySupply+pendingStakes)
      • and update an array rewardsPerTokenAt[X+1] with the global rewards (instead of currently it is a single variable)
    • when user does any action - withdraw/stake, we use rewardsPerTokenAt[X+1] as his baseline. so if user staked at time Ti and withdraw at time Tj he is entitled to rewardsPerTokenAt[Tj] - rewardsPerTokenAt[Ti+1] (synthetix earned())
@GoldenSylph
Copy link
Contributor Author

GoldenSylph commented Mar 9, 2022

  • Make a struct that will contains BPSs and receivers of the part of the users reward.
  • Make a setter that only be called by a role Guardian.
  • Store in an array of the structs the info about distribution. (basically just create field)
  • Each time user will withdraw its reward iterate over the array and make all necessary sends, and at the end send the stakers part.

Warning: the DAO part must be one instance of the struct (except UBI and community pool, they must be independent instances) stored in the array.

@sirpy sirpy changed the title Make a reward distribution mechanism in function that sends the users reward on his demand FuseStaking rewards distribution logic Mar 17, 2022
@sirpy sirpy changed the title FuseStaking rewards distribution logic Generic contract for rewards distribution logic Mar 30, 2022
@GoldenSylph GoldenSylph linked a pull request Mar 30, 2022 that will close this issue
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 a pull request may close this issue.

1 participant