Cant find `Math` library in openzeppelin/contracts-upgradeable/contracts/utils/math

I wanted to use the math library for upgradeable contracts but I cant seem to find it in the repo, interestingly the readme talks about the library in utils but the math folder itself is not visible.

I cant find the math library in oz upgradeable in the github either, I'm using v4.9.2

Can someone help me figure out what is happening?

Math is an internally linked library, so it's agnostic to upgradability.

In short, just get rid of the -upgradable part in your search path.

This is for v5, but you can probably see the same directory structure in your version:

Ty mate, the problem is that its in a deployed contract and I wanted to run forked tests against it,

import { MathUpgradeable as Math } from "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol";

Update the remappings in my setup?

I think that this is (was, by now) just an attempt by OZ dev team to keep their naming-convention consistent across the repository. It is virtually identical to Math as far as I know, so you may as well just use:

import { Math } from "@openzeppelin-contracts-upgradeable/contracts/utils/math/Math.sol";

BTW, compared with the title of your question, you are missing /contracts in your current code:

"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol";

The current code is a deployed one, so I actually cant edit it.

The missing contracts is okay, updated by the remappings

@openzeppelin/contracts-upgradeable=lib/openzeppelin-contracts-upgradeable/contracts

But I cant seem to get the math lib

You can just navigate to the node_modules directory in your local project and search for that file.

1 Like

Did you manage to solve this? I am at the same bug, unfortunately. I cant seem to find the MathUpgradeable sol file despite the team claiming it is here [import {MathUpgradeable} from '@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol';], there is no math folder as a matter of fact.