Python SDK for Pump.fun’s PumpSwap AMM on Solana
Project description
PumpSwapAMM
Python SDK for Pump.fun AMM (PumpSwap) on Solana.
- Trade tokens, create & manage pairs.
Latest update reflects newest (01.08.25) changes in Pump.fun AMM program, adds reversed_buy and reversed_sell; Use them when WSOL is the base token. You can also pass keypair to each function instead of having a single signer for the whole class, which is useful when you want to use different wallets for different operations.
The module implements ways to fetch pool keys and price or account reserves, deriving addresses, finding pools and more...
Tip wallet: FL4CKfetEWBMXFs15ZAz4peyGbCuzVaoszRKcoVt3WfC, Thanks đź’™
Contact & Support
Discord: FLOCK4H.CAVE, Telegram: FLOCK4H.CAVE
Telegram private handle: @dubskii420
Setup
Most convenient:
If module or a command can't be found, try installing in a shell with administrative rights
$ pip install PumpSwapAMM
When above fails for any reason:
$ git clone https://github.com/FLOCK4H/PumpSwapAMM
$ cd PumpSwapAMM
$ pip install .
Usage
Check out the example.py and example_pool.py scripts for a Plug & Play implementation
class PumpSwap(
async_client: AsyncClient,
)
(method) def buy(
pool_data: dict,
sol_amount: float,
keypair: Keypair | None = None,
pool_type: str = NEW_POOL_TYPE,
slippage_pct: float,
fee_sol: float
return_instructions: bool = False,
) -> Coroutine[Any, Any, bool]
Args:
pool_data: dict
sol_amount: float
slippage_pct: float
fee_sol: float
Returns:
bool: True if successful, False otherwise
(method) def reversed_buy(
pool_data: dict,
sell_pct: float,
keypair: Keypair,
pool_type: str = NEW_POOL_TYPE,
slippage_pct: float = 10, # slippage works differently here, we can't apply slippage because we spend all the tokens, so only way is to sell less, set slippage to as low as possible to sell as much WSOL
fee_sol: float = 0.00001, # total priority fee user wants to pay, e.g. 0.0005
debug_prints: bool = False,
return_instructions: bool = False,
):
(method) def sell(
pool_data: dict,
sell_pct: float,
slippage_pct: float,
fee_sol: float
) -> Coroutine[Any, Any, bool]
Args:
pool_data: dict
sell_pct: float
slippage_pct: float
fee_sol: float
Returns:
bool: True if successful, False otherwise
(method) def reversed_sell(
pool_data: dict,
sol_amount: float,
keypair: Keypair,
pool_type: str = NEW_POOL_TYPE,
slippage_pct: float = 10,
fee_sol: float = 0.00001,
debug_prints: bool = False,
return_instructions: bool = False,
):
(function) def fetch_pool(
pool: str,
async_client: AsyncClient
) -> Coroutine[Any, Any, dict[str, Any]]
(function) def fetch_pool_base_price(
pool_keys: Any,
async_client: Any
) -> Coroutine[Any, Any, tuple[Decimal, Any, Any] | None]
(method) def derive_pool_address(
creator: Pubkey,
base_mint: Pubkey,
quote_mint: Pubkey,
index: int = 0
) -> Pubkey
(method) def create_pool(
base_mint: Pubkey,
base_amount_tokens: float,
quote_amount_sol: float,
decimals_base: int = 6,
index: int = 0,
fee_sol: float = 0.0005,
mute: bool = False
) -> Coroutine[Any, Any, bool]
(method) def withdraw(
pool_data: dict,
withdraw_pct: float,
fee_sol: float = 0.0003,
mute: bool = False
) -> Coroutine[Any, Any, bool]
(method) def deposit(
pool_data: dict,
base_amount_tokens: float,
slippage_pct: float = 1,
fee_sol: float = 0.0003,
sol_cap: float | None = None,
mute: bool = False
) -> Coroutine[Any, Any, bool]
Examples
Check example.py and example_pool.py for more examples.
Issues
- "get_account_info_json_parsed" may throw a 401 or 403 if you're using helius (& any other triton-based) dedicated node or staked APIs
LICENSE
Standard MIT License
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pumpswapamm-2.2.tar.gz.
File metadata
- Download URL: pumpswapamm-2.2.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
928954160c1c9f8d2e450b92bb6e60b725eeab1db890ec59083b83b20623d7e2
|
|
| MD5 |
d79b41927870a7451d1fa35350cf96a8
|
|
| BLAKE2b-256 |
b982b14e6e92d2560b263ebb04010bed579deaee7038a67495f0957abff19702
|
File details
Details for the file pumpswapamm-2.2-py3-none-any.whl.
File metadata
- Download URL: pumpswapamm-2.2-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
733852e7e8c3abc644dac37f0d97a775e26e6badfa3d18e0358b51f1feeee9d1
|
|
| MD5 |
1ee2c86f1656eefc369179f6dbb994bc
|
|
| BLAKE2b-256 |
dc50526a11836ab5886fa1794ae15263a741109affec3ca580daf28febc31501
|