v2-core icon indicating copy to clipboard operation
v2-core copied to clipboard

Replace `createWithDurations` with `createWithTimestamps` in claim function

Open smol-ninja opened this issue 7 months ago • 0 comments

Refer to discussion https://github.com/sablier-labs/v2-core/discussions/997 for historical context.

Tasks

SablierV2MerkleLL.sol

  • [ ] Replace createWithDurations with createWithTimestamps under claim function
  • [ ] Define a struct in a new MerkleLL library:
struct Schedule {
    uint40 startTime;
    uint40 cliffDuration;
    uint40 endDuration;
}
  • [ ] Use it to calculate LockupLinear.Timestamps as the following:
if (MerkleLockup.Schedule.startTime == 0) {
    LockupLinear.Timestamps.start = block.timestamp;
} else {
    LockupLinear.Timestamps.start = Schedule.startTime;
}
LockupLinear.Timestamps.cliff = LockupLinear.Timestamps.start + Schedule.cliffDuration;
LockupLinear.Timestamps.end = LockupLinear.Timestamps.start + Schedule.endDuration;

SablierV2MerkleLT.sol

  • [ ] Replace createWithDurations with createWithTimestamps under claim function
  • [ ] Define a new variable called startTime in SablierV2MerkleLT.sol. This plays the same role as startTime above.
if (startTime == 0) {
    CreateWithTimestamps.startTime = block.timestamp;
} else {
    CreateWithTimestamps.startTime = startTime;
}
  • [ ] Construct LockupTranched.Tranche as the following:
LockupTranched.Tranche.amount = f(MerkleLT.TrancheWithPercentage.unlockPercentage); // Calculations same as current
LockupTranched.Tranche.timestamp = startTime + MerkleLT.TrancheWithPercentage.duration // recursively

smol-ninja avatar Jul 24 '24 15:07 smol-ninja