Owners: @Giacomo Pasini @David Rusu

Reviewers: 🟢@Álvaro Castro-Castilla 🟨@Thomas Lavaur

Introduction

This documents presents the findings from implementing Uniswap V2 as faithfully as possible as a Nomos zone. Differences from Uniswap arise in that we make use of Utxo’s for tracking funds and state.

Uniswap V2 is a Automated Market Maker (AMM), a system that allows users to trade on different assets by regulating prices algorithmically. Anybody can contribute liquidity to the protocol and earn fees.

The central operation is a SWAP, a trade on some currency pair. Each currency pair has some associated liquidity (called a pool), where reserves of both currencies are held. The price for a swap is automatically determined based on the balances of each currency according the following formula

$$ (x_{1} − 0.003 · x_{in})) · y_1 >= x_0 · y_0 $$

where:

This design allows an user to become a liquidity provider (LP) by depositing his funds into a pair, this allows the user to passively provide a market making service while collecting fees from each swap.

The details around how LP’s and fee distribution works has been removed from the scope of this PoC. Instead we will focus on the SWAP operation

Overview

We will focus on the main components of the Uniswap Zone:

  1. how pools are represented
  2. how zone funds are managed
  3. how SWAPs are encoded and executed.

Pools