hackquest logo
 

DEX - Part 1

You may have heard of Binance and FTX from the news headlines. They are called Centralized Exchanges (CEX) since one company operates them and reaps profit from operating them. What is a Decentralized Exchange (DEX)? A decentralized exchange (DEX) is a peer-to-peer marketplace where users can trade cryptocurrency directly with each other, without using an intermediary. Popular DEXs include Uniswap, SushiSwap, Pancake Swap, DODO, and Curve. In Part 1 of the DEX course, we will learn to build a liquidity pool and implement the “add liquidity” functionality.

Language

Solidity

Total Length

1.7h

Part of Learning Track

Build on Ethereum + 1

What You’ll Learn

Introduction to liquidity principles Initialization of contracts, construction of liquidity pools, and calculation of LP tokens.
liquidity pool
LP token

Syllabus

Contract Setup

In this section, we will set up the ERC20 contract, establishing the foundation for our token system.

Pool Setup

This section focuses on setting up the liquidity pool, an essential component for token exchange and liquidity.

Calculate AmountB Add

Learn how to calculate the amountB that a user should add to the liquidity pool in this unit.

Calculate Liquidity Tokens - Section 1

This section will teach us how to calculate the number of LP Tokens to reward participants in the liquidity pool.

Calculate Liquidity Tokens - Section 2

Focus on calculating the amount of LP Tokens when the liquidity pool is initially empty.

Calculate Liquidity Tokens - Section 3

In this section, we will address what to do in scenarios where an error message is returned to users, followed by providing the final calculated result.