Skip to content

Commit

Permalink
feat: include stream duration in CreateMerkleLockupLT event (#309)
Browse files Browse the repository at this point in the history
* feat: include stream duration in CreateMerkleLockupLT event
feat: stop indexing ConstructorParams in CreateMerkleLockup events

* chore: update precompiles

* chore: capitalize comment
  • Loading branch information
smol-ninja authored Mar 31, 2024
1 parent a313183 commit 8683889
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 9 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion precompiles/Precompiles.sol

Large diffs are not rendered by default.

18 changes: 14 additions & 4 deletions src/SablierV2MerkleLockupFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,16 @@ contract SablierV2MerkleLockupFactory is ISablierV2MerkleLockupFactory {
external
returns (ISablierV2MerkleLockupLT merkleLockupLT)
{
// Calculate the sum of percentages across all tranches.
// Calculate the sum of percentages and durations across all tranches.
UD60x18 totalPercentage;
uint256 trancheCount = tranchesWithPercentages.length;
for (uint256 i = 0; i < trancheCount; ++i) {
uint256 totalDuration;
for (uint256 i = 0; i < tranchesWithPercentages.length; ++i) {
UD60x18 percentage = (tranchesWithPercentages[i].unlockPercentage).intoUD60x18();
totalPercentage = totalPercentage.add(percentage);
unchecked {
// Safe to use `unchecked` because its only used in the event.
totalDuration += tranchesWithPercentages[i].duration;
}
}

// Checks: the sum of percentages equals 100%.
Expand Down Expand Up @@ -102,7 +106,13 @@ contract SablierV2MerkleLockupFactory is ISablierV2MerkleLockupFactory {

// Log the creation of the Merkle Lockup, including some metadata that is not stored on-chain.
emit CreateMerkleLockupLT(
merkleLockupLT, baseParams, lockupTranched, tranchesWithPercentages, aggregateAmount, recipientsCount
merkleLockupLT,
baseParams,
lockupTranched,
tranchesWithPercentages,
totalDuration,
aggregateAmount,
recipientsCount
);
}
}
5 changes: 3 additions & 2 deletions src/interfaces/ISablierV2MerkleLockupFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface ISablierV2MerkleLockupFactory {
/// @notice Emitted when a Sablier V2 Lockup Linear Merkle Lockup is created.
event CreateMerkleLockupLL(
ISablierV2MerkleLockupLL indexed merkleLockupLL,
MerkleLockup.ConstructorParams indexed baseParams,
MerkleLockup.ConstructorParams baseParams,
ISablierV2LockupLinear lockupLinear,
LockupLinear.Durations streamDurations,
uint256 aggregateAmount,
Expand All @@ -29,9 +29,10 @@ interface ISablierV2MerkleLockupFactory {
/// @notice Emitted when a Sablier V2 Lockup Tranched Merkle Lockup is created.
event CreateMerkleLockupLT(
ISablierV2MerkleLockupLT indexed merkleLockupLT,
MerkleLockup.ConstructorParams indexed baseParams,
MerkleLockup.ConstructorParams baseParams,
ISablierV2LockupTranched lockupTranched,
MerkleLockupLT.TrancheWithPercentage[] tranchesWithPercentages,
uint256 totalDuration,
uint256 aggregateAmount,
uint256 recipientsCount
);
Expand Down
1 change: 1 addition & 0 deletions test/fork/merkle-lockup/MerkleLockupLT.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ abstract contract MerkleLockupLT_Fork_Test is Fork_Test {
baseParams: vars.baseParams,
lockupTranched: lockupTranched,
tranchesWithPercentages: defaults.tranchesWithPercentages(),
totalDuration: defaults.TOTAL_DURATION(),
aggregateAmount: vars.aggregateAmount,
recipientsCount: vars.recipientsCount
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ contract CreateMerkleLockupLT_Integration_Test is MerkleLockup_Integration_Test
baseParams: baseParams,
lockupTranched: lockupTranched,
tranchesWithPercentages: defaults.tranchesWithPercentages(),
totalDuration: defaults.TOTAL_DURATION(),
aggregateAmount: defaults.AGGREGATE_AMOUNT(),
recipientsCount: defaults.RECIPIENTS_COUNT()
});
Expand Down
5 changes: 3 additions & 2 deletions test/utils/Events.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ abstract contract Events {
event Clawback(address indexed admin, address indexed to, uint128 amount);
event CreateMerkleLockupLL(
ISablierV2MerkleLockupLL indexed merkleLockupLL,
MerkleLockup.ConstructorParams indexed baseParams,
MerkleLockup.ConstructorParams baseParams,
ISablierV2LockupLinear lockupLinear,
LockupLinear.Durations streamDurations,
uint256 aggregateAmount,
uint256 recipientsCount
);
event CreateMerkleLockupLT(
ISablierV2MerkleLockupLT indexed merkleLockupLT,
MerkleLockup.ConstructorParams indexed baseParams,
MerkleLockup.ConstructorParams baseParams,
ISablierV2LockupTranched lockupTranched,
MerkleLockupLT.TrancheWithPercentage[] tranchesWithPercentages,
uint256 totalDuration,
uint256 aggregateAmount,
uint256 recipientsCount
);
Expand Down

0 comments on commit 8683889

Please sign in to comment.