Can I use normal interface/library in place of upgradeable versions?

Hi! This is my first post, so please bear with me!

I would like to understand what the best practice is with regards to using the openzeppelin contracts vs upgradeable contracts repo. My understanding is for most of the interfaces, the code is basically identical, except names have been changed (e.g. IERC20 -> IERC20Upgradeable, SafeMath -> SafeMathUpgradeable). My questions:

  1. Why were these "clone" interfaces/libraries created? Was it to mostly keep a consistent naming across all contracts/interfaces/libraries in the upgradeable-contracts repo?
  2. Is it technically safe to use the IERC20 in place of IERC20Upgradeable (or vice versa) when writing my own contracts?

For some background, I am trying to merge code from two different sources, and one uses openzeppelins upgradeable contracts while the other does not.

Thank you!

Hey @gzr,

The upgradeable version of the contracts library is generated using a custom transpiler in this CI Job, so it's more of a result from such transpilation than an actual design decision.

We're currently considering ways of doing partial transpilation so it's not confusing anymore but our current recommendation is to use the Upgradeable suffixed contract and interfaces (although in IERC20 -> IERC20Upgradeable they're the same) and you should have no problems.

On the other hand, also consider using IERC20 instead of IERC20Upgradeable might cause unexpected issues in the inheritance order you may need to manually dissambiguate.

Got it, that makes sense. The note about using IERC20Upgradeable instead of IERC20 to avoid inheritance related issues is a good point as well. Thank you!

1 Like