This repository contains the on-chain Pump.fun smart contract implemented with the Anchor framework on Solana.
The program focuses on configurable swap fees, basic AMM-style liquidity management, and Raydium pool creation via CPI.
The code is suitable as a reference implementation for:
- Solana DeFi engineers integrating with Pump.fun–style liquidity flows.
- Auditors reviewing liquidity and swap logic.
- Contributors extending the pool logic or Raydium integration.
- Program name:
pump - Program ID (devnet):
7wUQXRQtBzTmyp9kcrmok9FKcc4RSYXxPYN9FGDLnqxb - Framework: Anchor on Solana
Core capabilities:
- Configurable fee curve via
CurveConfigurationaccount. - Liquidity provision to a
LiquidityPool(add/remove liquidity). - Token/SOL swaps using a constant‑product style formula with fee application.
- Raydium pool creation via CPI (
create_raydium_poolinstruction).
- Requirements
- Installation
- Build & Deploy
- Program Instructions
- Accounts & Architecture
- Development & Testing
- Support
- Contributing
- License
- Rust 1.70+
- Solana CLI 1.16+ (or compatible with your Anchor toolchain)
- Anchor 0.29.0+
- Node.js 18+ (for tests / TypeScript clients)
- Yarn or npm
# Clone the repository
git clone https://github.com/0xAllan123/Pumpfun-Smart-Contract.git
cd Pumpfun-Smart-Contract
# Install TypeScript / JS dependencies (for tests & clients)
yarn install # or: npm installThe project is configured with Anchor workspaces (Cargo.toml) and Anchor.toml for devnet deployment.
# Build the on-chain program
anchor build
# Deploy to devnet (uses provider settings from Anchor.toml)
anchor deployYou can also use solana config get and Anchor’s --provider.cluster flag to target a different cluster if required.
The pump program exposes the following primary instructions (see programs/pump/src/lib.rs and programs/pump/src/instructions):
-
initialize- Initializes the global
CurveConfigurationaccount and sets the swap fee (asf64). - Signature:
pub fn initialize(ctx: Context<InitializeCurveConfiguration>, fee: f64) -> Result<()>
- Initializes the global
-
add_liquidity- Adds liquidity to a
LiquidityPool, mints provider shares, and updates reserves. - Signature:
pub fn add_liquidity(ctx: Context<AddLiquidity>, amount_one: u64, amount_two: u64) -> Result<()>
- Adds liquidity to a
-
remove_liquidity- Burns provider shares and returns a proportional amount of underlying assets.
- Signature:
pub fn remove_liquidity(ctx: Context<RemoveLiquidity>, nonce: u8, init_pc_amount: u64) -> Result<()>
-
swap- Executes a token/SOL swap using the configured fee and AMM formula.
- Signature:
pub fn swap(ctx: Context<Swap>, amount: u64, style: u64) -> Result<()>
-
create_raydium_pool- Creates a Raydium pool via CPI, using initial token/PC amounts.
- Signature:
pub fn create_raydium_pool(ctx: Context<CreateRaydiumPool>, nonce: u8, init_pc_amount: u64, init_coin_amount: u64) -> Result<()>
import { Program } from '@coral-xyz/anchor';
import { Connection, PublicKey } from '@solana/web3.js';
// Example: swap
const connection = new Connection('https://api.devnet.solana.com');
const program = new Program(idl, new PublicKey('7wUQXRQtBzTmyp9kcrmok9FKcc4RSYXxPYN9FGDLnqxb'), { connection });
await program.methods
.swap(new anchor.BN(amount), new anchor.BN(style))
.accounts({
// fill in accounts as defined in the Anchor IDL / instruction context
})
.rpc();Key modules (under programs/pump/src):
-
state.rsCurveConfiguration– stores global fee configuration.LiquidityPool– tracks token mints, total supply, reserves, and bump.LiquidityProvider– stores LP share balances per provider.LiquidityPoolAccounttrait – encapsulates liquidity and swap logic, as well as SOL/token transfer helpers.
-
instructions/initialize.rs,add_liquidity.rs,remove_liquidity.rs,swap.rs, and Raydium-related logic forcreate_raydium_pool.
-
errors.rsCustomErrorenum with expressive error messages (e.g.,InsufficientShares,InvalidAmount,OverflowOrUnderflowOccurred).
-
consts.rs- Core configuration constants such as
INITIAL_PRICE.
- Core configuration constants such as
The swap implementation uses a constant‑product style formula with fee application derived from CurveConfiguration.fees, combined with SPL Token and system program CPI calls for token and SOL transfers.
Anchor test configuration is defined in Anchor.toml ([scripts] and [test] sections).
Typical local/dev workflow:
# Run the Anchor test suite
anchor test
# (Optional) TypeScript tests
yarn test # or: npm testTests use ts-mocha as configured in Anchor.toml:
[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"- Telegram:
@oxgoldenledger - Discord:
goldenledger - GitHub Issues: use the repository’s Issues tab for bug reports and feature requests.
Contributions, audits, and review feedback are welcome.
- Please read
CONTRIBUTING.mdfor guidelines. - Open an issue to discuss substantial changes before raising a PR.
This project is licensed under the MIT License. See LICENSE for details.