[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6GR80ZDGPREBF6SSCBVSZK7":3,"skill-same:01M6GR80ZDGPREBF6SSCBVSZK7":157},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":40,"linkOnly":41,"markdownContent":42,"markdownBody":43,"frontMatter":44,"refName":48,"commitSha":49,"skillDirectory":50,"forksCount":51,"repositoryHtmlUrl":52,"repositoryHomepageUrl":6,"ownerHtmlUrl":53,"ownerBlogUrl":54,"ownerDescription":55,"updatedAt":56,"install":57,"resources":70},"01M6GR80ZDGPREBF6SSCBVSZK7","swap",null,"Buy and sell tokens on pump.fun bonding curve and pump swap AMM pool, and query SOL\u002Ftoken balances. Prefer runnable Node scripts in this skill folder; use @pump-fun\u002Fpump-sdk and @pump-fun\u002Fpump-swap-sdk for custom integrations.","jiayaoqijia\u002Fcryptoskill","jiayaoqijia","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1453879?v=4","01M6GMYTX7Q7S504VC6E756ENR","YQ","01M6GMYV1QKJ1CC75MTTGT9PR0",81,"AGPL-3.0","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002FSKILL.md",[],[5,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39],"scripts","balances","custom","for","sol","pool","pump","pump.fun","amm","folder","pump-fun","sdk","tokens","token","sell","buy","query","fun","use","node","integrations","2026-11-10 10:12:30",false,"---\nname: swap\ndescription: >\n  Buy and sell tokens on pump.fun bonding curve and pump swap AMM pool, and\n  query SOL\u002Ftoken balances. Prefer runnable Node scripts in this skill folder;\n  use @pump-fun\u002Fpump-sdk and @pump-fun\u002Fpump-swap-sdk for custom integrations.\nmetadata:\n  author: pump-fun\n  version: \"1.0\"\n---\n\n# Before Starting Work **Critical** - Ask these from user\n\n**MANDATORY — Do NOT write or modify any code until every item below is answered by the user:**\n\n- [ ] RPC URL provided or a fallback agreed upon (for any on-chain or tx-building step)\n- [ ] **Signer wallet** public key (fee payer \u002F user)\n- [ ] Framework confirmed (Next.js, Express, CLI scripts only, other)\n- [ ] Operation type confirmed (buy or sell)\n- [ ] Coin mint address provided\n- [ ] Amount confirmed (SOL lamports for buy; token smallest units for sell)\n- [ ] Front-runner protection desired? If yes, confirm tip amount (default 0.0001 SOL). Transactions will be sent **only** to Jito block engine endpoints.\n\nYou 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.\n\n## API (preferred) — `https:\u002F\u002Ffun-block.pump.fun`\n\nUse 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.\n\n### `POST \u002Fagents\u002Fswap`\n\nBuilds a buy or sell transaction. Set `inputMint` to `So11111111111111111111111111111111111111112` (NATIVE_MINT) for buys, or set `outputMint` to NATIVE_MINT for sells.\n\n**Request body:**\n\n```json\n{\n  \"inputMint\": \"So11111111111111111111111111111111111111112\",\n  \"outputMint\": \"\u003CTOKEN_MINT>\",\n  \"amount\": \"1000000\",\n  \"user\": \"\u003CPUBKEY>\",\n  \"slippagePct\": 2,\n  \"feePayer\": \"\u003CPUBKEY>\",\n  \"frontRunningProtection\": false,\n  \"tipAmount\": 0,\n  \"encoding\": \"base64\"\n}\n```\n\nOnly `inputMint`, `outputMint`, `amount`, and `user` are required. All other fields have defaults.\n\n> **`tipAmount`** is a Jito tip in **SOL** (e.g. `0.0001` for 100,000 lamports). Only relevant when `frontRunningProtection` is `true`.\n\n> **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` \u002F `simulateTransaction` RPC calls — never rely on the RPC's default.\n\n- **Buy:** `inputMint` = NATIVE_MINT, `outputMint` = token mint, `amount` = SOL in lamports\n- **Sell:** `inputMint` = token mint, `outputMint` = NATIVE_MINT, `amount` = token amount (6 decimals)\n\n**Response:**\n\n```json\n{\n  \"transaction\": \"\u003Cbase64-encoded VersionedTransaction>\",\n  \"pumpMintInfo\": { \"hasGraduated\": false, \"expectedOutAmount\": \"123456\", \"...\" : \"...\" }\n}\n```\n\nDeserialize the `transaction`, have the user wallet sign, and submit to chain.\n\n## Runnable examples (Node scripts — only when user explicitly requests)\n\nUse **`{baseDir}`** as the path to this skill folder (OpenClaw and Agent Skills clients often expose this placeholder).\n\n```bash\ncd {baseDir}\nnpm install\nexport SOLANA_RPC_URL=https:\u002F\u002Frpc.solanatracker.io\u002Fpublic\n```\n\n| Operation | Script | Example |\n| --------- | ------ | ------- |\n| Fetch coin state (HTTP) | `scripts\u002Ffetch-coin.mjs` | `node scripts\u002Ffetch-coin.mjs --mint \u003CMINT> --subset` |\n| Buy (bonding curve) | `scripts\u002Fbuild-buy-bonding-tx.mjs` | `node scripts\u002Fbuild-buy-bonding-tx.mjs --mint \u003CMINT> --user \u003CPUBKEY> --amount 1000000` |\n| Sell (bonding curve) | `scripts\u002Fbuild-sell-bonding-tx.mjs` | `node scripts\u002Fbuild-sell-bonding-tx.mjs --mint \u003CMINT> --user \u003CPUBKEY> --amount 1000000` |\n| Buy (AMM) | `scripts\u002Fbuild-buy-amm-tx.mjs` | `node scripts\u002Fbuild-buy-amm-tx.mjs --mint \u003CMINT> --user \u003CPUBKEY> --amount 1000000` |\n| Sell (AMM) | `scripts\u002Fbuild-sell-amm-tx.mjs` | `node scripts\u002Fbuild-sell-amm-tx.mjs --mint \u003CMINT> --user \u003CPUBKEY> --amount 1000000` |\n| Balances | `scripts\u002Fprint-balances.mjs` | `node scripts\u002Fprint-balances.mjs --wallet \u003CPUBKEY> --mint \u003CMINT>` |\n\n- 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.).\n- Tx builders print **one JSON object** on stdout with `transaction` (base64-encoded VersionedTransaction). **Never** pass end-user private keys into these scripts.\n- **OpenClaw:** If YAML `metadata` ever fails to parse, collapse `metadata` to a single-line JSON object per [OpenClaw skills](https:\u002F\u002Fdocs.openclaw.ai\u002Fskills\u002F); optional `metadata.openclaw.requires.env: [\"SOLANA_RPC_URL\"]` can gate load-time eligibility.\n\n## Safety Rules\n\n- **NEVER** log, print, or return private keys or secret key material.\n- **NEVER** sign transactions on behalf of a user — scripts build txs; the user (or their wallet) co-signs and sends.\n- Always validate that amounts are `> 0` before building instructions.\n- Use the correct decimal precision: **9 decimals for SOL** (1 SOL = 1,000,000,000 lamports), **6 decimals for pump tokens**.\n- Always check the coin state (bonding curve vs AMM pool) before choosing the right path.\n- Always apply slippage protection on buy\u002Fsell transactions.\n- **NEVER trust `token_program` from the HTTP API** (`coins-v2`). Always fetch the mint account on-chain via `connection.getAccountInfo(mint)` and use `.owner` to determine the correct token program (SPL Token or Token-2022).\n- **Verify imports:** use `@pump-fun\u002Fpump-sdk` \u002F `@pump-fun\u002Fpump-swap-sdk` (not internal monorepo paths). In TypeScript apps, `BN` from `bn.js` matches what the SDKs expect (Anchor `BN` is the same type in practice).\n\n## Program IDs\n\n| Program  | ID                                             |\n| -------- | ---------------------------------------------- |\n| Pump     | `6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P` |\n| Pump AMM | `pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA` |\n\n## Environment Variables\n\n```env\nSOLANA_RPC_URL=https:\u002F\u002Frpc.solanatracker.io\u002Fpublic\nNEXT_PUBLIC_SOLANA_RPC_URL=https:\u002F\u002Frpc.solanatracker.io\u002Fpublic\n```\n\nThe default public mainnet RPC (`https:\u002F\u002Fapi.mainnet-beta.solana.com`) often **cannot send** transactions. Confirm an HTTPS RPC with the user. Examples: Solana Tracker public RPC, Ankr `https:\u002F\u002Frpc.ankr.com\u002Fsolana`.\n\n## Install\n\n**Inside this skill folder** (includes scripts):\n\n```bash\ncd {baseDir}\nnpm install\n```\n\n**Inside another app** (from scratch):\n\n```bash\nnpm install @pump-fun\u002Fpump-sdk @pump-fun\u002Fpump-swap-sdk @solana\u002Fweb3.js@^1.98.0 @solana\u002Fspl-token bn.js\n```\n\nCheck `npm info @pump-fun\u002Fpump-sdk dependencies` and align `@solana\u002Fweb3.js` \u002F `@solana\u002Fspl-token` versions to avoid duplicate incompatible copies.\n\n## SDK setup (minimal)\n\n```typescript\nimport { PUMP_SDK, OnlinePumpSdk } from \"@pump-fun\u002Fpump-sdk\";\nimport { PUMP_AMM_SDK, OnlinePumpAmmSdk } from \"@pump-fun\u002Fpump-swap-sdk\";\nimport { Connection } from \"@solana\u002Fweb3.js\";\n\nconst connection = new Connection(process.env.SOLANA_RPC_URL!);\nconst onlinePump = new OnlinePumpSdk(connection);\nconst onlineAmm = new OnlinePumpAmmSdk(connection);\n```\n\nFull transaction building (compute budget, blockhash, partial sign) is implemented in `scripts\u002Flib\u002Ftx-build.mjs` and `scripts\u002Flib\u002Fcompute.mjs`.\n\n## Determining coin state\n\nUse `node scripts\u002Ffetch-coin.mjs --mint \u003CMINT> --subset` or `GET`:\n\n`https:\u002F\u002Ffrontend-api-v3.pump.fun\u002Fcoins-v2\u002F{mint}`\n\n> **CORS-protected:** `frontend-api-v3.pump.fun` does not allow browser-origin requests. When building a web application, always call this endpoint from your backend\u002Fserver and proxy the result to the frontend. Do not call it directly from client-side JavaScript.\n\n```text\nif (!coin.complete) → bonding curve → PUMP_SDK buy\u002Fsell\nelse if (coin.pump_swap_pool) → AMM → PUMP_AMM_SDK (pool = pump_swap_pool)\nelse → migrating \u002F wait and retry\n```\n\n## Buy tokens (bonding curve)\n\n**Default:** `POST \u002Fagents\u002Fswap` with `inputMint` = NATIVE_MINT (see API section above)\n**Script (only when user explicitly requests):** `scripts\u002Fbuild-buy-bonding-tx.mjs`  \nRequires `complete === false`. Uses `OnlinePumpSdk`, `bondingCurvePda`, `getBuyTokenAmountFromSolAmount`, `getBuySolAmountFromTokenAmount`, `PUMP_SDK.buyInstructions`. `tokenProgram` is the mint account's owner from RPC (`getAccountInfo(mint).owner` — SPL Token or Token-2022).\n\nThe buy script performs a two-step quote matching the frontend `blockchainStore.getSwapTx`:\n1. `getBuyTokenAmountFromSolAmount(solInput)` — expected token amount\n2. `getBuySolAmountFromTokenAmount(tokenAmount)` — precise SOL cost (accounts for rounding)\n\n### Parameters (`buyInstructions`)\n\n| Parameter                   | Type                          | Description        |\n| --------------------------- | ----------------------------- | ------------------ |\n| `global`                    | `Global`                      | Global state       |\n| `bondingCurveAccountInfo`   | `AccountInfo\u003CBuffer>`         | Raw account        |\n| `bondingCurve`              | `BondingCurve`                | Decoded            |\n| `associatedUserAccountInfo` | `AccountInfo\u003CBuffer> \\| null` | User ATA           |\n| `mint` \u002F `user`             | `PublicKey`                   |                    |\n| `amount`                    | `BN`                          | Token out (6 dp)   |\n| `solAmount`                 | `BN`                          | SOL in (lamports)  |\n| `slippage`                  | `number`                      | **Percent** (below)|\n| `tokenProgram`              | `PublicKey`                   | e.g. Token-2022    |\n\n## Sell tokens (bonding curve)\n\n**Default:** `POST \u002Fagents\u002Fswap` with `outputMint` = NATIVE_MINT (see API section above)\n**Script (only when user explicitly requests):** `scripts\u002Fbuild-sell-bonding-tx.mjs`  \nUses `getSellSolAmountFromTokenAmount` and `PUMP_SDK.sellInstructions`. Same RPC-derived `tokenProgram` as the buy script.\n\n### Parameters (`sellInstructions`)\n\n| Parameter                 | Type                  | Description                                      |\n| ------------------------- | --------------------- | ------------------------------------------------ |\n| `global`                  | `Global`              | Global state                                     |\n| `bondingCurveAccountInfo` | `AccountInfo\u003CBuffer>` | Raw account                                      |\n| `bondingCurve`            | `BondingCurve`        | Decoded                                          |\n| `mint` \u002F `user`           | `PublicKey`           |                                                  |\n| `amount`                  | `BN`                  | Token to sell (6 dp)                             |\n| `solAmount`               | `BN`                  | Expected SOL out (lamports)                      |\n| `slippage`                | `number`              | **Percent** (below)                              |\n| `tokenProgram`            | `PublicKey`           | e.g. Token-2022                                  |\n| `mayhemMode`              | `boolean`             | Derived from `bondingCurve.isMayhemMode`         |\n| `cashback`                | `boolean`             | Derived from `bondingCurve.isCashbackCoin`       |\n\nThe sell script reads `mayhemMode` and `cashback` from the decoded on-chain bonding curve account automatically, matching the frontend `blockchainStore.getSwapTx` behavior. No flags needed.\n\n## Buy \u002F sell (AMM, post-graduation)\n\n**Default:** `POST \u002Fagents\u002Fswap` — the API automatically detects graduated coins and builds AMM transactions.\n**Script (only when user explicitly requests):** `scripts\u002Fbuild-buy-amm-tx.mjs`, `scripts\u002Fbuild-sell-amm-tx.mjs`  \nUses `OnlinePumpAmmSdk.swapSolanaState(pool, user)` and:\n\n- Buy: `PUMP_AMM_SDK.buyQuoteInput` (SOL in) or `PUMP_AMM_SDK.buyBaseInput` (token out)\n- Sell: `PUMP_AMM_SDK.sellBaseInput` (token in) or `PUMP_AMM_SDK.sellQuoteInput` (SOL out target)\n\n## Slippage\n\nThe pump bonding SDK takes slippage as a **percentage number** (e.g. `10` = 10%), **not** basis points. Same convention is used in the frontend `getSwapTx` path. The SDK applies it internally (e.g. max SOL cost scales with `floor(slippage * 10) \u002F 1000`).\n\n## Compute units and priority fees\n\nDefaults match the pump.fun app constants (see `scripts\u002Flib\u002Fconstants.mjs` in this skill):\n\n| Operation        | Default compute units |\n| ---------------- | --------------------- |\n| Bonding buy\u002Fsell | **120_000** each      |\n| AMM buy\u002Fsell     | **200_000**           |\n\nScripts accept `--compute-units` to override.\n\n**Priority fee:** If `--priority-micro-lamports` is omitted, scripts call Solana JSON-RPC `getPriorityFeeEstimate` on a draft serialized transaction (with a 100k microlamport floor and an upper cap — see `scripts\u002Flib\u002Fcompute.mjs`). Many RPCs support this; if not, the floor is used.\n\n## Transaction assembly and send\n\nAfter the user wallet signs, choose the send path based on whether `frontRunnerProtection` is `true` in the script output JSON.\n\n### Default (no front-runner protection)\n\n```typescript\nconst signature = await connection.sendRawTransaction(\n  signedTransaction.serialize(),\n  { skipPreflight: false, preflightCommitment: \"confirmed\" },\n);\nconst latestBlockhash = await connection.getLatestBlockhash(\"confirmed\");\nawait connection.confirmTransaction(\n  { signature, ...latestBlockhash },\n  \"confirmed\",\n);\n```\n\n### With front-runner protection (Jito only)\n\nWhen the transaction was built with `--front-runner-protection`, it already contains a Jito tip instruction. Send it **only** to Jito block engine endpoints — do **not** send via `connection.sendRawTransaction` or any other RPC, as that would leak the transaction to the public mempool and defeat the protection.\n\n```typescript\nimport { sendTransactionToJito } from \".\u002Flib\u002Fjito.mjs\";\n\nconst txBase64 = Buffer.from(signedTransaction.serialize()).toString(\"base64\");\nconst result = await sendTransactionToJito(txBase64);\n```\n\nOr manually via `fetch` (no dependency on the lib):\n\n```typescript\nconst JITO_ENDPOINTS = [\n  \"https:\u002F\u002Fmainnet.block-engine.jito.wtf\u002Fapi\u002Fv1\u002Ftransactions\",\n  \"https:\u002F\u002Famsterdam.mainnet.block-engine.jito.wtf\u002Fapi\u002Fv1\u002Ftransactions\",\n  \"https:\u002F\u002Ffrankfurt.mainnet.block-engine.jito.wtf\u002Fapi\u002Fv1\u002Ftransactions\",\n  \"https:\u002F\u002Fny.mainnet.block-engine.jito.wtf\u002Fapi\u002Fv1\u002Ftransactions\",\n  \"https:\u002F\u002Ftokyo.mainnet.block-engine.jito.wtf\u002Fapi\u002Fv1\u002Ftransactions\",\n];\n\nconst txBase64 = Buffer.from(signedTransaction.serialize()).toString(\"base64\");\nconst body = JSON.stringify({\n  jsonrpc: \"2.0\", id: 1, method: \"sendTransaction\",\n  params: [txBase64, { encoding: \"base64\" }],\n});\n\nawait Promise.any(\n  JITO_ENDPOINTS.map((url) =>\n    fetch(url, {\n      method: \"POST\",\n      headers: { \"Content-Type\": \"application\u002Fjson\" },\n      body,\n    }).then((r) => r.json()),\n  ),\n);\n```\n\nThen confirm as usual with `connection.confirmTransaction`.\n\n## Get balances\n\n**Script:** `scripts\u002Fprint-balances.mjs` (RPC + optional `--use-profile-api`).\n\n### SOL \u002F token (on-chain)\n\nUse `connection.getBalance` for lamports; `getAssociatedTokenAddressSync` + `getAccount` for the ATA (6 decimals for pump tokens).\n\n### Pump.fun HTTP APIs\n\n`GET https:\u002F\u002Fprofile-api.pump.fun\u002Fbalance\u002Fsummary\u002F{wallet}`\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"native_balance\": 1.5,\n    \"native_lamports\": 1500000000,\n    \"sol_price\": 145.23,\n    \"total_value\": 217.85\n  }\n}\n```\n\n`GET https:\u002F\u002Fprofile-api.pump.fun\u002Fbalance\u002Ftokens\u002F{wallet}?page=1&size=50`\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"tokens\": [\n      {\n        \"token_mint\": \"ABcDeFgHiJkLmNoPqRsTuVwXyZ123456789abcdefg\",\n        \"token_name\": \"MyToken\",\n        \"token_symbol\": \"MTK\",\n        \"token_image\": \"https:\u002F\u002Fipfs.io\u002Fipfs\u002FQm...\",\n        \"token_price\": 0.00123,\n        \"balance\": 5000000,\n        \"value\": 6.15,\n        \"usd_market_cap\": 50000\n      }\n    ]\n  },\n  \"pagination\": { \"page\": 1, \"size\": 50, \"total\": 3, \"totalPages\": 1 }\n}\n```\n\n`GET https:\u002F\u002Ffrontend-api-v3.pump.fun\u002Fsol-price`\n\n> **CORS-protected** — call from backend only (see note in \"Determining coin state\" above).\n\n```json\n{ \"solPrice\": 145.23 }\n```\n\n## Get coin data (HTTP)\n\n`GET https:\u002F\u002Ffrontend-api-v3.pump.fun\u002Fcoins-v2\u002F{mint}`\n\n> **CORS-protected** — call from backend only (see note in \"Determining coin state\" above).\n\n```json\n{\n  \"mint\": \"ABcDeFgHiJkLmNoPqRsTuVwXyZ123456789abcdefg\",\n  \"name\": \"MyToken\",\n  \"symbol\": \"MTK\",\n  \"description\": \"A sample token on pump.fun\",\n  \"image_uri\": \"https:\u002F\u002Fipfs.io\u002Fipfs\u002FQm...\",\n  \"metadata_uri\": \"https:\u002F\u002Fipfs.io\u002Fipfs\u002FQm...\",\n  \"creator\": \"CreatorWalletAddress...\",\n  \"created_timestamp\": 1700000000,\n  \"complete\": false,\n  \"bonding_curve\": \"BondingCurveAddress...\",\n  \"associated_bonding_curve\": \"AssociatedBondingCurveAddress...\",\n  \"pump_swap_pool\": null,\n  \"token_program\": \"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb\",\n  \"market_cap\": 25000000000,\n  \"usd_market_cap\": 50000,\n  \"virtual_sol_reserves\": \"30000000000\",\n  \"virtual_token_reserves\": \"1073000000000000\",\n  \"total_supply\": \"1000000000000000\",\n  \"raydium_pool\": \"\",\n  \"program\": \"pump\",\n  \"reply_count\": 42,\n  \"last_trade_timestamp\": 1700086400\n}\n```\n\n| Field                    | Notes                                      |\n| ------------------------ | ------------------------------------------ |\n| `complete`               | `true` when graduated off bonding curve    |\n| `pump_swap_pool`         | AMM pool address when on pump swap         |\n| `bonding_curve`          | Bonding curve PDA address                  |\n| `token_program`          | **Do NOT trust this value** — always verify on-chain (see below) |\n\n> **NEVER trust `token_program` from the HTTP API.** The `coins-v2` endpoint may return a stale or incorrect `token_program`. Always resolve it on-chain by fetching the mint account and reading its owner:\n>\n> ```typescript\n> const mintAccountInfo = await connection.getAccountInfo(mintPublicKey);\n> const tokenProgram = mintAccountInfo.owner; \u002F\u002F TOKEN_PROGRAM_ID or TOKEN_2022_PROGRAM_ID\n> ```\n>\n> The skill scripts already do this via `tokenProgramIdFromMint()` in `scripts\u002Flib\u002Fcoin-resolve.mjs`. Any custom integration **must** do the same.\n\n## Quote helpers (bonding curve)\n\nPure functions from `@pump-fun\u002Fpump-sdk` (see script source for usage):\n\n- `getBuyTokenAmountFromSolAmount`\n- `getBuySolAmountFromTokenAmount`\n- `getSellSolAmountFromTokenAmount`\n\nAll need `global`, `feeConfig` (`fetchFeeConfig()`), `mintSupply`, and `bondingCurve`.\n\n## Error handling and troubleshooting\n\n- **`complete === true` but `pump_swap_pool` is null** — migration window; retry later; do not use bonding instructions.\n- **Bonding curve account missing** — wrong mint, wrong network, or uninitialized coin.\n- **`Coin has graduated` \u002F AMM script errors on bonding-only coin** — re-fetch `coins-v2` and switch script path.\n- **Insufficient SOL** — user cannot pay buy amount or fees; check `nativeLamports` before building.\n- **Slippage \u002F simulation failures** — increase slippage cautiously, check pool reserves, retry with fresh blockhash (re-run script).\n- **ATA missing** — first buy may create ATA inside the same tx; if a custom flow fails, ensure ATA creation is included or pre-created.\n- **RPC errors** — rate limits, missing `getPriorityFeeEstimate`, or send blocked; try another RPC; pass `--priority-micro-lamports` explicitly.\n\n## End-to-end flow\n\n1. Confirm operation (buy or sell), mint address, and signer wallet; set `SOLANA_RPC_URL`. Ask if front-runner protection is desired.\n2. Use `POST \u002Fagents\u002Fswap` — the API automatically determines coin state and builds the correct transaction. Only use scripts if the user explicitly requests them: `fetch-coin` (or HTTP) → check coin state (see decision tree) → choose bonding or AMM script → run the appropriate `build-*` script; capture `transaction`. Add `--front-runner-protection` (and optionally `--tip-sol`) if the user wants Jito-only submission.\n3. Deserialize with `@solana\u002Fweb3.js` `VersionedTransaction.deserialize`, have user sign.\n4. **Send the transaction:** If `frontRunnerProtection` is `true` in the script output JSON, send **only** to Jito endpoints (see \"Transaction assembly and send\" above). Otherwise use `sendRawTransaction` + `confirmTransaction`.\n","# Before Starting Work **Critical** - Ask these from user\n\n**MANDATORY — Do NOT write or modify any code until every item below is answered by the user:**\n\n- [ ] RPC URL provided or a fallback agreed upon (for any on-chain or tx-building step)\n- [ ] **Signer wallet** public key (fee payer \u002F user)\n- [ ] Framework confirmed (Next.js, Express, CLI scripts only, other)\n- [ ] Operation type confirmed (buy or sell)\n- [ ] Coin mint address provided\n- [ ] Amount confirmed (SOL lamports for buy; token smallest units for sell)\n- [ ] Front-runner protection desired? If yes, confirm tip amount (default 0.0001 SOL). Transactions will be sent **only** to Jito block engine endpoints.\n\nYou 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.\n\n## API (preferred) — `https:\u002F\u002Ffun-block.pump.fun`\n\nUse 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.\n\n### `POST \u002Fagents\u002Fswap`\n\nBuilds a buy or sell transaction. Set `inputMint` to `So11111111111111111111111111111111111111112` (NATIVE_MINT) for buys, or set `outputMint` to NATIVE_MINT for sells.\n\n**Request body:**\n\n```json\n{\n  \"inputMint\": \"So11111111111111111111111111111111111111112\",\n  \"outputMint\": \"\u003CTOKEN_MINT>\",\n  \"amount\": \"1000000\",\n  \"user\": \"\u003CPUBKEY>\",\n  \"slippagePct\": 2,\n  \"feePayer\": \"\u003CPUBKEY>\",\n  \"frontRunningProtection\": false,\n  \"tipAmount\": 0,\n  \"encoding\": \"base64\"\n}\n```\n\nOnly `inputMint`, `outputMint`, `amount`, and `user` are required. All other fields have defaults.\n\n> **`tipAmount`** is a Jito tip in **SOL** (e.g. `0.0001` for 100,000 lamports). Only relevant when `frontRunningProtection` is `true`.\n\n> **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` \u002F `simulateTransaction` RPC calls — never rely on the RPC's default.\n\n- **Buy:** `inputMint` = NATIVE_MINT, `outputMint` = token mint, `amount` = SOL in lamports\n- **Sell:** `inputMint` = token mint, `outputMint` = NATIVE_MINT, `amount` = token amount (6 decimals)\n\n**Response:**\n\n```json\n{\n  \"transaction\": \"\u003Cbase64-encoded VersionedTransaction>\",\n  \"pumpMintInfo\": { \"hasGraduated\": false, \"expectedOutAmount\": \"123456\", \"...\" : \"...\" }\n}\n```\n\nDeserialize the `transaction`, have the user wallet sign, and submit to chain.\n\n## Runnable examples (Node scripts — only when user explicitly requests)\n\nUse **`{baseDir}`** as the path to this skill folder (OpenClaw and Agent Skills clients often expose this placeholder).\n\n```bash\ncd {baseDir}\nnpm install\nexport SOLANA_RPC_URL=https:\u002F\u002Frpc.solanatracker.io\u002Fpublic\n```\n\n| Operation | Script | Example |\n| --------- | ------ | ------- |\n| Fetch coin state (HTTP) | `scripts\u002Ffetch-coin.mjs` | `node scripts\u002Ffetch-coin.mjs --mint \u003CMINT> --subset` |\n| Buy (bonding curve) | `scripts\u002Fbuild-buy-bonding-tx.mjs` | `node scripts\u002Fbuild-buy-bonding-tx.mjs --mint \u003CMINT> --user \u003CPUBKEY> --amount 1000000` |\n| Sell (bonding curve) | `scripts\u002Fbuild-sell-bonding-tx.mjs` | `node scripts\u002Fbuild-sell-bonding-tx.mjs --mint \u003CMINT> --user \u003CPUBKEY> --amount 1000000` |\n| Buy (AMM) | `scripts\u002Fbuild-buy-amm-tx.mjs` | `node scripts\u002Fbuild-buy-amm-tx.mjs --mint \u003CMINT> --user \u003CPUBKEY> --amount 1000000` |\n| Sell (AMM) | `scripts\u002Fbuild-sell-amm-tx.mjs` | `node scripts\u002Fbuild-sell-amm-tx.mjs --mint \u003CMINT> --user \u003CPUBKEY> --amount 1000000` |\n| Balances | `scripts\u002Fprint-balances.mjs` | `node scripts\u002Fprint-balances.mjs --wallet \u003CPUBKEY> --mint \u003CMINT>` |\n\n- 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.).\n- Tx builders print **one JSON object** on stdout with `transaction` (base64-encoded VersionedTransaction). **Never** pass end-user private keys into these scripts.\n- **OpenClaw:** If YAML `metadata` ever fails to parse, collapse `metadata` to a single-line JSON object per [OpenClaw skills](https:\u002F\u002Fdocs.openclaw.ai\u002Fskills\u002F); optional `metadata.openclaw.requires.env: [\"SOLANA_RPC_URL\"]` can gate load-time eligibility.\n\n## Safety Rules\n\n- **NEVER** log, print, or return private keys or secret key material.\n- **NEVER** sign transactions on behalf of a user — scripts build txs; the user (or their wallet) co-signs and sends.\n- Always validate that amounts are `> 0` before building instructions.\n- Use the correct decimal precision: **9 decimals for SOL** (1 SOL = 1,000,000,000 lamports), **6 decimals for pump tokens**.\n- Always check the coin state (bonding curve vs AMM pool) before choosing the right path.\n- Always apply slippage protection on buy\u002Fsell transactions.\n- **NEVER trust `token_program` from the HTTP API** (`coins-v2`). Always fetch the mint account on-chain via `connection.getAccountInfo(mint)` and use `.owner` to determine the correct token program (SPL Token or Token-2022).\n- **Verify imports:** use `@pump-fun\u002Fpump-sdk` \u002F `@pump-fun\u002Fpump-swap-sdk` (not internal monorepo paths). In TypeScript apps, `BN` from `bn.js` matches what the SDKs expect (Anchor `BN` is the same type in practice).\n\n## Program IDs\n\n| Program  | ID                                             |\n| -------- | ---------------------------------------------- |\n| Pump     | `6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P` |\n| Pump AMM | `pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA` |\n\n## Environment Variables\n\n```env\nSOLANA_RPC_URL=https:\u002F\u002Frpc.solanatracker.io\u002Fpublic\nNEXT_PUBLIC_SOLANA_RPC_URL=https:\u002F\u002Frpc.solanatracker.io\u002Fpublic\n```\n\nThe default public mainnet RPC (`https:\u002F\u002Fapi.mainnet-beta.solana.com`) often **cannot send** transactions. Confirm an HTTPS RPC with the user. Examples: Solana Tracker public RPC, Ankr `https:\u002F\u002Frpc.ankr.com\u002Fsolana`.\n\n## Install\n\n**Inside this skill folder** (includes scripts):\n\n```bash\ncd {baseDir}\nnpm install\n```\n\n**Inside another app** (from scratch):\n\n```bash\nnpm install @pump-fun\u002Fpump-sdk @pump-fun\u002Fpump-swap-sdk @solana\u002Fweb3.js@^1.98.0 @solana\u002Fspl-token bn.js\n```\n\nCheck `npm info @pump-fun\u002Fpump-sdk dependencies` and align `@solana\u002Fweb3.js` \u002F `@solana\u002Fspl-token` versions to avoid duplicate incompatible copies.\n\n## SDK setup (minimal)\n\n```typescript\nimport { PUMP_SDK, OnlinePumpSdk } from \"@pump-fun\u002Fpump-sdk\";\nimport { PUMP_AMM_SDK, OnlinePumpAmmSdk } from \"@pump-fun\u002Fpump-swap-sdk\";\nimport { Connection } from \"@solana\u002Fweb3.js\";\n\nconst connection = new Connection(process.env.SOLANA_RPC_URL!);\nconst onlinePump = new OnlinePumpSdk(connection);\nconst onlineAmm = new OnlinePumpAmmSdk(connection);\n```\n\nFull transaction building (compute budget, blockhash, partial sign) is implemented in `scripts\u002Flib\u002Ftx-build.mjs` and `scripts\u002Flib\u002Fcompute.mjs`.\n\n## Determining coin state\n\nUse `node scripts\u002Ffetch-coin.mjs --mint \u003CMINT> --subset` or `GET`:\n\n`https:\u002F\u002Ffrontend-api-v3.pump.fun\u002Fcoins-v2\u002F{mint}`\n\n> **CORS-protected:** `frontend-api-v3.pump.fun` does not allow browser-origin requests. When building a web application, always call this endpoint from your backend\u002Fserver and proxy the result to the frontend. Do not call it directly from client-side JavaScript.\n\n```text\nif (!coin.complete) → bonding curve → PUMP_SDK buy\u002Fsell\nelse if (coin.pump_swap_pool) → AMM → PUMP_AMM_SDK (pool = pump_swap_pool)\nelse → migrating \u002F wait and retry\n```\n\n## Buy tokens (bonding curve)\n\n**Default:** `POST \u002Fagents\u002Fswap` with `inputMint` = NATIVE_MINT (see API section above)\n**Script (only when user explicitly requests):** `scripts\u002Fbuild-buy-bonding-tx.mjs`  \nRequires `complete === false`. Uses `OnlinePumpSdk`, `bondingCurvePda`, `getBuyTokenAmountFromSolAmount`, `getBuySolAmountFromTokenAmount`, `PUMP_SDK.buyInstructions`. `tokenProgram` is the mint account's owner from RPC (`getAccountInfo(mint).owner` — SPL Token or Token-2022).\n\nThe buy script performs a two-step quote matching the frontend `blockchainStore.getSwapTx`:\n1. `getBuyTokenAmountFromSolAmount(solInput)` — expected token amount\n2. `getBuySolAmountFromTokenAmount(tokenAmount)` — precise SOL cost (accounts for rounding)\n\n### Parameters (`buyInstructions`)\n\n| Parameter                   | Type                          | Description        |\n| --------------------------- | ----------------------------- | ------------------ |\n| `global`                    | `Global`                      | Global state       |\n| `bondingCurveAccountInfo`   | `AccountInfo\u003CBuffer>`         | Raw account        |\n| `bondingCurve`              | `BondingCurve`                | Decoded            |\n| `associatedUserAccountInfo` | `AccountInfo\u003CBuffer> \\| null` | User ATA           |\n| `mint` \u002F `user`             | `PublicKey`                   |                    |\n| `amount`                    | `BN`                          | Token out (6 dp)   |\n| `solAmount`                 | `BN`                          | SOL in (lamports)  |\n| `slippage`                  | `number`                      | **Percent** (below)|\n| `tokenProgram`              | `PublicKey`                   | e.g. Token-2022    |\n\n## Sell tokens (bonding curve)\n\n**Default:** `POST \u002Fagents\u002Fswap` with `outputMint` = NATIVE_MINT (see API section above)\n**Script (only when user explicitly requests):** `scripts\u002Fbuild-sell-bonding-tx.mjs`  \nUses `getSellSolAmountFromTokenAmount` and `PUMP_SDK.sellInstructions`. Same RPC-derived `tokenProgram` as the buy script.\n\n### Parameters (`sellInstructions`)\n\n| Parameter                 | Type                  | Description                                      |\n| ------------------------- | --------------------- | ------------------------------------------------ |\n| `global`                  | `Global`              | Global state                                     |\n| `bondingCurveAccountInfo` | `AccountInfo\u003CBuffer>` | Raw account                                      |\n| `bondingCurve`            | `BondingCurve`        | Decoded                                          |\n| `mint` \u002F `user`           | `PublicKey`           |                                                  |\n| `amount`                  | `BN`                  | Token to sell (6 dp)                             |\n| `solAmount`               | `BN`                  | Expected SOL out (lamports)                      |\n| `slippage`                | `number`              | **Percent** (below)                              |\n| `tokenProgram`            | `PublicKey`           | e.g. Token-2022                                  |\n| `mayhemMode`              | `boolean`             | Derived from `bondingCurve.isMayhemMode`         |\n| `cashback`                | `boolean`             | Derived from `bondingCurve.isCashbackCoin`       |\n\nThe sell script reads `mayhemMode` and `cashback` from the decoded on-chain bonding curve account automatically, matching the frontend `blockchainStore.getSwapTx` behavior. No flags needed.\n\n## Buy \u002F sell (AMM, post-graduation)\n\n**Default:** `POST \u002Fagents\u002Fswap` — the API automatically detects graduated coins and builds AMM transactions.\n**Script (only when user explicitly requests):** `scripts\u002Fbuild-buy-amm-tx.mjs`, `scripts\u002Fbuild-sell-amm-tx.mjs`  \nUses `OnlinePumpAmmSdk.swapSolanaState(pool, user)` and:\n\n- Buy: `PUMP_AMM_SDK.buyQuoteInput` (SOL in) or `PUMP_AMM_SDK.buyBaseInput` (token out)\n- Sell: `PUMP_AMM_SDK.sellBaseInput` (token in) or `PUMP_AMM_SDK.sellQuoteInput` (SOL out target)\n\n## Slippage\n\nThe pump bonding SDK takes slippage as a **percentage number** (e.g. `10` = 10%), **not** basis points. Same convention is used in the frontend `getSwapTx` path. The SDK applies it internally (e.g. max SOL cost scales with `floor(slippage * 10) \u002F 1000`).\n\n## Compute units and priority fees\n\nDefaults match the pump.fun app constants (see `scripts\u002Flib\u002Fconstants.mjs` in this skill):\n\n| Operation        | Default compute units |\n| ---------------- | --------------------- |\n| Bonding buy\u002Fsell | **120_000** each      |\n| AMM buy\u002Fsell     | **200_000**           |\n\nScripts accept `--compute-units` to override.\n\n**Priority fee:** If `--priority-micro-lamports` is omitted, scripts call Solana JSON-RPC `getPriorityFeeEstimate` on a draft serialized transaction (with a 100k microlamport floor and an upper cap — see `scripts\u002Flib\u002Fcompute.mjs`). Many RPCs support this; if not, the floor is used.\n\n## Transaction assembly and send\n\nAfter the user wallet signs, choose the send path based on whether `frontRunnerProtection` is `true` in the script output JSON.\n\n### Default (no front-runner protection)\n\n```typescript\nconst signature = await connection.sendRawTransaction(\n  signedTransaction.serialize(),\n  { skipPreflight: false, preflightCommitment: \"confirmed\" },\n);\nconst latestBlockhash = await connection.getLatestBlockhash(\"confirmed\");\nawait connection.confirmTransaction(\n  { signature, ...latestBlockhash },\n  \"confirmed\",\n);\n```\n\n### With front-runner protection (Jito only)\n\nWhen the transaction was built with `--front-runner-protection`, it already contains a Jito tip instruction. Send it **only** to Jito block engine endpoints — do **not** send via `connection.sendRawTransaction` or any other RPC, as that would leak the transaction to the public mempool and defeat the protection.\n\n```typescript\nimport { sendTransactionToJito } from \".\u002Flib\u002Fjito.mjs\";\n\nconst txBase64 = Buffer.from(signedTransaction.serialize()).toString(\"base64\");\nconst result = await sendTransactionToJito(txBase64);\n```\n\nOr manually via `fetch` (no dependency on the lib):\n\n```typescript\nconst JITO_ENDPOINTS = [\n  \"https:\u002F\u002Fmainnet.block-engine.jito.wtf\u002Fapi\u002Fv1\u002Ftransactions\",\n  \"https:\u002F\u002Famsterdam.mainnet.block-engine.jito.wtf\u002Fapi\u002Fv1\u002Ftransactions\",\n  \"https:\u002F\u002Ffrankfurt.mainnet.block-engine.jito.wtf\u002Fapi\u002Fv1\u002Ftransactions\",\n  \"https:\u002F\u002Fny.mainnet.block-engine.jito.wtf\u002Fapi\u002Fv1\u002Ftransactions\",\n  \"https:\u002F\u002Ftokyo.mainnet.block-engine.jito.wtf\u002Fapi\u002Fv1\u002Ftransactions\",\n];\n\nconst txBase64 = Buffer.from(signedTransaction.serialize()).toString(\"base64\");\nconst body = JSON.stringify({\n  jsonrpc: \"2.0\", id: 1, method: \"sendTransaction\",\n  params: [txBase64, { encoding: \"base64\" }],\n});\n\nawait Promise.any(\n  JITO_ENDPOINTS.map((url) =>\n    fetch(url, {\n      method: \"POST\",\n      headers: { \"Content-Type\": \"application\u002Fjson\" },\n      body,\n    }).then((r) => r.json()),\n  ),\n);\n```\n\nThen confirm as usual with `connection.confirmTransaction`.\n\n## Get balances\n\n**Script:** `scripts\u002Fprint-balances.mjs` (RPC + optional `--use-profile-api`).\n\n### SOL \u002F token (on-chain)\n\nUse `connection.getBalance` for lamports; `getAssociatedTokenAddressSync` + `getAccount` for the ATA (6 decimals for pump tokens).\n\n### Pump.fun HTTP APIs\n\n`GET https:\u002F\u002Fprofile-api.pump.fun\u002Fbalance\u002Fsummary\u002F{wallet}`\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"native_balance\": 1.5,\n    \"native_lamports\": 1500000000,\n    \"sol_price\": 145.23,\n    \"total_value\": 217.85\n  }\n}\n```\n\n`GET https:\u002F\u002Fprofile-api.pump.fun\u002Fbalance\u002Ftokens\u002F{wallet}?page=1&size=50`\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"tokens\": [\n      {\n        \"token_mint\": \"ABcDeFgHiJkLmNoPqRsTuVwXyZ123456789abcdefg\",\n        \"token_name\": \"MyToken\",\n        \"token_symbol\": \"MTK\",\n        \"token_image\": \"https:\u002F\u002Fipfs.io\u002Fipfs\u002FQm...\",\n        \"token_price\": 0.00123,\n        \"balance\": 5000000,\n        \"value\": 6.15,\n        \"usd_market_cap\": 50000\n      }\n    ]\n  },\n  \"pagination\": { \"page\": 1, \"size\": 50, \"total\": 3, \"totalPages\": 1 }\n}\n```\n\n`GET https:\u002F\u002Ffrontend-api-v3.pump.fun\u002Fsol-price`\n\n> **CORS-protected** — call from backend only (see note in \"Determining coin state\" above).\n\n```json\n{ \"solPrice\": 145.23 }\n```\n\n## Get coin data (HTTP)\n\n`GET https:\u002F\u002Ffrontend-api-v3.pump.fun\u002Fcoins-v2\u002F{mint}`\n\n> **CORS-protected** — call from backend only (see note in \"Determining coin state\" above).\n\n```json\n{\n  \"mint\": \"ABcDeFgHiJkLmNoPqRsTuVwXyZ123456789abcdefg\",\n  \"name\": \"MyToken\",\n  \"symbol\": \"MTK\",\n  \"description\": \"A sample token on pump.fun\",\n  \"image_uri\": \"https:\u002F\u002Fipfs.io\u002Fipfs\u002FQm...\",\n  \"metadata_uri\": \"https:\u002F\u002Fipfs.io\u002Fipfs\u002FQm...\",\n  \"creator\": \"CreatorWalletAddress...\",\n  \"created_timestamp\": 1700000000,\n  \"complete\": false,\n  \"bonding_curve\": \"BondingCurveAddress...\",\n  \"associated_bonding_curve\": \"AssociatedBondingCurveAddress...\",\n  \"pump_swap_pool\": null,\n  \"token_program\": \"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb\",\n  \"market_cap\": 25000000000,\n  \"usd_market_cap\": 50000,\n  \"virtual_sol_reserves\": \"30000000000\",\n  \"virtual_token_reserves\": \"1073000000000000\",\n  \"total_supply\": \"1000000000000000\",\n  \"raydium_pool\": \"\",\n  \"program\": \"pump\",\n  \"reply_count\": 42,\n  \"last_trade_timestamp\": 1700086400\n}\n```\n\n| Field                    | Notes                                      |\n| ------------------------ | ------------------------------------------ |\n| `complete`               | `true` when graduated off bonding curve    |\n| `pump_swap_pool`         | AMM pool address when on pump swap         |\n| `bonding_curve`          | Bonding curve PDA address                  |\n| `token_program`          | **Do NOT trust this value** — always verify on-chain (see below) |\n\n> **NEVER trust `token_program` from the HTTP API.** The `coins-v2` endpoint may return a stale or incorrect `token_program`. Always resolve it on-chain by fetching the mint account and reading its owner:\n>\n> ```typescript\n> const mintAccountInfo = await connection.getAccountInfo(mintPublicKey);\n> const tokenProgram = mintAccountInfo.owner; \u002F\u002F TOKEN_PROGRAM_ID or TOKEN_2022_PROGRAM_ID\n> ```\n>\n> The skill scripts already do this via `tokenProgramIdFromMint()` in `scripts\u002Flib\u002Fcoin-resolve.mjs`. Any custom integration **must** do the same.\n\n## Quote helpers (bonding curve)\n\nPure functions from `@pump-fun\u002Fpump-sdk` (see script source for usage):\n\n- `getBuyTokenAmountFromSolAmount`\n- `getBuySolAmountFromTokenAmount`\n- `getSellSolAmountFromTokenAmount`\n\nAll need `global`, `feeConfig` (`fetchFeeConfig()`), `mintSupply`, and `bondingCurve`.\n\n## Error handling and troubleshooting\n\n- **`complete === true` but `pump_swap_pool` is null** — migration window; retry later; do not use bonding instructions.\n- **Bonding curve account missing** — wrong mint, wrong network, or uninitialized coin.\n- **`Coin has graduated` \u002F AMM script errors on bonding-only coin** — re-fetch `coins-v2` and switch script path.\n- **Insufficient SOL** — user cannot pay buy amount or fees; check `nativeLamports` before building.\n- **Slippage \u002F simulation failures** — increase slippage cautiously, check pool reserves, retry with fresh blockhash (re-run script).\n- **ATA missing** — first buy may create ATA inside the same tx; if a custom flow fails, ensure ATA creation is included or pre-created.\n- **RPC errors** — rate limits, missing `getPriorityFeeEstimate`, or send blocked; try another RPC; pass `--priority-micro-lamports` explicitly.\n\n## End-to-end flow\n\n1. Confirm operation (buy or sell), mint address, and signer wallet; set `SOLANA_RPC_URL`. Ask if front-runner protection is desired.\n2. Use `POST \u002Fagents\u002Fswap` — the API automatically determines coin state and builds the correct transaction. Only use scripts if the user explicitly requests them: `fetch-coin` (or HTTP) → check coin state (see decision tree) → choose bonding or AMM script → run the appropriate `build-*` script; capture `transaction`. Add `--front-runner-protection` (and optionally `--tip-sol`) if the user wants Jito-only submission.\n3. Deserialize with `@solana\u002Fweb3.js` `VersionedTransaction.deserialize`, have user sign.\n4. **Send the transaction:** If `frontRunnerProtection` is `true` in the script output JSON, send **only** to Jito endpoints (see \"Transaction assembly and send\" above). Otherwise use `sendRawTransaction` + `confirmTransaction`.\n",{"name":5,"metadata":45,"description":47},{"author":29,"version":46},"1.0","Buy and sell tokens on pump.fun bonding curve and pump swap AMM pool, and query SOL\u002Ftoken balances. Prefer runnable Node scripts in this skill folder; use @pump-fun\u002Fpump-sdk and @pump-fun\u002Fpump-swap-sdk for custom integrations.\n","main","3df1d0d67b30ff15236561f8c0f9f06d33f42dfd","skills\u002Fdefi\u002Fpumpfun-official-swap",17,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia","https:\u002F\u002Feth2030.com","Hardcore infra. Building @alt-research and applied cryptography.","2026-11-15 02:28:10",{"source":8,"skillName":5,"commands":58,"prompt":68,"zipAvailable":69},[59,62,65],{"tool":60,"command":61},"npx","npx skills add jiayaoqijia\u002Fcryptoskill --skill swap",{"tool":63,"command":64},"bunx","bunx skills add jiayaoqijia\u002Fcryptoskill --skill swap",{"tool":66,"command":67},"pnpm","pnpm dlx skills add jiayaoqijia\u002Fcryptoskill --skill swap","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002FSKILL.md",true,[71,77,83,87,91,97,101,105,109,113,117,121,125,129,133,137,141,145,149,153],{"path":72,"resourceType":73,"resourceTypeDesc":74,"sizeBytes":75,"sourceHtmlUrl":76},".gitignore","OTHER","其他",14,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002F.gitignore",{"path":78,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":81,"sourceHtmlUrl":82},"package.json","REFERENCE","参考文档",853,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002Fpackage.json",{"path":84,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":85,"sourceHtmlUrl":86},"pnpm-lock.yaml",28901,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002Fpnpm-lock.yaml",{"path":88,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":89,"sourceHtmlUrl":90},"pnpm-workspace.yaml",696,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002Fpnpm-workspace.yaml",{"path":92,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":95,"sourceHtmlUrl":96},"scripts\u002Fbuild-buy-amm-tx.mjs","SCRIPT","脚本",5294,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002Fscripts\u002Fbuild-buy-amm-tx.mjs",{"path":98,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":99,"sourceHtmlUrl":100},"scripts\u002Fbuild-buy-bonding-tx.mjs",5458,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002Fscripts\u002Fbuild-buy-bonding-tx.mjs",{"path":102,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":103,"sourceHtmlUrl":104},"scripts\u002Fbuild-sell-amm-tx.mjs",5272,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002Fscripts\u002Fbuild-sell-amm-tx.mjs",{"path":106,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":107,"sourceHtmlUrl":108},"scripts\u002Fbuild-sell-bonding-tx.mjs",4880,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002Fscripts\u002Fbuild-sell-bonding-tx.mjs",{"path":110,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":111,"sourceHtmlUrl":112},"scripts\u002Ffetch-coin.mjs",1408,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002Fscripts\u002Ffetch-coin.mjs",{"path":114,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":115,"sourceHtmlUrl":116},"scripts\u002Flib\u002Fargs.mjs",1809,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002Fscripts\u002Flib\u002Fargs.mjs",{"path":118,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":119,"sourceHtmlUrl":120},"scripts\u002Flib\u002Fcoin-api.mjs",1114,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002Fscripts\u002Flib\u002Fcoin-api.mjs",{"path":122,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":123,"sourceHtmlUrl":124},"scripts\u002Flib\u002Fcoin-resolve.mjs",1392,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002Fscripts\u002Flib\u002Fcoin-resolve.mjs",{"path":126,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":127,"sourceHtmlUrl":128},"scripts\u002Flib\u002Fcompute.mjs",2403,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002Fscripts\u002Flib\u002Fcompute.mjs",{"path":130,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":131,"sourceHtmlUrl":132},"scripts\u002Flib\u002Fconstants.mjs",567,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002Fscripts\u002Flib\u002Fconstants.mjs",{"path":134,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":135,"sourceHtmlUrl":136},"scripts\u002Flib\u002Fenv.mjs",510,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002Fscripts\u002Flib\u002Fenv.mjs",{"path":138,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":139,"sourceHtmlUrl":140},"scripts\u002Flib\u002Fjito.mjs",2880,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002Fscripts\u002Flib\u002Fjito.mjs",{"path":142,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":143,"sourceHtmlUrl":144},"scripts\u002Flib\u002Ftx-build.mjs",2332,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002Fscripts\u002Flib\u002Ftx-build.mjs",{"path":146,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":147,"sourceHtmlUrl":148},"scripts\u002Fprint-balances.mjs",3318,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002Fscripts\u002Fprint-balances.mjs",{"path":150,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":151,"sourceHtmlUrl":152},"SOURCE.md",407,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002FSOURCE.md",{"path":154,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":155,"sourceHtmlUrl":156},"TRUST.auto.yaml",2202,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fdefi\u002Fpumpfun-official-swap\u002FTRUST.auto.yaml",[158,187,209,227,240,250],{"skillNo":159,"name":160,"nameZh":6,"description":161,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":162,"licenseFileUrl":163,"sourceHtmlUrl":164,"categories":165,"keywords":166,"publishedAt":40},"01M712C436EQYE43342Q4E7GG1","recipe-performance","Diagnose a specific MetaMask user flow's real-app performance and Sentry critical-user-flow telemetry with deterministic mm-harness recipes. Use for CUF boundaries, cold\u002Fwarm\u002Fbackground-resume behavior, latency regressions, lifecycle tags, duplicate or blocking network requests, long tasks, layout\u002Fpaint cost, screen redraws, React rerenders, or browser trace analysis where tests alone cannot prove the real app.","MIT","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fwallets\u002Fmetamask-official-recipe-performance\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fwallets\u002Fmetamask-official-recipe-performance\u002FSKILL.md",[],[167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186],"performance","recipe performance","recipe","mm","sentry","harness","app","deterministic","recipes","flow","cold","critical","analysis","tasks","react","browser","layout","screen","network","metamask",{"skillNo":188,"name":189,"nameZh":6,"description":190,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":191,"licenseFileUrl":192,"sourceHtmlUrl":193,"categories":194,"keywords":195,"publishedAt":40},"01M70XT2F8A5CQZ81JBP98KSW3","mexc-spot-websocket","MEXC Spot WebSocket workflows for public streams, protobuf handling, depth maintenance, listen keys, and private streams without exposing API keys.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fexchanges\u002Fmncrftfrcnm-mexc-spot-websocket\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fexchanges\u002Fmncrftfrcnm-mexc-spot-websocket\u002FSKILL.md",[],[196,197,198,199,200,201,202,203,204,205,22,206,207,208],"mexc spot websocket","spot","websocket","api","workflows","public","listen","streams","depth","keys","api keys","maintenance","protobuf",{"skillNo":210,"name":211,"nameZh":6,"description":212,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":191,"licenseFileUrl":213,"sourceHtmlUrl":214,"categories":215,"keywords":216,"publishedAt":40},"01M70XT0MBXN3WZY1BKN0CPNKR","mexc-spot-rest","MEXC Spot REST workflows for public data, signed account requests, orders, wallet\u002Fadmin actions, and secure signing without exposing API keys.","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fexchanges\u002Fmncrftfrcnm-mexc-spot-rest\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fexchanges\u002Fmncrftfrcnm-mexc-spot-rest\u002FSKILL.md",[],[217,197,218,219,220,221,222,206,22,205,223,224,225,201,226,200,199],"mexc spot rest","REST","admin","signing","Wallet","requests","actions","secure","data","orders",{"skillNo":228,"name":229,"nameZh":6,"description":230,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":191,"licenseFileUrl":231,"sourceHtmlUrl":232,"categories":233,"keywords":234,"publishedAt":40},"01M70XSYSVZ2N0N91XCAR2CAK0","mexc-futures-websocket","MEXC Futures WebSocket workflows for public streams, private account\u002Forder\u002Fposition streams, ping\u002Fpong, subscriptions, and depth maintenance.","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fexchanges\u002Fmncrftfrcnm-mexc-futures-websocket\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fexchanges\u002Fmncrftfrcnm-mexc-futures-websocket\u002FSKILL.md",[],[235,236,198,237,238,207,22,239,204,203,201,200],"mexc futures websocket","futures","position","ping","subscriptions",{"skillNo":241,"name":242,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":162,"licenseFileUrl":243,"sourceHtmlUrl":244,"categories":245,"keywords":246,"publishedAt":40},"01M6H0ZWHVE5W04WG2DKQE2SQC","0xklen-version-and-refresh-sanctions-lists","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fpayments\u002F0xklen-version-and-refresh-sanctions-lists\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fpayments\u002F0xklen-version-and-refresh-sanctions-lists\u002FSKILL.md",[],[247,248,249],"refresh","0xklen version and refresh sanctions lists","version",{"skillNo":251,"name":252,"nameZh":6,"description":253,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":162,"licenseFileUrl":254,"sourceHtmlUrl":255,"categories":256,"keywords":257,"publishedAt":40},"01M6H0Z28Q3R8J0S799GJQWXM3","verify-tests-cover-changed-lines","Use when a PR adds code that the existing suite may not exercise. Measures patch coverage — the share of newly changed lines hit by tests — before approving.","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fpayments\u002F0xklen-verify-tests-cover-changed-lines\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fpayments\u002F0xklen-verify-tests-cover-changed-lines\u002FSKILL.md",[],[258,259,260,261,262,263,264,37,265,266,267],"tests","cover","verify tests cover changed lines","verify","coverage","pr","exercise","patch","code","share"]