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

Refactor/cancel to pause #113

Merged
merged 12 commits into from
May 24, 2024
Merged

Refactor/cancel to pause #113

merged 12 commits into from
May 24, 2024

Conversation

andreivladbrg
Copy link
Member

@andreivladbrg andreivladbrg commented May 22, 2024

Related issues

Credits 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 to pause 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

OE_state_diagram_correct

Calculation diagram

image

@andreivladbrg andreivladbrg requested a review from smol-ninja May 22, 2024 11:14
@smol-ninja smol-ninja force-pushed the refactor/cancel-to-pause branch from 93717e1 to 621ff8c Compare May 22, 2024 21:35
Copy link
Member

@smol-ninja smol-ninja left a 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.

src/types/DataTypes.sol Outdated Show resolved Hide resolved
src/SablierV2OpenEnded.sol Outdated Show resolved Hide resolved
src/SablierV2OpenEnded.sol Outdated Show resolved Hide resolved
src/SablierV2OpenEnded.sol Outdated Show resolved Hide resolved
src/SablierV2OpenEnded.sol Show resolved Hide resolved
src/SablierV2OpenEnded.sol Show resolved Hide resolved
src/SablierV2OpenEnded.sol Show resolved Hide resolved
test/integration/pause/pause.tree Outdated Show resolved Hide resolved
test/integration/pause/pause.tree Outdated Show resolved Hide resolved
test/invariant/OpenEnded.t.sol Show resolved Hide resolved
refactor: remove pauseMultiple function
@andreivladbrg

This comment was marked as resolved.

@andreivladbrg andreivladbrg force-pushed the refactor/cancel-to-pause branch from 670bdf4 to aef3c12 Compare May 23, 2024 14:44
@smol-ninja

This comment was marked as resolved.

@andreivladbrg

This comment was marked as resolved.

Copy link
Member

@smol-ninja smol-ninja left a 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.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
test/invariant/stores/OpenEndedStore.sol Outdated Show resolved Hide resolved
smol-ninja and others added 3 commits May 23, 2024 19:05
…Of function

test: be more precise for caller test branches
test: remove unneeded test for pause function
docs: correct invariants
@andreivladbrg
Copy link
Member Author

andreivladbrg commented May 23, 2024

@smol-ninja there is only one thing left: #113 (comment)

since it is only about a notice natspec, let's find a middle ground in this PR and not create a separe issue


in rest, i've addressed all the feedback in my commits, please lmk if it looks good

@smol-ninja
Copy link
Member

Thanks for the long discussion @andreivladbrg. Feel free to merge this PR now.

@andreivladbrg andreivladbrg merged commit ef8b7ce into main May 24, 2024
6 checks passed
@smol-ninja smol-ninja deleted the refactor/cancel-to-pause branch May 24, 2024 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants