-
Notifications
You must be signed in to change notification settings - Fork 53
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
feat: add unlock amounts functionality #1075
Conversation
3e0cf63
to
9d7e555
Compare
@smol-ninja the PR is ready for your review, I have updated the OP with some useful comments, please get first through them before reviewing, |
b65cb8f
to
d4d8187
Compare
@smol-ninja just rebased from Note: the size of the contract is at its limit, adding new things to the contract would require us to decrease the optimizer runs.
|
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
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.
Nice work on the PR. Reviewed the src
and left my comments below.
151dbdd
to
57d7def
Compare
57d7def
to
8ca1274
Compare
d4d8187
to
d8865fd
Compare
8ca1274
to
9050f98
Compare
d8865fd
to
8e1364a
Compare
237cadb
to
e98d613
Compare
@smol-ninja I have addressed all the |
e98d613
to
290eb76
Compare
62d26a3
to
20e40ba
Compare
267b7fd
to
4b8a424
Compare
refactor: some polishes docs: update explanatory comments test: add new test branches in create function test: streamed amount in lockup linear test: fix common streamed amount tests test: remove unneeded branches build: update deps test: fix tranches default function feat: include unlock amounts in StreamLL docs: fix some comments test: improve fuzz streamed amount tests test: update fork with unlock amounts test: fix last failing tests docs: last polishes
4b8a424
to
5d48595
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.
Nice work on tests. Left my review below.
Also created a PR: #1088 about Schedule
struct that can be merged into this.
test/core/integration/concrete/lockup-linear/streamed-amount-of/streamedAmountOf.tree
Show resolved
Hide resolved
...re/integration/concrete/lockup-tranched/create-with-durations-lt/createWithDurationsLT.t.sol
Show resolved
Hide resolved
@@ -140,6 +140,7 @@ contract CreateWithTimestampsLT_Integration_Concrete_Test is CreateWithTimestamp | |||
whenStartTimeLessThanFirstTimestamp | |||
{ | |||
// Swap the tranche timestamps. | |||
// LockupTranched.Tranche[] memory tranches = defaults.tranches(); |
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.
This should be removed.
@@ -3,10 +3,7 @@ StreamedAmountOf_Lockup_Tranched_Integration_Concrete_Test | |||
├── given start time in present | |||
│ └── it should return zero | |||
└── given start time in past | |||
├── given end time not in future |
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.
Rationale behind removing them? Also, modifiers still exist in the corresponding test contracts.
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.
same reason as here
already tested in SETTLED
status branch
also re this #1075 (comment)
we should consider for SETTLED
this modifier for both now == end && now > end
:
modifier runBothCases() {
vm.warp({ newTimestamp: defaults.END_TIME() });
_;
vm.warp({ newTimestamp: defaults.END_TIME() + 1 });
_;
}
refactor: `Schedule` struct
7e1bad8
to
dfe17c3
Compare
test: add lockupCreateEvent in Defaults
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.
Approving the PR. There are still some unresolved comments regarding tests but since they are related to tests we can look into them later. The contract code looks good to me so given the audit date is near, feel free to merge it now.
Thanks, let's goo 🚀 |
* feat: add unlock amounts functionality refactor: some polishes docs: update explanatory comments test: add new test branches in create function test: streamed amount in lockup linear test: fix common streamed amount tests test: remove unneeded branches build: update deps test: fix tranches default function feat: include unlock amounts in StreamLL docs: fix some comments test: improve fuzz streamed amount tests test: update fork with unlock amounts test: fix last failing tests docs: last polishes * refactor: emit common parameters in Create event through Common struct * refactor: extend Schedule struct to have unlock amounts for Airstreams * test: remove redundant comment * refactor: rename Common struct to CreateEventCommon * refactor: pass timestamps in linear calculate function shub feedback * docs: add return natspec in _create test: add lockupCreateEvent in Defaults --------- Co-authored-by: smol-ninja <shubhamy2015@gmail.com>
Closes #1043 and #1067
Since we have the invariant:$\text{cliff time} = 0 \implies \text{cliff unlock amount} = 0$ , there are 6 possible scenarios in the
streamedAmountOf
function:Plot graphs with docs code
Scenario 5
Code to update the docs shapes with:
Scenario 6
Code to update the docs shapes with:
Note: Since the mathematical logic has changed in
SablierLockupLinear._calculateStreamedAmount
, in order to achieve the previous cliff linear shape, it is required to pass anunlockAmount.cliff > 0
; otherwise, the 5th scenario shape will be achieved. This is also the reason I needed to change the tests from warping toWARP_26_PERCENT
instead ofCLIFF_TIME,
as many tests were failing. The cliff amount has a remainder of 2534 due to a different "streamable" range.As you will see in the code, I am referring to the range that calculates the elapsed time as "streamable," which might be confusing since the entire function is called "streamed amount." However, we will eventually change this terminology to "vesting," so don’t mind the current terminology if you find it unclear.
Here's a diagram for visualizing the new function flow while reviewing.
New function flow