Skip to content

Conversation

0xdewy
Copy link
Contributor

@0xdewy 0xdewy commented Oct 4, 2022

Context

Closes #388 To align the naming between start/end, when expiring buckets and tranches.

Changes proposed in this pull request

This PR renames bucketStartTime to bucketEndTime to match the tranche expiry.

Test plan

Just a semantic change, no tests were added.

Checklist

  • Rebased the base branch
  • Attached corresponding Github issue
  • Prefixed the name with the type of change (i.e. feat, chore, test)
  • Performed a self-review of my own code
  • Followed the style guidelines of this project
  • Made corresponding changes to the documentation
  • Didn't generate new warnings
  • Didn't generate failures on existing tests
  • Added tests that prove my fix is effective or that my feature works

Review

When reviewing a PR, please indicate intention in comments using the following emojis:

  • 🍰 = Nice to have but not essential.
  • 💡 = Suggestion or a comment based on personal opinion
  • 🔨 = I believe this should be changed.
  • 🤔 = I don’t understand something, do you mind giving me more context?
  • 🚀 = Feedback

@0xdewy 0xdewy changed the title Rename bucketStartTime to bucketEndTime Chore/Rename bucketStartTime to bucketEndTime Oct 4, 2022
Copy link
Contributor

@shark0der shark0der left a comment

Choose a reason for hiding this comment

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

The first bucket and the first tranche (ie bucket id and tranche id = 0) start at zero unix time.

When you deposit to the tranche zero, your deposit is locked while the tranche is active. The tranche zero starts at trancheStartTime = trancheId * TRANCHE_DURATION = 0 and expires at trancheEndTime = (trancheId + 1) * TRANCHE_DURATION = TRANCHE_DURATION. That's why we're using trancheEndTime in our code, not start time.

For the buckets, let's say that current unix time = 0. Say someone buys a cover for a period equal to exactly one bucket. We increase the current reward per second and write down that we should decrease the reward per second at a particular time in the future. That particular time is when the bucket id = 1 starts. For this reason we're using bucketStartTime = bucketId * BUCKET_DURATION.

So technically just renaming bucketStartTime to bucketEndTime is incorrect, because that's not what it represents. If we want to use bucketEndTime, we will need to reflect this change in the code as well, and use bucketEndTime = bucketId * BUCKET_DURATION where bucketId will be the expiring bucket id BUT ALSO on each cover buy store the reward amount to be reduced in the last bucket that the cover will be active, instead of the first bucket where the cover is expired.

@shark0der shark0der force-pushed the chore/rename-bucket-tranche-expiry branch from 8e1f4db to 51cf9c6 Compare October 5, 2022 14:12
@0xdewy 0xdewy closed this Oct 5, 2022
@shark0der shark0der deleted the chore/rename-bucket-tranche-expiry branch October 6, 2022 18:51
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.

3 participants