Skip to content

feat: custom fees pallet with protocol and community fee layers#70

Open
olanod wants to merge 5 commits intomainfrom
custom-fees
Open

feat: custom fees pallet with protocol and community fee layers#70
olanod wants to merge 5 commits intomainfrom
custom-fees

Conversation

@olanod
Copy link
Copy Markdown
Member

@olanod olanod commented Apr 1, 2026

Summary

Custom fees pallet (fc-pallet-fees) that lets protocol governance and communities configure fees on asset transfers.

  • Protocol fees: global fees set by AdminOrigin, applied to all transfers
  • Community fees: per-community fees set by CommunityOrigin, applied when sender belongs to a community
  • Fee types: Fixed, Percentage (Permill), PercentageClamped (with min/max bounds)
  • Fee rounding: fees rounded up (mul_ceil) and clamped to asset's minimum_balance to avoid dust
  • WithFees<T> adapter: wraps fungibles::Mutate to charge fees transparently on transfer calls
  • ChargeFees<T> transaction extension: charges fees on direct pallet-assets calls detected by CallInspector

Test plan

  • 29 unit tests covering all fee types, rounding, protocol/community fees, adapter, and extension
  • CI passing (lint, check, clippy, test)

🤖 Generated with Claude Code

olanod added 4 commits April 2, 2026 01:35
Configurable protocol and community fees on asset transfers.
CallInspector trait detects pallet-assets transfers;
ChargeCommunityFees extension charges fees in prepare phase.
Rename pallet, directory, package, and ChargeCommunityFees → ChargeFees.
Internal storage names (ProtocolFees, CommunityFees) unchanged.
@olanod olanod changed the title Custom fees feat: custom fees pallet with protocol and community fee layers Apr 1, 2026
- FeeConfig::calculate now accepts optional min_balance parameter;
  non-zero fees below it are rounded up to avoid dust
- Percentage fees use mul_ceil (round up) instead of mul_floor
- calculate_fees takes the asset ID to look up minimum_balance
- Extrinsic weights now include proper read/write DB accounting
  instead of placeholder values
- Extension weight increased to reflect actual work
- Added tests: rounding to min_balance, percentage rounding up,
  zero stays zero, fixed fee rounding
@olanod olanod marked this pull request as ready for review April 2, 2026 15:37
@olanod olanod requested a review from pandres95 April 3, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant