Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[automations] VestingSchedulerV2 - unify claimable and non-claimable vesting creation functions #1970

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 24 additions & 166 deletions packages/automation-contracts/scheduler/contracts/VestingSchedulerV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase {
int96 flowRate,
uint256 cliffAmount,
uint32 endDate,
uint32 claimValidityDate,
bytes memory ctx
) external returns (bytes memory newCtx) {
newCtx = _validateAndCreateVestingSchedule(
ScheduleCreationParams({
superToken: superToken,
receiver: receiver,
startDate: startDate,
claimValidityDate: 0,
claimValidityDate: claimValidityDate,
cliffDate: cliffDate,
flowRate: flowRate,
cliffAmount: cliffAmount,
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -181,9 +184,9 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase {
receiver,
totalAmount,
totalDuration,
cliffPeriod,
startDate,
0 // claimPeriod
cliffPeriod,
claimPeriod
),
ctx
);
Expand All @@ -195,18 +198,19 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase {
address receiver,
uint256 totalAmount,
uint32 totalDuration,
uint32 startDate,
uint32 cliffPeriod,
uint32 startDate
uint32 claimPeriod
) external {
_validateAndCreateVestingSchedule(
getCreateVestingScheduleParamsFromAmountAndDuration(
superToken,
receiver,
totalAmount,
totalDuration,
cliffPeriod,
startDate,
0 // claimPeriod
cliffPeriod,
claimPeriod
),
bytes("")
);
Expand All @@ -218,17 +222,18 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase {
address receiver,
uint256 totalAmount,
uint32 totalDuration,
uint32 cliffPeriod
uint32 cliffPeriod,
uint32 claimPeriod
) external {
_validateAndCreateVestingSchedule(
getCreateVestingScheduleParamsFromAmountAndDuration(
superToken,
receiver,
totalAmount,
totalDuration,
cliffPeriod,
0, // startDate
0 // claimPeriod
cliffPeriod,
claimPeriod
),
bytes("")
);
Expand All @@ -239,17 +244,18 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase {
ISuperToken superToken,
address receiver,
uint256 totalAmount,
uint32 totalDuration
uint32 totalDuration,
uint32 claimPeriod
) external {
_validateAndCreateVestingSchedule(
getCreateVestingScheduleParamsFromAmountAndDuration(
superToken,
receiver,
totalAmount,
totalDuration,
0, // cliffPeriod
0, // startDate
0 // claimPeriod
0, // cliffPeriod
claimPeriod
),
bytes("")
);
Expand Down Expand Up @@ -302,8 +308,8 @@ contract VestingSchedulerV2 is IVestingSchedulerV2, SuperAppBase {
receiver,
totalAmount,
totalDuration,
0, // cliffPeriod
0, // startDate
0, // cliffPeriod
0 // claimValidityDate
),
ctx
Expand All @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
Loading
Loading