The architecture of AMM
This section will discuss the architecture of AMM, which supports scalable liquidity pools. This means the number of liquidity pools can grow to support multiple token liquidity pairs. Meanwhile, it allows people to trade tokens, add liquidities (liquidity mining), and remove liquidities (liquidity burning). This architecture has been adopted by many DEXs, such as Uniswap and PancakeSwap. We will also implement all the functions and components of this architecture in Chapter 5, Build Crypto-Trading Smart Contracts.
The architecture of AMM and its components are depicted in Figure 4.9.
Figure 4.9 – Architecture of Automated Market Maker (AMM) on blockchain
Figure 4.9 shows three main components of on-chain AMM. Each component is a smart contract with a few functions:
- AMM Router: The AMM router is a medium between AMM users and other on-chain components of the AMM. It implements the interfaces that off-chain components...