From 718074c1d3856713c620a137b2808649f022c9ff Mon Sep 17 00:00:00 2001 From: Paul Razvan Berg Date: Tue, 26 Nov 2024 18:57:32 +0000 Subject: [PATCH] refactor: add STREAM_ prefix docs: update NatSpec refactor: import from src --- remappings.txt | 3 +- script/CreateMerkleLL.s.sol | 3 +- script/CreateMerkleLT.s.sol | 3 +- src/SablierMerkleFactory.sol | 4 +- src/SablierMerkleLL.sol | 47 +++++++++++-------- src/SablierMerkleLT.sol | 20 ++++---- src/abstracts/SablierMerkleBase.sol | 2 +- src/interfaces/ISablierMerkleBase.sol | 4 +- src/interfaces/ISablierMerkleFactory.sol | 4 +- src/interfaces/ISablierMerkleInstant.sol | 2 +- src/interfaces/ISablierMerkleLL.sol | 19 ++++---- src/interfaces/ISablierMerkleLT.sol | 22 ++++----- tests/Base.t.sol | 6 +-- tests/fork/merkle-campaign/MerkleLL.t.sol | 2 +- tests/fork/merkle-campaign/MerkleLT.t.sol | 4 +- .../integration/concrete/ll/constructor.t.sol | 40 +++++++--------- .../integration/concrete/lt/constructor.t.sol | 20 ++++---- tests/utils/Assertions.sol | 2 +- tests/utils/Defaults.sol | 2 +- 19 files changed, 106 insertions(+), 103 deletions(-) diff --git a/remappings.txt b/remappings.txt index 03d3a2e..1bd6646 100644 --- a/remappings.txt +++ b/remappings.txt @@ -1,5 +1,6 @@ @openzeppelin/contracts/=node_modules/@openzeppelin/contracts/ @prb/math/=node_modules/@prb/math/ -@sablier/lockup/=node_modules/@sablier/lockup/src/ +@sablier/lockup/=node_modules/@sablier/lockup/ +@sablier/lockup-precompiles=node_modules/@sablier/lockup/precompiles/ forge-std/=node_modules/forge-std/ solady/=node_modules/solady/ diff --git a/script/CreateMerkleLL.s.sol b/script/CreateMerkleLL.s.sol index 9443f89..8f000b7 100644 --- a/script/CreateMerkleLL.s.sol +++ b/script/CreateMerkleLL.s.sol @@ -2,7 +2,8 @@ pragma solidity >=0.8.22 <0.9.0; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import { ISablierLockup } from "@sablier/lockup/interfaces/ISablierLockup.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 { MerkleBase, MerkleLL } from "../src/types/DataTypes.sol"; diff --git a/script/CreateMerkleLT.s.sol b/script/CreateMerkleLT.s.sol index ea3197d..3a6b23c 100644 --- a/script/CreateMerkleLT.s.sol +++ b/script/CreateMerkleLT.s.sol @@ -3,7 +3,8 @@ 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/interfaces/ISablierLockup.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 { MerkleBase, MerkleLT } from "../src/types/DataTypes.sol"; diff --git a/src/SablierMerkleFactory.sol b/src/SablierMerkleFactory.sol index 526c1f4..bd607c1 100644 --- a/src/SablierMerkleFactory.sol +++ b/src/SablierMerkleFactory.sol @@ -3,8 +3,8 @@ pragma solidity >=0.8.22; import { uUNIT } from "@prb/math/src/UD2x18.sol"; -import { Adminable } from "@sablier/lockup/abstracts/Adminable.sol"; -import { ISablierLockup } from "@sablier/lockup/interfaces/ISablierLockup.sol"; +import { Adminable } from "@sablier/lockup/src/abstracts/Adminable.sol"; +import { ISablierLockup } from "@sablier/lockup/src/interfaces/ISablierLockup.sol"; import { ISablierMerkleBase } from "./interfaces/ISablierMerkleBase.sol"; import { ISablierMerkleFactory } from "./interfaces/ISablierMerkleFactory.sol"; diff --git a/src/SablierMerkleLL.sol b/src/SablierMerkleLL.sol index 74477f6..882c127 100644 --- a/src/SablierMerkleLL.sol +++ b/src/SablierMerkleLL.sol @@ -4,8 +4,8 @@ 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 { ZERO } from "@prb/math/src/UD60x18.sol"; -import { ISablierLockup } from "@sablier/lockup/interfaces/ISablierLockup.sol"; -import { Broker, Lockup, LockupLinear } from "@sablier/lockup/types/DataTypes.sol"; +import { ISablierLockup } from "@sablier/lockup/src/interfaces/ISablierLockup.sol"; +import { Broker, Lockup, LockupLinear } from "@sablier/lockup/src/types/DataTypes.sol"; import { SablierMerkleBase } from "./abstracts/SablierMerkleBase.sol"; import { ISablierMerkleLL } from "./interfaces/ISablierMerkleLL.sol"; @@ -23,17 +23,17 @@ contract SablierMerkleLL is STATE VARIABLES //////////////////////////////////////////////////////////////////////////*/ - /// @inheritdoc ISablierMerkleLL - bool public immutable override CANCELABLE; - /// @inheritdoc ISablierMerkleLL ISablierLockup public immutable override LOCKUP; /// @inheritdoc ISablierMerkleLL - bool public immutable override TRANSFERABLE; + bool public immutable override STREAM_CANCELABLE; /// @inheritdoc ISablierMerkleLL - MerkleLL.Schedule public override schedule; + bool public immutable override STREAM_TRANSFERABLE; + + /// @dev See the documentation in {ISablierMerkleLL.getSchedule}. + MerkleLL.Schedule internal _schedule; /*////////////////////////////////////////////////////////////////////////// CONSTRUCTOR @@ -46,20 +46,29 @@ contract SablierMerkleLL is ISablierLockup lockup, bool cancelable, bool transferable, - MerkleLL.Schedule memory schedule_, + MerkleLL.Schedule memory schedule, uint256 fee ) SablierMerkleBase(baseParams, fee) { - CANCELABLE = cancelable; LOCKUP = lockup; - TRANSFERABLE = transferable; - schedule = schedule_; + STREAM_CANCELABLE = cancelable; + STREAM_TRANSFERABLE = transferable; + _schedule = schedule; // Max approve the Lockup contract to spend funds from the MerkleLL contract. TOKEN.forceApprove(address(LOCKUP), type(uint256).max); } + /*////////////////////////////////////////////////////////////////////////// + USER-FACING CONSTANT FUNCTIONS + //////////////////////////////////////////////////////////////////////////*/ + + /// @inheritdoc ISablierMerkleLL + function getSchedule() external view override returns (MerkleLL.Schedule memory) { + return _schedule; + } + /*////////////////////////////////////////////////////////////////////////// USER-FACING NON-CONSTANT FUNCTIONS //////////////////////////////////////////////////////////////////////////*/ @@ -68,10 +77,10 @@ contract SablierMerkleLL is function _claim(uint256 index, address recipient, uint128 amount) internal override { // Calculate the timestamps for the stream. Lockup.Timestamps memory timestamps; - if (schedule.startTime == 0) { + if (_schedule.startTime == 0) { timestamps.start = uint40(block.timestamp); } else { - timestamps.start = schedule.startTime; + timestamps.start = _schedule.startTime; } uint40 cliffTime; @@ -79,10 +88,10 @@ contract SablierMerkleLL is // It is safe to use unchecked arithmetic because the `createWithTimestamps` function in the Lockup contract // will nonetheless make the relevant checks. unchecked { - if (schedule.cliffDuration > 0) { - cliffTime = timestamps.start + schedule.cliffDuration; + if (_schedule.cliffDuration > 0) { + cliffTime = timestamps.start + _schedule.cliffDuration; } - timestamps.end = timestamps.start + schedule.totalDuration; + timestamps.end = timestamps.start + _schedule.totalDuration; } // Interaction: create the stream via {SablierLockup}. @@ -92,12 +101,12 @@ contract SablierMerkleLL is recipient: recipient, totalAmount: amount, asset: TOKEN, - cancelable: CANCELABLE, - transferable: TRANSFERABLE, + cancelable: STREAM_CANCELABLE, + transferable: STREAM_TRANSFERABLE, timestamps: timestamps, broker: Broker({ account: address(0), fee: ZERO }) }), - LockupLinear.UnlockAmounts({ start: schedule.startAmount, cliff: schedule.cliffAmount }), + LockupLinear.UnlockAmounts({ start: _schedule.startAmount, cliff: _schedule.cliffAmount }), cliffTime ); diff --git a/src/SablierMerkleLT.sol b/src/SablierMerkleLT.sol index c724e99..456afae 100644 --- a/src/SablierMerkleLT.sol +++ b/src/SablierMerkleLT.sol @@ -5,8 +5,8 @@ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { uUNIT } from "@prb/math/src/UD2x18.sol"; import { UD60x18, ud60x18, ZERO } from "@prb/math/src/UD60x18.sol"; -import { ISablierLockup } from "@sablier/lockup/interfaces/ISablierLockup.sol"; -import { Broker, Lockup, LockupTranched } from "@sablier/lockup/types/DataTypes.sol"; +import { ISablierLockup } from "@sablier/lockup/src/interfaces/ISablierLockup.sol"; +import { Broker, Lockup, LockupTranched } from "@sablier/lockup/src/types/DataTypes.sol"; import { SablierMerkleBase } from "./abstracts/SablierMerkleBase.sol"; import { ISablierMerkleLT } from "./interfaces/ISablierMerkleLT.sol"; @@ -26,19 +26,19 @@ contract SablierMerkleLT is //////////////////////////////////////////////////////////////////////////*/ /// @inheritdoc ISablierMerkleLT - bool public immutable override CANCELABLE; + ISablierLockup public immutable override LOCKUP; /// @inheritdoc ISablierMerkleLT - ISablierLockup public immutable override LOCKUP; + bool public immutable override STREAM_CANCELABLE; /// @inheritdoc ISablierMerkleLT uint40 public immutable override STREAM_START_TIME; /// @inheritdoc ISablierMerkleLT - uint64 public immutable override TOTAL_PERCENTAGE; + bool public immutable override STREAM_TRANSFERABLE; /// @inheritdoc ISablierMerkleLT - bool public immutable override TRANSFERABLE; + uint64 public immutable override TOTAL_PERCENTAGE; /// @dev The tranches with their respective unlock percentages and durations. MerkleLT.TrancheWithPercentage[] internal _tranchesWithPercentages; @@ -60,10 +60,10 @@ contract SablierMerkleLT is ) SablierMerkleBase(baseParams, fee) { - CANCELABLE = cancelable; + STREAM_CANCELABLE = cancelable; LOCKUP = lockup; STREAM_START_TIME = streamStartTime; - TRANSFERABLE = transferable; + STREAM_TRANSFERABLE = transferable; uint256 count = tranchesWithPercentages.length; @@ -116,8 +116,8 @@ contract SablierMerkleLT is recipient: recipient, totalAmount: amount, asset: TOKEN, - cancelable: CANCELABLE, - transferable: TRANSFERABLE, + cancelable: STREAM_CANCELABLE, + transferable: STREAM_TRANSFERABLE, timestamps: Lockup.Timestamps({ start: startTime, end: endTime }), broker: Broker({ account: address(0), fee: ZERO }) }), diff --git a/src/abstracts/SablierMerkleBase.sol b/src/abstracts/SablierMerkleBase.sol index b843382..8c31a35 100644 --- a/src/abstracts/SablierMerkleBase.sol +++ b/src/abstracts/SablierMerkleBase.sol @@ -5,7 +5,7 @@ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { MerkleProof } from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import { BitMaps } from "@openzeppelin/contracts/utils/structs/BitMaps.sol"; -import { Adminable } from "@sablier/lockup/abstracts/Adminable.sol"; +import { Adminable } from "@sablier/lockup/src/abstracts/Adminable.sol"; import { ISablierMerkleBase } from "./../interfaces/ISablierMerkleBase.sol"; import { Errors } from "./../libraries/Errors.sol"; diff --git a/src/interfaces/ISablierMerkleBase.sol b/src/interfaces/ISablierMerkleBase.sol index a92bd1e..777d436 100644 --- a/src/interfaces/ISablierMerkleBase.sol +++ b/src/interfaces/ISablierMerkleBase.sol @@ -2,10 +2,10 @@ pragma solidity >=0.8.22; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import { IAdminable } from "@sablier/lockup/interfaces/IAdminable.sol"; +import { IAdminable } from "@sablier/lockup/src/interfaces/IAdminable.sol"; /// @title ISablierMerkleBase -/// @dev This is the base interface for Merkle Lockups and Merkle Instant. +/// @dev Common interface between Merkle Lockups and Merkle Instant. interface ISablierMerkleBase is IAdminable { /*////////////////////////////////////////////////////////////////////////// EVENTS diff --git a/src/interfaces/ISablierMerkleFactory.sol b/src/interfaces/ISablierMerkleFactory.sol index 73d8a4e..f7fc591 100644 --- a/src/interfaces/ISablierMerkleFactory.sol +++ b/src/interfaces/ISablierMerkleFactory.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.22; -import { IAdminable } from "@sablier/lockup/interfaces/IAdminable.sol"; -import { ISablierLockup } from "@sablier/lockup/interfaces/ISablierLockup.sol"; +import { IAdminable } from "@sablier/lockup/src/interfaces/IAdminable.sol"; +import { ISablierLockup } from "@sablier/lockup/src/interfaces/ISablierLockup.sol"; import { ISablierMerkleBase } from "../interfaces/ISablierMerkleBase.sol"; import { MerkleBase, MerkleFactory, MerkleLL, MerkleLT } from "../types/DataTypes.sol"; diff --git a/src/interfaces/ISablierMerkleInstant.sol b/src/interfaces/ISablierMerkleInstant.sol index 002aa2a..f6db854 100644 --- a/src/interfaces/ISablierMerkleInstant.sol +++ b/src/interfaces/ISablierMerkleInstant.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.22; import { ISablierMerkleBase } from "./ISablierMerkleBase.sol"; /// @title ISablierMerkleInstant -/// @notice MerkleInstant enables instant airdrop campaigns. +/// @notice MerkleInstant enables airdrop distributions where the tokens are claimed directly to the users' wallets. interface ISablierMerkleInstant is ISablierMerkleBase { /*////////////////////////////////////////////////////////////////////////// EVENTS diff --git a/src/interfaces/ISablierMerkleLL.sol b/src/interfaces/ISablierMerkleLL.sol index cc3628b..2a87e96 100644 --- a/src/interfaces/ISablierMerkleLL.sol +++ b/src/interfaces/ISablierMerkleLL.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.22; -import { ISablierLockup } from "@sablier/lockup/interfaces/ISablierLockup.sol"; - +import { ISablierLockup } from "@sablier/lockup/src/interfaces/ISablierLockup.sol"; +import { MerkleLL } from "./../types/DataTypes.sol"; import { ISablierMerkleBase } from "./ISablierMerkleBase.sol"; /// @title ISablierMerkleLL -/// @notice Merkle Lockup campaign that creates Lockup Linear streams. +/// @notice Merkle Lockup enables airdrops with a vesting period powered by the Lockup Linear distribution model. interface ISablierMerkleLL is ISablierMerkleBase { /*////////////////////////////////////////////////////////////////////////// EVENTS @@ -21,20 +21,17 @@ interface ISablierMerkleLL is ISablierMerkleBase { /// @notice A flag indicating whether the streams can be canceled. /// @dev This is an immutable state variable. - function CANCELABLE() external returns (bool); + function STREAM_CANCELABLE() external returns (bool); /// @notice The address of the {SablierLockup} contract. function LOCKUP() external view returns (ISablierLockup); /// @notice A flag indicating whether the stream NFTs are transferable. /// @dev This is an immutable state variable. - function TRANSFERABLE() external returns (bool); + function STREAM_TRANSFERABLE() external returns (bool); - /// @notice The start time, start unlock amount, cliff duration, cliff unlock amount and the end duration used to - /// calculate the vesting schedule in `Lockup.CreateWithTimestampsLL`. + /// @notice A tuple containing the start time, start unlock amount, cliff duration, cliff unlock amount, and end + /// duration. These values are used to calculate the vesting schedule in `Lockup.CreateWithTimestampsLL`. /// @dev A start time value of zero will be considered as `block.timestamp`. - function schedule() - external - view - returns (uint40 startTime, uint128 startAmount, uint40 cliffDuration, uint128 cliffAmount, uint40 endDuration); + function getSchedule() external view returns (MerkleLL.Schedule memory); } diff --git a/src/interfaces/ISablierMerkleLT.sol b/src/interfaces/ISablierMerkleLT.sol index fa6cb17..e246728 100644 --- a/src/interfaces/ISablierMerkleLT.sol +++ b/src/interfaces/ISablierMerkleLT.sol @@ -1,13 +1,13 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.22; -import { ISablierLockup } from "@sablier/lockup/interfaces/ISablierLockup.sol"; +import { ISablierLockup } from "@sablier/lockup/src/interfaces/ISablierLockup.sol"; import { MerkleLT } from "./../types/DataTypes.sol"; import { ISablierMerkleBase } from "./ISablierMerkleBase.sol"; /// @title ISablierMerkleLT -/// @notice Merkle Lockup campaign that creates Lockup Tranched streams. +/// @notice Merkle Lockup enables airdrops with a vesting period powered by the Lockup Tranched distribution model. interface ISablierMerkleLT is ISablierMerkleBase { /*////////////////////////////////////////////////////////////////////////// EVENTS @@ -20,23 +20,23 @@ interface ISablierMerkleLT is ISablierMerkleBase { CONSTANT FUNCTIONS //////////////////////////////////////////////////////////////////////////*/ - /// @notice A flag indicating whether the streams can be canceled. - /// @dev This is an immutable state variable. - function CANCELABLE() external returns (bool); - /// @notice The address of the {SablierLockup} contract. function LOCKUP() external view returns (ISablierLockup); + /// @notice A flag indicating whether the streams can be canceled. + /// @dev This is an immutable state variable. + function STREAM_CANCELABLE() external returns (bool); + /// @notice The start time of the streams created through {SablierMerkleBase.claim} function. - /// @dev A start time value of zero will be considered as `block.timestamp`. + /// @dev A start time value of zero will be treated as `block.timestamp`. function STREAM_START_TIME() external returns (uint40); - /// @notice The total percentage of the tranches. - function TOTAL_PERCENTAGE() external view returns (uint64); - /// @notice A flag indicating whether the stream NFTs are transferable. /// @dev This is an immutable state variable. - function TRANSFERABLE() external returns (bool); + function STREAM_TRANSFERABLE() external returns (bool); + + /// @notice The total percentage of the tranches. + function TOTAL_PERCENTAGE() external view returns (uint64); /// @notice Retrieves the tranches with their respective unlock percentages and durations. function getTranchesWithPercentages() external view returns (MerkleLT.TrancheWithPercentage[] memory); diff --git a/tests/Base.t.sol b/tests/Base.t.sol index aff3b03..6c0a25c 100644 --- a/tests/Base.t.sol +++ b/tests/Base.t.sol @@ -2,9 +2,9 @@ pragma solidity >=0.8.22 <0.9.0; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import { ISablierLockup } from "@sablier/lockup/interfaces/ISablierLockup.sol"; -import { LockupNFTDescriptor } from "@sablier/lockup/LockupNFTDescriptor.sol"; -import { SablierLockup } from "@sablier/lockup/SablierLockup.sol"; +import { ISablierLockup } from "@sablier/lockup/src/interfaces/ISablierLockup.sol"; +import { LockupNFTDescriptor } from "@sablier/lockup/src/LockupNFTDescriptor.sol"; +import { SablierLockup } from "@sablier/lockup/src/SablierLockup.sol"; import { ISablierMerkleBase } from "src/interfaces/ISablierMerkleBase.sol"; import { ISablierMerkleFactory } from "src/interfaces/ISablierMerkleFactory.sol"; import { ISablierMerkleInstant } from "src/interfaces/ISablierMerkleInstant.sol"; diff --git a/tests/fork/merkle-campaign/MerkleLL.t.sol b/tests/fork/merkle-campaign/MerkleLL.t.sol index dae1206..4d2baba 100644 --- a/tests/fork/merkle-campaign/MerkleLL.t.sol +++ b/tests/fork/merkle-campaign/MerkleLL.t.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.22 <0.9.0; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { Arrays } from "@openzeppelin/contracts/utils/Arrays.sol"; -import { Lockup } from "@sablier/lockup/types/DataTypes.sol"; +import { Lockup } from "@sablier/lockup/src/types/DataTypes.sol"; import { ISablierMerkleFactory } from "src/interfaces/ISablierMerkleFactory.sol"; import { ISablierMerkleBase, ISablierMerkleLL } from "src/interfaces/ISablierMerkleLL.sol"; diff --git a/tests/fork/merkle-campaign/MerkleLT.t.sol b/tests/fork/merkle-campaign/MerkleLT.t.sol index efc8f4d..cb6cbc5 100644 --- a/tests/fork/merkle-campaign/MerkleLT.t.sol +++ b/tests/fork/merkle-campaign/MerkleLT.t.sol @@ -3,8 +3,8 @@ pragma solidity >=0.8.22 <0.9.0; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { Arrays } from "@openzeppelin/contracts/utils/Arrays.sol"; -import { LockupTranched } from "@sablier/lockup//types/DataTypes.sol"; -import { Lockup } from "@sablier/lockup/types/DataTypes.sol"; +import { LockupTranched } from "@sablier/lockup/src/types/DataTypes.sol"; +import { Lockup } from "@sablier/lockup/src/types/DataTypes.sol"; import { ISablierMerkleFactory } from "src/interfaces/ISablierMerkleFactory.sol"; import { ISablierMerkleBase, ISablierMerkleLT } from "src/interfaces/ISablierMerkleLT.sol"; import { MerkleBase } from "src/types/DataTypes.sol"; diff --git a/tests/integration/concrete/ll/constructor.t.sol b/tests/integration/concrete/ll/constructor.t.sol index 9ca66a4..f679d5a 100644 --- a/tests/integration/concrete/ll/constructor.t.sol +++ b/tests/integration/concrete/ll/constructor.t.sol @@ -11,30 +11,30 @@ contract Constructor_MerkleLL_Integration_Test is Integration_Test { struct Vars { address actualAdmin; uint256 actualAllowance; - bool actualCancelable; uint40 actualExpiration; address actualFactory; + uint256 actualFee; string actualIpfsCID; address actualLockup; bytes32 actualMerkleRoot; string actualName; - uint256 actualFee; + bool actualStreamCancelable; MerkleLL.Schedule actualSchedule; + bool actualStreamTransferable; address actualToken; - bool actualTransferable; address expectedAdmin; uint256 expectedAllowance; - bool expectedCancelable; + bool expectedStreamCancelable; uint40 expectedExpiration; address expectedFactory; + uint256 expectedFee; string expectedIpfsCID; address expectedLockup; bytes32 expectedMerkleRoot; bytes32 expectedName; - uint256 expectedFee; MerkleLL.Schedule expectedSchedule; + bool expectedStreamTransferable; address expectedToken; - bool expectedTransferable; } function test_Constructor() external { @@ -60,13 +60,9 @@ contract Constructor_MerkleLL_Integration_Test is Integration_Test { vars.expectedAllowance = MAX_UINT256; assertEq(vars.actualAllowance, vars.expectedAllowance, "allowance"); - vars.actualToken = address(constructedLL.TOKEN()); - vars.expectedToken = address(dai); - assertEq(vars.actualToken, vars.expectedToken, "token"); - - vars.actualCancelable = constructedLL.CANCELABLE(); - vars.expectedCancelable = defaults.CANCELABLE(); - assertEq(vars.actualCancelable, vars.expectedCancelable, "cancelable"); + vars.actualStreamCancelable = constructedLL.STREAM_CANCELABLE(); + vars.expectedStreamCancelable = defaults.CANCELABLE(); + assertEq(vars.actualStreamCancelable, vars.expectedStreamCancelable, "cancelable"); vars.actualExpiration = constructedLL.EXPIRATION(); vars.expectedExpiration = defaults.EXPIRATION(); @@ -92,13 +88,7 @@ contract Constructor_MerkleLL_Integration_Test is Integration_Test { vars.expectedName = defaults.NAME_BYTES32(); assertEq(bytes32(abi.encodePacked(vars.actualName)), vars.expectedName, "name"); - ( - vars.actualSchedule.startTime, - vars.actualSchedule.startAmount, - vars.actualSchedule.cliffDuration, - vars.actualSchedule.cliffAmount, - vars.actualSchedule.totalDuration - ) = constructedLL.schedule(); + vars.actualSchedule = constructedLL.getSchedule(); vars.expectedSchedule = defaults.schedule(); assertEq(vars.actualSchedule.startTime, vars.expectedSchedule.startTime, "schedule.startTime"); assertEq(vars.actualSchedule.startAmount, vars.expectedSchedule.startAmount, "schedule.startAmount"); @@ -106,9 +96,13 @@ contract Constructor_MerkleLL_Integration_Test is Integration_Test { assertEq(vars.actualSchedule.cliffAmount, vars.expectedSchedule.cliffAmount, "schedule.cliffAmount"); assertEq(vars.actualSchedule.totalDuration, vars.expectedSchedule.totalDuration, "schedule.totalDuration"); - vars.actualTransferable = constructedLL.TRANSFERABLE(); - vars.expectedTransferable = defaults.TRANSFERABLE(); - assertEq(vars.actualTransferable, vars.expectedTransferable, "transferable"); + vars.actualToken = address(constructedLL.TOKEN()); + vars.expectedToken = address(dai); + assertEq(vars.actualToken, vars.expectedToken, "token"); + + vars.actualStreamTransferable = constructedLL.STREAM_TRANSFERABLE(); + vars.expectedStreamTransferable = defaults.TRANSFERABLE(); + assertEq(vars.actualStreamTransferable, vars.expectedStreamTransferable, "transferable"); vars.actualFee = constructedLL.FEE(); vars.expectedFee = defaults.FEE(); diff --git a/tests/integration/concrete/lt/constructor.t.sol b/tests/integration/concrete/lt/constructor.t.sol index d4fc645..4b3b1c4 100644 --- a/tests/integration/concrete/lt/constructor.t.sol +++ b/tests/integration/concrete/lt/constructor.t.sol @@ -11,7 +11,6 @@ contract Constructor_MerkleLT_Integration_Test is Integration_Test { struct Vars { address actualAdmin; uint256 actualAllowance; - bool actualCancelable; uint40 actualExpiration; address actualFactory; string actualIpfsCID; @@ -19,14 +18,14 @@ contract Constructor_MerkleLT_Integration_Test is Integration_Test { bytes32 actualMerkleRoot; string actualName; uint256 actualFee; + bool actualStreamCancelable; uint40 actualStreamStartTime; + bool actualStreamTransferable; address actualToken; uint64 actualTotalPercentage; MerkleLT.TrancheWithPercentage[] actualTranchesWithPercentages; - bool actualTransferable; address expectedAdmin; uint256 expectedAllowance; - bool expectedCancelable; uint40 expectedExpiration; address expectedFactory; string expectedIpfsCID; @@ -34,11 +33,12 @@ contract Constructor_MerkleLT_Integration_Test is Integration_Test { bytes32 expectedMerkleRoot; bytes32 expectedName; uint256 expectedFee; + bool expectedStreamCancelable; uint40 expectedStreamStartTime; + bool expectedStreamTransferable; address expectedToken; uint64 expectedTotalPercentage; MerkleLT.TrancheWithPercentage[] expectedTranchesWithPercentages; - bool expectedTransferable; } function test_Constructor() external { @@ -69,9 +69,9 @@ contract Constructor_MerkleLT_Integration_Test is Integration_Test { vars.expectedToken = address(dai); assertEq(vars.actualToken, vars.expectedToken, "token"); - vars.actualCancelable = constructedLT.CANCELABLE(); - vars.expectedCancelable = defaults.CANCELABLE(); - assertEq(vars.actualCancelable, vars.expectedCancelable, "cancelable"); + vars.actualStreamCancelable = constructedLT.STREAM_CANCELABLE(); + vars.expectedStreamCancelable = defaults.CANCELABLE(); + assertEq(vars.actualStreamCancelable, vars.expectedStreamCancelable, "cancelable"); vars.actualExpiration = constructedLT.EXPIRATION(); vars.expectedExpiration = defaults.EXPIRATION(); @@ -109,9 +109,9 @@ contract Constructor_MerkleLT_Integration_Test is Integration_Test { vars.expectedTotalPercentage = defaults.TOTAL_PERCENTAGE(); assertEq(vars.actualTotalPercentage, vars.expectedTotalPercentage, "totalPercentage"); - vars.actualTransferable = constructedLT.TRANSFERABLE(); - vars.expectedTransferable = defaults.TRANSFERABLE(); - assertEq(vars.actualTransferable, vars.expectedTransferable, "transferable"); + vars.actualStreamTransferable = constructedLT.STREAM_TRANSFERABLE(); + vars.expectedStreamTransferable = defaults.TRANSFERABLE(); + assertEq(vars.actualStreamTransferable, vars.expectedStreamTransferable, "transferable"); vars.actualTranchesWithPercentages = constructedLT.getTranchesWithPercentages(); vars.expectedTranchesWithPercentages = defaults.tranchesWithPercentages(); diff --git a/tests/utils/Assertions.sol b/tests/utils/Assertions.sol index 905441f..737ae63 100644 --- a/tests/utils/Assertions.sol +++ b/tests/utils/Assertions.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.22; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { PRBMathAssertions } from "@prb/math/test/utils/Assertions.sol"; -import { Lockup, LockupTranched } from "@sablier/lockup/types/DataTypes.sol"; +import { Lockup, LockupTranched } from "@sablier/lockup/src/types/DataTypes.sol"; import { MerkleLT } from "../../src/types/DataTypes.sol"; diff --git a/tests/utils/Defaults.sol b/tests/utils/Defaults.sol index f1ea179..97710d5 100644 --- a/tests/utils/Defaults.sol +++ b/tests/utils/Defaults.sol @@ -5,7 +5,7 @@ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { Arrays } from "@openzeppelin/contracts/utils/Arrays.sol"; import { ud2x18, uUNIT } from "@prb/math/src/UD2x18.sol"; import { ud } from "@prb/math/src/UD60x18.sol"; -import { LockupTranched } from "@sablier/lockup/types/DataTypes.sol"; +import { LockupTranched } from "@sablier/lockup/src/types/DataTypes.sol"; import { MerkleBase, MerkleLL, MerkleLT } from "../../src/types/DataTypes.sol";