Skip to main content

High-performance DEX swap streaming and analysis (Rust/PyO3)

Project description


DexTrades 🦄

A Python library for streaming DEX trades from RPC nodes.

PyPI License: MIT

✨ 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 async generator 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

🗺️ 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

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

dextrades-0.1.1.tar.gz (104.5 kB view details)

Uploaded Source

Built Distributions

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

dextrades-0.1.1-cp313-cp313-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.13Windows x86-64

dextrades-0.1.1-cp313-cp313-win32.whl (2.9 MB view details)

Uploaded CPython 3.13Windows x86

dextrades-0.1.1-cp313-cp313-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

dextrades-0.1.1-cp313-cp313-macosx_10_12_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

dextrades-0.1.1-cp312-cp312-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.12Windows x86-64

dextrades-0.1.1-cp312-cp312-win32.whl (2.9 MB view details)

Uploaded CPython 3.12Windows x86

dextrades-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl (6.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

dextrades-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

dextrades-0.1.1-cp312-cp312-macosx_10_12_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

Details for the file dextrades-0.1.1.tar.gz.

File metadata

  • Download URL: dextrades-0.1.1.tar.gz
  • Upload date:
  • Size: 104.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dextrades-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5c1e3ad0a187a36605c9a9473d29da2f260514496ca250f88e82b1a5b45d73db
MD5 83c7088785bcd9037cf099975200a9f5
BLAKE2b-256 6017168b916bedabdeedf4e147f6f714cb9610217afdc9bf9c3291b3180bd429

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.1.tar.gz:

Publisher: release.yml on elyase/dextrades

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dextrades-0.1.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: dextrades-0.1.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.1 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dextrades-0.1.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 54507c9fe7cde26a80a4459816e621edc9bf8c140c1a8ff660bdf6d4de7241f5
MD5 d283f8d487762864c3becd5f7eaf5651
BLAKE2b-256 0790fbff05ae1c9d3bf605b137ffbd336daefc4476d75b3bfedc702010dc1053

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.1-cp313-cp313-win_amd64.whl:

Publisher: release.yml on elyase/dextrades

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dextrades-0.1.1-cp313-cp313-win32.whl.

File metadata

  • Download URL: dextrades-0.1.1-cp313-cp313-win32.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.13, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dextrades-0.1.1-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 29c0f4d9441a0a0608b565d2ee9142aca7c6cf86a255fe2e6ec8ade09f55b9a3
MD5 6bff7b9ee49c2928ddc9f1bfa36d83f5
BLAKE2b-256 819bf679eb91896f67ab98ad5e92a502754e8a6ba02bdc4f74bc5d29280fe60a

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.1-cp313-cp313-win32.whl:

Publisher: release.yml on elyase/dextrades

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dextrades-0.1.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dextrades-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bdb95c45bc3063063239fbdd5cab382d52c9f1c313eec8808493ee5bfcc70b6f
MD5 c11736a44c8303eccc734dc4567fd5fb
BLAKE2b-256 6c1066b79ea4b27ad181531ce07f3151d3f85a4359b7aad124d96c1c90484091

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on elyase/dextrades

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dextrades-0.1.1-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for dextrades-0.1.1-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 54c85ff8cfa3af4b64b24ade8318ca203fd7c310981186a8e4863e148641b14d
MD5 f92cd6ae4dc1b13f419a03eb853df31e
BLAKE2b-256 6b2ffb701eae06c905d298ea31a310b918029e3a301ae315836b7a8ef2b187ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.1-cp313-cp313-macosx_10_12_x86_64.whl:

Publisher: release.yml on elyase/dextrades

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dextrades-0.1.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: dextrades-0.1.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.1 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dextrades-0.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a5dd46e67728aa3574587d10f25829430aefa882884308816e4a3972153841fb
MD5 85d2aa90be8c40722850fe85dc90b6c6
BLAKE2b-256 8f7c5093205985967e993ab9fad6730edaaf800866ae6640d60d2c20ae616626

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.1-cp312-cp312-win_amd64.whl:

Publisher: release.yml on elyase/dextrades

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dextrades-0.1.1-cp312-cp312-win32.whl.

File metadata

  • Download URL: dextrades-0.1.1-cp312-cp312-win32.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.12, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dextrades-0.1.1-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 354d0bd8c321be2015b23951e7eb608dcadba3ae79334106ad607faa3415ac76
MD5 be457960ff2572afd65e7a18f1a44d68
BLAKE2b-256 4e3fb2de1d0263620380f710efb365c32fab776b111cac8eb000d25652106417

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.1-cp312-cp312-win32.whl:

Publisher: release.yml on elyase/dextrades

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dextrades-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for dextrades-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d1734d0dc14a88e55265bf14beaeb35e36602f498d81de4f3c06be045aa5e32f
MD5 9f57fc329783694bd51d2d5e91306002
BLAKE2b-256 6c19f9313c347c98884fe7b5b6151f4ae20fcbbec71f59e3257ab6997b713955

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: release.yml on elyase/dextrades

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dextrades-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dextrades-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6a2e6d93db944dee970eef2deb78b0426b1b7c4d47b19ac18f5e3b34f6b65139
MD5 b639e2b255a8538d39f8f419fe5f7cb6
BLAKE2b-256 ff29118b838534021989250f33f0e82fcc2713d2d24218fa8186eb6ca4839e0f

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on elyase/dextrades

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dextrades-0.1.1-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for dextrades-0.1.1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3aafb46da9aae8170436e8ddeb0b5797b2e8f401723c724f019c6f0f12b54041
MD5 8b3738abb17df750bf089e5dfbe70935
BLAKE2b-256 bbfd97864fc140026076246f009cc1a6213ef0aa66b0d0df93e26ec4d3dae813

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.1-cp312-cp312-macosx_10_12_x86_64.whl:

Publisher: release.yml on elyase/dextrades

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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