This project is a basic concept of a DEX application. The purpose is to learn how a DEX works from the basics to a deeper understanding. Do not use this project on a mainnet because it is far from a production ready DEX application.
The application is based on a simple monorepo. There are two packages, one for the smart contracts-related codes and one for the front-end application. The easiest way to develop the project is using the packages locally, both of them contain the necessary information in the README files. If you want to deploy the front-end application somewhere I suggest using a testnet for the smart contract, in this case, the deployed front-end application can reach a deployed smart contract.
Read more about the smart contracts
An automated market maker (AMM) is a system that provides liquidity to the exchange it operates in through automated trading.
An automated market maker (AMM) is the underlying protocol that powers decentralized exchanges (DEXs). The core purpose of automated market makers is to address the problem of liquidity on a DEX. AMMs create pools of liquidity that can be contributed to by anyone. Users of platforms that integrate automated market platforms trade against a liquidity pool. In simple terms, a liquidity pool is a shared pool of an asset — such as a blockchain token — with the price of the asset determined by a mathematical formula.
The assets held within a liquidity pool are traded via an algorithm, rather than the limit order book model used in traditional markets.
AMMs have become a primary way to trade assets in the DeFi ecosystem, and it all began with a blog post about “on-chain market makers” by Ethereum founder Vitalik Buterin. The secret ingredient of AMMs is a simple mathematical formula that can take many forms. The most common one was proposed by Vitalik as:
tokenA_balance(p) * tokenB_balance(p) = k
and popularized by Uniswap as:
x * y = k
The constant, represented by k
means there is a constant balance of assets that determines the price of tokens in a liquidity pool. For example, if an AMM has ether (ETH) and bitcoin (BTC), two volatile assets, every time ETH is bought, the price of ETH goes up as there is less ETH in the pool than before the purchase.
The DeFi ecosystem evolves quickly, but three dominant AMM models have emerged: Uniswap, Curve, and Balancer.
-
Uniswap’s pioneering technology allows users to create a liquidity pool with any pair of ERC-20 tokens with a 50/50 ratio, and has become the most enduring AMM model on Ethereum.
-
Curve specializes in creating liquidity pools of similar assets such as stablecoins, and as a result, offers some of the lowest rates and most efficient trades in the industry while solving the problem of limited liquidity.
-
Balancer stretches the limits of Uniswap by allowing users to create dynamic liquidity pools of up to eight different assets in any ratio, thus expanding AMMs’ flexibility.
Read more about AMMs here