Add configurable fee with linear decay to bid wall#404
Open
Add configurable fee with linear decay to bid wall#404
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_bpswhen the bid wall is created and linearly decays tomin_fee_bpsoverfee_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)BidWallaccount:fee_decay_duration_seconds: u32- duration over which the fee decaysmax_fee_bps: u16- starting fee in basis pointsmin_fee_bps: u16- floor fee in basis pointsFee Calculation (
sell_tokens.rs)FEE_BPSconstant (was 100 bps / 1%)max_fee - (max_fee - min_fee) * bid_wall_age / fee_decay_durationmin_fee_bpsafter the decay period completesu128arithmetic to prevent overflow during intermediate calculationsInitialization (
initialize_bid_wall.rs)fee_decay_duration_seconds > 0to prevent division by zeroInitializeBidWallArgswith the three new fee parametersBidWallInitializedEventLaunchpad Integration (
complete_launch.rs)PASS_THRESHOLD_BPSconstant (300 bps / 3%)fee_decay_duration_seconds: 14 daysmax_fee_bps: 500 (5%, which is pass threshold + 200 bps)min_fee_bps: 300 (3%, equal to pass threshold)SDK Updates
BidWallClient.initializeBidWallIx()with required fee parametersMechanics
The fee decay mechanism works as follows:
t=0(bid wall creation), sellers paymax_fee_bpsfee_decay_duration_secondsmin_fee_bpsThe formula ensures the fee is always at least
min_fee_bpsvia.max():For the default launch configuration (5% -> 3% over 14 days).
Remaining work
fee_decay_duration_seconds= 1max_fee_bps= 100min_fee_bps= 100