-
Notifications
You must be signed in to change notification settings - Fork 237
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-CONTRACT] Vesting Scheduler V3 #2054
base: dev
Are you sure you want to change the base?
Conversation
- Rename `updateVestingSchedule` to `updateVestingScheduleEndDate` - Optimize schedule update mechanism with more precise vesting calculations - Simplify flow rate and remainder amount handling - Update error handling and edge case management
- Add comprehensive test cases for `updateVestingScheduleEndDate` and `updateVestingScheduleAmount` - Improve error handling tests for non-existent vesting schedules - Refactor existing tests to use new method signatures - Optimize test scenarios for end date and amount updates
- Introduce `_settle` method to handle vesting schedule updates and tracking - Remove `totalAmount` from storage and improve vesting calculation logic - Add `lastUpdated` timestamp to track precise vesting progress - Enhance early termination and compensation handling - Commented out unused update methods with TODOs for future implementation
- Update test cases to reflect recent refactoring of vesting schedule mechanisms - Remove commented-out test methods for non-existent schedule updates - Improve settlement calculation by using total amount to vest - Simplify vesting schedule verification in test scenarios
- Adjust settlement calculation to subtract cliff amount from already vested amount - Optimize total vested amount calculation by improving parentheses placement - Refactor `_executeCliffAndFlow` and `executeEndVesting` to handle vesting amounts more precisely
- Update test cases to improve vesting amount and timing calculations - Simplify test setup and execution flow - Enhance precision in settlement and balance verification - Optimize time warping and event expectation in test methods
- Refactor `_getTotalVestedAmount` to enhance clarity and precision of vesting calculations - Correct remainder amount calculation by subtracting flow rate duration from total vested amount - Add comments to clarify vesting logic for different schedule stages - Optimize flow amount calculation with improved variable naming
- Replace hardcoded early end time calculation with bounded randomization - Remove unused total amount to vest calculation - Comment out previous early end time calculation method - Improve test scenario randomness and flexibility
- Restore original early end time calculation using division - Remove bounded randomization approach - Simplify early vesting end time selection logic
…hedule update logic - Add implementation for `updateVestingScheduleFlowRateFromAmount` method - Enhance schedule update validation with comprehensive time window checks - Improve settlement logic in `_settle` method - Optimize flow rate and remainder amount calculations during schedule updates - Add comments to clarify update conditions and vesting logic
…dulerV3 - Implement new events `VestingScheduleTotalAmountUpdated` and `VestingScheduleEndDateUpdated` - Update event emissions to include remainder amount and flow rate details - Rename `updateVestingScheduleEndDate` to `updateVestingScheduleFlowRateFromEndDate` - Enhance event logging with comprehensive schedule update information
… updates - Modify test methods to use `updateVestingScheduleFlowRateFromEndDate` - Enhance calculation of expected remainder and new flow rate - Update test assertions to verify total vested amount and balance transfers - Refactor batch operation encoding to match new method signature
…method - Delete unused and commented-out method from VestingSchedulerV3 - Clean up code by removing deprecated implementation with TODO comments - Simplify contract by eliminating unimplemented method
…dates - Implement test scenarios for updating vesting schedules with longer and shorter durations - Add test cases for updating vesting schedule amounts (both larger and smaller) - Uncomment and update previously commented-out test method for non-existent schedule updates - Enhance test coverage for flow rate and remainder calculations during schedule modifications
added support for batch calls using OPERATION_TYPE_ERC2771_FORWARD_CALL
…hedulerV3 deployment
|
||
uint32 endDate = startDate + totalDuration; | ||
int96 flowRate = SafeCast.toInt96(SafeCast.toInt256(totalAmount / totalDuration)); | ||
uint96 remainderAmount = SafeCast.toUint96(totalAmount - (SafeCast.toUint256(flowRate) * totalDuration)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to have this in a separate function and re-use it in the update function.
|
||
// Update the vesting flow rate and remainder amount | ||
vestingSchedules[agg.id].flowRate = SafeCast.toInt96( | ||
SafeCast.toInt256(totalVestedAmount - alreadyVestedAmount) / SafeCast.toInt256(endDate - block.timestamp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be more readable to have a variables:
uint256 amountLeftToVest = _getTotalVestedAmount(schedule) - _settleAlreadyVestedAmount(agg);
uint32 timeLeftToVest = endDate - block.timestamp;
And pass those into a re-used function that calculates the flow rate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed and updated
|
||
function _settle(ScheduleAggregate memory agg) internal returns (uint256 alreadyVestedAmount) { | ||
VestingSchedule memory schedule = agg.schedule; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Best to have the guard clauses (reverts or asserts) in here as well, just in case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed. Added assert clause in _settle
ensuring that settlement cannot occur before the cliffAndFlowDate
Vesting Scheduler V3 offers the possibility for vesting sender to update their vesting schedule amounts and/or durations.
Modifications includes :
updateVestingSchedule
method with dynamic flow rate calculationOptimism Sepolia Deployment :
Contract is deployed at 0x2dCFbF5BcE0522257E78bF164871770D30634A96