Skip to main content

PumpSdk

Struct PumpSdk 

Source
pub struct PumpSdk;
Expand description

Offline instruction builders. No RPC calls are made and does not require RPC connection url.

Implementations§

Source§

impl PumpSdk

Source

pub const fn new() -> Self

Source

pub fn create_instruction( &self, mint: Pubkey, user: Pubkey, name: impl Into<String>, symbol: impl Into<String>, uri: impl Into<String>, creator: Pubkey, ) -> Instruction

👎Deprecated:

Use create_v2_instruction instead

v1 create: SPL Token + Metaplex metadata. The TS SDK marks the matching helper @deprecated in favor of create_v2_instruction, but it remains supported on-chain.

Source

pub fn create_v2_instruction( &self, mint: Pubkey, user: Pubkey, name: impl Into<String>, symbol: impl Into<String>, uri: impl Into<String>, creator: Pubkey, mayhem_mode: bool, cashback: bool, ) -> Instruction

v2 create: Token-2022 + Mayhem PDAs.

Source

pub fn buy_instruction( &self, mint: Pubkey, user: Pubkey, creator: Pubkey, fee_recipient: Pubkey, buyback_fee_recipient: Pubkey, amount: u64, max_sol_cost: u64, token_program: Pubkey, ) -> Instruction

👎Deprecated:

Use buy_v2_instruction instead

Buy tokens from a bonding curve. The caller picks fee_recipient and buyback_fee_recipient from the on-chain Global state. max_sol_cost is the slippage-adjusted ceiling on SOL spent. token_program is the SPL Token program for the mint (Token-2022 for v2 coins, classic SPL Token otherwise).

Remaining accounts (in order, mirrors pump-sdk-internal’s getBuyInstructionInternal): bonding_curve_v2 (readonly), buyback_fee_recipient (writable).

Source

pub fn buy_v2_instruction( &self, base_mint: Pubkey, quote_mint: Pubkey, base_token_program: Pubkey, quote_token_program: Pubkey, user: Pubkey, creator: Pubkey, fee_recipient: Pubkey, buyback_fee_recipient: Pubkey, amount: u64, max_sol_cost: u64, ) -> Instruction

Buy tokens with an arbitrary quote mint. Unlike buy_instruction, the program takes the quote asset on its own token program and routes a share of fees through the per-mint sharing_config. Caller picks fee_recipient and buyback_fee_recipient from Global.

Source

pub fn buy_v2_instructions( &self, base_mint: Pubkey, quote_mint: Pubkey, base_token_program: Pubkey, quote_token_program: Pubkey, user: Pubkey, creator: Pubkey, fee_recipient: Pubkey, buyback_fee_recipient: Pubkey, amount: u64, max_sol_cost: u64, ) -> Vec<Instruction>

buy_v2 preceded by idempotent ATA creates for every account the program does NOT lazy-initialize. From programs/pump/src/buy_v2.rs, validate_quote_token_account only initializes the creator-vault, user-volume-accumulator, and quote-fee-recipient quote ATAs (should_initialize = true); everything else must already exist. We emit 4 prefixes:

  1. associated_base_user (always required)
  2. associated_quote_bonding_curve
  3. associated_quote_user
  4. associated_quote_buyback_fee_recipient (2-4) are only enforced for non-legacy curves but are idempotent and cheap when already present.
Source

pub fn sell_instruction( &self, mint: Pubkey, user: Pubkey, creator: Pubkey, fee_recipient: Pubkey, amount: u64, min_sol_output: u64, token_program: Pubkey, ) -> Instruction

👎Deprecated:

Use sell_v2_instruction instead

Sell tokens back to a bonding curve. The caller picks fee_recipient from the on-chain Global state. min_sol_output is the slippage-adjusted floor on SOL received. token_program is the SPL Token program for the mint (Token-2022 for v2 coins, classic SPL Token otherwise).

Remaining accounts (in order, mirrors the on-chain handler’s cashback path): user_volume_accumulator (writable), bonding_curve_v2 (readonly). Always appended; the program falls back to creator_vault when these are absent or invalid.

Source

pub fn sell_v2_instruction( &self, base_mint: Pubkey, quote_mint: Pubkey, base_token_program: Pubkey, quote_token_program: Pubkey, user: Pubkey, creator: Pubkey, fee_recipient: Pubkey, buyback_fee_recipient: Pubkey, amount: u64, min_sol_output: u64, ) -> Instruction

Sell tokens for an arbitrary quote mint. Mirror of buy_v2_instruction on the sell side. Routes a share of fees through the per-mint sharing_config. Caller picks fee_recipient and buyback_fee_recipient from Global.

Source

pub fn sell_v2_instructions( &self, base_mint: Pubkey, quote_mint: Pubkey, base_token_program: Pubkey, quote_token_program: Pubkey, user: Pubkey, creator: Pubkey, fee_recipient: Pubkey, buyback_fee_recipient: Pubkey, amount: u64, min_sol_output: u64, ) -> Vec<Instruction>

sell_v2 preceded by idempotent ATA creates for every account the program does NOT lazy-initialize. Mirrors buy_v2_instructions. We emit 4 prefixes:

  1. associated_base_user (user must hold the base token)
  2. associated_quote_bonding_curve
  3. associated_quote_user (user receives quote)
  4. associated_quote_buyback_fee_recipient
Source

pub fn create_v2_and_buy_instruction( &self, mint: Pubkey, user: Pubkey, name: impl Into<String>, symbol: impl Into<String>, uri: impl Into<String>, creator: Pubkey, mayhem_mode: bool, cashback: bool, fee_recipient: Pubkey, buyback_fee_recipient: Pubkey, amount: u64, max_sol_cost: u64, ) -> Vec<Instruction>

create_v2 + idempotent ATA + buy, in that order. Mirrors createV2AndBuyInstructions in pump-sdk/src/sdk.ts. fee_recipient is supplied by the caller (typically picked from Global). Quote is wSOL on the classic SPL Token program — the only sensible quote at creation time. For other quotes, call buy_v2_instruction directly.

Source

pub fn extend_account_ix(&self, mint: Pubkey, user: Pubkey) -> Instruction

Source

pub fn buy_amm_instruction( &self, pool: Pubkey, base_mint: Pubkey, quote_mint: Pubkey, base_token_program: Pubkey, quote_token_program: Pubkey, user: Pubkey, coin_creator: Pubkey, protocol_fee_recipient: Pubkey, buyback_fee_recipient: Pubkey, is_cashback_coin: bool, base_amount_out: u64, max_quote_amount_in: u64, ) -> Instruction

Buy on a graduated pump_amm pool. Mirrors PUMP_AMM_SDK.buyInstructions’ inner IX from pump-swap-sdk/src/sdk/offlinePumpAmm.ts. Caller picks protocol_fee_recipient from GlobalConfig (via getFeeRecipient) and buyback_fee_recipient likewise (via getBuybackFeeRecipient). coin_creator and is_cashback_coin come from the on-chain Pool. Pass Pubkey::default() for coin_creator to skip the bonding_curve_v2 remaining account on default-creator pools. track_volume is hardcoded to true (matches the TS SDK).

Source

pub fn buy_amm_instructions( &self, pool: Pubkey, base_mint: Pubkey, quote_mint: Pubkey, base_token_program: Pubkey, quote_token_program: Pubkey, user: Pubkey, coin_creator: Pubkey, protocol_fee_recipient: Pubkey, buyback_fee_recipient: Pubkey, is_cashback_coin: bool, base_amount_out: u64, max_quote_amount_in: u64, ) -> Vec<Instruction>

buy_amm preceded by an idempotent ATA-create for the user’s base ATA (the asset being received). Wsol management for the quote side is the caller’s responsibility; the existing buy_v2_instructions wrapper follows the same convention.

Source

pub fn sell_amm_instruction( &self, pool: Pubkey, base_mint: Pubkey, quote_mint: Pubkey, base_token_program: Pubkey, quote_token_program: Pubkey, user: Pubkey, coin_creator: Pubkey, protocol_fee_recipient: Pubkey, buyback_fee_recipient: Pubkey, is_cashback_coin: bool, base_amount_in: u64, min_quote_amount_out: u64, ) -> Instruction

Sell on a graduated pump_amm pool. Mirrors PUMP_AMM_SDK.sellInstructions’ inner IX from pump-swap-sdk/src/sdk/offlinePumpAmm.ts. The remaining-account layout differs from buy in three places (cashback adds two accounts not one, the cashback ATA uses quote_mint not NATIVE_MINT, and buyback_fee_recipient is read-only). See buy_amm_instruction for the rest of the parameter contract.

Source

pub fn sell_amm_instructions( &self, pool: Pubkey, base_mint: Pubkey, quote_mint: Pubkey, base_token_program: Pubkey, quote_token_program: Pubkey, user: Pubkey, coin_creator: Pubkey, protocol_fee_recipient: Pubkey, buyback_fee_recipient: Pubkey, is_cashback_coin: bool, base_amount_in: u64, min_quote_amount_out: u64, ) -> Vec<Instruction>

sell_amm preceded by an idempotent ATA-create for the user’s quote ATA (the asset being received).

Source

pub fn trade_tx_instructions(&self, params: TradeTxParams) -> Vec<Instruction>

Build a complete buy/sell against either the bonding curve (buy_v2/ sell_v2) or a graduated pump_amm pool. Mirrors TradeTxService.tradeTx.

Source

pub fn create_coin_instructions( &self, params: CreateCoinParams, ) -> Vec<Instruction>

Build a complete create_v2 + initial-buy with full SOL wrap/unwrap. Mirrors TradeTxService.createCoin minus the optional tokenized-agent step (no Rust pump-agent-payments SDK in this repo).

Source

pub fn buy_quote_bonding_curve_sol_in( &self, global: &Global, fee_config: Option<&FeeConfig>, bonding_curve: &BondingCurve, mint_supply: u64, sol_amount: u64, slippage_bps: u16, ) -> QuoteResult<Quote>

Bonding curve buy quoting where the user specifies SOL in.

Source

pub fn buy_quote_bonding_curve_token_out( &self, global: &Global, fee_config: Option<&FeeConfig>, bonding_curve: &BondingCurve, mint_supply: u64, token_amount: u64, slippage_bps: u16, ) -> QuoteResult<Quote>

Bonding curve buy quoting where the user specifies token amount out.

Source

pub fn sell_quote_bonding_curve( &self, global: &Global, fee_config: Option<&FeeConfig>, bonding_curve: &BondingCurve, mint_supply: u64, token_amount: u64, slippage_bps: u16, ) -> QuoteResult<Quote>

Bonding curve sell quoting.

Source

pub fn buy_quote_amm_sol_in( &self, global_config: &GlobalConfig, fee_config: Option<&AmmFeeConfig>, source: AmmQuoteSource<'_>, sol_amount: u64, slippage_bps: u16, ) -> QuoteResult<Quote>

AMM buy quoting where the user specifies quote (e.g. wSOL) in.

Source

pub fn buy_quote_amm_token_out( &self, global_config: &GlobalConfig, fee_config: Option<&AmmFeeConfig>, source: AmmQuoteSource<'_>, token_amount: u64, slippage_bps: u16, ) -> QuoteResult<Quote>

AMM buy quoting where the user specifies token amount out.

Source

pub fn sell_quote_amm( &self, global_config: &GlobalConfig, fee_config: Option<&AmmFeeConfig>, source: AmmQuoteSource<'_>, token_amount: u64, slippage_bps: u16, ) -> QuoteResult<Quote>

AMM sell quoting.

Trait Implementations§

Source§

impl Clone for PumpSdk

Source§

fn clone(&self) -> PumpSdk

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PumpSdk

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PumpSdk

Source§

fn default() -> PumpSdk

Returns the “default value” for a type. Read more
Source§

impl Copy for PumpSdk

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V