📦Storage Upgradeable Proxy

The Storage Upgradeable Proxy is based on reading the target from a slot from a Storage. This means multiple proxies can read from the same slot and can all be upgraded at once by changing that Storage slot.

The Storage mentioned here is not the internal storage of the contract but a separate contract capable of storing and reading storage slots. This means data is stored elsewhere than the proxy contract itself and can be updated independently of it.

StorageUpgradeableProxy.sol
contract StorageUpgradeableProxy is ProxyOwnable, Proxy {
  bytes32 internal constant _STORAGE_SLOT =
    bytes32(uint256(keccak256("proxy.storage")) - 1);

  bytes32 internal constant _SLOT_SLOT =
    bytes32(uint256(keccak256("proxy.storage.slot")) - 1);

  event Upgraded(address indexed _newStorage, bytes32 indexed _newSlot);

  constructor(
    address _owner,
    address _storage,
    bytes32 _slot,
    bytes memory _initialCall
  );

  function upgradeTo(
    address _newStorage,
    bytes32 _newSlot,
    bytes memory _oldImplementationData,
    bytes memory _newImplementationData
  ) external;

  function implementation()
    public
    view
    override
    returns (address _implementation);

  function proxyType() public pure override returns (uint256 _type);

  function _setImplementation(address _newStorage, bytes32 _newSlot) internal;
}

Last updated