Sushi Swap fork error-VM Exception while processing transaction: revert UniswapV2: FORBIDDEN

Hello, Im trying to fork and deploy Sushi swap to ropsten and I keep getting the same error when deploying, I have deployed sushi swap on my local ganache cli and didnt have any problems.

I have been searching for days to try and find anyone with a similar error and have not found anyone. I have seen nothing on google with answers to this problem.

I tried searching on open zep for this particular error and nothing comes up in the search results.

Im using truffle, and starting with…

Truffle develop
truffle(develop)> migrate --reset --network ropsten

this is the 2_deploy_contracts.js file

const Factory = artifacts.require('uniswapv2/UniswapV2Factory.sol');
const Router = artifacts.require('uniswapv2/UniswapV2Router02.sol');
const WETH = artifacts.require('WETH.sol');
const MockERC20 = artifacts.require('mocks/ERC20Mock.sol');
const SushiToken = artifacts.require('SushiToken.sol') 
const MasterChef = artifacts.require('MasterChef.sol'); 
const SushiBar = artifacts.require('SushiBar.sol');
const SushiMaker = artifacts.require('SushiMaker.sol');
const Migrator = artifacts.require('Migrator.sol');

module.exports = async function(deployer, _network, addresses) {
  const [admin, _] = addresses;

  await deployer.deploy(WETH);
  const weth = await WETH.deployed();
  const tokenA = await MockERC20.new('Token A', 'TKA', web3.utils.toWei('1000'));
  const tokenB = await MockERC20.new('Token B', 'TKB', web3.utils.toWei('1000'));

  await deployer.deploy(Factory, admin);
  const factory = await Factory.deployed();
  await factory.createPair(weth.address, tokenA.address);
  await factory.createPair(weth.address, tokenB.address);
  await deployer.deploy(Router, factory.address, weth.address);
  const router = await Router.deployed();

  await deployer.deploy(SushiToken);
  const sushiToken = await SushiToken.deployed();

  await deployer.deploy(
    MasterChef,
    sushiToken.address,
    admin,
    web3.utils.toWei('100'),
    1,
    1
  );
  const masterChef = await MasterChef.deployed();
  await sushiToken.transferOwnership(masterChef.address);

  await deployer.deploy(SushiBar, sushiToken.address);
  const sushiBar = await SushiBar.deployed();

  await deployer.deploy(
    SushiMaker,
    factory.address, 
    sushiBar.address, 
    sushiToken.address, 
    weth.address
  );
  const sushiMaker = await SushiMaker.deployed();
  await factory.setFeeTo(sushiMaker.address);

  await deployer.deploy(
    Migrator,
    masterChef.address,
    '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f',
    factory.address,
    1
  ); 
};

This is the output I am getting (I was getting another part at the end about exceeding event listeners that I think i have solved by changing the truffle-config file to manually increase that limit) :

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.



Migrations dry-run (simulation)
===============================
> Network name:    'ropsten-fork'
> Network id:      3
> Block gas limit: 8000000 (0x7a1200)


1_initial_migrations.js
=======================

   Deploying 'Migrations'
   ----------------------
   > block number:        10346914
   > block timestamp:     1622477789
   > account:             0xaaD9762251F69603A26C392d0175E34084a23c8F
   > balance:             1.999656074
   > gas used:            171963 (0x29fbb)
   > gas price:           2 gwei
   > value sent:          0 ETH
   > total cost:          0.000343926 ETH

   -------------------------------------
   > Total cost:         0.000343926 ETH


2_deploy_contracts.js
=====================

   Deploying 'WETH'
   ----------------
   > block number:        10346916
   > block timestamp:     1622477800
   > account:             0xaaD9762251F69603A26C392d0175E34084a23c8F
   > balance:             1.998043396
   > gas used:            779004 (0xbe2fc)
   > gas price:           2 gwei
   > value sent:          0 ETH
   > total cost:          0.001558008 ETH


   Deploying 'UniswapV2Factory'
   ----------------------------
   > block number:        10346919
   > block timestamp:     1622477816
   > account:             0xaaD9762251F69603A26C392d0175E34084a23c8F
   > balance:             1.98547806
   > gas used:            4207018 (0x4031aa)
   > gas price:           2 gwei
   > value sent:          0 ETH
   > total cost:          0.008414036 ETH


   Deploying 'UniswapV2Router02'
   -----------------------------
   > block number:        10346922
   > block timestamp:     1622477837
   > account:             0xaaD9762251F69603A26C392d0175E34084a23c8F
   > balance:             1.963752522
   > gas used:            4562335 (0x459d9f)
   > gas price:           2 gwei
   > value sent:          0 ETH
   > total cost:          0.00912467 ETH


   Deploying 'SushiToken'
   ----------------------
   > block number:        10346923
   > block timestamp:     1622477842
   > account:             0xaaD9762251F69603A26C392d0175E34084a23c8F
   > balance:             1.958461704
   > gas used:            2645409 (0x285da1)
   > gas price:           2 gwei
   > value sent:          0 ETH
   > total cost:          0.005290818 ETH


   Deploying 'MasterChef'
   ----------------------
   > block number:        10346924
   > block timestamp:     1622477853
   > account:             0xaaD9762251F69603A26C392d0175E34084a23c8F
   > balance:             1.953331164
   > gas used:            2565270 (0x272496)
   > gas price:           2 gwei
   > value sent:          0 ETH
   > total cost:          0.00513054 ETH


   Deploying 'SushiBar'
   --------------------
   > block number:        10346926
   > block timestamp:     1622477861
   > account:             0xaaD9762251F69603A26C392d0175E34084a23c8F
   > balance:             1.950097774
   > gas used:            1585543 (0x183187)
   > gas price:           2 gwei
   > value sent:          0 ETH
   > total cost:          0.003171086 ETH


   Deploying 'SushiMaker'
   ----------------------
   > block number:        10346927
   > block timestamp:     1622477865
   > account:             0xaaD9762251F69603A26C392d0175E34084a23c8F
   > balance:             1.946142226
   > gas used:            1977774 (0x1e2dae)
   > gas price:           2 gwei
   > value sent:          0 ETH
   > total cost:          0.003955548 ETH


RuntimeError: VM Exception while processing transaction: revert UniswapV2: FORBIDDEN
    at module.exports (/Users/edwardmcmillan/bull_bear/migrations/2_deploy_contracts.js:51:17)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at Migration._deploy (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:79:1)
    at Migration._load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:61:1)
    at Migration.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:212:1)
    at Object.runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:150:1)
    at Object.runFrom (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
    at Object.runAll (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:114:1)
    at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:79:1)
    at runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:258:1)
    at setupDryRunEnvironmentThenRunMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:246:1)
    at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:215:1)
    at Command.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:147:1)

I think the error is from the following function call from the pair contract:

// called once by the factory at time of deployment
    function initialize(address _token0, address _token1) external {
        require(msg.sender == factory, 'UniswapV2: FORBIDDEN'); // sufficient check
        token0 = _token0;
        token1 = _token1;
    }

Im following a tutorial (eat the block-fork sushi swap) and Im also a little confused as to why not to deploy the pair contract w/ all the others in the 2_deploy_contracts.js file? If, in the initial deployment we have to call the initialize function from the pair contract it seems to me this contract should be deployed?

Also, If the require here is for …require(msg.sender == factory, ‘UniswapV2: FORBIDDEN’)
to me what this is saying is the caller of this has to be the factory contract which when I deploy the contracts is my 0 address right (deploying address) ? the constructor is directly above that function and sets the factory = msg.sender; (below) so I cant see why that is not me/my 0 address/deployer address?

constructor() public {
        factory = msg.sender;
    }

    // called once by the factory at time of deployment
    function initialize(address _token0, address _token1) external {
        require(msg.sender == factory, 'UniswapV2: FORBIDDEN'); // sufficient check
        token0 = _token0;
        token1 = _token1;
    }

Questions:

  1. How can I fix this error?
  2. Should the pair contract be deployed?
  3. Any opinion on why when sushi swap forked uniswap they did not change the names on the uniswap contracts? ie, UniswapV2Pair.sol, UniswapV2Router.sol, UniswapV2Factory.sol and UniswapV2ERC20.sol… everyone seems to fork/copy uniswap but some leave the uniswap names and others change to their own name? Just wondering if anyone had a best practice or view on the subject?

Any help would be appreciated! Sorry if the structure of this post is not in the correct format…

Please use triple backticks to surround your code in order to get proper formatting.

```
code here
```

I can’t tell where the error is coming from. I’m not sure it’s the line that you pointed out. Try to make sure that you’ve identified the exact line in the migration that is causing the error.

Maybe someone else can help.

'0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f',

Is this address valid on Ropsten.

Usually when things like this are failing to deploy it’s because of an incorrect address on the specific testnet. You might be using the live address.

Hi, THANKS FOR THE HELP! I solved the problem…I had to change the truffle-config file and add this…

skipDryRun: true

I have successfully deployed it on ropsten.

It would be great to get some feedback on the name change issue?

THX

1 Like

Keeping the same name sounds like a good way to indicate that the contracts are the same and will be as secure as they are in Uniswap itself (that is, very highly secure). Of course this should only be done if the source code was not changed.