I am trying to import uniswap v3 contracts, which uses version 0.7.6 in my contract that uses 0.8.1. for fetching the TWAP price. am importing these two :

import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol";
import "@uniswap/v3-periphery/contracts/libraries/OracleLibrary.sol";

I am getting thes errors

Error HH606: The project cannot be compiled, see reasons below.

These files import other files that use a different and incompatible version of Solidity:

I have tried -

  • Added compiler verion in hardhat config.

I have found this Hardhat FAQ

which states that

you might have a contract with pragma version ^0.7.0 that imports a contract with ^0.6.0. This can never be compiled. Pragma versions indicate which subset of the compiler versions can be used, and if two pragma versions don’t intersect (like in this example), then the files cannot be compiled. Period. 

Is there anyway how i can make this work, without downgrading my custom contracts, because that is not an option right now.

  • 2
    Uniswap provides a Solidity v0.8 implementation on the 0.8 branch. Also see this discussion in my PRBMath project's repository involving a user who tried to use PRBMath (v0.8) with Uniswap (v0.7). Jul 19, 2022 at 9:08
  • Thank you refering this have helped Jul 19, 2022 at 13:04
  • I ended up copying the uniswap V3 contracts in my own repo, which worked but with a hasle. Jul 19, 2022 at 13:11

2 Answers 2


Use Uniswaps ^0.8.0 contracts. You can find them here easily: https://github.com/Uniswap/v3-core/tree/0.8

  • Thank you, I have copied their codes and used it in my contracts instead of importing from npm packages. Jul 20, 2022 at 10:30

You can compile contracts with multiple versions of Solidity by setting in the hardhat.config.js file. Here is the example:

module.exports = {
    solidity: {
        compilers: [
                version: "0.7.6",
                version: "0.8.1",

You can read more about compiling multiple versions in Hardhat here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.