Uniswap Fork Testing Hardhat

@Isa_O @gperezalba
I had similar issues and after doing some debugging I found that there is an issue with
UniswapV2Library function. For some reason function pairFor of this library returns different pair address.

Change this function to this and it will work:

import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol';
    function pairFor(address factory, address tokenA, address tokenB) internal view returns (address pair) {
        pair = IUniswapV2Factory(factory).getPair(tokenA,tokenB);
    }
4 Likes