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.

Skill LevelBeginner
Total Length1.7h

Intended Learners

Who’s This Course For

  • For developers who are interested in blockchain finance
  • For developers who are curious about decentralized exchanges
  • For developers who are looking to learn Solidity programming applications


  • Basic understanding of exchanges and cryptocurrency concepts
  • Familiar with the ERC20 standard
  • Basic Solidity programming skills, with a recommendation to first complete Solidity foundational courses (at least Solidity 101 to 104)
  • Possess an Ethereum account, connected to both Mantle and a wallet, holding either Mantle tokens or test tokens (for those wishing to perform real on-chain operations, though deployment can also be done directly in a local environment if test tokens are not available)

What You’ll Learn

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


  • 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.


DEX - Part 1

27 lessons
Access on mobile and desktop