Today I’d like to announce the project I’d been working on for several months: Uniswap V3 Development Book 🥳
The book will guide you through building of a Uniswap V3 clone from scratch. We’ll start with an empty Foundry project and will build a fully functioning Uniswap V3 clone in discrete steps. Uniswap V3 is a big project packed with many bigger and smaller mechanics and algorithms. So, to make our journey lighter, we’ll follow the Minimum Viable Product principle: at each step, we’ll focus only on one part of the Uniswap V3 implementation.
The book is split into multiple milestones:
- in Milestone 0, you’ll learn about market makers, markets, and how decentralized exchanges (DEX) work in general;
- in Milestone 1, you’ll make a simple DEX that’s capable of swapping tokens in one direction with predefined prices and amounts;
- in Milestone 2, we’ll evolve our DEX implementation to support swaps in both directions (selling and buying) and we’ll start implementing mathematical calculations in Solidity;
- Milestone 3 will, probably, be the hardest part of the book: in this milestone, we’ll implement liquidity management and swaps over multiple liquidity positions–the most innovational part of the Uniswap V3 design;
- in Milestone 4, we’ll go beyond one Uniswap pool and implement chained swaps, i.e. swaps between two tokens that don’t have a common pool;
- in Milestone 5, we’ll finish the implementation of our Uniswap V3 clone by introducing swap fees and a price oracle;
- in Milestone 6, we’ll see how Uniswap V3 can be extended with third-party contracts to turn liquidity positions into NFT tokens.
But that’s not all! Along the way, we’ll build a front-end application in React that will imitate that of Uniswap and will allow to perform swaps and provide/remove liquidity. While this front-end application won’t be our primary focus in the book (I’m a bad front-end developer 🙈), it’ll show you how to build such an app and how to integrate it with smart contracts that you built.
But that’s also not all!
Math!! There will be a lot of math! Some chapters are packed with mathematical formulas, but don’t be scared–as soon as you get the core mathematical concepts of constant-function market makers, the math of Uniswap V2 and V3 will make absolute sense. In case math is not something you feel confident with, Algebra 1 and Algebra 2 courses on Khan Academy are more than enough to understand the math of Uniswap.
Uniswap is a unique project. It’s one of the first DeFi (Decentralized Finance) projects that went from zero to one:
- it was one of the first decentralized exchanges;
- its developers managed to find a simple and elegant solution (basically, the
x * y = kequation);
- it kicked off, gained traction, and became a reference DEX implementation that gave birth to endless clones.
While many smart contract developers are fond of Uniswap V2 due to its simplicity and elegance, Uniswap V3 is seemed like a bloated project with complex functionality. This is not true! And you’ll see this 😁
Uniswap V3 is definitely the next step of smart contracts development. While its business logic is entirely based on Uniswap
V2 (which is just an implementation of the
x * y = k formula), it pushes DEX development forward by using derived math
formulas and adding a thick layer of engineering on top of them. It’s this extra layer of engineering that’s seemed
complex by many developers. But you, a reader of this book, will see that this is not true and Uniswap V3 is not so
Finally, why I personally think Uniswap V3 is a great educational resource is that you do want to learn from complex projects. As smart contract development evolves and projects are getting more advanced, you don’t want to stick with simpler projects and should embrace the complexity–this will pay off and you’ll become a better developer. Uniswap V3 is a great example of a complex project that’s based on more-or-less simple ideas and that’s been running in production for several years and that has become one of the biggest DeFi projects–this is the kind of projects you want to strive to build as a smart contracts developer.
Who is This Book For?
This book is not for beginners. I won’t teach you Solidity. In fact, after reading a half of this book, you’ll see that Solidity is not a hard language and that the hardest part of smart contracts development is not Solidity but business logic and state management. So, this book is for those who knows Solidity or who can pick it up while reading the book.
If decentralized exchanges and constant-function market makers is something new to you, reading my series on Uniswap V2 development will help you a lot. As I mentioned above, Uniswap V3 is entirely based on V2. This is why understanding Uniswap V2 will make you journey through the book much easier, and it will also make your understanding of the V3 mechanics much deeper.
Uniswap Grants Program
To write this book, I received a grant from Uniswap Foundation. Without the grant, I wouldn’t probably have had enough motivation and patience to dig Uniswap into its deepest depths and to finish the book. The grant is also the main reason why the book is open-source and free for anyone. You can learn more about Uniswap Grants Program (and maybe apply!).