-
Hey community, I'm currently trying to get started using the prb-math package for my contracts via hardhat (I can't use foundry due to a different conflict). I was wondering if somebody could help me, for some reason my contract can't find the import. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
hey @kkoshiya, thanks for your question, and sorry to hear that you are encountering this difficulty. Would you be able to add more detail about what exactly went wrong? Ideally, if you could reproduce the error in an open-source repo, that would be perfect. |
Beta Was this translation helpful? Give feedback.
-
The instructions in the README pertain to a Foundry environment in which the PRBMath submodules are remapped to remove the As you can see in the node modules installed in CauchyAMM, the https://github.com/kkoshiya/CauchyAMM/tree/main/node_modules/%40prb/math So the solution is to change this line: import { SD59x18 } from "@prb/math/SD59x18.sol"; To this: import { SD59x18 } from "@prb/math/src/SD59x18.sol"; Side note: I will update the imports in the README to use |
Beta Was this translation helpful? Give feedback.
The instructions in the README pertain to a Foundry environment in which the PRBMath submodules are remapped to remove the
src
. But in Hardhat and Node.js, that is not possible, so you have to import the contracts using the full paths.As you can see in the node modules installed in CauchyAMM, the
@prb/math
path contains asrc
directory:https://github.com/kkoshiya/CauchyAMM/tree/main/node_modules/%40prb/math
So the solution is to change this line:
To this:
Side note: I will update the imports in the README to use
src
because now I recommend this approach even for Foundry projects.