Skip to main content

An unofficial Python wrapper for the Uniswap exchange

Project description


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


  • 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


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


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.
make test

Support our continued work!

You can support us on Gitcoin Grants.




  • Updated dependencies
  • Fixed minor typing issues


  • 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)


  • Bug fix: Update bleach package from 3.1.4 to 3.3.0


  • Bug fix: Use .eth instead of .ens


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


  • Allow kwargs in approved decorator.


  • Add note about Uniswap V2 support


  • Update changelog for PyPi and clean up


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


  • Provide token inputs as addresses instead of names


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


  • Add tests for all types of trades


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


  • Add liquidity tests


  • Add liquidity and ERC20 pool methods


  • Major README update


  • Add market endpoints
  • Add tests for market endpoints

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for uniswap-python, version 0.5.2
Filename, size File type Python version Upload date Hashes
Filename, size uniswap_python-0.5.2-py3-none-any.whl (23.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size uniswap-python-0.5.2.tar.gz (21.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page