futarchy
futarchy copied to clipboard
Launch funding fees
Add Funding Fees to Launchpad
Summary
Implements a 1% funding fee on launchpad token sales, applied to all user contributions. Fees are collected during the claim process and transferred to a designated fee wallet.
Changes
Core Implementation
- Fee Calculation Functions: Added
apply_funding_fee()andapply_funding_fee_inverse()utility functions in both Rust (programs/launchpad/src/utils.rs) and TypeScript (sdk/src/v0.6/utils/launch.ts) for consistent fee calculations across the stack - Fee Constants:
- Rust:
DEFAULT_FUNDING_FEE_BPS = 100(1%) andFUNDING_FEE_WALLETaddress inlib.rs - TypeScript:
DEFAULT_FUNDING_FEE_BPS = new BN(100)inconstants.ts
- Rust:
Instruction Updates
- Claim: Modified to deduct fees from user token allocations and transfer fee amounts to the fee wallet
- Complete Launch: Updated to use post-fee amounts when determining final raise amount
- Refund: Enhanced refund calculations to properly handle fees for both full refunds (unsuccessful launches) and partial refunds (oversubscribed launches)
SDK & Testing
- Added
mulDivCeil()helper function for precise ceiling division in tests - Updated integration and unit tests to account for fee calculations
- Added
applyFundingFeeInverse()import to test suite for reverse fee calculations
Fee Logic
- Fees are calculated as 1% of committed amounts using basis points (100 bps = 1%)
- Fee rounding ensures amounts are always rounded up (ceiling division) to prevent dust accumulation
- During claims, users receive tokens proportional to their post-fee contribution
- For partial refunds (oversubscribed launches), fees are proportionally distributed
Todo
- [ ] Set up correct wallet for fee collection
- [ ] Program
- [ ] SDK
- [ ] See what's going on with changes in SDK types, e.g.
sdk/src/v0.6/types/autocrat.ts
Moved into draft as part of reprioritization
Closing in favor of bid wall #367