creation_sourcecode: // Sources flattened with hardhat v2.22.2 https://hardhat.org
  
  // SPDX-License-Identifier: MIT
  
  // File @openzeppelin/contracts-upgradeable/interfaces/draft-IERC1822Upgradeable.sol@v4.9.6
  
  // Original license: SPDX_License_Identifier: MIT
  // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
  
  pragma solidity ^0.8.0;
  
  /**
   * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
   * proxy whose upgrades are fully controlled by the current implementation.
   */
  interface IERC1822ProxiableUpgradeable {
      /**
       * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
       * address.
       *
       * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
       * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
       * function revert if invoked through a proxy.
       */
      function proxiableUUID() external view returns (bytes32);
  }
  
  
  // File @openzeppelin/contracts-upgradeable/interfaces/IERC1967Upgradeable.sol@v4.9.6
  
  // Original license: SPDX_License_Identifier: MIT
  // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)
  
  pragma solidity ^0.8.0;
  
  /**
   * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
   *
   * _Available since v4.8.3._
   */
  interface IERC1967Upgradeable {
      /**
       * @dev Emitted when the implementation is upgraded.
       */
      event Upgraded(address indexed implementation);
  
      /**
       * @dev Emitted when the admin account has changed.
       */
      event AdminChanged(address previousAdmin, address newAdmin);
  
      /**
       * @dev Emitted when the beacon is changed.
       */
      event BeaconUpgraded(address indexed beacon);
  }
  
  
  // File @openzeppelin/contracts-upgradeable/proxy/beacon/IBeaconUpgradeable.sol@v4.9.6
  
  // Original license: SPDX_License_Identifier: MIT
  // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
  
  pragma solidity ^0.8.0;
  
  /**
   * @dev This is the interface that {BeaconProxy} expects of its beacon.
   */
  interface IBeaconUpgradeable {
      /**
       * @dev Must return an address that can be used as a delegate call target.
       *
       * {BeaconProxy} will check that this address is a contract.
       */
      function implementation() external view returns (address);
  }
  
  
  // File @openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol@v4.9.6
  
  // Original license: SPDX_License_Identifier: MIT
  // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
  
  pragma solidity ^0.8.1;
  
  /**
   * @dev Collection of functions related to the address type
   */
  library AddressUpgradeable {
      /**
       * @dev Returns true if `account` is a contract.
       *
       * [IMPORTANT]
       * ====
       * It is unsafe to assume that an address for which this function returns
       * false is an externally-owned account (EOA) and not a contract.
       *
       * Among others, `isContract` will return false for the following
       * types of addresses:
       *
       *  - an externally-owned account
       *  - a contract in construction
       *  - an address where a contract will be created
       *  - an address where a contract lived, but was destroyed
       *
       * Furthermore, `isContract` will also return true if the target contract within
       * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
       * which only has an effect at the end of a transaction.
       * ====
       *
       * [IMPORTANT]
       * ====
       * You shouldn't rely on `isContract` to protect against flash loan attacks!
       *
       * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
       * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
       * constructor.
       * ====
       */
      function isContract(address account) internal view returns (bool) {
          // This method relies on extcodesize/address.code.length, which returns 0
          // for contracts in construction, since the code is only stored at the end
          // of the constructor execution.
  
          return account.code.length > 0;
      }
  
      /**
       * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
       * `recipient`, forwarding all available gas and reverting on errors.
       *
       * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
       * of certain opcodes, possibly making contracts go over the 2300 gas limit
       * imposed by `transfer`, making them unable to receive funds via
       * `transfer`. {sendValue} removes this limitation.
       *
       * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
       *
       * IMPORTANT: because control is transferred to `recipient`, care must be
       * taken to not create reentrancy vulnerabilities. Consider using
       * {ReentrancyGuard} or the
       * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
       */
      function sendValue(address payable recipient, uint256 amount) internal {
          require(address(this).balance >= amount, "Address: insufficient balance");
  
          (bool success, ) = recipient.call{value: amount}("");
          require(success, "Address: unable to send value, recipient may have reverted");
      }
  
      /**
       * @dev Performs a Solidity function call using a low level `call`. A
       * plain `call` is an unsafe replacement for a function call: use this
       * function instead.
       *
       * If `target` reverts with a revert reason, it is bubbled up by this
       * function (like regular Solidity function calls).
       *
       * Returns the raw returned data. To convert to the expected return value,
       * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
       *
       * Requirements:
       *
       * - `target` must be a contract.
       * - calling `target` with `data` must not revert.
       *
       * _Available since v3.1._
       */
      function functionCall(address target, bytes memory data) internal returns (bytes memory) {
          return functionCallWithValue(target, data, 0, "Address: low-level call failed");
      }
  
      /**
       * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
       * `errorMessage` as a fallback revert reason when `target` reverts.
       *
       * _Available since v3.1._
       */
      function functionCall(
          address target,
          bytes memory data,
          string memory errorMessage
      ) internal returns (bytes memory) {
          return functionCallWithValue(target, data, 0, errorMessage);
      }
  
      /**
       * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
       * but also transferring `value` wei to `target`.
       *
       * Requirements:
       *
       * - the calling contract must have an ETH balance of at least `value`.
       * - the called Solidity function must be `payable`.
       *
       * _Available since v3.1._
       */
      function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
          return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
      }
  
      /**
       * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
       * with `errorMessage` as a fallback revert reason when `target` reverts.
       *
       * _Available since v3.1._
       */
      function functionCallWithValue(
          address target,
          bytes memory data,
          uint256 value,
          string memory errorMessage
      ) internal returns (bytes memory) {
          require(address(this).balance >= value, "Address: insufficient balance for call");
          (bool success, bytes memory returndata) = target.call{value: value}(data);
          return verifyCallResultFromTarget(target, success, returndata, errorMessage);
      }
  
      /**
       * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
       * but performing a static call.
       *
       * _Available since v3.3._
       */
      function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
          return functionStaticCall(target, data, "Address: low-level static call failed");
      }
  
      /**
       * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
       * but performing a static call.
       *
       * _Available since v3.3._
       */
      function functionStaticCall(
          address target,
          bytes memory data,
          string memory errorMessage
      ) internal view returns (bytes memory) {
          (bool success, bytes memory returndata) = target.staticcall(data);
          return verifyCallResultFromTarget(target, success, returndata, errorMessage);
      }
  
      /**
       * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
       * but performing a delegate call.
       *
       * _Available since v3.4._
       */
      function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
          return functionDelegateCall(target, data, "Address: low-level delegate call failed");
      }
  
      /**
       * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
       * but performing a delegate call.
       *
       * _Available since v3.4._
       */
      function functionDelegateCall(
          address target,
          bytes memory data,
          string memory errorMessage
      ) internal returns (bytes memory) {
          (bool success, bytes memory returndata) = target.delegatecall(data);
          return verifyCallResultFromTarget(target, success, returndata, errorMessage);
      }
  
      /**
       * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
       * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
       *
       * _Available since v4.8._
       */
      function verifyCallResultFromTarget(
          address target,
          bool success,
          bytes memory returndata,
          string memory errorMessage
      ) internal view returns (bytes memory) {
          if (success) {
              if (returndata.length == 0) {
                  // only check isContract if the call was successful and the return data is empty
                  // otherwise we already know that it was a contract
                  require(isContract(target), "Address: call to non-contract");
              }
              return returndata;
          } else {
              _revert(returndata, errorMessage);
          }
      }
  
      /**
       * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
       * revert reason or using the provided one.
       *
       * _Available since v4.3._
       */
      function verifyCallResult(
          bool success,
          bytes memory returndata,
          string memory errorMessage
      ) internal pure returns (bytes memory) {
          if (success) {
              return returndata;
          } else {
              _revert(returndata, errorMessage);
          }
      }
  
      function _revert(bytes memory returndata, string memory errorMessage) private pure {
          // Look for revert reason and bubble it up if present
          if (returndata.length > 0) {
              // The easiest way to bubble the revert reason is using memory via assembly
              /// @solidity memory-safe-assembly
              assembly {
                  let returndata_size := mload(returndata)
                  revert(add(32, returndata), returndata_size)
              }
          } else {
              revert(errorMessage);
          }
      }
  }
  
  
  // File @openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol@v4.9.6
  
  // Original license: SPDX_License_Identifier: MIT
  // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)
  
  pragma solidity ^0.8.2;
  
  /**
   * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
   * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
   * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
   * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
   *
   * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
   * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
   * case an upgrade adds a module that needs to be initialized.
   *
   * For example:
   *
   * [.hljs-theme-light.nopadding]
   * ```solidity
   * contract MyToken is ERC20Upgradeable {
   *     function initialize() initializer public {
   *         __ERC20_init("MyToken", "MTK");
   *     }
   * }
   *
   * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
   *     function initializeV2() reinitializer(2) public {
   *         __ERC20Permit_init("MyToken");
   *     }
   * }
   * ```
   *
   * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
   * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
   *
   * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
   * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
   *
   * [CAUTION]
   * ====
   * Avoid leaving a contract uninitialized.
   *
   * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
   * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
   * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
   *
   * [.hljs-theme-light.nopadding]
   * ```
   * /// @custom:oz-upgrades-unsafe-allow constructor
   * constructor() {
   *     _disableInitializers();
   * }
   * ```
   * ====
   */
  abstract contract Initializable {
      /**
       * @dev Indicates that the contract has been initialized.
       * @custom:oz-retyped-from bool
       */
      uint8 private _initialized;
  
      /**
       * @dev Indicates that the contract is in the process of being initialized.
       */
      bool private _initializing;
  
      /**
       * @dev Triggered when the contract has been initialized or reinitialized.
       */
      event Initialized(uint8 version);
  
      /**
       * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
       * `onlyInitializing` functions can be used to initialize parent contracts.
       *
       * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
       * constructor.
       *
       * Emits an {Initialized} event.
       */
      modifier initializer() {
          bool isTopLevelCall = !_initializing;
          require(
              (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
              "Initializable: contract is already initialized"
          );
          _initialized = 1;
          if (isTopLevelCall) {
              _initializing = true;
          }
          _;
          if (isTopLevelCall) {
              _initializing = false;
              emit Initialized(1);
          }
      }
  
      /**
       * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
       * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
       * used to initialize parent contracts.
       *
       * A reinitializer may be used after the original initialization step. This is essential to configure modules that
       * are added through upgrades and that require initialization.
       *
       * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
       * cannot be nested. If one is invoked in the context of another, execution will revert.
       *
       * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
       * a contract, executing them in the right order is up to the developer or operator.
       *
       * WARNING: setting the version to 255 will prevent any future reinitialization.
       *
       * Emits an {Initialized} event.
       */
      modifier reinitializer(uint8 version) {
          require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
          _initialized = version;
          _initializing = true;
          _;
          _initializing = false;
          emit Initialized(version);
      }
  
      /**
       * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
       * {initializer} and {reinitializer} modifiers, directly or indirectly.
       */
      modifier onlyInitializing() {
          require(_initializing, "Initializable: contract is not initializing");
          _;
      }
  
      /**
       * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
       * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
       * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
       * through proxies.
       *
       * Emits an {Initialized} event the first time it is successfully executed.
       */
      function _disableInitializers() internal virtual {
          require(!_initializing, "Initializable: contract is initializing");
          if (_initialized != type(uint8).max) {
              _initialized = type(uint8).max;
              emit Initialized(type(uint8).max);
          }
      }
  
      /**
       * @dev Returns the highest version that has been initialized. See {reinitializer}.
       */
      function _getInitializedVersion() internal view returns (uint8) {
          return _initialized;
      }
  
      /**
       * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
       */
      function _isInitializing() internal view returns (bool) {
          return _initializing;
      }
  }
  
  
  // File @openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol@v4.9.6
  
  // Original license: SPDX_License_Identifier: MIT
  // OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
  // This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
  
  pragma solidity ^0.8.0;
  
  /**
   * @dev Library for reading and writing primitive types to specific storage slots.
   *
   * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
   * This library helps with reading and writing to such slots without the need for inline assembly.
   *
   * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
   *
   * Example usage to set ERC1967 implementation slot:
   * ```solidity
   * contract ERC1967 {
   *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
   *
   *     function _getImplementation() internal view returns (address) {
   *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
   *     }
   *
   *     function _setImplementation(address newImplementation) internal {
   *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
   *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
   *     }
   * }
   * ```
   *
   * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._
   * _Available since v4.9 for `string`, `bytes`._
   */
  library StorageSlotUpgradeable {
      struct AddressSlot {
          address value;
      }
  
      struct BooleanSlot {
          bool value;
      }
  
      struct Bytes32Slot {
          bytes32 value;
      }
  
      struct Uint256Slot {
          uint256 value;
      }
  
      struct StringSlot {
          string value;
      }
  
      struct BytesSlot {
          bytes value;
      }
  
      /**
       * @dev Returns an `AddressSlot` with member `value` located at `slot`.
       */
      function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
          /// @solidity memory-safe-assembly
          assembly {
              r.slot := slot
          }
      }
  
      /**
       * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
       */
      function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
          /// @solidity memory-safe-assembly
          assembly {
              r.slot := slot
          }
      }
  
      /**
       * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
       */
      function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
          /// @solidity memory-safe-assembly
          assembly {
              r.slot := slot
          }
      }
  
      /**
       * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
       */
      function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
          /// @solidity memory-safe-assembly
          assembly {
              r.slot := slot
          }
      }
  
      /**
       * @dev Returns an `StringSlot` with member `value` located at `slot`.
       */
      function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
          /// @solidity memory-safe-assembly
          assembly {
              r.slot := slot
          }
      }
  
      /**
       * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
       */
      function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
          /// @solidity memory-safe-assembly
          assembly {
              r.slot := store.slot
          }
      }
  
      /**
       * @dev Returns an `BytesSlot` with member `value` located at `slot`.
       */
      function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
          /// @solidity memory-safe-assembly
          assembly {
              r.slot := slot
          }
      }
  
      /**
       * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
       */
      function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
          /// @solidity memory-safe-assembly
          assembly {
              r.slot := store.slot
          }
      }
  }
  
  
  // File @openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol@v4.9.6
  
  // Original license: SPDX_License_Identifier: MIT
  // OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)
  
  pragma solidity ^0.8.2;
  
  
  
  
  
  
  /**
   * @dev This abstract contract provides getters and event emitting update functions for
   * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
   *
   * _Available since v4.1._
   */
  abstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable {
      // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
      bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
  
      /**
       * @dev Storage slot with the address of the current implementation.
       * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
       * validated in the constructor.
       */
      bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
  
      function __ERC1967Upgrade_init() internal onlyInitializing {
      }
  
      function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
      }
      /**
       * @dev Returns the current implementation address.
       */
      function _getImplementation() internal view returns (address) {
          return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
      }
  
      /**
       * @dev Stores a new address in the EIP1967 implementation slot.
       */
      function _setImplementation(address newImplementation) private {
          require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
          StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
      }
  
      /**
       * @dev Perform implementation upgrade
       *
       * Emits an {Upgraded} event.
       */
      function _upgradeTo(address newImplementation) internal {
          _setImplementation(newImplementation);
          emit Upgraded(newImplementation);
      }
  
      /**
       * @dev Perform implementation upgrade with additional setup call.
       *
       * Emits an {Upgraded} event.
       */
      function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {
          _upgradeTo(newImplementation);
          if (data.length > 0 || forceCall) {
              AddressUpgradeable.functionDelegateCall(newImplementation, data);
          }
      }
  
      /**
       * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
       *
       * Emits an {Upgraded} event.
       */
      function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {
          // Upgrades from old implementations will perform a rollback test. This test requires the new
          // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
          // this special case will break upgrade paths from old UUPS implementation to new ones.
          if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
              _setImplementation(newImplementation);
          } else {
              try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                  require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
              } catch {
                  revert("ERC1967Upgrade: new implementation is not UUPS");
              }
              _upgradeToAndCall(newImplementation, data, forceCall);
          }
      }
  
      /**
       * @dev Storage slot with the admin of the contract.
       * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
       * validated in the constructor.
       */
      bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
  
      /**
       * @dev Returns the current admin.
       */
      function _getAdmin() internal view returns (address) {
          return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
      }
  
      /**
       * @dev Stores a new address in the EIP1967 admin slot.
       */
      function _setAdmin(address newAdmin) private {
          require(newAdmin != address(0), "ERC1967: new admin is the zero address");
          StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
      }
  
      /**
       * @dev Changes the admin of the proxy.
       *
       * Emits an {AdminChanged} event.
       */
      function _changeAdmin(address newAdmin) internal {
          emit AdminChanged(_getAdmin(), newAdmin);
          _setAdmin(newAdmin);
      }
  
      /**
       * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
       * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
       */
      bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
  
      /**
       * @dev Returns the current beacon.
       */
      function _getBeacon() internal view returns (address) {
          return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
      }
  
      /**
       * @dev Stores a new beacon in the EIP1967 beacon slot.
       */
      function _setBeacon(address newBeacon) private {
          require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
          require(
              AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
              "ERC1967: beacon implementation is not a contract"
          );
          StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
      }
  
      /**
       * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
       * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
       *
       * Emits a {BeaconUpgraded} event.
       */
      function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {
          _setBeacon(newBeacon);
          emit BeaconUpgraded(newBeacon);
          if (data.length > 0 || forceCall) {
              AddressUpgradeable.functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
          }
      }
  
      /**
       * @dev This empty reserved space is put in place to allow future versions to add new
       * variables without shifting down storage in the inheritance chain.
       * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
       */
      uint256[50] private __gap;
  }
  
  
  // File @openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol@v4.9.6
  
  // Original license: SPDX_License_Identifier: MIT
  // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/UUPSUpgradeable.sol)
  
  pragma solidity ^0.8.0;
  
  
  
  /**
   * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
   * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
   *
   * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
   * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
   * `UUPSUpgradeable` with a custom implementation of upgrades.
   *
   * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
   *
   * _Available since v4.1._
   */
  abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
      /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
      address private immutable __self = address(this);
  
      /**
       * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
       * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
       * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
       * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
       * fail.
       */
      modifier onlyProxy() {
          require(address(this) != __self, "Function must be called through delegatecall");
          require(_getImplementation() == __self, "Function must be called through active proxy");
          _;
      }
  
      /**
       * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
       * callable on the implementing contract but not through proxies.
       */
      modifier notDelegated() {
          require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
          _;
      }
  
      function __UUPSUpgradeable_init() internal onlyInitializing {
      }
  
      function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
      }
      /**
       * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
       * implementation. It is used to validate the implementation's compatibility when performing an upgrade.
       *
       * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
       * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
       * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
       */
      function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
          return _IMPLEMENTATION_SLOT;
      }
  
      /**
       * @dev Upgrade the implementation of the proxy to `newImplementation`.
       *
       * Calls {_authorizeUpgrade}.
       *
       * Emits an {Upgraded} event.
       *
       * @custom:oz-upgrades-unsafe-allow-reachable delegatecall
       */
      function upgradeTo(address newImplementation) public virtual onlyProxy {
          _authorizeUpgrade(newImplementation);
          _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
      }
  
      /**
       * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
       * encoded in `data`.
       *
       * Calls {_authorizeUpgrade}.
       *
       * Emits an {Upgraded} event.
       *
       * @custom:oz-upgrades-unsafe-allow-reachable delegatecall
       */
      function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
          _authorizeUpgrade(newImplementation);
          _upgradeToAndCallUUPS(newImplementation, data, true);
      }
  
      /**
       * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
       * {upgradeTo} and {upgradeToAndCall}.
       *
       * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
       *
       * ```solidity
       * function _authorizeUpgrade(address) internal override onlyOwner {}
       * ```
       */
      function _authorizeUpgrade(address newImplementation) internal virtual;
  
      /**
       * @dev This empty reserved space is put in place to allow future versions to add new
       * variables without shifting down storage in the inheritance chain.
       * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
       */
      uint256[50] private __gap;
  }
  
  
  // File contracts/pass/dn404/DN404Mirror.sol
  
  // Original license: SPDX_License_Identifier: MIT
  pragma solidity ^0.8.17;
  
  /// @title DN404Mirror
  /// @notice DN404Mirror provides an interface for interacting with the
  /// NFT tokens in a DN404 implementation.
  ///
  /// @author vectorized.eth (@optimizoor)
  /// @author Quit (@0xQuit)
  /// @author Michael Amadi (@AmadiMichaels)
  /// @author cygaar (@0xCygaar)
  /// @author Thomas (@0xjustadev)
  /// @author Harrison (@PopPunkOnChain)
  ///
  /// @dev Note:
  /// - The ERC721 data is stored in the base DN404 contract.
  abstract contract DN404Mirror is Initializable {
      /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
      /*                           EVENTS                           */
      /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/
  
      /// @dev Emitted when token `id` is transferred from `from` to `to`.
      event Transfer(address indexed from, address indexed to, uint256 indexed id);
  
      /// @dev Emitted when `owner` enables `account` to manage the `id` token.
      event Approval(address indexed owner, address indexed account, uint256 indexed id);
  
      /// @dev Emitted when `owner` enables or disables `operator` to manage all of their tokens.
      event ApprovalForAll(address indexed owner, address indexed operator, bool isApproved);
  
      /// @dev The ownership is transferred from `oldOwner` to `newOwner`.
      /// This is for marketplace signaling purposes. This contract has a `pullOwner()`
      /// function that will sync the owner from the base contract.
      event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);
  
      /// @dev `keccak256(bytes("Transfer(address,address,uint256)"))`.
      uint256 private constant _TRANSFER_EVENT_SIGNATURE =
          0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;
  
      /// @dev `keccak256(bytes("Approval(address,address,uint256)"))`.
      uint256 private constant _APPROVAL_EVENT_SIGNATURE =
          0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925;
  
      /// @dev `keccak256(bytes("ApprovalForAll(address,address,bool)"))`.
      uint256 private constant _APPROVAL_FOR_ALL_EVENT_SIGNATURE =
          0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31;
  
      /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
      /*                        CUSTOM ERRORS                       */
      /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/
  
      /// @dev Thrown when a call for an NFT function did not originate
      /// from the base DN404 contract.
      error SenderNotBase();
  
      /// @dev Thrown when a call for an NFT function did not originate from the deployer.
      error SenderNotDeployer();
  
      /// @dev Thrown when transferring an NFT to a contract address that
      /// does not implement ERC721Receiver.
      error TransferToNonERC721ReceiverImplementer();
  
      /// @dev Thrown when linking to the DN404 base contract and the
      /// DN404 supportsInterface check fails or the call reverts.
      error CannotLink();
  
      /// @dev Thrown when a linkMirrorContract call is received and the
      /// NFT mirror contract has already been linked to a DN404 base contract.
      error AlreadyLinked();
  
      /// @dev Thrown when retrieving the base DN404 address when a link has not
      /// been established.
      error NotLinked();
  
      /// @dev The function selector is not recognized.
      error FnSelectorNotRecognized();
  
      /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
      /*                          STORAGE                           */
      /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/
  
      /// @dev Struct contain the NFT mirror contract storage.
      struct DN404NFTStorage {
          // Address of the ERC20 base contract.
          address baseERC20;
          // The deployer, if provided. If non-zero, the initialization of the
          // ERC20 <-> ERC721 link can only be done be the deployer via the ERC20 base contract.
          address deployer;
          // The owner of the ERC20 base contract. For marketplace signaling.
          address owner;
      }
  
      /// @dev Returns a storage pointer for DN404NFTStorage.
      function _getDN404NFTStorage() internal pure virtual returns (DN404NFTStorage storage $) {
          /// @solidity memory-safe-assembly
          assembly {
              // `uint72(bytes9(keccak256("DN404_MIRROR_STORAGE")))`.
              $.slot := 0x3602298b8c10b01230 // Truncate to 9 bytes to reduce bytecode size.
          }
      }
  
      /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
      /*                        CONSTRUCTOR                         */
      /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/
  
      function _initializeMirror(address owner_, address deployer_) internal onlyInitializing {
          // For non-proxies, we will store the deployer so that only the deployer can
          // link the base contract.
          _getDN404NFTStorage().deployer = deployer_;
          _getDN404NFTStorage().owner = owner_;
      }
  
      /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
      /*                     ERC721 OPERATIONS                      */
      /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/
  
      /// @dev Returns the token collection name from the base DN404 contract.
      function name() public view virtual returns (string memory) {
          return _readString(0x06fdde03, 0); // `name()`.
      }
  
      /// @dev Returns the token collection symbol from the base DN404 contract.
      function symbol() public view virtual returns (string memory) {
          return _readString(0x95d89b41, 0); // `symbol()`.
      }
  
      /// @dev Returns the Uniform Resource Identifier (URI) for token `id` from
      /// the base DN404 contract.
      function tokenURI(uint256 id) public view virtual returns (string memory) {
          return _readString(0xc87b56dd, id); // `tokenURI(uint256)`.
      }
  
      /// @dev Returns the total NFT supply from the base DN404 contract.
      function totalSupply() public view virtual returns (uint256) {
          return _readWord(0xe2c79281, 0, 0); // `totalNFTSupply()`.
      }
  
      /// @dev Returns the number of NFT tokens owned by `nftOwner` from the base DN404 contract.
      ///
      /// Requirements:
      /// - `nftOwner` must not be the zero address.
      function balanceOf(address nftOwner) public view virtual returns (uint256) {
          return _readWord(0xf5b100ea, uint160(nftOwner), 0); // `balanceOfNFT(address)`.
      }
  
      /// @dev Returns the owner of token `id` from the base DN404 contract.
      ///
      /// Requirements:
      /// - Token `id` must exist.
      function ownerOf(uint256 id) public view virtual returns (address) {
          return address(uint160(_readWord(0x6352211e, id, 0))); // `ownerOf(uint256)`.
      }
  
      /// @dev Returns the owner of token `id` from the base DN404 contract.
      /// Returns `address(0)` instead of reverting if the token does not exist.
      function ownerAt(uint256 id) public view virtual returns (address) {
          return address(uint160(_readWord(0x24359879, id, 0))); // `ownerAt(uint256)`.
      }
  
      /// @dev Sets `spender` as the approved account to manage token `id` in
      /// the base DN404 contract.
      ///
      /// Requirements:
      /// - Token `id` must exist.
      /// - The caller must be the owner of the token,
      ///   or an approved operator for the token owner.
      ///
      /// Emits an {Approval} event.
      function approve(address spender, uint256 id) public payable virtual {
          address base = baseERC20();
          /// @solidity memory-safe-assembly
          assembly {
              spender := shr(96, shl(96, spender))
              let m := mload(0x40)
              mstore(0x00, 0xd10b6e0c) // `approveNFT(address,uint256,address)`.
              mstore(0x20, spender)
              mstore(0x40, id)
              mstore(0x60, caller())
              if iszero(
                  and( // Arguments of `and` are evaluated last to first.
                      gt(returndatasize(), 0x1f), // The call must return at least 32 bytes.
                      call(gas(), base, callvalue(), 0x1c, 0x64, 0x00, 0x20)
                  )
              ) {
                  returndatacopy(m, 0x00, returndatasize())
                  revert(m, returndatasize())
              }
              mstore(0x40, m) // Restore the free memory pointer.
              mstore(0x60, 0) // Restore the zero pointer.
              // Emit the {Approval} event.
              log4(codesize(), 0x00, _APPROVAL_EVENT_SIGNATURE, shr(96, mload(0x0c)), spender, id)
          }
      }
  
      /// @dev Returns the account approved to manage token `id` from
      /// the base DN404 contract.
      ///
      /// Requirements:
      /// - Token `id` must exist.
      function getApproved(uint256 id) public view virtual returns (address) {
          return address(uint160(_readWord(0x081812fc, id, 0))); // `getApproved(uint256)`.
      }
  
      /// @dev Sets whether `operator` is approved to manage the tokens of the caller in
      /// the base DN404 contract.
      ///
      /// Emits an {ApprovalForAll} event.
      function setApprovalForAll(address operator, bool approved) public virtual {
          address base = baseERC20();
          /// @solidity memory-safe-assembly
          assembly {
              operator := shr(96, shl(96, operator))
              let m := mload(0x40)
              mstore(0x00, 0x813500fc) // `setApprovalForAll(address,bool,address)`.
              mstore(0x20, operator)
              mstore(0x40, iszero(iszero(approved)))
              mstore(0x60, caller())
              if iszero(
                  and( // Arguments of `and` are evaluated last to first.
                      eq(mload(0x00), 1), // The call must return 1.
                      call(gas(), base, callvalue(), 0x1c, 0x64, 0x00, 0x20)
                  )
              ) {
                  returndatacopy(m, 0x00, returndatasize())
                  revert(m, returndatasize())
              }
              // Emit the {ApprovalForAll} event.
              // The `approved` value is already at 0x40.
              log3(0x40, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, caller(), operator)
              mstore(0x40, m) // Restore the free memory pointer.
              mstore(0x60, 0) // Restore the zero pointer.
          }
      }
  
      /// @dev Returns whether `operator` is approved to manage the tokens of `nftOwner` from
      /// the base DN404 contract.
      function isApprovedForAll(address nftOwner, address operator)
          public
          view
          virtual
          returns (bool)
      {
          // `isApprovedForAll(address,address)`.
          return _readWord(0xe985e9c5, uint160(nftOwner), uint160(operator)) != 0;
      }
  
      /// @dev Transfers token `id` from `from` to `to`.
      ///
      /// Requirements:
      ///
      /// - Token `id` must exist.
      /// - `from` must be the owner of the token.
      /// - `to` cannot be the zero address.
      /// - The caller must be the owner of the token, or be approved to manage the token.
      ///
      /// Emits a {Transfer} event.
      function transferFrom(address from, address to, uint256 id) public payable virtual {
          address base = baseERC20();
          /// @solidity memory-safe-assembly
          assembly {
              from := shr(96, shl(96, from))
              to := shr(96, shl(96, to))
              let m := mload(0x40)
              mstore(m, 0xe5eb36c8) // `transferFromNFT(address,address,uint256,address)`.
              mstore(add(m, 0x20), from)
              mstore(add(m, 0x40), to)
              mstore(add(m, 0x60), id)
              mstore(add(m, 0x80), caller())
              if iszero(
                  and( // Arguments of `and` are evaluated last to first.
                      eq(mload(m), 1), // The call must return 1.
                      call(gas(), base, callvalue(), add(m, 0x1c), 0x84, m, 0x20)
                  )
              ) {
                  returndatacopy(m, 0x00, returndatasize())
                  revert(m, returndatasize())
              }
              // Emit the {Transfer} event.
              log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, from, to, id)
          }
      }
  
      /// @dev Equivalent to `safeTransferFrom(from, to, id, "")`.
      function safeTransferFrom(address from, address to, uint256 id) public payable virtual {
          transferFrom(from, to, id);
          if (_hasCode(to)) _checkOnERC721Received(from, to, id, "");
      }
  
      /// @dev Transfers token `id` from `from` to `to`.
      ///
      /// Requirements:
      ///
      /// - Token `id` must exist.
      /// - `from` must be the owner of the token.
      /// - `to` cannot be the zero address.
      /// - The caller must be the owner of the token, or be approved to manage the token.
      /// - If `to` refers to a smart contract, it must implement
      ///   {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
      ///
      /// Emits a {Transfer} event.
      function safeTransferFrom(address from, address to, uint256 id, bytes calldata data)
          public
          payable
          virtual
      {
          transferFrom(from, to, id);
          if (_hasCode(to)) _checkOnERC721Received(from, to, id, data);
      }
  
      /// @dev Returns true if this contract implements the interface defined by `interfaceId`.
      /// See: https://eips.ethereum.org/EIPS/eip-165
      /// This function call must use less than 30000 gas.
      function supportsInterface(bytes4 interfaceId) public view virtual returns (bool result) {
          /// @solidity memory-safe-assembly
          assembly {
              let s := shr(224, interfaceId)
              // ERC165: 0x01ffc9a7, ERC721: 0x80ac58cd, ERC721Metadata: 0x5b5e139f.
              result := or(or(eq(s, 0x01ffc9a7), eq(s, 0x80ac58cd)), eq(s, 0x5b5e139f))
          }
      }
  
      /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
      /*                  OWNER SYNCING OPERATIONS                  */
      /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/
  
      /// @dev Returns the `owner` of the contract, for marketplace signaling purposes.
      function owner() public view virtual returns (address) {
          return _getDN404NFTStorage().owner;
      }
  /*
      /// @dev Permissionless function to pull the owner from the base DN404 contract
      /// if it implements ownable, for marketplace signaling purposes.
      function pullOwner() public virtual returns (bool) {
          address newOwner;
          address base = baseERC20();
          /// @solidity memory-safe-assembly
          assembly {
              mstore(0x00, 0x8da5cb5b) // `owner()`.
              let success := staticcall(gas(), base, 0x1c, 0x04, 0x00, 0x20)
              newOwner := mul(shr(96, mload(0x0c)), and(gt(returndatasize(), 0x1f), success))
          }
          DN404NFTStorage storage $ = _getDN404NFTStorage();
          address oldOwner = $.owner;
          if (oldOwner != newOwner) {
              $.owner = newOwner;
              emit OwnershipTransferred(oldOwner, newOwner);
          }
          return true;
      }
  */
  
      /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
      /*                     MIRROR OPERATIONS                      */
      /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/
  
      /// @dev Returns the address of the base DN404 contract.
      function baseERC20() public view virtual returns (address base) {
          base = _getDN404NFTStorage().baseERC20;
          if (base == address(0)) revert NotLinked();
      }
  
      /// @dev Fallback modifier to execute calls from the base DN404 contract.
      modifier dn404NFTFallback() virtual {
          DN404NFTStorage storage $ = _getDN404NFTStorage();
  
          uint256 fnSelector = _calldataload(0x00) >> 224;
  
          // `logTransfer(uint256[])`.
          if (fnSelector == 0x263c69d6) {
              if (msg.sender != $.baseERC20) revert SenderNotBase();
              /// @solidity memory-safe-assembly
              assembly {
                  let o := add(0x24, calldataload(0x04)) // Packed logs offset.
                  let end := add(o, shl(5, calldataload(sub(o, 0x20))))
                  for {} iszero(eq(o, end)) { o := add(0x20, o) } {
                      let d := calldataload(o) // Entry in the packed logs.
                      let a := shr(96, d) // The address.
                      let b := and(1, d) // Whether it is a burn.
                      log4(
                          codesize(),
                          0x00,
                          _TRANSFER_EVENT_SIGNATURE,
                          mul(a, b), // `from`.
                          mul(a, iszero(b)), // `to`.
                          shr(168, shl(160, d)) // `id`.
                      )
                  }
                  mstore(0x00, 0x01)
                  return(0x00, 0x20)
              }
          }
          // `logDirectTransfer(address,address,uint256[])`.
          if (fnSelector == 0x144027d3) {
              if (msg.sender != $.baseERC20) revert SenderNotBase();
              /// @solidity memory-safe-assembly
              assembly {
                  let from := calldataload(0x04)
                  let to := calldataload(0x24)
                  let o := add(0x24, calldataload(0x44)) // Direct logs offset.
                  let end := add(o, shl(5, calldataload(sub(o, 0x20))))
                  for {} iszero(eq(o, end)) { o := add(0x20, o) } {
                      log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, from, to, calldataload(o))
                  }
                  mstore(0x00, 0x01)
                  return(0x00, 0x20)
              }
          }
          // `linkMirrorContract(address)`.
          if (fnSelector == 0x0f4599e5) {
              if ($.deployer != address(0)) {
                  if (address(uint160(_calldataload(0x04))) != $.deployer) {
                      revert SenderNotDeployer();
                  }
              }
              if ($.baseERC20 != address(0)) revert AlreadyLinked();
              $.baseERC20 = msg.sender;
              /// @solidity memory-safe-assembly
              assembly {
                  mstore(0x00, 0x01)
                  return(0x00, 0x20)
              }
          }
          _;
      }
  
      /// @dev Fallback function for calls from base DN404 contract.
      /// Override this if you need to implement your custom
      /// fallback with utilities like Solady's `LibZip.cdFallback()`.
      /// And always remember to always wrap the fallback with `dn404NFTFallback`.
      fallback() external payable virtual dn404NFTFallback {
          revert FnSelectorNotRecognized(); // Not mandatory. Just for quality of life.
      }
  
      /// @dev This is to silence the compiler warning.
      /// Override and remove the revert if you want your contract to receive ETH via receive.
      receive() external payable virtual {
          if (msg.value != 0) revert();
      }
  
      /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
      /*                      PRIVATE HELPERS                       */
      /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/
  
      /// @dev Helper to read a string from the base DN404 contract.
      function _readString(uint256 fnSelector, uint256 arg0)
          private
          view
          returns (string memory result)
      {
          address base = baseERC20();
          /// @solidity memory-safe-assembly
          assembly {
              result := mload(0x40)
              mstore(0x00, fnSelector)
              mstore(0x20, arg0)
              if iszero(staticcall(gas(), base, 0x1c, 0x24, 0x00, 0x00)) {
                  returndatacopy(result, 0x00, returndatasize())
                  revert(result, returndatasize())
              }
              returndatacopy(0x00, 0x00, 0x20) // Copy the offset of the string in returndata.
              returndatacopy(result, mload(0x00), 0x20) // Copy the length of the string.
              returndatacopy(add(result, 0x20), add(mload(0x00), 0x20), mload(result)) // Copy the string.
              let end := add(add(result, 0x20), mload(result))
              mstore(end, 0) // Zeroize the word after the string.
              mstore(0x40, add(end, 0x20)) // Allocate memory.
          }
      }
  
      /// @dev Helper to read a word from the base DN404 contract.
      function _readWord(uint256 fnSelector, uint256 arg0, uint256 arg1)
          private
          view
          returns (uint256 result)
      {
          address base = baseERC20();
          /// @solidity memory-safe-assembly
          assembly {
              let m := mload(0x40)
              mstore(0x00, fnSelector)
              mstore(0x20, arg0)
              mstore(0x40, arg1)
              if iszero(
                  and( // Arguments of `and` are evaluated last to first.
                      gt(returndatasize(), 0x1f), // The call must return at least 32 bytes.
                      staticcall(gas(), base, 0x1c, 0x44, 0x00, 0x20)
                  )
              ) {
                  returndatacopy(m, 0x00, returndatasize())
                  revert(m, returndatasize())
              }
              mstore(0x40, m) // Restore the free memory pointer.
              result := mload(0x00)
          }
      }
  
      /// @dev Returns the calldata value at `offset`.
      function _calldataload(uint256 offset) private pure returns (uint256 value) {
          /// @solidity memory-safe-assembly
          assembly {
              value := calldataload(offset)
          }
      }
  
      /// @dev Returns if `a` has bytecode of non-zero length.
      function _hasCode(address a) private view returns (bool result) {
          /// @solidity memory-safe-assembly
          assembly {
              result := extcodesize(a) // Can handle dirty upper bits.
          }
      }
  
      /// @dev Perform a call to invoke {IERC721Receiver-onERC721Received} on `to`.
      /// Reverts if the target does not support the function correctly.
      function _checkOnERC721Received(address from, address to, uint256 id, bytes memory data)
          private
      {
          /// @solidity memory-safe-assembly
          assembly {
              // Prepare the calldata.
              let m := mload(0x40)
              let onERC721ReceivedSelector := 0x150b7a02
              mstore(m, onERC721ReceivedSelector)
              mstore(add(m, 0x20), caller()) // The `operator`, which is always `msg.sender`.
              mstore(add(m, 0x40), shr(96, shl(96, from)))
              mstore(add(m, 0x60), id)
              mstore(add(m, 0x80), 0x80)
              let n := mload(data)
              mstore(add(m, 0xa0), n)
              if n { pop(staticcall(gas(), 4, add(data, 0x20), n, add(m, 0xc0), n)) }
              // Revert if the call reverts.
              if iszero(call(gas(), to, 0, add(m, 0x1c), add(n, 0xa4), m, 0x20)) {
                  if returndatasize() {
                      // Bubble up the revert if the call reverts.
                      returndatacopy(m, 0x00, returndatasize())
                      revert(m, returndatasize())
                  }
              }
              // Load the returndata and compare it.
              if iszero(eq(mload(m), shl(224, onERC721ReceivedSelector))) {
                  mstore(0x00, 0xd1a57ed6) // `TransferToNonERC721ReceiverImplementer()`.
                  revert(0x1c, 0x04)
              }
          }
      }
  }
  
  
  // File contracts/pass/VelocityPass2.sol
  
  // Original license: SPDX_License_Identifier: MIT
  pragma solidity ^0.8.17;
  
  
  /**
   * @title VelocityPass2
   * @notice Sample DN404 contract that demonstrates the owner selling fungible tokens.
   * When a user has at least one base unit (10^18) amount of tokens, they will automatically receive an NFT.
   * NFTs are minted as an address accumulates each base unit amount of tokens.
   */
  contract VelocityPass2 is DN404Mirror, UUPSUpgradeable  {
  
      modifier onlyOwner() {
          require(owner() == msg.sender, "Ownable: not owner");
          _;
      }
  
      constructor() {
          _disableInitializers();
      }
  
      // required by the OZ UUPS module
      function _authorizeUpgrade(address) internal override onlyOwner {}
  
      function initialize(address _owner) external initializer {
          _initializeMirror(_owner, _owner);
          __UUPSUpgradeable_init();
      }
  
      function transferOwnership(address newOwner) external onlyOwner {
          require(newOwner != address(0), "Ownable: new owner is zero");
          _getDN404NFTStorage().owner = newOwner;
      }
  }