This program implements an ICO (Initial Coin Offering) launchpad. It allows a project authority to create a new token where the price is determined by a linear bonding curve. It is the mint authority for the token it creates and is responsible for processing purchases and CPI-calling the affiliate program to handle commissions.
- PDA Seeds:
["launch_state", authority_pubkey, token_mint_pubkey] - Purpose: Stores the configuration and live state of a single ICO launch.
- Fields:
authority: Pubkey- The wallet authorized to withdraw SOL.token_mint: Pubkey- The mint address of the token being sold.sol_vault_bump: u8- The bump seed for the SOL vault PDA.initial_price: u64- The starting price of the token in lamports per token.slope: u64- The value by which the price increases for each token sold.tokens_sold: u64- The total number of tokens sold to date.
- Description: Initializes a new ICO. Creates the
LaunchStateaccount and thetoken_mint. - Parameters:
initial_price: u64slope: u64
- Description: Allows a user to buy tokens by sending SOL. Calculates the token amount based on the current price from the bonding curve, transfers SOL to the vault, and mints tokens to the buyer. If an affiliate is provided, it triggers a CPI call.
- Parameters:
sol_amount: u64affiliate_key: Option<Pubkey>
- Description: Allows the authority to withdraw all accumulated SOL from the vault.
- Parameters: None.
InvalidAmount: Input amount is zero or invalid.Overflow: A mathematical calculation resulted in an overflow.InsufficientFunds: The SOL amount is too small to purchase any tokens at the current price.AuthorityMismatch: The signer ofwithdraw_solis not the launch authority.AffiliateMismatch: The providedaffiliate_keydoes not match the public key in theaffiliate_infoaccount.