Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- GuardianNodeStakingPool
- Optimization enabled
- true
- Compiler version
- v0.8.23+commit.f704f362
- Optimization runs
- 200
- EVM Version
- paris
- Verified at
- 2024-09-24T03:39:48.501246Z
contracts/GuardianNodeStakingPool.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.23; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts/interfaces/IERC721Receiver.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "./interfaces/IGuardianNode.sol"; contract GuardianNodeStakingPool is IERC721Receiver, Initializable, AccessControlUpgradeable, UUPSUpgradeable, PausableUpgradeable { using SafeERC20 for IERC20; struct LicenseInfo { uint256 totalLockedTime; uint256 totalClaimedRewards; uint256 lastUpdateAt; uint256 lastClaimedAt; } struct UserStakeInfo { address user; uint256 stakeAt; uint256 totalLockedTime; uint256 totalClaimedRewards; uint256 lastUpdateAt; } struct ClaimRewardInfo { uint256 licenseId; uint256 amount; } struct LicenseLockInfo { uint256 stakeTime; uint256 totalLockedTime; uint256 totalRewards; } bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE"); mapping(uint256 _nftId => LicenseInfo _license) public licenses; mapping(address _user => mapping(uint256 _licenseId => UserStakeInfo _info)) public userStakeInfos; mapping(uint256 _nftId => address _owner) public nftStakeOwners; mapping(address _user => uint256 _totalLicenses) public userTotalLicenses; mapping(address _user => uint256 _totalRewards) public userTotalRewards; uint256 public totalStakingLicenses; uint256 public totalClaimedRewards; uint256 public FOUR_YEAR_IN_SECONDS; //126144000s uint256 public FOUR_YEAR_REWARDS; //864 - 288 uint256 public REWARDS_PER_SECOND; uint256 public MAX_CLAIM_REWARDS; uint256 public CLAIM_TIME; address public GUARDIAN; address public REWARD_TOKEN; uint256 public START_TIME; uint256 public END_TIME; uint256 public INIT_AIRDROP; event UpdateLicenseLockTime(uint256 indexed _licenseId, uint256 indexed _time, uint256 indexed _totalLockedTime); event UpdateUserLockTime(uint256 indexed _licenseId, address indexed _user, uint256 indexed _time, uint256 _totalLockedTime); event ClaimLicenseReward(uint256 indexed _licenseId, uint256 indexed _amount, uint256 indexed _totalClaimedRewards); event Stake(uint256 indexed _licenseId, address indexed _user, uint256 indexed _time); event UnStake(uint256 indexed _licenseId, address indexed _user); event ClaimReward(uint256 indexed _licenseId, address indexed _user, uint256 indexed _rewards); function _authorizeUpgrade(address newImplementation) internal override onlyRole(ADMIN_ROLE) {} receive() external payable {} function initialize(address _admin, address _guardian, uint256 _startTime) external initializer { require(_admin != address(0), '_admin Zero Address'); require(_guardian != address(0), '_nft Zero Address'); require(_startTime > 0, '_startTime Zero'); FOUR_YEAR_IN_SECONDS = 4 * 365 days; FOUR_YEAR_REWARDS = 576 * 1e18; //864 - 288 INIT_AIRDROP = 288 * 1e18; REWARDS_PER_SECOND = FOUR_YEAR_REWARDS / FOUR_YEAR_IN_SECONDS; GUARDIAN = _guardian; START_TIME = _startTime; END_TIME = START_TIME + 30 days; _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); _grantRole(ADMIN_ROLE, msg.sender); _grantRole(ADMIN_ROLE, _admin); __AccessControl_init(); __UUPSUpgradeable_init(); __Pausable_init(); } function setFourYearInSecond(uint256 _seconds) external onlyRole(ADMIN_ROLE) { FOUR_YEAR_IN_SECONDS = _seconds; } function setFourYearReward(uint256 _reward) external onlyRole(ADMIN_ROLE) { FOUR_YEAR_REWARDS = _reward; } function setRewardPerSecond(uint256 _reward) external onlyRole(ADMIN_ROLE) { REWARDS_PER_SECOND = _reward; } function setMaxClaimReward(uint256 _reward) external onlyRole(ADMIN_ROLE) { MAX_CLAIM_REWARDS = _reward; } function setInitAirdrop(uint256 _airdrop) external onlyRole(ADMIN_ROLE) { INIT_AIRDROP = _airdrop; } function setGuardian(address _guardian) external onlyRole(ADMIN_ROLE) { GUARDIAN = _guardian; } function setRewardToken(address _token) external onlyRole(ADMIN_ROLE) { REWARD_TOKEN = _token; } function setClaimTime(uint256 _time) external onlyRole(ADMIN_ROLE) { CLAIM_TIME = _time; } function setStartTime(uint256 _startTime) external onlyRole(ADMIN_ROLE) { START_TIME = _startTime; } function setEndTime(uint256 _endTime) external onlyRole(ADMIN_ROLE) { END_TIME = _endTime; } function redeemNative(address _to, uint256 _amount) external onlyRole(ADMIN_ROLE) { payable(_to).transfer(_amount); } function redeemToken(address _token, address _to, uint256 _amount) external onlyRole(ADMIN_ROLE) { IERC20(_token).safeTransfer(_to, _amount); } function rescueLicense(uint256 _licenseId, address _to) external onlyRole(ADMIN_ROLE) { IGuardianNode(GUARDIAN).safeTransferFrom(address(this), _to, _licenseId); } function stakeGuardianNode( uint256 _licenseId ) external whenNotPaused { require(block.timestamp >= START_TIME, 'Not Start'); require(block.timestamp < END_TIME, 'Ended'); require(GUARDIAN != address(0), 'Invalid Guardian Node'); _stake(_licenseId); } function stakeGuardianNodes( uint256[] calldata _licenseIds ) external whenNotPaused { require(block.timestamp >= START_TIME, 'Not Start'); require(block.timestamp < END_TIME, 'Ended'); require(GUARDIAN != address(0), 'Invalid Guardian Node'); require(_licenseIds.length > 0, 'Invalid License List'); for (uint256 i = 0; i < _licenseIds.length; i++) { _stake(_licenseIds[i]); } } function unStakeGuardianNode( uint256 _licenseId ) external whenNotPaused { _unStake(_licenseId); } function unStakeGuardianNodes( uint256[] calldata _licenseIds ) external whenNotPaused { require(_licenseIds.length > 0, 'Invalid License List'); for (uint256 i = 0; i < _licenseIds.length; i++) _unStake(_licenseIds[i]); } function claimGuardianNodeRewards( ClaimRewardInfo calldata _info ) external whenNotPaused { require(CLAIM_TIME > 0 && block.timestamp > CLAIM_TIME, 'Not Start'); _claimReward(_info); } function claimGuardianNodesRewards( ClaimRewardInfo[] calldata _infos ) external whenNotPaused { require(CLAIM_TIME > 0 && block.timestamp > CLAIM_TIME, 'Not Start'); require(_infos.length > 0, 'Empty Claim Request List'); for (uint256 i = 0; i < _infos.length; i++) { _claimReward(_infos[i]); } } function getAvailableRewards( address _user, uint256[] calldata _licenseIds ) external view returns (uint256[] memory) { uint256[] memory result = new uint256[](_licenseIds.length); for (uint256 i = 0; i < _licenseIds.length; i++) { (uint256 rewards,) = _availableReward(_user, _licenseIds[i]); result[i] = rewards; } return result; } function getUserLicenseRewards( address _user, uint256[] calldata _licenseIds ) external view returns (LicenseLockInfo[] memory) { LicenseLockInfo[] memory result = new LicenseLockInfo[](_licenseIds.length); for (uint256 i = 0; i < _licenseIds.length; i++) { (uint256 rewards, uint256 lockTime) = _availableReward(_user, _licenseIds[i]); result[i].stakeTime = userStakeInfos[_user][_licenseIds[i]].stakeAt; result[i].totalRewards = rewards; result[i].totalLockedTime = lockTime; } return result; } function _stake(uint256 _licenseId) internal { LicenseInfo storage license = licenses[_licenseId]; UserStakeInfo storage userStakeInfo = userStakeInfos[msg.sender][_licenseId]; require(_licenseId > 0, '_licenseId Zero'); require(license.totalLockedTime < FOUR_YEAR_IN_SECONDS, 'Max 4 Years'); require(nftStakeOwners[_licenseId] == address(0), 'Staking'); license.lastUpdateAt = block.timestamp; nftStakeOwners[_licenseId] = msg.sender; userTotalLicenses[msg.sender] += 1; userStakeInfo.stakeAt = block.timestamp; totalStakingLicenses += 1; IGuardianNode(GUARDIAN).safeTransferFrom(msg.sender, address(this), _licenseId); emit Stake(_licenseId, msg.sender, userStakeInfo.stakeAt); } function _unStake( uint256 _licenseId ) internal { UserStakeInfo storage userStakeInfo = userStakeInfos[msg.sender][_licenseId]; require(nftStakeOwners[_licenseId] == msg.sender, 'Only Owner Of License'); require(userStakeInfo.stakeAt > 0, 'License Is Not Staked'); _updateStake(msg.sender, _licenseId); nftStakeOwners[_licenseId] = address(0); userTotalLicenses[msg.sender] -= 1; userStakeInfo.stakeAt = 0; totalStakingLicenses -= 1; IGuardianNode(GUARDIAN).safeTransferFrom(address(this), msg.sender, _licenseId); emit UnStake(_licenseId, msg.sender); } function _claimReward( ClaimRewardInfo calldata _info ) internal { LicenseInfo storage license = licenses[_info.licenseId]; UserStakeInfo storage userStakeInfo = userStakeInfos[msg.sender][_info.licenseId]; require(_info.amount > 0, 'Invalid Amount'); require(license.totalClaimedRewards + _info.amount <= FOUR_YEAR_REWARDS, 'Exceed 4 Years Reward'); require(license.totalClaimedRewards + _info.amount <= MAX_CLAIM_REWARDS, 'Max Claim Reward'); uint256 availableReward = _updateStake(msg.sender, _info.licenseId); require(_info.amount <= availableReward, 'Exceed Available Reward'); license.totalClaimedRewards += _info.amount; license.lastClaimedAt = block.timestamp; userStakeInfo.totalClaimedRewards += _info.amount; userStakeInfo.lastUpdateAt = block.timestamp; userTotalRewards[msg.sender] += _info.amount; totalClaimedRewards += _info.amount; if (REWARD_TOKEN == address(0)) { (bool success,) = payable(msg.sender).call{value: _info.amount}(""); require(success, "Transfer Native Failed!"); } else { require(IERC20(REWARD_TOKEN).balanceOf(address(this)) >= _info.amount, "Insufficient Balance"); IERC20(REWARD_TOKEN).safeTransfer(msg.sender, _info.amount); } emit ClaimLicenseReward(_info.licenseId, _info.amount, license.totalClaimedRewards); emit ClaimReward(_info.licenseId, msg.sender, _info.amount); } function _updateStake( address _user, uint256 _licenseId ) internal returns (uint256) { UserStakeInfo storage userStakeInfo = userStakeInfos[_user][_licenseId]; LicenseInfo storage license = licenses[_licenseId]; if (userStakeInfo.stakeAt > 0) { uint256 markTime = block.timestamp < END_TIME ? block.timestamp : END_TIME; uint256 totalLockedTime = 0; if (markTime > userStakeInfo.stakeAt) { totalLockedTime = markTime - userStakeInfo.stakeAt; } if (license.totalLockedTime < FOUR_YEAR_IN_SECONDS) { if (license.totalLockedTime + totalLockedTime > FOUR_YEAR_IN_SECONDS) { totalLockedTime = FOUR_YEAR_IN_SECONDS - license.totalLockedTime; } } else { totalLockedTime = 0; } if (totalLockedTime > 0) { userStakeInfo.totalLockedTime += totalLockedTime; userStakeInfo.stakeAt = block.timestamp; userStakeInfo.lastUpdateAt = block.timestamp; license.totalLockedTime += totalLockedTime; license.lastUpdateAt = block.timestamp; emit UpdateLicenseLockTime(_licenseId, totalLockedTime, license.totalLockedTime); emit UpdateUserLockTime(_licenseId, _user, totalLockedTime, userStakeInfo.totalLockedTime); } } uint256 availableRewards = 0; if (license.totalClaimedRewards >= FOUR_YEAR_REWARDS) { return availableRewards; } uint256 totalRewards = INIT_AIRDROP + userStakeInfo.totalLockedTime * REWARDS_PER_SECOND; if (userStakeInfo.totalClaimedRewards >= totalRewards) { return availableRewards; } uint256 totalLicenseRewards = FOUR_YEAR_REWARDS + INIT_AIRDROP; availableRewards = totalRewards - userStakeInfo.totalClaimedRewards; if (license.totalClaimedRewards < totalLicenseRewards) { if (license.totalClaimedRewards + availableRewards >= totalLicenseRewards) { availableRewards = totalLicenseRewards - license.totalClaimedRewards; } } else { availableRewards = 0; } return availableRewards; } function _availableReward( address _user, uint256 _licenseId ) internal view returns (uint256, uint256) { UserStakeInfo memory userStakeInfo = userStakeInfos[_user][_licenseId]; LicenseInfo memory license = licenses[_licenseId]; uint256 totalLockingTime = 0; if (userStakeInfo.stakeAt > 0) { uint256 markTime = block.timestamp < END_TIME ? block.timestamp : END_TIME; if (markTime > userStakeInfo.stakeAt) { totalLockingTime = markTime - userStakeInfo.stakeAt; } if (license.totalLockedTime < FOUR_YEAR_IN_SECONDS) { if (license.totalLockedTime + totalLockingTime > FOUR_YEAR_IN_SECONDS) { totalLockingTime = FOUR_YEAR_IN_SECONDS - license.totalLockedTime; } } else { totalLockingTime = 0; } } uint256 totalLicenseRewards = FOUR_YEAR_REWARDS + INIT_AIRDROP; uint256 availableRewards = 0; if (license.totalClaimedRewards >= totalLicenseRewards) { return (availableRewards, FOUR_YEAR_IN_SECONDS); } uint256 totalTime = userStakeInfo.totalLockedTime + totalLockingTime; uint256 totalRewards = INIT_AIRDROP + totalTime * REWARDS_PER_SECOND; if (userStakeInfo.totalClaimedRewards >= totalRewards) { return (availableRewards, totalTime); } availableRewards = totalRewards - userStakeInfo.totalClaimedRewards; if (license.totalClaimedRewards < totalLicenseRewards) { if (license.totalClaimedRewards + availableRewards > totalLicenseRewards) { availableRewards = totalLicenseRewards - license.totalClaimedRewards; totalTime = FOUR_YEAR_IN_SECONDS; } } else { availableRewards = 0; totalTime = FOUR_YEAR_IN_SECONDS; } return (availableRewards, totalTime); } function pause() external whenNotPaused onlyRole(ADMIN_ROLE) { _pause(); } function unpause() external whenPaused onlyRole(ADMIN_ROLE) { _unpause(); } function onERC721Received( address, address, uint256, bytes memory ) external virtual override returns (bytes4) { return this.onERC721Received.selector; } }
@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC20Permit} from "../extensions/IERC20Permit.sol"; import {Address} from "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev An operation with an ERC20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0; } }
@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol"; import {ContextUpgradeable} from "../utils/ContextUpgradeable.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 { } /** * @dev See {IERC165-supportsInterface}. */ 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` to `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; } } }
@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.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 reininitialization) 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 Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.20; 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 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() { _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 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 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 ERC1967-compliant implementation pointing to self. * See {_onlyProxy}. */ 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 ERC1967. * * 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); } } }
@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol
// 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; } }
@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol) pragma solidity ^0.8.20; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /// @custom:storage-location erc7201:openzeppelin.storage.Pausable struct PausableStorage { bool _paused; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300; function _getPausableStorage() private pure returns (PausableStorage storage $) { assembly { $.slot := PausableStorageLocation } } /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); /** * @dev The operation failed because the contract is paused. */ error EnforcedPause(); /** * @dev The operation failed because the contract is not paused. */ error ExpectedPause(); /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { PausableStorage storage $ = _getPausableStorage(); $._paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { PausableStorage storage $ = _getPausableStorage(); return $._paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { if (paused()) { revert EnforcedPause(); } } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { if (!paused()) { revert ExpectedPause(); } } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { PausableStorage storage $ = _getPausableStorage(); $._paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { PausableStorage storage $ = _getPausableStorage(); $._paused = false; emit Unpaused(_msgSender()); } }
@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.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 ERC165 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 { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
@openzeppelin/contracts/access/IAccessControl.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol) pragma solidity ^0.8.20; /** * @dev External interface of AccessControl declared to support ERC165 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 signaling 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, an admin role * bearer except when using {AccessControl-_setupRole}. */ 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; }
@openzeppelin/contracts/interfaces/IERC721Receiver.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC721Receiver.sol) pragma solidity ^0.8.20; import {IERC721Receiver} from "../token/ERC721/IERC721Receiver.sol";
@openzeppelin/contracts/interfaces/draft-IERC1822.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.20; /** * @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 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); }
@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol) pragma solidity ^0.8.20; import {IBeacon} from "../beacon/IBeacon.sol"; import {Address} from "../../utils/Address.sol"; import {StorageSlot} from "../../utils/StorageSlot.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. */ library ERC1967Utils { // We re-declare ERC-1967 events here because they can't be used directly from IERC1967. // This will be fixed in Solidity 0.8.21. At that point we should remove these events. /** * @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); /** * @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 EIP1967 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 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 EIP1967) 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 EIP1967 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 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 EIP1967 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 ERC1967InvalidImplementation(beaconImplementation); } } /** * @dev Change the beacon and trigger a 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-BeaconUpgraded} event. * * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for * efficiency. */ function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } else { _checkNonPayable(); } } /** * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract * if an upgrade doesn't perform an initialization call. */ function _checkNonPayable() private { if (msg.value > 0) { revert ERC1967NonPayable(); } } }
@openzeppelin/contracts/proxy/beacon/IBeacon.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.20; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {UpgradeableBeacon} will check that this address is a contract. */ function implementation() external view returns (address); }
@openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ 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); }
@openzeppelin/contracts/token/ERC721/IERC721.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - 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 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or * {setApprovalForAll}. * - 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 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the address zero. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.20; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be * reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
@openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @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.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @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 or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * 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. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @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`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) 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 FailedInnerCall(); } } }
@openzeppelin/contracts/utils/StorageSlot.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.20; /** * @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(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` */ library StorageSlot { 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 } } }
@openzeppelin/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * 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[EIP 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); }
contracts/interfaces/IGuardianNode.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.23; import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; interface IGuardianNode is IERC721 { function mint(address _to, uint256 _tokenId, string memory _uri) external; }
Compiler Settings
{"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{},"evmVersion":"paris"}
Contract ABI
[{"type":"error","name":"AccessControlBadConfirmation","inputs":[]},{"type":"error","name":"AccessControlUnauthorizedAccount","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"bytes32","name":"neededRole","internalType":"bytes32"}]},{"type":"error","name":"AddressEmptyCode","inputs":[{"type":"address","name":"target","internalType":"address"}]},{"type":"error","name":"AddressInsufficientBalance","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"error","name":"ERC1967InvalidImplementation","inputs":[{"type":"address","name":"implementation","internalType":"address"}]},{"type":"error","name":"ERC1967NonPayable","inputs":[]},{"type":"error","name":"EnforcedPause","inputs":[]},{"type":"error","name":"ExpectedPause","inputs":[]},{"type":"error","name":"FailedInnerCall","inputs":[]},{"type":"error","name":"InvalidInitialization","inputs":[]},{"type":"error","name":"NotInitializing","inputs":[]},{"type":"error","name":"SafeERC20FailedOperation","inputs":[{"type":"address","name":"token","internalType":"address"}]},{"type":"error","name":"UUPSUnauthorizedCallContext","inputs":[]},{"type":"error","name":"UUPSUnsupportedProxiableUUID","inputs":[{"type":"bytes32","name":"slot","internalType":"bytes32"}]},{"type":"event","name":"ClaimLicenseReward","inputs":[{"type":"uint256","name":"_licenseId","internalType":"uint256","indexed":true},{"type":"uint256","name":"_amount","internalType":"uint256","indexed":true},{"type":"uint256","name":"_totalClaimedRewards","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"ClaimReward","inputs":[{"type":"uint256","name":"_licenseId","internalType":"uint256","indexed":true},{"type":"address","name":"_user","internalType":"address","indexed":true},{"type":"uint256","name":"_rewards","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint64","name":"version","internalType":"uint64","indexed":false}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Stake","inputs":[{"type":"uint256","name":"_licenseId","internalType":"uint256","indexed":true},{"type":"address","name":"_user","internalType":"address","indexed":true},{"type":"uint256","name":"_time","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"UnStake","inputs":[{"type":"uint256","name":"_licenseId","internalType":"uint256","indexed":true},{"type":"address","name":"_user","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"UpdateLicenseLockTime","inputs":[{"type":"uint256","name":"_licenseId","internalType":"uint256","indexed":true},{"type":"uint256","name":"_time","internalType":"uint256","indexed":true},{"type":"uint256","name":"_totalLockedTime","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"UpdateUserLockTime","inputs":[{"type":"uint256","name":"_licenseId","internalType":"uint256","indexed":true},{"type":"address","name":"_user","internalType":"address","indexed":true},{"type":"uint256","name":"_time","internalType":"uint256","indexed":true},{"type":"uint256","name":"_totalLockedTime","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"type":"address","name":"implementation","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"CLAIM_TIME","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"END_TIME","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"FOUR_YEAR_IN_SECONDS","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"FOUR_YEAR_REWARDS","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"GUARDIAN","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"INIT_AIRDROP","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MAX_CLAIM_REWARDS","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"REWARDS_PER_SECOND","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"REWARD_TOKEN","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"START_TIME","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"UPGRADE_INTERFACE_VERSION","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimGuardianNodeRewards","inputs":[{"type":"tuple","name":"_info","internalType":"struct GuardianNodeStakingPool.ClaimRewardInfo","components":[{"type":"uint256","name":"licenseId","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimGuardianNodesRewards","inputs":[{"type":"tuple[]","name":"_infos","internalType":"struct GuardianNodeStakingPool.ClaimRewardInfo[]","components":[{"type":"uint256","name":"licenseId","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"getAvailableRewards","inputs":[{"type":"address","name":"_user","internalType":"address"},{"type":"uint256[]","name":"_licenseIds","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"","internalType":"struct GuardianNodeStakingPool.LicenseLockInfo[]","components":[{"type":"uint256","name":"stakeTime","internalType":"uint256"},{"type":"uint256","name":"totalLockedTime","internalType":"uint256"},{"type":"uint256","name":"totalRewards","internalType":"uint256"}]}],"name":"getUserLicenseRewards","inputs":[{"type":"address","name":"_user","internalType":"address"},{"type":"uint256[]","name":"_licenseIds","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_admin","internalType":"address"},{"type":"address","name":"_guardian","internalType":"address"},{"type":"uint256","name":"_startTime","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"totalLockedTime","internalType":"uint256"},{"type":"uint256","name":"totalClaimedRewards","internalType":"uint256"},{"type":"uint256","name":"lastUpdateAt","internalType":"uint256"},{"type":"uint256","name":"lastClaimedAt","internalType":"uint256"}],"name":"licenses","inputs":[{"type":"uint256","name":"_nftId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"_owner","internalType":"address"}],"name":"nftStakeOwners","inputs":[{"type":"uint256","name":"_nftId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"onERC721Received","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"bytes","name":"","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"pause","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"proxiableUUID","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"redeemNative","inputs":[{"type":"address","name":"_to","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"redeemToken","inputs":[{"type":"address","name":"_token","internalType":"address"},{"type":"address","name":"_to","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"callerConfirmation","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"rescueLicense","inputs":[{"type":"uint256","name":"_licenseId","internalType":"uint256"},{"type":"address","name":"_to","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setClaimTime","inputs":[{"type":"uint256","name":"_time","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setEndTime","inputs":[{"type":"uint256","name":"_endTime","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setFourYearInSecond","inputs":[{"type":"uint256","name":"_seconds","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setFourYearReward","inputs":[{"type":"uint256","name":"_reward","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setGuardian","inputs":[{"type":"address","name":"_guardian","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setInitAirdrop","inputs":[{"type":"uint256","name":"_airdrop","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMaxClaimReward","inputs":[{"type":"uint256","name":"_reward","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setRewardPerSecond","inputs":[{"type":"uint256","name":"_reward","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setRewardToken","inputs":[{"type":"address","name":"_token","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setStartTime","inputs":[{"type":"uint256","name":"_startTime","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"stakeGuardianNode","inputs":[{"type":"uint256","name":"_licenseId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"stakeGuardianNodes","inputs":[{"type":"uint256[]","name":"_licenseIds","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalClaimedRewards","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalStakingLicenses","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unStakeGuardianNode","inputs":[{"type":"uint256","name":"_licenseId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unStakeGuardianNodes","inputs":[{"type":"uint256[]","name":"_licenseIds","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unpause","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"upgradeToAndCall","inputs":[{"type":"address","name":"newImplementation","internalType":"address"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"user","internalType":"address"},{"type":"uint256","name":"stakeAt","internalType":"uint256"},{"type":"uint256","name":"totalLockedTime","internalType":"uint256"},{"type":"uint256","name":"totalClaimedRewards","internalType":"uint256"},{"type":"uint256","name":"lastUpdateAt","internalType":"uint256"}],"name":"userStakeInfos","inputs":[{"type":"address","name":"_user","internalType":"address"},{"type":"uint256","name":"_licenseId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"_totalLicenses","internalType":"uint256"}],"name":"userTotalLicenses","inputs":[{"type":"address","name":"_user","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"_totalRewards","internalType":"uint256"}],"name":"userTotalRewards","inputs":[{"type":"address","name":"_user","internalType":"address"}]},{"type":"receive","stateMutability":"payable"}]
Contract Creation Code
0x60a06040523060805234801561001457600080fd5b5060805161315561003e60003960008181611927015281816119500152611aa101526131556000f3fe6080604052600436106103395760003560e01c806375b238fc116101ab578063ad3cb1cc116100f7578063d547741f11610095578063d95a6b171161006f578063d95a6b1714610a66578063ddaa26ad14610a86578063df841c9e14610a9c578063f6a3f3cf14610abc57600080fd5b8063d547741f14610a10578063d578ceab14610a30578063d6222c9214610a4657600080fd5b8063b9b06bc3116100d1578063b9b06bc31461099a578063bed1521b146109ba578063cbff71ed146109d0578063ccb98ffc146109f057600080fd5b8063ad3cb1cc1461091c578063ad85ab471461095a578063aec4af3d1461097a57600080fd5b80638aee81271161016457806399248ea71161013e57806399248ea7146108a45780639989896b146108c4578063a217fddf146108f1578063ad1fe0691461090657600080fd5b80638aee81271461082e57806391d148541461084e57806392fd1f1d1461086e57600080fd5b806375b238fc1461076a57806376c8dbab1461078c5780637b3d2733146107b957806382d46d56146107d95780638456cb59146107f95780638a0dac4a1461080e57600080fd5b80633bcaba8b116102855780635c975abb1161022357806364a593ea116101fd57806364a593ea146106d257806366da5815146106f25780636cf678c214610712578063724c184c1461073257600080fd5b80635c975abb146106815780635f8578a0146106a6578063634dc5fb146106bc57600080fd5b80633f4ba83a1161025f5780633f4ba83a14610624578063421cc337146106395780634f1ef2861461065957806352d1902d1461066c57600080fd5b80633bcaba8b1461055f5780633d45747f146105755780633e0a322d1461060457600080fd5b80631d84cee9116102f25780632f2ff15d116102cc5780632f2ff15d146104a757806333790845146104c757806336568abe1461052957806337ba682d1461054957600080fd5b80631d84cee914610444578063248a9ca31461045a5780632bbc6a8e1461047a57600080fd5b806301ffc9a7146103455780630d71bdc31461037a578063117978e21461039c5780631315a139146103bc578063150b7a02146103e05780631794bb3c1461042457600080fd5b3661034057005b600080fd5b34801561035157600080fd5b50610365610360366004612ae6565b610ae9565b60405190151581526020015b60405180910390f35b34801561038657600080fd5b5061039a610395366004612b2c565b610b20565b005b3480156103a857600080fd5b5061039a6103b7366004612b68565b610b52565b3480156103c857600080fd5b506103d260085481565b604051908152602001610371565b3480156103ec57600080fd5b5061040b6103fb366004612c24565b630a85bd0160e11b949350505050565b6040516001600160e01b03199091168152602001610371565b34801561043057600080fd5b5061039a61043f366004612b2c565b610b70565b34801561045057600080fd5b506103d260095481565b34801561046657600080fd5b506103d2610475366004612b68565b610e0f565b34801561048657600080fd5b506103d2610495366004612c8c565b60036020526000908152604090205481565b3480156104b357600080fd5b5061039a6104c2366004612ca7565b610e31565b3480156104d357600080fd5b506105096104e2366004612b68565b60006020819052908152604090208054600182015460028301546003909301549192909184565b604080519485526020850193909352918301526060820152608001610371565b34801561053557600080fd5b5061039a610544366004612ca7565b610e4d565b34801561055557600080fd5b506103d2600f5481565b34801561056b57600080fd5b506103d2600b5481565b34801561058157600080fd5b506105d2610590366004612cd3565b60016020818152600093845260408085209091529183529120805491810154600282015460038301546004909301546001600160a01b03909416939192909185565b604080516001600160a01b0390961686526020860194909452928401919091526060830152608082015260a001610371565b34801561061057600080fd5b5061039a61061f366004612b68565b610e85565b34801561063057600080fd5b5061039a610ea3565b34801561064557600080fd5b5061039a610654366004612b68565b610ece565b61039a610667366004612cfd565b610eec565b34801561067857600080fd5b506103d2610f0b565b34801561068d57600080fd5b506000805160206130e08339815191525460ff16610365565b3480156106b257600080fd5b506103d260105481565b3480156106c857600080fd5b506103d260055481565b3480156106de57600080fd5b5061039a6106ed366004612cd3565b610f28565b3480156106fe57600080fd5b5061039a61070d366004612b68565b610f76565b34801561071e57600080fd5b5061039a61072d366004612d4b565b610f94565b34801561073e57600080fd5b50600c54610752906001600160a01b031681565b6040516001600160a01b039091168152602001610371565b34801561077657600080fd5b506103d260008051602061310083398151915281565b34801561079857600080fd5b506107ac6107a7366004612e05565b61104b565b6040516103719190612e58565b3480156107c557600080fd5b5061039a6107d4366004612eb1565b6111b4565b3480156107e557600080fd5b5061039a6107f4366004612ca7565b6112df565b34801561080557600080fd5b5061039a611368565b34801561081a57600080fd5b5061039a610829366004612c8c565b611390565b34801561083a57600080fd5b5061039a610849366004612c8c565b6113cb565b34801561085a57600080fd5b50610365610869366004612ca7565b611406565b34801561087a57600080fd5b50610752610889366004612b68565b6002602052600090815260409020546001600160a01b031681565b3480156108b057600080fd5b50600d54610752906001600160a01b031681565b3480156108d057600080fd5b506108e46108df366004612e05565b61143e565b6040516103719190612ef3565b3480156108fd57600080fd5b506103d2600081565b34801561091257600080fd5b506103d2600a5481565b34801561092857600080fd5b5061094d604051806040016040528060058152602001640352e302e360dc1b81525081565b6040516103719190612f4f565b34801561096657600080fd5b5061039a610975366004612b68565b6114d4565b34801561098657600080fd5b5061039a610995366004612b68565b6114f2565b3480156109a657600080fd5b5061039a6109b5366004612eb1565b611510565b3480156109c657600080fd5b506103d260075481565b3480156109dc57600080fd5b5061039a6109eb366004612f82565b611590565b3480156109fc57600080fd5b5061039a610a0b366004612b68565b6115d0565b348015610a1c57600080fd5b5061039a610a2b366004612ca7565b6115ee565b348015610a3c57600080fd5b506103d260065481565b348015610a5257600080fd5b5061039a610a61366004612b68565b61160a565b348015610a7257600080fd5b5061039a610a81366004612b68565b611628565b348015610a9257600080fd5b506103d2600e5481565b348015610aa857600080fd5b5061039a610ab7366004612b68565b6116e4565b348015610ac857600080fd5b506103d2610ad7366004612c8c565b60046020526000908152604090205481565b60006001600160e01b03198216637965db0b60e01b1480610b1a57506301ffc9a760e01b6001600160e01b03198316145b92915050565b600080516020613100833981519152610b38816116f5565b610b4c6001600160a01b03851684846116ff565b50505050565b600080516020613100833981519152610b6a816116f5565b50600855565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff16600081158015610bb65750825b905060008267ffffffffffffffff166001148015610bd35750303b155b905081158015610be1575080155b15610bff5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610c2957845460ff60401b1916600160401b1785555b6001600160a01b038816610c7a5760405162461bcd60e51b81526020600482015260136024820152725f61646d696e205a65726f204164647265737360681b60448201526064015b60405180910390fd5b6001600160a01b038716610cc45760405162461bcd60e51b81526020600482015260116024820152705f6e6674205a65726f204164647265737360781b6044820152606401610c71565b60008611610d065760405162461bcd60e51b815260206004820152600f60248201526e5f737461727454696d65205a65726f60881b6044820152606401610c71565b630784ce006007819055681f399b1438a10000006008819055680f9ccd8a1c50800000601055610d369190612fb0565b600955600c80546001600160a01b0319166001600160a01b038916179055600e869055610d668662278d00612fd2565b600f55610d74600033611751565b50610d8d60008051602061310083398151915233611751565b50610da660008051602061310083398151915289611751565b50610daf6117f6565b610db76117f6565b610dbf611800565b8315610e0557845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050565b60009081526000805160206130c0833981519152602052604090206001015490565b610e3a82610e0f565b610e43816116f5565b610b4c8383611751565b6001600160a01b0381163314610e765760405163334bd91960e11b815260040160405180910390fd5b610e808282611810565b505050565b600080516020613100833981519152610e9d816116f5565b50600e55565b610eab61188c565b600080516020613100833981519152610ec3816116f5565b610ecb6118bc565b50565b600080516020613100833981519152610ee6816116f5565b50600b55565b610ef461191c565b610efd826119c1565b610f0782826119d9565b5050565b6000610f15611a96565b506000805160206130a083398151915290565b600080516020613100833981519152610f40816116f5565b6040516001600160a01b0384169083156108fc029084906000818181858888f19350505050158015610b4c573d6000803e3d6000fd5b600080516020613100833981519152610f8e816116f5565b50600955565b610f9c611adf565b6000600b54118015610faf5750600b5442115b610fcb5760405162461bcd60e51b8152600401610c7190612fe5565b806110185760405162461bcd60e51b815260206004820152601860248201527f456d70747920436c61696d2052657175657374204c69737400000000000000006044820152606401610c71565b60005b81811015610e805761104383838381811061103857611038613008565b905060400201611b10565b60010161101b565b606060008267ffffffffffffffff81111561106857611068612b81565b6040519080825280602002602001820160405280156110bd57816020015b6110aa60405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816110865790505b50905060005b838110156111a9576000806110f0888888868181106110e4576110e4613008565b90506020020135611f15565b6001600160a01b038a16600090815260016020526040812092945090925088888681811061112057611120613008565b9050602002013581526020019081526020016000206001015484848151811061114b5761114b613008565b602002602001015160000181815250508184848151811061116e5761116e613008565b602002602001015160400181815250508084848151811061119157611191613008565b602090810291909101810151015250506001016110c3565b5090505b9392505050565b6111bc611adf565b600e544210156111de5760405162461bcd60e51b8152600401610c7190612fe5565b600f5442106112175760405162461bcd60e51b8152602060048201526005602482015264115b99195960da1b6044820152606401610c71565b600c546001600160a01b03166112675760405162461bcd60e51b8152602060048201526015602482015274496e76616c696420477561726469616e204e6f646560581b6044820152606401610c71565b806112ab5760405162461bcd60e51b8152602060048201526014602482015273125b9d985b1a5908131a58d95b9cd948131a5cdd60621b6044820152606401610c71565b60005b81811015610e80576112d78383838181106112cb576112cb613008565b9050602002013561211e565b6001016112ae565b6000805160206131008339815191526112f7816116f5565b600c54604051632142170760e11b81523060048201526001600160a01b03848116602483015260448201869052909116906342842e0e90606401600060405180830381600087803b15801561134b57600080fd5b505af115801561135f573d6000803e3d6000fd5b50505050505050565b611370611adf565b600080516020613100833981519152611388816116f5565b610ecb61231c565b6000805160206131008339815191526113a8816116f5565b50600c80546001600160a01b0319166001600160a01b0392909216919091179055565b6000805160206131008339815191526113e3816116f5565b50600d80546001600160a01b0319166001600160a01b0392909216919091179055565b60009182526000805160206130c0833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b606060008267ffffffffffffffff81111561145b5761145b612b81565b604051908082528060200260200182016040528015611484578160200160208202803683370190505b50905060005b838110156111a95760006114aa878787858181106110e4576110e4613008565b509050808383815181106114c0576114c0613008565b60209081029190910101525060010161148a565b6000805160206131008339815191526114ec816116f5565b50600a55565b60008051602061310083398151915261150a816116f5565b50600755565b611518611adf565b8061155c5760405162461bcd60e51b8152602060048201526014602482015273125b9d985b1a5908131a58d95b9cd948131a5cdd60621b6044820152606401610c71565b60005b81811015610e805761158883838381811061157c5761157c613008565b90506020020135612365565b60010161155f565b611598611adf565b6000600b541180156115ab5750600b5442115b6115c75760405162461bcd60e51b8152600401610c7190612fe5565b610ecb81611b10565b6000805160206131008339815191526115e8816116f5565b50600f55565b6115f782610e0f565b611600816116f5565b610b4c8383611810565b600080516020613100833981519152611622816116f5565b50601055565b611630611adf565b600e544210156116525760405162461bcd60e51b8152600401610c7190612fe5565b600f54421061168b5760405162461bcd60e51b8152602060048201526005602482015264115b99195960da1b6044820152606401610c71565b600c546001600160a01b03166116db5760405162461bcd60e51b8152602060048201526015602482015274496e76616c696420477561726469616e204e6f646560581b6044820152606401610c71565b610ecb8161211e565b6116ec611adf565b610ecb81612365565b610ecb813361252f565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610e80908490612568565b60006000805160206130c083398151915261176c8484611406565b6117ec576000848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556117a23390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610b1a565b6000915050610b1a565b6117fe6125cb565b565b6118086125cb565b6117fe612614565b60006000805160206130c083398151915261182b8484611406565b156117ec576000848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610b1a565b6000805160206130e08339815191525460ff166117fe57604051638dfc202b60e01b815260040160405180910390fd5b6118c461188c565b6000805160206130e0833981519152805460ff191681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a150565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614806119a357507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166119976000805160206130a0833981519152546001600160a01b031690565b6001600160a01b031614155b156117fe5760405163703e46dd60e11b815260040160405180910390fd5b600080516020613100833981519152610f07816116f5565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611a33575060408051601f3d908101601f19168201909252611a309181019061301e565b60015b611a5b57604051634c9c8ce360e01b81526001600160a01b0383166004820152602401610c71565b6000805160206130a08339815191528114611a8c57604051632a87526960e21b815260048101829052602401610c71565b610e808383612635565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146117fe5760405163703e46dd60e11b815260040160405180910390fd5b6000805160206130e08339815191525460ff16156117fe5760405163d93c066560e01b815260040160405180910390fd5b80356000818152602081815260408083203384526001835281842094845293825290912090830135611b755760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908105b5bdd5b9d60921b6044820152606401610c71565b60085483602001358360010154611b8c9190612fd2565b1115611bd25760405162461bcd60e51b8152602060048201526015602482015274115e18d95959080d081659585c9cc814995dd85c99605a1b6044820152606401610c71565b600a5483602001358360010154611be99190612fd2565b1115611c2a5760405162461bcd60e51b815260206004820152601060248201526f13585e0810db185a5b4814995dd85c9960821b6044820152606401610c71565b6000611c3733853561268b565b90508084602001351115611c8d5760405162461bcd60e51b815260206004820152601760248201527f45786365656420417661696c61626c65205265776172640000000000000000006044820152606401610c71565b8360200135836001016000828254611ca59190612fd2565b925050819055504283600301819055508360200135826003016000828254611ccd9190612fd2565b90915550504260048084019190915533600090815260209182526040812080549287013592909190611d00908490612fd2565b92505081905550836020013560066000828254611d1d9190612fd2565b9091555050600d546001600160a01b0316611dd45760405160009033906020870135908381818185875af1925050503d8060008114611d78576040519150601f19603f3d011682016040523d82523d6000602084013e611d7d565b606091505b5050905080611dce5760405162461bcd60e51b815260206004820152601760248201527f5472616e73666572204e6174697665204661696c6564210000000000000000006044820152606401610c71565b50611ea4565b600d546040516370a0823160e01b81523060048201526020860135916001600160a01b0316906370a0823190602401602060405180830381865afa158015611e20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e44919061301e565b1015611e895760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742042616c616e636560601b6044820152606401610c71565b600d54611ea4906001600160a01b03163360208701356116ff565b60018301546040516020860135908635907f09b7b434eef537a08c4c4ca519cc79a3a51a8611e45be24c11442f9192a74a4690600090a460405160208501359033908635907fa756e4d8f7509f4ea7c440cd474be2db34f2c8e4a142b5bfbee53cb92124c6df90600090a450505050565b6001600160a01b0380831660009081526001602081815260408084208685528252808420815160a0810183528154909616865280840154868401908152600280830154888501526003808401546060808b01919091526004909401546080808b01919091528a8952888752858920865191820187528054825297880154968101969096529086015493850193909352939091015490820152905191928392909190839015612031576000600f544210611fd057600f54611fd2565b425b90508360200151811115611ff2576020840151611fef9082613037565b91505b6007548351101561202a57600754835161200d908490612fd2565b11156120255782516007546120229190613037565b91505b61202f565b600091505b505b60006010546008546120439190612fd2565b90506000818460200151106120645780600754965096505050505050612117565b60008386604001516120769190612fd2565b9050600060095482612088919061304a565b6010546120959190612fd2565b9050808760600151106120b2575090965094506121179350505050565b60608701516120c19082613037565b9250838660200151101561210257838387602001516120e09190612fd2565b11156120fd5760208601516120f59085613037565b925060075491505b61210c565b6000925060075491505b509096509450505050505b9250929050565b600081815260208181526040808320338452600183528184208585529092529091208261217f5760405162461bcd60e51b815260206004820152600f60248201526e5f6c6963656e73654964205a65726f60881b6044820152606401610c71565b6007548254106121bf5760405162461bcd60e51b815260206004820152600b60248201526a4d6178203420596561727360a81b6044820152606401610c71565b6000838152600260205260409020546001600160a01b03161561220e5760405162461bcd60e51b81526020600482015260076024820152665374616b696e6760c81b6044820152606401610c71565b4260028084019190915560008481526020918252604080822080546001600160a01b0319163390811790915582526003909252908120805460019290612255908490612fd2565b90915550504260018083019190915560058054600090612276908490612fd2565b9091555050600c54604051632142170760e11b8152336004820152306024820152604481018590526001600160a01b03909116906342842e0e90606401600060405180830381600087803b1580156122cd57600080fd5b505af11580156122e1573d6000803e3d6000fd5b505050506001810154604051339085907f02567b2553aeb44e4ddd5d68462774dc3de158cb0f2c2da1740e729b22086aff90600090a4505050565b612324611adf565b6000805160206130e0833981519152805460ff191660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258336118fe565b336000818152600160209081526040808320858452825280832060029092529091205490916001600160a01b03909116146123da5760405162461bcd60e51b81526020600482015260156024820152744f6e6c79204f776e6572204f66204c6963656e736560581b6044820152606401610c71565b60008160010154116124265760405162461bcd60e51b8152602060048201526015602482015274131a58d95b9cd948125cc8139bdd0814dd185ad959605a1b6044820152606401610c71565b612430338361268b565b50600082815260026020908152604080832080546001600160a01b03191690553383526003909152812080546001929061246b908490613037565b925050819055506000816001018190555060016005600082825461248f9190613037565b9091555050600c54604051632142170760e11b8152306004820152336024820152604481018490526001600160a01b03909116906342842e0e90606401600060405180830381600087803b1580156124e657600080fd5b505af11580156124fa573d6000803e3d6000fd5b50506040513392508491507f41750de21fefee6a20fa35759739bf062be264de08a6e85edd566af1161e8c0f90600090a35050565b6125398282611406565b610f075760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610c71565b600061257d6001600160a01b038416836128bc565b905080516000141580156125a25750808060200190518101906125a09190613061565b155b15610e8057604051635274afe760e01b81526001600160a01b0384166004820152602401610c71565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff166117fe57604051631afcd79f60e31b815260040160405180910390fd5b61261c6125cb565b6000805160206130e0833981519152805460ff19169055565b61263e826128ca565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a280511561268357610e80828261292f565b610f076129a5565b6001600160a01b0382166000908152600160208181526040808420858552825280842091849052832091810154909190156127fa576000600f5442106126d357600f546126d5565b425b9050600083600101548211156126f75760018401546126f49083613037565b90505b6007548354101561272f576007548354612712908390612fd2565b111561272a5782546007546127279190613037565b90505b612733565b5060005b80156127f7578084600201600082825461274d9190612fd2565b909155505042600185018190556004850155825481908490600090612773908490612fd2565b90915550504260028401558254604051829088907fe495b44b3ab20b0cbb527beab88e5f90df21e559ac9cb6e9ac6bb6bde1a742f990600090a480876001600160a01b0316877fb2aac303a7d0b2c822c26f85c87414da1fdf9d0ea92a54e3cac6a18b86f2aed187600201546040516127ee91815260200190565b60405180910390a45b50505b6000600854826001015410612813579250610b1a915050565b60006009548460020154612827919061304a565b6010546128349190612fd2565b90508084600301541061284c57509250610b1a915050565b600060105460085461285e9190612fd2565b90508460030154826128709190613037565b925080846001015410156128ab578083856001015461288f9190612fd2565b106128a65760018401546128a39082613037565b92505b6128b0565b600092505b50909695505050505050565b60606111ad838360006129c4565b806001600160a01b03163b60000361290057604051634c9c8ce360e01b81526001600160a01b0382166004820152602401610c71565b6000805160206130a083398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b03168460405161294c9190613083565b600060405180830381855af49150503d8060008114612987576040519150601f19603f3d011682016040523d82523d6000602084013e61298c565b606091505b509150915061299c858383612a61565b95945050505050565b34156117fe5760405163b398979f60e01b815260040160405180910390fd5b6060814710156129e95760405163cd78605960e01b8152306004820152602401610c71565b600080856001600160a01b03168486604051612a059190613083565b60006040518083038185875af1925050503d8060008114612a42576040519150601f19603f3d011682016040523d82523d6000602084013e612a47565b606091505b5091509150612a57868383612a61565b9695505050505050565b606082612a7657612a7182612abd565b6111ad565b8151158015612a8d57506001600160a01b0384163b155b15612ab657604051639996b31560e01b81526001600160a01b0385166004820152602401610c71565b50806111ad565b805115612acd5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b600060208284031215612af857600080fd5b81356001600160e01b0319811681146111ad57600080fd5b80356001600160a01b0381168114612b2757600080fd5b919050565b600080600060608486031215612b4157600080fd5b612b4a84612b10565b9250612b5860208501612b10565b9150604084013590509250925092565b600060208284031215612b7a57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112612ba857600080fd5b813567ffffffffffffffff80821115612bc357612bc3612b81565b604051601f8301601f19908116603f01168101908282118183101715612beb57612beb612b81565b81604052838152866020858801011115612c0457600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060008060808587031215612c3a57600080fd5b612c4385612b10565b9350612c5160208601612b10565b925060408501359150606085013567ffffffffffffffff811115612c7457600080fd5b612c8087828801612b97565b91505092959194509250565b600060208284031215612c9e57600080fd5b6111ad82612b10565b60008060408385031215612cba57600080fd5b82359150612cca60208401612b10565b90509250929050565b60008060408385031215612ce657600080fd5b612cef83612b10565b946020939093013593505050565b60008060408385031215612d1057600080fd5b612d1983612b10565b9150602083013567ffffffffffffffff811115612d3557600080fd5b612d4185828601612b97565b9150509250929050565b60008060208385031215612d5e57600080fd5b823567ffffffffffffffff80821115612d7657600080fd5b818501915085601f830112612d8a57600080fd5b813581811115612d9957600080fd5b8660208260061b8501011115612dae57600080fd5b60209290920196919550909350505050565b60008083601f840112612dd257600080fd5b50813567ffffffffffffffff811115612dea57600080fd5b6020830191508360208260051b850101111561211757600080fd5b600080600060408486031215612e1a57600080fd5b612e2384612b10565b9250602084013567ffffffffffffffff811115612e3f57600080fd5b612e4b86828701612dc0565b9497909650939450505050565b602080825282518282018190526000919060409081850190868401855b82811015612ea45781518051855286810151878601528501518585015260609093019290850190600101612e75565b5091979650505050505050565b60008060208385031215612ec457600080fd5b823567ffffffffffffffff811115612edb57600080fd5b612ee785828601612dc0565b90969095509350505050565b6020808252825182820181905260009190848201906040850190845b818110156128b057835183529284019291840191600101612f0f565b60005b83811015612f46578181015183820152602001612f2e565b50506000910152565b6020815260008251806020840152612f6e816040850160208701612f2b565b601f01601f19169190910160400192915050565b600060408284031215612f9457600080fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600082612fcd57634e487b7160e01b600052601260045260246000fd5b500490565b80820180821115610b1a57610b1a612f9a565b602080825260099082015268139bdd0814dd185c9d60ba1b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561303057600080fd5b5051919050565b81810381811115610b1a57610b1a612f9a565b8082028115828204841417610b1a57610b1a612f9a565b60006020828403121561307357600080fd5b815180151581146111ad57600080fd5b60008251613095818460208701612f2b565b919091019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775a2646970667358221220c072d7296635401bc6b2f813ed7d13eaf5f310f88c084764523f72022c23faf864736f6c63430008170033
Deployed ByteCode
0x6080604052600436106103395760003560e01c806375b238fc116101ab578063ad3cb1cc116100f7578063d547741f11610095578063d95a6b171161006f578063d95a6b1714610a66578063ddaa26ad14610a86578063df841c9e14610a9c578063f6a3f3cf14610abc57600080fd5b8063d547741f14610a10578063d578ceab14610a30578063d6222c9214610a4657600080fd5b8063b9b06bc3116100d1578063b9b06bc31461099a578063bed1521b146109ba578063cbff71ed146109d0578063ccb98ffc146109f057600080fd5b8063ad3cb1cc1461091c578063ad85ab471461095a578063aec4af3d1461097a57600080fd5b80638aee81271161016457806399248ea71161013e57806399248ea7146108a45780639989896b146108c4578063a217fddf146108f1578063ad1fe0691461090657600080fd5b80638aee81271461082e57806391d148541461084e57806392fd1f1d1461086e57600080fd5b806375b238fc1461076a57806376c8dbab1461078c5780637b3d2733146107b957806382d46d56146107d95780638456cb59146107f95780638a0dac4a1461080e57600080fd5b80633bcaba8b116102855780635c975abb1161022357806364a593ea116101fd57806364a593ea146106d257806366da5815146106f25780636cf678c214610712578063724c184c1461073257600080fd5b80635c975abb146106815780635f8578a0146106a6578063634dc5fb146106bc57600080fd5b80633f4ba83a1161025f5780633f4ba83a14610624578063421cc337146106395780634f1ef2861461065957806352d1902d1461066c57600080fd5b80633bcaba8b1461055f5780633d45747f146105755780633e0a322d1461060457600080fd5b80631d84cee9116102f25780632f2ff15d116102cc5780632f2ff15d146104a757806333790845146104c757806336568abe1461052957806337ba682d1461054957600080fd5b80631d84cee914610444578063248a9ca31461045a5780632bbc6a8e1461047a57600080fd5b806301ffc9a7146103455780630d71bdc31461037a578063117978e21461039c5780631315a139146103bc578063150b7a02146103e05780631794bb3c1461042457600080fd5b3661034057005b600080fd5b34801561035157600080fd5b50610365610360366004612ae6565b610ae9565b60405190151581526020015b60405180910390f35b34801561038657600080fd5b5061039a610395366004612b2c565b610b20565b005b3480156103a857600080fd5b5061039a6103b7366004612b68565b610b52565b3480156103c857600080fd5b506103d260085481565b604051908152602001610371565b3480156103ec57600080fd5b5061040b6103fb366004612c24565b630a85bd0160e11b949350505050565b6040516001600160e01b03199091168152602001610371565b34801561043057600080fd5b5061039a61043f366004612b2c565b610b70565b34801561045057600080fd5b506103d260095481565b34801561046657600080fd5b506103d2610475366004612b68565b610e0f565b34801561048657600080fd5b506103d2610495366004612c8c565b60036020526000908152604090205481565b3480156104b357600080fd5b5061039a6104c2366004612ca7565b610e31565b3480156104d357600080fd5b506105096104e2366004612b68565b60006020819052908152604090208054600182015460028301546003909301549192909184565b604080519485526020850193909352918301526060820152608001610371565b34801561053557600080fd5b5061039a610544366004612ca7565b610e4d565b34801561055557600080fd5b506103d2600f5481565b34801561056b57600080fd5b506103d2600b5481565b34801561058157600080fd5b506105d2610590366004612cd3565b60016020818152600093845260408085209091529183529120805491810154600282015460038301546004909301546001600160a01b03909416939192909185565b604080516001600160a01b0390961686526020860194909452928401919091526060830152608082015260a001610371565b34801561061057600080fd5b5061039a61061f366004612b68565b610e85565b34801561063057600080fd5b5061039a610ea3565b34801561064557600080fd5b5061039a610654366004612b68565b610ece565b61039a610667366004612cfd565b610eec565b34801561067857600080fd5b506103d2610f0b565b34801561068d57600080fd5b506000805160206130e08339815191525460ff16610365565b3480156106b257600080fd5b506103d260105481565b3480156106c857600080fd5b506103d260055481565b3480156106de57600080fd5b5061039a6106ed366004612cd3565b610f28565b3480156106fe57600080fd5b5061039a61070d366004612b68565b610f76565b34801561071e57600080fd5b5061039a61072d366004612d4b565b610f94565b34801561073e57600080fd5b50600c54610752906001600160a01b031681565b6040516001600160a01b039091168152602001610371565b34801561077657600080fd5b506103d260008051602061310083398151915281565b34801561079857600080fd5b506107ac6107a7366004612e05565b61104b565b6040516103719190612e58565b3480156107c557600080fd5b5061039a6107d4366004612eb1565b6111b4565b3480156107e557600080fd5b5061039a6107f4366004612ca7565b6112df565b34801561080557600080fd5b5061039a611368565b34801561081a57600080fd5b5061039a610829366004612c8c565b611390565b34801561083a57600080fd5b5061039a610849366004612c8c565b6113cb565b34801561085a57600080fd5b50610365610869366004612ca7565b611406565b34801561087a57600080fd5b50610752610889366004612b68565b6002602052600090815260409020546001600160a01b031681565b3480156108b057600080fd5b50600d54610752906001600160a01b031681565b3480156108d057600080fd5b506108e46108df366004612e05565b61143e565b6040516103719190612ef3565b3480156108fd57600080fd5b506103d2600081565b34801561091257600080fd5b506103d2600a5481565b34801561092857600080fd5b5061094d604051806040016040528060058152602001640352e302e360dc1b81525081565b6040516103719190612f4f565b34801561096657600080fd5b5061039a610975366004612b68565b6114d4565b34801561098657600080fd5b5061039a610995366004612b68565b6114f2565b3480156109a657600080fd5b5061039a6109b5366004612eb1565b611510565b3480156109c657600080fd5b506103d260075481565b3480156109dc57600080fd5b5061039a6109eb366004612f82565b611590565b3480156109fc57600080fd5b5061039a610a0b366004612b68565b6115d0565b348015610a1c57600080fd5b5061039a610a2b366004612ca7565b6115ee565b348015610a3c57600080fd5b506103d260065481565b348015610a5257600080fd5b5061039a610a61366004612b68565b61160a565b348015610a7257600080fd5b5061039a610a81366004612b68565b611628565b348015610a9257600080fd5b506103d2600e5481565b348015610aa857600080fd5b5061039a610ab7366004612b68565b6116e4565b348015610ac857600080fd5b506103d2610ad7366004612c8c565b60046020526000908152604090205481565b60006001600160e01b03198216637965db0b60e01b1480610b1a57506301ffc9a760e01b6001600160e01b03198316145b92915050565b600080516020613100833981519152610b38816116f5565b610b4c6001600160a01b03851684846116ff565b50505050565b600080516020613100833981519152610b6a816116f5565b50600855565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff16600081158015610bb65750825b905060008267ffffffffffffffff166001148015610bd35750303b155b905081158015610be1575080155b15610bff5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610c2957845460ff60401b1916600160401b1785555b6001600160a01b038816610c7a5760405162461bcd60e51b81526020600482015260136024820152725f61646d696e205a65726f204164647265737360681b60448201526064015b60405180910390fd5b6001600160a01b038716610cc45760405162461bcd60e51b81526020600482015260116024820152705f6e6674205a65726f204164647265737360781b6044820152606401610c71565b60008611610d065760405162461bcd60e51b815260206004820152600f60248201526e5f737461727454696d65205a65726f60881b6044820152606401610c71565b630784ce006007819055681f399b1438a10000006008819055680f9ccd8a1c50800000601055610d369190612fb0565b600955600c80546001600160a01b0319166001600160a01b038916179055600e869055610d668662278d00612fd2565b600f55610d74600033611751565b50610d8d60008051602061310083398151915233611751565b50610da660008051602061310083398151915289611751565b50610daf6117f6565b610db76117f6565b610dbf611800565b8315610e0557845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050565b60009081526000805160206130c0833981519152602052604090206001015490565b610e3a82610e0f565b610e43816116f5565b610b4c8383611751565b6001600160a01b0381163314610e765760405163334bd91960e11b815260040160405180910390fd5b610e808282611810565b505050565b600080516020613100833981519152610e9d816116f5565b50600e55565b610eab61188c565b600080516020613100833981519152610ec3816116f5565b610ecb6118bc565b50565b600080516020613100833981519152610ee6816116f5565b50600b55565b610ef461191c565b610efd826119c1565b610f0782826119d9565b5050565b6000610f15611a96565b506000805160206130a083398151915290565b600080516020613100833981519152610f40816116f5565b6040516001600160a01b0384169083156108fc029084906000818181858888f19350505050158015610b4c573d6000803e3d6000fd5b600080516020613100833981519152610f8e816116f5565b50600955565b610f9c611adf565b6000600b54118015610faf5750600b5442115b610fcb5760405162461bcd60e51b8152600401610c7190612fe5565b806110185760405162461bcd60e51b815260206004820152601860248201527f456d70747920436c61696d2052657175657374204c69737400000000000000006044820152606401610c71565b60005b81811015610e805761104383838381811061103857611038613008565b905060400201611b10565b60010161101b565b606060008267ffffffffffffffff81111561106857611068612b81565b6040519080825280602002602001820160405280156110bd57816020015b6110aa60405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816110865790505b50905060005b838110156111a9576000806110f0888888868181106110e4576110e4613008565b90506020020135611f15565b6001600160a01b038a16600090815260016020526040812092945090925088888681811061112057611120613008565b9050602002013581526020019081526020016000206001015484848151811061114b5761114b613008565b602002602001015160000181815250508184848151811061116e5761116e613008565b602002602001015160400181815250508084848151811061119157611191613008565b602090810291909101810151015250506001016110c3565b5090505b9392505050565b6111bc611adf565b600e544210156111de5760405162461bcd60e51b8152600401610c7190612fe5565b600f5442106112175760405162461bcd60e51b8152602060048201526005602482015264115b99195960da1b6044820152606401610c71565b600c546001600160a01b03166112675760405162461bcd60e51b8152602060048201526015602482015274496e76616c696420477561726469616e204e6f646560581b6044820152606401610c71565b806112ab5760405162461bcd60e51b8152602060048201526014602482015273125b9d985b1a5908131a58d95b9cd948131a5cdd60621b6044820152606401610c71565b60005b81811015610e80576112d78383838181106112cb576112cb613008565b9050602002013561211e565b6001016112ae565b6000805160206131008339815191526112f7816116f5565b600c54604051632142170760e11b81523060048201526001600160a01b03848116602483015260448201869052909116906342842e0e90606401600060405180830381600087803b15801561134b57600080fd5b505af115801561135f573d6000803e3d6000fd5b50505050505050565b611370611adf565b600080516020613100833981519152611388816116f5565b610ecb61231c565b6000805160206131008339815191526113a8816116f5565b50600c80546001600160a01b0319166001600160a01b0392909216919091179055565b6000805160206131008339815191526113e3816116f5565b50600d80546001600160a01b0319166001600160a01b0392909216919091179055565b60009182526000805160206130c0833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b606060008267ffffffffffffffff81111561145b5761145b612b81565b604051908082528060200260200182016040528015611484578160200160208202803683370190505b50905060005b838110156111a95760006114aa878787858181106110e4576110e4613008565b509050808383815181106114c0576114c0613008565b60209081029190910101525060010161148a565b6000805160206131008339815191526114ec816116f5565b50600a55565b60008051602061310083398151915261150a816116f5565b50600755565b611518611adf565b8061155c5760405162461bcd60e51b8152602060048201526014602482015273125b9d985b1a5908131a58d95b9cd948131a5cdd60621b6044820152606401610c71565b60005b81811015610e805761158883838381811061157c5761157c613008565b90506020020135612365565b60010161155f565b611598611adf565b6000600b541180156115ab5750600b5442115b6115c75760405162461bcd60e51b8152600401610c7190612fe5565b610ecb81611b10565b6000805160206131008339815191526115e8816116f5565b50600f55565b6115f782610e0f565b611600816116f5565b610b4c8383611810565b600080516020613100833981519152611622816116f5565b50601055565b611630611adf565b600e544210156116525760405162461bcd60e51b8152600401610c7190612fe5565b600f54421061168b5760405162461bcd60e51b8152602060048201526005602482015264115b99195960da1b6044820152606401610c71565b600c546001600160a01b03166116db5760405162461bcd60e51b8152602060048201526015602482015274496e76616c696420477561726469616e204e6f646560581b6044820152606401610c71565b610ecb8161211e565b6116ec611adf565b610ecb81612365565b610ecb813361252f565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610e80908490612568565b60006000805160206130c083398151915261176c8484611406565b6117ec576000848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556117a23390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610b1a565b6000915050610b1a565b6117fe6125cb565b565b6118086125cb565b6117fe612614565b60006000805160206130c083398151915261182b8484611406565b156117ec576000848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610b1a565b6000805160206130e08339815191525460ff166117fe57604051638dfc202b60e01b815260040160405180910390fd5b6118c461188c565b6000805160206130e0833981519152805460ff191681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a150565b306001600160a01b037f00000000000000000000000003e5d16eb274a96e053d3588f63abc0ae49042aa1614806119a357507f00000000000000000000000003e5d16eb274a96e053d3588f63abc0ae49042aa6001600160a01b03166119976000805160206130a0833981519152546001600160a01b031690565b6001600160a01b031614155b156117fe5760405163703e46dd60e11b815260040160405180910390fd5b600080516020613100833981519152610f07816116f5565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611a33575060408051601f3d908101601f19168201909252611a309181019061301e565b60015b611a5b57604051634c9c8ce360e01b81526001600160a01b0383166004820152602401610c71565b6000805160206130a08339815191528114611a8c57604051632a87526960e21b815260048101829052602401610c71565b610e808383612635565b306001600160a01b037f00000000000000000000000003e5d16eb274a96e053d3588f63abc0ae49042aa16146117fe5760405163703e46dd60e11b815260040160405180910390fd5b6000805160206130e08339815191525460ff16156117fe5760405163d93c066560e01b815260040160405180910390fd5b80356000818152602081815260408083203384526001835281842094845293825290912090830135611b755760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908105b5bdd5b9d60921b6044820152606401610c71565b60085483602001358360010154611b8c9190612fd2565b1115611bd25760405162461bcd60e51b8152602060048201526015602482015274115e18d95959080d081659585c9cc814995dd85c99605a1b6044820152606401610c71565b600a5483602001358360010154611be99190612fd2565b1115611c2a5760405162461bcd60e51b815260206004820152601060248201526f13585e0810db185a5b4814995dd85c9960821b6044820152606401610c71565b6000611c3733853561268b565b90508084602001351115611c8d5760405162461bcd60e51b815260206004820152601760248201527f45786365656420417661696c61626c65205265776172640000000000000000006044820152606401610c71565b8360200135836001016000828254611ca59190612fd2565b925050819055504283600301819055508360200135826003016000828254611ccd9190612fd2565b90915550504260048084019190915533600090815260209182526040812080549287013592909190611d00908490612fd2565b92505081905550836020013560066000828254611d1d9190612fd2565b9091555050600d546001600160a01b0316611dd45760405160009033906020870135908381818185875af1925050503d8060008114611d78576040519150601f19603f3d011682016040523d82523d6000602084013e611d7d565b606091505b5050905080611dce5760405162461bcd60e51b815260206004820152601760248201527f5472616e73666572204e6174697665204661696c6564210000000000000000006044820152606401610c71565b50611ea4565b600d546040516370a0823160e01b81523060048201526020860135916001600160a01b0316906370a0823190602401602060405180830381865afa158015611e20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e44919061301e565b1015611e895760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742042616c616e636560601b6044820152606401610c71565b600d54611ea4906001600160a01b03163360208701356116ff565b60018301546040516020860135908635907f09b7b434eef537a08c4c4ca519cc79a3a51a8611e45be24c11442f9192a74a4690600090a460405160208501359033908635907fa756e4d8f7509f4ea7c440cd474be2db34f2c8e4a142b5bfbee53cb92124c6df90600090a450505050565b6001600160a01b0380831660009081526001602081815260408084208685528252808420815160a0810183528154909616865280840154868401908152600280830154888501526003808401546060808b01919091526004909401546080808b01919091528a8952888752858920865191820187528054825297880154968101969096529086015493850193909352939091015490820152905191928392909190839015612031576000600f544210611fd057600f54611fd2565b425b90508360200151811115611ff2576020840151611fef9082613037565b91505b6007548351101561202a57600754835161200d908490612fd2565b11156120255782516007546120229190613037565b91505b61202f565b600091505b505b60006010546008546120439190612fd2565b90506000818460200151106120645780600754965096505050505050612117565b60008386604001516120769190612fd2565b9050600060095482612088919061304a565b6010546120959190612fd2565b9050808760600151106120b2575090965094506121179350505050565b60608701516120c19082613037565b9250838660200151101561210257838387602001516120e09190612fd2565b11156120fd5760208601516120f59085613037565b925060075491505b61210c565b6000925060075491505b509096509450505050505b9250929050565b600081815260208181526040808320338452600183528184208585529092529091208261217f5760405162461bcd60e51b815260206004820152600f60248201526e5f6c6963656e73654964205a65726f60881b6044820152606401610c71565b6007548254106121bf5760405162461bcd60e51b815260206004820152600b60248201526a4d6178203420596561727360a81b6044820152606401610c71565b6000838152600260205260409020546001600160a01b03161561220e5760405162461bcd60e51b81526020600482015260076024820152665374616b696e6760c81b6044820152606401610c71565b4260028084019190915560008481526020918252604080822080546001600160a01b0319163390811790915582526003909252908120805460019290612255908490612fd2565b90915550504260018083019190915560058054600090612276908490612fd2565b9091555050600c54604051632142170760e11b8152336004820152306024820152604481018590526001600160a01b03909116906342842e0e90606401600060405180830381600087803b1580156122cd57600080fd5b505af11580156122e1573d6000803e3d6000fd5b505050506001810154604051339085907f02567b2553aeb44e4ddd5d68462774dc3de158cb0f2c2da1740e729b22086aff90600090a4505050565b612324611adf565b6000805160206130e0833981519152805460ff191660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258336118fe565b336000818152600160209081526040808320858452825280832060029092529091205490916001600160a01b03909116146123da5760405162461bcd60e51b81526020600482015260156024820152744f6e6c79204f776e6572204f66204c6963656e736560581b6044820152606401610c71565b60008160010154116124265760405162461bcd60e51b8152602060048201526015602482015274131a58d95b9cd948125cc8139bdd0814dd185ad959605a1b6044820152606401610c71565b612430338361268b565b50600082815260026020908152604080832080546001600160a01b03191690553383526003909152812080546001929061246b908490613037565b925050819055506000816001018190555060016005600082825461248f9190613037565b9091555050600c54604051632142170760e11b8152306004820152336024820152604481018490526001600160a01b03909116906342842e0e90606401600060405180830381600087803b1580156124e657600080fd5b505af11580156124fa573d6000803e3d6000fd5b50506040513392508491507f41750de21fefee6a20fa35759739bf062be264de08a6e85edd566af1161e8c0f90600090a35050565b6125398282611406565b610f075760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610c71565b600061257d6001600160a01b038416836128bc565b905080516000141580156125a25750808060200190518101906125a09190613061565b155b15610e8057604051635274afe760e01b81526001600160a01b0384166004820152602401610c71565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff166117fe57604051631afcd79f60e31b815260040160405180910390fd5b61261c6125cb565b6000805160206130e0833981519152805460ff19169055565b61263e826128ca565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a280511561268357610e80828261292f565b610f076129a5565b6001600160a01b0382166000908152600160208181526040808420858552825280842091849052832091810154909190156127fa576000600f5442106126d357600f546126d5565b425b9050600083600101548211156126f75760018401546126f49083613037565b90505b6007548354101561272f576007548354612712908390612fd2565b111561272a5782546007546127279190613037565b90505b612733565b5060005b80156127f7578084600201600082825461274d9190612fd2565b909155505042600185018190556004850155825481908490600090612773908490612fd2565b90915550504260028401558254604051829088907fe495b44b3ab20b0cbb527beab88e5f90df21e559ac9cb6e9ac6bb6bde1a742f990600090a480876001600160a01b0316877fb2aac303a7d0b2c822c26f85c87414da1fdf9d0ea92a54e3cac6a18b86f2aed187600201546040516127ee91815260200190565b60405180910390a45b50505b6000600854826001015410612813579250610b1a915050565b60006009548460020154612827919061304a565b6010546128349190612fd2565b90508084600301541061284c57509250610b1a915050565b600060105460085461285e9190612fd2565b90508460030154826128709190613037565b925080846001015410156128ab578083856001015461288f9190612fd2565b106128a65760018401546128a39082613037565b92505b6128b0565b600092505b50909695505050505050565b60606111ad838360006129c4565b806001600160a01b03163b60000361290057604051634c9c8ce360e01b81526001600160a01b0382166004820152602401610c71565b6000805160206130a083398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b03168460405161294c9190613083565b600060405180830381855af49150503d8060008114612987576040519150601f19603f3d011682016040523d82523d6000602084013e61298c565b606091505b509150915061299c858383612a61565b95945050505050565b34156117fe5760405163b398979f60e01b815260040160405180910390fd5b6060814710156129e95760405163cd78605960e01b8152306004820152602401610c71565b600080856001600160a01b03168486604051612a059190613083565b60006040518083038185875af1925050503d8060008114612a42576040519150601f19603f3d011682016040523d82523d6000602084013e612a47565b606091505b5091509150612a57868383612a61565b9695505050505050565b606082612a7657612a7182612abd565b6111ad565b8151158015612a8d57506001600160a01b0384163b155b15612ab657604051639996b31560e01b81526001600160a01b0385166004820152602401610c71565b50806111ad565b805115612acd5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b600060208284031215612af857600080fd5b81356001600160e01b0319811681146111ad57600080fd5b80356001600160a01b0381168114612b2757600080fd5b919050565b600080600060608486031215612b4157600080fd5b612b4a84612b10565b9250612b5860208501612b10565b9150604084013590509250925092565b600060208284031215612b7a57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112612ba857600080fd5b813567ffffffffffffffff80821115612bc357612bc3612b81565b604051601f8301601f19908116603f01168101908282118183101715612beb57612beb612b81565b81604052838152866020858801011115612c0457600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060008060808587031215612c3a57600080fd5b612c4385612b10565b9350612c5160208601612b10565b925060408501359150606085013567ffffffffffffffff811115612c7457600080fd5b612c8087828801612b97565b91505092959194509250565b600060208284031215612c9e57600080fd5b6111ad82612b10565b60008060408385031215612cba57600080fd5b82359150612cca60208401612b10565b90509250929050565b60008060408385031215612ce657600080fd5b612cef83612b10565b946020939093013593505050565b60008060408385031215612d1057600080fd5b612d1983612b10565b9150602083013567ffffffffffffffff811115612d3557600080fd5b612d4185828601612b97565b9150509250929050565b60008060208385031215612d5e57600080fd5b823567ffffffffffffffff80821115612d7657600080fd5b818501915085601f830112612d8a57600080fd5b813581811115612d9957600080fd5b8660208260061b8501011115612dae57600080fd5b60209290920196919550909350505050565b60008083601f840112612dd257600080fd5b50813567ffffffffffffffff811115612dea57600080fd5b6020830191508360208260051b850101111561211757600080fd5b600080600060408486031215612e1a57600080fd5b612e2384612b10565b9250602084013567ffffffffffffffff811115612e3f57600080fd5b612e4b86828701612dc0565b9497909650939450505050565b602080825282518282018190526000919060409081850190868401855b82811015612ea45781518051855286810151878601528501518585015260609093019290850190600101612e75565b5091979650505050505050565b60008060208385031215612ec457600080fd5b823567ffffffffffffffff811115612edb57600080fd5b612ee785828601612dc0565b90969095509350505050565b6020808252825182820181905260009190848201906040850190845b818110156128b057835183529284019291840191600101612f0f565b60005b83811015612f46578181015183820152602001612f2e565b50506000910152565b6020815260008251806020840152612f6e816040850160208701612f2b565b601f01601f19169190910160400192915050565b600060408284031215612f9457600080fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600082612fcd57634e487b7160e01b600052601260045260246000fd5b500490565b80820180821115610b1a57610b1a612f9a565b602080825260099082015268139bdd0814dd185c9d60ba1b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561303057600080fd5b5051919050565b81810381811115610b1a57610b1a612f9a565b8082028115828204841417610b1a57610b1a612f9a565b60006020828403121561307357600080fd5b815180151581146111ad57600080fd5b60008251613095818460208701612f2b565b919091019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775a2646970667358221220c072d7296635401bc6b2f813ed7d13eaf5f310f88c084764523f72022c23faf864736f6c63430008170033