pumpfun-toolkit 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,290 @@
1
+ Metadata-Version: 2.5
2
+ Name: pumpfun-toolkit
3
+ Version: 0.1.1
4
+ Summary: Read-only Python tools for the Pump.fun program on Solana: event decoding, bonding curve math, mint inspection and heuristic risk checks.
5
+ Project-URL: Homepage, https://github.com/abidihassanreza12-svg/pumpfun-toolkit
6
+ Project-URL: Documentation, https://github.com/abidihassanreza12-svg/pumpfun-toolkit/blob/main/docs/api.md
7
+ Project-URL: Issues, https://github.com/abidihassanreza12-svg/pumpfun-toolkit/issues
8
+ Project-URL: Changelog, https://github.com/abidihassanreza12-svg/pumpfun-toolkit/blob/main/CHANGELOG.md
9
+ Author: abidihassanreza12-svg
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: anchor,bonding-curve,borsh,pump.fun,pumpfun,solana,token-2022
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Libraries
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.10
25
+ Requires-Dist: httpx<1,>=0.28
26
+ Requires-Dist: solders<1,>=0.29
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
29
+ Requires-Dist: pytest-cov>=5; extra == 'dev'
30
+ Requires-Dist: pytest>=8; extra == 'dev'
31
+ Requires-Dist: ruff>=0.8; extra == 'dev'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # pumpfun-toolkit
35
+
36
+ [![CI](https://github.com/abidihassanreza12-svg/pumpfun-toolkit/actions/workflows/ci.yml/badge.svg)](https://github.com/abidihassanreza12-svg/pumpfun-toolkit/actions/workflows/ci.yml)
37
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/abidihassanreza12-svg/pumpfun-toolkit/blob/main/LICENSE)
38
+ ![Python 3.10–3.13](https://img.shields.io/badge/python-3.10%E2%80%933.13-blue.svg)
39
+
40
+ Read-only Python tools for the [Pump.fun](https://pump.fun) program on Solana.
41
+
42
+ - **Decode program events** (`CreateEvent`, `TradeEvent`, `CompleteEvent`) from
43
+ transaction logs, with protection against events forged by other programs.
44
+ - **Decode bonding curve accounts** and compute price, market cap, progress,
45
+ buy/sell quotes and price impact with exact integer arithmetic.
46
+ - **Inspect SPL Token and Token-2022 mints** for active mint/freeze authorities
47
+ and dangerous extensions (transfer hooks, permanent delegates, pausable, …).
48
+ - **Run a heuristic risk check** over facts you collect.
49
+ - **A small async Solana RPC client** that only allows read-only methods and
50
+ keeps the API key in your endpoint URL out of errors and log lines, including
51
+ the request log of `httpx` (see [API keys and logging](#api-keys-and-logging)).
52
+
53
+ The package **never signs or sends transactions** and never handles private keys.
54
+
55
+ > **Disclaimer.** This project is not affiliated with, endorsed by or sponsored by
56
+ > Pump.fun. It is a technical library, not financial advice. Most tokens launched
57
+ > on Pump.fun lose value; a clean result from the risk check does **not** mean a
58
+ > token is safe to buy.
59
+
60
+ ## Status
61
+
62
+ Alpha (`0.1.1`). The public API may still change. Field layouts follow the official
63
+ Pump.fun IDL at commit
64
+ [`e244b35`](https://github.com/pump-fun/pump-public-docs/blob/e244b35ba70864c029411e81ed1bbd4dee4d2926/idl/pump.json)
65
+ (2026-11-27). See [docs/idl-provenance.md](https://github.com/abidihassanreza12-svg/pumpfun-toolkit/blob/main/docs/idl-provenance.md).
66
+
67
+ ## Installation
68
+
69
+ Requires Python 3.10 or newer. Install the release from PyPI:
70
+
71
+ ```bash
72
+ python -m pip install pumpfun-toolkit
73
+ ```
74
+
75
+ or a tagged release straight from GitHub:
76
+
77
+ ```bash
78
+ python -m pip install "pumpfun-toolkit @ git+https://github.com/abidihassanreza12-svg/pumpfun-toolkit.git@v0.1.1"
79
+ ```
80
+
81
+ or from a local clone:
82
+
83
+ ```bash
84
+ git clone https://github.com/abidihassanreza12-svg/pumpfun-toolkit.git
85
+ cd pumpfun-toolkit
86
+ python -m venv .venv
87
+ # Windows: .venv\Scripts\activate macOS/Linux: source .venv/bin/activate
88
+ python -m pip install .
89
+ ```
90
+
91
+ Runtime dependencies: [`solders`](https://github.com/kevinheavey/solders) (public
92
+ key handling and PDA derivation) and [`httpx`](https://www.python-httpx.org/)
93
+ (HTTP client for the RPC module).
94
+
95
+ ## Quick start
96
+
97
+ ### Decode the events of a transaction
98
+
99
+ ```python
100
+ import asyncio
101
+
102
+ from pumpfun_toolkit import CreateEvent, SolanaRpcClient, TradeEvent, decode_logs
103
+
104
+
105
+ async def main() -> None:
106
+ async with SolanaRpcClient("https://api.mainnet-beta.solana.com") as rpc:
107
+ logs = await rpc.get_transaction_logs("<transaction signature>")
108
+ events, failures = decode_logs(logs or [])
109
+ for event in events:
110
+ if isinstance(event, CreateEvent):
111
+ print("created", event.name, event.mint)
112
+ elif isinstance(event, TradeEvent):
113
+ print("buy" if event.is_buy else "sell", event.sol_amount, "lamports")
114
+
115
+
116
+ asyncio.run(main())
117
+ ```
118
+
119
+ You can also feed log lines from a `logsSubscribe` WebSocket notification straight
120
+ into `decode_logs`; no RPC client is needed for decoding.
121
+
122
+ ### Price a bonding curve
123
+
124
+ ```python
125
+ from pumpfun_toolkit import bonding_curve_address, decode_bonding_curve
126
+
127
+ curve_address = bonding_curve_address(mint) # PDA, computed offline
128
+ owner, data = await rpc.get_account_data(curve_address)
129
+ curve = decode_bonding_curve(data)
130
+
131
+ state = curve.state
132
+ state.price_sol # Decimal, SOL per whole token
133
+ state.market_cap_sol # Decimal
134
+ state.tokens_out_for_sol(100_000_000) # quote for 0.1 SOL, fees excluded
135
+ state.price_impact(1_000_000_000) # about 0.0333 (3.3 %) on a fresh curve
136
+ ```
137
+
138
+ ### Inspect a mint
139
+
140
+ ```python
141
+ from pumpfun_toolkit import parse_mint
142
+ from pumpfun_toolkit.mint import DANGEROUS_EXTENSIONS, EXTENSION_NAMES
143
+
144
+ owner, data = await rpc.get_account_data(mint)
145
+ info = parse_mint(owner, data)
146
+
147
+ info.mint_authority # None once revoked
148
+ info.freeze_authority # None once revoked
149
+ for kind in info.extensions:
150
+ print(EXTENSION_NAMES.get(kind, kind), DANGEROUS_EXTENSIONS.get(kind, ""))
151
+ ```
152
+
153
+ ### Heuristic risk check
154
+
155
+ ```python
156
+ from pumpfun_toolkit import SecurityInputs, assess
157
+
158
+ result = assess(SecurityInputs(mint=mint, mint_info=info, curve=curve, token=..., holders=...))
159
+ result.verdict # "blocked", "risky" or "passed"
160
+ result.score # 0..100
161
+ result.findings # list of Finding(code, severity, message, penalty)
162
+ result.missing # information that was not available (blocks the verdict)
163
+ ```
164
+
165
+ `TokenFacts` and `HolderFacts` describe trading activity you observed yourself,
166
+ for example by decoding `TradeEvent`s since the token's creation. The rules,
167
+ penalties and thresholds are documented assumptions and **have not been validated
168
+ against market data**. Missing information always blocks.
169
+
170
+ Runnable versions of these snippets live in [`examples/`](https://github.com/abidihassanreza12-svg/pumpfun-toolkit/tree/main/examples).
171
+
172
+ ## API overview
173
+
174
+ | Module | Main objects | Purpose |
175
+ |---|---|---|
176
+ | `pumpfun_toolkit.events` | `decode_logs`, `decode_event`, `extract_program_data`, `CreateEvent`, `TradeEvent`, `CompleteEvent` | Event decoding from log lines |
177
+ | `pumpfun_toolkit.curve` | `decode_bonding_curve`, `bonding_curve_address`, `CurveState`, `BondingCurveAccount` | Curve account and constant-product math |
178
+ | `pumpfun_toolkit.mint` | `parse_mint`, `MintInfo`, `EXTENSION_NAMES`, `DANGEROUS_EXTENSIONS` | SPL Token / Token-2022 mint parsing |
179
+ | `pumpfun_toolkit.risk` | `assess`, `SecurityInputs`, `TokenFacts`, `HolderFacts`, `Assessment`, `Finding` | Heuristic risk rules (pure function) |
180
+ | `pumpfun_toolkit.rpc` | `SolanaRpcClient`, `READ_ONLY_METHODS` | Read-only async JSON-RPC client |
181
+ | `pumpfun_toolkit.redact` | `redact_url` | Mask API keys in endpoint URLs |
182
+ | `pumpfun_toolkit.fees` | `estimate_fee`, `typical_priority_price`, `lamports_to_sol`, `sol_to_lamports`, `lamports_to_fiat` | Fee arithmetic and unit conversion |
183
+ | `pumpfun_toolkit.borsh` | `BorshReader` | Bounds-checked Borsh reader |
184
+ | `pumpfun_toolkit.text` | `clean_text` | Strip control characters from untrusted token names |
185
+ | `pumpfun_toolkit.errors` | `PumpfunToolkitError`, `DecodeError`, `MintDecodeError`, `SolanaRpcError`, `MethodNotAllowedError`, `InvalidRpcUrlError` | Exception hierarchy |
186
+
187
+ All amounts are integers in base units (lamports, raw token units); derived values
188
+ are `decimal.Decimal`. All data classes are frozen. The full reference with every
189
+ function signature is in [docs/api.md](https://github.com/abidihassanreza12-svg/pumpfun-toolkit/blob/main/docs/api.md).
190
+
191
+ ## Design notes
192
+
193
+ **Forged events.** Any Solana program can write a `Program data:` line. If a
194
+ decoder accepts every such line, another program in the same transaction can fake
195
+ a Pump.fun `CreateEvent`. `extract_program_data` follows the
196
+ `invoke [n]` / `success` / `failed` lines of the runtime and only returns data
197
+ written while the Pump.fun program itself is executing.
198
+
199
+ **Forward compatibility.** Pump.fun appends fields to its events and accounts. The
200
+ decoders read the fields they need and ignore trailing bytes, so newer layouts keep
201
+ decoding. Older, shorter layouts are recognised as well (for example trade events
202
+ without a quote mint, which means SOL).
203
+
204
+ **Untrusted input.** Strings are length-limited (2 KiB), booleans must be 0 or 1,
205
+ vectors have plausibility bounds, and every read is bounds-checked. Malformed data
206
+ raises `DecodeError` instead of returning partial results. Token names and symbols
207
+ are chosen by token creators; pass them through `clean_text` before printing them
208
+ to a terminal or log.
209
+
210
+ **Read-only RPC client.** Methods that change chain state (`sendTransaction`,
211
+ `requestAirdrop`, …) are rejected before any request is made.
212
+
213
+ ## API keys and logging
214
+
215
+ RPC providers put API keys into the endpoint URL: into the query
216
+ (`https://mainnet.helius-rpc.com/?api-key=…`), into the path
217
+ (`…/v2/<key>`) or into the user info (`https://user:token@host`).
218
+ `SolanaRpcClient` protects such URLs as follows:
219
+
220
+ | Where | What you see |
221
+ |---|---|
222
+ | `SolanaRpcError` messages and `details`, exception chains, tracebacks | no URL at all |
223
+ | `repr(rpc)`, `rpc.endpoint` | the redacted form, e.g. `https://mainnet.helius-rpc.com/***` |
224
+ | log lines of `pumpfun_toolkit` | no URL at all |
225
+ | request log of `httpx` (`HTTP Request: POST …`, level INFO) | the redacted form |
226
+ | error messages returned by the node | URL and key masked if the node echoes them |
227
+ | an invalid URL | `InvalidRpcUrlError`, which does not repeat the URL |
228
+
229
+ How this works depends on who creates the HTTP client:
230
+
231
+ - **No `http` argument (recommended).** The client creates its own
232
+ `httpx.AsyncClient`, and that client only ever sees the redacted URL. A private
233
+ transport puts the real URL in at the last step, just before the request goes
234
+ to the network. Your logging configuration is not touched. `user:password@` in
235
+ the URL is sent as a Basic auth header. This HTTP client does not read proxy
236
+ environment variables (`HTTPS_PROXY`, …); pass your own client if you need a
237
+ proxy.
238
+ - **Your own `httpx.AsyncClient`.** Your client has to receive the real URL, so
239
+ `httpx` would log it. The RPC client therefore adds one filter to the `httpx`
240
+ logger. It only rewrites records that contain a URL or key registered by a
241
+ `SolanaRpcClient` and leaves all other records, levels and handlers as they
242
+ are. Your own event hooks, transports and middleware still see the real URL.
243
+
244
+ Use `rpc.endpoint` or `pumpfun_toolkit.redact_url(url)` when you want to log
245
+ which endpoint is in use; never log the URL itself.
246
+
247
+ Recommended logging settings for applications:
248
+
249
+ ```python
250
+ import logging
251
+
252
+ logging.basicConfig(level=logging.INFO)
253
+ # Request logs are noisy and rarely needed in production. The key is masked
254
+ # either way; this only reduces volume.
255
+ logging.getLogger("httpx").setLevel(logging.WARNING)
256
+ logging.getLogger("httpcore").setLevel(logging.WARNING)
257
+ ```
258
+
259
+ Limits: the host name is shown, so an endpoint whose host name itself is secret
260
+ is not masked. Error trackers that record the local variables of stack frames
261
+ (for example Sentry with `include_local_variables`) can still capture the URL
262
+ from inside the transport; turn that off or scrub it there. Keep the key in an
263
+ environment variable or a secret store, not in source code.
264
+
265
+ ## Development
266
+
267
+ ```bash
268
+ python -m venv .venv
269
+ python -m pip install -e ".[dev]"
270
+ python -m pytest # tests, no network access
271
+ python -m pytest --cov # with coverage
272
+ python -m ruff check .
273
+ python -m ruff format --check .
274
+ ```
275
+
276
+ The tests run entirely offline: RPC calls go to an in-process fake node or to a
277
+ small HTTP server on `127.0.0.1` started by the tests, and the decoder is also
278
+ checked against real mainnet log captures stored in
279
+ `tests/fixtures/pump_logs.json`.
280
+
281
+ See [CONTRIBUTING.md](https://github.com/abidihassanreza12-svg/pumpfun-toolkit/blob/main/CONTRIBUTING.md) for guidelines and
282
+ [SECURITY.md](https://github.com/abidihassanreza12-svg/pumpfun-toolkit/blob/main/SECURITY.md) for reporting vulnerabilities.
283
+
284
+ ## License
285
+
286
+ [MIT](https://github.com/abidihassanreza12-svg/pumpfun-toolkit/blob/main/LICENSE).
287
+
288
+ The Pump.fun IDL is not redistributed in this repository; the decoders are an
289
+ independent implementation of the published layout. "Pump.fun" is used only to
290
+ describe compatibility.
@@ -0,0 +1,17 @@
1
+ pumpfun_toolkit/__init__.py,sha256=4LLDgRMq5upzuVH4D8kmgTtOmJwcPPaHRf04S7S6Q_Y,1907
2
+ pumpfun_toolkit/borsh.py,sha256=UxqZJHKIOsp6IRqIjTA8sRTKGXZu1KYzSOvUHZdoLnE,1997
3
+ pumpfun_toolkit/constants.py,sha256=pvrb7amKOfugKBWRoAlXwFR8dE-eUXlnv-pqpM1JUyM,1284
4
+ pumpfun_toolkit/curve.py,sha256=U01d966ZVzMyRCpjk7leAXfEgD4ZkiwfaN47REkeZto,5210
5
+ pumpfun_toolkit/errors.py,sha256=ypLXVdyhb-w8XyKKPG7Wq7zIMy76dFAS-bgZnnhOve8,1330
6
+ pumpfun_toolkit/events.py,sha256=SmdVeCx1SwUJneppmnAyUK3nz-m74Rt1Yu65UuZ7WTc,7927
7
+ pumpfun_toolkit/fees.py,sha256=GgtuHJo0PX_zgbnbDfEsZiUQeFEU7nglMqsWCMaUdfw,2208
8
+ pumpfun_toolkit/mint.py,sha256=B1vo1pqO3gUHxkhjvlYd2_LQHhHZ6EWjTT5LHij3ogo,4974
9
+ pumpfun_toolkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ pumpfun_toolkit/redact.py,sha256=ZYZplZzZZBOHNnb7KW5p0XkI2n4x_lUkR5a_ahClJeo,5021
11
+ pumpfun_toolkit/risk.py,sha256=qR9tFwH1AnV-yIoHRlchad9yC2c9LPuOwINTNHYyWto,12541
12
+ pumpfun_toolkit/rpc.py,sha256=axRCWjg-Cxp_LDboJ8eKcYZr_hOYxse2g0qPGa7Iedw,16779
13
+ pumpfun_toolkit/text.py,sha256=4Jgm14GwMDK-91nLB43tjx77cRe6rHJ46m3wJSJQ2AA,481
14
+ pumpfun_toolkit-0.1.1.dist-info/METADATA,sha256=L1A2unnJvU9vYLEpzGz7IL8kpKpbMtPxPcHk0xiOX_0,13305
15
+ pumpfun_toolkit-0.1.1.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
16
+ pumpfun_toolkit-0.1.1.dist-info/licenses/LICENSE,sha256=ZZByZB2x2kmTMIjh56X7qJR7xr8Q1JQN4BD_MOmEIw8,1078
17
+ pumpfun_toolkit-0.1.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 abidihassanreza12-svg
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.