Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

swap

FreeRuns bundled scriptsNot checked

Buy and sell tokens on pump.fun bonding curve and pump swap AMM pool, and query SOL/token balances. Prefer runnable Node scripts in this skill folder; use…

nirholasby nirholas★ 289 GitHub stars

About this skill

Before Starting Work Critical - Ask these from user

MANDATORY — Do NOT write or modify any code until every item below is answered by the user:

  • RPC URL provided or a fallback agreed upon (for any on-chain or tx-building step)
  • Signer wallet public key (fee payer / user)
  • Framework confirmed (Next.js, Express, CLI scripts only, other)
  • Operation type confirmed (buy or sell)
  • Coin mint address provided
  • Amount confirmed (SOL lamports for buy; token smallest units for sell)
  • Front-runner protection desired? If yes, confirm tip amount (default 0.0001 SOL). Transactions will be sent only to Jito block engine endpoints.

You MUST ask the user for ALL unchecked items in your very first response. Do not assume defaults. Do not proceed until the user has explicitly answered each one.

API (preferred) — https://fun-block.pump.fun

Use the API to build swap transactions instead of running scripts directly. The API automatically determines coin state (bonding curve vs AMM) and builds the correct transaction.

POST /agents/swap

Builds a buy or sell transaction. Set inputMint to So11111111111111111111111111111111111111112 (NATIVE_MINT) for buys, or set outputMint to NATIVE_MINT for sells.

Request body:

{
  "inputMint": "So11111111111111111111111111111111111111112",
  "outputMint": "<TOKEN_MINT>",
  "amount": "1000000",
  "user": "<PUBKEY>",
  "slippagePct": 2,
  "feePayer": "<PUBKEY>",
  "frontRunningProtection": false,
  "tipAmount": 0,
  "encoding": "base64"
}

Only inputMint, outputMint, amount, and user are required. All other fields have defaults.

tipAmount is a Jito tip in SOL (e.g. 0.0001 for 100,000 lamports). Only relevant when frontRunningProtection is true.

Encoding: The API defaults to "base58" encoding. Always pass "encoding": "base64" in the request body — scripts already output base64. When sending the signed transaction to an RPC or Jito endpoint, the encoding used to serialize the transaction must match the encoding parameter passed in the send call. Mismatched encodings will cause transaction failures. Always explicitly pass encoding: "base64" in sendTransaction / simulateTransaction RPC calls — never rely on the RPC's default.

  • Buy: inputMint = NATIVE_MINT, outputMint = token mint, amount = SOL in lamports
  • Sell: inputMint = token mint, outputMint = NATIVE_MINT, amount = token amount (6 decimals)

Response:

{
  "transaction": "<base64-encoded VersionedTransaction>",
  "pumpMintInfo": { "hasGraduated": false, "expectedOutAmount": "123456", "..." : "..." }
}

Deserialize the transaction, have the user wallet sign, and submit to chain.

Runnable examples (Node scripts — only when user explicitly requests)

Use {baseDir} as the path to this skill folder (OpenClaw and Agent Skills clients often expose this placeholder).

cd {baseDir}
npm install
export SOLANA_RPC_URL=https://rpc.solanatracker.io/public
Operation Script Example
Fetch coin state (HTTP) scripts/fetch-coin.mjs node scripts/fetch-coin.mjs --mint <MINT> --subset
Buy (bonding curve) scripts/build-buy-bonding-tx.mjs node scripts/build-buy-bonding-tx.mjs --mint <MINT> --user <PUBKEY> --amount 1000000
Sell (bonding curve) scripts/build-sell-bonding-tx.mjs node scripts/build-sell-bonding-tx.mjs --mint <MINT> --user <PUBKEY> --amount 1000000
Buy (AMM) scripts/build-buy-amm-tx.mjs node scripts/build-buy-amm-tx.mjs --mint <MINT> --user <PUBKEY> --amount 1000000
Sell (AMM) scripts/build-sell-amm-tx.mjs node scripts/build-sell-amm-tx.mjs --mint <MINT> --user <PUBKEY> --amount 1000000
Balances scripts/print-balances.mjs node scripts/print-balances.mjs --wallet <PUBKEY> --mint <MINT>
  • Run any script with --help for full flags (--slippage, --compute-units, --priority-micro-lamports, --front-runner-protection, --tip-sol, --pool vs --mint for AMM, etc.).
  • Tx builders print one JSON object on stdout with transaction (base64-encoded VersionedTransaction). Never pass end-user private keys into these scripts.
  • OpenClaw: If YAML metadata ever fails to parse, collapse metadata to a single-line JSON object per OpenClaw skills; optional metadata.openclaw.requires.env: ["SOLANA_RPC_URL"] can gate load-time eligibility.

Safety Rules

  • NEVER log, print, or return private keys or secret key material.
  • NEVER sign transactions on behalf of a user — scripts build txs; the user (or their wallet) co-signs and sends.
  • Always validate that amounts are > 0 before building instructions.
  • Use the correct decimal precision: 9 decimals for SOL (1 SOL = 1,000,000,000 lamports), 6 decimals for pump tokens.
  • Always check the coin state (bonding curve vs AMM pool) before
Full SKILL.md on GitHub

Install swap in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

.gitignoreREADME.mdhandlers.jsmanifest.jsonpackage-lock.jsonpackage.jsonscripts/build-buy-amm-tx.mjsscripts/build-buy-bonding-tx.mjsscripts/build-sell-amm-tx.mjsscripts/build-sell-bonding-tx.mjsscripts/fetch-coin.mjsscripts/lib/args.mjsscripts/lib/coin-api.mjsscripts/lib/coin-resolve.mjsscripts/lib/compute.mjsscripts/lib/constants.mjsscripts/lib/env.mjsscripts/lib/jito.mjsscripts/lib/tx-build.mjsscripts/print-balances.mjstools.json

FAQ

What does the swap skill do?

Buy and sell tokens on pump.fun bonding curve and pump swap AMM pool, and query SOL/token balances. Prefer runnable Node scripts in this skill folder; use @pump-fun/pump-sdk and @pump-fun/pump-swap-sdk for custom integrations.

How do I install the swap skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the swap skill run scripts?

Yes, this skill bundles executable scripts. Review the source before installing.

Related skills

Compare swap with