Skip to content

feat(soroban-contracts): Add payment splitter contract for revenue sharing (#247) - #283

Merged
manoahLinks merged 1 commit into
crowdpass-live:mainfrom
amankoli09:feature/247-payment-splitter
Apr 27, 2026
Merged

feat(soroban-contracts): Add payment splitter contract for revenue sharing (#247)#283
manoahLinks merged 1 commit into
crowdpass-live:mainfrom
amankoli09:feature/247-payment-splitter

Conversation

@amankoli09

Copy link
Copy Markdown
Contributor

Summary

Implements PaymentSplitter, a Soroban smart contract that distributes
incoming token payments proportionally across multiple recipients using
configurable share weights.

Closes #247


Changes

New contract: soroban-contract/contracts/payment_splitter/

File Purpose
Cargo.toml Package manifest, links soroban-sdk + upgradeable
src/lib.rs Contract implementation
src/test.rs 19 unit tests

Modified

  • soroban-contract/Cargo.toml — registered payment_splitter as a workspace member

Features

  • Proportional splits — each recipient holds a u32 share weight; payout is balance × shares / total_shares
  • Dust-aware — indivisible remainder (from integer division) always forwarded to the first recipient; contract never accumulates un-claimable dust
  • Multi-token — any SEP-41 / Soroban token address works at release time
  • Admin-controlled recipient management
    • add_recipient(account, shares) — adds a new payee
    • remove_recipient(account) — O(1) swap-with-last removal
    • update_shares(account, new_shares) — adjust weights without re-initialization
  • Reentrancy guard — boolean lock on release() prevents cross-contract re-entry
  • Hard capMAX_RECIPIENTS = 50 to bound per-call resource usage
  • Upgradeable — inherits the project's time-lock upgrade pattern via upgradeable crate
  • Rich eventsPaymentReleased, RecipientAdded, RecipientRemoved, SharesUpdated

Tests (19 / 19 pass)

Category Tests
Initialization success, duplicate call, empty list, zero share, duplicate recipient, too many
Release equal shares, unequal shares (60/30/10), dust to first recipient, nothing to release, single recipient
Recipient management add, add duplicate, remove, remove nonexistent, update shares, update zero, update nonexistent
End-to-end add/remove recipients then release

Security Notes

  • Only the admin may call release(), add_recipient(), remove_recipient(), and update_shares() — prevents griefing
  • Reentrancy lock cleared in all early-return error paths
  • No floating-point arithmetic — all division is integer; dust handled explicitly

…crowdpass-live#247)

Implements a Soroban smart contract that distributes incoming token
payments proportionally across multiple recipients using configurable
share weights.

- Configurable share weights per recipient (u32)
- Multi-token support via any SEP-41 / Soroban token address
- Admin-controlled recipient management (add / remove / update shares)
- Dust-aware distribution: indivisible remainder forwarded to first recipient
- Reentrancy guard on release() to prevent re-entrant attacks
- Swap-with-last O(1) recipient removal algorithm
- Hard cap of 50 recipients to bound per-call resource usage
- Full upgradeable / time-lock pattern via upgradeable crate
- Rich event emissions: PaymentReleased, RecipientAdded, RecipientRemoved, SharesUpdated

19 unit tests covering:
- Initialization happy path and all error cases
- Release with equal shares, unequal shares, dust remainder, single recipient
- Add / remove / update recipient operations with error cases
- End-to-end: recipient mutation followed by release

Closes crowdpass-live#247
@drips-wave

drips-wave Bot commented Apr 27, 2026

Copy link
Copy Markdown

@amankoli09 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

@manoahLinks
manoahLinks merged commit 7a61134 into crowdpass-live:main Apr 27, 2026
2 of 4 checks passed
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.

soroban-contracts: Create payment splitter contract for revenue sharing

2 participants