Introduction
Dynamic Fee Sharing is a program that allows any project to configure a fee sharing mechanism for their fees earned.
Program Address
- Mainnet-beta:
dfsdo2UqvwfN8DuUVrMRNfQe11VaiNoKcMqLHVvDPzh
- Devnet:
dfsdo2UqvwfN8DuUVrMRNfQe11VaiNoKcMqLHVvDPzh
Resources
Features
Dynamic Fee Vault Creation
Two initialization methods:
initialize_fee_vault
: Creates a fee vault with a signer keypairinitialize_fee_vault_pda
: Creates a fee vault using PDA for deterministic addresses
Multi-user support: Supports 2-5 users per vault (configurable via MAX_USER constant)
Token compatibility: Supports both SPL Token and Token-2022 standards
Proportional Fee Distribution System
Share-based allocation: Each user has a defined share amount that determines their portion of fees
Precision calculations: Uses 52-bit precision scaling for accurate fee distribution math
Dynamic fee accumulation: Tracks fee_per_share
to calculate individual user rewards over time
Fee Funding Mechanism
Flexible funding: Anyone can fund fees into the vault via fund_fee
instruction
Transfer fee handling: Automatically accounts for token transfer fees (important for Token-2022)
Amount validation: Ensures funded amounts are greater than zero
Real-time distribution: Fees are immediately distributed proportionally to all users
Individual Fee Claiming
Index-based claiming: Users claim fees using their assigned index (0-4)
Authorization: Only the designated user can claim their fees
Checkpoint system: Tracks fee_per_share_checkpoint
to calculate unclaimed rewards
Accumulated tracking: Maintains running total of claimed fees per user
Token Management
Vault authority: Uses PDA-based authority for secure token operations
Token vault: Dedicated token account for holding fees
Multi-token support: Each vault is tied to a specific token mint
Transfer utilities: Includes helper functions for token transfers
Security & Validation Features
Ownership controls: Each vault has a designated owner
User validation: Validates user addresses and share amounts during initialization
Index bounds checking: Prevents out-of-bounds access to user array
Math overflow protection: Safe math operations throughout
Mint verification: Ensures only supported token mints can be used
Event Logging
Initialization events: Logs vault creation with all parameters
Funding events: Tracks fee funding activities with amounts and funders
Claiming events: Records fee claims with user details and amounts
Flexible Architecture
Zero-copy accounts: Efficient memory usage with zero-copy account structures
Modular design: Well-organized instruction handlers and utilities
Future extensibility: Built-in padding fields for future feature additions