Skip to content

Invoice Creator Revenue Share #559

Description

@Kingsman-99

Description

Platform fees accrue exclusively to the platform treasury, but invoice creators (e.g., freelancers or service providers deploying the dApp) have no on-chain mechanism to claim a portion of the collected total as their own service fee. A configurable creator_fee_bps field should allow the creator to declare a basis-point share deducted before recipient payouts, with a combined cap alongside the platform fee.

Technical Context

contracts/split/src/types.rs — add creator_fee_bps: u32 to the Invoice struct (valid range 0–10 000); contracts/split/src/lib.rsrelease_funds() computes creator_fee = total_collected * creator_fee_bps / 10_000 using checked_mul/checked_div, transfers to invoice.creator, then distributes the remainder to recipients; contracts/split/src/validation.rs — at initialize(), assert creator_fee_bps + platform_fee_bps <= 10_000; contracts/split/src/events.rs — emit event::creator_fee_paid(invoice_id, creator, amount).

Acceptance Criteria

  • Invoice stores creator_fee_bps and initialize() rejects values where creator_fee_bps + platform_fee_bps > 10_000 with Error::FeeSumExceedsCap
  • release_funds() deducts the creator fee from gross collected funds before computing per-recipient shares
  • The creator fee transfer occurs before any recipient transfer in every code path of release_funds()
  • A creator_fee_paid event is emitted with invoice ID, creator address, and exact fee amount on every successful release
  • Tests in contracts/split/src/tests/creator_fee_tests.rs cover zero fee, a representative non-zero fee, maximum combined fee, and over-cap rejection
  • All CI checks (cargo build --target wasm32-unknown-unknown, cargo test, cargo clippy) pass and the branch has no merge conflicts

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programcomplexity: highComplex feature requiring deep knowledge - 200 ptsfeatureNew contract feature or operation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions