Implement payment delegation, compute budget estimation, dispute mechanism, and protocol fee#338
Open
brite-side0 wants to merge 1 commit into
Open
Conversation
…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>
|
@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! 🚀 |
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.
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; aDelegatedPaymentevent 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. AddsCOMPUTE_BUDGETS.mdwith 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 — setsdisputed = trueand blocksrelease.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 theDisputeRecord. 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_fullbefore recipient payouts.get_fee_config()returns{ rate_bps, treasury }.FeePaidevent emitted on each release.Test plan
set_delegation+pay_invoice_delegated: delegation grant → delegated pay → confirm payer recorded ason_behalf_of, replay attack (second call) panics with "no delegation authorization"raise_payer_disputewithin 48-ledger window →releaseblocked →resolve_payer_dispute(Approved)releases fundsraise_payer_dispute→resolve_payer_dispute(Refunded)→ payers receive refundsraise_payer_dispute→ wait 73 ledgers →expire_disputereleases to recipientsset_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 instructionsCloses #315
Closes #316
Closes #325
Closes #326
🤖 Generated with Claude Code