-
Notifications
You must be signed in to change notification settings - Fork 8
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: implement airstreams with lockup dynamic #282
Conversation
33a85a0
to
2eb5a19
Compare
Let's add an |
Yeah. I agree with that. |
2eb5a19
to
4f34a57
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.
Great work, Shub!
I'll leave these comments for now (might find more things later), so we can keep things moving
src/SablierV2MerkleLockupLD.sol
Outdated
{ | ||
// Generate the Merkle tree leaf by hashing the corresponding parameters. Hashing twice prevents second | ||
// preimage attacks. | ||
bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(index, recipient, segments)))); |
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.
let's include amount
in the leaf
so that the leaf is the same as LL + segments. it would make things easier for merkle-api (i think)
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.
makes sense. I have changed it to
bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(index, recipient, amount, segments))));
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.
@andreivladbrg reopening this conversation because I disagree that we should include amount
in the leaf.
When the protocol fee is non-zero, constructing Merkle tree would require the UI to reverse calculate all the claim amounts to include the protocol fee.
Consider the below simple example
- Segments sum to 10,000 for each user.
- If protocol fee = 1%, UI would have to reverse calculate the amount as 10,000/0.9 = 11111 and include it in the Merkle tree.
- When a user claims, 11111*0.9 must match the segments sum otherwise claim would fail. Now because step 2 requires division in the UI, it is exposed to floating point errors leading to users not being able to claim (since we have strict equality
depositAmount != segmentAmountsSum
). This may require re-submitting the Merkle tree.
So it is safe to not include amount
in the Merkle leaf and let it be an input parameter into the claim function.
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.
you are correct
i will create a separate discussion regarding what to include in the Merkle tree because Mircea told me that there are some considerations we have to take into account
Great feedbacks @andreivladbrg and thank you for the review. |
632d533
to
b5e7199
Compare
Until we make a decision regarding this discussion, I suggest we put this PR on hold. |
1804e53
to
8276e73
Compare
b5e7199
to
d9fde9d
Compare
241b49c
to
536be9e
Compare
test: integration and fork tests for MerkleLockupLD refactor: add NatSpec format to events feat: include amount in claim function feat: include "amount" in LD leaf test: refine fork tests refactor: use "airstream campaign" terminology test: replace streamDurations with endTime in Vars struct
d9fde9d
to
5495217
Compare
I will fix the merge conflicts after we have made this decision. |
Closing it as discussed in #288. |
Closes #274.
Summary
event CreateMerkleLockupLD(merkleLockupLD, baseParams, lockupDynamic, ipfsCID, aggregateAmount, recipientsCount);
Security consideration
If protocol fee is not zero, claiming will fail.When protocol fee is non-zero,amount
inclaim()
must include the protocol fee.