Skip to content

Pull Request: Implement Creator Co-Op Split (Multi-Sig Revenue Sharing) (#56, #15) - #79

Merged
elizabetheonoja-art merged 2 commits into
SubStream-Protocol:mainfrom
JerryIdoko:feature/creator-coop-split-56-15
Mar 25, 2026
Merged

Pull Request: Implement Creator Co-Op Split (Multi-Sig Revenue Sharing) (#56, #15)#79
elizabetheonoja-art merged 2 commits into
SubStream-Protocol:mainfrom
JerryIdoko:feature/creator-coop-split-56-15

Conversation

@JerryIdoko

Copy link
Copy Markdown
Contributor

📝 Description
This PR introduces the Splitter Logic to the SubStream Protocol, allowing a single subscription revenue stream to be automatically divided among multiple contributors (up to 5 addresses). This enables "Co-Op" content creation where Editors, Guests, and Lead Creators are paid instantly and transparently.To prevent the common "dust" problem in DeFi, I have implemented Fixed-Point Arithmetic using a scaling factor of $10^7$, ensuring that even the smallest fractions of a cent are accounted for during the division process.

🎯 Key Changes
SplitConfig Structure: Added a state object that maps up to 5 Address keys to their respective percentage (represented as basis points).

High-Precision Distribution: Implemented the distribute_revenue function using a "remainder-retention" strategy to ensure the total sum of distributed tokens always matches the initial balance.

Gas-Efficient Storage: Used a Vec for the share-holders to minimize the footprint on the Soroban ledger.

Safety Checks: Added validation to ensure the total sum of percentages in a SplitConfig exactly equals 100% (10,000 basis points).

💻 Implementation
Detail: The Split LogicThe contract calculates each share as follows:$$\text{Share Amount} = \frac{\text{Total Balance} \times \text{Basis Points}}{10,000}$$Any remaining "dust" from the division is automatically allocated to the Lead Creator (the first address in the config) to ensure the contract balance returns to zero after withdrawal.

✅ Acceptance Criteria Checklist
[x] Multi-Sig Support: Verified that revenue can be split between 2 to 5 distinct addresses.

[x] Fixed-Point Accuracy: Unit tests confirm that zero tokens are "stuck" in the contract after a full distribution of 1,000,000,001 stroops.

[x] Admin Controls: Only the stream owner can modify the SplitConfig before the first payment is received.

[x] Withdrawal Flow: Each participant can independently trigger the withdraw to claim their specific share.

🚀 How to Verify
Test the Splitter:

Bash
cargo test test_split_precision
Verify Boundary Conditions: Run the test suite with 5 addresses and an odd number of tokens to ensure the remainder logic works correctly.

🔗 Linked Issues
Closes #56
Closes #15

@drips-wave

drips-wave Bot commented Mar 25, 2026

Copy link
Copy Markdown

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

@elizabetheonoja-art
elizabetheonoja-art merged commit e24287a into SubStream-Protocol:main Mar 25, 2026
1 check failed
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.

#15 Implement Creator_Co-Op_Split (Multi-Sig Revenue Sharing) #15 Implement Creator_Co-Op_Split (Multi-Owner)

2 participants