Skip to main content

uniswap-viewer

A lightweight Python library for accessing Uniswap V3 on-chain data.

uniswap-viewer provides a clean and efficient interface for reading price and tick information directly from Uniswap V3 smart contracts using web3.py. It supports both synchronous and asynchronous workflows and is ideal for developers, analysts, and algorithmic traders.

Features

  • Supports both sync and async Web3 clients
  • Fetches token prices using sqrtPriceX96 and token decimals
  • Retrieves detailed tick data via ABI-decoded contract calls
  • Computes tick index, tick spacing, and tick slot
  • Includes block streaming generator to track new blocks in real time
  • Built-in utilities for loading ABIs and checking Ethereum addresses

Modules

  • viewer_sync.py – synchronous Uniswap V3 viewer using web3.Web3
  • viewer_async.py – asynchronous Uniswap V3 viewer using web3.AsyncWeb3
  • utils.py – helper functions (ABI loading, tick keys, address filters)

Usage

Sync example

from uniswap_viewer import ViewerSync
from web3 import Web3

w3 = Web3(Web3.HTTPProvider("<your_provider_url>"))

viewer = ViewerSync(w3, "usdt", "weth", fee=3000)
viewer.init()

price = viewer.get_price()

tick = viewer.calc_tick(price, normalize=True)
tick_data = viewer.get_tick_data(tick)
liquidity = tick_data['liquidityGross']

Async example

from uniswap_viewer import ViewerAsync
from web3 import AsyncWeb3

w3 = AsyncWeb3(AsyncWeb3.AsyncHTTPProvider("<your_provider_url>"))

viewer = ViewerAsync(w3, "usdt", "weth", fee=3000)
await viewer.init()

price = await viewer.get_price()

tick = viewer.calc_tick(price, normalize=True)
tick_data = await viewer.get_tick_data(tick)
liquidity = tick_data['liquidityGross']

Stream example

from uniswap_viewer.viewer_async import Viewer as ViewerAsync, stream_new_blocks
from web3 import AsyncWeb3

w3 = AsyncWeb3(AsyncWeb3.AsyncHTTPProvider("<your_provider_url>"))

viewer = ViewerAsync(w3, "usdt", "weth", fee=3000)
await viewer.init()

async for block_num in stream_new_blocks(w3, timeout=3):
    price = await viewer.get_price(block_num=block_num)

    tick = viewer.calc_tick(price, normalize=True)
    tick_data = await viewer.get_tick_data(tick, block_num=block_num)
    liquidity = tick_data['liquidityGross']

    print(price, liquidity)

Requirements

  • Python 3.8+
  • web3 library (sync or async)

Motivation

This library is designed for:

  • Developers integrating Uniswap data directly from the blockchain
  • Quants and analysts building custom tooling
  • Avoiding reliance on third-party APIs like The Graph

License

MIT

Metadata

Release files for uniswap-viewer 0.1.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for uniswap-viewer 0.1.10
File Size Uploaded Provenance
uniswap_viewer-0.1.10.tar.gz 9.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for uniswap-viewer 0.1.10
File Interpreter ABI Platform
uniswap_viewer-0.1.10-py3-none-any.whl Python 3 none any Details

Total release size: 22.6 kB

Release files / uniswap_viewer-0.1.10.tar.gz

Download URL uniswap_viewer-0.1.10.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f34c130d268299119899842740a2b552f4998445d5f32645b09e713487c4b2f5
BLAKE2b-256 checksum
How to use checksums
728d612c1377949216004d9d54f2ee556a06cf653ade9829efd78725f1038638
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / uniswap_viewer-0.1.10-py3-none-any.whl

Download URL uniswap_viewer-0.1.10-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f89788ea983024cc1f6f3c92923e7016a05059e35c21cd68218a8ea96545f44b
BLAKE2b-256 checksum
How to use checksums
8213e641fe934422d8cbae54bb81a05b81b3baa0f4501caa77ff7eeff92e178f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Security for uniswap-viewer 0.1.10

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page