Description:
Multi-signature wallet contract requiring multiple confirmations for transaction execution.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"src/calculators/SupplyCalculator.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IZKC} from "../interfaces/IZKC.sol";
import {Supply} from "../libraries/Supply.sol";
/// @title Supply Calculator for ZKC tokens
/// @notice Contract computes various supply metrics of ZKC tokens, intended to be used by frontend apps/exchanges
contract SupplyCalculator is Initializable, AccessControlUpgradeable, UUPSUpgradeable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
/// @notice Admin role identifier
bytes32 public immutable ADMIN_ROLE = DEFAULT_ADMIN_ROLE;
/// @notice Reference to the ZKC token contract
IZKC public zkc;
/// @notice Amount of tokens considered unlocked and in circulation
uint256 public unlocked;
/// @notice Emitted when the unlocked value is updated
/// @param oldValue The previous unlocked value
/// @param newValue The new unlocked value
event UnlockedValueUpdated(uint256 oldValue, uint256 newValue);
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
/// @notice Initialize the SupplyCalculator contract
/// @param _zkc Address of the ZKC token contract
/// @param _initialUnlocked Initial value for the unlocked tokens
/// @param _admin Address that will be granted the admin role
function initialize(address _zkc, uint256 _initialUnlocked, address _admin) public initializer {
require(_zkc != address(0), "ZKC address cannot be zero");
require(_admin != address(0), "Admin address cannot be zero");
__AccessControl_init();
__UUPSUpgradeable_init();
zkc = IZKC(_zkc);
unlocked = _initialUnlocked;
_grantRole(ADMIN_ROLE, _admin);
}
/// @notice Calculate the current circulating supply
/// @dev Formula: unlocked + (zkc.claimedTotalSupply() - zkc.INITIAL_SUPPLY())
/// @dev Essentially, unlocked tokens from the initial mint + claimed rewards from PoVW and staking rewards
/// @return The current circulating supply of ZKC tokens
function circulatingSupply() public view returns (uint256) {
uint256 claimedTotal = zkc.claimedTotalSupply();
uint256 initialSupply = Supply.INITIAL_SUPPLY;
// Calculate the claimed rewards from PoVW and staking rewards
uint256 claimedRewards = claimedTotal - initialSupply;
return unlocked + claimedRewards;
}
/// @notice Calculate the current circulating supply rounded to the nearest whole token (18dp representation)
/// @dev Returns value in wei (18 decimals) but rounded such that when converted to whole tokens it's rounded
/// @return The current circulating supply rounded to nearest whole token in 18dp format
function circulatingSupplyRounded() public view returns (uint256) {
uint256 supply = circulatingSupply();
return _roundTo18dp(supply);
}
/// @notice Calculate the current circulating supply as a rounded whole number
/// @dev Returns the value in regular representation (divided by 10^18) rounded to nearest whole token
/// @return The current circulating supply as a whole number
function circulatingSupplyAmountRounded() public view returns (uint256) {
uint256 supply = circulatingSupply();
return _roundToWholeTokens(supply);
}
/// @notice Get the total supply
/// @dev This represents the theoretical total supply of ZKC tokens based on the current epoch
/// @return The total supply of ZKC tokens
function totalSupply() public view returns (uint256) {
return IERC20(address(zkc)).totalSupply();
}
/// @notice Get the total supply rounded to the nearest whole token (18dp representation)
/// @dev Returns value in wei (18 decimals) but rounded such that when converted to whole tokens it's rounded
/// @dev Uses the theoretical total supply based on current epoch
/// @return The total supply rounded to nearest whole token in 18dp format
function totalSupplyRounded() public view returns (uint256) {
uint256 supply = IERC20(address(zkc)).totalSupply();
return _roundTo18dp(supply);
}
/// @notice Get the total supply as a rounded whole number
/// @dev Returns the value in regular representation (divided by 10^18) rounded to nearest whole token
/// @dev Uses the theoretical total supply based on current epoch
/// @return The total supply as a whole number
function totalSupplyAmountRounded() public view returns (uint256) {
uint256 supply = IERC20(address(zkc)).totalSupply();
return _roundToWholeTokens(supply);
}
/// @notice Get the total claimed supply
/// @dev This represents the initial supply that was minted and allocated to initial minters,
/// as well as tokens that have been claimed (and thus minted) via PoVW or Staking rewards.
/// @return The total amount of tokens that have been claimed
function claimedTotalSupply() public view returns (uint256) {
return zkc.claimedTotalSupply();
}
/// @notice Get the claimed total supply rounded to the nearest whole token (18dp representation)
/// @dev Returns value in wei (18 decimals) but rounded such that when converted to whole tokens it's rounded
/// @dev Uses the actual claimed/minted supply
/// @return The claimed total supply rounded to nearest whole token in 18dp format
function claimedTotalSupplyRounded() public view returns (uint256) {
uint256 supply = zkc.claimedTotalSupply();
return _roundTo18dp(supply);
}
/// @notice Get the claimed total supply as a rounded whole number
/// @dev Returns the value in regular representation (divided by 10^18) rounded to nearest whole token
/// @dev Uses the actual claimed/minted supply
/// @return The claimed total supply as a whole number
function claimedTotalSupplyAmountRounded() public view returns (uint256) {
uint256 supply = zkc.claimedTotalSupply();
return _roundToWholeTokens(supply);
}
/// @notice Round a value to the nearest whole token (18dp representation)
/// @dev Rounds to nearest 1e18, so when divided by 1e18 it gives a whole number
/// @param value The value to round
/// @return The rounded value in 18dp format
function _roundTo18dp(uint256 value) private pure returns (uint256) {
uint256 remainder = value % 1e18;
if (remainder >= 5e17) {
// Round up
return value - remainder + 1e18;
} else {
// Round down
return value - remainder;
}
}
/// @notice Round a value to the nearest whole token and return as a whole number
/// @dev Divides by 1e18 with rounding
/// @param value The value to round
/// @return The rounded value as a whole number
function _roundToWholeTokens(uint256 value) private pure returns (uint256) {
uint256 remainder = value % 1e18;
if (remainder >= 5e17) {
// Round up
return (value / 1e18) + 1;
} else {
// Round down
return value / 1e18;
}
}
/// @notice Update the unlocked value
/// @dev Only callable by accounts with ADMIN_ROLE
/// @param _newUnlocked The new value for unlocked tokens
function updateUnlockedValue(uint256 _newUnlocked) external onlyRole(ADMIN_ROLE) {
uint256 oldValue = unlocked;
unlocked = _newUnlocked;
emit UnlockedValueUpdated(oldValue, _newUnlocked);
}
/// @notice Authorize contract upgrades (UUPS pattern)
/// @dev Only accounts with ADMIN_ROLE can authorize upgrades
/// @param newImplementation Address of the new implementation contract
function _authorizeUpgrade(address newImplementation) internal override onlyRole(ADMIN_ROLE) {}
}
"
},
"lib/openzeppelin-contracts-upgradeable/contracts/access/AccessControlUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/// @custom:storage-location erc7201:openzeppelin.storage.AccessControl
struct AccessControlStorage {
mapping(bytes32 role => RoleData) _roles;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;
function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {
assembly {
$.slot := AccessControlStorageLocation
}
}
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
function __AccessControl_init() internal onlyInitializing {
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
AccessControlStorage storage $ = _getAccessControlStorage();
bytes32 previousAdminRole = getRoleAdmin(role);
$._roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (!hasRole(role, account)) {
$._roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` from `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (hasRole(role, account)) {
$._roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}
"
},
"lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @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 Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 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 in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reinitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._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 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._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() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @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 {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Pointer to storage slot. Allows integrators to override it with a custom storage location.
*
* NOTE: Consider following the ERC-7201 formula to derive storage locations.
*/
function _initializableStorageSlot() internal pure virtual returns (bytes32) {
return INITIALIZABLE_STORAGE;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
bytes32 slot = _initializableStorageSlot();
assembly {
$.slot := slot
}
}
}
"
},
"lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.22;
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";
/**
* @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.
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable __self = address(this);
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
* and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
* while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
/**
* @dev The call is from an unauthorized context.
*/
error UUPSUnauthorizedCallContext();
/**
* @dev The storage `slot` is unsupported as a UUID.
*/
error UUPSUnsupportedProxiableUUID(bytes32 slot);
/**
* @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 ERC-1967) 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 ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
_checkProxy();
_;
}
/**
* @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() {
_checkNotDelegated();
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC-1822 {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 notDelegated returns (bytes32) {
return ERC1967Utils.IMPLEMENTATION_SLOT;
}
/**
* @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);
}
/**
* @dev Reverts if the execution is not performed via delegatecall or the execution
* context is not of a proxy with an ERC-1967 compliant implementation pointing to self.
*/
function _checkProxy() internal view virtual {
if (
address(this) == __self || // Must be called through delegatecall
ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
) {
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Reverts if the execution is performed via delegatecall.
* See {notDelegated}.
*/
function _checkNotDelegated() internal view virtual {
if (address(this) != __self) {
// Must not be called through delegatecall
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
*
* As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
* is expected to be the implementation slot in ERC-1967.
*
* Emits an {IERC1967-Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
revert UUPSUnsupportedProxiableUUID(slot);
}
ERC1967Utils.upgradeToAndCall(newImplementation, data);
} catch {
// The implementation is not UUPS
revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
}
}
}
"
},
"lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
"
},
"src/interfaces/IZKC.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
/// @title IZKC
/// @notice Interface for the ZKC token with epoch-based emissions
/// @dev Defines ZKC-specific functionality for epoch-based reward distribution
interface IZKC {
/// @notice Emitted when a recipient claims PoVW rewards.
/// @param recipient The address that claimed the rewards
/// @param amount The amount of ZKC tokens claimed
/// @dev The reward amount could include ZKC that was earned across multiple epochs.
event PoVWRewardsClaimed(address indexed recipient, uint256 amount);
/// @notice Emitted when a recipient claims staking rewards.
/// @param recipient The address that claimed the rewards
/// @param amount The amount of ZKC tokens claimed
/// @dev The reward amount could include ZKC that was earned across multiple epochs.
event StakingRewardsClaimed(address indexed recipient, uint256 amount);
error EpochNotEnded(uint256 epoch);
error TotalAllocationExceeded();
error EpochsNotStarted();
/// @notice Perform initial token distribution to specified recipients
/// @dev Only callable by designated initial minters
/// @param recipients Array of addresses to receive tokens
/// @param amounts Array of token amounts corresponding to each recipient
function initialMint(address[] calldata recipients, uint256[] calldata amounts) external;
/// @notice Mint PoVW rewards for a specific recipient
/// @dev Only callable by addresses with POVW_MINTER_ROLE
/// @param recipient Address to receive the minted rewards
/// @param amount Amount of tokens to mint
function mintPoVWRewardsForRecipient(address recipient, uint256 amount) external;
/// @notice Mint staking rewards for a specific recipient
/// @dev Only callable by addresses with STAKING_MINTER_ROLE
/// @param recipient Address to receive the minted rewards
/// @param amount Amount of tokens to mint
function mintStakingRewardsForRecipient(address recipient, uint256 amount) external;
/// @notice Get the total supply at the start of a specific epoch
/// @dev ZKC is emitted at the end of each epoch, so this excludes rewards generated
/// as part of staking/work during the current epoch.
/// @param epoch The epoch number (0-indexed)
/// @return The total supply at the start of the epoch
function getSupplyAtEpochStart(uint256 epoch) external pure returns (uint256);
/// @notice Get the cumulative total PoVW emissions since genesis up to the start of a specific epoch
/// @param epoch The epoch number
/// @return Total PoVW emissions up to the epoch start
function getTotalPoVWEmissionsAtEpochStart(uint256 epoch) external returns (uint256);
/// @notice Get the cumulative total staking emissions since genesis up to the start of a specific epoch
/// @param epoch The epoch number
/// @return Total staking emissions up to the epoch start
function getTotalStakingEmissionsAtEpochStart(uint256 epoch) external returns (uint256);
/// @notice Get the total ZKC that will be emitted at the _end_ of the specified epoch
/// @dev Includes both PoVW and staking rewards
/// @param epoch The epoch number
/// @return Total emissions for the epoch
function getEmissionsForEpoch(uint256 epoch) external returns (uint256);
/// @notice Get the PoVW emissions that will be emitted at the _end_ of the specified epoch
/// @param epoch The epoch number
/// @return PoVW emissions for the epoch
function getPoVWEmissionsForEpoch(uint256 epoch) external returns (uint256);
/// @notice Get the staking emissions that will be emitted at the _end_ of the specified epoch
/// @param epoch The epoch number
/// @return Staking emissions for the epoch
function getStakingEmissionsForEpoch(uint256 epoch) external returns (uint256);
/// @notice Get the current epoch number
/// @dev Calculated based on time elapsed since deployment.
/// @dev Reverts if epochs have not started yet.
/// @return The current epoch number (0-indexed)
function getCurrentEpoch() external view returns (uint256);
/// @notice Get the current epoch end time
/// @dev Returns the final timestamp at which the current epoch is active.
/// After this time, rewards will be emitted.
/// @return The timestamp when the current epoch ends
function getCurrentEpochEndTime() external view returns (uint256);
/// @notice Get the start timestamp of a specific epoch
/// @dev Reverts if epochs have not started yet.
/// @param epoch The epoch number
/// @return The timestamp when the epoch starts
function getEpochStartTime(uint256 epoch) external view returns (uint256);
/// @notice Get the end timestamp of a specific epoch
/// @dev Returns the final timestamp at which the epoch is active
/// @dev Reverts if epochs have not started yet.
/// @param epoch The epoch number
/// @return The timestamp when the epoch ends
function getEpochEndTime(uint256 epoch) external view returns (uint256);
/// @notice Get the actual minted and claimed total supply
/// @dev This represents the initial supply that was minted and allocated to initial minters,
/// as well as tokens that have been claimed (and thus minted) via PoVW or Staking rewards.
/// @return The total amount of tokens that have been claimed
function claimedTotalSupply() external view returns (uint256);
}
"
},
"src/libraries/Supply.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {UD60x18, ud, unwrap, pow, convert} from "lib/prb-math/src/UD60x18.sol";
/// @title ZKC Supply Library
/// @notice Library for calculating ZKC supply and emissions based on epoch
/// @dev Annual supply values and epoch scaling factors per year are precomputed for gas efficiency.
/// Precomputed values were created by running the script/PrecomputeSupply.s.sol script.
///
/// Inflation schedule:
/// - Year 0: 7.0% annual, reduces by 0.5% each year
/// - Year 8+: 3.0% annual (minimum rate)
library Supply {
uint256 public constant INITIAL_SUPPLY = 1_000_000_000 * 10 ** 18; // 1 billion ZKC
uint256 public constant EPOCHS_PER_YEAR = 182;
uint256 public constant EPOCH_DURATION = 2 days;
/// @notice Precomputed per-epoch growth factors (1e18 scaled)
/// @dev Calculated with PRBMath UD60x18: r = (1 + annual_rate)^(1/182)
uint256 public constant Y0_R_PER_EPOCH = 1000371819923688085; // Year 0: 7.000% annual
uint256 public constant Y1_R_PER_EPOCH = 1000346075250234369; // Year 1: 6.500% annual
uint256 public constant Y2_R_PER_EPOCH = 1000320210092156012; // Year 2: 6.000% annual
uint256 public constant Y3_R_PER_EPOCH = 1000294223313256956; // Year 3: 5.500% annual
uint256 public constant Y4_R_PER_EPOCH = 1000268113761178075; // Year 4: 5.000% annual
uint256 public constant Y5_R_PER_EPOCH = 1000241880267088989; // Year 5: 4.500% annual
uint256 public constant Y6_R_PER_EPOCH = 1000215521645372515; // Year 6: 4.000% annual
uint256 public constant Y7_R_PER_EPOCH = 1000189036693301502; // Year 7: 3.500% annual
uint256 public constant Y8_R_PER_EPOCH = 1000162424190707866; // Year 8+: 3.000% annual
/// @dev Year 8 and beyond use the minimum 3% rate
uint256 public constant FINAL_R_PER_EPOCH = Y8_R_PER_EPOCH;
/// @notice Precomputed supply values at year boundaries for optimization
/// @dev These values represent the total supply at the START of each year, where a year
/// is defined as 182 epochs.
uint256 public constant SUPPLY_YEAR_0 = INITIAL_SUPPLY;
uint256 public constant SUPPLY_YEAR_1 = 1069999999999998184000000000; // Supply at epoch 182
uint256 public constant SUPPLY_YEAR_2 = 1139549999999995737640000000; // Supply at epoch 364
uint256 public constant SUPPLY_YEAR_3 = 1207922999999993680269850000; // Supply at epoch 546
uint256 public constant SUPPLY_YEAR_4 = 1274358764999991093195449750; // Supply at epoch 728
uint256 public constant SUPPLY_YEAR_5 = 1338076703249988310681247227; // Supply at epoch 910
uint256 public constant SUPPLY_YEAR_6 = 1398290154896235164707718388; // Supply at epoch 1092
uint256 public constant SUPPLY_YEAR_7 = 1454221761092082452886442455; // Supply at epoch 1274
uint256 public constant SUPPLY_YEAR_8 = 1505119522730302372125075313; // Supply at epoch 1456
uint256 public constant SUPPLY_YEAR_9 = 1550273108412208360804045020; // Supply at epoch 1638
/// @notice Calculate the total supply at the start of a given epoch
/// @param epoch The epoch number (0-indexed)
/// @return The total supply at the start of the epoch
function getSupplyAtEpoch(uint256 epoch) internal pure returns (uint256) {
if (epoch == 0) return SUPPLY_YEAR_0;
// Determine which year this epoch falls into
uint256 year = getYearForEpoch(epoch);
// Start from the precomputed supply at the beginning of this year
uint256 supply = _getSupplyAtYearBoundary(year);
// Calculate the starting epoch for this year
uint256 yearStartEpoch = year * EPOCHS_PER_YEAR;
// Get the growth factor for this year
uint256 growthFactor = _getGrowthFactorForYear(year);
// Calculate how many epochs within the year we need to apply growth for
uint256 epochsInYear = epoch - yearStartEpoch;
if (epochsInYear == 0) {
return supply;
}
// Calculate: supply * (growthFactor ^ epochsInYear)
// Everything is scaled by 1e18 for PRBMath.
UD60x18 supplyUD = ud(supply);
UD60x18 factorUD = ud(growthFactor);
UD60x18 epochsUD = convert(epochsInYear);
// Calculate factor^epochs
UD60x18 multiplierUD = pow(factorUD, epochsUD);
// Apply to supply: supply * multiplier
UD60x18 resultUD = supplyUD * multiplierUD;
return unwrap(resultUD);
}
/// @notice Get precomputed supply at year boundary
/// @param year The year number (0-indexed)
/// @return The supply at the start of that year
function _getSupplyAtYearBoundary(uint256 year) internal pure returns (uint256) {
if (year == 0) return SUPPLY_YEAR_0;
if (year == 1) return SUPPLY_YEAR_1;
if (year == 2) return SUPPLY_YEAR_2;
if (year == 3) return SUPPLY_YEAR_3;
if (year == 4) return SUPPLY_YEAR_4;
if (year == 5) return SUPPLY_YEAR_5;
if (year == 6) return SUPPLY_YEAR_6;
if (year == 7) return SUPPLY_YEAR_7;
if (year == 8) return SUPPLY_YEAR_8;
if (year == 9) return SUPPLY_YEAR_9;
// For year 10+, calculate from year 9 using PRBMath
uint256 supply = SUPPLY_YEAR_9;
uint256 yearsToCalculate = year - 9;
// Use PRBMath to calculate: supply * (FINAL_R_PER_EPOCH ^ (yearsToCalculate * EPOCHS_PER_YEAR))
UD60x18 supplyUD = ud(supply);
UD60x18 factorUD = ud(FINAL_R_PER_EPOCH);
UD60x18 totalEpochsUD = convert(yearsToCalculate * EPOCHS_PER_YEAR);
// Calculate factor^totalEpochs
UD60x18 multiplierUD = pow(factorUD, totalEpochsUD);
// Apply to supply: supply * multiplier
UD60x18 resultUD = supplyUD * multiplierUD;
return unwrap(resultUD);
}
/// @notice Get growth factor for a specific year
/// @param year The year number (0-indexed)
/// @return The per-epoch growth factor for that year
function _getGrowthFactorForYear(uint256 year) internal pure returns (uint256) {
if (year == 0) return Y0_R_PER_EPOCH;
if (year == 1) return Y1_R_PER_EPOCH;
if (year == 2) return Y2_R_PER_EPOCH;
if (year == 3) return Y3_R_PER_EPOCH;
if (year == 4) return Y4_R_PER_EPOCH;
if (year == 5) return Y5_R_PER_EPOCH;
if (year == 6) return Y6_R_PER_EPOCH;
if (year == 7) return Y7_R_PER_EPOCH;
// Year 8 and beyond use the minimum rate
return FINAL_R_PER_EPOCH;
}
/// @notice Returns the amount of ZKC that will be emitted at the end of the provided epoch.
/// @param epoch The epoch number
/// @dev Caches supply calculations to save gas for batch mint scenarios.
/// There is possible repeated work, between the two getSupplyAtEpoch calls as they
/// one does exp(_, epoch) and the other does exp(_, epoch+1).
/// @return The amount of new tokens to be emitted at the end of this epoch
function getEmissionsForEpoch(uint256 epoch) internal returns (uint256) {
uint256 supplyAtNextEpoch = _getCachedEpochSupply(epoch + 1);
if (supplyAtNextEpoch == 0) {
supplyAtNextEpoch = getSupplyAtEpoch(epoch + 1);
_cacheEpochSupply(epoch + 1, supplyAtNextEpoch);
}
uint256 supplyAtEpoch = _getCachedEpochSupply(epoch);
if (supplyAtEpoch == 0) {
supplyAtEpoch = getSupplyAtEpoch(epoch);
_cacheEpochSupply(epoch, supplyAtEpoch);
}
return supplyAtNextEpoch - supplyAtEpoch;
}
/// @notice Get which year a given epoch falls into
/// @param epoch The epoch number (0-indexed)
/// @return The year number (0-indexed)
function getYearForEpoch(uint256 epoch) internal pure returns (uint256) {
return epoch / EPOCHS_PER_YEAR;
}
/// @notice Supply values for epochs are cached, to enable efficient batch claims of epochs.
/// @dev This is a transient storage cache, so it is not persisted across blocks.
/// NOTE: We do not need to clear the cache after use, as supply values are deterministic.
/// @dev Apply a prefix to reduce risk of collisions with future tstore features.
/// Prefix is "ZKCEMISSIONS" hex encoded (0x5A4B43454D495353494F4E53) padded to 32 bytes.
/// Leaves 20 bytes for epoch (max epoch: 2^160 - 1).
bytes32 private constant CACHE_PREFIX = 0x5A4B43454D495353494F4E530000000000000000000000000000000000000000;
/// @notice Calculate transient storage slot for epoch supply cache
/// @param epoch The epoch number to cache
/// @return slot The transient storage slot
function _getSupplyCacheSlot(uint256 epoch) private pure returns (bytes32 slot) {
assembly {
slot := or(CACHE_PREFIX, epoch)
}
}
function _cacheEpochSupply(uint256 epoch, uint256 supply) internal {
bytes32 slot = _getSupplyCacheSlot(epoch);
assembly {
tstore(slot, supply)
}
}
function _getCachedEpochSupply(uint256 epoch) internal view returns (uint256 supply) {
bytes32 slot = _getSupplyCacheSlot(epoch);
assembly {
supply := tload(slot)
}
}
}
"
},
"lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/access/IAccessControl.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC-165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted to signal this.
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
* Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}
"
},
"lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
"
},
"lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
"
},
"lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/ERC165Upgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165Upgradeable is Initializable, IERC165 {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
"
},
"lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/interfaces/draft-IERC1822.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.20;
/**
* @dev ERC-1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @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);
}
"
},
"lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Utils.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.22;
import {IBeacon} from "../beacon/IBeacon.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
/**
* @dev This library provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.
*/
library ERC1967Utils {
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/
error ERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/
error ERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/
error ERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/
error ERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit IERC1967.Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-AdminChanged} event.
*/
function changeAdmin(address newAdmin) internal {
emit IERC1967.AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the ERC-1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplemen
Submitted on: 2025-10-16 10:47:05
Comments
Log in to comment.
No comments yet.