Skip to content

Implement multi-tranche release schedule with configurable cliff period #348

Description

@Kingsman-99

Overview

Support invoices where funds are released in scheduled tranches rather than all at once. Contributors or clients can structure milestone-based payments with a cliff (nothing released until a date) followed by periodic tranches.

Requirements

  • Extend InvoiceOptions with tranches: Option<Vec<Tranche>> where Tranche { release_time: u64, bps: u32 } (basis points of total)
  • bps across all tranches must sum to exactly 10000 (validated at creation)
  • release_tranche(env, invoice_id, tranche_index) entry point — releases one tranche if current time ≥ its release_time and invoice is fully funded
  • Store released tranche indices to prevent double-release
  • Emit TrancheReleased { invoice_id, tranche_index, amount } event
  • Write tests: full vesting schedule, attempt release before time panics, double-release panics, bps not summing to 10000 panics at creation

Acceptance Criteria

  • Tranche validation at creation (sum of bps = 10000)
  • Per-tranche release with time gate
  • Double-release protection
  • Storage snapshot updated
  • All existing tests pass
  • cargo test --workspace passes with zero failures
  • cargo clippy --all-targets -- -D warnings produces zero warnings

Definition of Done

All CI checks must pass before the PR is reviewed.

Metadata

Metadata

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignOfficial Campaign | FWC26Campaign: Official Campaign | FWC26complexity: highComplex feature requiring deep knowledge - 200 ptsfeatureNew contract feature or operationgrantfoxIssue for GrantFox program

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions