Skip to main content

uniswap-python

GitHub Actions codecov Downloads License PyPI Typechecking: Mypy Code style: black

GitHub Repo stars Twitter Follow

The unofficial Python client for Uniswap.

Documentation is available at https://uniswap-python.com/

Functionality

  • A simple to use Python wrapper for all available contract functions and variables
  • A basic CLI to get prices and token metadata
  • Simple parsing of data returned from the Uniswap contract

Supports

  • Uniswap v3 (experimental, in master)
  • Uniswap v2 (as of v0.4.0)
  • Uniswap v1 (deprecated)
  • Various forks (untested, but should work)
    • Honeyswap (xDai)
    • Pancakeswap (BSC)
    • Sushiswap (mainnet)

Getting Started

See our Getting started guide in the documentation.

Testing

Unit tests are under development using the pytest framework. Contributions are welcome!

Test are run on a fork of the main net using ganache-cli. You need to install it with npm install -g ganache-cli before running tests.

To run the full test suite, in the project directory set the PROVIDER env variable to a mainnet provider, and run:

poetry install
export PROVIDER= # URL of provider, e.g. https://mainnet.infura.io/v3/...
make test

Authors

Changelog

0.5.0

  • Basic support for Uniswap V3
  • Added new methods get_price_input and get_price_output
  • Made a lot of previously public methods private
  • Added documentation site
  • Removed ENS support (which was probably broken to begin with)

0.4.6

  • Bug fix: Update bleach package from 3.1.4 to 3.3.0

0.4.5

  • Bug fix: Use .eth instead of .ens

0.4.4

  • General: Add new logo for Uniswap V2
  • Bug fix: Invalid balance check (#25)
  • Bug fix: Fixed error when passing WETH as token

0.4.3

  • Allow kwargs in approved decorator.

0.4.2

  • Add note about Uniswap V2 support

0.4.1

  • Update changelog for PyPi and clean up

0.4.0

A huge thank you Erik Bjäreholt for adding Uniswap V2 support, as well as all changes in this version!

  • Added support for Uniswap v2
  • Handle arbitrary tokens (by address) using the factory contract
  • Switched from setup.py to pyproject.toml/poetry
  • Switched from Travis to GitHub Actions
  • For CI to work in your repo, you need to set the secret MAINNET_PROVIDER. I use Infura.
  • Running tests on a local fork of mainnet using ganache-cli (started as a fixture)
  • Fixed tests for make_trade and make_trade_output
  • Added type annotations to the entire codebase and check them with mypy in CI
  • Formatted entire codebase with black
  • Moved stuff around such that the basic import becomes from uniswap import Uniswap (instead of from uniswap.uniswap import UniswapWrapper)
  • Fixed misc bugs

0.3.3

  • Provide token inputs as addresses instead of names

0.3.2

  • Add ability to transfer tokens after a trade
  • Add tests for this new functionality

0.3.1

  • Add tests for all types of trades

0.3.0

  • Add ability to make all types of trades
  • Add example to README

0.2.1

  • Add liquidity tests

0.2.0

  • Add liquidity and ERC20 pool methods

0.1.1

  • Major README update

0.1.0

  • Add market endpoints
  • Add tests for market endpoints

Metadata

Release files for uniswap-python 0.5.0

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-python 0.5.0
File Size Uploaded Provenance Actions
uniswap-python-0.5.0.tar.gz 21.3 kB Without provenance Details for uniswap-python-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for uniswap-python 0.5.0
File Interpreter ABI Platform Actions
uniswap_python-0.5.0-py3-none-any.whl Python 3 none any Details for uniswap_python-0.5.0-py3-none-any.whl

Total release size: 44.7 kB

Release files / uniswap-python-0.5.0.tar.gz

Download URL uniswap-python-0.5.0.tar.gz
Size 21.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a915a6baf5a289807d535b9db230dce66b346d9e84b3db7fed2e9d26a143af85
BLAKE2b-256 checksum
How to use checksums
e8fb2b0e1633a3e15fbbc3c034086a5af13ed1f3b3871a14f6a54ef2c9d5610b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.9.5 Linux/5.12.4-arch1-2

Release files / uniswap_python-0.5.0-py3-none-any.whl

Download URL uniswap_python-0.5.0-py3-none-any.whl
Size 23.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e6c75183ab13decd86ad7b3a6d0c2f708ed5960eb128b682dcf282d3d63caa0e
BLAKE2b-256 checksum
How to use checksums
030b8c9ae95df0b156c829d24a1c91d2fd5085ddaa3d65df8e2e0092b014ee10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.9.5 Linux/5.12.4-arch1-2

Security for uniswap-python 0.5.0

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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