Implementing pair factory smart contracts
The pair factory is a smart contract that creates token pairs. It also helps the AMM router locate the addresses of deployed token pairs by giving two token addresses. Now, let’s start creating the pair factory smart contract.
Introducing the smart contract source file
The source file of the pair factory smart contract is located at src/backend/contracts/PairFactory.sol
within the project. The Solidity file implements the PairFactory
smart contract. We will not examine every line of code of the smart contract – if you want, you can refer to the full source code of the smart contract at https://github.com/PacktPublishing/Building-Full-stack-DeFi-Application/blob/chapter05-end/defi-apps/src/backend/contracts/PairFactory.sol.
At the beginning of the PairFactory
smart contract implementation, the constructor of the contract sets the deployer (msg.sender
) to rewardTo
as the default account to receive the LP token rewards from...