DexTrades 🦄
A Python library for streaming DEX trades from RPC nodes.
✨ Features
-
Direct On-Chain Data: Pulls event logs directly from a given RPC URL, requiring no indexers or third-party APIs. It currently decodes swaps from Uniswap V2 and V3.
-
Data Enrichment Pipeline: The library can enrich raw log data with:
- Token metadata (symbols, decimals) for readable amounts.
- Block timestamps for each swap.
- USD values calculated using Chainlink ETH/USD price feeds at the swap's block height.
-
Rust Core: Built with a Rust backend (
PyO3,alloy) for processing. It implements RPC provider racing, a circuit breaker, and automatic retries for connection resilience. -
Friendly Python API: Provides an
asyncgenerator to stream trades. Enrichments are controlled via boolean flags. Supports streaming individual swaps or Apache Arrow batches.
📦 Installation
Using uv (recommended):
uv add dextrades
Or with pip:
pip install dextrades
💻 Usage
The Client manages connections to one or more RPC endpoints. The stream_swaps method returns an async iterator of swap events.
import asyncio
import dextrades
urls = [
"https://eth-pokt.nodies.app",
"https://ethereum.publicnode.com",
]
with dextrades.Client(urls) as client:
# Stream a small block range; normalized token amounts included
async for swap in client.stream_swaps(
["uniswap_v2", "uniswap_v3"],
17000003, 17000003,
batch_size=1,
enrich_timestamps=True,
enrich_usd=True,
):
print(
swap.get("dex_protocol"),
swap.get("token_sold_symbol"), swap.get("token_sold_amount"),
"→",
swap.get("token_bought_symbol"), swap.get("token_bought_amount"),
"USD:", swap.get("value_usd"),
)
Example Output
time dex bought sold value_usd trader hash
-----------------------------------------------------------------------------------------------------------------------------
2023-04-08 01:58:47 Uniswap V2 0.0529 WETH 98.9990 USDC $99.00 0x5eA7 0x37f7
2023-04-08 01:58:47 Uniswap V2 0.0398 XMON 0.0529 WETH $98.63 0x5eA7 0x37f7
2023-04-08 01:58:47 Uniswap V2 0.0452 WETH 0.7000 QNT $84.38 0x4a30 0x5428
2023-04-08 01:58:47 Uniswap V2 3.2402 WETH 2.9994 PAXG $6,045.62 0xdBC2 0x8f46
📊 Available Fields
| Enricher | Fields Added | Description |
|---|---|---|
| Core | block_number, tx_hash, log_index, dex_protocol, pool_address |
Always present |
| transaction | tx_from, tx_to, gas_used |
Transaction context |
| timestamp | block_timestamp |
Block mining time |
| token_metadata | token0_address, token1_address, token0_symbol, token1_symbol, token0_decimals, token1_decimals |
Token information |
| swap | token_bought_address, token_sold_address, token_bought_symbol, token_sold_symbol, token_bought_amount, token_sold_amount, token_bought_amount_raw, token_sold_amount_raw |
Trade direction & amounts |
| price_usd | value_usd, value_usd_method, chainlink_updated_at |
USD valuation (stablecoins + Chainlink ETH/USD) |
Network overrides (generic per-chain pricing)
Provide network-specific overrides at client initialization to make USD pricing and warmup work on non-mainnet chains.
overrides = {
# Wrapped native token address (e.g., WETH, wCAMP)
"native_wrapped": "0x4200000000000000000000000000000000000006",
# Chainlink-style native/USD aggregator (optional)
# "native_usd_aggregator": "0x...",
# Stablecoin addresses to treat as USD stables on this network
"stable_addresses": [
# "0x...", "0x..."
],
# Optional warmup tokens that exist on the current network (avoid noisy warmup logs)
"warmup_tokens": []
}
with dextrades.Client(["<rpc-url>"], network_overrides=overrides) as client:
async for swap in client.stream_swaps(["uniswap_v2", "uniswap_v3"], 100, 100, enrich_usd=True):
...
If no per-network aggregator is provided, USD pricing falls back to:
- Stablecoin passthrough (by address or common stable symbols)
- Native/USD via Chainlink only on Ethereum mainnet (default mainnet aggregator)
Router filter (optional)
Filter to SmartRouter transactions only:
async for swap in client.stream_swaps(["uniswap_v2","uniswap_v3"], 100, 100, routers=["0xRouter..."]):
...
# Also available for individual streaming:
client.stream_individual_swaps(["uniswap_v2","uniswap_v3"], 100, 100, routers=["0xRouter..."])
🗺️ Roadmap
- Uniswap V2
- Uniswap V3
- and deduplication
- Enrichments:
- token metadata
- trade direction
- timestamps
- USD values via Chainlink
- USD values via stablecoin passthrough
- RPC provider
- racing
- retries
- circuit breakers
- sharded
getLogs
- Python API
- CLI
- example and demo
- benchmarks
- additional enrichments:
- trader balance
- Uniswap V3 Quoter fallback for non-WETH/stable tokens
- Chainlink Feed Registry (USD feeds) and multi-chain aggregator addresses
- CLI UX polish (enrichment flags, simple table mode)
- Light metrics: stage counters and provider health snapshot
- Additional DEX protocols
- Optional persistent caches and Parquet/Polars export helpers
Metadata
Release files for dextrades 0.1.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dextrades-0.1.12.tar.gz | 113.7 kB | With provenance | Details for dextrades-0.1.12.tar.gz |
Built distributions (wheels)
Total release size: 30.3 MB
Release files / dextrades-0.1.12.tar.gz
| Download URL | dextrades-0.1.12.tar.gz |
|---|---|
| Size | 113.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e62396e6491734f71859318c1444b4945177396183adbe9c36add8a378c448f1
|
|
BLAKE2b-256 checksum How to use checksums |
5c7c0802faad671db7de4796463ab11478e0b764efaee7d48c8863e08d6c426b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2025.
Transparency logRelease files / dextrades-0.1.12-cp313-cp313-win_amd64.whl
| Download URL | dextrades-0.1.12-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 3.2 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
e279cf3a7c26a130298a498d5ef8e5c50fcb4ed136b5b8f7aa27cb504a6da4a8
|
|
BLAKE2b-256 checksum How to use checksums |
c7e5d7fa6b360f7df83f1e25e07a50eb35e83062bfaa255c295b2520ddcb9c7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2025.
Transparency logRelease files / dextrades-0.1.12-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | dextrades-0.1.12-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d0097c84952cd5917a3f4caa2accc13e39074c5d3ac8d73debd5ddcb402373dd
|
|
BLAKE2b-256 checksum How to use checksums |
7e24c9ad740e44e1d75e7c9031bd86e7e5397b3a18eee8c916261068c6d403b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2025.
Transparency logRelease files / dextrades-0.1.12-cp313-cp313-macosx_10_12_x86_64.whl
| Download URL | dextrades-0.1.12-cp313-cp313-macosx_10_12_x86_64.whl |
|---|---|
| Size | 3.6 MB |
| Tags | CPython 3.13 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
af6e69a86f865e96437de7a2e89498ac752d7d8e82103d533110de5517723b15
|
|
BLAKE2b-256 checksum How to use checksums |
3e712fa891a2df23d449693bd0d3b812da78e1407aece54b79a5584699cf5bd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2025.
Transparency logRelease files / dextrades-0.1.12-cp312-cp312-win_amd64.whl
| Download URL | dextrades-0.1.12-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 3.2 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ac8b5712e895fdbe2fe1838647a4ace505b05795b065511557a7712fa42defb4
|
|
BLAKE2b-256 checksum How to use checksums |
587d7bc164642f0b96a6b29d1ef52b5e0d69af74cb1aa5a13a84daf914e9bda1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2025.
Transparency logRelease files / dextrades-0.1.12-cp312-cp312-manylinux_2_34_x86_64.whl
| Download URL | dextrades-0.1.12-cp312-cp312-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 6.1 MB |
| Tags | CPython 3.12 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
0b07b4d6f56964a40ecb00701473052cb37a30bd43460d44856cd2191c41ab8a
|
|
BLAKE2b-256 checksum How to use checksums |
23154edc5d389cc60a9ba0e5b4a6fde7ca6cc47c14c6d157577a935bd76b72c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2025.
Transparency logRelease files / dextrades-0.1.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | dextrades-0.1.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 3.8 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
c739cb01b83f1fb674746416a5942bff4d9ba98386bc805a10c55efcf16c3da7
|
|
BLAKE2b-256 checksum How to use checksums |
fd2f5355e56324cfce41f90f04517556bdd1ee24fc0dd037efb3524e0b4f847e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2025.
Transparency logRelease files / dextrades-0.1.12-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | dextrades-0.1.12-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3a14f3c86bafe30fb032ce79e7b46472faa70b69dac6de28f6f0e31a9aec30e1
|
|
BLAKE2b-256 checksum How to use checksums |
a6ea344d34b9ffa073a1feadb87b1b7666d664bed53c92fc6254ec3543153232
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2025.
Transparency logRelease files / dextrades-0.1.12-cp312-cp312-macosx_10_12_x86_64.whl
| Download URL | dextrades-0.1.12-cp312-cp312-macosx_10_12_x86_64.whl |
|---|---|
| Size | 3.6 MB |
| Tags | CPython 3.12 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
cf83e181a9f76aaedf89c2e12d0bc40a3b87fa5bd1f045aedfd55ae2d1a54b05
|
|
BLAKE2b-256 checksum How to use checksums |
650d09880076289b2c9f1bb790843dd60f8e19e5bc38212f4e8a488234c4cbc6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2025.
Transparency logSecurity for dextrades 0.1.12
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.
Full provenance
All 9 files in this release have been uploaded with provenance metadata.
Attestation for dextrades-0.1.12.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2025.
Transparency logA 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.