feat: implement creator vesting contracts - #907
Merged
Kingsman-99 merged 2 commits intoSep 30, 2026
Merged
Conversation
|
@ochedev6789 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #878 — Implement creator vesting contracts
Implements a linear vesting schedule system that allows invoice creators to
attach time-based vesting schedules to their invoices.
#878 — Creator vesting contracts
New file:
contracts/split/src/creator_vesting_ext.rsCore functionality
A creator can attach a linear vesting schedule to any invoice they own. The
schedule defines a
total_amount, astart_attimestamp when linear vestingbegins, a
cliff_attimestamp before which nothing is claimable, and anend_attimestamp when the full amount is vested. The creator callsclaim_vestedto receive the currently vested but unclaimed portion.Vesting formula (after cliff):
Entry points
create_vesting_schedule(creator, invoice_id, total_amount, start_at, cliff_at, end_at)— creator only; must own the invoice;cliff_at ≥ start_atandend_at > start_at.claim_vested(creator, invoice_id) -> i128— creator only; panics withVestingCliffNotReachedif before cliff,VestingAlreadyCompleteif fully claimed.get_vesting_schedule(invoice_id) -> Option<VestingSchedule>— returns the schedule orNone.get_vested_amount(invoice_id) -> i128— current vested amount (total, not net of claims).Events
(split, vest_crt, invoice_id)— schedule created(split, vest_clm, invoice_id)— tokens claimedNew storage key
VestingKey::Schedule(invoice_id)— private enum increator_vesting_ext.rs(noInvoiceKeyvariant needed)New type:
VestingScheduleintypes.rsNew errors:
VestingNotFound = 84— no schedule exists for this invoiceVestingCliffNotReached = 85— nothing claimable yet (before cliff)VestingAlreadyComplete = 86— all tokens already claimedTests: 6 unit tests covering: create and get schedule, get none when absent, only creator can create, claim before cliff panics, get vested amount without schedule panics, invalid cliff before start panics.
Files changed
contracts/split/src/creator_vesting_ext.rscontracts/split/src/lib.rsmod creator_vesting_ext;andVestingScheduletype importcontracts/split/src/types.rsVestingSchedulestructcontracts/split/src/error.rsVestingNotFound = 84,VestingCliffNotReached = 85,VestingAlreadyComplete = 86contracts/split/src/events.rsvesting_schedule_createdandvesting_claimedevent functionsVerification
#[contractimpl] impl SplitContractpattern asdynamic_fee.rs,earnings_insurance.rs, and other established extension modules.VestingKeyis a private enum in the module.Closes #878
Closes #873
Closes #874
Closes #876