Skip to content

Commit

Permalink
refactor: LockupLL to LL and LockupLT to LT
Browse files Browse the repository at this point in the history
  • Loading branch information
smol-ninja committed Apr 11, 2024
1 parent 0045f4a commit ac75fbb
Show file tree
Hide file tree
Showing 37 changed files with 332 additions and 356 deletions.
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ vulnerability, it must adhere to these assumptions as well:

- [All assumptions](https://github.com/sablier-labs/v2-core/blob/main/SECURITY.md) in Sablier V2 Core apply to Sablier
V2 Periphery as well.
- In `SablierV2MerkleLockupLT`, the tranche unlock percentages and the durations will be same for all airdrop claimers.
- In `SablierV2MerkleLT`, the tranche unlock percentages and the durations will be same for all airdrop claimers.

### Rewards

Expand Down
Binary file modified bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
]
gas_reports = [
"SablierV2Batch",
"SablierV2MerkleLL",
"SablierV2MerkleLockupFactory",
"SablierV2MerkleLockupLL",
"SablierV2MerkleLockupLT",
"SablierV2MerkleLT",
]
optimizer = true
optimizer_runs = 10_000
Expand Down
2 changes: 1 addition & 1 deletion precompiles/Precompiles.sol

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { LockupLinear } from "@sablier/v2-core/src/types/DataTypes.sol";

import { BaseScript } from "./Base.s.sol";

import { ISablierV2MerkleLL } from "../src/interfaces/ISablierV2MerkleLL.sol";
import { ISablierV2MerkleLockupFactory } from "../src/interfaces/ISablierV2MerkleLockupFactory.sol";
import { ISablierV2MerkleLockupLL } from "../src/interfaces/ISablierV2MerkleLockupLL.sol";
import { MerkleLockup } from "../src/types/DataTypes.sol";

contract CreateMerkleLockupLL is BaseScript {
contract CreateMerkleLL is BaseScript {
struct Params {
MerkleLockup.ConstructorParams baseParams;
ISablierV2LockupLinear lockupLinear;
Expand All @@ -27,9 +27,9 @@ contract CreateMerkleLockupLL is BaseScript {
public
virtual
broadcast
returns (ISablierV2MerkleLockupLL merkleLockupLL)
returns (ISablierV2MerkleLL merkleLL)
{
merkleLockupLL = _run(merkleLockupFactory, params);
merkleLL = _run(merkleLockupFactory, params);
}

/// @dev Deploy via Sphinx.
Expand All @@ -40,19 +40,19 @@ contract CreateMerkleLockupLL is BaseScript {
public
virtual
sphinx
returns (ISablierV2MerkleLockupLL merkleLockupLL)
returns (ISablierV2MerkleLL merkleLL)
{
merkleLockupLL = _run(merkleLockupFactory, params);
merkleLL = _run(merkleLockupFactory, params);
}

function _run(
ISablierV2MerkleLockupFactory merkleLockupFactory,
Params calldata params
)
internal
returns (ISablierV2MerkleLockupLL merkleLockupLL)
returns (ISablierV2MerkleLL merkleLL)
{
merkleLockupLL = merkleLockupFactory.createMerkleLockupLL(
merkleLL = merkleLockupFactory.createMerkleLL(
params.baseParams,
params.lockupLinear,
params.streamDurations,
Expand Down
20 changes: 10 additions & 10 deletions script/CreateMerkleLockupLT.s.sol → script/CreateMerkleLT.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { ISablierV2LockupTranched } from "@sablier/v2-core/src/interfaces/ISabli
import { BaseScript } from "./Base.s.sol";

import { ISablierV2MerkleLockupFactory } from "../src/interfaces/ISablierV2MerkleLockupFactory.sol";
import { ISablierV2MerkleLockupLT } from "../src/interfaces/ISablierV2MerkleLockupLT.sol";
import { MerkleLockup, MerkleLockupLT } from "../src/types/DataTypes.sol";
import { ISablierV2MerkleLT } from "../src/interfaces/ISablierV2MerkleLT.sol";
import { MerkleLockup, MerkleLT } from "../src/types/DataTypes.sol";

contract CreateMerkleLockupLT is BaseScript {
contract CreateMerkleLT is BaseScript {
struct Params {
MerkleLockup.ConstructorParams baseParams;
ISablierV2LockupTranched lockupTranched;
MerkleLockupLT.TrancheWithPercentage[] tranchesWithPercentages;
MerkleLT.TrancheWithPercentage[] tranchesWithPercentages;
uint256 campaignTotalAmount;
uint256 recipientCount;
}
Expand All @@ -26,9 +26,9 @@ contract CreateMerkleLockupLT is BaseScript {
public
virtual
broadcast
returns (ISablierV2MerkleLockupLT merkleLockupLT)
returns (ISablierV2MerkleLT merkleLT)
{
merkleLockupLT = _run(merkleLockupFactory, params);
merkleLT = _run(merkleLockupFactory, params);
}

/// @dev Deploy via Sphinx.
Expand All @@ -39,19 +39,19 @@ contract CreateMerkleLockupLT is BaseScript {
public
virtual
sphinx
returns (ISablierV2MerkleLockupLT merkleLockupLT)
returns (ISablierV2MerkleLT merkleLT)
{
merkleLockupLT = _run(merkleLockupFactory, params);
merkleLT = _run(merkleLockupFactory, params);
}

function _run(
ISablierV2MerkleLockupFactory merkleLockupFactory,
Params calldata params
)
internal
returns (ISablierV2MerkleLockupLT merkleLockupLT)
returns (ISablierV2MerkleLT merkleLT)
{
merkleLockupLT = merkleLockupFactory.createMerkleLockupLT(
merkleLT = merkleLockupFactory.createMerkleLT(
params.baseParams,
params.lockupTranched,
params.tranchesWithPercentages,
Expand Down
8 changes: 4 additions & 4 deletions shell/prepare-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ FOUNDRY_PROFILE=optimized forge build

# Copy the production artifacts
cp out-optimized/SablierV2Batch.sol/SablierV2Batch.json $artifacts
cp out-optimized/SablierV2MerkleLL.sol/SablierV2MerkleLL.json $artifacts
cp out-optimized/SablierV2MerkleLockupFactory.sol/SablierV2MerkleLockupFactory.json $artifacts
cp out-optimized/SablierV2MerkleLockupLL.sol/SablierV2MerkleLockupLL.json $artifacts
cp out-optimized/SablierV2MerkleLockupLT.sol/SablierV2MerkleLockupLT.json $artifacts
cp out-optimized/SablierV2MerkleLT.sol/SablierV2MerkleLT.json $artifacts

interfaces=./artifacts/interfaces
cp out-optimized/ISablierV2Batch.sol/ISablierV2Batch.json $interfaces
cp out-optimized/ISablierV2MerkleLL.sol/ISablierV2MerkleLL.json $interfaces
cp out-optimized/ISablierV2MerkleLockupFactory.sol/ISablierV2MerkleLockupFactory.json $interfaces
cp out-optimized/ISablierV2MerkleLockupLL.sol/ISablierV2MerkleLockupLL.json $interfaces
cp out-optimized/ISablierV2MerkleLockupLT.sol/ISablierV2MerkleLockupLT.json $interfaces
cp out-optimized/ISablierV2MerkleLT.sol/ISablierV2MerkleLT.json $interfaces

erc20=./artifacts/interfaces/erc20
cp out-optimized/IERC20.sol/IERC20.json $erc20
Expand Down
16 changes: 8 additions & 8 deletions src/SablierV2MerkleLockupLL.sol → src/SablierV2MerkleLL.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import { ISablierV2LockupLinear } from "@sablier/v2-core/src/interfaces/ISablier
import { Broker, LockupLinear } from "@sablier/v2-core/src/types/DataTypes.sol";

import { SablierV2MerkleLockup } from "./abstracts/SablierV2MerkleLockup.sol";
import { ISablierV2MerkleLockupLL } from "./interfaces/ISablierV2MerkleLockupLL.sol";
import { ISablierV2MerkleLL } from "./interfaces/ISablierV2MerkleLL.sol";
import { MerkleLockup } from "./types/DataTypes.sol";

/// @title SablierV2MerkleLockupLL
/// @notice See the documentation in {ISablierV2MerkleLockupLL}.
contract SablierV2MerkleLockupLL is
ISablierV2MerkleLockupLL, // 2 inherited components
/// @title SablierV2MerkleLL
/// @notice See the documentation in {ISablierV2MerkleLL}.
contract SablierV2MerkleLL is
ISablierV2MerkleLL, // 2 inherited components
SablierV2MerkleLockup // 4 inherited components
{
using BitMaps for BitMaps.BitMap;
Expand All @@ -25,10 +25,10 @@ contract SablierV2MerkleLockupLL is
STATE VARIABLES
//////////////////////////////////////////////////////////////////////////*/

/// @inheritdoc ISablierV2MerkleLockupLL
/// @inheritdoc ISablierV2MerkleLL
ISablierV2LockupLinear public immutable override LOCKUP_LINEAR;

/// @inheritdoc ISablierV2MerkleLockupLL
/// @inheritdoc ISablierV2MerkleLL
LockupLinear.Durations public override streamDurations;

/*//////////////////////////////////////////////////////////////////////////
Expand All @@ -55,7 +55,7 @@ contract SablierV2MerkleLockupLL is
USER-FACING NON-CONSTANT FUNCTIONS
//////////////////////////////////////////////////////////////////////////*/

/// @inheritdoc ISablierV2MerkleLockupLL
/// @inheritdoc ISablierV2MerkleLL
function claim(
uint256 index,
address recipient,
Expand Down
31 changes: 13 additions & 18 deletions src/SablierV2MerkleLockupLT.sol → src/SablierV2MerkleLT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import { ISablierV2LockupTranched } from "@sablier/v2-core/src/interfaces/ISabli
import { Broker, LockupTranched } from "@sablier/v2-core/src/types/DataTypes.sol";

import { SablierV2MerkleLockup } from "./abstracts/SablierV2MerkleLockup.sol";
import { ISablierV2MerkleLockupLT } from "./interfaces/ISablierV2MerkleLockupLT.sol";
import { MerkleLockup, MerkleLockupLT } from "./types/DataTypes.sol";
import { ISablierV2MerkleLT } from "./interfaces/ISablierV2MerkleLT.sol";
import { MerkleLockup, MerkleLT } from "./types/DataTypes.sol";

/// @title SablierV2MerkleLockupLT
/// @notice See the documentation in {ISablierV2MerkleLockupLT}.
contract SablierV2MerkleLockupLT is
ISablierV2MerkleLockupLT, // 2 inherited components
/// @title SablierV2MerkleLT
/// @notice See the documentation in {ISablierV2MerkleLT}.
contract SablierV2MerkleLT is
ISablierV2MerkleLT, // 2 inherited components
SablierV2MerkleLockup // 4 inherited components
{
using BitMaps for BitMaps.BitMap;
Expand All @@ -25,11 +25,11 @@ contract SablierV2MerkleLockupLT is
STATE VARIABLES
//////////////////////////////////////////////////////////////////////////*/

/// @inheritdoc ISablierV2MerkleLockupLT
/// @inheritdoc ISablierV2MerkleLT
ISablierV2LockupTranched public immutable override LOCKUP_TRANCHED;

/// @dev The tranches with their respective unlock percentages and durations.
MerkleLockupLT.TrancheWithPercentage[] internal _tranchesWithPercentages;
MerkleLT.TrancheWithPercentage[] internal _tranchesWithPercentages;

/*//////////////////////////////////////////////////////////////////////////
CONSTRUCTOR
Expand All @@ -40,7 +40,7 @@ contract SablierV2MerkleLockupLT is
constructor(
MerkleLockup.ConstructorParams memory baseParams,
ISablierV2LockupTranched lockupTranched,
MerkleLockupLT.TrancheWithPercentage[] memory tranchesWithPercentages
MerkleLT.TrancheWithPercentage[] memory tranchesWithPercentages
)
SablierV2MerkleLockup(baseParams)
{
Expand All @@ -61,21 +61,16 @@ contract SablierV2MerkleLockupLT is
USER-FACING CONSTANT FUNCTIONS
//////////////////////////////////////////////////////////////////////////*/

/// @inheritdoc ISablierV2MerkleLockupLT
function getTranchesWithPercentages()
external
view
override
returns (MerkleLockupLT.TrancheWithPercentage[] memory)
{
/// @inheritdoc ISablierV2MerkleLT
function getTranchesWithPercentages() external view override returns (MerkleLT.TrancheWithPercentage[] memory) {
return _tranchesWithPercentages;
}

/*//////////////////////////////////////////////////////////////////////////
USER-FACING NON-CONSTANT FUNCTIONS
//////////////////////////////////////////////////////////////////////////*/

/// @inheritdoc ISablierV2MerkleLockupLT
/// @inheritdoc ISablierV2MerkleLT
function claim(
uint256 index,
address recipient,
Expand Down Expand Up @@ -128,7 +123,7 @@ contract SablierV2MerkleLockupLT is
returns (LockupTranched.TrancheWithDuration[] memory tranches)
{
// Load the tranches in memory (to save gas).
MerkleLockupLT.TrancheWithPercentage[] memory tranchesWithPercentages = _tranchesWithPercentages;
MerkleLT.TrancheWithPercentage[] memory tranchesWithPercentages = _tranchesWithPercentages;

// Declare the variables needed for calculation.
uint128 calculatedAmountsSum;
Expand Down
32 changes: 15 additions & 17 deletions src/SablierV2MerkleLockupFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { ISablierV2LockupLinear } from "@sablier/v2-core/src/interfaces/ISablier
import { ISablierV2LockupTranched } from "@sablier/v2-core/src/interfaces/ISablierV2LockupTranched.sol";
import { LockupLinear } from "@sablier/v2-core/src/types/DataTypes.sol";

import { ISablierV2MerkleLL } from "./interfaces/ISablierV2MerkleLL.sol";
import { ISablierV2MerkleLockupFactory } from "./interfaces/ISablierV2MerkleLockupFactory.sol";
import { ISablierV2MerkleLockupLL } from "./interfaces/ISablierV2MerkleLockupLL.sol";
import { ISablierV2MerkleLockupLT } from "./interfaces/ISablierV2MerkleLockupLT.sol";
import { ISablierV2MerkleLT } from "./interfaces/ISablierV2MerkleLT.sol";
import { Errors } from "./libraries/Errors.sol";
import { SablierV2MerkleLockupLL } from "./SablierV2MerkleLockupLL.sol";
import { SablierV2MerkleLockupLT } from "./SablierV2MerkleLockupLT.sol";
import { MerkleLockup, MerkleLockupLT } from "./types/DataTypes.sol";
import { SablierV2MerkleLL } from "./SablierV2MerkleLL.sol";
import { SablierV2MerkleLT } from "./SablierV2MerkleLT.sol";
import { MerkleLockup, MerkleLT } from "./types/DataTypes.sol";

/// @title SablierV2MerkleLockupFactory
/// @notice See the documentation in {ISablierV2MerkleLockupFactory}.
Expand All @@ -22,15 +22,15 @@ contract SablierV2MerkleLockupFactory is ISablierV2MerkleLockupFactory {
//////////////////////////////////////////////////////////////////////////*/

/// @notice inheritdoc ISablierV2MerkleLockupFactory
function createMerkleLockupLL(
function createMerkleLL(
MerkleLockup.ConstructorParams memory baseParams,
ISablierV2LockupLinear lockupLinear,
LockupLinear.Durations memory streamDurations,
uint256 aggregateAmount,
uint256 recipientCount
)
external
returns (ISablierV2MerkleLockupLL merkleLockupLL)
returns (ISablierV2MerkleLL merkleLL)
{
// Hash the parameters to generate a salt.
bytes32 salt = keccak256(
Expand All @@ -49,24 +49,22 @@ contract SablierV2MerkleLockupFactory is ISablierV2MerkleLockupFactory {
);

// Deploy the MerkleLockup contract with CREATE2.
merkleLockupLL = new SablierV2MerkleLockupLL{ salt: salt }(baseParams, lockupLinear, streamDurations);
merkleLL = new SablierV2MerkleLL{ salt: salt }(baseParams, lockupLinear, streamDurations);

// Log the creation of the MerkleLockup contract, including some metadata that is not stored on-chain.
emit CreateMerkleLockupLL(
merkleLockupLL, baseParams, lockupLinear, streamDurations, aggregateAmount, recipientCount
);
emit CreateMerkleLL(merkleLL, baseParams, lockupLinear, streamDurations, aggregateAmount, recipientCount);
}

/// @notice inheritdoc ISablierV2MerkleLockupFactory
function createMerkleLockupLT(
function createMerkleLT(
MerkleLockup.ConstructorParams memory baseParams,
ISablierV2LockupTranched lockupTranched,
MerkleLockupLT.TrancheWithPercentage[] memory tranchesWithPercentages,
MerkleLT.TrancheWithPercentage[] memory tranchesWithPercentages,
uint256 aggregateAmount,
uint256 recipientCount
)
external
returns (ISablierV2MerkleLockupLT merkleLockupLT)
returns (ISablierV2MerkleLT merkleLT)
{
// Calculate the sum of percentages and durations across all tranches.
uint64 totalPercentage;
Expand Down Expand Up @@ -102,11 +100,11 @@ contract SablierV2MerkleLockupFactory is ISablierV2MerkleLockupFactory {
);

// Deploy the MerkleLockup contract with CREATE2.
merkleLockupLT = new SablierV2MerkleLockupLT{ salt: salt }(baseParams, lockupTranched, tranchesWithPercentages);
merkleLT = new SablierV2MerkleLT{ salt: salt }(baseParams, lockupTranched, tranchesWithPercentages);

// Log the creation of the MerkleLockup contract, including some metadata that is not stored on-chain.
emit CreateMerkleLockupLT(
merkleLockupLT,
emit CreateMerkleLT(
merkleLT,
baseParams,
lockupTranched,
tranchesWithPercentages,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { ISablierV2LockupLinear } from "@sablier/v2-core/src/interfaces/ISablier

import { ISablierV2MerkleLockup } from "./ISablierV2MerkleLockup.sol";

/// @title ISablierV2MerkleLockupLL
/// @title ISablierV2MerkleLL
/// @notice MerkleLockup campaign that creates LockupLinear streams.
interface ISablierV2MerkleLockupLL is ISablierV2MerkleLockup {
interface ISablierV2MerkleLL is ISablierV2MerkleLockup {
/*//////////////////////////////////////////////////////////////////////////
CONSTANT FUNCTIONS
//////////////////////////////////////////////////////////////////////////*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ pragma solidity >=0.8.22;
import { ISablierV2LockupTranched } from "@sablier/v2-core/src/interfaces/ISablierV2LockupTranched.sol";

import { ISablierV2MerkleLockup } from "./ISablierV2MerkleLockup.sol";
import { MerkleLockupLT } from "./../types/DataTypes.sol";
import { MerkleLT } from "./../types/DataTypes.sol";

/// @title ISablierV2MerkleLockupLT
/// @title ISablierV2MerkleLT
/// @notice MerkleLockup campaign that creates LockupTranched streams.
interface ISablierV2MerkleLockupLT is ISablierV2MerkleLockup {
interface ISablierV2MerkleLT is ISablierV2MerkleLockup {
/*//////////////////////////////////////////////////////////////////////////
CONSTANT FUNCTIONS
//////////////////////////////////////////////////////////////////////////*/

/// @notice Retrieves the tranches with their respective unlock percentages and durations.
function getTranchesWithPercentages() external view returns (MerkleLockupLT.TrancheWithPercentage[] memory);
function getTranchesWithPercentages() external view returns (MerkleLT.TrancheWithPercentage[] memory);

/// @notice The address of the {SablierV2LockupTranched} contract.
function LOCKUP_TRANCHED() external view returns (ISablierV2LockupTranched);
Expand Down
Loading

0 comments on commit ac75fbb

Please sign in to comment.