diff --git a/bun.lockb b/bun.lockb index 47adad30..2ba27d49 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index b7bad1e6..619373c5 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "dependencies": { "@openzeppelin/contracts": "4.9.2", "@prb/math": "4.0.2", - "@sablier/v2-core": "1.1.2" + "@sablier/v2-core": "github:sablier-labs/v2-core#staging" }, "devDependencies": { "@prb/test": "0.6.4", diff --git a/src/SablierV2Batch.sol b/src/SablierV2Batch.sol index d8666326..12ff58e6 100644 --- a/src/SablierV2Batch.sol +++ b/src/SablierV2Batch.sol @@ -21,10 +21,10 @@ contract SablierV2Batch is ISablierV2Batch { //////////////////////////////////////////////////////////////////////////*/ /// @inheritdoc ISablierV2Batch - function createWithDurations( + function createWithDurationsLL( ISablierV2LockupLinear lockupLinear, IERC20 asset, - Batch.CreateWithDurations[] calldata batch + Batch.CreateWithDurationsLL[] calldata batch ) external override @@ -69,10 +69,10 @@ contract SablierV2Batch is ISablierV2Batch { } /// @inheritdoc ISablierV2Batch - function createWithRange( + function createWithTimestampsLL( ISablierV2LockupLinear lockupLinear, IERC20 asset, - Batch.CreateWithRange[] calldata batch + Batch.CreateWithTimestampsLL[] calldata batch ) external override @@ -101,8 +101,8 @@ contract SablierV2Batch is ISablierV2Batch { streamIds = new uint256[](batchSize); for (i = 0; i < batchSize; ++i) { // Create the stream. - streamIds[i] = lockupLinear.createWithRange( - LockupLinear.CreateWithRange({ + streamIds[i] = lockupLinear.createWithTimestamps( + LockupLinear.CreateWithTimestamps({ sender: batch[i].sender, recipient: batch[i].recipient, totalAmount: batch[i].totalAmount, @@ -121,10 +121,10 @@ contract SablierV2Batch is ISablierV2Batch { //////////////////////////////////////////////////////////////////////////*/ /// @inheritdoc ISablierV2Batch - function createWithDeltas( + function createWithDurationsLD( ISablierV2LockupDynamic lockupDynamic, IERC20 asset, - Batch.CreateWithDeltas[] calldata batch + Batch.CreateWithDurationsLD[] calldata batch ) external override @@ -153,8 +153,8 @@ contract SablierV2Batch is ISablierV2Batch { streamIds = new uint256[](batchSize); for (i = 0; i < batchSize; ++i) { // Create the stream. - streamIds[i] = lockupDynamic.createWithDeltas( - LockupDynamic.CreateWithDeltas({ + streamIds[i] = lockupDynamic.createWithDurations( + LockupDynamic.CreateWithDurations({ sender: batch[i].sender, recipient: batch[i].recipient, totalAmount: batch[i].totalAmount, @@ -169,10 +169,10 @@ contract SablierV2Batch is ISablierV2Batch { } /// @inheritdoc ISablierV2Batch - function createWithMilestones( + function createWithTimestampsLD( ISablierV2LockupDynamic lockupDynamic, IERC20 asset, - Batch.CreateWithMilestones[] calldata batch + Batch.CreateWithTimestampsLD[] calldata batch ) external override @@ -201,8 +201,8 @@ contract SablierV2Batch is ISablierV2Batch { streamIds = new uint256[](batchSize); for (i = 0; i < batchSize; ++i) { // Create the stream. - streamIds[i] = lockupDynamic.createWithMilestones( - LockupDynamic.CreateWithMilestones({ + streamIds[i] = lockupDynamic.createWithTimestamps( + LockupDynamic.CreateWithTimestamps({ sender: batch[i].sender, recipient: batch[i].recipient, totalAmount: batch[i].totalAmount, diff --git a/src/interfaces/ISablierV2Batch.sol b/src/interfaces/ISablierV2Batch.sol index f7d328a4..7b3512a4 100644 --- a/src/interfaces/ISablierV2Batch.sol +++ b/src/interfaces/ISablierV2Batch.sol @@ -25,29 +25,29 @@ interface ISablierV2Batch { /// @param batch An array of structs, each encapsulating a subset of the parameters of /// {SablierV2LockupLinear.createWithDurations}. /// @return streamIds The ids of the newly created streams. - function createWithDurations( + function createWithDurationsLL( ISablierV2LockupLinear lockupLinear, IERC20 asset, - Batch.CreateWithDurations[] calldata batch + Batch.CreateWithDurationsLL[] calldata batch ) external returns (uint256[] memory streamIds); - /// @notice Creates a batch of Lockup Linear streams using `createWithRange`. + /// @notice Creates a batch of Lockup Linear streams using `createWithTimestamps`. /// /// @dev Requirements: /// - There must be at least one element in `batch`. - /// - All requirements from {ISablierV2LockupLinear.createWithRange} must be met for each stream. + /// - All requirements from {ISablierV2LockupLinear.createWithTimestamps} must be met for each stream. /// /// @param lockupLinear The address of the {SablierV2LockupLinear} contract. /// @param asset The contract address of the ERC-20 asset used for streaming. /// @param batch An array of structs, each encapsulating a subset of the parameters of - /// {SablierV2LockupLinear.createWithRange}. + /// {SablierV2LockupLinear.createWithTimestamps}. /// @return streamIds The ids of the newly created streams. - function createWithRange( + function createWithTimestampsLL( ISablierV2LockupLinear lockupLinear, IERC20 asset, - Batch.CreateWithRange[] calldata batch + Batch.CreateWithTimestampsLL[] calldata batch ) external returns (uint256[] memory streamIds); @@ -56,40 +56,40 @@ interface ISablierV2Batch { SABLIER-V2-LOCKUP-DYNAMIC //////////////////////////////////////////////////////////////////////////*/ - /// @notice Creates a batch of Lockup Dynamic streams using `createWithDeltas`. + /// @notice Creates a batch of Lockup Dynamic streams using `createWithDurations`. /// /// @dev Requirements: /// - There must be at least one element in `batch`. - /// - All requirements from {ISablierV2LockupDynamic.createWithDeltas} must be met for each stream. + /// - All requirements from {ISablierV2LockupDynamic.createWithDurations} must be met for each stream. /// /// @param lockupDynamic The address of the {SablierV2LockupDynamic} contract. /// @param asset The contract address of the ERC-20 asset used for streaming. /// @param batch An array of structs, each encapsulating a subset of the parameters of - /// {SablierV2LockupDynamic.createWithDeltas}. + /// {SablierV2LockupDynamic.createWithDurations}. /// @return streamIds The ids of the newly created streams. - function createWithDeltas( + function createWithDurationsLD( ISablierV2LockupDynamic lockupDynamic, IERC20 asset, - Batch.CreateWithDeltas[] calldata batch + Batch.CreateWithDurationsLD[] calldata batch ) external returns (uint256[] memory streamIds); - /// @notice Creates a batch of Lockup Dynamic streams using `createWithMilestones`. + /// @notice Creates a batch of Lockup Dynamic streams using `createWithTimestamps`. /// /// @dev Requirements: /// - There must be at least one element in `batch`. - /// - All requirements from {ISablierV2LockupDynamic.createWithMilestones} must be met for each stream. + /// - All requirements from {ISablierV2LockupDynamic.createWithTimestamps} must be met for each stream. /// /// @param lockupDynamic The address of the {SablierV2LockupDynamic} contract. /// @param asset The contract address of the ERC-20 asset used for streaming. /// @param batch An array of structs, each encapsulating a subset of the parameters of - /// {SablierV2LockupDynamic.createWithMilestones}. + /// {SablierV2LockupDynamic.createWithTimestamps}. /// @return streamIds The ids of the newly created streams. - function createWithMilestones( + function createWithTimestampsLD( ISablierV2LockupDynamic lockupDynamic, IERC20 asset, - Batch.CreateWithMilestones[] calldata batch + Batch.CreateWithTimestampsLD[] calldata batch ) external returns (uint256[] memory streamIds); diff --git a/src/types/DataTypes.sol b/src/types/DataTypes.sol index e4e3f6ea..ca2d63ec 100644 --- a/src/types/DataTypes.sol +++ b/src/types/DataTypes.sol @@ -11,20 +11,21 @@ library Batch { uint256[] streamIds; } - /// @notice A struct encapsulating all parameters of {SablierV2LockupDynamic.createWithDelta} except for the asset. - struct CreateWithDeltas { + /// @notice A struct encapsulating all parameters of {SablierV2LockupDynamic.createWithDurations} except for the + /// asset. + struct CreateWithDurationsLD { address sender; address recipient; uint128 totalAmount; bool cancelable; bool transferable; - LockupDynamic.SegmentWithDelta[] segments; + LockupDynamic.SegmentWithDuration[] segments; Broker broker; } /// @notice A struct encapsulating all parameters of {SablierV2LockupLinear.createWithDurations} except for the /// asset. - struct CreateWithDurations { + struct CreateWithDurationsLL { address sender; address recipient; uint128 totalAmount; @@ -34,9 +35,9 @@ library Batch { Broker broker; } - /// @notice A struct encapsulating all parameters of {SablierV2LockupDynamic.createWithMilestones} except for the + /// @notice A struct encapsulating all parameters of {SablierV2LockupDynamic.createWithTimestamps} except for the /// asset. - struct CreateWithMilestones { + struct CreateWithTimestampsLD { address sender; address recipient; uint128 totalAmount; @@ -47,8 +48,9 @@ library Batch { Broker broker; } - /// @notice A struct encapsulating all parameters of {SablierV2LockupLinear.createWithRange} except for the asset. - struct CreateWithRange { + /// @notice A struct encapsulating all parameters of {SablierV2LockupLinear.createWithTimestamps} except for the + /// asset. + struct CreateWithTimestampsLL { address sender; address recipient; uint128 totalAmount; diff --git a/test/Base.t.sol b/test/Base.t.sol index 8a8b1045..164b60c5 100644 --- a/test/Base.t.sol +++ b/test/Base.t.sol @@ -111,35 +111,35 @@ abstract contract Base_Test is DeployOptimized, Events, Merkle, V2CoreAssertions CALL EXPECTS //////////////////////////////////////////////////////////////////////////*/ - /// @dev Expects a call to {ISablierV2LockupDynamic.createWithDeltas}. - function expectCallToCreateWithDeltas(LockupDynamic.CreateWithDeltas memory params) internal { + /// @dev Expects a call to {ISablierV2LockupDynamic.createWithDurations}. + function expectCallToCreateWithDurationsLD(LockupDynamic.CreateWithDurations memory params) internal { vm.expectCall({ callee: address(lockupDynamic), - data: abi.encodeCall(ISablierV2LockupDynamic.createWithDeltas, (params)) + data: abi.encodeCall(ISablierV2LockupDynamic.createWithDurations, (params)) }); } /// @dev Expects a call to {ISablierV2LockupLinear.createWithDurations}. - function expectCallToCreateWithDurations(LockupLinear.CreateWithDurations memory params) internal { + function expectCallToCreateWithDurationsLL(LockupLinear.CreateWithDurations memory params) internal { vm.expectCall({ callee: address(lockupLinear), data: abi.encodeCall(ISablierV2LockupLinear.createWithDurations, (params)) }); } - /// @dev Expects a call to {ISablierV2LockupDynamic.createWithMilestones}. - function expectCallToCreateWithMilestones(LockupDynamic.CreateWithMilestones memory params) internal { + /// @dev Expects a call to {ISablierV2LockupDynamic.createWithTimestamps}. + function expectCallToCreateWithTimestampsLD(LockupDynamic.CreateWithTimestamps memory params) internal { vm.expectCall({ callee: address(lockupDynamic), - data: abi.encodeCall(ISablierV2LockupDynamic.createWithMilestones, (params)) + data: abi.encodeCall(ISablierV2LockupDynamic.createWithTimestamps, (params)) }); } - /// @dev Expects a call to {ISablierV2LockupLinear.createWithRange}. - function expectCallToCreateWithRange(LockupLinear.CreateWithRange memory params) internal { + /// @dev Expects a call to {ISablierV2LockupLinear.createWithTimestamps}. + function expectCallToCreateWithTimestampsLL(LockupLinear.CreateWithTimestamps memory params) internal { vm.expectCall({ callee: address(lockupLinear), - data: abi.encodeCall(ISablierV2LockupLinear.createWithRange, (params)) + data: abi.encodeCall(ISablierV2LockupLinear.createWithTimestamps, (params)) }); } @@ -163,24 +163,24 @@ abstract contract Base_Test is DeployOptimized, Events, Merkle, V2CoreAssertions vm.expectCall({ callee: asset_, data: abi.encodeCall(IERC20.transferFrom, (from, to, amount)) }); } - /// @dev Expects multiple calls to {ISablierV2LockupDynamic.createWithDeltas}, each with the specified + /// @dev Expects multiple calls to {ISablierV2LockupDynamic.createWithDurations}, each with the specified /// `params`. - function expectMultipleCallsToCreateWithDeltas( + function expectMultipleCallsToCreateWithDurationsLD( uint64 count, - LockupDynamic.CreateWithDeltas memory params + LockupDynamic.CreateWithDurations memory params ) internal { vm.expectCall({ callee: address(lockupDynamic), count: count, - data: abi.encodeCall(ISablierV2LockupDynamic.createWithDeltas, (params)) + data: abi.encodeCall(ISablierV2LockupDynamic.createWithDurations, (params)) }); } - /// @dev Expects multiple calls to {ISablierV2LockupDynamic.createWithDurations}, each with the specified + /// @dev Expects multiple calls to {ISablierV2LockupLinear.createWithDurations}, each with the specified /// `params`. - function expectMultipleCallsToCreateWithDurations( + function expectMultipleCallsToCreateWithDurationsLL( uint64 count, LockupLinear.CreateWithDurations memory params ) @@ -193,28 +193,33 @@ abstract contract Base_Test is DeployOptimized, Events, Merkle, V2CoreAssertions }); } - /// @dev Expects multiple calls to {ISablierV2LockupDynamic.createWithMilestones}, each with the specified + /// @dev Expects multiple calls to {ISablierV2LockupDynamic.createWithTimestamps}, each with the specified /// `params`. - function expectMultipleCallsToCreateWithMilestones( + function expectMultipleCallsToCreateWithTimestampsLD( uint64 count, - LockupDynamic.CreateWithMilestones memory params + LockupDynamic.CreateWithTimestamps memory params ) internal { vm.expectCall({ callee: address(lockupDynamic), count: count, - data: abi.encodeCall(ISablierV2LockupDynamic.createWithMilestones, (params)) + data: abi.encodeCall(ISablierV2LockupDynamic.createWithTimestamps, (params)) }); } - /// @dev Expects multiple calls to {ISablierV2LockupDynamic.createWithRange}, each with the specified + /// @dev Expects multiple calls to {ISablierV2LockupLinear.createWithTimestamps}, each with the specified /// `params`. - function expectMultipleCallsToCreateWithRange(uint64 count, LockupLinear.CreateWithRange memory params) internal { + function expectMultipleCallsToCreateWithTimestampsLL( + uint64 count, + LockupLinear.CreateWithTimestamps memory params + ) + internal + { vm.expectCall({ callee: address(lockupLinear), count: count, - data: abi.encodeCall(ISablierV2LockupLinear.createWithRange, (params)) + data: abi.encodeCall(ISablierV2LockupLinear.createWithTimestamps, (params)) }); } diff --git a/test/fork/Fork.t.sol b/test/fork/Fork.t.sol index c1ab84e6..7d1ad224 100644 --- a/test/fork/Fork.t.sol +++ b/test/fork/Fork.t.sol @@ -4,6 +4,7 @@ pragma solidity >=0.8.22 <0.9.0; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { ISablierV2LockupDynamic } from "@sablier/v2-core/src/interfaces/ISablierV2LockupDynamic.sol"; import { ISablierV2LockupLinear } from "@sablier/v2-core/src/interfaces/ISablierV2LockupLinear.sol"; +import { Precompiles as V2CorePrecompiles } from "@sablier/v2-core/test/utils/Precompiles.sol"; import { Fuzzers as V2CoreFuzzers } from "@sablier/v2-core/test/utils/Fuzzers.sol"; @@ -32,7 +33,9 @@ abstract contract Fork_Test is Base_Test, V2CoreFuzzers { Base_Test.setUp(); // Load the external dependencies. - loadDependencies(); + // loadDependencies(); + // TODO: Remove this line once the v2 core contracts are deployed on Mainnet. + deployDependencies(); // Deploy the defaults contract and allow it to access cheatcodes. defaults = new Defaults(users, asset); @@ -72,4 +75,10 @@ abstract contract Fork_Test is Base_Test, V2CoreFuzzers { lockupDynamic = ISablierV2LockupDynamic(0x7CC7e125d83A581ff438608490Cc0f7bDff79127); lockupLinear = ISablierV2LockupLinear(0xAFb979d9afAd1aD27C5eFf4E27226E3AB9e5dCC9); } + + /// @dev Deploys the v2 core dependencies. + // TODO: Remove this function once the v2 core contracts are deployed on Mainnet. + function deployDependencies() private { + (, lockupDynamic, lockupLinear,) = new V2CorePrecompiles().deployCore(users.admin); + } } diff --git a/test/fork/assets/USDC.t.sol b/test/fork/assets/USDC.t.sol index cecf1298..ef356d0c 100644 --- a/test/fork/assets/USDC.t.sol +++ b/test/fork/assets/USDC.t.sol @@ -3,14 +3,18 @@ pragma solidity >=0.8.22 <0.9.0; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import { CreateWithMilestones_Batch_Fork_Test } from "../batch/createWithMilestones.t.sol"; -import { CreateWithRange_Batch_Fork_Test } from "../batch/createWithRange.t.sol"; +import { CreateWithTimestamps_LockupDynamic_Batch_Fork_Test } from "../batch/createWithTimestampsLD.t.sol"; +import { CreateWithTimestamps_LockupLinear_Batch_Fork_Test } from "../batch/createWithTimestampsLL.t.sol"; import { MerkleStreamerLL_Fork_Test } from "../merkle-streamer/MerkleStreamerLL.t.sol"; IERC20 constant usdc = IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48); -contract USDC_CreateWithMilestones_Batch_Fork_Test is CreateWithMilestones_Batch_Fork_Test(usdc) { } +contract USDC_CreateWithTimestamps_LockupDynamic_Batch_Fork_Test is + CreateWithTimestamps_LockupDynamic_Batch_Fork_Test(usdc) +{ } -contract USDC_CreateWithRange_Batch_Fork_Test is CreateWithRange_Batch_Fork_Test(usdc) { } +contract USDC_CreateWithTimestamps_LockupLinear_Batch_Fork_Test is + CreateWithTimestamps_LockupLinear_Batch_Fork_Test(usdc) +{ } contract USDC_MerkleStreamerLL_Fork_Test is MerkleStreamerLL_Fork_Test(usdc) { } diff --git a/test/fork/assets/USDT.t.sol b/test/fork/assets/USDT.t.sol index ae8cd8a0..4b03564a 100644 --- a/test/fork/assets/USDT.t.sol +++ b/test/fork/assets/USDT.t.sol @@ -3,14 +3,18 @@ pragma solidity >=0.8.22 <0.9.0; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import { CreateWithMilestones_Batch_Fork_Test } from "../batch/createWithMilestones.t.sol"; -import { CreateWithRange_Batch_Fork_Test } from "../batch/createWithRange.t.sol"; +import { CreateWithTimestamps_LockupDynamic_Batch_Fork_Test } from "../batch/createWithTimestampsLD.t.sol"; +import { CreateWithTimestamps_LockupLinear_Batch_Fork_Test } from "../batch/createWithTimestampsLL.t.sol"; import { MerkleStreamerLL_Fork_Test } from "../merkle-streamer/MerkleStreamerLL.t.sol"; IERC20 constant usdt = IERC20(0xdAC17F958D2ee523a2206206994597C13D831ec7); -contract USDT_CreateWithMilestones_Batch_Fork_Test is CreateWithMilestones_Batch_Fork_Test(usdt) { } +contract USDT_CreateWithTimestamps_LockupDynamic_Batch_Fork_Test is + CreateWithTimestamps_LockupDynamic_Batch_Fork_Test(usdt) +{ } -contract USDT_CreateWithRange_Batch_Fork_Test is CreateWithRange_Batch_Fork_Test(usdt) { } +contract USDT_CreateWithTimestamps_LockupLinear_Batch_Fork_Test is + CreateWithTimestamps_LockupLinear_Batch_Fork_Test(usdt) +{ } contract USDT_MerkleStreamerLL_Fork_Test is MerkleStreamerLL_Fork_Test(usdt) { } diff --git a/test/fork/batch/createWithMilestones.t.sol b/test/fork/batch/createWithTimestampsLD.t.sol similarity index 77% rename from test/fork/batch/createWithMilestones.t.sol rename to test/fork/batch/createWithTimestampsLD.t.sol index 1a61c842..81cbe2c8 100644 --- a/test/fork/batch/createWithMilestones.t.sol +++ b/test/fork/batch/createWithTimestampsLD.t.sol @@ -11,7 +11,7 @@ import { ArrayBuilder } from "../../utils/ArrayBuilder.sol"; import { BatchBuilder } from "../../utils/BatchBuilder.sol"; /// @dev Runs against multiple fork assets. -abstract contract CreateWithMilestones_Batch_Fork_Test is Fork_Test { +abstract contract CreateWithTimestamps_LockupDynamic_Batch_Fork_Test is Fork_Test { constructor(IERC20 asset_) Fork_Test(asset_) { } function setUp() public virtual override { @@ -19,10 +19,10 @@ abstract contract CreateWithMilestones_Batch_Fork_Test is Fork_Test { } /*////////////////////////////////////////////////////////////////////////// - BATCH-CREATE-WITH-MILESTONES + BATCH-CREATE-WITH-TIMESTAMPS //////////////////////////////////////////////////////////////////////////*/ - struct CreateWithMilestonesParams { + struct CreateWithTimestampsParams { uint128 batchSize; address sender; address recipient; @@ -31,11 +31,11 @@ abstract contract CreateWithMilestones_Batch_Fork_Test is Fork_Test { LockupDynamic.Segment[] segments; } - function testForkFuzz_CreateWithMilestones(CreateWithMilestonesParams memory params) external { + function testForkFuzz_CreateWithTimestamps(CreateWithTimestampsParams memory params) external { vm.assume(params.segments.length != 0); params.batchSize = boundUint128(params.batchSize, 1, 20); params.startTime = boundUint40(params.startTime, getBlockTimestamp(), getBlockTimestamp() + 24 hours); - fuzzSegmentMilestones(params.segments, params.startTime); + fuzzSegmentTimestamps(params.segments, params.startTime); (params.perStreamAmount,) = fuzzDynamicStreamAmounts({ upperBound: MAX_UINT128 / params.batchSize, segments: params.segments, @@ -52,7 +52,7 @@ abstract contract CreateWithMilestones_Batch_Fork_Test is Fork_Test { changePrank({ msgSender: params.sender }); asset.approve({ spender: address(batch), amount: totalTransferAmount }); - LockupDynamic.CreateWithMilestones memory createWithMilestones = LockupDynamic.CreateWithMilestones({ + LockupDynamic.CreateWithTimestamps memory createWithTimestamps = LockupDynamic.CreateWithTimestamps({ sender: params.sender, recipient: params.recipient, totalAmount: params.perStreamAmount, @@ -63,7 +63,8 @@ abstract contract CreateWithMilestones_Batch_Fork_Test is Fork_Test { segments: params.segments, broker: defaults.broker() }); - Batch.CreateWithMilestones[] memory batchParams = BatchBuilder.fillBatch(createWithMilestones, params.batchSize); + Batch.CreateWithTimestampsLD[] memory batchParams = + BatchBuilder.fillBatch(createWithTimestamps, params.batchSize); expectCallToTransferFrom({ asset_: address(asset), @@ -71,7 +72,7 @@ abstract contract CreateWithMilestones_Batch_Fork_Test is Fork_Test { to: address(batch), amount: totalTransferAmount }); - expectMultipleCallsToCreateWithMilestones({ count: uint64(params.batchSize), params: createWithMilestones }); + expectMultipleCallsToCreateWithTimestampsLD({ count: uint64(params.batchSize), params: createWithTimestamps }); expectMultipleCallsToTransferFrom({ asset_: address(asset), count: uint64(params.batchSize), @@ -80,7 +81,7 @@ abstract contract CreateWithMilestones_Batch_Fork_Test is Fork_Test { amount: params.perStreamAmount }); - uint256[] memory actualStreamIds = batch.createWithMilestones(lockupDynamic, asset, batchParams); + uint256[] memory actualStreamIds = batch.createWithTimestampsLD(lockupDynamic, asset, batchParams); uint256[] memory expectedStreamIds = ArrayBuilder.fillStreamIds(firstStreamId, params.batchSize); assertEq(actualStreamIds, expectedStreamIds); } diff --git a/test/fork/batch/createWithRange.t.sol b/test/fork/batch/createWithTimestampsLL.t.sol similarity index 79% rename from test/fork/batch/createWithRange.t.sol rename to test/fork/batch/createWithTimestampsLL.t.sol index cc3600fb..179b20e4 100644 --- a/test/fork/batch/createWithRange.t.sol +++ b/test/fork/batch/createWithTimestampsLL.t.sol @@ -11,7 +11,7 @@ import { ArrayBuilder } from "../../utils/ArrayBuilder.sol"; import { BatchBuilder } from "../../utils/BatchBuilder.sol"; /// @dev Runs against multiple fork assets. -abstract contract CreateWithRange_Batch_Fork_Test is Fork_Test { +abstract contract CreateWithTimestamps_LockupLinear_Batch_Fork_Test is Fork_Test { constructor(IERC20 asset_) Fork_Test(asset_) { } function setUp() public virtual override { @@ -19,10 +19,10 @@ abstract contract CreateWithRange_Batch_Fork_Test is Fork_Test { } /*////////////////////////////////////////////////////////////////////////// - BATCH-CREATE-WITH-RANGE + BATCH-CREATE-WITH-TIMESTAMPS //////////////////////////////////////////////////////////////////////////*/ - struct CreateWithRangeParams { + struct CreateWithTimestampsParams { uint128 batchSize; LockupLinear.Range range; address sender; @@ -30,7 +30,7 @@ abstract contract CreateWithRange_Batch_Fork_Test is Fork_Test { uint128 perStreamAmount; } - function testForkFuzz_CreateWithRange(CreateWithRangeParams memory params) external { + function testForkFuzz_CreateWithTimestamps(CreateWithTimestampsParams memory params) external { params.batchSize = boundUint128(params.batchSize, 1, 20); params.perStreamAmount = boundUint128(params.perStreamAmount, 1, MAX_UINT128 / params.batchSize); params.range.start = boundUint40(params.range.start, getBlockTimestamp(), getBlockTimestamp() + 24 hours); @@ -46,7 +46,7 @@ abstract contract CreateWithRange_Batch_Fork_Test is Fork_Test { changePrank({ msgSender: params.sender }); asset.approve({ spender: address(batch), amount: totalTransferAmount }); - LockupLinear.CreateWithRange memory createParams = LockupLinear.CreateWithRange({ + LockupLinear.CreateWithTimestamps memory createParams = LockupLinear.CreateWithTimestamps({ sender: params.sender, recipient: params.recipient, totalAmount: params.perStreamAmount, @@ -56,7 +56,7 @@ abstract contract CreateWithRange_Batch_Fork_Test is Fork_Test { range: params.range, broker: defaults.broker() }); - Batch.CreateWithRange[] memory batchParams = BatchBuilder.fillBatch(createParams, params.batchSize); + Batch.CreateWithTimestampsLL[] memory batchParams = BatchBuilder.fillBatch(createParams, params.batchSize); // Asset flow: sender → batch → Sablier expectCallToTransferFrom({ @@ -65,7 +65,7 @@ abstract contract CreateWithRange_Batch_Fork_Test is Fork_Test { to: address(batch), amount: totalTransferAmount }); - expectMultipleCallsToCreateWithRange({ count: uint64(params.batchSize), params: createParams }); + expectMultipleCallsToCreateWithTimestampsLL({ count: uint64(params.batchSize), params: createParams }); expectMultipleCallsToTransferFrom({ asset_: address(asset), count: uint64(params.batchSize), @@ -74,7 +74,7 @@ abstract contract CreateWithRange_Batch_Fork_Test is Fork_Test { amount: params.perStreamAmount }); - uint256[] memory actualStreamIds = batch.createWithRange(lockupLinear, asset, batchParams); + uint256[] memory actualStreamIds = batch.createWithTimestampsLL(lockupLinear, asset, batchParams); uint256[] memory expectedStreamIds = ArrayBuilder.fillStreamIds(firstStreamId, params.batchSize); assertEq(actualStreamIds, expectedStreamIds); } diff --git a/test/integration/batch/create-with-deltas/createWithDeltas.t.sol b/test/integration/batch/lockup-dynamic/create-with-durations/createWithDurations.t.sol similarity index 65% rename from test/integration/batch/create-with-deltas/createWithDeltas.t.sol rename to test/integration/batch/lockup-dynamic/create-with-durations/createWithDurations.t.sol index dac44686..1af6d955 100644 --- a/test/integration/batch/create-with-deltas/createWithDeltas.t.sol +++ b/test/integration/batch/lockup-dynamic/create-with-durations/createWithDurations.t.sol @@ -4,28 +4,31 @@ pragma solidity >=0.8.22 <0.9.0; import { Errors } from "src/libraries/Errors.sol"; import { Batch } from "src/types/DataTypes.sol"; -import { Integration_Test } from "../../Integration.t.sol"; +import { Integration_Test } from "../../../Integration.t.sol"; -contract CreateWithDeltas_Integration_Test is Integration_Test { +contract CreateWithDurations_LockupDynamic_Integration_Test is Integration_Test { function setUp() public virtual override { Integration_Test.setUp(); } function test_RevertWhen_BatchSizeZero() external { - Batch.CreateWithDeltas[] memory batchParams = new Batch.CreateWithDeltas[](0); + Batch.CreateWithDurationsLD[] memory batchParams = new Batch.CreateWithDurationsLD[](0); vm.expectRevert(Errors.SablierV2Batch_BatchSizeZero.selector); - batch.createWithDeltas(lockupDynamic, asset, batchParams); + batch.createWithDurationsLD(lockupDynamic, asset, batchParams); } modifier whenBatchSizeNotZero() { _; } - function test_BatchCreateWithDeltas() external whenBatchSizeNotZero { + function test_BatchCreateWithDurations() external whenBatchSizeNotZero { // Asset flow: Alice → batch → Sablier // Expect transfers from Alice to the batch, and then from the batch to the Sablier contract. expectCallToTransferFrom({ from: users.alice, to: address(batch), amount: defaults.TOTAL_TRANSFER_AMOUNT() }); - expectMultipleCallsToCreateWithDeltas({ count: defaults.BATCH_SIZE(), params: defaults.createWithDeltas() }); + expectMultipleCallsToCreateWithDurationsLD({ + count: defaults.BATCH_SIZE(), + params: defaults.createWithDurationsLD() + }); expectMultipleCallsToTransferFrom({ count: defaults.BATCH_SIZE(), from: address(batch), @@ -35,7 +38,7 @@ contract CreateWithDeltas_Integration_Test is Integration_Test { // Assert that the batch of streams has been created successfully. uint256[] memory actualStreamIds = - batch.createWithDeltas(lockupDynamic, asset, defaults.batchCreateWithDeltas()); + batch.createWithDurationsLD(lockupDynamic, asset, defaults.batchCreateWithDurationsLD()); uint256[] memory expectedStreamIds = defaults.incrementalStreamIds(); assertEq(actualStreamIds, expectedStreamIds, "stream ids mismatch"); } diff --git a/test/integration/batch/create-with-durations/createWithDurations.tree b/test/integration/batch/lockup-dynamic/create-with-durations/createWithDurations.tree similarity index 100% rename from test/integration/batch/create-with-durations/createWithDurations.tree rename to test/integration/batch/lockup-dynamic/create-with-durations/createWithDurations.tree diff --git a/test/integration/batch/create-with-milestones/createWithMilestones.t.sol b/test/integration/batch/lockup-dynamic/create-with-timestamps/createWithTimestamps.t.sol similarity index 68% rename from test/integration/batch/create-with-milestones/createWithMilestones.t.sol rename to test/integration/batch/lockup-dynamic/create-with-timestamps/createWithTimestamps.t.sol index a3e9484b..81500065 100644 --- a/test/integration/batch/create-with-milestones/createWithMilestones.t.sol +++ b/test/integration/batch/lockup-dynamic/create-with-timestamps/createWithTimestamps.t.sol @@ -4,30 +4,30 @@ pragma solidity >=0.8.22 <0.9.0; import { Errors } from "src/libraries/Errors.sol"; import { Batch } from "src/types/DataTypes.sol"; -import { Integration_Test } from "../../Integration.t.sol"; +import { Integration_Test } from "../../../Integration.t.sol"; -contract CreateWithMilestones_Integration_Test is Integration_Test { +contract CreateWithTimestamps_LockupDynamic_Integration_Test is Integration_Test { function setUp() public virtual override { Integration_Test.setUp(); } function test_RevertWhen_BatchSizeZero() external { - Batch.CreateWithMilestones[] memory batchParams = new Batch.CreateWithMilestones[](0); + Batch.CreateWithTimestampsLD[] memory batchParams = new Batch.CreateWithTimestampsLD[](0); vm.expectRevert(Errors.SablierV2Batch_BatchSizeZero.selector); - batch.createWithMilestones(lockupDynamic, asset, batchParams); + batch.createWithTimestampsLD(lockupDynamic, asset, batchParams); } modifier whenBatchSizeNotZero() { _; } - function test_BatchCreateWithMilestones() external whenBatchSizeNotZero { + function test_BatchCreateWithTimestamps() external whenBatchSizeNotZero { // Asset flow: Alice → batch → Sablier // Expect transfers from Alice to the batch, and then from the batch to the Sablier contract. expectCallToTransferFrom({ from: users.alice, to: address(batch), amount: defaults.TOTAL_TRANSFER_AMOUNT() }); - expectMultipleCallsToCreateWithMilestones({ + expectMultipleCallsToCreateWithTimestampsLD({ count: defaults.BATCH_SIZE(), - params: defaults.createWithMilestones() + params: defaults.createWithTimestampsLD() }); expectMultipleCallsToTransferFrom({ count: defaults.BATCH_SIZE(), @@ -38,7 +38,7 @@ contract CreateWithMilestones_Integration_Test is Integration_Test { // Assert that the batch of streams has been created successfully. uint256[] memory actualStreamIds = - batch.createWithMilestones(lockupDynamic, asset, defaults.batchCreateWithMilestones()); + batch.createWithTimestampsLD(lockupDynamic, asset, defaults.batchCreateWithTimestampsLD()); uint256[] memory expectedStreamIds = defaults.incrementalStreamIds(); assertEq(actualStreamIds, expectedStreamIds, "stream ids mismatch"); } diff --git a/test/integration/batch/create-with-milestones/createWithMilestones.tree b/test/integration/batch/lockup-dynamic/create-with-timestamps/createWithTimestamps.tree similarity index 64% rename from test/integration/batch/create-with-milestones/createWithMilestones.tree rename to test/integration/batch/lockup-dynamic/create-with-timestamps/createWithTimestamps.tree index 41e9e3f9..7769ecd1 100644 --- a/test/integration/batch/create-with-milestones/createWithMilestones.tree +++ b/test/integration/batch/lockup-dynamic/create-with-timestamps/createWithTimestamps.tree @@ -1,6 +1,6 @@ -createWithMilestones.t.sol +createWithTimestamps.t.sol ├── when the batch size is zero │ └── it should revert └── when the batch size is not zero - ├── it should create a batch of streams with milestones + ├── it should create a batch of streams with timestamps └── it should perform the ERC-20 transfers diff --git a/test/integration/batch/create-with-durations/createWithDurations.t.sol b/test/integration/batch/lockup-linear/create-with-durations/createWithDurations.t.sol similarity index 69% rename from test/integration/batch/create-with-durations/createWithDurations.t.sol rename to test/integration/batch/lockup-linear/create-with-durations/createWithDurations.t.sol index cfbf667c..f3f4523a 100644 --- a/test/integration/batch/create-with-durations/createWithDurations.t.sol +++ b/test/integration/batch/lockup-linear/create-with-durations/createWithDurations.t.sol @@ -4,17 +4,17 @@ pragma solidity >=0.8.22 <0.9.0; import { Errors } from "src/libraries/Errors.sol"; import { Batch } from "src/types/DataTypes.sol"; -import { Integration_Test } from "../../Integration.t.sol"; +import { Integration_Test } from "../../../Integration.t.sol"; -contract CreateWithDurations_Integration_Test is Integration_Test { +contract CreateWithDurations_LockupLinear_Integration_Test is Integration_Test { function setUp() public virtual override { Integration_Test.setUp(); } function test_RevertWhen_BatchSizeZero() external { - Batch.CreateWithDurations[] memory batchParams = new Batch.CreateWithDurations[](0); + Batch.CreateWithDurationsLL[] memory batchParams = new Batch.CreateWithDurationsLL[](0); vm.expectRevert(Errors.SablierV2Batch_BatchSizeZero.selector); - batch.createWithDurations(lockupLinear, asset, batchParams); + batch.createWithDurationsLL(lockupLinear, asset, batchParams); } modifier whenBatchSizeNotZero() { @@ -25,7 +25,10 @@ contract CreateWithDurations_Integration_Test is Integration_Test { // Asset flow: Alice → batch → Sablier // Expect transfers from Alice to the batch, and then from the batch to the Sablier contract. expectCallToTransferFrom({ from: users.alice, to: address(batch), amount: defaults.TOTAL_TRANSFER_AMOUNT() }); - expectMultipleCallsToCreateWithDurations({ count: defaults.BATCH_SIZE(), params: defaults.createWithDurations() }); + expectMultipleCallsToCreateWithDurationsLL({ + count: defaults.BATCH_SIZE(), + params: defaults.createWithDurationsLL() + }); expectMultipleCallsToTransferFrom({ count: defaults.BATCH_SIZE(), from: address(batch), @@ -35,7 +38,7 @@ contract CreateWithDurations_Integration_Test is Integration_Test { // Assert that the batch of streams has been created successfully. uint256[] memory actualStreamIds = - batch.createWithDurations(lockupLinear, asset, defaults.batchCreateWithDurations()); + batch.createWithDurationsLL(lockupLinear, asset, defaults.batchCreateWithDurationsLL()); uint256[] memory expectedStreamIds = defaults.incrementalStreamIds(); assertEq(actualStreamIds, expectedStreamIds, "stream ids mismatch"); } diff --git a/test/integration/batch/create-with-range/createWithRange.tree b/test/integration/batch/lockup-linear/create-with-durations/createWithDurations.tree similarity index 64% rename from test/integration/batch/create-with-range/createWithRange.tree rename to test/integration/batch/lockup-linear/create-with-durations/createWithDurations.tree index 886e5ff0..377110d8 100644 --- a/test/integration/batch/create-with-range/createWithRange.tree +++ b/test/integration/batch/lockup-linear/create-with-durations/createWithDurations.tree @@ -1,6 +1,6 @@ -createWithRange.t.sol +createWithDurations.t.sol ├── when the batch size is zero │ └── it should revert └── when the batch size is not zero - ├── it should create a batch of streams with range + ├── it should create a batch of streams with durations └── it should perform the ERC-20 transfers diff --git a/test/integration/batch/create-with-range/createWithRange.t.sol b/test/integration/batch/lockup-linear/create-with-timestamps/createWithTimestamps.t.sol similarity index 62% rename from test/integration/batch/create-with-range/createWithRange.t.sol rename to test/integration/batch/lockup-linear/create-with-timestamps/createWithTimestamps.t.sol index 4fac3995..66639b2f 100644 --- a/test/integration/batch/create-with-range/createWithRange.t.sol +++ b/test/integration/batch/lockup-linear/create-with-timestamps/createWithTimestamps.t.sol @@ -4,28 +4,31 @@ pragma solidity >=0.8.22 <0.9.0; import { Errors } from "src/libraries/Errors.sol"; import { Batch } from "src/types/DataTypes.sol"; -import { Integration_Test } from "../../Integration.t.sol"; +import { Integration_Test } from "../../../Integration.t.sol"; -contract CreateWithRange_Integration_Test is Integration_Test { +contract CreateWithTimestamps_LockupLinear_Integration_Test is Integration_Test { function setUp() public virtual override { Integration_Test.setUp(); } function test_RevertWhen_BatchSizeZero() external { - Batch.CreateWithRange[] memory batchParams = new Batch.CreateWithRange[](0); + Batch.CreateWithTimestampsLL[] memory batchParams = new Batch.CreateWithTimestampsLL[](0); vm.expectRevert(Errors.SablierV2Batch_BatchSizeZero.selector); - batch.createWithRange(lockupLinear, asset, batchParams); + batch.createWithTimestampsLL(lockupLinear, asset, batchParams); } modifier whenBatchSizeNotZero() { _; } - function test_CreateWithRange() external whenBatchSizeNotZero { + function test_BatchCreateWithTimestamps() external whenBatchSizeNotZero { // Asset flow: Alice → batch → Sablier // Expect transfers from Alice to the batch, and then from the batch to the Sablier contract. expectCallToTransferFrom({ from: users.alice, to: address(batch), amount: defaults.TOTAL_TRANSFER_AMOUNT() }); - expectMultipleCallsToCreateWithRange({ count: defaults.BATCH_SIZE(), params: defaults.createWithRange() }); + expectMultipleCallsToCreateWithTimestampsLL({ + count: defaults.BATCH_SIZE(), + params: defaults.createWithTimestampsLL() + }); expectMultipleCallsToTransferFrom({ count: defaults.BATCH_SIZE(), from: address(batch), @@ -34,7 +37,8 @@ contract CreateWithRange_Integration_Test is Integration_Test { }); // Assert that the batch of streams has been created successfully. - uint256[] memory actualStreamIds = batch.createWithRange(lockupLinear, asset, defaults.batchCreateWithRange()); + uint256[] memory actualStreamIds = + batch.createWithTimestampsLL(lockupLinear, asset, defaults.batchCreateWithTimestampsLL()); uint256[] memory expectedStreamIds = defaults.incrementalStreamIds(); assertEq(actualStreamIds, expectedStreamIds, "stream ids mismatch"); } diff --git a/test/integration/batch/create-with-deltas/createWithDeltas.tree b/test/integration/batch/lockup-linear/create-with-timestamps/createWithTimestamps.tree similarity index 64% rename from test/integration/batch/create-with-deltas/createWithDeltas.tree rename to test/integration/batch/lockup-linear/create-with-timestamps/createWithTimestamps.tree index 37e9b52f..7769ecd1 100644 --- a/test/integration/batch/create-with-deltas/createWithDeltas.tree +++ b/test/integration/batch/lockup-linear/create-with-timestamps/createWithTimestamps.tree @@ -1,6 +1,6 @@ -createWithDeltas.t.sol +createWithTimestamps.t.sol ├── when the batch size is zero │ └── it should revert └── when the batch size is not zero - ├── it should create a batch of streams with deltas + ├── it should create a batch of streams with timestamps └── it should perform the ERC-20 transfers diff --git a/test/utils/BatchBuilder.sol b/test/utils/BatchBuilder.sol index dfc59bf9..d52e3dff 100644 --- a/test/utils/BatchBuilder.sol +++ b/test/utils/BatchBuilder.sol @@ -8,30 +8,30 @@ import { Batch } from "../../src/types/DataTypes.sol"; library BatchBuilder { /// @notice Generates an array containing `batchSize` copies of `batchSingle`. function fillBatch( - Batch.CreateWithDeltas memory batchSingle, + Batch.CreateWithDurationsLD memory batchSingle, uint256 batchSize ) internal pure - returns (Batch.CreateWithDeltas[] memory batch) + returns (Batch.CreateWithDurationsLD[] memory batch) { - batch = new Batch.CreateWithDeltas[](batchSize); + batch = new Batch.CreateWithDurationsLD[](batchSize); for (uint256 i = 0; i < batchSize; ++i) { batch[i] = batchSingle; } } - /// @notice Turns the `params` into an array of `Batch.CreateWithDeltas` structs. + /// @notice Turns the `params` into an array of `Batch.CreateWithDurationsLD` structs. function fillBatch( - LockupDynamic.CreateWithDeltas memory params, + LockupDynamic.CreateWithDurations memory params, uint256 batchSize ) internal pure - returns (Batch.CreateWithDeltas[] memory batch) + returns (Batch.CreateWithDurationsLD[] memory batch) { - batch = new Batch.CreateWithDeltas[](batchSize); - Batch.CreateWithDeltas memory batchSingle = Batch.CreateWithDeltas({ + batch = new Batch.CreateWithDurationsLD[](batchSize); + Batch.CreateWithDurationsLD memory batchSingle = Batch.CreateWithDurationsLD({ sender: params.sender, recipient: params.recipient, totalAmount: params.totalAmount, @@ -45,30 +45,30 @@ library BatchBuilder { /// @notice Generates an array containing `batchSize` copies of `batchSingle`. function fillBatch( - Batch.CreateWithDurations memory batchSingle, + Batch.CreateWithDurationsLL memory batchSingle, uint256 batchSize ) internal pure - returns (Batch.CreateWithDurations[] memory batch) + returns (Batch.CreateWithDurationsLL[] memory batch) { - batch = new Batch.CreateWithDurations[](batchSize); + batch = new Batch.CreateWithDurationsLL[](batchSize); for (uint256 i = 0; i < batchSize; ++i) { batch[i] = batchSingle; } } - /// @notice Turns the `params` into an array of `Batch.CreateWithDurations` structs. + /// @notice Turns the `params` into an array of `Batch.CreateWithDurationsLL` structs. function fillBatch( LockupLinear.CreateWithDurations memory params, uint256 batchSize ) internal pure - returns (Batch.CreateWithDurations[] memory batch) + returns (Batch.CreateWithDurationsLL[] memory batch) { - batch = new Batch.CreateWithDurations[](batchSize); - Batch.CreateWithDurations memory batchSingle = Batch.CreateWithDurations({ + batch = new Batch.CreateWithDurationsLL[](batchSize); + Batch.CreateWithDurationsLL memory batchSingle = Batch.CreateWithDurationsLL({ sender: params.sender, recipient: params.recipient, totalAmount: params.totalAmount, @@ -82,30 +82,30 @@ library BatchBuilder { /// @notice Generates an array containing `batchSize` copies of `batchSingle`. function fillBatch( - Batch.CreateWithMilestones memory batchSingle, + Batch.CreateWithTimestampsLD memory batchSingle, uint256 batchSize ) internal pure - returns (Batch.CreateWithMilestones[] memory batch) + returns (Batch.CreateWithTimestampsLD[] memory batch) { - batch = new Batch.CreateWithMilestones[](batchSize); + batch = new Batch.CreateWithTimestampsLD[](batchSize); for (uint256 i = 0; i < batchSize; ++i) { batch[i] = batchSingle; } } - /// @notice Turns the `params` into an array of `Batch.CreateWithMilestones` structs. + /// @notice Turns the `params` into an array of `Batch.CreateWithTimestampsLDs` structs. function fillBatch( - LockupDynamic.CreateWithMilestones memory params, + LockupDynamic.CreateWithTimestamps memory params, uint256 batchSize ) internal pure - returns (Batch.CreateWithMilestones[] memory batch) + returns (Batch.CreateWithTimestampsLD[] memory batch) { - batch = new Batch.CreateWithMilestones[](batchSize); - Batch.CreateWithMilestones memory batchSingle = Batch.CreateWithMilestones({ + batch = new Batch.CreateWithTimestampsLD[](batchSize); + Batch.CreateWithTimestampsLD memory batchSingle = Batch.CreateWithTimestampsLD({ sender: params.sender, recipient: params.recipient, totalAmount: params.totalAmount, @@ -120,30 +120,30 @@ library BatchBuilder { /// @notice Generates an array containing `batchSize` copies of `batchSingle`. function fillBatch( - Batch.CreateWithRange memory batchSingle, + Batch.CreateWithTimestampsLL memory batchSingle, uint256 batchSize ) internal pure - returns (Batch.CreateWithRange[] memory batch) + returns (Batch.CreateWithTimestampsLL[] memory batch) { - batch = new Batch.CreateWithRange[](batchSize); + batch = new Batch.CreateWithTimestampsLL[](batchSize); for (uint256 i = 0; i < batchSize; ++i) { batch[i] = batchSingle; } } - /// @notice Turns the `params` into an array of `Batch.CreateWithRange` structs. + /// @notice Turns the `params` into an array of `Batch.CreateWithTimestampsLL` structs. function fillBatch( - LockupLinear.CreateWithRange memory params, + LockupLinear.CreateWithTimestamps memory params, uint256 batchSize ) internal pure - returns (Batch.CreateWithRange[] memory batch) + returns (Batch.CreateWithTimestampsLL[] memory batch) { - batch = new Batch.CreateWithRange[](batchSize); - Batch.CreateWithRange memory batchSingle = Batch.CreateWithRange({ + batch = new Batch.CreateWithTimestampsLL[](batchSize); + Batch.CreateWithTimestampsLL memory batchSingle = Batch.CreateWithTimestampsLL({ sender: params.sender, recipient: params.recipient, totalAmount: params.totalAmount, diff --git a/test/utils/Defaults.sol b/test/utils/Defaults.sol index 7ab5e3a6..66297b86 100644 --- a/test/utils/Defaults.sol +++ b/test/utils/Defaults.sol @@ -135,29 +135,29 @@ contract Defaults is Merkle { SABLIER-V2-LOCKUP-DYNAMIC //////////////////////////////////////////////////////////////////////////*/ - function createWithDeltas() public view returns (LockupDynamic.CreateWithDeltas memory) { - return createWithDeltas(asset); + function createWithDurationsLD() public view returns (LockupDynamic.CreateWithDurations memory) { + return createWithDurationsLD(asset); } - function createWithDeltas(IERC20 asset_) public view returns (LockupDynamic.CreateWithDeltas memory) { - return LockupDynamic.CreateWithDeltas({ + function createWithDurationsLD(IERC20 asset_) public view returns (LockupDynamic.CreateWithDurations memory) { + return LockupDynamic.CreateWithDurations({ sender: users.alice, recipient: users.recipient0, totalAmount: PER_STREAM_AMOUNT, asset: asset_, cancelable: true, transferable: true, - segments: segmentsWithDeltas(), + segments: segmentsWithDurations(), broker: broker() }); } - function createWithMilestones() public view returns (LockupDynamic.CreateWithMilestones memory) { - return createWithMilestones(asset); + function createWithTimestampsLD() public view returns (LockupDynamic.CreateWithTimestamps memory) { + return createWithTimestampsLD(asset); } - function createWithMilestones(IERC20 asset_) public view returns (LockupDynamic.CreateWithMilestones memory) { - return LockupDynamic.CreateWithMilestones({ + function createWithTimestampsLD(IERC20 asset_) public view returns (LockupDynamic.CreateWithTimestamps memory) { + return LockupDynamic.CreateWithTimestamps({ sender: users.alice, recipient: users.recipient0, totalAmount: PER_STREAM_AMOUNT, @@ -180,45 +180,45 @@ contract Defaults is Merkle { segments_[0] = LockupDynamic.Segment({ amount: 2500e18, exponent: ud2x18(3.14e18), - milestone: START_TIME + CLIFF_DURATION + timestamp: START_TIME + CLIFF_DURATION }); segments_[1] = LockupDynamic.Segment({ amount: 7500e18, exponent: ud2x18(3.14e18), - milestone: START_TIME + TOTAL_DURATION + timestamp: START_TIME + TOTAL_DURATION }); } - /// @dev Returns a batch of `LockupDynamic.SegmentWithDelta` parameters. - function segmentsWithDeltas() public pure returns (LockupDynamic.SegmentWithDelta[] memory) { - return segmentsWithDeltas({ amount0: 2500e18, amount1: 7500e18 }); + /// @dev Returns a batch of `LockupDynamic.SegmentWithDuration` parameters. + function segmentsWithDurations() public pure returns (LockupDynamic.SegmentWithDuration[] memory) { + return segmentsWithDurations({ amount0: 2500e18, amount1: 7500e18 }); } - /// @dev Returns a batch of `LockupDynamic.SegmentWithDelta` parameters. - function segmentsWithDeltas( + /// @dev Returns a batch of `LockupDynamic.SegmentWithDuration` parameters. + function segmentsWithDurations( uint128 amount0, uint128 amount1 ) public pure - returns (LockupDynamic.SegmentWithDelta[] memory segments_) + returns (LockupDynamic.SegmentWithDuration[] memory segments_) { - segments_ = new LockupDynamic.SegmentWithDelta[](2); + segments_ = new LockupDynamic.SegmentWithDuration[](2); segments_[0] = - LockupDynamic.SegmentWithDelta({ amount: amount0, exponent: ud2x18(3.14e18), delta: 2500 seconds }); + LockupDynamic.SegmentWithDuration({ amount: amount0, exponent: ud2x18(3.14e18), duration: 2500 seconds }); segments_[1] = - LockupDynamic.SegmentWithDelta({ amount: amount1, exponent: ud2x18(3.14e18), delta: 7500 seconds }); + LockupDynamic.SegmentWithDuration({ amount: amount1, exponent: ud2x18(3.14e18), duration: 7500 seconds }); } /*////////////////////////////////////////////////////////////////////////// SABLIER-V2-LOCKUP-LINEAR //////////////////////////////////////////////////////////////////////////*/ - function createWithDurations() public view returns (LockupLinear.CreateWithDurations memory) { - return createWithDurations(asset); + function createWithDurationsLL() public view returns (LockupLinear.CreateWithDurations memory) { + return createWithDurationsLL(asset); } - function createWithDurations(IERC20 asset_) public view returns (LockupLinear.CreateWithDurations memory) { + function createWithDurationsLL(IERC20 asset_) public view returns (LockupLinear.CreateWithDurations memory) { return LockupLinear.CreateWithDurations({ sender: users.alice, recipient: users.recipient0, @@ -231,12 +231,12 @@ contract Defaults is Merkle { }); } - function createWithRange() public view returns (LockupLinear.CreateWithRange memory) { - return createWithRange(asset); + function createWithTimestampsLL() public view returns (LockupLinear.CreateWithTimestamps memory) { + return createWithTimestampsLL(asset); } - function createWithRange(IERC20 asset_) public view returns (LockupLinear.CreateWithRange memory) { - return LockupLinear.CreateWithRange({ + function createWithTimestampsLL(IERC20 asset_) public view returns (LockupLinear.CreateWithTimestamps memory) { + return LockupLinear.CreateWithTimestamps({ sender: users.alice, recipient: users.recipient0, totalAmount: PER_STREAM_AMOUNT, @@ -260,37 +260,41 @@ contract Defaults is Merkle { BATCH //////////////////////////////////////////////////////////////////////////*/ - /// @dev Returns a default-size batch of `Batch.CreateWithDeltas` parameters. - function batchCreateWithDeltas() public view returns (Batch.CreateWithDeltas[] memory batch) { - batch = BatchBuilder.fillBatch(createWithDeltas(), BATCH_SIZE); + /// @dev Returns a default-size batch of `Batch.CreateWithDurationsLD` parameters. + function batchCreateWithDurationsLD() public view returns (Batch.CreateWithDurationsLD[] memory batch) { + batch = BatchBuilder.fillBatch(createWithDurationsLD(), BATCH_SIZE); } - /// @dev Returns a default-size batch of `Batch.CreateWithDurations` parameters. - function batchCreateWithDurations() public view returns (Batch.CreateWithDurations[] memory batch) { - batch = BatchBuilder.fillBatch(createWithDurations(), BATCH_SIZE); + /// @dev Returns a default-size batch of `Batch.CreateWithDurationsLL` parameters. + function batchCreateWithDurationsLL() public view returns (Batch.CreateWithDurationsLL[] memory batch) { + batch = BatchBuilder.fillBatch(createWithDurationsLL(), BATCH_SIZE); } - /// @dev Returns a default-size batch of `Batch.CreateWithMilestones` parameters. - function batchCreateWithMilestones() public view returns (Batch.CreateWithMilestones[] memory batch) { - batch = batchCreateWithMilestones(BATCH_SIZE); + /// @dev Returns a default-size batch of `Batch.CreateWithTimestampsLD` parameters. + function batchCreateWithTimestampsLD() public view returns (Batch.CreateWithTimestampsLD[] memory batch) { + batch = batchCreateWithTimestampsLD(BATCH_SIZE); } - /// @dev Returns a batch of `Batch.CreateWithMilestones` parameters. - function batchCreateWithMilestones(uint256 batchSize) + /// @dev Returns a batch of `Batch.CreateWithTimestampsLD` parameters. + function batchCreateWithTimestampsLD(uint256 batchSize) public view - returns (Batch.CreateWithMilestones[] memory batch) + returns (Batch.CreateWithTimestampsLD[] memory batch) { - batch = BatchBuilder.fillBatch(createWithMilestones(), batchSize); + batch = BatchBuilder.fillBatch(createWithTimestampsLD(), batchSize); } - /// @dev Returns a default-size batch of `Batch.CreateWithRange` parameters. - function batchCreateWithRange() public view returns (Batch.CreateWithRange[] memory batch) { - batch = batchCreateWithRange(BATCH_SIZE); + /// @dev Returns a default-size batch of `Batch.CreateWithTimestampsLL` parameters. + function batchCreateWithTimestampsLL() public view returns (Batch.CreateWithTimestampsLL[] memory batch) { + batch = batchCreateWithTimestampsLL(BATCH_SIZE); } - /// @dev Returns a batch of `Batch.CreateWithRange` parameters. - function batchCreateWithRange(uint256 batchSize) public view returns (Batch.CreateWithRange[] memory batch) { - batch = BatchBuilder.fillBatch(createWithRange(), batchSize); + /// @dev Returns a batch of `Batch.CreateWithTimestampsLL` parameters. + function batchCreateWithTimestampsLL(uint256 batchSize) + public + view + returns (Batch.CreateWithTimestampsLL[] memory batch) + { + batch = BatchBuilder.fillBatch(createWithTimestampsLL(), batchSize); } }