futarchy icon indicating copy to clipboard operation
futarchy copied to clipboard

Launch funding fees

Open pileks opened this issue 1 month ago • 1 comments

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() and apply_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%) and FUNDING_FEE_WALLET address in lib.rs
    • TypeScript: DEFAULT_FUNDING_FEE_BPS = new BN(100) in constants.ts

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

pileks avatar Nov 13 '25 15:11 pileks

Moved into draft as part of reprioritization

pileks avatar Nov 20 '25 21:11 pileks

Closing in favor of bid wall #367

pileks avatar Dec 01 '25 09:12 pileks