Skip to main content

uniswap-python

Build Status License

The unofficial Python client for the Uniswap.

Provided under MIT License by Shane Fontaine.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

I am in no way affiliated with or funded by Uniswap, uniswap.io, or any subsidiaries or affiliates of any of the previously mentioned entities.

Functionality

  • A simple to use Python wrapper for both public and authenticated endpoints.
  • Easy interaction with the Uniswap smart contracts
  • Simple parsing of data returned from the Uniswap contract

Under Development

  • Better error handling
  • Tests

Getting Started

This README is documentation on the syntax of the python client presented in this repository. See function docstrings for full syntax details. This API attempts to present a clean interface to Uniswap, but in order to use it to its full potential, you must familiarize yourself with the official Uniswap documentation.

You may manually install the project or use pip:

pip install uniswap-python

# or

pip install git+git://github.com/shanefontaine/uniswap-python.git

Public Client

Only some endpoints in the API are available to everyone. The public endpoints can be reached using PublicClient

import uniswap
uniswap_wrapper = uniswap.UniswapWrapper()

Market Methods

  • get_fee_maker
uniswap_wrapper.get_fee_maker()
  • get_fee_taker
uniswap_wrapper.get_fee_taker()
# Get the public price for ETH to Token trades with an exact input.
uniswap_wrapper.get_eth_token_input_price('bat', 1*10**18)
uniswap_wrapper.get_eth_token_input_price('dai', 5*10**18)
# Get the public price for token to ETH trades with an exact input.
uniswap_wrapper.get_token_eth_input_price('bat', 1*10**18)
uniswap_wrapper.get_token_eth_input_price('dai', 5*10**18)
# Get the public price for ETH to Token trades with an exact output
uniswap_wrapper.get_eth_token_output_price('bat', 1*10**18)
uniswap_wrapper.get_eth_token_output_price('dai', 5*10**18)
# Get the public price for token to ETH trades with an exact output.
uniswap_wrapper.get_token_eth_output_price('bat', 1*10**18)
uniswap_wrapper.get_token_eth_output_price('dai', 5*10**18)

Testing

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

To run the full test suite and ignore warnings, in the project directory run:

python -m pytest -W ignore::DeprecationWarning

Changelog

0.1.1

  • Major README update

0.1.0

  • Add market endpoints
  • Add tests for market endpoints

Metadata

Release files for uniswap-python 0.1.1

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

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

Download URL uniswap-python-0.1.1.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ea0d6c5aa013744b9751ca1f0f1328937322ea9cfe263906c5a6608d07582eab
BLAKE2b-256 checksum
How to use checksums
7de895080742f2ea8505f085af1e4bf69dbf95ce52d2b88e068118b843e59001
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

Security for uniswap-python 0.1.1

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