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

MerkleLockup for LockupTranched #297

Merged
merged 21 commits into from
Mar 11, 2024
Merged

Conversation

andreivladbrg
Copy link
Member

@andreivladbrg andreivladbrg commented Mar 5, 2024

Closes #273

Simillar to Lockup Dynamic, but we store in the MerkleLockupLT contract an array of structs with percetanges and durations (how Razvan suggested here).

 struct TrancheWithPercentage {
     UD2x18 amountPercentage; // 1e18 = 100%
     uint40 duration;
 }
 MerkleLockupLT.TrancheWithPercentage[] internal _tranchesWithPercentages;

I used UD2x18 instead of UD60x18 to be more gas efficient. The sum of these percentages must be equal to 100%

There is no change in the claim function parameters between linear and tranched. Thus, the Merkle tree would be the same.

feat: add createMerkleLockupLT in SablierV2MerkleLockupFactory contract
docs: add requirements in createMerkleLockupLT natspec
chore: improve wording in explanatory comments
test: add Merkle Lockup LT integration tests
test: add fork tests for Merkle Lockup LT
andreivladbrg and others added 4 commits March 6, 2024 01:06
test: use pragma >=0.8.22
test: createMerkleLockupLT in factory
test: update Precompiles bytecode
test: getTranchesWithPercentages function
test: update Precompiles bytecode
refactor: use maxCount in DeployProtocol script
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.

Reviewed src. Made a PR to arrange imports alphabetically.

src/types/DataTypes.sol Outdated Show resolved Hide resolved
src/SablierV2MerkleLockupFactory.sol Show resolved Hide resolved
src/SablierV2MerkleLockupLT.sol Outdated Show resolved Hide resolved
test/utils/Assertions.sol Outdated Show resolved Hide resolved
src/SablierV2MerkleLockupFactory.sol Show resolved Hide 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.

I have reviewed the PR. Left my comments below.

I think we should find a new name for tranches percentages. tranchesWithPercentages does not look apt to me.

@smol-ninja
Copy link
Member

smol-ninja commented Mar 7, 2024

Also, MerkleLockupLT fork tests are failing at assertEq(vars.actualStream, vars.expectedStream);. The tranche amounts mismatch.

@andreivladbrg
Copy link
Member Author

andreivladbrg commented Mar 7, 2024

I think we should find a new name for tranches percentages. tranchesWithPercentages does not look apt to me

I agree that the name is not the best, but I couldn't find something better. Do you have other suggestions?

Also, should we not use plural?

build: bump core
test: dry-fy fork tests
test: remove protocol fee tests in claim
test: add headers in MerkleLockup
test: emit the correct element in the assertEq
test:
chore: improve explanatory comments
test: fix fork test for MerkleLockupLT
@andreivladbrg
Copy link
Member Author

@smol-ninja addressed all the feedback, lmk if it looks good.

for some reason the ci passes, still not sure why

@smol-ninja
Copy link
Member

Every time there is a new commit in v2-core#staging, the bun lockfile needs to be updated to fetch the latest commit. Without which, ci fails. Not sure why this behaviour though.

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.

Looks good to me except the following comments:

Also, should we not use plural?

I thought about it. My view is that using a plural for the variable name makes more sense. Struct TrancheWithPercentage represents single tranche while tranchesWithPercentages represents a set of tranche. So I am good with using plural in this context. However I have the following suggestions:

  1. Because it leads to longer names, how about we use synonym of percentage which is Pct - see Cambridge definition? That will change tranchesWithPercentages to tranchesWithPct. I know it might not be super clear compared to the original name, but curious to know what your think about it.

For example,

  • actualTranchesWithPercentages becomes actualTranchesWithPct.
  • MerkleLockupLT.TrancheWithPercentage[] tranchesWithPercentages becomes MerkleLockupLT.TrancheWithPct[] tranchesWithPct.
  • SablierV2MerkleLockupFactory_PercentageSumNotEqualOneHundred becomes SablierV2MerkleLockupFactory_TotalPctNotEqual100
  1. And instead of amountsSum and PercentagesSum, how about totalAmount and totalPercentage / totalPct? But If double s doesn't look weird to you, feel free to ignore this and such comments.

Please review this commit: 6ad73ed

src/SablierV2MerkleLockupFactory.sol Outdated Show resolved Hide resolved
src/SablierV2MerkleLockupLT.sol Outdated Show resolved Hide resolved
src/SablierV2MerkleLockupLT.sol Show resolved Hide resolved
src/libraries/Errors.sol Outdated Show resolved Hide resolved
test: remove protocol feee branch from claim.tree
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.

LGTM except minor refactors in createMerkleLockupLT.t.sol and createMerkleLockupLT.tree.

@andreivladbrg
Copy link
Member Author

My view is that using a plural for the variable name makes more sense. Struct TrancheWithPercentage represents single tranche while tranchesWithPercentages represents a set of tranche.

My reasoning was the same.

Because it leads to longer names, how about we use synonym of percentage which is Pct - see Cambridge definition? That will change tranchesWithPercentages to tranchesWithPct. I know it might not be super clear compared to the original name, but curious to know what your think about it.

Interesting idea, but the name is not that long. Plus, the core structs have pretty much the same size (e.g., SegmentWithDuration).

Also, I discussed it with Paul, and he said that it is clearer with the long form (Pct might be confusing to some individuals who are not familiar with the term).

Please review this commit: 6ad73ed

It looks good, thanks

@andreivladbrg
Copy link
Member Author

LGTM except minor refactors in createMerkleLockupLT.t.sol and createMerkleLockupLT.tree.

forced push a commit, lmk if everything is alright, if yes, can you approve the PR?

test/integration/merkle-lockup/lt/claim/claim.t.sol Outdated Show resolved Hide resolved
test/integration/merkle-lockup/lt/claim/claim.t.sol Outdated Show resolved Hide resolved
test/integration/merkle-lockup/lt/claim/claim.t.sol Outdated Show resolved Hide resolved
src/SablierV2MerkleLockupLT.sol Outdated Show resolved Hide resolved
test/integration/merkle-lockup/lt/claim/claim.tree Outdated Show resolved Hide resolved
test/integration/merkle-lockup/lt/claim/claim.t.sol Outdated Show resolved Hide resolved
test/integration/merkle-lockup/lt/claim/claim.t.sol Outdated Show resolved Hide resolved
test/integration/merkle-lockup/lt/claim/claim.t.sol Outdated Show resolved Hide resolved
test/integration/merkle-lockup/lt/claim/claim.t.sol Outdated Show resolved Hide resolved
@andreivladbrg
Copy link
Member Author

thanks for the review @smol-ninja

i've pushed a commit now, lmk if it looks good

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.

LGTM except my last reply.

@andreivladbrg andreivladbrg merged commit 2282afc into staging Mar 11, 2024
5 of 7 checks passed
@smol-ninja smol-ninja deleted the feat/tranched-campaign branch March 11, 2024 12:25
@andreivladbrg andreivladbrg mentioned this pull request Jul 2, 2024
2 tasks
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