diff --git a/packages/automation-contracts/scheduler/contracts/VestingSchedulerV2.sol b/packages/automation-contracts/scheduler/contracts/VestingSchedulerV2.sol index d002d9c779..5b9c26e7c0 100644 --- a/packages/automation-contracts/scheduler/contracts/VestingSchedulerV2.sol +++ b/packages/automation-contracts/scheduler/contracts/VestingSchedulerV2.sol @@ -60,6 +60,7 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase { int96 flowRate, uint256 cliffAmount, uint32 endDate, + uint32 claimValidityDate, bytes memory ctx ) external returns (bytes memory newCtx) { newCtx = _validateAndCreateVestingSchedule( @@ -67,7 +68,7 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase { superToken: superToken, receiver: receiver, startDate: startDate, - claimValidityDate: 0, + claimValidityDate: claimValidityDate, cliffDate: cliffDate, flowRate: flowRate, cliffAmount: cliffAmount, @@ -86,14 +87,15 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase { uint32 cliffDate, int96 flowRate, uint256 cliffAmount, - uint32 endDate + uint32 endDate, + uint32 claimValidityDate ) external { _validateAndCreateVestingSchedule( ScheduleCreationParams({ superToken: superToken, receiver: receiver, startDate: startDate, - claimValidityDate: 0, + claimValidityDate: claimValidityDate, cliffDate: cliffDate, flowRate: flowRate, cliffAmount: cliffAmount, @@ -171,8 +173,9 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase { address receiver, uint256 totalAmount, uint32 totalDuration, - uint32 cliffPeriod, uint32 startDate, + uint32 cliffPeriod, + uint32 claimPeriod, bytes memory ctx ) external returns (bytes memory newCtx) { newCtx = _validateAndCreateVestingSchedule( @@ -181,9 +184,9 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase { receiver, totalAmount, totalDuration, - cliffPeriod, startDate, - 0 // claimPeriod + cliffPeriod, + claimPeriod ), ctx ); @@ -195,8 +198,9 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase { address receiver, uint256 totalAmount, uint32 totalDuration, + uint32 startDate, uint32 cliffPeriod, - uint32 startDate + uint32 claimPeriod ) external { _validateAndCreateVestingSchedule( getCreateVestingScheduleParamsFromAmountAndDuration( @@ -204,9 +208,9 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase { receiver, totalAmount, totalDuration, - cliffPeriod, startDate, - 0 // claimPeriod + cliffPeriod, + claimPeriod ), bytes("") ); @@ -218,7 +222,8 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase { address receiver, uint256 totalAmount, uint32 totalDuration, - uint32 cliffPeriod + uint32 cliffPeriod, + uint32 claimPeriod ) external { _validateAndCreateVestingSchedule( getCreateVestingScheduleParamsFromAmountAndDuration( @@ -226,9 +231,9 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase { receiver, totalAmount, totalDuration, - cliffPeriod, 0, // startDate - 0 // claimPeriod + cliffPeriod, + claimPeriod ), bytes("") ); @@ -239,7 +244,8 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase { ISuperToken superToken, address receiver, uint256 totalAmount, - uint32 totalDuration + uint32 totalDuration, + uint32 claimPeriod ) external { _validateAndCreateVestingSchedule( getCreateVestingScheduleParamsFromAmountAndDuration( @@ -247,9 +253,9 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase { receiver, totalAmount, totalDuration, - 0, // cliffPeriod 0, // startDate - 0 // claimPeriod + 0, // cliffPeriod + claimPeriod ), bytes("") ); @@ -302,8 +308,8 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase { receiver, totalAmount, totalDuration, - 0, // cliffPeriod 0, // startDate + 0, // cliffPeriod 0 // claimValidityDate ), ctx @@ -316,155 +322,7 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase { assert(_executeCliffAndFlow(agg)); } - /// @dev IVestingScheduler.createClaimableVestingSchedule implementation. - function createClaimableVestingSchedule( - ISuperToken superToken, - address receiver, - uint32 startDate, - uint32 claimValidityDate, - uint32 cliffDate, - int96 flowRate, - uint256 cliffAmount, - uint32 endDate, - bytes memory ctx - ) external returns (bytes memory newCtx) { - newCtx = _validateAndCreateVestingSchedule( - ScheduleCreationParams({ - superToken: superToken, - receiver: receiver, - startDate: startDate, - claimValidityDate: claimValidityDate, - cliffDate: cliffDate, - flowRate: flowRate, - cliffAmount: cliffAmount, - endDate: endDate, - remainderAmount: 0 - }), - ctx - ); - } - - /// @dev IVestingScheduler.createClaimableVestingSchedule implementation. - function createClaimableVestingSchedule( - ISuperToken superToken, - address receiver, - uint32 startDate, - uint32 claimValidityDate, - uint32 cliffDate, - int96 flowRate, - uint256 cliffAmount, - uint32 endDate - ) external { - _validateAndCreateVestingSchedule( - ScheduleCreationParams({ - superToken: superToken, - receiver: receiver, - startDate: startDate, - claimValidityDate: claimValidityDate, - cliffDate: cliffDate, - flowRate: flowRate, - cliffAmount: cliffAmount, - endDate: endDate, - remainderAmount: 0 - }), - bytes("") - ); - } - - /// @dev IVestingScheduler.createClaimableVestingScheduleFromAmountAndDuration implementation. - function createClaimableVestingScheduleFromAmountAndDuration( - ISuperToken superToken, - address receiver, - uint256 totalAmount, - uint32 totalDuration, - uint32 claimPeriod, - uint32 cliffPeriod, - uint32 startDate, - bytes memory ctx - ) external returns (bytes memory newCtx) { - newCtx = _validateAndCreateVestingSchedule( - getCreateVestingScheduleParamsFromAmountAndDuration( - superToken, - receiver, - totalAmount, - totalDuration, - cliffPeriod, - startDate, - claimPeriod - ), - ctx - ); - } - - /// @dev IVestingScheduler.createClaimableVestingScheduleFromAmountAndDuration implementation. - function createClaimableVestingScheduleFromAmountAndDuration( - ISuperToken superToken, - address receiver, - uint256 totalAmount, - uint32 totalDuration, - uint32 claimPeriod, - uint32 cliffPeriod, - uint32 startDate - ) external { - _validateAndCreateVestingSchedule( - getCreateVestingScheduleParamsFromAmountAndDuration( - superToken, - receiver, - totalAmount, - totalDuration, - cliffPeriod, - startDate, - claimPeriod - ), - bytes("") - ); - } - - /// @dev IVestingScheduler.createVestingScheduleFromAmountAndDuration implementation. - function createClaimableVestingScheduleFromAmountAndDuration( - ISuperToken superToken, - address receiver, - uint256 totalAmount, - uint32 totalDuration, - uint32 claimPeriod, - uint32 cliffPeriod - ) external { - _validateAndCreateVestingSchedule( - getCreateVestingScheduleParamsFromAmountAndDuration( - superToken, - receiver, - totalAmount, - totalDuration, - cliffPeriod, - 0, // startDate - claimPeriod - ), - bytes("") - ); - } - - /// @dev IVestingScheduler.createVestingScheduleFromAmountAndDuration implementation. - function createClaimableVestingScheduleFromAmountAndDuration( - ISuperToken superToken, - address receiver, - uint256 totalAmount, - uint32 totalDuration, - uint32 claimPeriod - ) external { - _validateAndCreateVestingSchedule( - getCreateVestingScheduleParamsFromAmountAndDuration( - superToken, - receiver, - totalAmount, - totalDuration, - 0, // cliffPeriod - 0, // startDate - claimPeriod - ), - bytes("") - ); - } - + /// @dev IVestingScheduler.updateVestingSchedule implementation. function updateVestingSchedule( ISuperToken superToken, address receiver, @@ -721,8 +579,8 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase { address receiver, uint256 totalAmount, uint32 totalDuration, - uint32 cliffPeriod, uint32 startDate, + uint32 cliffPeriod, uint32 claimPeriod ) public view override returns (ScheduleCreationParams memory result) { // Default to current block timestamp if no start date is provided. diff --git a/packages/automation-contracts/scheduler/contracts/interface/IVestingSchedulerV2.sol b/packages/automation-contracts/scheduler/contracts/interface/IVestingSchedulerV2.sol index 2bbefc5e1c..f237e8449f 100644 --- a/packages/automation-contracts/scheduler/contracts/interface/IVestingSchedulerV2.sol +++ b/packages/automation-contracts/scheduler/contracts/interface/IVestingSchedulerV2.sol @@ -101,6 +101,7 @@ interface IVestingSchedulerV2 { * @param flowRate The flowRate for the stream * @param cliffAmount The amount to be transferred at the cliff * @param endDate The timestamp when the stream should stop. + * @param claimValidityDate Date before which the claimable schedule must be claimed * @param ctx Superfluid context used when batching operations. (or bytes(0) if not SF batching) */ function createVestingSchedule( @@ -111,6 +112,7 @@ interface IVestingSchedulerV2 { int96 flowRate, uint256 cliffAmount, uint32 endDate, + uint32 claimValidityDate, bytes memory ctx ) external returns (bytes memory newCtx); @@ -124,7 +126,8 @@ interface IVestingSchedulerV2 { uint32 cliffDate, int96 flowRate, uint256 cliffAmount, - uint32 endDate + uint32 endDate, + uint32 claimValidityDate ) external; /** @@ -135,8 +138,9 @@ interface IVestingSchedulerV2 { * @param receiver Vesting receiver * @param totalAmount The total amount to be vested * @param totalDuration The total duration of the vestingß - * @param cliffPeriod The cliff period of the vesting * @param startDate Timestamp when the vesting should start + * @param cliffPeriod The cliff period of the vesting + * @param claimPeriod The claim availability period * @param ctx Superfluid context used when batching operations. (or bytes(0) if not SF batching) */ function createVestingScheduleFromAmountAndDuration( @@ -144,50 +148,12 @@ interface IVestingSchedulerV2 { address receiver, uint256 totalAmount, uint32 totalDuration, - uint32 cliffPeriod, uint32 startDate, + uint32 cliffPeriod, + uint32 claimPeriod, bytes memory ctx ) external returns (bytes memory newCtx); - /** - * @dev Returns all relevant information related to a new vesting schedule creation - * @dev based on the amounts and durations. - * @param superToken SuperToken to be vested - * @param receiver Vesting receiver - * @param totalAmount The total amount to be vested - * @param totalDuration The total duration of the vestingß - * @param cliffPeriod The cliff period of the vesting - * @param startDate Timestamp when the vesting should start - */ - function getCreateVestingScheduleParamsFromAmountAndDuration( - ISuperToken superToken, - address receiver, - uint256 totalAmount, - uint32 totalDuration, - uint32 cliffPeriod, - uint32 startDate, - uint32 claimPeriod - ) external returns (ScheduleCreationParams memory params); - - /** - * @dev Estimates the maximum possible ERC-20 token allowance needed for the vesting schedule - * @dev to work properly under all circumstances. - * @param vestingSchedule A vesting schedule (doesn't have to exist) - */ - function getMaximumNeededTokenAllowance( - VestingSchedule memory vestingSchedule - ) external returns (uint256); - - /** - * @dev Estimates maximum ERC-20 token allowance needed for an existing vesting schedule. - * @param superToken SuperToken to be vested - * @param sender Vesting sender - * @param receiver Vesting receiver - */ - function getMaximumNeededTokenAllowance( - address superToken, address sender, address receiver - ) external returns (uint256); - /** * @dev See IVestingScheduler.createVestingScheduleFromAmountAndDuration overload for more details. */ @@ -196,8 +162,9 @@ interface IVestingSchedulerV2 { address receiver, uint256 totalAmount, uint32 totalDuration, + uint32 startDate, uint32 cliffPeriod, - uint32 startDate + uint32 claimPeriod ) external; /** @@ -209,7 +176,8 @@ interface IVestingSchedulerV2 { address receiver, uint256 totalAmount, uint32 totalDuration, - uint32 cliffPeriod + uint32 cliffPeriod, + uint32 claimPeriod ) external; /** @@ -221,139 +189,77 @@ interface IVestingSchedulerV2 { ISuperToken superToken, address receiver, uint256 totalAmount, - uint32 totalDuration + uint32 totalDuration, + uint32 claimPeriod ) external; /** - * @dev Creates a new vesting schedule - * @dev The function calculates the endDate, cliffDate, cliffAmount, flowRate, etc, based on the input arguments. - * @dev The function creates the vesting schedule with start date set to current timestamp, - * @dev and executes the start (i.e. creation of the flow) immediately. + * @dev Returns all relevant information related to a new vesting schedule creation + * @dev based on the amounts and durations. * @param superToken SuperToken to be vested * @param receiver Vesting receiver * @param totalAmount The total amount to be vested * @param totalDuration The total duration of the vestingß - * @param ctx Superfluid context used when batching operations. (or bytes(0) if not SF batching) + * @param startDate Timestamp when the vesting should start + * @param cliffPeriod The cliff period of the vesting + * @param claimPeriod The claim availability period */ - function createAndExecuteVestingScheduleFromAmountAndDuration( + function getCreateVestingScheduleParamsFromAmountAndDuration( ISuperToken superToken, address receiver, uint256 totalAmount, uint32 totalDuration, - bytes memory ctx - ) external returns (bytes memory newCtx); + uint32 startDate, + uint32 cliffPeriod, + uint32 claimPeriod + ) external returns (ScheduleCreationParams memory params); - /** - * @dev See IVestingScheduler.createAndExecuteVestingScheduleFromAmountAndDuration. + /** + * @dev Estimates the maximum possible ERC-20 token allowance needed for the vesting schedule + * @dev to work properly under all circumstances. + * @param vestingSchedule A vesting schedule (doesn't have to exist) */ - function createAndExecuteVestingScheduleFromAmountAndDuration( - ISuperToken superToken, - address receiver, - uint256 totalAmount, - uint32 totalDuration - ) external; + function getMaximumNeededTokenAllowance( + VestingSchedule memory vestingSchedule + ) external returns (uint256); /** - * @dev Creates a new vesting schedule that needs to be claimed by the receiver to start flowing. - * @dev If a non-zero cliffDate is set, the startDate has no effect other than being logged in an event. - * @dev If cliffDate is set to zero, the startDate becomes the cliff (transfer cliffAmount and start stream). + * @dev Estimates maximum ERC-20 token allowance needed for an existing vesting schedule. * @param superToken SuperToken to be vested + * @param sender Vesting sender * @param receiver Vesting receiver - * @param startDate Timestamp when the vesting should start - * @param claimValidityDate Date before which the claimable schedule must be claimed - * @param cliffDate Timestamp of cliff exectution - if 0, startDate acts as cliff - * @param flowRate The flowRate for the stream - * @param cliffAmount The amount to be transferred at the cliff - * @param endDate The timestamp when the stream should stop. - * @param ctx Superfluid context used when batching operations. (or bytes(0) if not SF batching) */ - function createClaimableVestingSchedule( - ISuperToken superToken, - address receiver, - uint32 startDate, - uint32 claimValidityDate, - uint32 cliffDate, - int96 flowRate, - uint256 cliffAmount, - uint32 endDate, - bytes memory ctx - ) external returns (bytes memory newCtx); - - /** - * @dev See IVestingScheduler.createClaimableVestingSchedule overload for more details. - */ - function createClaimableVestingSchedule( - ISuperToken superToken, - address receiver, - uint32 startDate, - uint32 claimValidityDate, - uint32 cliffDate, - int96 flowRate, - uint256 cliffAmount, - uint32 endDate - ) external; + function getMaximumNeededTokenAllowance( + address superToken, address sender, address receiver + ) external returns (uint256); /** - * @dev Creates a new vesting schedule that needs to be claimed by the receiver to start flowing. - * @dev The function makes it more intuitive to create a vesting schedule compared to the original function. + * @dev Creates a new vesting schedule * @dev The function calculates the endDate, cliffDate, cliffAmount, flowRate, etc, based on the input arguments. + * @dev The function creates the vesting schedule with start date set to current timestamp, + * @dev and executes the start (i.e. creation of the flow) immediately. * @param superToken SuperToken to be vested * @param receiver Vesting receiver - * @param totalAmount The total amount to be vested - * @param totalDuration The total duration of the vesting - * @param claimPeriod The claim availability period - * @param cliffPeriod The cliff period of the vesting - * @param startDate Timestamp when the vesting should start + * @param totalAmount The total amount to be vested + * @param totalDuration The total duration of the vestingß * @param ctx Superfluid context used when batching operations. (or bytes(0) if not SF batching) */ - function createClaimableVestingScheduleFromAmountAndDuration( + function createAndExecuteVestingScheduleFromAmountAndDuration( ISuperToken superToken, address receiver, uint256 totalAmount, uint32 totalDuration, - uint32 claimPeriod, - uint32 cliffPeriod, - uint32 startDate, bytes memory ctx ) external returns (bytes memory newCtx); - /** - * @dev See IVestingScheduler.createClaimableVestingScheduleFromAmountAndDuration overload for more details. - */ - function createClaimableVestingScheduleFromAmountAndDuration( - ISuperToken superToken, - address receiver, - uint256 totalAmount, - uint32 totalDuration, - uint32 claimPeriod, - uint32 cliffPeriod, - uint32 startDate - ) external; - - /** - * @dev See IVestingScheduler.createClaimableVestingScheduleFromAmountAndDuration overload for more details. - * The startDate is set to current block timestamp. - */ - function createClaimableVestingScheduleFromAmountAndDuration( - ISuperToken superToken, - address receiver, - uint256 totalAmount, - uint32 totalDuration, - uint32 claimPeriod, - uint32 cliffPeriod - ) external; - - /** - * @dev See IVestingScheduler.createClaimableVestingScheduleFromAmountAndDuration overload for more details. - * The startDate is set to current block timestamp. - * Cliff period is not applied. + /** + * @dev See IVestingScheduler.createAndExecuteVestingScheduleFromAmountAndDuration. */ - function createClaimableVestingScheduleFromAmountAndDuration( + function createAndExecuteVestingScheduleFromAmountAndDuration( ISuperToken superToken, address receiver, uint256 totalAmount, - uint32 totalDuration, - uint32 claimPeriod + uint32 totalDuration ) external; /** diff --git a/packages/automation-contracts/scheduler/test/VestingSchedulerV2.t.sol b/packages/automation-contracts/scheduler/test/VestingSchedulerV2.t.sol index cf825f5765..d398f97d3c 100644 --- a/packages/automation-contracts/scheduler/test/VestingSchedulerV2.t.sol +++ b/packages/automation-contracts/scheduler/test/VestingSchedulerV2.t.sol @@ -142,6 +142,7 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { FLOW_RATE, CLIFF_TRANSFER_AMOUNT, END_DATE, + 0, EMPTY_CTX ); vm.stopPrank(); @@ -149,15 +150,15 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { function _createClaimableVestingScheduleWithDefaultData(address sender, address receiver) private { vm.startPrank(sender); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( superToken, receiver, START_DATE, - CLAIM_VALIDITY_DATE, CLIFF_DATE, FLOW_RATE, CLIFF_TRANSFER_AMOUNT, END_DATE, + CLAIM_VALIDITY_DATE, EMPTY_CTX ); vm.stopPrank(); @@ -165,15 +166,15 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { function _createClaimableVestingScheduleWithClaimDateAfterEndDate(address sender, address receiver, uint256 delayAfterEndDate) private { vm.startPrank(sender); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( superToken, receiver, START_DATE, - END_DATE + uint32(delayAfterEndDate), CLIFF_DATE, FLOW_RATE, CLIFF_TRANSFER_AMOUNT, END_DATE, + END_DATE + uint32(delayAfterEndDate), EMPTY_CTX ); vm.stopPrank(); @@ -301,6 +302,7 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { FLOW_RATE, CLIFF_TRANSFER_AMOUNT, END_DATE, + 0, EMPTY_CTX ); @@ -314,6 +316,7 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { FLOW_RATE, CLIFF_TRANSFER_AMOUNT, END_DATE, + 0, EMPTY_CTX ); @@ -327,6 +330,7 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { FLOW_RATE, CLIFF_TRANSFER_AMOUNT, END_DATE, + 0, EMPTY_CTX ); @@ -340,6 +344,7 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { 0, CLIFF_TRANSFER_AMOUNT, END_DATE, + 0, EMPTY_CTX ); @@ -353,6 +358,7 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { FLOW_RATE, CLIFF_TRANSFER_AMOUNT, END_DATE, + 0, EMPTY_CTX ); @@ -366,6 +372,7 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { FLOW_RATE, 0, END_DATE, + 0, EMPTY_CTX ); @@ -379,6 +386,7 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { FLOW_RATE, CLIFF_TRANSFER_AMOUNT, 0, + 0, EMPTY_CTX ); @@ -392,6 +400,7 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { FLOW_RATE, 0, END_DATE, + 0, EMPTY_CTX ); @@ -405,6 +414,7 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { FLOW_RATE, CLIFF_TRANSFER_AMOUNT, CLIFF_DATE, + 0, EMPTY_CTX ); @@ -418,6 +428,7 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { FLOW_RATE, CLIFF_TRANSFER_AMOUNT, CLIFF_DATE, + 0, EMPTY_CTX ); @@ -431,6 +442,7 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { FLOW_RATE, CLIFF_TRANSFER_AMOUNT, END_DATE, + 0, EMPTY_CTX ); @@ -445,6 +457,7 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { FLOW_RATE, CLIFF_TRANSFER_AMOUNT, CLIFF_DATE + 2 days, + 0, EMPTY_CTX ); } @@ -587,6 +600,7 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { FLOW_RATE, 0, END_DATE, + 0, EMPTY_CTX ); superToken.increaseAllowance(address(vestingScheduler), type(uint256).max); @@ -775,6 +789,7 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { FLOW_RATE, CLIFF_TRANSFER_AMOUNT, END_DATE, + 0, EMPTY_CTX ); // --- @@ -831,10 +846,11 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { vestingScheduler.createVestingScheduleFromAmountAndDuration( superToken, bob, - 0, - 1209600, - 604800, - uint32(block.timestamp), + 0, // amount + 1209600, // duration + uint32(block.timestamp), // startDate + 604800, // cliffPeriod + 0, // claimPeriod EMPTY_CTX ); @@ -843,10 +859,11 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { vestingScheduler.createVestingScheduleFromAmountAndDuration( superToken, bob, - 1 ether, - 1209600, - 0, - uint32(block.timestamp - 1), + 1 ether, // amount + 1209600, // duration + uint32(block.timestamp - 1), // startDate + 0, // cliffPeriod + 0, // claimPeriod EMPTY_CTX ); @@ -855,10 +872,11 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { vestingScheduler.createVestingScheduleFromAmountAndDuration( superToken, bob, - type(uint256).max, - 1209600, - 0, - uint32(block.timestamp), + type(uint256).max, // amount + 1209600, // duration + uint32(block.timestamp), // startDate + 0, // cliffPeriod + 0, // claimPeriod EMPTY_CTX ); @@ -867,10 +885,11 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { vestingScheduler.createVestingScheduleFromAmountAndDuration( superToken, bob, - 1 ether, - type(uint32).max, - 0, - uint32(block.timestamp), + 1 ether, // amount + type(uint32).max, // duration + uint32(block.timestamp), // startDate + 0, // cliffPeriod + 0, // claimPeriod EMPTY_CTX ); @@ -879,10 +898,11 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { vestingScheduler.createVestingScheduleFromAmountAndDuration( superToken, bob, - 1 ether, - 1209600, - 604800, - uint32(block.timestamp - 1), + 1 ether, // amount + 1209600, // duration + uint32(block.timestamp - 1), // startDate + 604800, // cliffPeriod + 0, // claimPeriod EMPTY_CTX ); } @@ -911,8 +931,9 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { bob, totalVestedAmount, vestingDuration, - 0, - startDate, + startDate, + 0, // cliffPeriod + 0, // claimPeriod EMPTY_CTX ); } else { @@ -921,8 +942,9 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { bob, totalVestedAmount, vestingDuration, - 0, - startDate + startDate, + 0, // cliffPeriod + 0 // claimPeriod ); } vm.stopPrank(); @@ -956,8 +978,9 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { bob, totalVestedAmount, vestingDuration, - cliffPeriod, startDate, + cliffPeriod, + 0, EMPTY_CTX ); } else { @@ -966,8 +989,9 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { bob, totalVestedAmount, vestingDuration, + startDate, cliffPeriod, - startDate + 0 ); } vm.stopPrank(); @@ -1064,7 +1088,7 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { expectedSchedule.endDate, expectedSchedule.remainderAmount ), - vestingScheduler.getCreateVestingScheduleParamsFromAmountAndDuration(superToken, bob, totalAmount, totalDuration, cliffPeriod, startDate, 0)); + vestingScheduler.getCreateVestingScheduleParamsFromAmountAndDuration(superToken, bob, totalAmount, totalDuration, startDate, cliffPeriod, 0)); vm.expectEmit(); emit VestingScheduleCreated(superToken, alice, bob, $.expectedStartDate, $.expectedCliffDate, expectedSchedule.flowRate, expectedSchedule.endDate, expectedSchedule.cliffAmount, 0, expectedSchedule.remainderAmount); @@ -1078,7 +1102,8 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { bob, totalAmount, totalDuration, - cliffPeriod + cliffPeriod, + 0 ); } else { if (randomizer % 3 == 0) { @@ -1088,8 +1113,9 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { bob, totalAmount, totalDuration, + startDate, cliffPeriod, - startDate + 0 ); } else { console.log("Using the overload with superfluid context."); @@ -1098,8 +1124,9 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { bob, totalAmount, totalDuration, - cliffPeriod, startDate, + cliffPeriod, + 0, EMPTY_CTX ); } @@ -1196,15 +1223,15 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { superToken, alice, bob, START_DATE, CLIFF_DATE, FLOW_RATE, END_DATE, CLIFF_TRANSFER_AMOUNT, CLAIM_VALIDITY_DATE, 0); vm.startPrank(alice); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( superToken, bob, START_DATE, - CLAIM_VALIDITY_DATE, CLIFF_DATE, FLOW_RATE, CLIFF_TRANSFER_AMOUNT, END_DATE, + CLAIM_VALIDITY_DATE, EMPTY_CTX ); vm.stopPrank(); @@ -1225,15 +1252,15 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { superToken, alice, bob, START_DATE, CLIFF_DATE, FLOW_RATE, END_DATE, CLIFF_TRANSFER_AMOUNT, CLAIM_VALIDITY_DATE, 0); vm.startPrank(alice); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( superToken, bob, START_DATE, - CLAIM_VALIDITY_DATE, CLIFF_DATE, FLOW_RATE, CLIFF_TRANSFER_AMOUNT, END_DATE, + CLAIM_VALIDITY_DATE, EMPTY_CTX ); vm.stopPrank(); @@ -1254,15 +1281,15 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { superToken, alice, bob, START_DATE, CLIFF_DATE, FLOW_RATE, END_DATE, CLIFF_TRANSFER_AMOUNT, CLAIM_VALIDITY_DATE, 0); vm.startPrank(alice); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( superToken, bob, START_DATE, - CLAIM_VALIDITY_DATE, CLIFF_DATE, FLOW_RATE, CLIFF_TRANSFER_AMOUNT, - END_DATE + END_DATE, + CLAIM_VALIDITY_DATE ); vm.stopPrank(); @@ -1280,199 +1307,199 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { vm.startPrank(alice); // revert with superToken = 0 vm.expectRevert(IVestingSchedulerV2.ZeroAddress.selector); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( ISuperToken(address(0)), bob, START_DATE, - 0, // claimValidityDate CLIFF_DATE, FLOW_RATE, CLIFF_TRANSFER_AMOUNT, END_DATE, + CLAIM_VALIDITY_DATE, EMPTY_CTX ); // revert with receivers = sender vm.expectRevert(IVestingSchedulerV2.AccountInvalid.selector); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( superToken, alice, START_DATE, - 0, // claimValidityDate CLIFF_DATE, FLOW_RATE, CLIFF_TRANSFER_AMOUNT, END_DATE, + CLAIM_VALIDITY_DATE, EMPTY_CTX ); // revert with receivers = address(0) vm.expectRevert(IVestingSchedulerV2.AccountInvalid.selector); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( superToken, address(0), START_DATE, - 0, // claimValidityDate CLIFF_DATE, FLOW_RATE, CLIFF_TRANSFER_AMOUNT, END_DATE, + CLAIM_VALIDITY_DATE, EMPTY_CTX ); // revert with flowRate = 0 vm.expectRevert(IVestingSchedulerV2.FlowRateInvalid.selector); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( superToken, bob, START_DATE, - 0, // claimValidityDate CLIFF_DATE, 0, CLIFF_TRANSFER_AMOUNT, END_DATE, + CLAIM_VALIDITY_DATE, EMPTY_CTX ); // revert with cliffDate = 0 but cliffAmount != 0 vm.expectRevert(IVestingSchedulerV2.CliffInvalid.selector); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( superToken, bob, 0, - 0, // claimValidityDate 0, FLOW_RATE, CLIFF_TRANSFER_AMOUNT, END_DATE, + CLAIM_VALIDITY_DATE, EMPTY_CTX ); // revert with startDate < block.timestamp && cliffDate = 0 vm.expectRevert(IVestingSchedulerV2.TimeWindowInvalid.selector); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( superToken, bob, uint32(block.timestamp - 1), - 0, // claimValidityDate 0, FLOW_RATE, 0, END_DATE, + CLAIM_VALIDITY_DATE, EMPTY_CTX ); // revert with endDate = 0 vm.expectRevert(IVestingSchedulerV2.TimeWindowInvalid.selector); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( superToken, bob, START_DATE, - 0, // claimValidityDate CLIFF_DATE, FLOW_RATE, CLIFF_TRANSFER_AMOUNT, 0, + CLAIM_VALIDITY_DATE, EMPTY_CTX ); // revert with cliffAndFlowDate < block.timestamp vm.expectRevert(IVestingSchedulerV2.TimeWindowInvalid.selector); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( superToken, bob, 0, - 0, // claimValidityDate uint32(block.timestamp) - 1, FLOW_RATE, 0, END_DATE, + CLAIM_VALIDITY_DATE, EMPTY_CTX ); // revert with cliffAndFlowDate >= endDate vm.expectRevert(IVestingSchedulerV2.TimeWindowInvalid.selector); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( superToken, bob, START_DATE, - 0, // claimValidityDate CLIFF_DATE, FLOW_RATE, CLIFF_TRANSFER_AMOUNT, CLIFF_DATE, + CLAIM_VALIDITY_DATE, EMPTY_CTX ); // revert with cliffAndFlowDate + startDateValidFor >= endDate - endDateValidBefore vm.expectRevert(IVestingSchedulerV2.TimeWindowInvalid.selector); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( superToken, bob, START_DATE, - 0, // claimValidityDate CLIFF_DATE, FLOW_RATE, CLIFF_TRANSFER_AMOUNT, CLIFF_DATE, + CLAIM_VALIDITY_DATE, EMPTY_CTX ); // revert with startDate > cliffDate vm.expectRevert(IVestingSchedulerV2.TimeWindowInvalid.selector); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( superToken, bob, CLIFF_DATE + 1, - 0, // claimValidityDate CLIFF_DATE, FLOW_RATE, CLIFF_TRANSFER_AMOUNT, END_DATE, + CLAIM_VALIDITY_DATE, EMPTY_CTX ); // revert with vesting duration < 7 days vm.expectRevert(IVestingSchedulerV2.TimeWindowInvalid.selector); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( superToken, bob, START_DATE, - 0, // claimValidityDate CLIFF_DATE, FLOW_RATE, CLIFF_TRANSFER_AMOUNT, CLIFF_DATE + 2 days, + CLAIM_VALIDITY_DATE, EMPTY_CTX ); // revert with invalid claim validity date (before schedule/cliff start) vm.expectRevert(IVestingSchedulerV2.TimeWindowInvalid.selector); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( superToken, bob, START_DATE, - CLIFF_DATE - 1, CLIFF_DATE, FLOW_RATE, CLIFF_TRANSFER_AMOUNT, END_DATE, + CLIFF_DATE - 1, EMPTY_CTX ); } function test_createClaimableVestingSchedule_dataExists() public { vm.startPrank(alice); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( superToken, bob, START_DATE, - 0, // claimValidityDate CLIFF_DATE, FLOW_RATE, CLIFF_TRANSFER_AMOUNT, END_DATE, + CLAIM_VALIDITY_DATE, EMPTY_CTX ); vm.stopPrank(); @@ -1480,15 +1507,15 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { vm.expectRevert(IVestingSchedulerV2.ScheduleAlreadyExists.selector); vm.startPrank(alice); - vestingScheduler.createClaimableVestingSchedule( + vestingScheduler.createVestingSchedule( superToken, bob, START_DATE, - 0, // claimValidityDate CLIFF_DATE, FLOW_RATE, CLIFF_TRANSFER_AMOUNT, END_DATE, + CLAIM_VALIDITY_DATE, EMPTY_CTX ); vm.stopPrank(); @@ -1514,25 +1541,25 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { vm.startPrank(alice); bool useCtx = randomizer % 2 == 0; if (useCtx) { - vestingScheduler.createClaimableVestingScheduleFromAmountAndDuration( + vestingScheduler.createVestingScheduleFromAmountAndDuration( superToken, bob, totalVestedAmount, vestingDuration, - claimPeriod, - 0, startDate, + 0, // cliffPeriod + claimPeriod, EMPTY_CTX ); } else { - vestingScheduler.createClaimableVestingScheduleFromAmountAndDuration( + vestingScheduler.createVestingScheduleFromAmountAndDuration( superToken, bob, totalVestedAmount, vestingDuration, - claimPeriod, - 0, - startDate + startDate, + 0, // cliffPeriod + claimPeriod ); } vm.stopPrank(); @@ -1567,7 +1594,7 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { vm.startPrank(alice); - vestingScheduler.createClaimableVestingScheduleFromAmountAndDuration( + vestingScheduler.createVestingScheduleFromAmountAndDuration( superToken, bob, totalVestedAmount, @@ -1598,25 +1625,25 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { vm.startPrank(alice); bool useCtx = randomizer % 2 == 0; if (useCtx) { - vestingScheduler.createClaimableVestingScheduleFromAmountAndDuration( + vestingScheduler.createVestingScheduleFromAmountAndDuration( superToken, bob, totalVestedAmount, vestingDuration, - claimPeriod, - cliffPeriod, startDate, + cliffPeriod, + claimPeriod, EMPTY_CTX ); } else { - vestingScheduler.createClaimableVestingScheduleFromAmountAndDuration( + vestingScheduler.createVestingScheduleFromAmountAndDuration( superToken, bob, totalVestedAmount, vestingDuration, - claimPeriod, + startDate, cliffPeriod, - startDate + claimPeriod ); } vm.stopPrank(); @@ -1644,13 +1671,13 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { vm.startPrank(alice); - vestingScheduler.createClaimableVestingScheduleFromAmountAndDuration( + vestingScheduler.createVestingScheduleFromAmountAndDuration( superToken, bob, totalVestedAmount, vestingDuration, - claimPeriod, - cliffPeriod + cliffPeriod, + claimPeriod ); vm.stopPrank(); @@ -1661,66 +1688,66 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { superToken.increaseAllowance(address(vestingScheduler), type(uint256).max); vm.expectRevert(IVestingSchedulerV2.FlowRateInvalid.selector); - vestingScheduler.createClaimableVestingScheduleFromAmountAndDuration( + vestingScheduler.createVestingScheduleFromAmountAndDuration( superToken, bob, - 0, - 1209600, - 15 days, - 604800, - uint32(block.timestamp), + 0, // amount + 1209600, // duration + uint32(block.timestamp), // startDate + 604800, // cliffPeriod + 15 days, // claimPeriod EMPTY_CTX ); console.log("Revert with cliff and start in history."); vm.expectRevert(IVestingSchedulerV2.TimeWindowInvalid.selector); - vestingScheduler.createClaimableVestingScheduleFromAmountAndDuration( + vestingScheduler.createVestingScheduleFromAmountAndDuration( superToken, bob, - 1 ether, - 1209600, - 15 days, - 0, - uint32(block.timestamp - 1), + 1 ether, // amount + 1209600, // duration + uint32(block.timestamp - 1), // startDate + 0, // cliffPeriod + 15 days, // claimPeriod EMPTY_CTX ); console.log("Revert with overflow."); vm.expectRevert("SafeCast: value doesn't fit in 96 bits"); - vestingScheduler.createClaimableVestingScheduleFromAmountAndDuration( + vestingScheduler.createVestingScheduleFromAmountAndDuration( superToken, bob, - type(uint256).max, - 1209600, - 15 days, - 0, - uint32(block.timestamp), + type(uint256).max, // amount + 1209600, // duration + uint32(block.timestamp), // startDate + 0, // cliffPeriod + 15 days, // claimPeriod EMPTY_CTX ); console.log("Revert with underflow/overflow."); vm.expectRevert(); // todo: the right error - vestingScheduler.createClaimableVestingScheduleFromAmountAndDuration( + vestingScheduler.createVestingScheduleFromAmountAndDuration( superToken, bob, - 1 ether, - type(uint32).max, - 15 days, - 0, - uint32(block.timestamp), + 1 ether, // amount + type(uint32).max, // duration + uint32(block.timestamp), // startDate + 0, // cliffPeriod + 15 days, // claimPeriod EMPTY_CTX ); console.log("Revert with start date in history."); vm.expectRevert(IVestingSchedulerV2.TimeWindowInvalid.selector); - vestingScheduler.createClaimableVestingScheduleFromAmountAndDuration( + vestingScheduler.createVestingScheduleFromAmountAndDuration( superToken, bob, - 1 ether, - 1209600, - 15 days, - 604800, - uint32(block.timestamp - 1), + 1 ether, // amount + 1209600, // duration + uint32(block.timestamp - 1), // startDate + 604800, // cliffPeriod + 15 days, // claimPeriod EMPTY_CTX ); } @@ -1969,8 +1996,9 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { bob, totalAmount, totalDuration, - cliffPeriod, startDate, + cliffPeriod, + 0, EMPTY_CTX ); vm.stopPrank(); @@ -2061,14 +2089,14 @@ contract VestingSchedulerV2Tests is FoundrySuperfluidTester { // Act vm.startPrank(alice); - vestingScheduler.createClaimableVestingScheduleFromAmountAndDuration( + vestingScheduler.createVestingScheduleFromAmountAndDuration( superToken, bob, totalAmount, totalDuration, - claimPeriod, - cliffPeriod, startDate, + cliffPeriod, + claimPeriod, EMPTY_CTX ); vm.stopPrank();