Pump.fun Public Documentation

repository·main·Indexed 18 days ago

https://github.com/pump-fun/pump-public-docs

Technical specifications and developer guides for the Pump.fun ecosystem. Includes documentation on the PumpSwap protocol, Bonding Curve V2 trading instructions, SDK usage for TypeScript and Rust, and guidelines for implementing Cross-Program Invocations (CPI) via the pump_rust_client. Covers critical program upgrades regarding fee recipient accounts, dynamic fee structures based on market cap, and effective quote reserve calculations for indexers and trading bots.

Tokens
29.7K
Snippets
54
Records
92
Agent score
65%

What's inside pump-fun-pump-public-docs

  1. Overview of the Pump Program

    main

    The Pump program enables the creation of SPL coins that are immediately tradable on a bonding curve without requiring initial liquidity seeding.

    Key Lifecycle:

    1. Bonding Curve Phase: Coins trade on a bonding curve based on a Uniswap V2-style formula using synthetic reserves.
    2. Migration: Once a coin reaches a specific market cap, the liquidity is migrated to PumpSwap (an AMM on Solana).
    3. Liquidity Burn: The LP tokens received from the PumpSwap pool are automatically burnt.

    Program Addresses:

    • Program ID: 6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P (deployed on both Mainnet and Devnet).
  2. How Creator Fee Sharing works

    main

    Creator Fee Sharing allows a coin's creator fees to be distributed among multiple shareholders instead of a single recipient. This is achieved by migrating the creator vault from a single address to a sharing_config Program Derived Address (PDA) managed by the Pump Fees program.

    Important: These instructions only apply to coins that have a sharing_config. For single-creator-recipient coins, use collect_creator_fee_v2 or collect_coin_creator_fee instead.

    The Lifecycle

    1. create_fee_sharing_config (Pump Fees): Opts the coin into shared distribution. This migrates the bonding curve creator (and the AMM pool.coin_creator if the coin has graduated) to the new sharing_config PDA.
    2. update_fee_shares_v2 (Pump Fees): Sets the final list of shareholders. This instruction sweeps any pending creator fees from both the AMM and the bonding curve via CPI before applying the new shares. It can only be called once per sharing_config (the admin is revoked after execution).
    3. transfer_creator_fees_to_pump_v2 (Pump AMM): A permissionless instruction that sweeps coin creator fees accrued on the AMM into the bonding curve's creator vault so they can be distributed by the Pump program.
    4. distribute_creator_fees_v2 (Pump program): A permissionless instruction that pays out the bonding curve's creator vault to each shareholder according to their share_bps.
  3. How to calculate effective quote reserves

    main

    When quoting, pricing, or indexing a pool, you must use the effective quote reserves rather than the raw vault balance. This ensures compatibility with future pools that may use virtual_quote_reserves.

    Formula: effective_quote_reserves = pool_quote_token_account.amount + Pool::virtual_quote_reserves

    Note: The base side remains unchanged; use the raw pool_base_token_account.amount for base reserves. Indexers can reconstruct effective reserves from BuyEvent and SellEvent logs as they include the virtual_quote_reserves field.

    effective_quote_reserves = pool_quote_token_account.amount + Pool::virtual_quote_reserves
  4. Configure fee recipients for buy_v2

    main

    Every buy_v2 call requires a feeRecipient and a buybackFeeRecipient.

    • Non-mayhem coins: Choose one of the 8 normal fee recipients as feeRecipient.
    • Mayhem mode coins: Choose one of the 8 reserved fee recipients as feeRecipient.
    • All coins: Choose one of the 8 buyback fee recipients as buybackFeeRecipient.

    Refer to the FEE_RECIPIENTS.md documentation for the full list of valid addresses.

  5. Derive the creator_vault PDA

    main

    The creator_vault is a Program Derived Address (PDA) used to hold fees for a specific coin creator. It is derived using the creator-vault seed and the creator's public key from the BondingCurve account.

    PDA Seeds:

    • b"creator-vault"
    • bonding_curve.creator (the creator's Pubkey)
    • bump
    #[account(
        mut,
        seeds = [
            b"creator-vault",
            bonding_curve.creator.as_ref()
        ],
        bump
    )]
    pub creator_vault: AccountInfo<'info >,
  6. Choose the appropriate Pump SDK version

    main

    The Pump SDK is provided in three distinct tiers depending on your integration needs:

    • PumpAmmSdk: The high-level SDK designed for UI integrations. It includes autocomplete methods to help sync UI inputs (like base/quote amounts) with pool states.
    • PumpAmmInternalSdk: The low-level SDK for programmatic integrations. Use this when you need full customization of the underlying instructions.
    • PumpAmmAdminSdk: A specialized SDK that provides access to admin-protected instructions.
  7. Calculate effective quote reserves for PumpSwap pools

    main

    When quoting, pricing, or indexing a PumpSwap pool, you must use the effective quote reserves instead of the raw quote-vault token balance. This ensures accuracy if the pool carries a non-zero virtual_quote_reserves value.

    Use the following formula: effective_quote_reserves = pool_quote_token_account.amount + Pool::virtual_quote_reserves

    Note: For all pools currently, virtual_quote_reserves is 0, but switching to this calculation now will future-proof your integration.

    For Indexers: Effective quote reserves can be reconstructed from the event stream because the BuyEvent and SellEvent logs include the appended virtual_quote_reserves field.

    effective_quote_reserves = pool_quote_token_account.amount + Pool::virtual_quote_reserves
  8. How Bonding Curve accounts work

    main

    Every coin has a unique bonding curve account, which is a PDA derived from the seeds ["bonding-curve", mint]. This account tracks the liquidity state of the specific coin.

    Key Fields:

    • virtual_token_reserves, virtual_sol_reserves: Synthetic reserves used for the bonding curve formula.
    • real_token_reserves, real_sol_reserves: The actual amount of tokens and SOL held in the curve.
    • token_total_supply: Total supply of the coin.
    • complete: A boolean that becomes true when real_token_reserves == 0 (indicating the bonding curve is finished and ready for migration).

    State Changes:

    • Buy: virtual_sol_reserves and real_sol_reserves increase; virtual_token_reserves and real_token_reserves decrease.
    • Sell: virtual_sol_reserves and real_sol_reserves decrease; virtual_token_reserves and real_token_reserves increase.
    {
      "virtual_token_reserves": { "type": "u64", "data": "1072999999992855" },
      "virtual_sol_reserves": { "type": "u64", "data": "30000000013" },
      "real_token_reserves": { "type": "u64", "data": "793099999992855" },
      "real_sol_reserves": { "type": "u64", "data": "13" },
      "token_total_supply": { "type": "u64", "data": "1000000000000000" },
      "complete": { "type": "bool", "data": false }
    }
  9. Understand the dynamic fee structure for Pump and PumpSwap

    main

    The fee structure has transitioned from a static model to a dynamic model based on the current market cap of the coin (in lamports). This applies to:

    1. Pump bonding curves
    2. PumpSwap canonical pools: A pool is considered canonical if its pool.creator (not pool.coinCreator) matches the pumpPoolAuthorityPda(baseMint)[0].

    To implement this correctly, use the official TypeScript SDKs:

    • @pump-fun/pump-sdk
    • @pump-fun/pump-swap-sdk
  10. How creator fee vaults work

    main

    Coin creators accrue fees in two separate, independent vaults depending on the coin's lifecycle stage:

    1. Bonding Curve Creator Vault: Held by the Pump program. Fees are drained via collect_creator_fee_v2.
    2. AMM Coin Creator Vault: Held by the Pump AMM program (post-migration). Fees are drained via collect_coin_creator_fee.

    A creator typically needs to call both instructions to fully sweep all accrued fees.

    Note on Migration: If a coin's creator vault has been migrated to a sharing_config (multi-creator-recipient), these instructions will fail. In that case, fees must be distributed through the Pump Fees program instead.

  11. Handle breaking upgrade for PumpSwap coin creator fees

    main

    The PumpSwap (Pump AMM) program is undergoing a breaking upgrade to support coin creator fees. To ensure compatibility and avoid downtime, developers must update their transaction construction logic to account for extended Pool account sizes and new required accounts in buy and sell instructions.

    Key changes:

    1. Account Extension: Pool accounts are being extended to 300 bytes. If pool.dataLen < 300, you must prepend an extendAccount(pool) instruction to your buy or sell transactions.
    2. New Instruction Inputs: Both buy and sell instructions now require two additional input accounts at indexes 17 and 18:
      • coin_creator_vault_ata: The Associated Token Account (ATA) for the creator vault.
      • coin_creator_vault_authority: A PDA derived from the coin_creator field in the Pool account.
    3. SDK Update: Use the latest version of @pump-fun/pump-swap-sdk to handle these changes automatically.