Metadata-Version: 2.1
Name: PumpSwapAMM
Version: 2.0.0
Summary: Python SDK + optional CLI for Pump.fun’s PumpSwap AMM on Solana
Author: FLOCK4H
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: solana==0.35.1
Requires-Dist: solders==0.21.0
Requires-Dist: construct
Requires-Dist: base58
Requires-Dist: python-dotenv
Requires-Dist: requests>=2.31.0
Requires-Dist: Pillow>=10.2.0
Requires-Dist: readchar>=4.2.1
Provides-Extra: cli
Requires-Dist: Tkinter-Designer>=1.0.2; sys_platform == "win32" and extra == "cli"
Provides-Extra: dev
Requires-Dist: black; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: mypy; extra == "dev"

# PumpSwapAMM

**Python SDK + optional CLI for Pump.funâ€™s PumpSwap AMM on Solana**

Trade, create, and manage - Pools and Tokens.
The module implements ways to fetch pool keys and price or account reserves.

Tip wallet: `3oFDwxVtZEpSGeNgdWRiJtNiArv4k9FiMsMz3yjudgeS`

**Thanks đź’™**

**Discord: [FLOCK4H.CAVE](https://discord.gg/thREUECv2a)**, **Telegram: [FLOCK4H.CAVE](https://t.me/flock4hcave)**

**Telegram private handle: @dubskii420**

<img src="https://github.com/user-attachments/assets/d655c153-0056-47fc-8314-6f919f18ed6d" width="256" />

# Setup

```
  $ git clone https://github.com/FLOCK4H/PumpSwapAMM
  $ cd PumpSwapAMM
  $ pip install .
```

# Usage

**Check out the `example.py` script for a plug&play implementation**

```python
class PumpSwap(
    async_client: AsyncClient,
    signer: Keypair
)

(method) def buy(
    pool_data: dict,
    sol_amount: float,
    slippage_pct: float,
    fee_sol: float
) -> 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 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

(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]
```

<h4>Examples</h4>

```python
  # 1) Initialize PumpSwap client
  client = PumpSwap(async_client, signer=async_payer_keypair)

  # Example pool: https://solscan.io/account/9NXBQSt63ZZcw3e4DhbDPGP2FjnwW3aDJWEXRwcGEsN3
  pool = "9NXBQSt63ZZcw3e4DhbDPGP2FjnwW3aDJWEXRwcGEsN3" # Change this to the token pool address you want to buy

  # 2) Fetch pool data
  pool_keys = await fetch_pool(pool, async_client) 
  base_price, base_balance_tokens, quote_balance_sol = await fetch_pool_base_price(pool_keys, async_client)
  decimals_base = 6 # Pump.fun mints got 6 decimals, otherwise it can be read from Pool Creation, or Mint Creation transaction

  # 3) Prepare pool data
  pool_data = {
      "pool_pubkey": Pubkey.from_string(pool),
      "token_base": Pubkey.from_string(pool_keys["base_mint"]),
      "token_quote": Pubkey.from_string(pool_keys["quote_mint"]),
      "pool_base_token_account": pool_keys["pool_base_token_account"],
      "pool_quote_token_account": pool_keys["pool_quote_token_account"],
      "base_balance_tokens": base_balance_tokens,
      "quote_balance_sol": quote_balance_sol,
      "decimals_base": decimals_base
  }

  await client.buy(
      pool_data,
      sol_amount=0.002,
      slippage_pct=10,
      fee_sol=0.0005,
  )

  await client.sell(
      pool_data,
      sell_pct=100,
      slippage_pct=10,
      fee_sol=0.0005,
  )
```

# Issues

- "get_account_info_json_parsed" may throw a 401 or 403 if you're using helius/ (any other triton) 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.
