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

fix: lowest epoch calc #2018

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

fix: lowest epoch calc #2018

wants to merge 6 commits into from

Conversation

guibescos
Copy link
Contributor

@guibescos guibescos commented Oct 9, 2024

Until now lowest epoch calculation was wrong because it only took into account delegation records, but these don't exist if you have never claimed.
When the delegation record doesn't exist, you need to look at the activationEpoch of the positions to get a sense of the expiry date of the rewards.

Copy link

vercel bot commented Oct 9, 2024

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

Name Status Preview Comments Updated (UTC)
api-reference ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 9, 2024 6:32pm
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 9, 2024 6:32pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
proposals ⬜️ Ignored (Inspect) Visit Preview Oct 9, 2024 6:32pm

lowestEpoch === undefined ? undefined : epochToDate(lowestEpoch + 52n),
instructions.lowestEpoch === undefined
? undefined
: epochToDate(instructions.lowestEpoch + 53n),
Copy link
Contributor Author

@guibescos guibescos Oct 9, 2024

Choose a reason for hiding this comment

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

I think the 52 was wrong and should instead be 53, if my math isn't wrong.

@guibescos guibescos changed the title Fix/lowest epoch calc fix: lowest epoch calc Oct 9, 2024
Comment on lines +696 to +701
if (
lowestEpoch === undefined ||
position.activationEpoch < lowestEpoch
) {
lowestEpoch = position.activationEpoch;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use bigintMax here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we have to use bigintMin. It might be worth making it a funciton since it'll be used in 2 different places.

Comment on lines 773 to +776
return {
advanceDelegationRecordInstructions,
mergePositionsInstruction,
publishers,
lowestEpoch,
Copy link
Contributor

Choose a reason for hiding this comment

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

we have to refactor this function at some point, probably not worth doing rn.

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