{"id":34507943,"url":"https://github.com/elnaril/python-uniswapx-sdk","last_synced_at":"2025-12-24T03:14:32.063Z","repository":{"id":214218529,"uuid":"735107608","full_name":"Elnaril/python-uniswapx-sdk","owner":"Elnaril","description":"Python SDK for UniswapX","archived":false,"fork":false,"pushed_at":"2024-01-09T12:45:41.000Z","size":77,"stargazers_count":5,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-25T02:53:56.718Z","etag":null,"topics":["codec","defi","dex","ethereum","ethereum-dapp","python","sdk-python","trading","uniswap"],"latest_commit_sha":null,"homepage":"https://www.buymeacoffee.com/elnaril","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Elnaril.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"Elnaril","custom":["https://www.buymeacoffee.com/elnaril","https://www.fiverr.com/freelancers/elnaril"]}},"created_at":"2023-12-23T17:31:48.000Z","updated_at":"2024-12-30T09:15:31.000Z","dependencies_parsed_at":"2024-01-04T16:49:07.177Z","dependency_job_id":null,"html_url":"https://github.com/Elnaril/python-uniswapx-sdk","commit_stats":null,"previous_names":["elnaril/python-uniswapx-sdk"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Elnaril/python-uniswapx-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Elnaril%2Fpython-uniswapx-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Elnaril%2Fpython-uniswapx-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Elnaril%2Fpython-uniswapx-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Elnaril%2Fpython-uniswapx-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Elnaril","download_url":"https://codeload.github.com/Elnaril/python-uniswapx-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Elnaril%2Fpython-uniswapx-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27994386,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codec","defi","dex","ethereum","ethereum-dapp","python","sdk-python","trading","uniswap"],"created_at":"2025-12-24T03:14:26.938Z","updated_at":"2025-12-24T03:14:32.054Z","avatar_url":"https://github.com/Elnaril.png","language":"Python","readme":"# Python UniswapX SDK\n\n---\n\n#### Project Information\n[![Tests \u0026 Lint](https://github.com/Elnaril/python-uniswapx-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/Elnaril/python-uniswapx-sdk/actions/workflows/ci.yml)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/uniswapx-sdk)](https://pypi.org/project/python-uniswapx-sdk/)\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/Elnaril/python-uniswapx-sdk)](https://github.com/Elnaril/python-uniswapx-sdk/releases)\n[![PyPi Repository](https://img.shields.io/badge/repository-pipy.org-blue)](https://pypi.org/project/python-uniswapx-sdk/)\n[![GitHub](https://img.shields.io/github/license/Elnaril/python-uniswapx-sdk)](https://github.com/Elnaril/python-uniswapx-sdk/blob/master/LICENSE)\n\n#### Code Quality\n[![CodeQL](https://github.com/elnaril/python-uniswapx-sdk/workflows/CodeQL/badge.svg)](https://github.com/Elnaril/python-uniswapx-sdk/actions/workflows/codeql.yml)\n[![Test Coverage](https://img.shields.io/badge/dynamic/json?color=blueviolet\u0026label=coverage\u0026query=%24.totals.percent_covered_display\u0026suffix=%25\u0026url=https%3A%2F%2Fraw.githubusercontent.com%2FElnaril%2Fpython-uniswapx-sdk%2Fmaster%2Fcoverage.json)](https://github.com/Elnaril/python-uniswapx-sdk/blob/master/coverage.json)\n[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat\u0026labelColor=ef8336)](https://pycqa.github.io/isort/)\n[![Type Checker: mypy](https://img.shields.io/badge/%20type%20checker-mypy-%231674b1?style=flat\u0026labelColor=ef8336)](https://mypy-lang.org/)\n[![Linter: flake8](https://img.shields.io/badge/%20linter-flake8-%231674b1?style=flat\u0026labelColor=ef8336)](https://flake8.pycqa.org/en/latest/)\n\n---\n\n## Release Notes\n### V0.0.2\n - Exclusive Dutch Order Encoder\n - Reactor Execute Encoder\n - Get Orders from UniswapX API\n - Integration Tests\n - Documentation\n### V0.0.1\n - Exclusive Dutch Order Decoder\n - Order Resolver\n\n---\n\n## Overview and Points of Attention\nThis library is a Python SDK that can be used to easily interact with UniswapX ecosystem: Reactors, Quoter, API.\nIt's partially inspired by https://github.com/Uniswap/uniswapx-sdk\n\n⚠ This library has not been audited, so use at your own risk !\n\n⚠ The API currently exposed is very likely to change with the following versions: consider forcing the version.\n\n⚠ This project is a work in progress so not all features have already been implemented.\n\n---\n\n## Installation\nA good practice is to use [Python virtual environments](https://python.readthedocs.io/en/latest/library/venv.html), here is a [tutorial](https://www.freecodecamp.org/news/how-to-setup-virtual-environments-in-python/).\n\nThe library can be pip installed from [pypi.org](https://pypi.org/project/uniswapx-sdk/) as usual:\n\n```bash\n# update pip to latest version if needed\npip install -U pip\n\n# install the decoder from pypi.org\npip install uniswapx-sdk\n```\n\n---\n\n## Usage\n\n### How to encode an Exclusive Ducth Order\nFirst, you need to import the classes that will help you to structure the encoding, along with a function that will compute the order nonce: \n```python\nfrom uniswapx_sdk.encoder import (\n    DecayTime,    \n    ExclusiveDutchOrderInfo,\n    ExclusiveDutchOrderInput,\n    ExclusiveDutchOrderOutput,\n    ExclusiveFiller,\n    get_nonce,\n)\n```\n\nThen you instantiate them:\n```python\norder_info = ExclusiveDutchOrderInfo(\n    reactor=\"0x6000da47483062a0d734ba3dc7576ce6a0b645c4\",\n    swapper=\"0x...\",  # your account address\n    nonce=get_nonce(),\n    deadline=deadline,  # Unix timestamp after which the order won't be valid any more.\n)\n\ndecay_time = DecayTime(start_timestamp, end_timestamp)\n\ndutch_input = ExclusiveDutchOrderInput(in_token_address, start_amount_in_wei, end_amount_in_wei)\n\ndutch_outputs = (\n    ExclusiveDutchOrderOutput(\n        token=out_token_address,  # or '0x0000000000000000000000000000000000000000' for native coin\n        start_amount=start_amount_in_wei,\n        end_amount=end_amount_in_wei,\n        recipient=recipient_address,  # who is going to receive the output\n    ),\n)\n\nexclusive_filler = ExclusiveFiller(filler_address, bps)  # the exclusive filler if any with the override bps\n#  or exclusive_filler = ExclusiveFiller() if no exclusive filler\n```\n\nAnd now you're ready to encode the order and sign it:\n```python\nimport ExclusiveDutchOrderEncoder\n\nencoder = ExclusiveDutchOrderEncoder(chain_id)\nencoded_order, signable_message = encoder.encode_order(\n    order_info,\n    decay_time,\n    dutch_input,\n    dutch_outputs,\n    exclusive_filler\n)\nsigned_message = your_account.sign_message(signable_message)\n```\n\n### How to resolve/validate/quote an order\nLet's say you have en encoded `order` along with its signature `sig`. Resolving it is as simple as:\n\n```python\nfrom uniswapx_sdk.resolver import OrderResolver\n\nresolver = await OrderResolver.create(rpc_endpoint=\"https://...\")\nresolved_order = asyncio.run(resolver.resolve(order, sig))\n```\n\n### How to decode an order\nLet's say you have en encoded order. Decoding it is as simple as:\n```python\nfrom uniswapx_sdk.decoder import ExclusiveDutchOrderDecoder\n\ndecoder = ExclusiveDutchOrderDecoder()\ndecoded_order = decoder.decode(encoded_order)\n```\n\n### How to get orders from UniswapX API\n```python\nfrom uniswapx_sdk.api import UniswapXAPI\n\napi = UniswapXAPI(chain_id)\norders = await api.get_orders(order_status)  # with order_status in open, expired, error, cancelled, filled, insufficient-funds\n```\n\n### How to fill an order\nLet's say you want to fill (execute) a dutch order. First you encode it as follows:\n```python\nfrom uniswapx_sdk.encoder import ExclusiveDutchOrderEncoder\n\nencoded_input = ExclusiveDutchOrderEncoder.encode_execute(order, sig)  # where sig is the signature corresponding to the order\n```\nThen you include the `encoded_input` in the transaction you sign and send to the Exclusive Dutch Order Reactor.\n","funding_links":["https://github.com/sponsors/Elnaril","https://www.buymeacoffee.com/elnaril","https://www.fiverr.com/freelancers/elnaril"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felnaril%2Fpython-uniswapx-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felnaril%2Fpython-uniswapx-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felnaril%2Fpython-uniswapx-sdk/lists"}