Implementing token pair smart contracts
A token pair smart contract is a DEX component used to support operations on each trading pair and maintain the token reserves. Each instance of a token pair smart contract represents a liquidity pool for a token pair of the DEX.
We will start implementing the smart contracts for our DEX in this section. Before writing code, we encourage you to copy the code from the chapter05-start
branch of the Git repository of this book because it contains all the working code we created in previous chapters as well as the smart contract interfaces that we will use in this chapter.
If you want to continue the work you did in the previous chapter, you can just create a folder at src/backend/contracts/interfaces
and put the following three files into the directory: IAMMRouter.sol
, IPairFactory.sol
, and ITokenPair.sol
. These three Solidity files define the thee interfaces with their functions that we will implement in this chapter. We will explain more...