Skip to content

Commit

Permalink
refactor: rename variable to totalPercentage
Browse files Browse the repository at this point in the history
  • Loading branch information
andreivladbrg committed Mar 8, 2024
1 parent 6ad73ed commit 048894d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/SablierV2MerkleLockupFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ contract SablierV2MerkleLockupFactory is ISablierV2MerkleLockupFactory {
returns (ISablierV2MerkleLockupLT merkleLockupLT)
{
// Calculate the sum of percentages across all tranches.
UD60x18 percentagesSum;
UD60x18 totalPercentage;
uint256 trancheCount = tranchesWithPercentages.length;
for (uint256 i = 0; i < trancheCount; ++i) {
UD60x18 percentage = (tranchesWithPercentages[i].unlockPercentage).intoUD60x18();
percentagesSum = percentagesSum.add(percentage);
totalPercentage = totalPercentage.add(percentage);
}

// Checks: the sum of percentages equals 100%.
if (!percentagesSum.eq(ud(1e18))) {
revert Errors.SablierV2MerkleLockupFactory_PercentageSumNotEqualOneHundred(percentagesSum.intoUint256());
if (!totalPercentage.eq(ud(1e18))) {
revert Errors.SablierV2MerkleLockupFactory_PercentageSumNotEqualOneHundred(totalPercentage.intoUint256());
}

// Hash the parameters to generate a salt.
Expand Down
2 changes: 1 addition & 1 deletion src/SablierV2MerkleLockupLT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ contract SablierV2MerkleLockupLT is
emit Claim(index, recipient, amount, streamId);
}

/// @dev Calculates the stream tranches based on Merkle tree amount and predefined percentage for each tranche.
/// @dev Calculates the stream tranches based on Merkle tree amount and unlock percentage for each tranche.
function _calculateTranches(uint128 amount)
internal
view
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ contract CreateMerkleLockupLT_Integration_Test is MerkleLockup_Integration_Test
MerkleLockup_Integration_Test.setUp();
}

modifier whenPercentagesSumIsNotOneHundred() {
modifier whenTotalPercentageIsNotOneHundred() {
_;
}

function test_RevertWhen_PercentageSumLessThanOneHundred() external whenPercentagesSumIsNotOneHundred {
function test_RevertWhen_PercentageSumLessThanOneHundred() external whenTotalPercentageIsNotOneHundred {
MerkleLockup.ConstructorParams memory baseParams = defaults.baseParams();
uint256 aggregateAmount = defaults.AGGREGATE_AMOUNT();
uint256 recipientsCount = defaults.RECIPIENTS_COUNT();
Expand All @@ -44,7 +44,7 @@ contract CreateMerkleLockupLT_Integration_Test is MerkleLockup_Integration_Test
});
}

function test_RevertWhen_PercentageSumGreaterThanOneHundred() external whenPercentagesSumIsNotOneHundred {
function test_RevertWhen_PercentageSumGreaterThanOneHundred() external whenTotalPercentageIsNotOneHundred {
MerkleLockup.ConstructorParams memory baseParams = defaults.baseParams();
uint256 aggregateAmount = defaults.AGGREGATE_AMOUNT();
uint256 recipientsCount = defaults.RECIPIENTS_COUNT();
Expand All @@ -70,11 +70,11 @@ contract CreateMerkleLockupLT_Integration_Test is MerkleLockup_Integration_Test
});
}

modifier whenPercentagesSumIsOneHundred() {
modifier whenTotalPercentageIsOneHundred() {
_;
}

function test_RevertWhen_CampaignNameTooLong() external whenPercentagesSumIsOneHundred {
function test_RevertWhen_CampaignNameTooLong() external whenTotalPercentageIsOneHundred {
MerkleLockup.ConstructorParams memory baseParams = defaults.baseParams();
MerkleLockupLT.TrancheWithPercentage[] memory tranchesWithPercentages = defaults.tranchesWithPercentages();
uint256 aggregateAmount = defaults.AGGREGATE_AMOUNT();
Expand Down Expand Up @@ -102,7 +102,7 @@ contract CreateMerkleLockupLT_Integration_Test is MerkleLockup_Integration_Test
}

/// @dev This test works because a default Merkle Lockup contract is deployed in {Integration_Test.setUp}
function test_RevertGiven_AlreadyCreated() external whenPercentagesSumIsOneHundred whenCampaignNameIsNotTooLong {
function test_RevertGiven_AlreadyCreated() external whenTotalPercentageIsOneHundred whenCampaignNameIsNotTooLong {
MerkleLockup.ConstructorParams memory baseParams = defaults.baseParams();
MerkleLockupLT.TrancheWithPercentage[] memory tranchesWithPercentages = defaults.tranchesWithPercentages();
uint256 aggregateAmount = defaults.AGGREGATE_AMOUNT();
Expand All @@ -127,7 +127,7 @@ contract CreateMerkleLockupLT_Integration_Test is MerkleLockup_Integration_Test
uint40 expiration
)
external
whenPercentagesSumIsOneHundred
whenTotalPercentageIsOneHundred
whenCampaignNameIsNotTooLong
givenNotAlreadyCreated
{
Expand Down

0 comments on commit 048894d

Please sign in to comment.