Skip to content

Commit

Permalink
refactor: Rename MerkleStreamer to MerkleLockup
Browse files Browse the repository at this point in the history
  • Loading branch information
smol-ninja committed Jan 29, 2024
1 parent bbf6366 commit 846c8e0
Show file tree
Hide file tree
Showing 42 changed files with 365 additions and 374 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Create Merkle Streamer LockupLinear"
name: "Create Merkle Lockup LockupLinear"

env:
API_KEY_INFURA: ${{ secrets.API_KEY_INFURA }}
Expand All @@ -18,7 +18,7 @@ on:
required: false

jobs:
create-merkle-streamer-ll:
create-merkle-lockup-ll:
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
Expand All @@ -27,9 +27,9 @@ jobs:
- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Create a Merkle streamer contract that uses Sablier V2 Lockup Linear"
- name: "Create a Merkle lockup contract that uses Sablier V2 Lockup Linear"
run: >-
forge script script/CreateMerkleStreamerLL.s.sol
forge script script/CreateMerkleLockupLL.s.sol
--broadcast
--rpc-url "${{ inputs.chain }}"
--sig "run(address,(address,address,address,bytes32,uint40,(uint40,uint40),bool,bool,string,uint256,uint256))"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Deploy Merkle Streamer Factory"
name: "Deploy Merkle Lockup Factory"

env:
API_KEY_INFURA: ${{ secrets.API_KEY_INFURA }}
Expand All @@ -15,7 +15,7 @@ on:
required: false

jobs:
deploy-merkle-streamer-factory:
deploy-merkle-lockup-factory:
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
Expand All @@ -24,9 +24,9 @@ jobs:
- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Deploy the SablierV2MerkleStreamerFactory contract"
- name: "Deploy the SablierV2MerkleLockupFactory contract"
run: >-
forge script script/DeployMerkleStreamerFactory.s.sol
forge script script/DeployMerkleLockupFactory.s.sol
--broadcast
--rpc-url "${{ inputs.chain }}"
--sig "run()"
Expand Down
4 changes: 2 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
fs_permissions = [{ access = "read", path = "out-optimized" }]
gas_reports = [
"SablierV2Batch",
"SablierV2MerkleStreamerFactory",
"SablierV2MerkleStreamerLL",
"SablierV2MerkleLockupFactory",
"SablierV2MerkleLockupLL",
]
optimizer = true
optimizer_runs = 10_000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { LockupLinear } from "@sablier/v2-core/src/types/DataTypes.sol";

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

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

contract CreateMerkleStreamerLL is BaseScript {
contract CreateMerkleLockupLL is BaseScript {
struct Params {
MerkleStreamer.ConstructorParams constructorParams;
MerkleLockup.ConstructorParams constructorParams;
ISablierV2LockupLinear lockupLinear;
LockupLinear.Durations streamDurations;
string ipfsCID;
Expand All @@ -21,14 +21,14 @@ contract CreateMerkleStreamerLL is BaseScript {
}

function run(
ISablierV2MerkleStreamerFactory merkleStreamerFactory,
ISablierV2MerkleLockupFactory merkleLockupFactory,
Params calldata params
)
public
broadcast
returns (ISablierV2MerkleStreamerLL merkleStreamerLL)
returns (ISablierV2MerkleLockupLL merkleLockupLL)
{
merkleStreamerLL = merkleStreamerFactory.createMerkleStreamerLL(
merkleLockupLL = merkleLockupFactory.createMerkleLockupLL(
params.constructorParams,
params.lockupLinear,
params.streamDurations,
Expand Down
8 changes: 4 additions & 4 deletions script/DeployDeterministicPeriphery.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ pragma solidity >=0.8.22 <0.9.0;
import { BaseScript } from "./Base.s.sol";

import { SablierV2Batch } from "../src/SablierV2Batch.sol";
import { SablierV2MerkleStreamerFactory } from "../src/SablierV2MerkleStreamerFactory.sol";
import { SablierV2MerkleLockupFactory } from "../src/SablierV2MerkleLockupFactory.sol";

/// @notice Deploys all V2 Periphery contracts at deterministic addresses across chains, in the following order:
///
/// 1. {SablierV2Batch}
/// 2. {SablierV2MerkleStreamerFactory}
/// 2. {SablierV2MerkleLockupFactory}
///
/// @dev Reverts if any contract has already been deployed.
contract DeployDeterministicPeriphery is BaseScript {
Expand All @@ -19,9 +19,9 @@ contract DeployDeterministicPeriphery is BaseScript {
public
virtual
broadcast
returns (SablierV2Batch batch, SablierV2MerkleStreamerFactory merkleStreamerFactory)
returns (SablierV2Batch batch, SablierV2MerkleLockupFactory merkleLockupFactory)
{
batch = new SablierV2Batch{ salt: bytes32(abi.encodePacked(create2Salt)) }();
merkleStreamerFactory = new SablierV2MerkleStreamerFactory{ salt: bytes32(abi.encodePacked(create2Salt)) }();
merkleLockupFactory = new SablierV2MerkleLockupFactory{ salt: bytes32(abi.encodePacked(create2Salt)) }();
}
}
12 changes: 12 additions & 0 deletions script/DeployMerkleLockupFactory.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.22 <0.9.0;

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

import { SablierV2MerkleLockupFactory } from "../src/SablierV2MerkleLockupFactory.sol";

contract DeployMerkleLockupFactory is BaseScript {
function run() public broadcast returns (SablierV2MerkleLockupFactory merkleLockupFactory) {
merkleLockupFactory = new SablierV2MerkleLockupFactory();
}
}
12 changes: 0 additions & 12 deletions script/DeployMerkleStreamerFactory.s.sol

This file was deleted.

12 changes: 4 additions & 8 deletions script/DeployPeriphery.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@ pragma solidity >=0.8.22 <0.9.0;

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

import { SablierV2MerkleStreamerFactory } from "../src/SablierV2MerkleStreamerFactory.sol";
import { SablierV2MerkleLockupFactory } from "../src/SablierV2MerkleLockupFactory.sol";
import { SablierV2Batch } from "../src/SablierV2Batch.sol";

/// @notice Deploys all V2 Periphery contract in the following order:
///
/// 1. {SablierV2Batch}
/// 2. {SablierV2MerkleStreamerFactory}
/// 2. {SablierV2MerkleLockupFactory}
contract DeployPeriphery is BaseScript {
function run()
public
broadcast
returns (SablierV2Batch batch, SablierV2MerkleStreamerFactory merkleStreamerFactory)
{
function run() public broadcast returns (SablierV2Batch batch, SablierV2MerkleLockupFactory merkleLockupFactory) {
batch = new SablierV2Batch();
merkleStreamerFactory = new SablierV2MerkleStreamerFactory();
merkleLockupFactory = new SablierV2MerkleLockupFactory();
}
}
6 changes: 3 additions & 3 deletions script/DeployProtocol.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { SablierV2LockupLinear } from "@sablier/v2-core/src/SablierV2LockupLinea
import { SablierV2NFTDescriptor } from "@sablier/v2-core/src/SablierV2NFTDescriptor.sol";
import { BaseScript } from "./Base.s.sol";

import { SablierV2MerkleStreamerFactory } from "../src/SablierV2MerkleStreamerFactory.sol";
import { SablierV2MerkleLockupFactory } from "../src/SablierV2MerkleLockupFactory.sol";
import { SablierV2Batch } from "../src/SablierV2Batch.sol";

/// @notice Deploys the Sablier V2 Protocol.
Expand All @@ -25,7 +25,7 @@ contract DeployProtocol is BaseScript {
SablierV2LockupLinear lockupLinear,
SablierV2NFTDescriptor nftDescriptor,
SablierV2Batch batch,
SablierV2MerkleStreamerFactory merkleStreamerFactory
SablierV2MerkleLockupFactory merkleLockupFactory
)
{
// Deploy V2 Core.
Expand All @@ -35,6 +35,6 @@ contract DeployProtocol is BaseScript {
lockupLinear = new SablierV2LockupLinear(initialAdmin, comptroller, nftDescriptor);

batch = new SablierV2Batch();
merkleStreamerFactory = new SablierV2MerkleStreamerFactory();
merkleLockupFactory = new SablierV2MerkleLockupFactory();
}
}
8 changes: 4 additions & 4 deletions shell/prepare-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ FOUNDRY_PROFILE=optimized forge build

# Copy the production artifacts
cp out-optimized/SablierV2Batch.sol/SablierV2Batch.json $artifacts
cp out-optimized/SablierV2MerkleStreamerFactory.sol/SablierV2MerkleStreamerFactory.json $artifacts
cp out-optimized/SablierV2MerkleStreamerLL.sol/SablierV2MerkleStreamerLL.json $artifacts
cp out-optimized/SablierV2MerkleLockupFactory.sol/SablierV2MerkleLockupFactory.json $artifacts
cp out-optimized/SablierV2MerkleLockupLL.sol/SablierV2MerkleLockupLL.json $artifacts

interfaces=./artifacts/interfaces
cp out-optimized/ISablierV2Batch.sol/ISablierV2Batch.json $interfaces
cp out-optimized/ISablierV2MerkleStreamerFactory.sol/ISablierV2MerkleStreamerFactory.json $interfaces
cp out-optimized/ISablierV2MerkleStreamerLL.sol/ISablierV2MerkleStreamerLL.json $interfaces
cp out-optimized/ISablierV2MerkleLockupFactory.sol/ISablierV2MerkleLockupFactory.json $interfaces
cp out-optimized/ISablierV2MerkleLockupLL.sol/ISablierV2MerkleLockupLL.json $interfaces

erc20=./artifacts/interfaces/erc20
cp out-optimized/IERC20.sol/IERC20.json $erc20
Expand Down
4 changes: 2 additions & 2 deletions shell/update-precompiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ FOUNDRY_PROFILE=optimized forge build

# Retrieve the raw bytecodes, removing the "0x" prefix
batch=$(cat out-optimized/SablierV2Batch.sol/SablierV2Batch.json | jq -r '.bytecode.object' | cut -c 3-)
merkle_streamer_factory=$(cat out-optimized/SablierV2MerkleStreamerFactory.sol/SablierV2MerkleStreamerFactory.json | jq -r '.bytecode.object' | cut -c 3-)
merkle_lockup_factory=$(cat out-optimized/SablierV2MerkleLockupFactory.sol/SablierV2MerkleLockupFactory.json | jq -r '.bytecode.object' | cut -c 3-)

precompiles_path="test/utils/Precompiles.sol"
if [ ! -f $precompiles_path ]; then
Expand All @@ -23,7 +23,7 @@ fi

# Replace the current bytecodes
sd "(BYTECODE_BATCH =)[^;]+;" "\$1 hex\"$batch\";" $precompiles_path
sd "(BYTECODE_MERKLE_STREAMER_FACTORY =)[^;]+;" "\$1 hex\"$merkle_streamer_factory\";" $precompiles_path
sd "(BYTECODE_MERKLE_LOCKUP_FACTORY =)[^;]+;" "\$1 hex\"$merkle_lockup_factory\";" $precompiles_path

# Reformat the code with Forge
forge fmt $precompiles_path
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@ pragma solidity >=0.8.22;
import { LockupLinear } from "@sablier/v2-core/src/types/DataTypes.sol";
import { ISablierV2LockupLinear } from "@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol";

import { SablierV2MerkleStreamerLL } from "./SablierV2MerkleStreamerLL.sol";
import { ISablierV2MerkleStreamerFactory } from "./interfaces/ISablierV2MerkleStreamerFactory.sol";
import { ISablierV2MerkleStreamerLL } from "./interfaces/ISablierV2MerkleStreamerLL.sol";
import { MerkleStreamer } from "./types/DataTypes.sol";
import { SablierV2MerkleLockupLL } from "./SablierV2MerkleLockupLL.sol";
import { ISablierV2MerkleLockupFactory } from "./interfaces/ISablierV2MerkleLockupFactory.sol";
import { ISablierV2MerkleLockupLL } from "./interfaces/ISablierV2MerkleLockupLL.sol";
import { MerkleLockup } from "./types/DataTypes.sol";

/// @title SablierV2MerkleStreamerFactory
/// @notice See the documentation in {ISablierV2MerkleStreamerFactory}.
contract SablierV2MerkleStreamerFactory is ISablierV2MerkleStreamerFactory {
/// @title SablierV2MerkleLockupFactory
/// @notice See the documentation in {ISablierV2MerkleLockupFactory}.
contract SablierV2MerkleLockupFactory is ISablierV2MerkleLockupFactory {
/*//////////////////////////////////////////////////////////////////////////
USER-FACING NON-CONSTANT FUNCTIONS
//////////////////////////////////////////////////////////////////////////*/

/// @notice inheritdoc ISablierV2MerkleStreamerFactory
function createMerkleStreamerLL(
MerkleStreamer.ConstructorParams memory params,
/// @notice inheritdoc ISablierV2MerkleLockupFactory
function createMerkleLockupLL(
MerkleLockup.ConstructorParams memory params,
ISablierV2LockupLinear lockupLinear,
LockupLinear.Durations memory streamDurations,
string memory ipfsCID,
uint256 aggregateAmount,
uint256 recipientsCount
)
external
returns (ISablierV2MerkleStreamerLL merkleStreamerLL)
returns (ISablierV2MerkleLockupLL merkleLockupLL)
{
// Hash the parameters to generate a salt.
bytes32 salt = keccak256(
Expand All @@ -43,12 +43,12 @@ contract SablierV2MerkleStreamerFactory is ISablierV2MerkleStreamerFactory {
)
);

// Deploy the Merkle streamer with CREATE2.
merkleStreamerLL = new SablierV2MerkleStreamerLL{ salt: salt }(params, lockupLinear, streamDurations);
// Deploy the Merkle lockup with CREATE2.
merkleLockupLL = new SablierV2MerkleLockupLL{ salt: salt }(params, lockupLinear, streamDurations);

// Using a different function to emit the event to avoid stack too deep error.
emit CreateMerkleStreamerLL(
merkleStreamerLL, params, lockupLinear, streamDurations, ipfsCID, aggregateAmount, recipientsCount
emit CreateMerkleLockupLL(
merkleLockupLL, params, lockupLinear, streamDurations, ipfsCID, aggregateAmount, recipientsCount
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { ISablierV2LockupLinear } from "@sablier/v2-core/src/interfaces/ISablier
import { Broker, LockupLinear } from "@sablier/v2-core/src/types/DataTypes.sol";
import { ud } from "@prb/math/src/UD60x18.sol";

import { SablierV2MerkleStreamer } from "./abstracts/SablierV2MerkleStreamer.sol";
import { ISablierV2MerkleStreamerLL } from "./interfaces/ISablierV2MerkleStreamerLL.sol";
import { MerkleStreamer } from "./types/DataTypes.sol";

/// @title SablierV2MerkleStreamerLL
/// @notice See the documentation in {ISablierV2MerkleStreamerLL}.
contract SablierV2MerkleStreamerLL is
ISablierV2MerkleStreamerLL, // 2 inherited components
SablierV2MerkleStreamer // 4 inherited components
import { SablierV2MerkleLockup } from "./abstracts/SablierV2MerkleLockup.sol";
import { ISablierV2MerkleLockupLL } from "./interfaces/ISablierV2MerkleLockupLL.sol";
import { MerkleLockup } from "./types/DataTypes.sol";

/// @title SablierV2MerkleLockupLL
/// @notice See the documentation in {ISablierV2MerkleLockupLL}.
contract SablierV2MerkleLockupLL is
ISablierV2MerkleLockupLL, // 2 inherited components
SablierV2MerkleLockup // 4 inherited components
{
using BitMaps for BitMaps.BitMap;
using SafeERC20 for IERC20;
Expand All @@ -25,14 +25,14 @@ contract SablierV2MerkleStreamerLL is
USER-FACING CONSTANTS
//////////////////////////////////////////////////////////////////////////*/

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

/*//////////////////////////////////////////////////////////////////////////
USER-FACING STORAGE
//////////////////////////////////////////////////////////////////////////*/

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

/*//////////////////////////////////////////////////////////////////////////
Expand All @@ -42,24 +42,24 @@ contract SablierV2MerkleStreamerLL is
/// @dev Constructs the contract by initializing the immutable state variables, and max approving the Sablier
/// contract.
constructor(
MerkleStreamer.ConstructorParams memory params,
MerkleLockup.ConstructorParams memory params,
ISablierV2LockupLinear lockupLinear,
LockupLinear.Durations memory streamDurations_
)
SablierV2MerkleStreamer(params)
SablierV2MerkleLockup(params)
{
LOCKUP_LINEAR = lockupLinear;
streamDurations = streamDurations_;

// Max approve the Sablier contract to spend funds from the Merkle streamer.
// Max approve the Sablier contract to spend funds from the Merkle lockup.
ASSET.forceApprove(address(LOCKUP_LINEAR), type(uint256).max);
}

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

/// @inheritdoc ISablierV2MerkleStreamerLL
/// @inheritdoc ISablierV2MerkleLockupLL
function claim(
uint256 index,
address recipient,
Expand Down
Loading

0 comments on commit 846c8e0

Please sign in to comment.