7_deploy_erc20_mixer_proxy.js 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. /* global artifacts */
  2. require('dotenv').config({ path: '../.env' })
  3. const ERC20Mixer = artifacts.require('ERC20Mixer')
  4. const gsnProxy = artifacts.require('GSNProxy')
  5. const ERC20Mock = artifacts.require('ERC20Mock')
  6. const UniswapMock = artifacts.require('UniswapMock')
  7. const { toBN, toWei } = require('web3-utils')
  8. const eth2daiPrice = toBN('174552286079977583324') // cause 1 ETH == 174.55 DAI
  9. module.exports = function(deployer, network) {
  10. return deployer.then(async () => {
  11. const { ERC20_TOKEN } = process.env
  12. let token = ERC20_TOKEN
  13. let uniswapAddress
  14. if (network === 'development') { // means we want to test with mock
  15. if (token === '') {
  16. const tokenInstance = await ERC20Mock.deployed()
  17. token = tokenInstance.address
  18. }
  19. const uniswap = await deployer.deploy(UniswapMock, token, eth2daiPrice, { value: toWei('0.5') })
  20. uniswapAddress = uniswap.address
  21. }
  22. let mixer = await ERC20Mixer.deployed()
  23. const proxy = await deployer.deploy(
  24. gsnProxy,
  25. mixer.address,
  26. uniswapAddress,
  27. )
  28. console.log('ERC20Mixer\'s proxy address ', proxy.address)
  29. })
  30. }