• Stars
    star
    596
  • Rank 75,095 (Top 2 %)
  • Language
    JavaScript
  • Created over 2 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Uniswap V3 Development Book

Uniswap V3 Development Book

Uniswap V3 Development Book cover

This book will teach how to develop an advanced decentralized application! Specifically, we'll be building a clone of Uniswap V3, which is a decentralized exchange.

Why Uniswap?

  • It implements a very simple mathematical concept, x * y = k, which still makes it very powerful.
  • It's an advanced application that has a thick layer of engineering on top of the simple formula.
  • It's permissionless and battle-tested. Learning from an application that's been running in production for several years and handling billions of dollars will make you a better developer.

What we'll build

Front-end application screenshot

We'll build a full clone of Uniswap V3. It won't be an exact copy and it won't be production-ready because we'll do something in our own way and we'll definitely introduce multiple bugs. So, don't deploy this to the mainnet!

While our focus will primarily be on smart contracts, we'll also build a front-end application as a side hustle. πŸ™‚ I'm not a front-end developer and I cannot make a front-end application better than you, but I can show you how a decentralized exchange can be integrated into a front-end application.

The full code of what we'll build is stored in a separate repository:

https://github.com/Jeiwan/uniswapv3-code

You can read this book at:

https://uniswapv3book.com/

Questions?

Each milestone has its own section in the GitHub Discussions. Don't hesitate to ask questions about anything that's not clear in the book!

Table of Contents

  • Milestone 0. Introduction

    1. Introduction to markets
    2. Constant Function Market Makers
    3. Uniswap V3
    4. Development Environment
    5. What We'll Build
  • Milestone 1. First Swap

    1. Introduction
    2. Calculating Liquidity
    3. Providing Liquidity
    4. First Swap
    5. Manager Contract
    6. Deployment
    7. User Interface
  • Milestone 2. Second Swap

    1. Introduction
    2. Output Amount Calculation
    3. Math in Solidity
    4. Tick Bitmap Index
    5. Generalize Minting
    6. Generalize Swapping
    7. Quoter Contract
    8. User Interface
  • Milestone 3. Cross-tick Swaps

    1. Introduction
    2. Different Price Ranges
    3. Cross-Tick Swaps
    4. Slippage Protection
    5. Liquidity Calculation
    6. A Little Bit More on Fixed-point Numbers
    7. Flash Loans
    8. User Interface
  • Milestone 4. Multi-pool Swaps

    1. Introduction
    2. Factory Contract
    3. Swap Path
    4. Multi-pool Swaps
    5. User Interface
    6. Tick Rounding
  • Milestone 5. Fees and Price Oracle

    1. Introduction
    2. Swap Fees
    3. Flash Loan Fees
    4. Protocol Fees
    5. Price Oracle
    6. User Interface
  • Milestone 6: NFT positions

    1. Introduction
    2. ERC721 Overview
    3. NFT Manager
    4. NFT Renderer

Running locally

To run the book locally:

  1. Install Hugo.
  2. Clone the repo:
    $ git clone https://github.com/Jeiwan/uniswapv3-book
    $ cd uniswapv3-book
  3. Run:
    $ hugo server -D
  4. Visit http://localhost:1313/ (or whatever URL the previous command outputs!)

TODO

  1. Milestone 2, Tick Bitmap Index: what happens when there are no ticks? Will it keep looping until it reaches max/min tick?
  2. Milestone 3: liquidity management
  3. Somewhere: clarify that sqrtP has better precision than ticks and that current price is never computed from current tick.
  4. Add dark mode (with images)
  5. Make a PDF
  6. Add Next/Back buttons to the bottom of pages.
  7. Ideas for Extras:
    1. Tick math implementation. Explanation of the math in TickMath contract.
    2. Breakdown of the alpha-router: https://github.com/Uniswap/swap-router-contracts

More Repositories

1

blockchain_go

A simplified blockchain implementation in Golang
Go
4,102
star
2

uniswapv3-code

Uniswap V3 clone built to learn smart-contracts development in Solidity
Solidity
281
star
3

flash-loans-comparison

Comparison of flash loan solutions on Ethereum
Solidity
269
star
4

zuniswapv2

UniswapV2 clone made in educational purposes
Solidity
171
star
5

awesome-blockchain

A curated list of blockchain resources for developers
Makefile
119
star
6

zuniswap

UniswapV1 clone made in educational purposes
JavaScript
117
star
7

tinybit

Tiny Bitcoin Node [Work in Progress]
Go
40
star
8

uniswapv3-unrefunded-eth-poc

Solidity
38
star
9

upgradeable-proxy-from-scratch

Code from "Upgradeable proxy contract from scratch" blog post
JavaScript
24
star
10

defi-strategy-eth-staking

Leveraged ETH staking strategy contract
Solidity
21
star
11

uniswapv2-contracts

Uniswap V2 contracts, ready to be deployed to local or test network
Solidity
14
star
12

ethernaut-solutions

My solutions for Ethernaut, https://ethernaut.openzeppelin.com/
Solidity
10
star
13

rails_telegram_bot

Rails Telegram Bot
Ruby
8
star
14

eosgo

Instead, use:
Go
7
star
15

StackUnderflow

A clone of StackOverflow
Ruby
6
star
16

eos-abi

ABI deserializer for EOS
Go
4
star
17

uniswapv4-book

🚧 WORK IN PROGRESS 🚧
JavaScript
4
star
18

eosio-alpine

Alpine Linux based Docker image of EOS blockchain
Dockerfile
3
star
19

titan-finance-analysis

Analysis of the TITAN fall
JavaScript
3
star
20

manzana-client

Ruby
2
star
21

opscript

A viewer and debugger of Bitcoin scripts.
Go
2
star
22

go-blogs-demo

An example multi-tenancy application in Golang
Go
1
star
23

bank_client

Ruby
1
star
24

micros

A basic microservices setup
Go
1
star
25

switter

Twitter-like application on Ruby on Rails from scratch
Ruby
1
star
26

jeiwan.github.io

A blog about blockchains and smart contracts development
HTML
1
star