[Smart Contracts] Dynamic Protocol Fee Architecture & Multi-Recipient Treasury Split
Overview & Background
Sustainable protocol governance requires flexible fee economics. Currently, protocol fees (if assessed) route into a single fixed administrative address without dynamic configuration or revenue-sharing logic. In a decentralized ecosystem, protocol fees must be routed across multiple stakeholders—such as a Community DAO Treasury, an Insurance Reserve Pool, and a Staking/Burn Mechanism—according to configurable basis points (BPS).
Detailed Problem Statement
- Single Point of Treasury Bottleneck:
- Routing 100% of protocol fees to a single key creates custody risk and requires complex off-chain re-distribution scripts.
- Hardcoded Fee Parameters:
- Protocol fee percentages cannot be adapted for promotional events, volume tiers, or ecosystem partner integrations without contract redeployments.
- Lack of Timelock and Safety Caps:
- Any fee adjustment must have an enforced maximum cap (e.g. max 1% / 100 BPS) and optional timelock delay to protect users against predatory fee hikes.
Technical Specification & Architecture
1. Treasury Split Structure (types.rs)
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct FeeRecipient {
pub recipient: Address,
pub share_bps: u32, // Basis points (100 = 1%, sum must equal 10,000)
}
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ProtocolFeeConfig {
pub fee_bps: u32, // Total fee in BPS (e.g. 25 BPS = 0.25%, max 100 BPS)
pub splits: Vec<FeeRecipient>, // Destination splits
pub is_enabled: bool,
}
2. Administrative Configuration Entrypoint
pub fn configure_protocol_fees(
env: Env,
admin: Address,
fee_bps: u32,
splits: Vec<FeeRecipient>,
is_enabled: bool,
) -> Result<(), StreamError>
3. Execution & Fee Splitting Logic
- Enforce
admin.require_auth(). - Validate that
fee_bps <= MAX_ALLOWED_FEE_BPS(e.g. 100 BPS = 1.00%). - Ensure
splits.iter().map(|s| s.share_bps).sum() == 10_000(100% distribution of collected fee). - When a stream is created or funds are withdrawn:
- Calculate
total_fee = (amount * fee_bps) / 10_000. - For each
splitinsplits:split_amount = (total_fee * split.share_bps) / 10_000.- Transfer
split_amounttosplit.recipientvia Soroban Token client.
- Transfer remaining
(amount - total_fee)to target stream / recipient.
- Calculate
- Emit
ProtocolFeeCollectedevent detailing per-recipient distribution.
Target Files
contracts/stream_contract/src/types.rscontracts/stream_contract/src/storage.rscontracts/stream_contract/src/lib.rscontracts/stream_contract/src/events.rscontracts/stream_contract/src/test.rs
Acceptance Criteria
- [ ] Admin can update fee configuration and recipient splits with sum validation.
- [ ] Exceeding
MAX_ALLOWED_FEE_BPSreverts withStreamError::FeeExceedsMaximum. - [ ] Splits summing to anything other than 10,000 BPS revert with
StreamError::InvalidFeeSplit. - [ ] Non-admin callers revert with
StreamError::Unauthorized. - [ ] Fee deductions correctly distribute tokens to multiple treasury addresses without rounding loss or dust leaks.
- [ ] Unit tests verify multi-recipient split math across standard Stellar tokens and stablecoins.
@CARTEL-L has applied to work on this issue as part of the Stellar Wave Program's 9th wave.
Hi! I’m a full-stack developer with a strong blockchain background. I’d love to handle this issue and can deliver a clean, reliable solution. Kindly assign it to me.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @CARTEL-L to this issue.
@amehsamuel200225-sketch has applied to work on this issue as part of the Stellar Wave Program's 9th wave.
Hi, I’m Ameh Samuel…. A software engineer, let me fix this issue please!
ℹ️ Repo Maintainers: To accept this application, review their application or assign @amehsamuel200225-sketch to this issue.
@Osifowora has applied to work on this issue as part of the Stellar Wave Program's 9th wave.
Hi maintainer, I would love to work on this issue. I can get started on it right away.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Osifowora to this issue.
Congratulations, @Osifowora! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on September 30, 2026.
🧑💻 @Osifowora: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
🌊 Happy Wave 🌊
This issue has been marked as completed by a Drips Wave moderator for @Osifowora as part of the Stellar Wave Program's 9th Wave 🥳
Moderator's reason: [Auto-assessed] The PR (#1524) is open with no maintainer objections across any channel, and it implements the required dynamic protocol fee architecture, multi-recipient treasury split logic, and position receipt / cross-asset routing features for Issue #1465. Furthermore, the CI failure is an untrusted/non-actionable or external platform check rather than a test or build error in the contributor's code.
😎 @Osifowora: You earned 150 Points for completing this issue! After the current Wave ends, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here.
🧑💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.
ℹ️ Note: This issue was marked complete via moderation. Points were issued even though the GitHub issue remains open.
@Gentle842 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
Hi maintenaner, I can work on this, Pls kindly assign it to me
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Gentle842 to this issue.
@laxjovial has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
Hello maintainer, i would like to work on this issue
ℹ️ Repo Maintainers: To accept this application, review their application or assign @laxjovial to this issue.
@CollinsKRO has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
Hi Maintainer, I can fix this pls assign. ETA 5hrs
ℹ️ Repo Maintainers: To accept this application, review their application or assign @CollinsKRO to this issue.
@harmondconsultant-png has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
hy, i can work on it pleas assign
ℹ️ Repo Maintainers: To accept this application, review their application or assign @harmondconsultant-png to this issue.
@anasisgay16 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
Hello maintainer, i would like to work on this issue
ℹ️ Repo Maintainers: To accept this application, review their application or assign @anasisgay16 to this issue.
@julietashia9-dev has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
Good day. I would be grateful for the opportunity to be assigned to this issue. Having reviewed the overview, the problem statement, the technical specification, and the acceptance criteria, I understand the objective to be a configurable protocol fee in the stream contract. Admins would set a fee in basis points, capped at 100 BPS, and route the collected fee across multiple recipients whose shares sum to 10,000 BPS. Invalid configurations would revert with the specified errors, and fee deductions would distribute tokens without rounding loss or dust. My intended approach is to first study the existing stream contract's types, storage, and fee-free transfer paths in contracts/stream_contract/src, then add the FeeRecipient and ProtocolFeeConfig types, the admin-only configure_protocol_fees entrypoint with its validation, and the split logic applied on stream creation and withdrawal. I would assign any rounding remainder deterministically so that the splits always sum exactly to the collected fee, emit the ProtocolFeeCollected event, and cover the multi-recipient math, error paths, and authorization with unit tests across standard token decimals. I anticipate having a first version ready within 2 days, and I will gladly seek the maintainers' guidance in the thread should a question arise regarding where the rounding remainder should go, whether fee changes should be subject to a timelock, or how the fee should interact with withdrawals of partially streamed funds.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @julietashia9-dev to this issue.
Congratulations, @anasisgay16! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.
🧑💻 @anasisgay16: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
🌊 Happy Wave 🌊