What should we include in the Merkle tree leaf for Dynamic/Tranched campaigns #288
Replies: 7 comments 21 replies
-
Thanks, will review later.
We will very likely end up removing the fee as per the discussion in https://github.com/sablier-labs/company-discussions/discussions/2 |
Beta Was this translation helpful? Give feedback.
-
On first problemThere was an idea floated by @razgraf, see here, about storing a single set of segments globally for the whole dynamic campaign. A modified version of that idea can allow storing mapping(uint256 N => LockupDynamic.SegmentWithDuration[] segments) private allocationSegments; and then we can have the following design for the leaf bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(index, recipient, amount, N)))); In the future, if we come across a user who wants to define unique segments for each claim, we can then discuss an upgrade, however, I think in practice, it is a very unlikely scenario. For most cases, it should work. What's your opinion on this? |
Beta Was this translation helpful? Give feedback.
-
SegmentsSince the problem is different whether we're talking about LT or LD, I will provide a two-pronged response. MerkleLockupLTThis is easy. We can just apply Razvan's idea from here of storing a global array of percentages that would be used to dynamically generate the segments at claim time. MerkleLockupLDThis is difficult. LD is so general purpose that the only way to cater to all potential use cases is to include the segment data in the CSV array. However, as Mircea pointed out, that would significantly increase the costs of our web2 API (Pinata, etc.). I see two ways out of this:
I don't understand what you said here. Could you please restate this sentence, @andreivladbrg? I specifically don't understand why something that is part of the CSV would then have to be obtained when a claim is made. Also, @gavriliumircea, it would be helpful if you could join the conversation and respond to Andrei's question. Protocol FeeThe development cost is not worth it anymore, so please go ahead assuming that they will be removed. I will follow up in https://github.com/sablier-labs/company-discussions/discussions/2 now to persuade Max to let go. |
Beta Was this translation helpful? Give feedback.
-
MerkleLockupLT: I think we can move ahead with this MerkleLockupLD: The conversation revolved around creating a one-size-fits-all solution for LD support. Why don't we just assume the same as for LT and start with the same segments for everyone, only with different concrete amounts? Same idea you've referenced above from an old reply of mine. It would keep the CSV data mostly the same, and the implementation should be quite trivial. I've seen a few requests for MerkleLockupLD (not sure we tracked them all in #23, I have a feeling I've heard it at least 3 or 4 times from potential users) but I don't think I've seen a literal request for everyone having a different stream shape in the same campaign. While the "editions" idea is cool (we can optimize case-by-case with it), we'd have to get it audited every time and I'm not sure if it solves the problem of having to store each different segment in the CSV (even if we know the final shape will be an exponential for example). My proposal for now:
Note: MerkleLockupLT = MerkleLockupLockupTranched, a bit repretitive although I'd keep the "LT" abbreviation intact - why not MerkleLT? |
Beta Was this translation helpful? Give feedback.
-
Request for MLLD from a new user, Arcana. They want Unlock-Cliff which can only be supported by LD not by LT. |
Beta Was this translation helpful? Give feedback.
-
Should we close this, @andreivladbrg, @smol-ninja? |
Beta Was this translation helpful? Give feedback.
-
The current version implemented for Dynamic contract hashes all relevant information for a specific recipient:
v2-periphery/src/SablierV2MerkleLockupLD.sol
Lines 53 to 70 in b5e7199
@gavriliumircea mentioned that including the segments in the tree leaf would be time-consuming (when creating the campaign) and also expensive in terms of API calls, and he suggested including only the
(index, recipient, amount)
in the Merkle tree leaf. The.csv
would still include the segments, but they would be obtained when a claim is being made. (Mircea, correct me if I understood it wrong)The other problem1 is when the
protocol fee is > 0
, the amount in the claim function needs to be greater than the amount from the actual leaf amount. To address this, we either:treeLeafAmount
andcreateAmount
- this version would require the UI to calculate both amounts.claim
function by summing the segment amounts - this version would be more expensive in terms of gas.Curious about your opinions @PaulRBerg @razgraf @smol-ninja. How should the Merkle tree look for Dynamic and Tranched contracts? There are also other discussions regarding UX flow, but they can be open on other repos.
Footnotes
This is a problem because we have an invariant on the core that says the segment amounts sum must equal the deposited amount, and in the
create
function, we need to pass an amount equal to theleaf amount + the fee amount
. ↩Beta Was this translation helpful? Give feedback.
All reactions