-
Notifications
You must be signed in to change notification settings - Fork 16
Protocol Fee Engine with Multi-Party Payout Splits & Treasury Accounting #39
Copy link
Copy link
Closed
Labels
GrantFox OSSIssue tracked in GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26Campaign: Official Campaign | FWC26Third CampaignCampaign: Third CampaignCampaign: Third CampaigncontractsSmart contract (Soroban) workSmart contract (Soroban) workdifficulty: very hard⚫ Very Hard⚫ Very HardenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is neededpriority: medium🟠 Medium priority🟠 Medium priority
Description
Activity
Metadata
Metadata
Assignees
Labels
GrantFox OSSIssue tracked in GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26Campaign: Official Campaign | FWC26Third CampaignCampaign: Third CampaignCampaign: Third CampaigncontractsSmart contract (Soroban) workSmart contract (Soroban) workdifficulty: very hard⚫ Very Hard⚫ Very HardenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is neededpriority: medium🟠 Medium priority🟠 Medium priority
Description
This issue aims to address the implementation of Protocol Fee Engine with Multi-Party Payout Splits & Treasury Accounting.
The core objective is to: Add a configurable, governance-bounded fee engine to the escrow contract that splits every payout across worker, protocol treasury, and optional referrer in exact integer arithmetic, with per-token treasury accounting and provable no-dust/no-loss invariants.
By completing this feature, we will ensure that the GuildWorkman protocol maintains its high standards for security, usability, and decentralized logic. This issue requires careful attention to the Smart Contract architecture and adherence to the existing project conventions.
When picking up this issue, please ensure you document any new dependencies or architectural decisions made during development.
Component
Smart Contracts (Soroban)
Difficulty
⚫ Very Hard
Current state
escrow::confirm_completion,cancel_appointment, andresolve_disputeall transfer the entireappointment.amountto exactly one recipient. There is no protocol revenue path, no treasury, and no notion of a referrer or guild cut — so the protocol currently cannot sustain itself, and every future fee change would be a breaking rewrite of the payout paths.The hard part here is not the split; it is the arithmetic and the invariants. Payouts are
i128token units, fee rates are basis points, and every rounding decision must be deliberate and provable: no path may ever pay out more than was escrowed, and no path may leave stranded dust in the contract.Tasks
soroban-contracts/contracts/confirm_completion,resolve_dispute, and the cancel/refund path (a cancellation must define whether fees are charged at all — document the choice)i128::MAX-adjacent amounts, zero-fee and max-fee configs, and a property/invariant test assertingsum(payouts) == amountfor randomized inputscargo fmt --checkandcargo clippy -- -D warningscargo testandsoroban contract buildto verify the optimized WASM buildAcceptance Criteria
Estimated Time
4-5 days