Skip to content

Implement payment delegation, compute budget estimation, dispute mechanism, and protocol fee#338

Open
brite-side0 wants to merge 1 commit into
Stellar-split:mainfrom
brite-side0:feature/issues-315-316-325-326
Open

Implement payment delegation, compute budget estimation, dispute mechanism, and protocol fee#338
brite-side0 wants to merge 1 commit into
Stellar-split:mainfrom
brite-side0:feature/issues-315-316-325-326

Conversation

@brite-side0

Copy link
Copy Markdown

Summary

  • Issue Add payment delegation — allow a third party to pay on behalf of a payer #315 — Payment delegation: set_delegation(invoice_id, on_behalf_of, delegate) grants single-use authorization; pay_invoice_delegated(executor, invoice_id, amount, nonce, on_behalf_of) lets a third party fund on behalf of another address. Both payer and executor are recorded; a DelegatedPayment event is emitted. Delegation is consumed on first use (replay-proof).

  • Issue Add compute budget estimation utility for all contract functions #316 — Compute budget estimation: estimate_compute(function_name, recipient_count) returns { instructions, mem_bytes, read_entries, write_entries } for all public functions. Warning event emitted above 80% of the Soroban instruction limit. Adds COMPUTE_BUDGETS.md with measured counts for 1/5/20 recipients and a new CI workflow (.github/workflows/compute-budget.yml) that posts a budget table on each PR.

  • Issue Add invoice dispute mechanism with arbitration window #325 — Invoice dispute mechanism: raise_payer_dispute(invoice_id, payer, reason_hash) callable by any payer within 48 ledgers of full funding — sets disputed = true and blocks release. resolve_payer_dispute(invoice_id, admin, outcome) (admin only) either releases (Approved) or refunds (Refunded). expire_dispute(invoice_id) auto-releases after 72 ledgers if unresolved. get_dispute() returns the DisputeRecord. Events: DisputeRaised, DisputeResolved, DisputeExpired.

  • Issue Implement protocol fee distribution to treasury address #326 — Protocol fee distribution: set_protocol_fee(admin, rate_bps, treasury) configures a fee (0–500 bps, default 0 = disabled). Fee is deducted atomically from release amount and transferred to treasury inside _release_full before recipient payouts. get_fee_config() returns { rate_bps, treasury }. FeePaid event emitted on each release.

Test plan

  • set_delegation + pay_invoice_delegated: delegation grant → delegated pay → confirm payer recorded as on_behalf_of, replay attack (second call) panics with "no delegation authorization"
  • raise_payer_dispute within 48-ledger window → release blocked → resolve_payer_dispute(Approved) releases funds
  • raise_payer_disputeresolve_payer_dispute(Refunded) → payers receive refunds
  • raise_payer_dispute → wait 73 ledgers → expire_dispute releases to recipients
  • set_protocol_fee(100, treasury)release → treasury receives 1% → recipients receive 99%
  • set_protocol_fee(0, treasury) → fee disabled (no-op path)
  • estimate_compute("release", 20) → returns values under 100,000,000 instructions

Closes #315
Closes #316
Closes #325
Closes #326

🤖 Generated with Claude Code

…protocol fee

Closes Stellar-split#315 — adds set_delegation/pay_invoice_delegated for third-party payments
Closes Stellar-split#316 — adds estimate_compute utility + COMPUTE_BUDGETS.md + CI workflow
Closes Stellar-split#325 — adds raise_payer_dispute/resolve_payer_dispute/expire_dispute with 48/72-ledger windows
Closes Stellar-split#326 — adds set_protocol_fee/get_fee_config with atomic fee transfer in _release_full

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@brite-side0 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

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

Labels

None yet

Projects

None yet

1 participant