Uniswap getPair() does not deliver address

Hi there,

I have a problem when running the following 4 lines of code from the main JS script (see below):

  • await uniswapFactory.getPair(daiAddress, wethAddress)
  • await sushiFactory.getPair(daiAddress, wethAddress),
  • const uniswapReserves = await uniswapDaiEth.getReserves();
  • const sushiReserves = await sushiEthDai.getReserves();

For the first two, if I substituted them with hardcoded token pair addresses from Etherscan into the code it works. If I run the first two directly into Truffle console it resolves the pair addresses but strangely enough it doesn´t resolve when I execute the JS script!

For the above two .getReserves() function calls it doesn´t retrieve any of the reserve values unless if I ran them as they are under Truffle console environment then it retrieves them OK.

I appreciate your assistance here as it´s been bugging me for the full last two days and am running out of options to resolve this.

Full JS script

const { INFURA_API_KEY, PRIVATE_KEY } = process.env;
const { ethers } = require('ethers');

const UniswapV2Pair = require(".././build/contracts/IUniswapV2Pair.json");
const UniswapV2Factory = require('.././build/contracts/IUniswapV2Factory.json');

const daiAddress = "0x6B175474E89094C44Da98b954EedeAC495271d0F";
const wethAddress = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";

const privateKey = process.env.PRIVATE_KEY;
const infuraProvider = new ethers.providers.InfuraProvider('mainnet', process.env.INFURA_API_KEY);
const wallet = new ethers.Wallet(privateKey, infuraProvider);

const testBasic = async () => {
  const uniswapFactory = new ethers.Contract(

  const sushiFactory = new ethers.Contract(

  let uniswapDaiEth;
  let sushiEthDai;

  const loadPairs = async () => {
    uniswapDaiEth = new ethers.Contract(
      await uniswapFactory.getPair(daiAddress, wethAddress),
    sushiEthDai = new ethers.Contract(
      await sushiFactory.getPair(daiAddress, wethAddress),
  await loadPairs();

  infuraProvider.on('block', async (blockNumber) => {
    try {
      const uniswapReserves = await uniswapDaiEth.getReserves();
      const sushiReserves = await sushiEthDai.getReserves();
    } catch (err) {


Thank you very much for your help!

Best, Samuel

Hello Samuel.
Here is Marko Frei.
Contact @markofrei on Telegram


Please contact me

TG : @anydevbest
Skype : live:.cid.588439c6887bd701

Hello do you have an email address that I could send you more details about another issue that I have and if you could help, perhaps we could jump into a Teams meeting to go over it? Would this be possible?
Thank you


Please eamil me amureke71@gmail.com with the details.