Skip to content

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.

@vercel
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 10, 2024 6:49pm
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 10, 2024 6:49pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
proposals ⬜️ Ignored (Inspect) Visit Preview Oct 10, 2024 6:49pm

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.

@guibescos guibescos merged commit 47d6535 into main Oct 10, 2024
4 of 6 checks passed
@guibescos guibescos deleted the fix/lowest-epoch-calc branch October 10, 2024 18:45
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