Skip to main content

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.

Metadata

Release files for pumpswapamm 2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pumpswapamm 2.2
File Size Uploaded Provenance Actions
pumpswapamm-2.2.tar.gz 15.0 kB Without provenance Details for pumpswapamm-2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pumpswapamm 2.2
File Interpreter ABI Platform Actions
pumpswapamm-2.2-py3-none-any.whl Python 3 none any Details for pumpswapamm-2.2-py3-none-any.whl

Total release size: 28.7 kB

Release files / pumpswapamm-2.2.tar.gz

Download URL pumpswapamm-2.2.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
928954160c1c9f8d2e450b92bb6e60b725eeab1db890ec59083b83b20623d7e2
BLAKE2b-256 checksum
How to use checksums
b982b14e6e92d2560b263ebb04010bed579deaee7038a67495f0957abff19702
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.6

Release files / pumpswapamm-2.2-py3-none-any.whl

Download URL pumpswapamm-2.2-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
733852e7e8c3abc644dac37f0d97a775e26e6badfa3d18e0358b51f1feeee9d1
BLAKE2b-256 checksum
How to use checksums
dc50526a11836ab5886fa1794ae15263a741109affec3ca580daf28febc31501
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.6

Security for pumpswapamm 2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page