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.sol
assigns a minter role toSwapper.sol
contract viainit()
that takes the address of theSwapper.sol
contract- An initial supply of
FRM
tokens can be minted by the owner viamintFRM()
in theSwapper.sol
contract after passing the address ofFermatToken.sol
to theconstructor()
- Assign an allowance to the
Swapper.sol
of1000000 * 10 ** 18
from each token contract (that is,EulerToken.sol
&GaussToken.sol
) - Provide an initial liquidity to the swapper of
1000000 * 10 ** 18
viainit()
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
FRM
and the amount of the token (ELR
orGAU
) 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
FRM
viasetPriceFRM()
(pass a value without adding decimals) - Finally, to view the current price of
FRM
, you'll simply callgetPriceFRM()
npm install
npx hardhat compile
npx hardhat test