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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13Windows x86

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12Windows x86

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

Uploaded CPython 3.12macOS 11.0+ ARM64

dextrades-0.1.0-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.0.tar.gz.

File metadata

  • Download URL: dextrades-0.1.0.tar.gz
  • Upload date:
  • Size: 104.6 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.0.tar.gz
Algorithm Hash digest
SHA256 2734b173914b6a295464a66e7e401fb8cf0dec24ac875eeda36fb999a53ecf97
MD5 0ba944c19fd3e5b894c481dca16baa0a
BLAKE2b-256 65e522972bc895bf956ac4ffa8786a64535b4520c39f7a13bca1b22aa1f34c4e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: dextrades-0.1.0-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.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d6701587390ddc4328a2326345d1f470fe6658554db6fcc5707a6af77b3c4e26
MD5 88cdc2116b7cb0ed32b2f4023496e010
BLAKE2b-256 c087a83b89786c7b9ba2b27cd42ef1354fcb38a750a4d26b6297fd36d8a6de57

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: dextrades-0.1.0-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.0-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 28d2179fcfd68ac2469edae34be2caf68163f7fe4f21125225d6c3544f019d56
MD5 535b0b50c198d55a9dbbf6d87b21b3af
BLAKE2b-256 d467020db6c635b7778006ba196661aa01c4d987f975209e4b0a6e2ae7c6ed5e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for dextrades-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 95492077ef79ede90b8be90478757b34ce0f263b96867cde00c6f14d79c60a3c
MD5 b506ce01f4c9c673c0f27236996b9948
BLAKE2b-256 50295a81339fdde91083effe3c08dce4b5f9694cae3fa7f2eefc70c1c5f54550

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for dextrades-0.1.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e7d71051e8ff260466265728e29fdbf2da33c3dd40b655d10a72eda7c8362cb2
MD5 5bc8e26bcf3fc5b117a28c2229a67413
BLAKE2b-256 c41f96371229e112845cddd6c1de5cae7ac9330e13368bb422c457eff55ea295

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: dextrades-0.1.0-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.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3903879b1a7bb74e4909f47c294e68ea8503537ecc582571a3ced6f746e6f156
MD5 d1b0c0853ecc4e664117727e69fe5890
BLAKE2b-256 ad815c0dc139ef92d0cc96b8d4d15ed1b495f9a7f906be2821023aec4ef63f45

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: dextrades-0.1.0-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.0-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 eae65a26fbac0c9969bce20a4b4c67e7ce4fcd5d9b485f2d8fa449d986b69132
MD5 f47afa6e17cac62a00b86b4b2b2db473
BLAKE2b-256 24623b5c447169b50ed19e4a511449404e0499daacdd28fd456d3c656fe21443

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for dextrades-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 44433a071e433b27cf014687a39db230e18d890e168d6b6e0b0a401e3e93de28
MD5 8d468ed5f5965d7aa47b0bd5509d5284
BLAKE2b-256 d4ffc7891a77f4a2f7b8aef3025b88355d34df5b918592b361d537de806797a1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for dextrades-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1707b378a4b9c524f38ecbe508465b32209f8db538c76dcc7c581c062cc1e35e
MD5 a2339b66347b65dd6afba0d71d5d94dc
BLAKE2b-256 1856ff0b3331529789acc7057647415bf34ac814d0eddd800ec7a3f627d880b4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for dextrades-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9e927696d8027db201e2188cddc572329e375b482b109f072858336fe0e9f51e
MD5 84b8d41f1ec9573ea00b04ff52625802
BLAKE2b-256 3796a970cab6ef2ae4af780cb476867172146c5cb791b46a9db381d311c1584e

See more details on using hashes here.

Provenance

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