User can perform a swapping operation described as ELR || GAU <==> FRM where ELR, GAU, and FRM are arbitray names given to the tokens.
- Fermat Token ("FRM"). Polygonscan 🔎
- Euler Token ("ELR"). Polygonscan 🔎
- Gauss Token ("GAU"). Polygonscan 🔎
- Swapper. Polygonscan 🔎
FermatToken.solassigns a minter role toSwapper.solcontract viainit()that takes the address of theSwapper.solcontract- An initial supply of
FRMtokens can be minted by the owner viamintFRM()in theSwapper.solcontract after passing the address ofFermatToken.solto theconstructor() - Assign an allowance to the
Swapper.solof1000000 * 10 ** 18from each token contract (that is,EulerToken.sol&GaussToken.sol) - Provide an initial liquidity to the swapper of
1000000 * 10 ** 18viainit()that takes in the address for each tokenELR&GAU - Now you're ready to swap! this part is important. you'll pass the address of the token you want to swap for
FRMand the amount of the token (ELRorGAU) you're trading in exchange for it - Un-swapping also takes in the same parameters as
swap()described in step 5 - As an admin, you can set a new price for
FRMviasetPriceFRM()(pass a value without adding decimals) - Finally, to view the current price of
FRM, you'll simply callgetPriceFRM()
npm installnpx hardhat compilenpx hardhat test