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 🙏

© 2026 – Pkg Stats / Ryan Hefner

like-pumpswap

v2.4.1

Published

Buy and sell tokens on swap.pump.fun (AMM) easily

Downloads

252

Readme

like-pumpswap

Buy and sell tokens on swap.pump.fun (AMM) easily

npm i like-pumpswap

Need support? Join the community: https://lucasbarrena.com

Usage

Both like-pumpfun and like-pumpswap have similar API on purpose for easyness.

They have different math and instructions underneath.

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

const Pumpswap = require('like-pumpswap')
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
}

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,
  quoteAmountOutWithoutLpFee: BigInt,
  userQuoteAmountOut: BigInt,
  quoteOutMin: BigInt
}

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.

Pumpfun compatible

ix = pumpswap.buy(mint, baseAmountOut, quoteInMax, userPublicKey, reserves)

Create buy instructions. This mimics the API from like-pumpfun on purpose.

Internally, it uses buyExactOut.

Note: Reserves here specifically only needs { creator }.

ix = pumpswap.sell(mint, baseAmountIn, quoteOutMin, userPublicKey, reserves)

Create sell instructions. This mimics the API from like-pumpfun on purpose.

Internally, it uses sellExactIn.

Note: Reserves here specifically only needs { creator }.

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