← 返回
开发者工具 Key 中文

Pump Sdk Core

Build and extend the core Pump SDK — an offline-first TypeScript SDK that constructs Solana TransactionInstructions for token creation, buying, selling, migr...
构建并扩展核心 Pump SDK — 一个离线优先的 TypeScript SDK,用于生成 Solana TransactionInstructions,涵盖代币创建、购买、出售、迁移等...
speraxos
开发者工具 clawhub v0.1.0 1 版本 99817.2 Key: 需要
★ 0
Stars
📥 546
下载
💾 5
安装
1
版本
#latest

概述

Pump SDK Core — Instruction Building & On-Chain Interaction

Build, extend, and maintain the core Pump SDK — an offline-first TypeScript SDK that constructs Solana TransactionInstructions for token creation, buying, selling, migration, and creator fee collection across three on-chain programs (Pump, PumpAMM, PumpFees) plus the Mayhem program.

Context

The SDK is published as @pump-fun/pump-sdk (npm) and powers the Pump protocol — a Solana-based token launchpad with bonding curve pricing, automatic AMM migration after graduation, tiered fees, and creator fee sharing. The codebase uses Anchor for IDL-based instruction building and supports both Token (SPL) and Token-2022 token programs.

Key Files

  • src/sdk.tsPumpSdk class with all instruction builders and account decoders
  • src/onlineSdk.tsOnlinePumpSdk class extending offline SDK with live RPC fetches
  • src/index.ts — barrel re-export module defining the public API surface
  • src/state.ts — TypeScript interfaces for all on-chain account state
  • src/pda.ts — Program Derived Address derivation for all programs
  • src/idl/pump.ts, src/idl/pump_amm.ts, src/idl/pump_fees.ts — Anchor IDL definitions

Architecture

  • Offline SDK (PumpSdk): Builds instructions without a live connection. Uses Anchor Program instances initialized with a dummy keypair and connection. Exported as a singleton PUMP_SDK.
  • Online SDK (OnlinePumpSdk): Wraps PumpSdk with a real Connection for fetching account state via getMultipleAccountsInfo. Provides "BothPrograms" methods that aggregate data across bonding curve (Pump) and AMM (PumpAMM) programs.
  • Three program IDs: PUMP_PROGRAM_ID, PUMP_AMM_PROGRAM_ID, PUMP_FEE_PROGRAM_ID, plus MAYHEM_PROGRAM_ID for mayhem-mode tokens.

Instruction Builder Pattern

Every instruction method returns TransactionInstruction[] (not transactions), allowing callers to compose them into transactions freely. Methods follow a naming convention:

  • *Instruction — single instruction
  • *Instructions — multiple instructions (e.g., ATA creation + buy)

Account Decoders

The SDK decodes raw AccountInfo into typed interfaces using the Anchor coder:

  • decodeGlobal, decodeBondingCurve, decodeFeeConfig, decodeSharingConfig, etc.
  • Nullable variants (e.g., decodeBondingCurveNullable) handle missing or undersized accounts gracefully.

Slippage Calculation

maxSolCost = solAmount + (solAmount × slippage × 10 / 1000)
minSolReceived = solAmount - (solAmount × slippage × 10 / 1000)

Patterns to Follow

  • Always return TransactionInstruction[] from instruction builders, never full Transaction objects
  • Use getMultipleAccountsInfo to batch RPC calls (2–3 accounts per call)
  • Support both Token (SPL) and Token-2022 programs via tokenProgram parameter
  • Handle account extension (extendAccountInstruction) for bonding curves that need more space
  • Validate shareholder arrays: max 10 shareholders, shares must total 10,000 bps, no duplicates, no zero shares
  • Use typed error classes from src/errors.ts for validation failures
  • Keep the offline SDK connection-free; all RPC calls belong in OnlinePumpSdk

Common Pitfalls

  • Circular dependency between sdk.ts and onlineSdk.ts
  • Buy instruction passes { 0: true } as a flags argument — this is intentional, not a bug
  • BONDING_CURVE_NEW_SIZE = 151 — accounts may need extension before certain operations
  • BondingCurve.complete === true means the token has graduated to AMM — bonding curve operations will fail
  • The createInstruction (v1) is deprecated in favor of createV2Instruction (Token-2022)

版本历史

共 1 个版本

  • v0.1.0 当前
    2026-03-30 03:30 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 921 📥 185,799
ai-intelligence

Pump MCP Server

speraxos
模型上下文协议服务器暴露7个工具、3种资源类型和3个提示,供AI代理使用——包括Solana钱包操作、虚荣地址生成...
★ 0 📥 823
developer-tools

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 68 📥 180,185