{"id":27972692,"url":"https://github.com/defipy-devs/uniswappy","last_synced_at":"2025-05-07T23:13:40.800Z","repository":{"id":197460084,"uuid":"698689330","full_name":"defipy-devs/uniswappy","owner":"defipy-devs","description":"[Python Programming] Uniswap V2 / V3 Analytics with Python","archived":false,"fork":false,"pushed_at":"2025-04-29T23:01:07.000Z","size":37093,"stargazers_count":36,"open_issues_count":0,"forks_count":12,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-07T23:13:33.759Z","etag":null,"topics":["analytics","python","uniswap","uniswap-v2","uniswap-v3"],"latest_commit_sha":null,"homepage":"https://defipy.org","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/defipy-devs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-09-30T16:58:20.000Z","updated_at":"2025-04-29T23:01:11.000Z","dependencies_parsed_at":"2023-10-05T06:28:24.853Z","dependency_job_id":"6412db4e-4d2e-411f-a761-a5027819de22","html_url":"https://github.com/defipy-devs/uniswappy","commit_stats":null,"previous_names":["icmoore/uniswappy","defipy-devs/uniswappy"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defipy-devs%2Funiswappy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defipy-devs%2Funiswappy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defipy-devs%2Funiswappy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defipy-devs%2Funiswappy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/defipy-devs","download_url":"https://codeload.github.com/defipy-devs/uniswappy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252968121,"owners_count":21833252,"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","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":["analytics","python","uniswap","uniswap-v2","uniswap-v3"],"created_at":"2025-05-07T23:13:40.187Z","updated_at":"2025-05-07T23:13:40.792Z","avatar_url":"https://github.com/defipy-devs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UniswapPy: Uniswap V2 / V3 Analytics with Python\nThis package contains python re-factors of both original Uniswap [V2](https://github.com/Uniswap/v2-core/blob/master/contracts/UniswapV2Pair.sol) and [V3](https://github.com/Uniswap/v3-core/blob/main/contracts/UniswapV3Pool.sol)\npairing codes, and can be utilized for the purpose of analysing and modelling its behavior for DeFi. \n\n## Docs\nVisit [docs](https://defipy.org) for full documentation with walk-through \ntutorials\n\n## Installation \n```\n\u003e git clone https://github.com/defipy-devs/uniswappy\n\u003e pip install .\n```\nor\n```\n\u003e pip install UniswapPy\n```\n\n## Uniswap V2\n\n* See [test notebook](https://github.com/defipy-devs/uniswappy/blob/main/notebooks/tutorials/uniswap_v2.ipynb) \nfor basic usage and [tutorial](https://medium.com/coinmonks/uniswap-v2-math-tutorial-using-uniswappy-abb23cdef005) on Uniswap V2 math\n\n```\nfrom uniswappy import *\n\nuser_nm = 'user'\neth_amount = 1000\ntkn_amount = 100000\n\ntkn = ERC20(\"TKN\", \"0x111\")\neth = ERC20(\"ETH\", \"0x09\")\nexchg_data = UniswapExchangeData(tkn0 = eth, tkn1 = tkn, symbol=\"LP\", address=\"0x011\")\n\nfactory = UniswapFactory(\"ETH pool factory\", \"0x2\")\nlp = factory.deploy(exchg_data)\n\nJoin().apply(lp, user_nm, eth_amount, tkn_amount)\nlp.summary()\n```\n\n#### OUTPUT:\nExchange ETH-TKN (LP) \u003cbr/\u003e\nReserves: ETH = 1000, TKN = 100000 \u003cbr/\u003e\nLiquidity: 10000.0 \u003cbr/\u003e\u003cbr/\u003e \n\n```\nout = Swap().apply(lp, tkn, user_nm, 1000)\nlp.summary()\n```\n\n#### OUTPUT:\nExchange ETH-TKN (LP) \u003cbr/\u003e\nReserves: 990.1284196560293, TKN = 101000 \u003cbr/\u003e\nLiquidity: 10000.0 \u003cbr/\u003e\u003cbr/\u003e \n\n\n## Uniswap V3\n\n* See [test notebook](https://github.com/defipy-devs/uniswappy/blob/main/notebooks/tutorials/uniswap_v3.ipynb) \nfor basic usage and [tutorial](https://medium.com/coinmonks/uniswap-v3-math-tutorial-using-uniswappy-c39795d1328a) on Uniswap V3 math\n\n```\nfrom uniswappy import *\n\nuser_nm = 'user'\neth_amount = 1000\ntkn_amount = 100000\n\neth = ERC20(\"ETH\", \"0x09\")\ntkn = ERC20(\"TKN\", \"0x111\")\n\nexchg_data = UniswapExchangeData(tkn0 = eth, tkn1 = tkn, symbol=\"LP\", \n                                   address=\"0x011\", version = 'V3', \n                                   tick_spacing = tick_spacing, \n                                   fee = fee)\n\nfactory = UniswapFactory(\"ETH pool factory\", \"0x2\")\nlp = factory.deploy(exchg_data)\n\nout_v3 = Join().apply(lp, user_nm, eth_amount, tkn_amount, lwr_tick, upr_tick)\nlp.summary()\n```\n\n#### OUTPUT:\nExchange ETH-TKN (LP) \u003cbr/\u003e\nReserves: ETH = 1000, TKN = 100000 \u003cbr/\u003e\nLiquidity: 10000.0 \u003cbr/\u003e\u003cbr/\u003e \n\n```\nout = Swap().apply(lp, tkn, user_nm, 1000)\nlp.summary()\n```\n\n#### OUTPUT:\nExchange ETH-TKN (LP) \u003cbr/\u003e\nReal Reserves: ETH = 990.1284196560293, TKN = 101000 \u003cbr/\u003e\nLiquidity: 10000.0 \u003cbr/\u003e\u003cbr/\u003e \n\n\n## 0x Quant Terminal\n\nThis application utilizes the 0x API to produce a mock Uniswap pool which allows end-users to stress test\nthe limitations of a Uniswap pool setup using live price feeds from [0x API](https://0x.org); for backend setup, see \n[notebook](https://github.com/defipy-devs/uniswappy/blob/main/notebooks/tutorials/quant_terminal.ipynb) \n\nClick [dashboard.defipy.org](https://dashboard.defipy.org/) for live link; for more detail see \n[README](https://github.com/defipy-devs/uniswappy/tree/main/python/application/quant_terminal#readme) \n\n![plot](./doc/quant_terminal/screenshot.png)\n\n### Run application locally  \n\n```\n\u003e bokeh serve --show python/application/quant_terminal/bokeh_server.py\n```\n\n## Special Features\n * **Abstracted Actions**: Obfuscation is removed from standard Uniswap \naction events to help streamline analysis and lower line count; see \narticle [How to Handle Uniswap Withdrawals like an \nOG](https://medium.com/coinmonks/handle-uniswap-withdrawals-like-an-og-389fe74be18c), \nand [Setup your Uniswap Deposits like a \nBaller](https://medium.com/coinmonks/setup-your-uniswap-deposits-like-a-baller-b99340ea302f)\n * **Indexing**: Can calculate settlment LP token amounts given token \namounts and vice versa; see article [The Uniswap Indexing \nProblem](https://medium.com/datadriveninvestor/the-uniswap-indexing-problem-8078b8b110fc)\n * **Simulation**: Can simulate trading using Geometric Brownian Motion \n(GBM) process, or feed in actual raw price data to analyze behavior; see \narticle [How to Simulate a Liquidity Pool for Decentralized \nFinance](https://medium.com/@icmoore/simulating-a-liquidity-pool-for-decentralized-finance-6f357ec8564b)\n * **Randomized Events**: Token amount and time delta models to simulate \npossible trading behavior\n * **Analytical Tools**: Basic yeild calculators and risk tools to assist \nin analyzing outcomes; see \narticle [How to Simulate a Uniswap V3 Order Book in Python](https://medium.com/datadriveninvestor/how-to-simulate-a-uniswap-v3-order-book-in-python-149480d12305)\n\nIf you find this package helpful, please leave a ⭐!\n \n \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefipy-devs%2Funiswappy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefipy-devs%2Funiswappy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefipy-devs%2Funiswappy/lists"}