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

payable_per_block suffers from integer division truncation #9

Closed
notlesh opened this issue May 20, 2021 · 2 comments · Fixed by #10
Closed

payable_per_block suffers from integer division truncation #9

notlesh opened this issue May 20, 2021 · 2 comments · Fixed by #10

Comments

@notlesh
Copy link
Contributor

notlesh commented May 20, 2021

The calculation for paying out a reward currently "rounds down" as a result of integer division. This result is then amplified by the number of blocks used to calculate how much should be paid over time, effectively dampening the payout rate.

The relevant code starts here.

As an extreme example, if payable_per_block were calculated as 2/3 (e.g. info.total_reward - first_paid == 2 and T::VestingPeriod::get() == 3), the result would be 0 (because floor(2/3) == 0). In this extreme case, no rewards would ever be paid out (as a result of lines 439/440).

The above is the case when (info.total_reward - first_paid) < T::VestingPeriod::get().

In less extreme examples (such as 11/10) the results would be that the payout rate is reduced, although the user would eventually be able to claim the entire balance (e.g. line 444).

@girazoki
Copy link
Contributor

Thanks, will work on a solution for this

@girazoki
Copy link
Contributor

#10 should solve it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants