### Anchor Wrapper Program for Pump CPI Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/CPI_README.md Example of an Anchor wrapper program demonstrating a CPI call to pump's buy_v2 instruction. Ensure your Accounts struct mirrors pump's BuyV2 account order exactly. ```rust use anchor_lang::prelude::*; declare_id!("7enkT8uLQrwKYSRMrazjr1YZPT7unToAtwdLMWa2QLYY"); declare_program!(pump); #[program] pub mod example_cpi_program { use super::*; pub fn buy_v2(ctx: Context, amount: u64, max_sol_cost: u64) -> Result<()> { pump::cpi::buy_v2( CpiContext::new( ctx.accounts.program.to_account_info(), pump::cpi::accounts::BuyV2 { global: ctx.accounts.global.to_account_info(), // ... all pump BuyV2 accounts, same order ... program: ctx.accounts.program.to_account_info(), }, ), amount, max_sol_cost, )?; Ok(()) } } #[derive(Accounts)] pub struct BuyV2<'info> { /// CHECK: passed straight to pump pub global: UncheckedAccount<'info>, // ... fields in the same order as pump::cpi::accounts::BuyV2 ... #[account(mut)] pub user: Signer<'info>, // ... /// CHECK: pump program; CPI target pub program: UncheckedAccount<'info>, } ``` -------------------------------- ### Collect Coin Creator Fees Instruction Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_CREATOR_FEE_README.md Example of how to use the `collectCoinCreatorFee` instruction from the PumpAmmSdk to transfer accumulated fees. The `coinCreator` must sign the transaction. ```javascript PumpAmmSdk.collectCoinCreatorFee(coinCreator) ``` -------------------------------- ### Example Bonding Curve Account Data Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_PROGRAM_README.md This JSON object represents the data structure of a bonding curve account, showing reserves and supply information. It is used to track the state of a coin's bonding curve. ```json { "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 } } ``` -------------------------------- ### Create Pool Instructions Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_SDK_README.md Use this to generate instructions for creating a new liquidity pool. Requires pool configuration details. ```javascript const createPoolInstructions = await pumpAmmSdk.createPoolInstructions(index, creator, baseMint, quoteMint, baseIn, quoteIn) ``` -------------------------------- ### Get Fees for PumpSwap Pools Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/FEE_PROGRAM_README.md Internal function to determine fees for PumpSwap pools. Applies dynamic fee tiers for Pump pools and flat fees from configuration for non-Pump pools. ```typescript function getFees({ feeConfig, isPumpPool, marketCap, }: { feeConfig: FeeConfig; isPumpPool: boolean; marketCap: BN; tradeSize: BN; }): Fees { if (isPumpPool) { return calculateFeeTier({ feeTiers: feeConfig.feeTiers, marketCap, }); } else { return feeConfig.flatFees; } } ``` -------------------------------- ### Utility Instructions Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md Utility instructions for managing program accounts. ```APIDOC ## POST /extend_account ### Description Allows any user to extend the data array of a program-owned account. ### Method POST ### Endpoint /extend_account ### Parameters #### Path Parameters - **user** (publicKey) - Required - The public key of the user initiating the extension. - **account** (publicKey) - Required - The public key of the account to extend (GlobalConfig or Pool). ### Request Body (Not applicable for this instruction, parameters are passed directly) ### Response #### Success Response (200) (No specific data returned, operation is confirmed) #### Response Example (Success is indicated by the absence of an error.) ``` -------------------------------- ### Swap Instructions Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md Instructions for swapping tokens within AMM pools. ```APIDOC ## POST /buy ### Description Allows a user to buy a specific amount of base tokens from the pool by paying quote tokens. ### Method POST ### Endpoint /buy ### Parameters #### Path Parameters - **pool** (publicKey) - Required - The public key of the AMM pool. - **user** (publicKey) - Required - The public key of the user performing the buy. - **baseOut** (number) - Required - The exact amount of base tokens to buy. #### Query Parameters - **maxQuoteIn** (number) - Required - The maximum amount of quote tokens the user is willing to pay. ### Request Body (Not applicable for this instruction, parameters are passed directly) ### Response #### Success Response (200) - **quotePaid** (number) - The actual amount of quote tokens paid by the user. #### Response Example { "quotePaid": 490 } ## POST /sell ### Description Allows a user to sell a specific amount of base tokens to the pool and receive quote tokens. ### Method POST ### Endpoint /sell ### Parameters #### Path Parameters - **pool** (publicKey) - Required - The public key of the AMM pool. - **user** (publicKey) - Required - The public key of the user performing the sell. - **baseIn** (number) - Required - The exact amount of base tokens to sell. #### Query Parameters - **minQuoteOut** (number) - Required - The minimum amount of quote tokens the user expects to receive. ### Request Body (Not applicable for this instruction, parameters are passed directly) ### Response #### Success Response (200) - **quoteReceived** (number) - The actual amount of quote tokens received by the user. #### Response Example { "quoteReceived": 510 } ``` -------------------------------- ### Create Pool Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_SDK_README.md Instructions for creating a new liquidity pool. ```APIDOC ## Create Pool ### Description This section details how to create a new liquidity pool for a given pair of base and quote tokens. ### Method `pumpAmmSdk.createPoolInstructions` ### Endpoint N/A (This is an SDK function, not a direct API endpoint) ### Parameters - **index** (number) - Required - An identifier for the pool. - **creator** (string) - Required - The address of the pool creator. - **baseMint** (string) - Required - The mint address of the base token. - **quoteMint** (string) - Required - The mint address of the quote token. - **baseIn** (number) - Required - The initial amount of base tokens to be deposited. - **quoteIn** (number) - Required - The initial amount of quote tokens to be deposited. ### Request Example ```javascript const createPoolInstructions = await pumpAmmSdk.createPoolInstructions(index, creator, baseMint, quoteMint, baseIn, quoteIn); ``` ### Helper Function for Initial Pool Price #### Description Calculates the initial pool price based on the initial base and quote amounts provided. #### Method `pumpAmmSdk.createAutocompleteInitialPoolPrice` #### Parameters - **initialBase** (number) - Required - The initial amount of base tokens. - **initialQuote** (number) - Required - The initial amount of quote tokens. #### Response Example ```javascript const initialPoolPrice = pumpAmmSdk.createAutocompleteInitialPoolPrice(initialBase, initialQuote); ``` ``` -------------------------------- ### Initialize Global Account Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_PROGRAM_README.md Initializes the sole Global account on program deployment. ```APIDOC ## POST /api/initialize ### Description Initializes the sole `Global` account on Pump program deployment. This instruction can only be executed once. The first successful execution sets the `Global::authority` field. ### Method POST ### Endpoint `/api/initialize` ### Parameters #### Query Parameters - **user** (pubkey) - Required - The public key of the user initiating the initialization. - **global** (pubkey) - Required - The public key for the `Global` account. ### Request Example ```json { "user": "", "global": "" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the initialization operation (e.g., "initialized"). #### Response Example ```json { "status": "initialized" } ``` ``` -------------------------------- ### Build AMM Swap Base Instructions Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_SDK_README.md Generates the AMM swap instructions for swapping base tokens for quote tokens. Requires pool, base amount, slippage, swap direction, and user's public key. ```javascript const swapInstructions = await pumpAmmSdk.swapBaseInstructions(pool, base, slippage, swapDirection, user) ``` -------------------------------- ### Build AMM Swap Quote Instructions Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_SDK_README.md Generates the AMM swap instructions for swapping quote tokens for base tokens. Requires pool, quote amount, slippage, swap direction, and user's public key. ```javascript const swapInstructions = await pumpAmmSdk.swapBaseInstructions(pool, quote, slippage, swapDirection, user) ``` -------------------------------- ### New Account Definitions for Buy/Sell Instructions Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_CREATOR_FEE_README.md Defines the new account types required for the 'buy' and 'sell' instructions to support coin creator fees. Ensure these accounts are included in your transactions. ```rust #[account( mut, associated_token::mint = quote_mint, associated_token::authority = coin_creator_vault_authority, associated_token::token_program = quote_token_program, )] pub coin_creator_vault_ata: InterfaceAccount<'info, TokenAccount>, #[account( seeds = [ b"creator_vault", pool.coin_creator.as_ref() ], bump )] pub coin_creator_vault_authority: AccountInfo<'info >, ``` -------------------------------- ### Deposit Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_SDK_README.md Instructions for depositing liquidity into an existing pool. ```APIDOC ## Deposit ### Description This section covers the process of depositing liquidity into a (quote, base) pool. It includes functions to autocomplete quote and base amounts based on user input and to generate the final deposit instructions. ### Autocomplete Quote and LP Token from Base Input #### Method `pumpAmmSdk.depositAutocompleteQuoteAndLpTokenFromBase` #### Description Call this when the `base` input changes to autocomplete the corresponding `quote` and `lpToken` values. #### Parameters - **pool** (object) - Required - The pool object. - **base** (number) - Required - The amount of base tokens to deposit. - **slippage** (number) - Required - The maximum acceptable slippage. #### Response Example ```javascript const {quote, lpToken} = await pumpAmmSdk.depositAutocompleteQuoteAndLpTokenFromBase(pool, base, slippage); ``` ### Autocomplete Base and LP Token from Quote Input #### Method `pumpAmmSdk.depositAutocompleteBaseAndLpTokenFromQuote` #### Description Call this when the `quote` input changes to autocomplete the corresponding `base` and `lpToken` values. #### Parameters - **pool** (object) - Required - The pool object. - **quote** (number) - Required - The amount of quote tokens to deposit. - **slippage** (number) - Required - The maximum acceptable slippage. #### Response Example ```javascript const {base, lpToken} = await pumpAmmSdk.depositAutocompleteBaseAndLpTokenFromQuote(pool, quote, slippage); ``` ### Generate Deposit Instructions #### Method `pumpAmmSdk.depositInstructions` #### Description Builds the AMM deposit instruction. This should be called when the user confirms the deposit, as `lpToken` is a required input. #### Parameters - **pool** (object) - Required - The pool object. - **lpToken** (number) - Required - The amount of LP tokens to mint. - **slippage** (number) - Required - The maximum acceptable slippage. - **user** (string) - Required - The user's wallet address. #### Response Example ```javascript const depositInstructions = await pumpAmmSdk.depositInstructions(pool, lpToken, slippage, user); ``` ``` -------------------------------- ### Create Pool Instruction Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md Generates the Anchor instruction for creating a new liquidity pool. Requires pool configuration parameters. ```typescript PumpAmmAdminSdk.createPoolInstructions(index, creator, baseMint, quoteMint, baseIn, quoteIn) ``` -------------------------------- ### Admin Instructions Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md Instructions exclusively for the program administrator. ```APIDOC ## POST /create_config ### Description Allows creating the sole GlobalConfig account on initial program deployment. ### Method POST ### Endpoint /create_config ### Parameters #### Path Parameters - **hardcoded_admin** (publicKey) - Required - A hardcoded admin pubkey within the program. #### Query Parameters - **global_config** (publicKey) - Required - The public key for the GlobalConfig account to be created. ### Request Body (Not applicable for this instruction, parameters are passed directly) ### Response #### Success Response (200) (GlobalConfig account created successfully.) #### Response Example (Success is indicated by the absence of an error.) ## POST /disable ### Description Allows the admin to globally disable specific Pump Swap operations. ### Method POST ### Endpoint /disable ### Parameters #### Path Parameters - **admin** (publicKey) - Required - The public key of the admin. #### Query Parameters - **disable_create_pool** (boolean) - Optional - Whether to disable pool creation. - **disable_deposit** (boolean) - Optional - Whether to disable deposits. - **disable_withdraw** (boolean) - Optional - Whether to disable withdrawals. - **disable_buy** (boolean) - Optional - Whether to disable buy operations. - **disable_sell** (boolean) - Optional - Whether to disable sell operations. ### Request Body (Not applicable for this instruction, parameters are passed directly) ### Response #### Success Response (200) (Operations disabled successfully.) #### Response Example (Success is indicated by the absence of an error.) ## POST /update_admin ### Description Allows the admin to update the GlobalConfig::admin public key. ### Method POST ### Endpoint /update_admin ### Parameters #### Path Parameters - **admin** (publicKey) - Required - The current admin's public key. - **new_admin** (publicKey) - Required - The new admin's public key. #### Query Parameters - **global_config** (publicKey) - Required - The public key of the GlobalConfig account. ### Request Body (Not applicable for this instruction, parameters are passed directly) ### Response #### Success Response (200) (Admin updated successfully.) #### Response Example (Success is indicated by the absence of an error.) ## POST /update_fee_config ### Description Allows the admin to update fee configurations in GlobalConfig. ### Method POST ### Endpoint /update_fee_config ### Parameters #### Path Parameters - **admin** (publicKey) - Required - The public key of the admin. #### Query Parameters - **lp_fee_basis_points** (number) - Optional - The new LP fee in basis points. - **protocol_fee_basis_points** (number) - Optional - The new protocol fee in basis points. - **protocol_fee_recipients** (array of publicKeys) - Optional - The new list of protocol fee recipients. ### Request Body (Not applicable for this instruction, parameters are passed directly) ### Response #### Success Response (200) (Fee configuration updated successfully.) #### Response Example (Success is indicated by the absence of an error.) ``` -------------------------------- ### Pool Creation Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md Instructions for creating new AMM pools. ```APIDOC ## POST /create_pool ### Description Allows creating a new AMM pool for a given token pair. ### Method POST ### Endpoint /create_pool ### Parameters #### Path Parameters - **index** (number) - Required - An index to differentiate pools with the same token pair from the same creator. - **creator** (publicKey) - Required - The public key of the pool creator and payer for creation costs. - **baseMint** (publicKey) - Required - The mint address of the base token. - **quoteMint** (publicKey) - Required - The mint address of the quote token. #### Query Parameters - **baseIn** (number) - Required - The initial amount of baseMint tokens to deposit. - **quoteIn** (number) - Required - The initial amount of quoteMint tokens to deposit. ### Request Body (Not applicable for this instruction, parameters are passed directly) ### Response #### Success Response (200) - **poolId** (publicKey) - The PDA-derived public key of the newly created pool. - **lpMint** (publicKey) - The mint address of the LP token for the new pool. #### Response Example { "poolId": "", "lpMint": "" } ``` -------------------------------- ### Swap Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_SDK_README.md Instructions for swapping tokens within a liquidity pool. ```APIDOC ## Swap ### Description This section describes how to perform token swaps within a pool. It covers both default swap directions (quote to base) and how to handle the reverse direction (base to quote), including autocompleting amounts and generating swap instructions. ### Swap Direction - `quoteToBase` (⬇️): Default direction, swapping quote tokens for base tokens. - `baseToQuote` (⬆️): Swapping base tokens for quote tokens. ### Autocomplete Base from Quote Input #### Method `pumpAmmSdk.swapAutocompleteBaseFromQuote` #### Description Call this when the `quote` input changes to autocomplete the corresponding `base` amount. #### Parameters - **pool** (object) - Required - The pool object. - **quote** (number) - Required - The amount of quote tokens to swap. - **slippage** (number) - Required - The maximum acceptable slippage. - **swapDirection** (string) - Required - The direction of the swap (`quoteToBase` or `baseToQuote`). #### Response Example ```javascript const base = await pumpAmmSdk.swapAutocompleteBaseFromQuote(pool, quote, slippage, swapDirection); ``` ### Autocomplete Quote from Base Input #### Method `pumpAmmSdk.swapAutocompleteQuoteFromBase` #### Description Call this when the `base` input changes to autocomplete the corresponding `quote` amount. #### Parameters - **pool** (object) - Required - The pool object. - **base** (number) - Required - The amount of base tokens to swap. - **slippage** (number) - Required - The maximum acceptable slippage. - **swapDirection** (string) - Required - The direction of the swap (`quoteToBase` or `baseToQuote`). #### Response Example ```javascript const quote = await pumpAmmSdk.swapAutocompleteQuoteFromBase(pool, base, slippage, swapDirection); ``` ### Generate Swap Instructions (Base for Quote) #### Method `pumpAmmSdk.swapBaseInstructions` #### Description Builds the AMM swap instructions when swapping base tokens for quote tokens. #### Parameters - **pool** (object) - Required - The pool object. - **base** (number) - Required - The amount of base tokens to swap. - **slippage** (number) - Required - The maximum acceptable slippage. - **swapDirection** (string) - Required - The direction of the swap (`quoteToBase` or `baseToQuote`). - **user** (string) - Required - The user's wallet address. #### Response Example ```javascript const swapInstructions = await pumpAmmSdk.swapBaseInstructions(pool, base, slippage, swapDirection, user); ``` ### Generate Swap Instructions (Quote for Base) #### Method `pumpAmmSdk.swapQuoteInstructions` #### Description Builds the AMM swap instructions when swapping quote tokens for base tokens. #### Parameters - **pool** (object) - Required - The pool object. - **quote** (number) - Required - The amount of quote tokens to swap. - **slippage** (number) - Required - The maximum acceptable slippage. - **swapDirection** (string) - Required - The direction of the swap (`quoteToBase` or `baseToQuote`). - **user** (string) - Required - The user's wallet address. #### Response Example ```javascript const swapInstructions = await pumpAmmSdk.swapQuoteInstructions(pool, quote, slippage, swapDirection, user); ``` ``` -------------------------------- ### Buy Base Input Instruction Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md Generates the Anchor instruction for buying the base asset. Computes the maximum quote input required based on the desired base output and slippage. ```typescript PumpAmmInternalSdk.buyBaseInput(pool, user, baseOut, slippage) ``` -------------------------------- ### PumpSwap SDK to Anchor Instruction Mapping Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md This section maps PumpSwap SDK methods to their corresponding Anchor instructions, detailing the parameters and return values. ```APIDOC ## PumpSwap SDK to Anchor Instruction Mapping ### Create Pool - **SDK Method**: `PumpAmmAdminSdk.createPoolInstructions(index, creator, baseMint, quoteMint, baseIn, quoteIn)` - **Anchor Instruction**: `create_pool(index, creator, baseMint, quoteMint, baseIn, quoteIn)` ### Deposit - **SDK Method**: `PumpAmmAdminSdk.depositInstructions(pool, user, lpTokenOut, slippage)` - **Anchor Instruction**: `deposit(pool, user, lpTokenOut, maxBaseIn, maxQuoteIn)` - **Description**: `maxBaseIn` and `maxQuoteIn` are computed using `lpTokenOut`, `slippage`, and current pool balances. ### Withdraw - **SDK Method**: `PumpAmmAdminSdk.withdrawInstructions(pool, user, lpTokenIn, slippage)` - **Anchor Instruction**: `withdraw(pool, user, lpTokenIn, minBaseOut, minQuoteOut)` - **Description**: `minBaseOut` and `minQuoteOut` are computed using `lpTokenIn`, `slippage`, and current pool balances. ### Buy Base Input - **SDK Method**: `PumpAmmInternalSdk.buyBaseInput(pool, user, baseOut, slippage)` - **Anchor Instruction**: `buy(pool, user, baseOut, maxQuoteIn)` - **Description**: `maxQuoteIn` is computed using `baseOut`, `slippage`, and current pool balances. ### Buy Quote Input - **SDK Method**: `PumpAmmInternalSdk.buyQuoteInput(pool, user, quote, slippage)` - **Anchor Instruction**: `buy(pool, user, baseOut, maxQuoteIn)` - **Description**: `baseOut` is computed using `quote`, `slippage`, and current pool balances. `maxQuoteIn` is `quote` scaled with `slippage`. ### Sell Base Input - **SDK Method**: `PumpAmmInternalSdk.sellBaseInput(pool, user, baseIn, slippage)` - **Anchor Instruction**: `sell(pool, user, baseIn, minQuoteOut)` - **Description**: `minQuoteOut` is computed using `baseIn`, `slippage`, and current pool balances. ### Sell Quote Input - **SDK Method**: `PumpAmmInternalSdk.sellQuoteInput(pool, user, quote, slippage)` - **Anchor Instruction**: `sell(pool, user, baseIn, minQuoteOut)` - **Description**: `baseIn` is computed using `quote`, `slippage`, and current pool balances. `minQuoteOut` is `quote` scaled with `slippage`. ### Swap Base Instructions - **SDK Method**: `PumpAmmSdk.swapBaseInstructions(pool, user, base, slippage, direction)` - **Description**: Calls either `PumpAmmInternalSdk.buyBaseInput` (if `direction == "quoteToBase"`) or `PumpAmmInternalSdk.sellBaseInput` (if `direction == "baseToQuote"`). ### Swap Quote Instructions - **SDK Method**: `PumpAmmSdk.swapQuoteInstructions(pool, user, quote, slippage, direction)` - **Description**: Calls either `PumpAmmInternalSdk.buyQuoteInput` (if `direction == "quoteToBase"`) or `PumpAmmInternalSdk.sellQuoteInput` (if `direction == "baseToQuote"`). ``` -------------------------------- ### Pump SDK Components Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_SDK_README.md Overview of the different SDK components available for integration. ```APIDOC ## Pump SDK Components ### Description The Pump SDK is structured into three main components: - `PumpAmmSdk`: High-level SDK suitable for UI integrations. - `PumpAmmInternalSdk`: Low-level SDK for programmatic integrations, offering full customization of instructions. - `PumpAmmAdminSdk`: SDK providing access to admin-protected instructions. ``` -------------------------------- ### Liquidity Management Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md Instructions for adding and removing liquidity from AMM pools. ```APIDOC ## POST /deposit ### Description Allows a user to deposit tokens into a pool to receive LP tokens. ### Method POST ### Endpoint /deposit ### Parameters #### Path Parameters - **pool** (publicKey) - Required - The public key of the AMM pool. - **user** (publicKey) - Required - The public key of the user depositing liquidity. - **lpTokenOut** (number) - Required - The amount of LP tokens to receive. #### Query Parameters - **maxBaseIn** (number) - Required - The maximum amount of base tokens the user is willing to deposit. - **maxQuoteIn** (number) - Required - The maximum amount of quote tokens the user is willing to deposit. ### Request Body (Not applicable for this instruction, parameters are passed directly) ### Response #### Success Response (200) - **baseDeposited** (number) - The actual amount of base tokens deposited. - **quoteDeposited** (number) - The actual amount of quote tokens deposited. #### Response Example { "baseDeposited": 1000, "quoteDeposited": 500 } ## POST /withdraw ### Description Allows a user to withdraw tokens from a pool by burning LP tokens. ### Method POST ### Endpoint /withdraw ### Parameters #### Path Parameters - **pool** (publicKey) - Required - The public key of the AMM pool. - **user** (publicKey) - Required - The public key of the user withdrawing liquidity. - **lpTokenIn** (number) - Required - The amount of LP tokens to burn. #### Query Parameters - **minBaseOut** (number) - Required - The minimum amount of base tokens the user expects to receive. - **minQuoteOut** (number) - Required - The minimum amount of quote tokens the user expects to receive. ### Request Body (Not applicable for this instruction, parameters are passed directly) ### Response #### Success Response (200) - **baseWithdrawn** (number) - The actual amount of base tokens withdrawn. - **quoteWithdrawn** (number) - The actual amount of quote tokens withdrawn. #### Response Example { "baseWithdrawn": 950, "quoteWithdrawn": 480 } ``` -------------------------------- ### Buy Quote Input Instruction Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md Generates the Anchor instruction for buying the quote asset. Computes the base output and maximum quote input based on the desired quote input and slippage. ```typescript PumpAmmInternalSdk.buyQuoteInput(pool, user, quote, slippage) ``` -------------------------------- ### Sell Base Input Instruction Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md Generates the Anchor instruction for selling the base asset. Computes the minimum quote output based on the provided base input and slippage. ```typescript PumpAmmInternalSdk.sellBaseInput(pool, user, baseIn, slippage) ``` -------------------------------- ### Coin Creation Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_PROGRAM_README.md Allows a user to create a new coin with specified name, symbol, and URI. ```APIDOC ## POST /api/create_coin ### Description Allows a `user` to create a new coin with the given `name`, `symbol`, and `uri`. The `creator` pubkey is added to the Metaplex metadata `creators` array. ### Method POST ### Endpoint `/api/create_coin` ### Parameters #### Query Parameters - **user** (pubkey) - Required - The public key of the user initiating the creation. - **name** (string) - Required - The name of the coin. - **symbol** (string) - Required - The symbol of the coin. - **uri** (string) - Required - The URI for the coin's metadata. - **creator** (pubkey) - Optional - The public key of the coin creator. Defaults to `user` if not provided. ### Request Example ```json { "user": "", "name": "MyToken", "symbol": "MTK", "uri": "https://example.com/metadata.json", "creator": "" } ``` ### Response #### Success Response (200) - **mint** (pubkey) - The public key of the newly created coin's mint. - **bonding_curve** (pubkey) - The public key of the associated bonding curve account. #### Response Example ```json { "mint": "", "bonding_curve": "" } ``` ``` -------------------------------- ### Autocomplete Deposit Base and LP Token from Quote Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md UI helper to autocomplete base and LP token amounts when the quote input changes during a deposit operation. Requires pool details, quote amount, and slippage. ```typescript PumpAmmSdk.depositAutocompleteBaseAndLpTokenFromQuote(pool, quote, slippage) ``` -------------------------------- ### Updated GlobalConfig Struct with Fee Field Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_CREATOR_FEE_README.md The 'GlobalConfig' account struct now includes 'coin_creator_fee_basis_points'. This field determines the fee percentage sent to the coin creator. ```rust #[account] pub struct GlobalConfig { pub admin: Pubkey, pub lp_fee_basis_points: u64, pub protocol_fee_basis_points: u64, pub disable_flags: u8, pub protocol_fee_recipients: [Pubkey; 8], pub coin_creator_fee_basis_points: u64, // new coin creator fee bps field } ``` -------------------------------- ### Build AMM Deposit Instruction Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_SDK_README.md Generates the AMM deposit instruction. Requires the pool, LP token amount, slippage, and user's public key. This is called after autocompleting other values. ```javascript const depositInstructions = await pumpAmmSdk.depositInstructions(pool, lpToken, slippage, user) ``` -------------------------------- ### Deposit Instruction Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md Generates the Anchor instruction for depositing assets into a pool. Computes maximum input amounts based on desired LP tokens and slippage tolerance. ```typescript PumpAmmAdminSdk.depositInstructions(pool, user, lpTokenOut, slippage) ``` -------------------------------- ### Build AMM Withdraw Instruction Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_SDK_README.md Generates the AMM withdraw instruction. Requires pool, LP token amount, slippage, and user's public key. ```javascript const withdrawInstructions = await pumpAmmSdk.withdrawInstructions(pool, lpToken, slippage, user) ``` -------------------------------- ### Swap Base Instruction Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md Provides a unified method to generate swap instructions for the base asset, internally calling either buy or sell logic based on the specified direction. ```typescript PumpAmmSdk.swapBaseInstructions(pool, user, base, slippage, direction) ``` -------------------------------- ### Autocomplete Initial Pool Price Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md Helper function to calculate and display the initial pool price for UI input during pool creation, based on initial base and quote amounts. ```typescript PumpAmmSdk.createAutocompleteInitialPoolPrice(initialBase, initialQuote) ``` -------------------------------- ### Autocomplete Initial Pool Price Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_SDK_README.md Helper function for UI integrations to calculate the initial pool price based on initial base and quote inputs. ```javascript const initialPoolPrice = pumpAmmSdk.createAutocompleteInitialPoolPrice(initialBase, initialQuote) ``` -------------------------------- ### Compute Fees for Bonding Curves Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/FEE_PROGRAM_README.md Determines the fee basis points for protocol and creator fees for bonding curves. If fee configuration is provided, it calculates fees based on market cap; otherwise, it uses global default fees. ```typescript export function computeFeesBps({ global, feeConfig, mintSupply, virtualSolReserves, virtualTokenReserves, }: { global: Global; feeConfig: FeeConfig | null; mintSupply: BN; virtualSolReserves: BN; virtualTokenReserves: BN; }): CalculatedFeesBps { if (feeConfig != null) { const marketCap = bondingCurveMarketCap({ mintSupply, virtualSolReserves, virtualTokenReserves, }); return calculateFeeTier({ feeTiers: feeConfig.feeTiers, marketCap, }); } return { protocolFeeBps: global.feeBasisPoints, creatorFeeBps: global.creatorFeeBasisPoints, }; } ``` -------------------------------- ### Autocomplete Deposit Quote and LP Token from Base Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md UI helper to autocomplete quote and LP token amounts when the base input changes during a deposit operation. Requires pool details, base amount, and slippage. ```typescript PumpAmmSdk.depositAutocompleteQuoteAndLpTokenFromBase(pool, base, slippage) ``` -------------------------------- ### Sell Quote Input Instruction Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md Generates the Anchor instruction for selling the quote asset. Computes the base input and minimum quote output based on the provided quote input and slippage. ```typescript PumpAmmInternalSdk.sellQuoteInput(pool, user, quote, slippage) ``` -------------------------------- ### PumpSwap SDK Autocomplete UI Helpers Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md This section provides details on PumpSwap SDK autocomplete methods used for UI input suggestions. ```APIDOC ## PumpSwap SDK Autocomplete UI Helpers ### Create Pool Autocomplete Initial Price - **SDK Method**: `PumpAmmSdk.createAutocompleteInitialPoolPrice(initialBase, initialQuote)` - **Description**: Used to display the initial pool price based on initial `base` and `quote` inputs on pool creation. ### Deposit Autocomplete Quote and LP Token from Base - **SDK Method**: `PumpAmmSdk.depositAutocompleteQuoteAndLpTokenFromBase(pool, base, slippage)` - **Description**: Autocompletes the corresponding `quote` and `lpToken` values in the UI when the `base` input changes on the deposit UI. ### Deposit Autocomplete Base and LP Token from Quote - **SDK Method**: `PumpAmmSdk.depositAutocompleteBaseAndLpTokenFromQuote(pool, quote, slippage)` - **Description**: Autocompletes the corresponding `base` and `lpToken` values in the UI when the `quote` input changes on the deposit UI. ### Swap Autocomplete Base from Quote - **SDK Method**: `PumpAmmSdk.swapAutocompleteBaseFromQuote(pool, quote, slippage, swapDirection)` - **Description**: Autocompletes the corresponding `base` value in the UI when the `quote` input changes on the swap UI. ### Swap Autocomplete Quote from Base - **SDK Method**: `PumpAmmSdk.swapAutocompleteQuoteFromBase(pool, base, slippage, swapDirection)` - **Description**: Autocompletes the corresponding `quote` value in the UI when the `base` input changes on the swap UI. ### Swap Autocomplete Base from Quote (Internal Mapping) - **SDK Method**: `PumpAmmSdk.swapAutocompleteBaseFromQuote(pool, quote, slippage, swapDirection)` - **Description**: Calls either `PumpAmmInternalSdk.buyAutocompleteBaseFromQuote` (if `swapDirection == "quoteToBase"`) or `PumpAmmInternalSdk.sellAutocompleteBaseFromQuote` (if `swapDirection == "baseToQuote"`). ### Swap Autocomplete Quote from Base (Internal Mapping) - **SDK Method**: `PumpAmmSdk.swapAutocompleteQuoteFromBase(pool, base, slippage, swapDirection)` - **Description**: Calls either `PumpAmmInternalSdk.buyAutocompleteQuoteFromBase` (if `swapDirection == "quoteToBase"`) or `PumpAmmInternalSdk.sellAutocompleteQuoteFromBase` (if `swapDirection == "baseToQuote"`). ### Withdraw Autocomplete Base and Quote from LP Token - **SDK Method**: `PumpAmmSdk.withdrawAutoCompleteBaseAndQuoteFromLpToken(pool, lpToken, slippage)` - **Description**: Autocompletes the corresponding `base` and `quote` values in the UI when the `lpToken` input changes on the withdraw UI. ``` -------------------------------- ### Withdraw Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_SDK_README.md Instructions for withdrawing liquidity from a pool. ```APIDOC ## Withdraw ### Description This section provides instructions on how to withdraw liquidity from a (base, quote) pool. It includes a function to generate withdrawal instructions and a helper function to autocomplete base and quote amounts based on the LP token amount. ### Generate Withdraw Instructions #### Method `pumpAmmSdk.withdrawInstructions` #### Description Generates the instructions required to withdraw liquidity from the pool. #### Parameters - **pool** (object) - Required - The pool object. - **lpToken** (number) - Required - The amount of LP tokens to withdraw. - **slippage** (number) - Required - The maximum acceptable slippage. - **user** (string) - Required - The user's wallet address. #### Response Example ```javascript const withdrawInstructions = await pumpAmmSdk.withdrawInstructions(pool, lpToken, slippage, user); ``` ### Autocomplete Base and Quote from LP Token #### Method `pumpAmmSdk.withdrawAutocompleteBaseAndQuoteFromLpToken` #### Description Autocompletes the `base` and `quote` amounts displayed in the UI based on the `lpToken` input. #### Parameters - **pool** (object) - Required - The pool object. - **lpToken** (number) - Required - The amount of LP tokens. - **slippage** (number) - Required - The maximum acceptable slippage. #### Response Example ```javascript const {base, quote} = pumpAmmSdk.withdrawAutocompleteBaseAndQuoteFromLpToken(pool, lpToken, slippage); ``` ``` -------------------------------- ### Autocomplete Swap Base from Quote Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md UI helper to autocomplete the base token amount when the quote input changes during a swap operation. Requires pool details, quote amount, slippage, and swap direction. ```typescript PumpAmmSdk.swapAutocompleteBaseFromQuote(pool, quote, slippage, swapDirection) ``` -------------------------------- ### Swap Quote Instruction Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md Provides a unified method to generate swap instructions for the quote asset, internally calling either buy or sell logic based on the specified direction. ```typescript PumpAmmSdk.swapQuoteInstructions(pool, user, quote, slippage, direction) ``` -------------------------------- ### Integrating Pump IDL with `idl-build` Feature Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/CPI_README.md Configure your wrapper program's Cargo.toml to include Pump's types in your IDL when building. This is achieved by enabling the 'idl-build' feature for pump-rust-client. ```toml [features] idl-build = [ "anchor-lang/idl-build", "anchor-spl/idl-build", "pump-rust-client/idl-build", ] [dependencies] pump-rust-client = { version = "...", path = "..." } ``` -------------------------------- ### Autocomplete Deposit Base and LP Token Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_SDK_README.md Call this when the quote input changes during a deposit to autocomplete base and LP token values. Requires pool, quote amount, and slippage. ```javascript const {base, lpToken} = await pumpAmmSdk.depositAutocompleteBaseAndLpTokenFromQuote(pool, quote, slippage) ``` -------------------------------- ### Buy Coins Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_PROGRAM_README.md Allows a user to buy a specified amount of coins from a bonding curve. ```APIDOC ## POST /api/buy ### Description Allows a `user` to buy a specific `amount` of coins from the bonding curve of a given `mint`, spending at most `max_sol_cost` lamports. ### Method POST ### Endpoint `/api/buy` ### Parameters #### Query Parameters - **user** (pubkey) - Required - The public key of the user buying the coins. - **associated_user** (pubkey) - Required - The associated user's public key (e.g., wallet address). - **mint** (pubkey) - Required - The public key of the coin's mint. - **amount** (u64) - Required - The exact amount of coins to buy. - **max_sol_cost** (u64) - Required - The maximum amount of SOL (in lamports) the user is willing to spend. ### Request Example ```json { "user": "", "associated_user": "", "mint": "", "amount": 1000000, "max_sol_cost": 5000000000 } ``` ### Response #### Success Response (200) - **sol_spent** (u64) - The amount of SOL spent in lamports. - **tokens_received** (u64) - The amount of tokens received. #### Response Example ```json { "sol_spent": 4500000000, "tokens_received": 950000 } ``` ``` -------------------------------- ### Withdraw Instruction Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_README.md Generates the Anchor instruction for withdrawing assets from a pool. Computes minimum output amounts based on provided LP tokens and slippage tolerance. ```typescript PumpAmmAdminSdk.withdrawInstructions(pool, user, lpTokenIn, slippage) ``` -------------------------------- ### Extend Account Data Size Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_PROGRAM_README.md Allows anyone to extend the data size of program-owned accounts. ```APIDOC ## POST /api/extend_account ### Description Allows any user to extend the data size of any program-owned account (`Global` or `BondingCurve`) to accommodate future field additions. ### Method POST ### Endpoint `/api/extend_account` ### Parameters #### Query Parameters - **user** (pubkey) - Required - The public key of the user initiating the extension. - **account** (pubkey) - Required - The public key of the account to extend. ### Request Example ```json { "user": "", "account": "" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the account extension operation (e.g., "extended"). #### Response Example ```json { "status": "extended" } ``` ``` -------------------------------- ### Autocomplete Swap Base from Quote Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_SWAP_SDK_README.md Call this when the quote input changes during a swap to autocomplete the base amount. Requires pool, quote amount, slippage, and swap direction. ```javascript const base = await pumpAmmSdk.swapAutocompleteBaseFromQuote(pool, quote, slippage, swapDirection) ``` -------------------------------- ### Derive User Accumulator PDA for Pump Program Source: https://github.com/pump-fun/pump-public-docs/blob/main/docs/PUMP_CASHBACK_README.md Use this function to derive the Program Derived Address (PDA) for the `UserVolumeAccumulator` account for the Pump program. Pass `PUMP_AMM_PROGRAM_ADDRESS` to derive the PDA for the Pump AMM program. ```typescript import { getAddressEncoder, getProgramDerivedAddress, getUtf8Encoder, } from "@solana/kit"; const addressEncoder = getAddressEncoder(); const utf8Encoder = getUtf8Encoder(); export const USER_ACCUMULATOR_SEED = utf8Encoder.encode( "user_volume_accumulator", ); export const NATIVE_MINT_ADDRESS = address( "So11111111111111111111111111111111111111112", ); export function getUserAccumulatorPda( walletAddress: Address, programAddress: Address = PUMP_PROGRAM_ADDRESS, ) { return getProgramDerivedAddress({ programAddress, seeds: [USER_ACCUMULATOR_SEED, addressEncoder.encode(walletAddress)], }); } export async function getUserAccumulatorCashbackPda( walletAddress: Address, programAddress: Address = PUMP_PROGRAM_ADDRESS, ): Promise { const [userAccumulatorPda] = await getUserAccumulatorPda( walletAddress, programAddress, ); return findAssociatedTokenPda({ mint: NATIVE_MINT_ADDRESS, owner: userAccumulatorPda, tokenProgram: TOKEN_PROGRAM_ADDRESS, }); } ```