Pump Swap (AMM) with Python
pumpswappy
Python library to trade on Pump Swap (AMM).
pip install solana==0.36.1 solders==0.23.0
Updated: 9/2/2025
PumpSwap program (pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA):
- Buy instruction: Add accounts at indexes 21 (feeconfig) and 22 (feeprogram)
- Sell instruction: Add accounts at indexes 19 (feeconfig) and 20 (feeprogram)
Contact
My Telegram: https://t.me/ALTHEBOT_FATHER
Instructions
Clone the repo and use examplebuy.py or examplesell.py.
If you can - please support my work and donate to: 3pPK76GL5ChVFBHND54UfBMtg36Bsh1mzbQPTbcK89PD
FAQS
What format should my private key be in?
The private key should be in the base58 string format, not bytes.
Why are my transactions being dropped?
You get what you pay for. Don't use the main-net RPC, just spend the money for Helius or Quick Node.
How do I change the fee?
Modify the unitbudget and unitprice values.
Does this code work on devnet?
No.
Example
from solana.rpc.api import Client
from solders.keypair import Keypair # type: ignore
from poolutils import fetchpairfromrpc from pump_swap import buy
Configuration
privkey = "base58privstrhere"
rpc = "rpcurlhere"
mintstr = "pumpswap_address"
sol_in = 0.1
slippage = 5
unitbudget = 150000
unitprice = 1000_000
Initialize client and keypair
client = Client(rpc)
payerkeypair = Keypair.frombase58string(privkey)
Fetch pair and execute buy
pairaddress = fetchpairfromrpc(client, mint_str)
if pair_address:
buy(client, payerkeypair, pairaddress, solin, slippage, unitbudget, unit_price)
else:
print("No pair address found...")
from solana.rpc.api import Client
from solders.keypair import Keypair # type: ignore
from poolutils import fetchpairfromrpc from pump_swap import sell
Configuration
privkey = "base58privstrhere"
rpc = "rpcurlhere"
mintstr = "pumpswap_address"
percentage = 100
slippage = 5
unitbudget = 150000
unitprice = 1000_000
Initialize client and keypair
client = Client(rpc)
payerkeypair = Keypair.frombase58string(privkey)
Fetch pair and execute buy
pairaddress = fetchpairfromrpc(client, mint_str)
if pair_address: sell(client, payerkeypair, pairaddress, percentage, slippage, unitbudget, unitprice) else: print("No pair address found...")
Contributors
https://github.com/Jarki