back to home

Elnaril / uniswap-universal-router-decoder

Uniswap Universal Router SDK - Decode and Encode Transactions - Uniswap V2, V3 & V4

272 stars
64 forks
1 issues
Python

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing Elnaril/uniswap-universal-router-decoder in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/Elnaril/uniswap-universal-router-decoder)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

Uniswap Universal Router Decoder & Encoder > Many thanks to **everyone** who has ☕️ offered some **coffees**! ☕️ > or ⭐ **starred** this project! ⭐ > It is **greatly** appreciated! :) --- --- Project Information Code Quality --- Release Notes See the release note page v3.0.0.dev0 - breaking changes • Add async support • Remove support for Python 3.9 • Remove support for Web3 **Tip**: You can format the decoded input like above with this Gedit plugin ;) How to decode a Uniswap Universal Router transaction It's also possible to decode the whole transaction, given its hash and providing the codec has been built with either a valid instance or the link to a rpc endpoint. The decoder will get the transaction from the blockchain and decode it, along with its input data: How to decode a Uniswap V3 swap path The class exposes also the method which can be used to decode a given Uniswap V3 path. The result is a tuple, starting with the "in-token" and ending with the "out-token", with the pool fees between each pair. How to encode The Uniswap Universal Router allows the chaining of several functions in the same transaction. This codec supports it (at least for supported functions) and exposes public methods that can be chained. The chaining starts with the method and ends with the one which returns the full encoded data to be included in the transaction. Below some examples of encoded data for one function and one example for 2 functions. Default values for deadlines and expirations can be computed with the static methods and respectively. These 2 functions accept a custom duration in seconds as argument. How to encode a call to the Uniswap Universal Router function WRAP_ETH This function can be used to convert eth to weth using the UR. How to encode a call to the Uniswap V2 function V2_SWAP_EXACT_IN This function can be used to swap tokens on a V2 pool. Correct allowances must have been set before sending such transaction. For more details, see this tutorial How to encode a call to the Uniswap V2 function V2_SWAP_EXACT_OUT This function can be used to swap tokens on a V2 pool. Correct allowances must have been set before sending such transaction. How to encode a call to the Uniswap V3 function V3_SWAP_EXACT_IN This function can be used to swap tokens on a V3 pool. Correct allowances must have been set before using sending such transaction. How to encode a call to the Uniswap V3 function V3_SWAP_EXACT_OUT This function can be used to swap tokens on a V3 pool. Correct allowances must have been set before sending such transaction. How to encode a call to the Uniswap Universal Router function PERMIT2_PERMIT This function is used to give an allowance to the universal router thanks to the Permit2 contract ( ). It is also necessary to approve the Permit2 contract using the token approve function. See this tutorial After that, you can swap tokens using the Uniswap universal router. _...truncated for preview_