{"size": 1073, "ext": "js", "max_stars_repo_path": "src/protocols/uniswapV1.js", "max_stars_repo_name": "NickCuso/hardlydifficult-eth", "max_stars_repo_stars_event_min_datetime": "2020-08-25T14:41:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-14T04:11:59.000Z", "max_issues_repo_path": "src/protocols/uniswapV1.js", "max_issues_repo_name": "NickCuso/hardlydifficult-eth", "max_issues_repo_issues_event_min_datetime": "2019-09-22T23:48:58.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-07T18:38:48.000Z", "max_forks_repo_path": "src/protocols/uniswapV1.js", "max_forks_repo_name": "HardlyDifficult/hardlydifficult-test-helpers", "max_forks_repo_forks_event_min_datetime": "2021-03-11T02:05:40.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-07T21:03:47.000Z"}
{"max_stars_count": 3, "max_issues_count": 35, "max_forks_count": 3, "avg_line_length": 27.5128205128, "max_line_length": 75, "alphanum_fraction": 0.6570363467}
const { truffleContract } = require("../helpers");
const uniswapJson = require("./uniswapV1.json");

module.exports = {
  mainnetFactoryAddress: "0xc0a47dfe034b400b47bdad5fecda2621de6c4d95",
  deploy: async (web3, owner) => {
    // Deploy exchange template
    // Deploy factory
    // initializeFactory(template: address)
    const exchangeTemplate = await truffleContract.new(
      web3,
      uniswapJson.exchange.abi,
      `0x${uniswapJson.exchange.bytecode.replace(/0x/, "")}`,
      owner
    );
    const factory = await truffleContract.new(
      web3,
      uniswapJson.abi,
      `0x${uniswapJson.bytecode.replace(/0x/, "")}`,
      owner
    );
    await factory.initializeFactory(exchangeTemplate.address, {
      from: owner,
    });

    return factory;
  },
  getFactory: async (web3, factoryAddress) => {
    return await truffleContract.at(web3, uniswapJson.abi, factoryAddress);
  },
  getExchange: async (web3, exchangeAddress) => {
    return await truffleContract.at(
      web3,
      uniswapJson.exchange.abi,
      exchangeAddress
    );
  },
};
