-
Notifications
You must be signed in to change notification settings - Fork 15
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
Reward calculation issue when the same player update in a row #16
Comments
It seems that this happens also when a user update twice, not just in a row. So it doesn't need to be twice in a row. I'll try looking at it further if you won't fix it by the time I'm able to. |
OK, I was too curious and continued to look at it 🙂 I believe the problem is that the code doesn't take into account that for example in this scenario:
Of the reward that was added in the last step, part of it belongs to Alice because of her first deposit. We are neglecting that part when we set the rewardDebt at the end. To fix, we need to calculate how much reward Alice earned from her new reward -
(Note that at this point And then substract it from rewardDebt so the user can claim it.
Perhaps more testing is needed, but this fixes the issue based on a quick test that I did. |
And if you don't want that Alice's second update will reward Alice's contribution from first update, I believe this is the change that is needed: Update
After updating the increase of shares reward and calculating how much of it belongs to the updating user, we use
And we keep rewardDebt the same - so it already takes
|
Oh Alice's second update should reward Alice's first update. I just tried to prevent rewarding from the current update. For example,
Assumption: All event increases the player's contribution by 1 (1 pixel update) |
Alright, cool. So this first fix that I suggested will fix it. I have created test script for the scenario you just described. [Note: there's some repetition in the test, maybe you'd like to extract some of it to a different function to remove the repetition. |
Thank you so much for your help on this issue @assafom 👍🏻 It looks fine now, but please let me know if there's more edge cases you can think of. |
When the same user updates the pixels twice, the reward doesn't get accumulated.
The text was updated successfully, but these errors were encountered: