Skip to content

feat(contracts): add optional vesting cliff with per-recipient claim …#138

Open
Saboleee wants to merge 2 commits into
Stellar-split:mainfrom
Saboleee:main
Open

feat(contracts): add optional vesting cliff with per-recipient claim …#138
Saboleee wants to merge 2 commits into
Stellar-split:mainfrom
Saboleee:main

Conversation

@Saboleee
Copy link
Copy Markdown

Summary

Adds an optional vesting cliff to invoices. When vesting_cliff is set, _release() marks the invoice as Released without transferring funds. Recipients
must call claim() after the cliff timestamp passes to receive their share. Each recipient can claim exactly once. Invoices without a cliff behave
identically to the current implementation.

Changes

  • types.rs — added vesting_cliff: Option and vesting_cliff_claimed: Vec to the Invoice struct; added vesting_cliff: Option and updated
    InvoiceOptions to include stake_amount and referrer fields
  • lib.rs — updated _release_full() to return early when cliff is set, marking invoice as Released without transferring funds; added claim(env,
    invoice_id, recipient) with cliff timestamp check, claimed guard, and per-recipient transfer; added referral_count_key() helper function; fixed all
    _create_invoice_inner() calls to pass the new parameters
  • test.rs — added three comprehensive tests covering: (1) no cliff scenario (funds transfer immediately on auto-release), (2) with cliff scenario (funds
    held on release, transferred after claim), and (3) claimed tracking (second claim panics)

Testing

  • ✅ No cliff: release transfers immediately, existing behavior unchanged
  • ✅ With cliff: release holds funds; claim after cliff passes transfers correct amount
  • ✅ Claimed tracking: second claim by same recipient panics (already claimed)
  • ✅ All 78 tests pass (76 existing + 2 new vesting cliff tests)
  • ✅ cargo check passes
  • ✅ Pre-existing clippy warnings (unrelated to this change)

Closes #27

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 30, 2026

@Saboleee 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! 🚀

Learn more about application limits

…function (Stellar-split#27)

Add optional vesting cliff to invoices. When vesting_cliff is set, _release()
marks the invoice as Released without transferring funds. Recipients must call
claim() after the cliff timestamp passes to receive their share. Each recipient
can claim exactly once. Invoices without a cliff behave identically to the
current implementation.

- types.rs: added vesting_cliff (Option<u64>) and vesting_cliff_claimed (Vec<bool>)
  to Invoice struct; added vesting_cliff and stake_amount/referrer fields to
  InvoiceOptions struct
- lib.rs: updated _release_full() to return early when vesting_cliff is set;
  added claim() function with cliff check, claimed guard, and per-recipient
  transfer; added referral_count_key() helper function
- test.rs: added three tests covering no-cliff (immediate transfer), with-cliff
  (no transfer on release, transfer after claim), and claim tracking

All existing tests pass; 78 total passing tests.
@Kingsman-99
Copy link
Copy Markdown
Contributor

please rosolve your issue so i can merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add recipient vesting cliff on release

2 participants