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

Quick Install

Using uv (recommended):

uv add dextrades

Or with pip:

pip install dextrades

Platform Support

Pre-built wheels available for:

  • 🍎 macOS: Intel (x86_64) + Apple Silicon (arm64)
  • 🪟 Windows: x64 + x86 (32-bit)
  • 🐍 Python: 3.12 and 3.13

Linux Installation: Due to cryptographic library compilation requirements, Linux users should install from source:

# Install Rust first (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Install from source
pip install dextrades --no-binary=dextrades

Alternatively, use the development Docker setup for a containerized environment.

💻 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.4.tar.gz (105.7 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.4-cp313-cp313-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13Windows x86

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12Windows x86

dextrades-0.1.4-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.4-cp312-cp312-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

dextrades-0.1.4-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.4.tar.gz.

File metadata

  • Download URL: dextrades-0.1.4.tar.gz
  • Upload date:
  • Size: 105.7 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.4.tar.gz
Algorithm Hash digest
SHA256 acdc5b3dd6b147239a2cc4ca475451c2ec6d2897f2f10863f54ea4a1cd7b50ab
MD5 046664636d4bfcd8d1b15eae95b8453a
BLAKE2b-256 5c6026237dfa45b04cec8670d060927c829cb2b5258c2645373e32d15f01016f

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.4.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.4-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: dextrades-0.1.4-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.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 889b2b3188f7a88738dfb257190c1a622ac4573aa0691ffa448e3f40512b547d
MD5 d376fc355f2990f1c1625e8b8fc76c05
BLAKE2b-256 5a708b53330d0767c724e2fe7bc3f2d9f33c5d061dd1f358e097c39efa0f89cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.4-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.4-cp313-cp313-win32.whl.

File metadata

  • Download URL: dextrades-0.1.4-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.4-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 093a2f9b580fe29a0d8229632e730ae8e6bd08f5c2d055b474ce6be77e6fbd0f
MD5 1eb6653df11b743503f172860f2a7272
BLAKE2b-256 3a618c0e7904ce48f2f6e6bcc80b345d2872ef1612238acffb6810e52d736df1

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.4-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.4-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dextrades-0.1.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fe16387450c0ac8f41f32bc455c70c7ed9abffe7b341247f8e1dcfcf4f7a8e6f
MD5 b4880d07c9d662a5a03bbb7695bf5209
BLAKE2b-256 3babb2a94fa385c6f600f393eda6d4cad86d3502d89c15d9e3e2bb5c53ecfc54

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.4-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.4-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for dextrades-0.1.4-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ec86f7d332e02b66c2f35ca2c11dd9414c6559cb9bf3d0839623922475118515
MD5 46471c3b990d470d4cfbd0889ac0dc4a
BLAKE2b-256 1485ac5227d87439f8b198056371305e2d31b8bdef4f7f7157620ba6863b273a

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.4-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.4-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: dextrades-0.1.4-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.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a37a680c6f2ab6e74b95152d3eeb84988633d05c2898556d5f2fbc89a706d97d
MD5 c0e6aed48b31e9579c3d90328ab03c39
BLAKE2b-256 1152df5fa42f501e11df55ed936c2adbcd03a4406edc95db6fbe7c2ebee9659b

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.4-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.4-cp312-cp312-win32.whl.

File metadata

  • Download URL: dextrades-0.1.4-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.4-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 eab61385bef8d9a4852c3bb955a0322717f92920889306a31d3a60b4fe231125
MD5 f7cc004c1d9def51f35f7af127c47af5
BLAKE2b-256 cdf4c502acc268f318633a3664df315262b76cdbc9ecb0420e12ebcfea1d78c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.4-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.4-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for dextrades-0.1.4-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5093933dc9a3da09f5187a07df98786ed4aeeb36021e143ffd10a23dce0b0f6f
MD5 3a4cc012dcda8a50ac74e590979ca29e
BLAKE2b-256 c1f7e06eac22e730898982abe16f036284a3818596daf1e845a073e682c7f551

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.4-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.4-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dextrades-0.1.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 57991141149a4f10d42c268177bbc0e547d77f82af1316172db1f558c27b7fd7
MD5 483218df5b9e1f104894604b4af34fc2
BLAKE2b-256 53f538b45ea7aa8f9a870cee46ad3dd701a0aa1dda529b87b183796108cec886

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.4-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.4-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for dextrades-0.1.4-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 632c13dcd55f0bc8cd45d6d33cdff014a1357a19fbd90f0149c295cce6c90e73
MD5 9fada2f2a0a08d656dda44b4ae63eac0
BLAKE2b-256 724423d2e10e85d24bc8bd34fb536ccd96ca485d29fa861789666a0a54532f0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.4-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