Hi,
I'm creating an upgradeable contract that inherit from the ERC4626Upgradeable using @openzeppelin/contracts-upgradeable v5.0.2.
I see that since v5 the Namespaced Storage Layout is used to avoid potential storage collisions and so OZ contract includes
bytes32 private constant ERC4626StorageLocation = 0x0773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e00;
function _getERC4626Storage() private pure returns (ERC4626Storage storage $) {
assembly {
$.slot := ERC4626StorageLocation
}
}
My contract inherits from the base ERC4626Upgradeable and need to access variables from the base storage
struct ERC4626Storage {
IERC20 _asset;
uint8 _underlyingDecimals;
}
(eg _asset). What's the correct pattern for doing this? Should I redeclare the needed variable in the child contract like the following
contract ERC4626Child is ERC4626Upgradeable {
address asset;
function initialize(address _asset) public initializer {
__ERC4626_init(IERC20(_asset));
asset = _asset;
}
}
?
Why both the constant and the _getERC4626Storage are private instead of internal?
Thanks in advance