Skip to content

Conversation

@pileks
Copy link
Contributor

@pileks pileks commented Jan 19, 2026

This PR introduces a configurable fee mechanism with time-based linear decay for the bid wall contract. Instead of a hardcoded 1% fee, bid walls can now be initialized with a maximum fee, minimum fee, and decay duration. The fee starts at max_fee_bps when the bid wall is created and linearly decays to min_fee_bps over fee_decay_duration_seconds. This creates an incentive structure that discourages early selling while providing a steady-state fee floor.

Changes

State Extension (bid_wall.rs)

  • Added three new fields to the BidWall account:
    • fee_decay_duration_seconds: u32 - duration over which the fee decays
    • max_fee_bps: u16 - starting fee in basis points
    • min_fee_bps: u16 - floor fee in basis points

Fee Calculation (sell_tokens.rs)

  • Removed the hardcoded FEE_BPS constant (was 100 bps / 1%)
  • Implemented linear fee decay formula: max_fee - (max_fee - min_fee) * bid_wall_age / fee_decay_duration
  • Fee is clamped to min_fee_bps after the decay period completes
  • Uses u128 arithmetic to prevent overflow during intermediate calculations

Initialization (initialize_bid_wall.rs)

  • Added validation requiring fee_decay_duration_seconds > 0 to prevent division by zero
  • Extended InitializeBidWallArgs with the three new fee parameters
  • Fee configuration is emitted in BidWallInitializedEvent

Launchpad Integration (complete_launch.rs)

  • Extracted PASS_THRESHOLD_BPS constant (300 bps / 3%)
  • Default bid wall configuration for launches:
    • fee_decay_duration_seconds: 14 days
    • max_fee_bps: 500 (5%, which is pass threshold + 200 bps)
    • min_fee_bps: 300 (3%, equal to pass threshold)

SDK Updates

  • Extended BidWallClient.initializeBidWallIx() with required fee parameters
  • Updated TypeScript IDL types for the new state fields and events

Mechanics

The fee decay mechanism works as follows:

  1. At t=0 (bid wall creation), sellers pay max_fee_bps
  2. The fee decreases linearly over fee_decay_duration_seconds
  3. After the decay period, the fee stabilizes at min_fee_bps

The formula ensures the fee is always at least min_fee_bps via .max():

let fee_bps = min_fee_bps.max(
    max_fee_bps - (max_fee_bps - min_fee_bps) * bid_wall_age / fee_decay_duration
);

For the default launch configuration (5% -> 3% over 14 days).

Remaining work

  • Add bid wall account migration (or cut a new release) if these changes are accepted.
    • Existing bid walls can have the following parameters:
    • fee_decay_duration_seconds = 1
    • max_fee_bps = 100
    • min_fee_bps = 100

@pileks pileks self-assigned this Jan 19, 2026
@pileks pileks changed the title Add Configurable Fee with Linear Decay to Bid Wall Add configurable fee with linear decay to bid wall Jan 19, 2026
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.

2 participants