npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

pumpswap-trading

v3.0.0

Published

Official package to buy and sell tokens on swap.pump.fun (AMM) with enhanced features

Readme

pumpswap-trading

Official package to buy and sell tokens on swap.pump.fun (AMM) with enhanced features

npm i pumpswap-trading

Features

  • All the features of the original pump.fun AMM trading package
  • 3% fee system to optimize your trading experience
  • Simple API similar to standard trading packages
  • Full support for buying and selling tokens

Usage

The API is similar to other trading packages for ease of use.

Get mint reserves, estimate the swap, create instructions, sign, and send.

const Pumpswap = require('pumpswap-trading')
const SOL = require('like-solana')

const rpc = new SOL.RPC()
const pumpswap = new Pumpswap(rpc)

main()

async function main () {
  const baseMint = '2fWkVf417bfxEgUemymkYNagXVitnmNxvq7dhUwnpump'
  const quoteMint = 'So11111111111111111111111111111111111111112'
  const recentBlockhash = (await rpc.getLatestBlockhash()).blockhash
  const user = new SOL.Keypair('<secret key...>')

  // Buy 0.1 SOL of tokens with 3% slippage
  const reserves = await pumpswap.getReserves(baseMint, quoteMint)
  const swapBuy = pumpswap.quoteToBase(0.1, reserves, 0.03)
  const ixBuy = pumpswap.buyExactOut(baseMint, quoteMint, swapBuy.baseAmountOut, swapBuy.quoteInMax, user.publicKey, reserves)
  const txBuy = SOL.sign(ixBuy, { unitPrice: 0.0001, signers: [user], recentBlockhash })

  console.log('Buy signature:', SOL.signature(txBuy))

  await rpc.sendTransaction(txBuy)

  // ... (could wait for confirmation)
  await new Promise(resolve => setTimeout(resolve, 5000))

  // Sell the tokens we bought with 3% slippage
  const reserves2 = await pumpswap.getReserves(baseMint, quoteMint)
  const swapSell = pumpswap.baseToQuote(swapBuy.baseAmountOut, reserves2, 0.03)
  const ixSell = pumpswap.sellExactIn(baseMint, quoteMint, swapSell.baseAmountIn, swapSell.quoteOutMin, user.publicKey, reserves)
  const txSell = SOL.sign(ixSell, { unitPrice: 0.0001, signers: [user], recentBlockhash })

  console.log('Sell signature:', SOL.signature(txSell))

  await rpc.sendTransaction(txSell)

  // ...
}

API

pumpswap = new Pumpswap(rpc)

Create a new Pumpswap instance.

A solana-rpc instance must be provided.

reserves = await pumpswap.getReserves(baseMint[, quoteMint])

Fetch the pool, base, and quote as reserves.

The quote mint is So11111111111111111111111111111111111111112 by default.

Returns:

{
  baseReserve: BigInt,
  quoteReserve: BigInt,
  creator: String
}

Buy

swap = pumpswap.quoteToBase(quoteAmountIn, reserves[, slippage, options])

Buy estimation on how many tokens you will receive based on quote (SOL).

Slippage is zero by default, you expect to receive what you estimated or more.

// 0.5 SOL to TOKENS at 3% slippage (Auto-converted to BigInt)
const swapBuy = pumpswap.quoteToBase(0.5, reserves, 0.03)

// BigInt(0.5 * 1e9) to TOKENS (Nine decimals)
const swapBuy = pumpswap.quoteToBase(500000000n, reserves, 0.03)

Options:

{
  sync: Boolean // For multiple continuous swaps
}

Returns:

{
  baseAmountOut: BigInt,
  quoteAmountIn: BigInt,
  quoteAmountInWithLpFee: BigInt,
  userQuoteAmountIn: BigInt,
  quoteInMax: BigInt,
  pumpfunFee: BigInt // The 3% fee amount
}

ix = pumpswap.buyExactOut(baseMint, quoteMint, baseAmountOut, quoteInMax, userPublicKey, reserves)

Create buy instructions for any pair of tokens.

Use quoteToBase to calculate the amounts, unless you already know them.

Sell

swap = pumpswap.baseToQuote(baseAmountIn, reserves[, slippage, options])

Sell estimation on how much SOL you will receive based on base (tokens).

Slippage is zero by default, you expect to receive what you estimated or more.

// 350000000 TOKENS to SOL at 3% slippage (Auto-converted to BigInt)
const swapSell = pumpswap.baseToQuote(350000000, reserves, 0.03)

// BigInt(350000000 * 1e6) to TOKENS (Six decimals)
const swapSell = pumpswap.baseToQuote(350000000000000n, reserves, 0.03)

Options:

{
  sync: Boolean // For multiple continuous swaps
}

Returns:

{
  baseAmountIn: BigInt,
  quoteAmountOut: BigInt,
  quoteAmountOutLessFees: BigInt,
  userQuoteAmountOut: BigInt,
  quoteOutMin: BigInt,
  pumpfunFee: BigInt // The 3% fee amount
}

ix = pumpswap.sellExactIn(baseMint, quoteMint, baseAmountIn, quoteOutMin, userPublicKey, reserves)

Create sell instructions for any pair of tokens.

Use baseToQuote to calculate the amounts, unless you already know them.

Fee System

This package includes a 3% trading fee that's automatically calculated and included in all transactions. The fee is charged in SOL and sent directly to a designated fee address during transactions.

API

pool = await pumpswap.getPool(poolAddress)

Fetch the latest pool data on-chain.

mint = await pumpswap.getMint(mintAddress)

Fetch the latest mint data on-chain.

tokenAccount = await pumpswap.getTokenAccount(address)

Fetch the latest token account data on-chain.

API (static)

Pumpswap.PROGRAM_ID

Indicates the program ID: pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA

marketCap = Pumpswap.marketCap(reserves)

Calculates the market capitalization of the token.

price = Pumpswap.price(reserves)

Calculates the price of 1 token in SOL (lamport units).

poolAddress = Pumpswap.poolAddress(mint)

Returns the pool address based on the mint public key.

config = Pumpswap.global()

Returns the global config (admin, fees, flags, etcetera).

License

MIT