Skip to content

Commit

Permalink
refactor: move batch lockup contract in core
Browse files Browse the repository at this point in the history
  • Loading branch information
andreivladbrg committed Nov 12, 2024
1 parent 4d54d7b commit 084066c
Show file tree
Hide file tree
Showing 34 changed files with 242 additions and 240 deletions.
2 changes: 1 addition & 1 deletion precompiles/Precompiles.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
pragma solidity >=0.8.22;

import { ILockupNFTDescriptor } from "./../src/core/interfaces/ILockupNFTDescriptor.sol";
import { ISablierBatchLockup } from "./../src/core/interfaces/ISablierBatchLockup.sol";
import { ISablierLockup } from "./../src/core/interfaces/ISablierLockup.sol";
import { LockupNFTDescriptor } from "./../src/core/LockupNFTDescriptor.sol";
import { ISablierBatchLockup } from "./../src/periphery/interfaces/ISablierBatchLockup.sol";
import { ISablierMerkleFactory } from "./../src/periphery/interfaces/ISablierMerkleFactory.sol";

/// @notice This is useful for external integrations seeking to test against the exact deployed bytecode, as recompiling
Expand Down
2 changes: 1 addition & 1 deletion script/periphery/DeployBatchLockup.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.22 <0.9.0;

import { SablierBatchLockup } from "../../src/periphery/SablierBatchLockup.sol";
import { SablierBatchLockup } from "../../src/core/SablierBatchLockup.sol";

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

Expand Down
2 changes: 1 addition & 1 deletion script/periphery/DeployDeterministicBatchLockup.s.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.22 <0.9.0;

import { SablierBatchLockup } from "../../src/periphery/SablierBatchLockup.sol";
import { SablierBatchLockup } from "../../src/core/SablierBatchLockup.sol";

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

Expand Down
2 changes: 1 addition & 1 deletion script/periphery/DeployDeterministicPeriphery.s.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.22 <0.9.0;

import { SablierBatchLockup } from "../../src/periphery/SablierBatchLockup.sol";
import { SablierBatchLockup } from "../../src/core/SablierBatchLockup.sol";
import { SablierMerkleFactory } from "../../src/periphery/SablierMerkleFactory.sol";

import { BaseScript } from "../Base.s.sol";
Expand Down
2 changes: 1 addition & 1 deletion script/periphery/DeployPeriphery.s.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.22 <0.9.0;

import { SablierBatchLockup } from "./../../src/periphery/SablierBatchLockup.sol";
import { SablierBatchLockup } from "./../../src/core/SablierBatchLockup.sol";
import { SablierMerkleFactory } from "./../../src/periphery/SablierMerkleFactory.sol";
import { BaseScript } from "./../Base.s.sol";

Expand Down
9 changes: 4 additions & 5 deletions script/protocol/DeployDeterministicProtocol.s.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.22 <0.9.0;

import { LockupNFTDescriptor } from "../../src/core/LockupNFTDescriptor.sol";
import { SablierLockup } from "../../src/core/SablierLockup.sol";
import { SablierBatchLockup } from "../../src/periphery/SablierBatchLockup.sol";
import { SablierMerkleFactory } from "../../src/periphery/SablierMerkleFactory.sol";

import { LockupNFTDescriptor } from "./../../src/core/LockupNFTDescriptor.sol";
import { SablierBatchLockup } from "./../../src/core/SablierBatchLockup.sol";
import { SablierLockup } from "./../../src/core/SablierLockup.sol";
import { SablierMerkleFactory } from "./../../src/periphery/SablierMerkleFactory.sol";
import { DeploymentLogger } from "./DeploymentLogger.s.sol";

/// @notice Deploys the Lockup Protocol at deterministic addresses across chains.
Expand Down
9 changes: 4 additions & 5 deletions script/protocol/DeployProtocol.s.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.22 <0.9.0;

import { LockupNFTDescriptor } from "../../src/core/LockupNFTDescriptor.sol";
import { SablierLockup } from "../../src/core/SablierLockup.sol";
import { SablierBatchLockup } from "../../src/periphery/SablierBatchLockup.sol";
import { SablierMerkleFactory } from "../../src/periphery/SablierMerkleFactory.sol";

import { LockupNFTDescriptor } from "./../../src/core/LockupNFTDescriptor.sol";
import { SablierBatchLockup } from "./../../src/core/SablierBatchLockup.sol";
import { SablierLockup } from "./../../src/core/SablierLockup.sol";
import { SablierMerkleFactory } from "./../../src/periphery/SablierMerkleFactory.sol";
import { DeploymentLogger } from "./DeploymentLogger.s.sol";

/// @notice Deploys the Lockup Protocol.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ pragma solidity >=0.8.22;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import { ISablierLockup } from "../core/interfaces/ISablierLockup.sol";
import { Lockup } from "../core/types/DataTypes.sol";

import { ISablierBatchLockup } from "./interfaces/ISablierBatchLockup.sol";
import { ISablierLockup } from "./interfaces/ISablierLockup.sol";
import { Errors } from "./libraries/Errors.sol";
import { BatchLockup } from "./types/DataTypes.sol";
import { BatchLockup, Lockup } from "./types/DataTypes.sol";

/// @title SablierBatchLockup
/// @notice See the documentation in {ISablierBatchLockup}.
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions src/core/libraries/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ library Errors {
error CallerNotAdmin(address admin, address caller);

/// @notice Thrown when trying to delegate call to a function that disallows delegate calls.

error DelegateCall();

/*//////////////////////////////////////////////////////////////////////////
SABLIER-BATCH-LOCKUP
//////////////////////////////////////////////////////////////////////////*/

error SablierBatchLockup_BatchSizeZero();

/*//////////////////////////////////////////////////////////////////////////
LOCKUP-NFT-DESCRIPTOR
//////////////////////////////////////////////////////////////////////////*/
Expand Down
71 changes: 71 additions & 0 deletions src/core/types/DataTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,74 @@ library LockupTranched {
uint40 duration;
}
}

library BatchLockup {
/// @notice A struct encapsulating all parameters of {SablierLockup.createWithDurationsLD} except for the asset.
struct CreateWithDurationsLD {
address sender;
address recipient;
uint128 totalAmount;
bool cancelable;
bool transferable;
LockupDynamic.SegmentWithDuration[] segmentsWithDuration;
Broker broker;
}

/// @notice A struct encapsulating all parameters of {SablierLockup.createWithDurationsLL} except for the asset.
struct CreateWithDurationsLL {
address sender;
address recipient;
uint128 totalAmount;
bool cancelable;
bool transferable;
LockupLinear.Durations durations;
Broker broker;
}

/// @notice A struct encapsulating all parameters of {SablierLockup.createWithDurationsLT} except for the asset.
struct CreateWithDurationsLT {
address sender;
address recipient;
uint128 totalAmount;
bool cancelable;
bool transferable;
LockupTranched.TrancheWithDuration[] tranchesWithDuration;
Broker broker;
}

/// @notice A struct encapsulating all parameters of {SablierLockup.createWithTimestampsLD} except for the asset.
struct CreateWithTimestampsLD {
address sender;
address recipient;
uint128 totalAmount;
bool cancelable;
bool transferable;
uint40 startTime;
LockupDynamic.Segment[] segments;
Broker broker;
}

/// @notice A struct encapsulating all parameters of {SablierLockup.createWithTimestampsLL} except for the asset.
struct CreateWithTimestampsLL {
address sender;
address recipient;
uint128 totalAmount;
bool cancelable;
bool transferable;
Lockup.Timestamps timestamps;
uint40 cliffTime;
Broker broker;
}

/// @notice A struct encapsulating all parameters of {SablierLockup.createWithTimestampsLT} except for the asset.
struct CreateWithTimestampsLT {
address sender;
address recipient;
uint128 totalAmount;
bool cancelable;
bool transferable;
uint40 startTime;
LockupTranched.Tranche[] tranches;
Broker broker;
}
}
6 changes: 0 additions & 6 deletions src/periphery/libraries/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ pragma solidity >=0.8.22;
/// @title Errors
/// @notice Library containing all custom errors the protocol may revert with.
library Errors {
/*//////////////////////////////////////////////////////////////////////////
SABLIER-BATCH-LOCKUP
//////////////////////////////////////////////////////////////////////////*/

error SablierBatchLockup_BatchSizeZero();

/*//////////////////////////////////////////////////////////////////////////
SABLIER-MERKLE-FACTORY
//////////////////////////////////////////////////////////////////////////*/
Expand Down
73 changes: 0 additions & 73 deletions src/periphery/types/DataTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,6 @@ pragma solidity >=0.8.22;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { UD2x18 } from "@prb/math/src/UD2x18.sol";

import { Broker, Lockup, LockupDynamic, LockupLinear, LockupTranched } from "../../core/types/DataTypes.sol";

library BatchLockup {
/// @notice A struct encapsulating all parameters of {SablierLockup.createWithDurationsLD} except for the asset.
struct CreateWithDurationsLD {
address sender;
address recipient;
uint128 totalAmount;
bool cancelable;
bool transferable;
LockupDynamic.SegmentWithDuration[] segmentsWithDuration;
Broker broker;
}

/// @notice A struct encapsulating all parameters of {SablierLockup.createWithDurationsLL} except for the asset.
struct CreateWithDurationsLL {
address sender;
address recipient;
uint128 totalAmount;
bool cancelable;
bool transferable;
LockupLinear.Durations durations;
Broker broker;
}

/// @notice A struct encapsulating all parameters of {SablierLockup.createWithDurationsLT} except for the asset.
struct CreateWithDurationsLT {
address sender;
address recipient;
uint128 totalAmount;
bool cancelable;
bool transferable;
LockupTranched.TrancheWithDuration[] tranchesWithDuration;
Broker broker;
}

/// @notice A struct encapsulating all parameters of {SablierLockup.createWithTimestampsLD} except for the asset.
struct CreateWithTimestampsLD {
address sender;
address recipient;
uint128 totalAmount;
bool cancelable;
bool transferable;
uint40 startTime;
LockupDynamic.Segment[] segments;
Broker broker;
}

/// @notice A struct encapsulating all parameters of {SablierLockup.createWithTimestampsLL} except for the asset.
struct CreateWithTimestampsLL {
address sender;
address recipient;
uint128 totalAmount;
bool cancelable;
bool transferable;
Lockup.Timestamps timestamps;
uint40 cliffTime;
Broker broker;
}

/// @notice A struct encapsulating all parameters of {SablierLockup.createWithTimestampsLT} except for the asset.
struct CreateWithTimestampsLT {
address sender;
address recipient;
uint128 totalAmount;
bool cancelable;
bool transferable;
uint40 startTime;
LockupTranched.Tranche[] tranches;
Broker broker;
}
}

library MerkleBase {
/// @notice Struct encapsulating the base constructor parameters of a Merkle campaign.
/// @param asset The contract address of the ERC-20 asset to be distributed.
Expand Down
Loading

0 comments on commit 084066c

Please sign in to comment.