-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Building Full Stack DeFi Applications
By :

Now we have implemented the smart contracts for DEX's fundamental features, here we will call the public or external functions from AMMRouter
to verify these features. The AMMRouter
smart contract provides interfaces for off-chain activities to access the DEX. Other components of the DEX, such as TokenPair
and PairFactory
, can also be verified by accessing AMMRouter
.
Similar to other smart contracts, AMMRouter
can also be deployed through scripts/deploy.js
. However, there is one difference in that AMMRouter
requires a _factory
parameter in its constructor for the deployment, which needs PairFactory
to be deployed before AMMRouter
, and uses the deployed pairFactoryAddress
as the argument when calling the deploy
function in JavaScript:
await contractFactory.deploy(pairFactoryAddress)
We need to refactor the script in the main
function to deploy PairFactory
before deploying AMMRouter
. You can check the updated...