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

Update vesting rounding #248

Merged
merged 4 commits into from
Oct 23, 2023
Merged

Update vesting rounding #248

merged 4 commits into from
Oct 23, 2023

Conversation

guibescos
Copy link
Contributor

@guibescos guibescos commented Oct 20, 2023

We were previously rounding down the amount vested, but that doesn't play well with the arithmetic for splitting accounts.

As seen in vesting_test.ts, it just changes some quantities by 10^(-6) tokens

@vercel
Copy link

vercel bot commented Oct 20, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 23, 2023 1:08pm
staking-devnet ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 23, 2023 1:08pm

// We round the unvested amount down, this makes the arithmetic for splitting accounts simpler.
let remaning_periods = num_periods.saturating_sub(periods_passed);

(((remaning_periods as u128) * (initial_balance as u128)) / (num_periods as u128))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remaining

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 this pull request may close these issues.

2 participants