0

I am looking how to implement liquidity pool from UniSwap documentation and getting error not found: Deferred import even when i just copy their example without any changes from my side i am getting the same error

i am trying to implement these :

import '@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol';
import '@uniswap/v3-core/contracts/libraries/TickMath.sol';
import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';
import '@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol';
import '@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol';
import '@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol';
import '@uniswap/v3-periphery/contracts/base/LiquidityManagement.sol';

Again..even when i copy their example i got error.I am using Remix ide

1 Answer 1

2

the way you import has to be done if you import via from your node_modules, in your case you should rather import directly from GitHub by including the link of the contract itself.

import "https://github.com/Uniswap/v3-core/blob/main/contracts/UniswapV3Pool.sol";
import "https://github.com/Uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import "https://github.com/Uniswap/v3-core/contracts/libraries/TickMath.sol";
import "https://github.com/Uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
import "https://github.com/Uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol";
import "https://github.com/Uniswap/v3-periphery/contracts/libraries/TransferHelper.sol";
import "https://github.com/Uniswap/v3-periphery/contracts/base/LiquidityManagement.sol";

for the IERC721Receiver.sol you need to find the right version to import or add directly to your remix and change the version.

5
  • But now i am getting not found @openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol error - BTW i am planing to use this contract to android platform using web3j,but i assume it doesn't matter which platform I plan to work on since it's a solidity code?
    – gojic
    Mar 25, 2022 at 13:06
  • 1
    No it doesn't matter, solidity is for smart contract, then integration you can use what you want web3j, web3js, ethers.js, etc. @openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol you need to find the contract on github, and paste the link like I have shown you above. If you are not able to find the right version just copy the contract into a new file on your remix and import it import "./nameOfFile.sol";
    – Adam Boudj
    Mar 25, 2022 at 13:24
  • i dont know,i give up.I copied IERC721Enumerable.sol in new file in remix but then everything explode with errors.Because some imports needs 0.7.6 version of solidity,and some 0.8.0 and some betwen 0.5.0 and 0.8.0...and getting not found: Deferred import error....i would imagine that uniswap would make thing easier,so that peoples can use their docs for fast testing while learning.Thanks for your effort tho
    – gojic
    Mar 25, 2022 at 15:51
  • 2
    I flattened all the interfaces and contracts, you can just copy/paste this code gist.github.com/Aboudjem/886f9fae8649d3801b4ffe6e9bac1564
    – Adam Boudj
    Mar 25, 2022 at 17:29
  • I dont know what to say..thank you a ton
    – gojic
    Mar 28, 2022 at 13:26

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.