PumpSwap Liquidity Management scripts for creating pools, depositing liquidity, and withdrawing LP tokens on the PumpSwap AMM — the native decentralized exchange on Solana.
PumpSwap is a constant-product AMM (x * y = k) deployed on Solana mainnet at program address pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA. Tokens that complete their bonding curve on Pump.fun migrate directly into PumpSwap pools, where liquidity providers earn a share of the 0.25% trade fee (0.20% to LPs, 0.05% to the protocol).
This toolkit gives you a clean, environment-variable-driven interface to the three core liquidity operations on PumpSwap:
| Script | What It Does |
|---|---|
createPool.ts |
Creates a new PumpSwap AMM pool with an initial base/quote deposit |
addLiq.ts |
Adds liquidity to an existing pool, minting proportional LP tokens |
withdrawLiq.ts |
Burns LP tokens and withdraws your share of base and quote reserves |
- Node.js ≥ 18
- Yarn
- A funded Solana wallet (mainnet-beta) whose private key you can set in
.env - Access to a Solana RPC endpoint (default:
https://api.mainnet-beta.solana.com)
git clone https://github.com/ElliteAnts/Pumpswap-Liquidity-Management-Script.git
cd Pumpswap-Liquidity-Management-Script
yarnCopy the sample file and fill in your values:
cp .env.sample .env| Variable | Description | Example |
|---|---|---|
SOLANA_RPC_URL |
Solana RPC endpoint | https://api.mainnet-beta.solana.com |
WALLET_SECRET_KEY |
Base-58 private key of your wallet | Your_Wallet_Privatekey |
BASE_MINT |
Mint address of the base token | (your token mint) |
QUOTE_MINT |
Mint address of the quote token | (e.g. SOL wrapped mint) |
BASE_DECIMALS |
Decimal places of the base token | 9 |
QUOTE_DECIMALS |
Decimal places of the quote token | 6 |
INITIAL_BASE |
Initial base amount when creating a pool (UI units) | 10 |
INITIAL_QUOTE |
Initial quote amount when creating a pool (UI units) | 0.001 |
ADD_LIQ_AMOUNT |
Quote amount to add on deposit (UI units) | 0.001 |
WITHDRAW_LP_AMOUNT |
LP token amount to burn on withdrawal (UI units) | 0.001 |
POOL_INDEX |
Pool index for PDA derivation | 0 |
Security note: Never commit your
.envfile. The.gitignorealready excludes it.
yarn run build# Create a new PumpSwap pool
yarn run create
# Add liquidity to your pool
yarn run deposit
# Withdraw liquidity (burn LP tokens)
yarn run withdrawUnderstanding the mechanics behind the scripts helps you tune parameters for your use case.
Pool creation derives a unique Pool PDA from ["pool", index, creator, base_mint, quote_mint]. The first deposit sets the pool's initial price ratio based on INITIAL_BASE and INITIAL_QUOTE.
Depositing liquidity mints LP tokens proportionally to your contribution relative to the current pool reserves. The SDK ensures your deposit maintains the existing ratio; any excess from the larger side is refunded.
Withdrawing liquidity burns LP tokens and returns a pro-rata share of both base and quote reserves:
base_out = (lp_burned / lp_supply) × base_reserves
quote_out = (lp_burned / lp_supply) × quote_reserves
├── src/
│ ├── createPool.ts # Pool creation logic
│ ├── addLiq.ts # Liquidity deposit logic
│ └── withdrawLiq.ts # Liquidity withdrawal logic
├── .env.sample # Environment variable template
├── package.json # Dependencies & npm scripts
├── tsconfig.json # TypeScript configuration
└── yarn.lock # Locked dependency versions
All transactions below were executed against mainnet-beta and can be inspected on Solscan.
| Action | Transaction / Account |
|---|---|
| Create Pool | CZe675tm…DCp5 |
| Pool Key | BeFYKqP…FEMd1 |
| Add Liquidity | 2EhhZig…kf9Yi |
| Withdraw Liquidity | 3UX1A7T…fR5Wj |
Pull requests are welcome. Please open an issue first to discuss the change you'd like to make.
Have a feature request or integration question? Reach out on Telegram.