Skip to main content

Python SDK for Pump.fun’s PumpSwap AMM on Solana

Project description

PumpSwapAMM

Python SDK for PumpSwap AMM on Solana.

  • Trade tokens, create & manage pairs.

Latest update 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pumpswapamm-2.1.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pumpswapamm-2.1-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file pumpswapamm-2.1.tar.gz.

File metadata

  • Download URL: pumpswapamm-2.1.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for pumpswapamm-2.1.tar.gz
Algorithm Hash digest
SHA256 4d181790e51a120f1966ee7b4f466b1f2f72fe270c88b834837a550bf54da732
MD5 f4ae1fdab97bdd47e7d1ab4e62cd8762
BLAKE2b-256 77597c38dae07eb93d41ff7da184857552606d52977d52fcfcf5081937d91424

See more details on using hashes here.

File details

Details for the file pumpswapamm-2.1-py3-none-any.whl.

File metadata

  • Download URL: pumpswapamm-2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for pumpswapamm-2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d4da5f2fa67f033eed01930b9c78bf30d7a334532efda45cde43fae378a03672
MD5 3451673214e07c074fb9cfb7c379e8f3
BLAKE2b-256 17042b5c22b28cbe907fb19dd20731271f5f9baf6a80191d7e085e8d196c8cc7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page