Skip to content

khawlahssn/multitoken-swapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-token Swapper

User can perform a swapping operation described as ELR || GAU <==> FRM where ELR, GAU, and FRM are arbitray names given to the tokens.

Contracts deployed:

Instructions:

  1. FermatToken.sol assigns a minter role to Swapper.sol contract via init() that takes the address of the Swapper.sol contract
  2. An initial supply of FRM tokens can be minted by the owner via mintFRM() in the Swapper.sol contract after passing the address of FermatToken.sol to the constructor()
  3. Assign an allowance to the Swapper.sol of 1000000 * 10 ** 18 from each token contract (that is, EulerToken.sol & GaussToken.sol)
  4. Provide an initial liquidity to the swapper of 1000000 * 10 ** 18 via init() that takes in the address for each token ELR & GAU
  5. 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 or GAU) you're trading in exchange for it
  6. Un-swapping also takes in the same parameters as swap() described in step 5
  7. As an admin, you can set a new price for FRM via setPriceFRM() (pass a value without adding decimals)
  8. Finally, to view the current price of FRM, you'll simply call getPriceFRM()

To run the test cases:

  • npm install
  • npx hardhat compile
  • npx hardhat test

About

Contract for multi-token swapping where A || B <==> C

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published