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

Uploaded CPython 3.13Windows x86-64

dextrades-0.1.10-cp313-cp313-win32.whl (2.8 MB view details)

Uploaded CPython 3.13Windows x86

dextrades-0.1.10-cp313-cp313-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

dextrades-0.1.10-cp313-cp313-macosx_10_12_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

dextrades-0.1.10-cp312-cp312-win32.whl (2.8 MB view details)

Uploaded CPython 3.12Windows x86

dextrades-0.1.10-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.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

dextrades-0.1.10-cp312-cp312-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

dextrades-0.1.10-cp312-cp312-macosx_10_12_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: dextrades-0.1.10.tar.gz
  • Upload date:
  • Size: 108.3 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.10.tar.gz
Algorithm Hash digest
SHA256 317aebf1965861c509537362a289894d3146ddefcc99056d12be2287680ce267
MD5 8ac618b8ebf7e7b20f11afb89a39d0f6
BLAKE2b-256 8ed6cf2555f43cc9788292e8bae561542a326b602b2122c3efcf0a537230dc75

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: dextrades-0.1.10-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.10-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 97fb3fd90fd4e4b5596d1955deb5877f350619431b374634d2f342e1faecb461
MD5 249359613ffdc8581f368b3b7ba0e8bd
BLAKE2b-256 7624861fce95ec39a99413eda24d0e464addbd101ee9c893c6ef1154ca6bd3e5

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: dextrades-0.1.10-cp313-cp313-win32.whl
  • Upload date:
  • Size: 2.8 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.10-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 6f2b4379b55c282cf21238a092a499b4c91dcd998ab92102dc6c618b2e0f1e48
MD5 7a61bbf7b43352342a9c7cefb9915f4a
BLAKE2b-256 13de96f072fda5e346fb1659278f58a5dc23948576a483dee08274cde2d31888

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for dextrades-0.1.10-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 48d26fd60eeb4b863f9499ef880b696a3f1b06e831512283c8c46ef6ada9dea6
MD5 7d1d24b47f442aa6cbbccfae682ac633
BLAKE2b-256 dea7ad01c35e098208d5cdb1d10182bb480bc73aa9fe9ca401cd91a72a66526f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for dextrades-0.1.10-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 86925e1988379f5d3dc59c02ee5c99c3ef3215a83c7cdd07129e218509148347
MD5 dd61d53cf687fda4c165061a577c71f0
BLAKE2b-256 6cc0a492c7b1799469454367268da2eaacd393ff9a6e6de7af27067176abcff4

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: dextrades-0.1.10-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.10-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 eb50db06daae9128102c1f888fdbf1ed72d0dfd867ffbee97f3f897d571a7a77
MD5 d6e11ff204713bd9d929f65ee7d27985
BLAKE2b-256 6616e92d5469bdc161b992d48e466db1f64007039fbfd91168e937017e833ba6

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: dextrades-0.1.10-cp312-cp312-win32.whl
  • Upload date:
  • Size: 2.8 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.10-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 7843e8161cec47ee0378b80fb98a7a996770223d76bb1fdb2229060295845bde
MD5 89321a9912fa6a87edc7f43186f5f11e
BLAKE2b-256 b509e76d51bb31a3190ca070413d41cdf8545bceef1dd7baa82b06fc1048427a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for dextrades-0.1.10-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 16f6a48f76195c2214d9052791c8dd87bb1d970c01bf8896a070370463d8f4a0
MD5 b86defd93fafc61168dbdec927e0f1b1
BLAKE2b-256 591d4d8ea8e48529fcee4ecb3afc54ca846cefee34b207e2402d87c036fd18bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.10-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.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for dextrades-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5b0e04483162e9ca23ee43e2892af6bf024505964616eb8c05ee26797144e708
MD5 baff579f0f9ea5a9511d19349dc9315f
BLAKE2b-256 a4434b9860f1e196b3f89190e77fb258ae9c453c6eb94738bbacf55ecbff4843

See more details on using hashes here.

Provenance

The following attestation bundles were made for dextrades-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_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.10-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dextrades-0.1.10-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7e96991d6f7d87a94a4ce47ea6e2519453c120b86f4875b5ac97645991d81e84
MD5 80aa6bdc145606fad7156bee6da45236
BLAKE2b-256 0153422db70d301352bac7e38eecb61bfe1386001db5f627e9e230720be724dd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for dextrades-0.1.10-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9a6f6cfb642b9b84359cd9765356f482a0ffa76547e7f98ef062ac4b386693bb
MD5 ad380314e8f905022475a171a8b06485
BLAKE2b-256 d4bce870fc112c6f758f036423e30d5305d6043897e5557a20b03ee278e38d77

See more details on using hashes here.

Provenance

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