Pull Request: Implement Creator Co-Op Split (Multi-Sig Revenue Sharing) (#56, #15) - #79
Merged
elizabetheonoja-art merged 2 commits intoMar 25, 2026
Conversation
|
@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! 🚀 |
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.
📝 Description$10^7$ , ensuring that even the smallest fractions of a cent are accounted for during the division process.
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
🎯 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