Uniswap / universal-router

Uniswap's Universal Router for NFT and ERC20 swapping

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NPM package cannot find Permit2 library

PowVT opened this issue · comments

commented

I installed the UR repo with this command yarn add @uniswap/universal-router.

Then added the UniversalRouter.sol contract as an import into a contract to compile and generate its artifacts.

The first error I see is Error HH411: The library solmate, imported from @uniswap/universal-router/contracts/base/Dispatcher.sol, is not installed. Try installing it using npm. I then installed solmate with yarn. Ran yarn compile again and had a similar issue with another of the submodules that the UR repo uses. Here is the error: Error HH411: The library permit2, imported from @uniswap/universal-router/contracts/base/Dispatcher.sol, is not installed. Try installing it using npm a Permit2 lib does not exist.

Am I taking the right approach here? I feel like the submodules in the UR repo need to be updated to get past these errors, but am not sure how as I am using as a NPM package. Thanks!

yarn -v
3.2.1
node -v
16.10.0

Thanks for reporting this! Forge/hardhat interop causing issues here as we need submodules internally to universal-router for solmate and permit2. I think the best bet is to add a postinstall script to universal-router that'll handle this automatically when you yarn install. We'll try to get something out fixing that today

running submodule update fixed it:
git submodule update --init --recursive

commented

Thanks all really appriciate the help. Still having the same issue. @codeislight1 this command produces and error which I pasted below.

Please make sure you have the correct access rights and the repository exists. fatal: clone of 'git@github.com:Uniswap/permit2.git' into submodule path '/Users/...

I have made sure there is a ssh key pair generated with this command ssh-keygen -t ed25519 -C "myemail@xyz.com". And get the same error. Is this a permissions thing? thanks

commented

Ya it worked for the Permit2 stuff, then starts erroring on the open-zeppelin submodule. So I did the same for that, extracted in to the OZ folder in the top level directory. Then I run git submodule update --init --recursive again and it gets past the permit2 and OZ stuff, but errors on the solmate submodule. Do I make a new folder for solmate similar to the other 2? Do this look like your file tree? Something feels off.

Screen Shot 2022-11-23 at 8 30 50 AM

commented

here is the yarn compile error message:
Screen Shot 2022-11-23 at 8 34 07 AM

commented

🙏 y'all are amazing, yup that was the key. Had to extract them into the lib/permit2, lib/openzeppelin-contracts, and lib/solmate folders. Then run yarn symlink like you said. Then yarn compile and test passed. Thanks.

I think the only stone left unturned is if I were to use this in another project's package.json and install via yarn add @uniswap/universal-router. The compiler still errors on those 3 packages. Solmate, OZ-contracts, and permit2 when I try to import and compile my project contracts. The first two I can install in my project, but Permit2 looks strictly a foundry repo, and cannot grab a package.json. Is this the right assumption? Would my route forward be to use it as a gitmodule as opposed to npm? Thanks again

addressed in PR above. New release has instructions on integrating the repo that should hopefully make things easier. We may try and get everything into node_modules for a future release.

https://github.com/Uniswap/universal-router#integrating