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: depletionTimeOf calculation #317

Merged
merged 7 commits into from
Oct 18, 2024
Merged

fix: depletionTimeOf calculation #317

merged 7 commits into from
Oct 18, 2024

Conversation

smol-ninja
Copy link
Member

@smol-ninja smol-ninja commented Oct 17, 2024

There was a small discrepancy between the definition of "depletion timestamp" and its implementation.

Depletion time is defined as the UNIX timestamp at which the total debt exceeds stream balance by 1 wei. That is, at depletion time, $\text{total debt} = \text{stream balance} + 1$. This also means that at depletion time, $\text{uncovered debt} = 1$. At depletion time, the streamed accrues 1 wei of uncovered debt. Therefore, this PR closes the gap between the definition and the implementation.

Therefore, consider the following cases and the expected results:

Changelog

  • Adds clarity to the definition of depletionTimeOf function
  • Adds + 1 to the returned value of depletionTimeOf if division is not exact
  • Compare values 1 second before, at, and 1 second after depletion timestamp in fuzz tests

@smol-ninja
Copy link
Member Author

RustyRabbit has given a green signal. @PaulRBerg if you can have a quick look and approve, I can merge and prepare it for Codehawk. Thank you.

Copy link
Member

@PaulRBerg PaulRBerg left a comment

Choose a reason for hiding this comment

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

LGTM, let's just add an explanatory comment in which we define MVT

@smol-ninja smol-ninja merged commit 6101d4c into main Oct 18, 2024
7 checks passed
@smol-ninja smol-ninja deleted the fix/depletionTimeOf branch October 18, 2024 11:22
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