text: const { WETH } = require("@sushiswap/sdk")
  
  module.exports = async function ({ ethers: { getNamedSigner }, getNamedAccounts, deployments }) {
    const { deploy } = deployments
  
    const { deployer, dev } = await getNamedAccounts()
  
    const chainId = await getChainId()
  
    const factory = await ethers.getContract("ReactSwapFactory")
    const bar = await ethers.getContract("XStakeBar")
    const react = await ethers.getContract("ReactToken")
    
    let wethAddress;
    
    if (chainId === '31337') {
      wethAddress = (await deployments.get("WETH9Mock")).address
    } else if (chainId in WETH) {
      wethAddress = WETH[chainId].address
    } else {
      throw Error("No WETH!")
    }
  
    await deploy("XBarman", {
      from: deployer,
      args: [factory.address, bar.address, react.address, wethAddress],
      log: true,
      deterministicDeployment: false
    })
  
    const maker = await ethers.getContract("XBarman")
    if (await maker.owner() !== dev) {
      console.log("Setting maker owner")
      await (await maker.transferOwnership(dev, true, false)).wait()
    }
  }
  
  module.exports.tags = ["XBarman"]
  module.exports.dependencies = ["ReactSwapFactory", "Router", "XStakeBar", "ReactToken"]