feat: add platform fee model with treasury routing on report_revenue#493
Open
BigNathan1 wants to merge 2 commits into
Open
feat: add platform fee model with treasury routing on report_revenue#493BigNathan1 wants to merge 2 commits into
BigNathan1 wants to merge 2 commits into
Conversation
|
@BigNathan1 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! 🚀 |
Define the missing PauseState enum, four DataKey2 variants (MinRevenueThreshold, DepositedRevenue, InvestmentConstraints, SupplyCap), and the StaleConcentrationData error; resolve the duplicate error discriminant 48; scope DataKey to the crate so it clears the 50-case spec-union limit. Format the tree, satisfy clippy -D warnings, register the kani cfg, and fix pre-existing broken tests so the suite compiles and passes (99 passed, 0 failed).
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.
feat: add platform fee model with treasury routing on report_revenue
closes #468
Summary
Adds a configurable, per-offering platform fee so the platform can take a
programmable share of each reported revenue amount, routed to a treasury
address and surfaced transparently in events. Previously report_revenue
allocated the full basis-point budget to holders.
Changes
PlatformFeeModel { fee_bps, treasury }contracttype andDataKey2::OfferingPlatformFee(OfferingId)storage key.set_offering_platform_fee(issuer, namespace, token, fee_bps, treasury):admin-only setter. Validates the offering exists and enforces the offering-level
invariant that
fee_bps + aggregate holder share <= 10_000, rejectingviolations with the new
RevoraError::FeeExceedsHolderShare. Emits apfee_setconfig event.get_offering_platform_fee(...)read-only accessor returning the model.report_revenuededucts the configured fee on each recorded report and emitsa
plat_feeevent carrying(treasury, fee_bps, fee_amount, period_id).Security and correctness
enforced at configuration time so the platform and holders can never claim
more than 100% of reported revenue.
(initial and override). Below-threshold and rejected-duplicate reports return
early and take no fee.
fee_bps = 0, zero-revenue reports, and sub-one-unit fees skip the deductionand emit no
plat_feeevent, so indexers can rely on the event being presentonly when a real, non-zero fee was routed.
amount * fee_bps / 10_000,truncating down).
DataKey2to avoid the primaryDataKeyunion's variant cap, and the setter uses a distinct name so it does not
collide with the existing global platform-fee API.
Tests
New module
src/test_platform_fee_model.rscovering: model storage and getter,config event shape, admin/offering/initialization guards, the
fee+holder-share invariant at and over the 10_000 boundary, full-fee-with-no-
holders, correct fee amount and round-down behavior on report_revenue, the
override path, and the no-event cases (fee_bps=0, no model, zero amount, sub-unit
fee, rejected duplicate, below threshold).