Skip to content

Commit

Permalink
refactor: multiple factories (#70)
Browse files Browse the repository at this point in the history
* refactor: add multiple factories

refactor: update deployment scripts to deploy all factories

feat: add initial minimumfee in factories

test: update tests accordingly

test: fix fork setUp

* build: update prepare artifacts script

* chore: remove ISablierMerkleFactory
docs: add natspecs over SablierMerkleFactoryBase
test: remove redundant lines from Base test
chore: use Merkle Factory contracts instead of Merkle Factories contracts
chore: remove redundant imports
test(fork): load factory admin in individual contracts
test(integration): add missing SetMinimumFee_Integration_Test tests
test(integration): use non-default fee value in SetMinimumFee_Integration_Test tests

---------

Co-authored-by: smol-ninja <[email protected]>
  • Loading branch information
andreivladbrg and smol-ninja authored Feb 20, 2025
1 parent 50487e0 commit f060524
Show file tree
Hide file tree
Showing 88 changed files with 1,469 additions and 825 deletions.
10 changes: 5 additions & 5 deletions script/CreateMerkleInstant.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
pragma solidity >=0.8.22 <0.9.0;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { ISablierMerkleFactory } from "src/interfaces/ISablierMerkleFactory.sol";
import { ISablierMerkleInstant } from "src/interfaces/ISablierMerkleInstant.sol";
import { MerkleInstant } from "src/types/DataTypes.sol";

import { ISablierMerkleInstant } from "./../src/interfaces/ISablierMerkleInstant.sol";
import { SablierMerkleFactoryInstant } from "./../src/SablierMerkleFactoryInstant.sol";
import { MerkleInstant } from "./../src/types/DataTypes.sol";
import { BaseScript } from "./Base.s.sol";

/// @dev Creates a dummy MerkleInstant campaign.
contract CreateMerkleInstant is BaseScript {
/// @dev Deploy via Forge.
function run() public broadcast returns (ISablierMerkleInstant merkleInstant) {
ISablierMerkleFactory merkleFactory = ISablierMerkleFactory(0x71DD3Ca88E7564416E5C2E350090C12Bf8F6144a);
// TODO: Load deployed addresses from Ethereum mainnet.
SablierMerkleFactoryInstant merkleFactory = new SablierMerkleFactoryInstant(DEFAULT_SABLIER_ADMIN, 0);

// Prepare the constructor parameters.
MerkleInstant.ConstructorParams memory params;
Expand Down
11 changes: 5 additions & 6 deletions script/CreateMerkleLL.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ pragma solidity >=0.8.22 <0.9.0;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { ud2x18 } from "@prb/math/src/UD2x18.sol";
import { ISablierLockup } from "@sablier/lockup/src/interfaces/ISablierLockup.sol";

import { ISablierMerkleFactory } from "../src/interfaces/ISablierMerkleFactory.sol";
import { ISablierMerkleLL } from "../src/interfaces/ISablierMerkleLL.sol";
import { MerkleLL } from "../src/types/DataTypes.sol";

import { ISablierMerkleLL } from "./../src/interfaces/ISablierMerkleLL.sol";
import { SablierMerkleFactoryLL } from "./../src/SablierMerkleFactoryLL.sol";
import { MerkleLL } from "./../src/types/DataTypes.sol";
import { BaseScript } from "./Base.s.sol";

/// @dev Creates a dummy campaign to airdrop tokens through Lockup Linear.
contract CreateMerkleLL is BaseScript {
/// @dev Deploy via Forge.
function run() public broadcast returns (ISablierMerkleLL merkleLL) {
ISablierMerkleFactory merkleFactory = ISablierMerkleFactory(0x71DD3Ca88E7564416E5C2E350090C12Bf8F6144a);
// TODO: Load deployed addresses from Ethereum mainnet.
SablierMerkleFactoryLL merkleFactory = new SablierMerkleFactoryLL(DEFAULT_SABLIER_ADMIN, 0);

// Prepare the constructor parameters.
MerkleLL.ConstructorParams memory params;
Expand Down
7 changes: 4 additions & 3 deletions script/CreateMerkleLT.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { ud2x18 } from "@prb/math/src/UD2x18.sol";
import { ISablierLockup } from "@sablier/lockup/src/interfaces/ISablierLockup.sol";

import { ISablierMerkleFactory } from "../src/interfaces/ISablierMerkleFactory.sol";
import { ISablierMerkleLT } from "../src/interfaces/ISablierMerkleLT.sol";
import { MerkleLT } from "../src/types/DataTypes.sol";
import { SablierMerkleFactoryLT } from "../src/SablierMerkleFactoryLT.sol";

import { MerkleLT } from "../src/types/DataTypes.sol";
import { BaseScript } from "./Base.s.sol";

/// @dev Creates a dummy campaign to airdrop tokens through Lockup Tranched.
contract CreateMerkleLT is BaseScript {
/// @dev Deploy via Forge.
function run() public broadcast returns (ISablierMerkleLT merkleLT) {
ISablierMerkleFactory merkleFactory = ISablierMerkleFactory(0x71DD3Ca88E7564416E5C2E350090C12Bf8F6144a);
// TODO: Load deployed addresses from Ethereum mainnet.
SablierMerkleFactoryLT merkleFactory = new SablierMerkleFactoryLT(DEFAULT_SABLIER_ADMIN, 0);

// Prepare the constructor parameters.
MerkleLT.ConstructorParams memory params;
Expand Down
5 changes: 2 additions & 3 deletions script/CreateMerkleVCA.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity >=0.8.22 <0.9.0;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { ISablierMerkleVCA } from "src/interfaces/ISablierMerkleVCA.sol";
import { SablierMerkleFactory } from "src/SablierMerkleFactory.sol";
import { SablierMerkleFactoryVCA } from "src/SablierMerkleFactoryVCA.sol";
import { MerkleVCA } from "src/types/DataTypes.sol";

import { BaseScript } from "./Base.s.sol";
Expand All @@ -13,8 +13,7 @@ contract CreateMerkleVCA is BaseScript {
/// @dev Deploy via Forge.
function run() public broadcast returns (ISablierMerkleVCA merkleVCA) {
// TODO: Load deployed addresses from Ethereum mainnet.
// ISablierMerkleFactory merkleFactory = ISablierMerkleFactory(0x71DD3Ca88E7564416E5C2E350090C12Bf8F6144a);
SablierMerkleFactory merkleFactory = new SablierMerkleFactory(DEFAULT_SABLIER_ADMIN);
SablierMerkleFactoryVCA merkleFactory = new SablierMerkleFactoryVCA(DEFAULT_SABLIER_ADMIN, 0);

// Prepare the constructor parameters.
MerkleVCA.ConstructorParams memory params;
Expand Down
32 changes: 32 additions & 0 deletions script/DeployDeterministicMerkleFactories.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.22 <0.9.0;

import { SablierMerkleFactoryInstant } from "../src/SablierMerkleFactoryInstant.sol";
import { SablierMerkleFactoryLL } from "../src/SablierMerkleFactoryLL.sol";
import { SablierMerkleFactoryLT } from "../src/SablierMerkleFactoryLT.sol";
import { SablierMerkleFactoryVCA } from "../src/SablierMerkleFactoryVCA.sol";

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

/// @notice Deploys Merkle factory contracts at deterministic address.
///
/// @dev Reverts if any contract has already been deployed.
contract DeployDeterministicMerkleFactories is BaseScript {
/// @dev Deploy via Forge.
function run(uint256 initialMinimumFee)
public
broadcast
returns (
SablierMerkleFactoryInstant merkleFactoryInstant,
SablierMerkleFactoryLL merkleFactoryLL,
SablierMerkleFactoryLT merkleFactoryLT,
SablierMerkleFactoryVCA merkleFactoryVCA
)
{
address initialAdmin = adminMap[block.chainid];
merkleFactoryInstant = new SablierMerkleFactoryInstant{ salt: SALT }(initialAdmin, initialMinimumFee);
merkleFactoryLL = new SablierMerkleFactoryLL{ salt: SALT }(initialAdmin, initialMinimumFee);
merkleFactoryLT = new SablierMerkleFactoryLT{ salt: SALT }(initialAdmin, initialMinimumFee);
merkleFactoryVCA = new SablierMerkleFactoryVCA{ salt: SALT }(initialAdmin, initialMinimumFee);
}
}
17 changes: 0 additions & 17 deletions script/DeployDeterministicMerkleFactory.s.sol

This file was deleted.

30 changes: 30 additions & 0 deletions script/DeployMerkleFactories.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.22 <0.9.0;

import { SablierMerkleFactoryInstant } from "../src/SablierMerkleFactoryInstant.sol";
import { SablierMerkleFactoryLL } from "../src/SablierMerkleFactoryLL.sol";
import { SablierMerkleFactoryLT } from "../src/SablierMerkleFactoryLT.sol";
import { SablierMerkleFactoryVCA } from "../src/SablierMerkleFactoryVCA.sol";

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

/// @notice Deploys Merkle factory contracts.
contract DeployMerkleFactories is BaseScript {
/// @dev Deploy via Forge.
function run(uint256 initialMinimumFee)
public
broadcast
returns (
SablierMerkleFactoryInstant merkleFactoryInstant,
SablierMerkleFactoryLL merkleFactoryLL,
SablierMerkleFactoryLT merkleFactoryLT,
SablierMerkleFactoryVCA merkleFactoryVCA
)
{
address initialAdmin = adminMap[block.chainid];
merkleFactoryInstant = new SablierMerkleFactoryInstant(initialAdmin, initialMinimumFee);
merkleFactoryLL = new SablierMerkleFactoryLL(initialAdmin, initialMinimumFee);
merkleFactoryLT = new SablierMerkleFactoryLT(initialAdmin, initialMinimumFee);
merkleFactoryVCA = new SablierMerkleFactoryVCA(initialAdmin, initialMinimumFee);
}
}
14 changes: 0 additions & 14 deletions script/DeployMerkleFactory.s.sol

This file was deleted.

10 changes: 8 additions & 2 deletions shell/prepare-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@ mkdir $artifacts \
"$artifacts/interfaces" \
"$artifacts/libraries"

cp out-optimized/SablierMerkleFactory.sol/SablierMerkleFactory.json $artifacts
cp out-optimized/SablierMerkleFactoryInstant.sol/SablierMerkleFactoryInstant.json $artifacts
cp out-optimized/SablierMerkleFactoryLL.sol/SablierMerkleFactoryLL.json $artifacts
cp out-optimized/SablierMerkleFactoryLT.sol/SablierMerkleFactoryLT.json $artifacts
cp out-optimized/SablierMerkleFactoryVCA.sol/SablierMerkleFactoryVCA.json $artifacts
cp out-optimized/SablierMerkleInstant.sol/SablierMerkleInstant.json $artifacts
cp out-optimized/SablierMerkleLL.sol/SablierMerkleLL.json $artifacts
cp out-optimized/SablierMerkleLT.sol/SablierMerkleLT.json $artifacts
cp out-optimized/SablierMerkleVCA.sol/SablierMerkleVCA.json $artifacts

interfaces=./artifacts/interfaces
cp out-optimized/ISablierMerkleFactory.sol/ISablierMerkleFactory.json $interfaces
cp out-optimized/ISablierMerkleFactoryInstant.sol/ISablierMerkleFactoryInstant.json $artifacts
cp out-optimized/ISablierMerkleFactoryLL.sol/ISablierMerkleFactoryLL.json $artifacts
cp out-optimized/ISablierMerkleFactoryLT.sol/ISablierMerkleFactoryLT.json $artifacts
cp out-optimized/ISablierMerkleFactoryVCA.sol/ISablierMerkleFactoryVCA.json $artifacts
cp out-optimized/ISablierMerkleInstant.sol/ISablierMerkleInstant.json $interfaces
cp out-optimized/ISablierMerkleLL.sol/ISablierMerkleLL.json $interfaces
cp out-optimized/ISablierMerkleLT.sol/ISablierMerkleLT.json $interfaces
Expand Down
Loading

0 comments on commit f060524

Please sign in to comment.