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

Estimate multiplier points per epoch to account for MP inconsistencies #48

Open
0x-r4bbit opened this issue Feb 12, 2024 · 3 comments
Open
Assignees
Labels
priority: high type: bug Something isn't working
Milestone

Comments

@0x-r4bbit
Copy link
Collaborator

Contents copied from: https://notes.status.im/lNd8kcVmQEWcDYEldpl26Q

On StakeManager, accounts need to be processed every epoch.

When an account is processed, it gets Multiplier Points.
An account can get Multiplier Points until it reaches a BOOST_LIMIT.
BOOST_LIMIT is _stake * MAX_BOOST

The increase on each account MPs also incrases the total supply of MPs.

To distribute rewards, the formula uses total supply of MPs:
((userBalance + userMultipliers) / (epochTotalBalance + epochTotalMultipliers)) * epochReward

The increase on MPs impact how epochReward is calculated, as for every account processed, the next epoch would have more MPs.

Additionally, the total MPs gets inconstient for future epochs, in a scenario where many accounts didnt processed, it could happen that a past epoch have more MPs than the epoch after it, it would be possible to hard to do in current architecture.

The best solution would be to be able to predict how much MPs would be minted by the end of the epoch.

  1. Estimate total MPs generated on epoch, based on total accounts * total staked - stake-on-limit reached
    a) Work on formula which uses (balanceSupply - balanceOnCap ) * ((MP_APY / YEAR) * epochTimeSize) to predict and use it as epochTotalMultipliers.
    Add another storage balanceOnCap that is changed when account balance change, which reflects a value used to correct estimation
    balanceOnCap = "incremented when an account reaches CAP"
    Passes on the problem further as it would only know when account reaches CAP when is processed.
    b) use (balanceSupply ) * ((MP_APY / YEAR) * timeSinceEpoch0+EPOCH_SIZE) to predict and use it as epochTotalMultipliers.
    while each account is processed, correct the amount of totalMultipliers, when an account reaches the cap, reduce from epochSupply.
    Makes incentive to wait to process, as lastest account to process get more2.
  2. Change contract requirements:
    a) Require users to process all accounts before rewarding
    b) Require users to process all accounts before processing epoch
    c) Remove MAX_BOOST dynamic
    d) Similar to a), b), but instead penalize that dont process in time by not giving any MPs.
    e) give incentives to third-party process late accounts before deadline, needs a) or b).
    f) Late process would get MPs in latest epoch, but in past epochs it wont count for rewards.
@0x-r4bbit 0x-r4bbit added type: bug Something isn't working priority: high labels Feb 12, 2024
@0x-r4bbit 0x-r4bbit added this to the Staking - MVP milestone Feb 12, 2024
@0x-r4bbit
Copy link
Collaborator Author

@3esmit I've taken the contents of the document you've created (thanks for that btw!) and created this issue here so we can track its state accordingly.

I understand that this is quite a big task, especially considering that we'll need at least some unit/e2e tests that show satisfying scenarios.

We can break this down further if necessary.

@3esmit
Copy link
Collaborator

3esmit commented Feb 18, 2024

Depends on #51

I started doing the changes as I have in my mind, but then I had the issue #51 as a blocker.
This is needed because this changes will update this logic, and it also should be clear what changed. Currently it would be unclear what would be changed because its currently unclear what current behavior is, and if it was working, changing it could break it.

@0x-r4bbit
Copy link
Collaborator Author

Thanks for the update, will have a look at #51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants