Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Docs

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip poetry
poetry install
- name: Docs
run: |
poetry run make docs
- name: Upload build
uses: actions/upload-artifact@v2-preview
with:
name: build
path: docs/_build
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/master'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/_build
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: test typecheck lint precommit
.PHONY: test typecheck lint precommit docs

test:
poetry run pytest -v --cov=uniswap --cov-report html
Expand All @@ -13,3 +13,6 @@ precommit:
make typecheck
make lint
make test

docs:
cd docs/ && make html
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ PROVIDER # HTTP Provider for web3

### Gas pricing

To modify the gas pricing strategy you need to pass a custom `Web3` instance to the `Uniswap` contructor. You can find details for how to configure Web3 gas strategies in their [documentation](https://web3py.readthedocs.io/en/stable/gas_price.html).
To modify the gas pricing strategy you need to pass a custom `Web3` instance to the `Uniswap` constructor. You can find details for how to configure Web3 gas strategies in their [documentation](https://web3py.readthedocs.io/en/stable/gas_price.html).

### Examples and API

**Note:** These examples are in the process of being moved to the [docs](https://shanefontaine.github.io/uniswap-python/).

The `Uniswap` class takes several optional parameters, read the code to see which ones are available.

```python
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
17 changes: 17 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
API Reference
=============

.. automodule:: uniswap

Uniswap class
-------------

.. autoclass:: Uniswap
:members:

Exceptions
----------

.. autoexception:: InvalidToken

.. autoexception:: InsufficientBalance
65 changes: 65 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys

sys.path.insert(0, os.path.abspath(".."))


# -- Project information -----------------------------------------------------

project = "uniswap-python"
copyright = "2021, Shane Fontaine, Erik Bjäreholt"
author = "Shane Fontaine, Erik Bjäreholt"


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ["sphinx.ext.autodoc"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_book_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

html_theme_options = {
"repository_url": "https://github.com/shanefontaine/uniswap-python",
"path_to_docs": "docs",
"use_repository_button": True,
"use_edit_page_button": True,
}


# Autodoc config

autoclass_content = "both"
autodoc_member_order = "bysource"
27 changes: 27 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Examples
========

Initializing the Uniswap class
------------------------------

.. code:: python
from uniswap import Uniswap
address = "YOUR ADDRESS" # or "0x0000000000000000000000000000000000000000", if you're not making transactions
private_key = "YOUR PRIVATE KEY" # or None, if you're not going to make transactions
uniswap = Uniswap(address, private_key, version=2) # pass version=2 to use Uniswap v2
eth = "0x0000000000000000000000000000000000000000"
bat = "0x0D8775F648430679A709E98d2b0Cb6250d2887EF"
dai = "0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359"



Getting prices
--------------

TODO


Making trades
-------------

TODO
6 changes: 6 additions & 0 deletions docs/forks.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Using uniswap-python for Uniswap forks
======================================

While not officially supported, you can use this library to trade across several Uniswap forks like Sushiswap (mainnet), Honeyswap (xDai), Pancakeswap (BSC), etc.


30 changes: 30 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.. uniswap-python documentation master file, created by
sphinx-quickstart on Tue May 4 11:20:21 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to uniswap-python's documentation!
==========================================

.. image:: https://user-images.githubusercontent.com/9441295/107376524-d96b5880-6a9e-11eb-9eba-094c439cfb07.png
:width: 350
:alt: uniswap-python logo
:align: center

**Note:** We're in the process of improving the documentation of the project. You will find some docs here, but there's also some documentation in the README that you might want to look at.

.. toctree::
:maxdepth: 2
:caption: Contents:

api
examples
forks


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
Loading