-
Notifications
You must be signed in to change notification settings - Fork 2
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
Refactor/cancel to pause #113
Conversation
refactor: don't refund in pause function feat: keep track of debt after pausing
93717e1
to
621ff8c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for this PR @andreivladbrg. I have reviewed it and left my comments. I will re-review it later after those comments have been addressed.
Note: the coverage has gone down.
refactor: remove pauseMultiple function
This comment was marked as resolved.
This comment was marked as resolved.
670bdf4
to
aef3c12
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More comments below on invariants.
…Of function test: be more precise for caller test branches test: remove unneeded test for pause function docs: correct invariants
@smol-ninja there is only one thing left: #113 (comment) since it is only about a in rest, i've addressed all the feedback in my commits, please lmk if it looks good |
Thanks for the long discussion @andreivladbrg. Feel free to merge this PR now. |
Related issues
cancel
overpause
function #85.remainingAmount
#91Credits to @smol-ninja for coming with this idea of carrying the debt after pausing. (and thanks for explaining on slack)
Changes
This PR renames
cancel
topause
and removes the refund from this function - similarly to create/deposit, now refund and pause are distinct operations.The remaining amount is now summed only by streamed amount, in
_pause
and_adjustRatePerSecond
functions. And it is subtracted in_withdraw
if there is debt, and if it is not it set to 0.The biggest change is in how the withdrawable amount is calculated. Since now the remaining amount can be greater than the balance, each case of the debt must be handled within it. We have to mentain the invariant (balance > withdrawable) - also see the diagrams below
Diagrams
State diagram
Calculation diagram