#850 [DOC-49] Add platform economics and fee structure analysis FIX - #920
Merged
anumukul merged 1 commit intoSep 4, 2026
Conversation
|
@solidsole 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! 🚀 |
Contributor
Author
|
@anumukul PLEASE REVIEW |
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.
Closes #850
What Changed
docs/TOKENOMICS.md— full rewrite (171 → 755 lines). The previous version haddrifted from the deployed contract (claimed the fee was "fixed", fee tiers "planned",
burn "not implemented"). The rewrite documents, function-by-function, what
contracts/escrow/src/lib.rsactually does:(
fee = floor(amount × fee_bps / 10_000), truncation semantics), base 250 bps,worked stroop-level examples, per-token accrual (
TokenFees) →withdraw_feeslifecycle, burn allocation mechanics, and conservation invariants tied to existing
contract tests.
burn / referral / multi-approver branch), dispute deposit + half-slashing flow, and
the zero-revenue refund/cancel branches.
referrer, oracle, relayer, plus an alignment/tension map (e.g. why 50/50 dispute
resolutions count as a raiser loss, why referral rewards can't be farmed).
breakeven GMV at illustrative cost levels, the disintermediation ceiling, micro-job
rounding floor, dispute-deposit regressivity, late-fee/burn/referral-budget
interactions, and a parameter interaction table.
Fiverr 20% + buyer fees, Freelancer.com, Toptal, Contra, LaborX, Guru) with sources,
dated September 2026.
auditability event map, corrected FAQ, and a "keeping this doc in sync" section.
scripts/check-tokenomics-docs.py(new, 138 lines) — automated doc↔codeconsistency guard. Parses
DEFAULT_FEE_BPS,MAX_FEE_BPS,MAX_FEE_BPS_CONFIG,MAX_FEE_TIERS,DEFAULT_DISPUTE_FEE,DEFAULT_ORACLE_FEE,DEFAULT_BURN_BPS,REFERRAL_BPSfrom the contract plus the frontend mirrors(
transactions.ts FEE_BPS, fee-calculatorPLATFORM_FEE_PERCENT) and asserts the docquotes identical values and cites functions that still exist.
.pre-commit-config.yaml— adds atokenomics-docshook (systempython3,files:filter on the 4 coupled paths) so editing the fee logic or its frontendmirrors re-validates the documentation; ordinary PRs pay zero cost.
docs/README.md— one line: updated the TOKENOMICS.md index description.Design trade-offs:
TOKENOMICS.mdin place instead of adding a parallelECONOMICS.md, so all doc links/index entries keep working and there is exactly onesource of truth.
caps — 10% vs 100%;
execute_burnbeing accounting rather than token destruction;dispute paths ignoring tiers/exemptions/burn; the orphaned
src/test.rsreferencingnon-existent rebate/SLA APIs). Transparency was the issue's stated goal, and a
stakeholder doc that hides these is worse than none. No contract behavior was changed.
contract, both frontend mirrors, and the markdown — and run without a toolchain.
git diff --exit-code contracts/escrow/src/lib.rspasses; the entire change surface is 2 docs files, 1 newPython script, 1 pre-commit hook block.
Validation
Closes #— insert issue number)soroban contract buildandcargo testincontracts/escrow) if contract code changed. N/A — verified no contract codechanged (empty
git diffoncontracts/escrow/); nothing in the test graph wastouched.
cargo/docker are unavailable in this environment, so instead the doc'sclaims were each re-verified against
lib.rssource this session and enforcedmechanically by
python3 scripts/check-tokenomics-docs.py→ OK (fee=250 bps,caps=1000/10000 bps, tiers≤10, dispute=50,000,000 stroops, oracle=20,000,000 stroops,
referral=50 bps, burn_default=0 bps).
files modified (confirmed via
git status).no UI changes. (Rendered Mermaid diagrams view on GitHub's markdown preview of the
changed file.)
or runtime surface to verify.
python3 scripts/check-tokenomics-docs.py(passes;and passes an adversarial negative test — mutating
DEFAULT_FEE_BPSto 300 in ascratch copy produced exactly the 3 expected
FAIL:lines before reverting),python3 scripts/check-heading-hierarchy.py(passes for all docs incl. the rewrittenfile), YAML parse of
.pre-commit-config.yaml(valid, 8 hooks), and ananchors/relative-links audit of the new doc (none broken).
Additional Notes
contracts/escrow/src/lib.rs; spot-check the "Fee Calculation and Distribution" and"Other Monetary Flows" sections against
approve_work,resolve_single_dispute, andsubmit_verdict. The "Known Gaps and Cautions" section is a candidate seed for newissues — especially the
update_fee(≤10%) vsupdate_fee_bps(≤100%) cap mismatch,which I'd recommend fixing in-contract rather than re-documenting here.
24h upgrade timelock; make dispute paths tier/exemption-aware or document-by-design;
make
execute_burncall tokenburn()for anchored assets; delete or wire up theorphaned
contracts/escrow/src/test.rs; replace the frontend's static 250 bps mirrorwith a
get_fee_bps()read.periodic refresh; the pre-commit hook requires
python3on PATH, consistent with theexisting
language: systemhooks (cargo/npm).messages name the drifted constant directly.