Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
NFTPlugging
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 100 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; contract NFTPlugging is Initializable, ReentrancyGuardUpgradeable, AccessControlUpgradeable, PausableUpgradeable, UUPSUpgradeable { // Events event Plugged( address indexed user, address indexed collection, uint256[] tokenIds, uint256 pluggedAt, uint256 pluggedUntil ); event Unplugged( address indexed user, address indexed collection, uint256[] tokenIds, uint256 unpluggedAt ); event TreasuryAddressUpdated( address indexed oldTreasury, address indexed newTreasury, uint256 timestamp, address initiatedBy ); event MaxTokenIdsLengthUpdated( uint oldLength, uint newLength, uint256 timestamp, address initiatedBy ); event SeasonStartTimestampUpdated( uint oldTimestamp, uint newTimestamp, uint256 timestamp, address initiatedBy ); event SeasonEndTimestampUpdated( uint oldTimestamp, uint newTimestamp, uint256 timestamp, address initiatedBy ); event GracePeriodTimestampUpdated( uint oldTimestamp, uint newTimestamp, uint256 timestamp, address initiatedBy ); event CollectionUnplugableStatusUpdated( address indexed collectionAddress, bool status, uint256 timestamp, address initiatedBy ); event NexusGemCollectionUpdated( address indexed oldCollection, address indexed newCollection, uint256 timestamp, address initiatedBy ); event RgCollectionUpdated( address indexed oldCollection, address indexed newCollection, uint256 timestamp, address initiatedBy ); event ImmortalCollectionUpdated( address indexed oldCollection, address indexed newCollection, uint256 timestamp, address initiatedBy ); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner, uint256 timestamp, address initiatedBy ); struct PlugDetails { address owner; uint256 tokenId; uint256 pluggedAt; uint256 pluggedUntil; } struct ScoutNodeDetails { address owner; string id; uint claimedAt; } using EnumerableSetUpgradeable for EnumerableSetUpgradeable.UintSet; IERC721Upgradeable public _nexusGem; IERC721Upgradeable public _rgBytes; IERC721Upgradeable public _immortals; uint public _seasonStartTimestamp; uint public _seasonEndTimestamp; uint public _gracePeriodTimestamp; uint public _maxTokenIdsLength; address public _treasury; mapping(address => mapping(uint256 => PlugDetails)) public _plugDetails; mapping(address => mapping(address => EnumerableSetUpgradeable.UintSet)) _pluggedTokenIds; mapping(address => mapping(uint256 => ScoutNodeDetails)) public _scoutNodeDetails; mapping(address => mapping(address => EnumerableSetUpgradeable.UintSet)) _claimedScoutNodes; mapping(address => mapping(uint => bool)) public _isTokenEverPlugged; mapping(address => bool) public _isUnplugable; bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE"); /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function initialize( address nexusGem, address rgBytes, address immortals, address admin, address treasury ) public initializer { __ReentrancyGuard_init(); __AccessControl_init(); __Pausable_init(); __UUPSUpgradeable_init(); _isValidAddress(nexusGem); _isValidAddress(rgBytes); _isValidAddress(immortals); _isValidAddress(treasury); _nexusGem = IERC721Upgradeable(nexusGem); _rgBytes = IERC721Upgradeable(rgBytes); _immortals = IERC721Upgradeable(immortals); _maxTokenIdsLength = 75; _treasury = treasury; _grantRole(DEFAULT_ADMIN_ROLE, admin); _grantRole(PAUSER_ROLE, admin); _grantRole(UPGRADER_ROLE, admin); } function plug( address collectionAddress, uint256[] memory tokenIds ) external nonReentrant whenNotPaused { _isValidColllectionAddress(collectionAddress); _isValidTokenIdsArray(tokenIds); IERC721Upgradeable nftContract = IERC721Upgradeable(collectionAddress); uint256 pluggedUntil; uint256 pluggedAt; require( block.timestamp >= _seasonStartTimestamp, "Plugging: Season has not started yet" ); require( block.timestamp <= _seasonEndTimestamp, "Plugging: Season has ended" ); if (block.timestamp <= _gracePeriodTimestamp) { pluggedAt = _seasonStartTimestamp; } else { pluggedAt = block.timestamp; } pluggedUntil = _seasonEndTimestamp; for (uint i; i < tokenIds.length; i++) { require( nftContract.ownerOf(tokenIds[i]) == msg.sender, "Plugging: You don't own all token" ); // if ( // !_isTokenEverPlugged[collectionAddress][tokenIds[i]] && // collectionAddress != address(_immortals) // ) { // _isTokenEverPlugged[collectionAddress][tokenIds[i]] = true; // string memory collectionName = _getCollectionName( // collectionAddress // ); // string memory scoutNodeId = _concatenateString( // collectionName, // Strings.toString(tokenIds[i]) // ); // _scoutNodeDetails[collectionAddress][ // tokenIds[i] // ] = ScoutNodeDetails(msg.sender, scoutNodeId, pluggedAt); // _claimedScoutNodes[collectionAddress][msg.sender].add( // tokenIds[i] // ); // } _plugDetails[collectionAddress][tokenIds[i]] = PlugDetails( msg.sender, tokenIds[i], pluggedAt, pluggedUntil ); _pluggedTokenIds[collectionAddress][msg.sender].add(tokenIds[i]); nftContract.transferFrom(msg.sender, _treasury, tokenIds[i]); } emit Plugged( msg.sender, collectionAddress, tokenIds, pluggedAt, pluggedUntil ); } function unplug( address collectionAddress, uint256[] memory tokenIds ) external nonReentrant whenNotPaused { _isValidColllectionAddress(collectionAddress); _isValidTokenIdsArray(tokenIds); _isCollectionUnplugable(collectionAddress); for (uint i; i < tokenIds.length; i++) { require( _plugDetails[collectionAddress][tokenIds[i]].owner == msg.sender, "Plugging: You don't own all plug" ); require( block.timestamp >= _plugDetails[collectionAddress][tokenIds[i]].pluggedUntil, "Plugging: Can't unplug before the pluggedUntil time" ); delete _plugDetails[collectionAddress][tokenIds[i]]; _pluggedTokenIds[collectionAddress][msg.sender].remove(tokenIds[i]); IERC721Upgradeable(collectionAddress).transferFrom( _treasury, msg.sender, tokenIds[i] ); } emit Unplugged( msg.sender, collectionAddress, tokenIds, block.timestamp ); } function updateTreasuryAddress( address treasury ) public onlyRole(DEFAULT_ADMIN_ROLE) whenNotPaused { _isValidAddress(treasury); address oldTreasury = _treasury; _treasury = treasury; emit TreasuryAddressUpdated( oldTreasury, treasury, block.timestamp, msg.sender ); } function updateMaxTokenIdsLength( uint length ) public onlyRole(DEFAULT_ADMIN_ROLE) whenNotPaused { require(length > 0, "Plugging: Invalid array length"); uint oldLength = _maxTokenIdsLength; _maxTokenIdsLength = length; emit MaxTokenIdsLengthUpdated( oldLength, length, block.timestamp, msg.sender ); } function updateSeasonStartTimestamp( uint timestamp ) public onlyRole(DEFAULT_ADMIN_ROLE) whenNotPaused { require(timestamp > 0, "Plugging: Invalid timestamp"); uint oldTimestamp = _seasonStartTimestamp; _seasonStartTimestamp = timestamp; emit SeasonStartTimestampUpdated( oldTimestamp, timestamp, block.timestamp, msg.sender ); } function updateSeasonEndTimestamp( uint timestamp ) public onlyRole(DEFAULT_ADMIN_ROLE) whenNotPaused { require(timestamp > 0, "Plugging: Invalid timestamp"); uint oldTimestamp = _seasonEndTimestamp; _seasonEndTimestamp = timestamp; emit SeasonEndTimestampUpdated( oldTimestamp, timestamp, block.timestamp, msg.sender ); } function updateGracePeriodTimestamp( uint timestamp ) public onlyRole(DEFAULT_ADMIN_ROLE) whenNotPaused { require(timestamp > 0, "Plugging: Invalid timestamp"); uint oldTimestamp = _gracePeriodTimestamp; _gracePeriodTimestamp = timestamp; emit GracePeriodTimestampUpdated( oldTimestamp, timestamp, block.timestamp, msg.sender ); } function updateCollectionUnplugableStatus( address[] calldata collectionAddresses, bool[] calldata statuses ) public onlyRole(DEFAULT_ADMIN_ROLE) whenNotPaused { require( collectionAddresses.length == statuses.length, "Plugging: Array length miss-match" ); for (uint i; i < collectionAddresses.length; i++) { _isValidColllectionAddress(collectionAddresses[i]); _isUnplugable[collectionAddresses[i]] = statuses[i]; emit CollectionUnplugableStatusUpdated( collectionAddresses[i], statuses[i], block.timestamp, msg.sender ); } } function updateNexusGemCollection( address collectionAddress ) public onlyRole(DEFAULT_ADMIN_ROLE) whenNotPaused { _isValidContractAddress(collectionAddress); address oldCollection = address(_nexusGem); _nexusGem = IERC721Upgradeable(collectionAddress); emit NexusGemCollectionUpdated( oldCollection, collectionAddress, block.timestamp, msg.sender ); } function updateRgCollection( address collectionAddress ) public onlyRole(DEFAULT_ADMIN_ROLE) whenNotPaused { _isValidContractAddress(collectionAddress); address oldCollection = address(_rgBytes); _rgBytes = IERC721Upgradeable(collectionAddress); emit RgCollectionUpdated( oldCollection, collectionAddress, block.timestamp, msg.sender ); } function updateImmortalCollection( address collectionAddress ) public onlyRole(DEFAULT_ADMIN_ROLE) whenNotPaused { _isValidContractAddress(collectionAddress); address oldCollection = address(_immortals); _immortals = IERC721Upgradeable(collectionAddress); emit ImmortalCollectionUpdated( oldCollection, collectionAddress, block.timestamp, msg.sender ); } function pause() public onlyRole(PAUSER_ROLE) { _pause(); } function unpause() public onlyRole(PAUSER_ROLE) { _unpause(); } function transferContractOwnership( address newOwner ) public onlyRole(DEFAULT_ADMIN_ROLE) { _isValidAddress(newOwner); address oldOwner = msg.sender; _revokeRole(DEFAULT_ADMIN_ROLE, msg.sender); _revokeRole(PAUSER_ROLE, msg.sender); _revokeRole(UPGRADER_ROLE, msg.sender); _grantRole(DEFAULT_ADMIN_ROLE, newOwner); _grantRole(PAUSER_ROLE, newOwner); _grantRole(UPGRADER_ROLE, newOwner); emit OwnershipTransferred( oldOwner, newOwner, block.timestamp, msg.sender ); } function getUserPluggedTokenIds( address collectionAddress, address userAddress ) public view returns (uint[] memory) { return _pluggedTokenIds[collectionAddress][userAddress].values(); } function getUserScoutNodeIds( address collectionAddress, address userAddress ) public view returns (uint[] memory) { return _claimedScoutNodes[collectionAddress][userAddress].values(); } function getUserPluggedNFTs( address collectionAddress, address userAddress ) public view returns (PlugDetails[] memory) { uint256[] memory pluggedTokenIds = _pluggedTokenIds[collectionAddress][ userAddress ].values(); PlugDetails[] memory pluggedDetails = new PlugDetails[]( pluggedTokenIds.length ); for (uint256 i = 0; i < pluggedTokenIds.length; i++) { pluggedDetails[i] = _plugDetails[collectionAddress][ pluggedTokenIds[i] ]; } return pluggedDetails; } function getUserScoutNodesPerCollection( address collectionAddress, address userAddress ) public view returns (ScoutNodeDetails[] memory) { uint256[] memory scoutNodesIds = _claimedScoutNodes[collectionAddress][ userAddress ].values(); ScoutNodeDetails[] memory scoutNodes = new ScoutNodeDetails[]( scoutNodesIds.length ); for (uint256 i = 0; i < scoutNodesIds.length; i++) { scoutNodes[i] = _scoutNodeDetails[collectionAddress][ scoutNodesIds[i] ]; } return scoutNodes; } function getUserPluggedNFTs( address userAddress ) public view returns ( PlugDetails[] memory, PlugDetails[] memory, PlugDetails[] memory ) { uint256[] memory gemPluggedTokenIds = _pluggedTokenIds[ address(_nexusGem) ][userAddress].values(); uint256[] memory rgPluggedTokenIds = _pluggedTokenIds[ address(_rgBytes) ][userAddress].values(); uint256[] memory immortalPluggedTokenIds = _pluggedTokenIds[ address(_immortals) ][userAddress].values(); PlugDetails[] memory pluggedGemDetails = new PlugDetails[]( gemPluggedTokenIds.length ); PlugDetails[] memory pluggedRgDetails = new PlugDetails[]( rgPluggedTokenIds.length ); PlugDetails[] memory pluggedImmortalDetails = new PlugDetails[]( immortalPluggedTokenIds.length ); for (uint256 i = 0; i < gemPluggedTokenIds.length; i++) { pluggedGemDetails[i] = _plugDetails[address(_nexusGem)][ gemPluggedTokenIds[i] ]; } for (uint256 i = 0; i < rgPluggedTokenIds.length; i++) { pluggedRgDetails[i] = _plugDetails[address(_rgBytes)][ rgPluggedTokenIds[i] ]; } for (uint256 i = 0; i < immortalPluggedTokenIds.length; i++) { pluggedImmortalDetails[i] = _plugDetails[address(_immortals)][ immortalPluggedTokenIds[i] ]; } return (pluggedGemDetails, pluggedRgDetails, pluggedImmortalDetails); } function getUserScoutNodes( address userAddress ) public view returns (ScoutNodeDetails[] memory, ScoutNodeDetails[] memory) { uint256[] memory gemScoutNodeIds = _claimedScoutNodes[ address(_nexusGem) ][userAddress].values(); uint256[] memory rgScoutNodeIds = _claimedScoutNodes[address(_rgBytes)][ userAddress ].values(); ScoutNodeDetails[] memory gemScoutNodeDetails = new ScoutNodeDetails[]( gemScoutNodeIds.length ); ScoutNodeDetails[] memory rgScoutNodeDetails = new ScoutNodeDetails[]( rgScoutNodeIds.length ); for (uint256 i = 0; i < gemScoutNodeIds.length; i++) { gemScoutNodeDetails[i] = _scoutNodeDetails[address(_nexusGem)][ gemScoutNodeIds[i] ]; } for (uint256 i = 0; i < rgScoutNodeIds.length; i++) { rgScoutNodeDetails[i] = _scoutNodeDetails[address(_rgBytes)][ rgScoutNodeIds[i] ]; } return (gemScoutNodeDetails, rgScoutNodeDetails); } function _getCollectionName( address collection ) private view returns (string memory) { if (collection == address(_nexusGem)) { return "gem_"; } else if (collection == address(_rgBytes)) { return "rg_"; } return ""; } function _concatenateString( string memory str1, string memory str2 ) private pure returns (string memory) { return string(abi.encodePacked(str1, str2)); } function _authorizeUpgrade( address newImplementation ) internal override onlyRole(UPGRADER_ROLE) {} function _isValidColllectionAddress(address addr) private view { require( addr == address(_immortals) || addr == address(_rgBytes) || addr == address(_nexusGem), "Plugging: Invalid collection address" ); } function _isValidContractAddress(address addr) private view { require(addr.code.length > 0, "Plugging: Invalid contract address"); } function _isValidAddress(address addr) private pure { require(addr != address(0), "Plugging: Invalid address"); } function _isValidTokenIdsArray(uint[] memory tokenIds) private view { require( tokenIds.length <= _maxTokenIdsLength, "Plugging: TokenIds array <= max allowed length" ); } function _isCollectionUnplugable(address collectionAddress) private view { require( _isUnplugable[collectionAddress], "Plugging: Cannot unplug NFTs from this collection" ); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../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, IAccessControlUpgradeable, ERC165Upgradeable { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ 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(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(account), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @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 override returns (bytes32) { 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 override 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 override 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 `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @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. * * _Available since v3.1._ */ 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 `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.0; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822ProxiableUpgradeable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol) pragma solidity ^0.8.0; /** * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC. * * _Available since v4.8.3._ */ interface IERC1967Upgradeable { /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Emitted when the beacon is changed. */ event BeaconUpgraded(address indexed beacon); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeaconUpgradeable.sol"; import "../../interfaces/IERC1967Upgradeable.sol"; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/StorageSlotUpgradeable.sol"; import {Initializable} from "../utils/Initializable.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ */ abstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable { // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; function __ERC1967Upgrade_init() internal onlyInitializing { } function __ERC1967Upgrade_init_unchained() internal onlyInitializing { } /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { AddressUpgradeable.functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else { try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) { require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID"); } catch { revert("ERC1967Upgrade: new implementation is not UUPS"); } _upgradeToAndCall(newImplementation, data, forceCall); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { AddressUpgradeable.functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../ERC1967/ERC1967UpgradeUpgradeable.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. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall"); _; } function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual override notDelegated returns (bytes32) { return _IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. * * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function upgradeTo(address newImplementation) public virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. * * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../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 { /** * @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); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _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) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == _ENTERED; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @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 caller. * * 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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol) pragma solidity ^0.8.0; 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; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.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); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @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 IERC165Upgradeable { /** * @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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUpgradeable { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMathUpgradeable { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ```solidity * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._ * _Available since v4.9 for `string`, `bytes`._ */ library StorageSlotUpgradeable { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/MathUpgradeable.sol"; import "./math/SignedMathUpgradeable.sol"; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = MathUpgradeable.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMathUpgradeable.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, MathUpgradeable.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant HEX_DIGITS = "0123456789abcdef"; uint8 private constant ADDRESS_LENGTH = 20; /** * @dev The `value` string doesn't fit in the specified `length`. */ error StringsInsufficientHexLength(uint256 value, uint256 length); /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), HEX_DIGITS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toStringSigned(int256 value) internal pure returns (string memory) { return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { uint256 localValue = value; bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = HEX_DIGITS[localValue & 0xf]; localValue >>= 4; } if (localValue != 0) { revert StringsInsufficientHexLength(value, length); } return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal * representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b)); } }
{ "optimizer": { "enabled": true, "runs": 100 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collectionAddress","type":"address"},{"indexed":false,"internalType":"bool","name":"status","type":"bool"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"initiatedBy","type":"address"}],"name":"CollectionUnplugableStatusUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"initiatedBy","type":"address"}],"name":"GracePeriodTimestampUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldCollection","type":"address"},{"indexed":true,"internalType":"address","name":"newCollection","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"initiatedBy","type":"address"}],"name":"ImmortalCollectionUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldLength","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newLength","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"initiatedBy","type":"address"}],"name":"MaxTokenIdsLengthUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldCollection","type":"address"},{"indexed":true,"internalType":"address","name":"newCollection","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"initiatedBy","type":"address"}],"name":"NexusGemCollectionUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"initiatedBy","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"collection","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"pluggedAt","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pluggedUntil","type":"uint256"}],"name":"Plugged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldCollection","type":"address"},{"indexed":true,"internalType":"address","name":"newCollection","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"initiatedBy","type":"address"}],"name":"RgCollectionUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"initiatedBy","type":"address"}],"name":"SeasonEndTimestampUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"initiatedBy","type":"address"}],"name":"SeasonStartTimestampUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldTreasury","type":"address"},{"indexed":true,"internalType":"address","name":"newTreasury","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"initiatedBy","type":"address"}],"name":"TreasuryAddressUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"collection","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"unpluggedAt","type":"uint256"}],"name":"Unplugged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_gracePeriodTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_immortals","outputs":[{"internalType":"contract IERC721Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"_isTokenEverPlugged","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"_isUnplugable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_maxTokenIdsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_nexusGem","outputs":[{"internalType":"contract IERC721Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"_plugDetails","outputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"pluggedAt","type":"uint256"},{"internalType":"uint256","name":"pluggedUntil","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_rgBytes","outputs":[{"internalType":"contract IERC721Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"_scoutNodeDetails","outputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"string","name":"id","type":"string"},{"internalType":"uint256","name":"claimedAt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_seasonEndTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_seasonStartTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"}],"name":"getUserPluggedNFTs","outputs":[{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"pluggedAt","type":"uint256"},{"internalType":"uint256","name":"pluggedUntil","type":"uint256"}],"internalType":"struct NFTPlugging.PlugDetails[]","name":"","type":"tuple[]"},{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"pluggedAt","type":"uint256"},{"internalType":"uint256","name":"pluggedUntil","type":"uint256"}],"internalType":"struct NFTPlugging.PlugDetails[]","name":"","type":"tuple[]"},{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"pluggedAt","type":"uint256"},{"internalType":"uint256","name":"pluggedUntil","type":"uint256"}],"internalType":"struct NFTPlugging.PlugDetails[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collectionAddress","type":"address"},{"internalType":"address","name":"userAddress","type":"address"}],"name":"getUserPluggedNFTs","outputs":[{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"pluggedAt","type":"uint256"},{"internalType":"uint256","name":"pluggedUntil","type":"uint256"}],"internalType":"struct NFTPlugging.PlugDetails[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collectionAddress","type":"address"},{"internalType":"address","name":"userAddress","type":"address"}],"name":"getUserPluggedTokenIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collectionAddress","type":"address"},{"internalType":"address","name":"userAddress","type":"address"}],"name":"getUserScoutNodeIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"}],"name":"getUserScoutNodes","outputs":[{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"string","name":"id","type":"string"},{"internalType":"uint256","name":"claimedAt","type":"uint256"}],"internalType":"struct NFTPlugging.ScoutNodeDetails[]","name":"","type":"tuple[]"},{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"string","name":"id","type":"string"},{"internalType":"uint256","name":"claimedAt","type":"uint256"}],"internalType":"struct NFTPlugging.ScoutNodeDetails[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collectionAddress","type":"address"},{"internalType":"address","name":"userAddress","type":"address"}],"name":"getUserScoutNodesPerCollection","outputs":[{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"string","name":"id","type":"string"},{"internalType":"uint256","name":"claimedAt","type":"uint256"}],"internalType":"struct NFTPlugging.ScoutNodeDetails[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"nexusGem","type":"address"},{"internalType":"address","name":"rgBytes","type":"address"},{"internalType":"address","name":"immortals","type":"address"},{"internalType":"address","name":"admin","type":"address"},{"internalType":"address","name":"treasury","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collectionAddress","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"plug","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferContractOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collectionAddress","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"unplug","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"collectionAddresses","type":"address[]"},{"internalType":"bool[]","name":"statuses","type":"bool[]"}],"name":"updateCollectionUnplugableStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"updateGracePeriodTimestamp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collectionAddress","type":"address"}],"name":"updateImmortalCollection","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"updateMaxTokenIdsLength","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collectionAddress","type":"address"}],"name":"updateNexusGemCollection","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collectionAddress","type":"address"}],"name":"updateRgCollection","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"updateSeasonEndTimestamp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"updateSeasonStartTimestamp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"treasury","type":"address"}],"name":"updateTreasuryAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"}]
Contract Creation Code
60a0604052306080523480156200001557600080fd5b506200002062000026565b620000e7565b600054610100900460ff1615620000935760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811614620000e5576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b6080516140dc6200011f6000396000818161119b015281816111db015281816113440152818161138401526113fc01526140dc6000f3fe60806040526004361061027d5760003560e01c806384d6b44d1161014f578063b12a6490116100c1578063e319a3d91161007a578063e319a3d914610857578063e63ab1e914610878578063e89a248e1461089a578063ebb576e8146108b1578063f6d7e4b2146108d2578063f72c0d8b146108f257600080fd5b8063b12a649014610735578063b8875e7c14610755578063c947846114610775578063c985c0c4146107f7578063d547741f14610817578063d82e94e01461083757600080fd5b8063925ef33711610113578063925ef33714610689578063938aa251146106a9578063953b484e146106c9578063a217fddf146106e0578063a843c51f146106f5578063acb1063e1461071557600080fd5b806384d6b44d146105b357806385c7b8ad146105ef578063904965f11461061c5780639149861e1461063c57806391d148541461066957600080fd5b806339a37442116101f35780635c975abb116101ac5780635c975abb146104ea578063622245ed146105025780637f93c7ee14610522578063841e4561146105515780638456cb5914610571578063846711f61461058657600080fd5b806339a37442146104505780633f4ba83a146104675780634b064dc81461047c5780634f1ef286146104ab5780635180c8ad146104be57806352d1902d146104d557600080fd5b8063248a9ca311610245578063248a9ca314610360578063284ea4201461039e5780632f2ff15d146103bf57806332f0492a146103df57806336568abe146104105780633659cfe61461043057600080fd5b806301ffc9a7146102825780631311d604146102b7578063139e3a39146102f05780631459457a1461031257806314e8fa9c14610332575b600080fd5b34801561028e57600080fd5b506102a261029d36600461367a565b610914565b60405190151581526020015b60405180910390f35b3480156102c357600080fd5b5061015f546102d8906001600160a01b031681565b6040516001600160a01b0390911681526020016102ae565b3480156102fc57600080fd5b5061031061030b3660046136ef565b61094b565b005b34801561031e57600080fd5b5061031061032d36600461376f565b610b22565b34801561033e57600080fd5b5061035261034d3660046137e0565b610d02565b6040516102ae9291906138ce565b34801561036c57600080fd5b5061039061037b3660046138fc565b60009081526097602052604090206001015490565b6040519081526020016102ae565b3480156103aa57600080fd5b50610161546102d8906001600160a01b031681565b3480156103cb57600080fd5b506103106103da366004613915565b6110e9565b3480156103eb57600080fd5b506102a26103fa3660046137e0565b61016c6020526000908152604090205460ff1681565b34801561041c57600080fd5b5061031061042b366004613915565b611113565b34801561043c57600080fd5b5061031061044b3660046137e0565b611191565b34801561045c57600080fd5b506103906101655481565b34801561047357600080fd5b50610310611259565b34801561048857600080fd5b5061049c610497366004613945565b611279565b6040516102ae93929190613971565b6103106104b93660046139eb565b61133a565b3480156104ca57600080fd5b506103906101625481565b3480156104e157600080fd5b506103906113ef565b3480156104f657600080fd5b5060c95460ff166102a2565b34801561050e57600080fd5b5061031061051d3660046138fc565b61149d565b34801561052e57600080fd5b5061054261053d3660046137e0565b61151c565b6040516102ae93929190613af6565b34801561055d57600080fd5b5061031061056c3660046137e0565b611931565b34801561057d57600080fd5b506103106119b2565b34801561059257600080fd5b506105a66105a1366004613b2f565b6119d2565b6040516102ae9190613b5d565b3480156105bf57600080fd5b506102a26105ce366004613945565b61016b60209081526000928352604080842090915290825290205460ff1681565b3480156105fb57600080fd5b5061060f61060a366004613b2f565b611b2a565b6040516102ae9190613b70565b34801561062857600080fd5b506103106106373660046138fc565b611d10565b34801561064857600080fd5b5061065c610657366004613b2f565b611db2565b6040516102ae9190613bb3565b34801561067557600080fd5b506102a2610684366004613915565b611deb565b34801561069557600080fd5b506103106106a4366004613bc6565b611e16565b3480156106b557600080fd5b506103106106c43660046137e0565b612158565b3480156106d557600080fd5b506103906101635481565b3480156106ec57600080fd5b50610390600081565b34801561070157600080fd5b506103106107103660046137e0565b6121cc565b34801561072157600080fd5b506103106107303660046138fc565b61229c565b34801561074157600080fd5b506103106107503660046138fc565b61230e565b34801561076157600080fd5b506103106107703660046137e0565b612380565b34801561078157600080fd5b506107cd610790366004613945565b61016760209081526000928352604080842090915290825290208054600182015460028301546003909301546001600160a01b0390921692909184565b604080516001600160a01b03909516855260208501939093529183015260608201526080016102ae565b34801561080357600080fd5b50610310610812366004613bc6565b6123f4565b34801561082357600080fd5b50610310610832366004613915565b61280c565b34801561084357600080fd5b506103106108523660046137e0565b612831565b34801561086357600080fd5b50610166546102d8906001600160a01b031681565b34801561088457600080fd5b5061039060008051602061406083398151915281565b3480156108a657600080fd5b506103906101645481565b3480156108bd57600080fd5b50610160546102d8906001600160a01b031681565b3480156108de57600080fd5b5061065c6108ed366004613b2f565b6128a5565b3480156108fe57600080fd5b5061039060008051602061402083398151915281565b60006001600160e01b03198216637965db0b60e01b148061094557506301ffc9a760e01b6001600160e01b03198316145b92915050565b6000610956816128d7565b61095e6128e1565b8382146109bc5760405162461bcd60e51b815260206004820152602160248201527f506c756767696e673a204172726179206c656e677468206d6973732d6d6174636044820152600d60fb1b60648201526084015b60405180910390fd5b60005b84811015610b1a576109f68686838181106109dc576109dc613c80565b90506020020160208101906109f191906137e0565b612929565b838382818110610a0857610a08613c80565b9050602002016020810190610a1d9190613c96565b61016c6000888885818110610a3457610a34613c80565b9050602002016020810190610a4991906137e0565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055858582818110610a8357610a83613c80565b9050602002016020810190610a9891906137e0565b6001600160a01b03167f5eebc2c7781bdf97cd290973f8ca664cfda1f3493d108af97c1b2a6b61fb5236858584818110610ad457610ad4613c80565b9050602002016020810190610ae99190613c96565b604080519115158252426020830152339082015260600160405180910390a280610b1281613cce565b9150506109bf565b505050505050565b600054610100900460ff1615808015610b425750600054600160ff909116105b80610b5c5750303b158015610b5c575060005460ff166001145b610bbf5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016109b3565b6000805460ff191660011790558015610be2576000805461ff0019166101001790555b610bea6129c5565b610bf26129f4565b610bfa612a1b565b610c026129f4565b610c0b86612a4a565b610c1485612a4a565b610c1d84612a4a565b610c2682612a4a565b61015f80546001600160a01b038089166001600160a01b03199283161790925561016080548884169083161790556101618054878416908316179055604b61016555610166805492851692909116919091179055610c85600084612a9c565b610c9d60008051602061406083398151915284612a9c565b610cb560008051602061402083398151915284612a9c565b8015610b1a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050505050565b61015f546001600160a01b03908116600090815261016a6020908152604080832093851683529290529081206060918291610d3c90612b22565b610160546001600160a01b03908116600090815261016a60209081526040808320938916835292905290812091925090610d7590612b22565b9050600082516001600160401b03811115610d9257610d926139a5565b604051908082528060200260200182016040528015610dcb57816020015b610db861361f565b815260200190600190039081610db05790505b509050600082516001600160401b03811115610de957610de96139a5565b604051908082528060200260200182016040528015610e2257816020015b610e0f61361f565b815260200190600190039081610e075790505b50905060005b8451811015610f805761015f546001600160a01b03166000908152610169602052604081208651909190879084908110610e6457610e64613c80565b602002602001015181526020019081526020016000206040518060600160405290816000820160009054906101000a90046001600160a01b03166001600160a01b03166001600160a01b03168152602001600182018054610ec490613ce7565b80601f0160208091040260200160405190810160405280929190818152602001828054610ef090613ce7565b8015610f3d5780601f10610f1257610100808354040283529160200191610f3d565b820191906000526020600020905b815481529060010190602001808311610f2057829003601f168201915b50505050508152602001600282015481525050838281518110610f6257610f62613c80565b60200260200101819052508080610f7890613cce565b915050610e28565b5060005b83518110156110dc57610160546001600160a01b03166000908152610169602052604081208551909190869084908110610fc057610fc0613c80565b602002602001015181526020019081526020016000206040518060600160405290816000820160009054906101000a90046001600160a01b03166001600160a01b03166001600160a01b0316815260200160018201805461102090613ce7565b80601f016020809104026020016040519081016040528092919081815260200182805461104c90613ce7565b80156110995780601f1061106e57610100808354040283529160200191611099565b820191906000526020600020905b81548152906001019060200180831161107c57829003601f168201915b505050505081526020016002820154815250508282815181106110be576110be613c80565b602002602001018190525080806110d490613cce565b915050610f84565b5090969095509350505050565b600082815260976020526040902060010154611104816128d7565b61110e8383612a9c565b505050565b6001600160a01b03811633146111835760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016109b3565b61118d8282612b2f565b5050565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036111d95760405162461bcd60e51b81526004016109b390613d21565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661120b612b96565b6001600160a01b0316146112315760405162461bcd60e51b81526004016109b390613d6d565b61123a81612bb2565b6040805160008082526020820190925261125691839190612bca565b50565b600080516020614060833981519152611271816128d7565b611256612d35565b610169602090815260009283526040808420909152908252902080546001820180546001600160a01b0390921692916112b190613ce7565b80601f01602080910402602001604051908101604052809291908181526020018280546112dd90613ce7565b801561132a5780601f106112ff5761010080835404028352916020019161132a565b820191906000526020600020905b81548152906001019060200180831161130d57829003601f168201915b5050505050908060020154905083565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036113825760405162461bcd60e51b81526004016109b390613d21565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166113b4612b96565b6001600160a01b0316146113da5760405162461bcd60e51b81526004016109b390613d6d565b6113e382612bb2565b61118d82826001612bca565b6000306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461148a5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b60648201526084016109b3565b5060008051602061404083398151915290565b60006114a8816128d7565b6114b06128e1565b600082116114d05760405162461bcd60e51b81526004016109b390613db9565b6101638054908390556040517fde52fa83109493c55c085b54becbf0aac762479e5f436e38d15b66d1fdd387739061150f908390869042903390613df0565b60405180910390a1505050565b61015f546001600160a01b039081166000908152610168602090815260408083209385168352929052908120606091829182919061155990612b22565b610160546001600160a01b03908116600090815261016860209081526040808320938a1683529290529081209192509061159290612b22565b610161546001600160a01b03908116600090815261016860209081526040808320938b168352929052908120919250906115cb90612b22565b9050600083516001600160401b038111156115e8576115e86139a5565b60405190808252806020026020018201604052801561162157816020015b61160e613649565b8152602001906001900390816116065790505b509050600083516001600160401b0381111561163f5761163f6139a5565b60405190808252806020026020018201604052801561167857816020015b611665613649565b81526020019060019003908161165d5790505b509050600083516001600160401b03811115611696576116966139a5565b6040519080825280602002602001820160405280156116cf57816020015b6116bc613649565b8152602001906001900390816116b45790505b50905060005b86518110156117965761015f546001600160a01b0316600090815261016760205260408120885190919089908490811061171157611711613c80565b6020908102919091018101518252818101929092526040908101600020815160808101835281546001600160a01b03168152600182015493810193909352600281015491830191909152600301546060820152845185908390811061177857611778613c80565b6020026020010181905250808061178e90613cce565b9150506116d5565b5060005b855181101561185b57610160546001600160a01b031660009081526101676020526040812087519091908890849081106117d6576117d6613c80565b6020908102919091018101518252818101929092526040908101600020815160808101835281546001600160a01b03168152600182015493810193909352600281015491830191909152600301546060820152835184908390811061183d5761183d613c80565b6020026020010181905250808061185390613cce565b91505061179a565b5060005b845181101561192057610161546001600160a01b0316600090815261016760205260408120865190919087908490811061189b5761189b613c80565b6020908102919091018101518252818101929092526040908101600020815160808101835281546001600160a01b03168152600182015493810193909352600281015491830191909152600301546060820152825183908390811061190257611902613c80565b6020026020010181905250808061191890613cce565b91505061185f565b509199909850909650945050505050565b600061193c816128d7565b6119446128e1565b61194d82612a4a565b61016680546001600160a01b038481166001600160a01b0319831681179093556040519116919082907f111d7d9ba75ec299e3ad78ca28dd6647b17b87fc2292dad7a0a2e4ac2e3cb15c906119a59042903390613e14565b60405180910390a3505050565b6000805160206140608339815191526119ca816128d7565b611256612d87565b6001600160a01b03808316600090815261016860209081526040808320938516835292905290812060609190611a0790612b22565b9050600081516001600160401b03811115611a2457611a246139a5565b604051908082528060200260200182016040528015611a5d57816020015b611a4a613649565b815260200190600190039081611a425790505b50905060005b8251811015611b21576001600160a01b0386166000908152610167602052604081208451909190859084908110611a9c57611a9c613c80565b6020908102919091018101518252818101929092526040908101600020815160808101835281546001600160a01b031681526001820154938101939093526002810154918301919091526003015460608201528251839083908110611b0357611b03613c80565b60200260200101819052508080611b1990613cce565b915050611a63565b50949350505050565b6001600160a01b03808316600090815261016a60209081526040808320938516835292905290812060609190611b5f90612b22565b9050600081516001600160401b03811115611b7c57611b7c6139a5565b604051908082528060200260200182016040528015611bb557816020015b611ba261361f565b815260200190600190039081611b9a5790505b50905060005b8251811015611b21576001600160a01b0386166000908152610169602052604081208451909190859084908110611bf457611bf4613c80565b602002602001015181526020019081526020016000206040518060600160405290816000820160009054906101000a90046001600160a01b03166001600160a01b03166001600160a01b03168152602001600182018054611c5490613ce7565b80601f0160208091040260200160405190810160405280929190818152602001828054611c8090613ce7565b8015611ccd5780601f10611ca257610100808354040283529160200191611ccd565b820191906000526020600020905b815481529060010190602001808311611cb057829003601f168201915b50505050508152602001600282015481525050828281518110611cf257611cf2613c80565b60200260200101819052508080611d0890613cce565b915050611bbb565b6000611d1b816128d7565b611d236128e1565b60008211611d735760405162461bcd60e51b815260206004820152601e60248201527f506c756767696e673a20496e76616c6964206172726179206c656e677468000060448201526064016109b3565b6101658054908390556040517f1ec459126636bfe98c20f9b92a13924caedbae653da45c756e3bade3ed2c12599061150f908390869042903390613df0565b6001600160a01b03808316600090815261016860209081526040808320938516835292905220606090611de490612b22565b9392505050565b60009182526097602090815260408084206001600160a01b0393909316845291905290205460ff1690565b611e1e612dc4565b611e266128e1565b611e2f82612929565b611e3881612e1d565b611e4182612e88565b60005b8151811015612101576001600160a01b0383166000908152610167602052604081208351339290859085908110611e7d57611e7d613c80565b6020908102919091018101518252810191909152604001600020546001600160a01b031614611eee5760405162461bcd60e51b815260206004820181905260248201527f506c756767696e673a20596f7520646f6e2774206f776e20616c6c20706c756760448201526064016109b3565b6001600160a01b0383166000908152610167602052604081208351909190849084908110611f1e57611f1e613c80565b6020026020010151815260200190815260200160002060030154421015611fa35760405162461bcd60e51b815260206004820152603360248201527f506c756767696e673a2043616e277420756e706c7567206265666f72652074686044820152726520706c7567676564556e74696c2074696d6560681b60648201526084016109b3565b6001600160a01b0383166000908152610167602052604081208351909190849084908110611fd357611fd3613c80565b6020908102919091018101518252810191909152604001600090812080546001600160a01b0319168155600181018290556002810182905560030155815161205c9083908390811061202757612027613c80565b6020908102919091018101516001600160a01b0386166000908152610168835260408082203383529093529190912090612f0b565b50826001600160a01b03166323b872dd61016660009054906101000a90046001600160a01b03163385858151811061209657612096613c80565b60200260200101516040518463ffffffff1660e01b81526004016120bc93929190613e2b565b600060405180830381600087803b1580156120d657600080fd5b505af11580156120ea573d6000803e3d6000fd5b5050505080806120f990613cce565b915050611e44565b50816001600160a01b0316336001600160a01b03167fc0f5a2a48d41af8ec29bf97ba6dac4335a15389d01989b0fc57c3158516cae6e8342604051612147929190613e4f565b60405180910390a361118d60018055565b6000612163816128d7565b61216b6128e1565b61217482612f1d565b61015f80546001600160a01b038481166001600160a01b0319831681179093556040519116919082907ff495a93845b6fdfbea2aaf56581914a5230c393b90ca893c62e320fd8cca41df906119a59042903390613e14565b60006121d7816128d7565b6121e082612a4a565b336121ec600082612b2f565b61220460008051602061406083398151915233612b2f565b61221c60008051602061402083398151915233612b2f565b612227600084612a9c565b61223f60008051602061406083398151915284612a9c565b61225760008051602061402083398151915284612a9c565b826001600160a01b0316816001600160a01b03167f1fb25c9e60d7a2ccc6262983e9e56cec2491bb6aad543e1e25459c789b313ced42336040516119a5929190613e14565b60006122a7816128d7565b6122af6128e1565b600082116122cf5760405162461bcd60e51b81526004016109b390613db9565b6101628054908390556040517f371d83057fbe64ef78f5b5e6b33dc2834b4ded888e4364e6fe99ad2679c791259061150f908390869042903390613df0565b6000612319816128d7565b6123216128e1565b600082116123415760405162461bcd60e51b81526004016109b390613db9565b6101648054908390556040517fd882d6ec557d912997df6094f8c7ea5fc7aa7f919161033eb3ae028e680506319061150f908390869042903390613df0565b600061238b816128d7565b6123936128e1565b61239c82612f1d565b61016180546001600160a01b038481166001600160a01b0319831681179093556040519116919082907fa7fba29371f41c1844426fabd1e548061569003bb4e61baf861dd1d3d9661ae0906119a59042903390613e14565b6123fc612dc4565b6124046128e1565b61240d82612929565b61241681612e1d565b60008290506000806101625442101561247d5760405162461bcd60e51b8152602060048201526024808201527f506c756767696e673a20536561736f6e20686173206e6f742073746172746564604482015263081e595d60e21b60648201526084016109b3565b610163544211156124d05760405162461bcd60e51b815260206004820152601a60248201527f506c756767696e673a20536561736f6e2068617320656e64656400000000000060448201526064016109b3565b6101645442116124e45750610162546124e7565b50425b61016354915060005b84518110156127b057336001600160a01b0316846001600160a01b0316636352211e87848151811061252457612524613c80565b60200260200101516040518263ffffffff1660e01b815260040161254a91815260200190565b602060405180830381865afa158015612567573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061258b9190613e71565b6001600160a01b0316146125eb5760405162461bcd60e51b815260206004820152602160248201527f506c756767696e673a20596f7520646f6e2774206f776e20616c6c20746f6b656044820152603760f91b60648201526084016109b3565b6040518060800160405280336001600160a01b0316815260200186838151811061261757612617613c80565b60200260200101518152602001838152602001848152506101676000886001600160a01b03166001600160a01b03168152602001908152602001600020600087848151811061266857612668613c80565b6020908102919091018101518252818101929092526040908101600020835181546001600160a01b0319166001600160a01b039091161781559183015160018301558201516002820155606090910151600390910155845161270b908690839081106126d6576126d6613c80565b6020908102919091018101516001600160a01b0389166000908152610168835260408082203383529093529190912090612f82565b50836001600160a01b03166323b872dd3361016660009054906101000a90046001600160a01b031688858151811061274557612745613c80565b60200260200101516040518463ffffffff1660e01b815260040161276b93929190613e2b565b600060405180830381600087803b15801561278557600080fd5b505af1158015612799573d6000803e3d6000fd5b5050505080806127a890613cce565b9150506124f0565b50846001600160a01b0316336001600160a01b03167fc8ba7816ccd1af249a8182d28ac11f15d5c4825982acfae63e67dafd2475a9fe8684866040516127f893929190613e8e565b60405180910390a350505061118d60018055565b600082815260976020526040902060010154612827816128d7565b61110e8383612b2f565b600061283c816128d7565b6128446128e1565b61284d82612f1d565b61016080546001600160a01b038481166001600160a01b0319831681179093556040519116919082907f274d37081e988ceba5e2e4076ede8ca88774faf820679d40774b39081e3fd292906119a59042903390613e14565b6001600160a01b03808316600090815261016a60209081526040808320938516835292905220606090611de490612b22565b6112568133612f8e565b60c95460ff16156129275760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016109b3565b565b610161546001600160a01b03828116911614806129545750610160546001600160a01b038281169116145b8061296d575061015f546001600160a01b038281169116145b6112565760405162461bcd60e51b8152602060048201526024808201527f506c756767696e673a20496e76616c696420636f6c6c656374696f6e206164646044820152637265737360e01b60648201526084016109b3565b600054610100900460ff166129ec5760405162461bcd60e51b81526004016109b390613eb3565b612927612fe7565b600054610100900460ff166129275760405162461bcd60e51b81526004016109b390613eb3565b600054610100900460ff16612a425760405162461bcd60e51b81526004016109b390613eb3565b61292761300e565b6001600160a01b0381166112565760405162461bcd60e51b8152602060048201526019602482015278506c756767696e673a20496e76616c6964206164647265737360381b60448201526064016109b3565b612aa68282611deb565b61118d5760008281526097602090815260408083206001600160a01b03851684529091529020805460ff19166001179055612ade3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60606000611de483613041565b612b398282611deb565b1561118d5760008281526097602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080516020614040833981519152546001600160a01b031690565b60008051602061402083398151915261118d816128d7565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615612bfd5761110e8361309d565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612c57575060408051601f3d908101601f19168201909252612c5491810190613efe565b60015b612cba5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b60648201526084016109b3565b6000805160206140408339815191528114612d295760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b60648201526084016109b3565b5061110e838383613139565b612d3d613164565b60c9805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b612d8f6128e1565b60c9805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612d6a3390565b600260015403612e165760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016109b3565b6002600155565b61016554815111156112565760405162461bcd60e51b815260206004820152602e60248201527f506c756767696e673a20546f6b656e496473206172726179203c3d206d61782060448201526d0c2d8d8deeecac840d8cadccee8d60931b60648201526084016109b3565b6001600160a01b038116600090815261016c602052604090205460ff166112565760405162461bcd60e51b815260206004820152603160248201527f506c756767696e673a2043616e6e6f7420756e706c7567204e4654732066726f60448201527036903a3434b99031b7b63632b1ba34b7b760791b60648201526084016109b3565b6000611de483836131ad565b60018055565b6000816001600160a01b03163b116112565760405162461bcd60e51b815260206004820152602260248201527f506c756767696e673a20496e76616c696420636f6e7472616374206164647265604482015261737360f01b60648201526084016109b3565b6000611de483836132a0565b612f988282611deb565b61118d57612fa5816132ef565b612fb0836020613301565b604051602001612fc1929190613f17565b60408051601f198184030181529082905262461bcd60e51b82526109b391600401613f86565b600054610100900460ff16612f175760405162461bcd60e51b81526004016109b390613eb3565b600054610100900460ff166130355760405162461bcd60e51b81526004016109b390613eb3565b60c9805460ff19169055565b60608160000180548060200260200160405190810160405280929190818152602001828054801561309157602002820191906000526020600020905b81548152602001906001019080831161307d575b50505050509050919050565b6001600160a01b0381163b61310a5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016109b3565b60008051602061404083398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6131428361349c565b60008251118061314f5750805b1561110e5761315e83836134dc565b50505050565b60c95460ff166129275760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016109b3565b600081815260018301602052604081205480156132965760006131d1600183613f99565b85549091506000906131e590600190613f99565b905081811461324a57600086600001828154811061320557613205613c80565b906000526020600020015490508087600001848154811061322857613228613c80565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061325b5761325b613fac565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610945565b6000915050610945565b60008181526001830160205260408120546132e757508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610945565b506000610945565b60606109456001600160a01b03831660145b60606000613310836002613fc2565b61331b906002613fd9565b6001600160401b03811115613332576133326139a5565b6040519080825280601f01601f19166020018201604052801561335c576020820181803683370190505b509050600360fc1b8160008151811061337757613377613c80565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106133a6576133a6613c80565b60200101906001600160f81b031916908160001a90535060006133ca846002613fc2565b6133d5906001613fd9565b90505b600181111561344d576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061340957613409613c80565b1a60f81b82828151811061341f5761341f613c80565b60200101906001600160f81b031916908160001a90535060049490941c9361344681613fec565b90506133d8565b508315611de45760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109b3565b6134a58161309d565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060611de48383604051806060016040528060278152602001614080602791396060600080856001600160a01b0316856040516135199190614003565b600060405180830381855af49150503d8060008114613554576040519150601f19603f3d011682016040523d82523d6000602084013e613559565b606091505b509150915061356a86838387613574565b9695505050505050565b606083156135e35782516000036135dc576001600160a01b0385163b6135dc5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109b3565b50816135ed565b6135ed83836135f5565b949350505050565b8151156136055781518083602001fd5b8060405162461bcd60e51b81526004016109b39190613f86565b604051806060016040528060006001600160a01b0316815260200160608152602001600081525090565b604051806080016040528060006001600160a01b031681526020016000815260200160008152602001600081525090565b60006020828403121561368c57600080fd5b81356001600160e01b031981168114611de457600080fd5b60008083601f8401126136b657600080fd5b5081356001600160401b038111156136cd57600080fd5b6020830191508360208260051b85010111156136e857600080fd5b9250929050565b6000806000806040858703121561370557600080fd5b84356001600160401b038082111561371c57600080fd5b613728888389016136a4565b9096509450602087013591508082111561374157600080fd5b5061374e878288016136a4565b95989497509550505050565b6001600160a01b038116811461125657600080fd5b600080600080600060a0868803121561378757600080fd5b85356137928161375a565b945060208601356137a28161375a565b935060408601356137b28161375a565b925060608601356137c28161375a565b915060808601356137d28161375a565b809150509295509295909350565b6000602082840312156137f257600080fd5b8135611de48161375a565b60005b83811015613818578181015183820152602001613800565b50506000910152565b600081518084526138398160208601602086016137fd565b601f01601f19169290920160200192915050565b600081518084526020808501808196508360051b8101915082860160005b858110156138c1578284038952815180516001600160a01b03168552858101516060878701819052906138a082880182613821565b6040938401519790930196909652509885019893509084019060010161386b565b5091979650505050505050565b6040815260006138e1604083018561384d565b82810360208401526138f3818561384d565b95945050505050565b60006020828403121561390e57600080fd5b5035919050565b6000806040838503121561392857600080fd5b82359150602083013561393a8161375a565b809150509250929050565b6000806040838503121561395857600080fd5b82356139638161375a565b946020939093013593505050565b6001600160a01b038416815260606020820181905260009061399590830185613821565b9050826040830152949350505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156139e3576139e36139a5565b604052919050565b600080604083850312156139fe57600080fd5b8235613a098161375a565b91506020838101356001600160401b0380821115613a2657600080fd5b818601915086601f830112613a3a57600080fd5b813581811115613a4c57613a4c6139a5565b613a5e601f8201601f191685016139bb565b91508082528784828501011115613a7457600080fd5b80848401858401376000848284010152508093505050509250929050565b600081518084526020808501945080840160005b83811015613aeb57815180516001600160a01b031688528381015184890152604080820151908901526060908101519088015260809096019590820190600101613aa6565b509495945050505050565b606081526000613b096060830186613a92565b8281036020840152613b1b8186613a92565b9050828103604084015261356a8185613a92565b60008060408385031215613b4257600080fd5b8235613b4d8161375a565b9150602083013561393a8161375a565b602081526000611de46020830184613a92565b602081526000611de4602083018461384d565b600081518084526020808501945080840160005b83811015613aeb57815187529582019590820190600101613b97565b602081526000611de46020830184613b83565b60008060408385031215613bd957600080fd5b8235613be48161375a565b91506020838101356001600160401b0380821115613c0157600080fd5b818601915086601f830112613c1557600080fd5b813581811115613c2757613c276139a5565b8060051b9150613c388483016139bb565b8181529183018401918481019089841115613c5257600080fd5b938501935b83851015613c7057843582529385019390850190613c57565b8096505050505050509250929050565b634e487b7160e01b600052603260045260246000fd5b600060208284031215613ca857600080fd5b81358015158114611de457600080fd5b634e487b7160e01b600052601160045260246000fd5b600060018201613ce057613ce0613cb8565b5060010190565b600181811c90821680613cfb57607f821691505b602082108103613d1b57634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b6020808252601b908201527f506c756767696e673a20496e76616c69642074696d657374616d700000000000604082015260600190565b938452602084019290925260408301526001600160a01b0316606082015260800190565b9182526001600160a01b0316602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b604081526000613e626040830185613b83565b90508260208301529392505050565b600060208284031215613e8357600080fd5b8151611de48161375a565b606081526000613ea16060830186613b83565b60208301949094525060400152919050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600060208284031215613f1057600080fd5b5051919050565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351613f498160178501602088016137fd565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613f7a8160288401602088016137fd565b01602801949350505050565b602081526000611de46020830184613821565b8181038181111561094557610945613cb8565b634e487b7160e01b600052603160045260246000fd5b808202811582820484141761094557610945613cb8565b8082018082111561094557610945613cb8565b600081613ffb57613ffb613cb8565b506000190190565b600082516140158184602087016137fd565b919091019291505056fe189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e3360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212208f7570aa5778bf7b054d086915c5a4737a35c8f24042223dc1e2b31c8bacf85564736f6c63430008140033
Deployed Bytecode
0x60806040526004361061027d5760003560e01c806384d6b44d1161014f578063b12a6490116100c1578063e319a3d91161007a578063e319a3d914610857578063e63ab1e914610878578063e89a248e1461089a578063ebb576e8146108b1578063f6d7e4b2146108d2578063f72c0d8b146108f257600080fd5b8063b12a649014610735578063b8875e7c14610755578063c947846114610775578063c985c0c4146107f7578063d547741f14610817578063d82e94e01461083757600080fd5b8063925ef33711610113578063925ef33714610689578063938aa251146106a9578063953b484e146106c9578063a217fddf146106e0578063a843c51f146106f5578063acb1063e1461071557600080fd5b806384d6b44d146105b357806385c7b8ad146105ef578063904965f11461061c5780639149861e1461063c57806391d148541461066957600080fd5b806339a37442116101f35780635c975abb116101ac5780635c975abb146104ea578063622245ed146105025780637f93c7ee14610522578063841e4561146105515780638456cb5914610571578063846711f61461058657600080fd5b806339a37442146104505780633f4ba83a146104675780634b064dc81461047c5780634f1ef286146104ab5780635180c8ad146104be57806352d1902d146104d557600080fd5b8063248a9ca311610245578063248a9ca314610360578063284ea4201461039e5780632f2ff15d146103bf57806332f0492a146103df57806336568abe146104105780633659cfe61461043057600080fd5b806301ffc9a7146102825780631311d604146102b7578063139e3a39146102f05780631459457a1461031257806314e8fa9c14610332575b600080fd5b34801561028e57600080fd5b506102a261029d36600461367a565b610914565b60405190151581526020015b60405180910390f35b3480156102c357600080fd5b5061015f546102d8906001600160a01b031681565b6040516001600160a01b0390911681526020016102ae565b3480156102fc57600080fd5b5061031061030b3660046136ef565b61094b565b005b34801561031e57600080fd5b5061031061032d36600461376f565b610b22565b34801561033e57600080fd5b5061035261034d3660046137e0565b610d02565b6040516102ae9291906138ce565b34801561036c57600080fd5b5061039061037b3660046138fc565b60009081526097602052604090206001015490565b6040519081526020016102ae565b3480156103aa57600080fd5b50610161546102d8906001600160a01b031681565b3480156103cb57600080fd5b506103106103da366004613915565b6110e9565b3480156103eb57600080fd5b506102a26103fa3660046137e0565b61016c6020526000908152604090205460ff1681565b34801561041c57600080fd5b5061031061042b366004613915565b611113565b34801561043c57600080fd5b5061031061044b3660046137e0565b611191565b34801561045c57600080fd5b506103906101655481565b34801561047357600080fd5b50610310611259565b34801561048857600080fd5b5061049c610497366004613945565b611279565b6040516102ae93929190613971565b6103106104b93660046139eb565b61133a565b3480156104ca57600080fd5b506103906101625481565b3480156104e157600080fd5b506103906113ef565b3480156104f657600080fd5b5060c95460ff166102a2565b34801561050e57600080fd5b5061031061051d3660046138fc565b61149d565b34801561052e57600080fd5b5061054261053d3660046137e0565b61151c565b6040516102ae93929190613af6565b34801561055d57600080fd5b5061031061056c3660046137e0565b611931565b34801561057d57600080fd5b506103106119b2565b34801561059257600080fd5b506105a66105a1366004613b2f565b6119d2565b6040516102ae9190613b5d565b3480156105bf57600080fd5b506102a26105ce366004613945565b61016b60209081526000928352604080842090915290825290205460ff1681565b3480156105fb57600080fd5b5061060f61060a366004613b2f565b611b2a565b6040516102ae9190613b70565b34801561062857600080fd5b506103106106373660046138fc565b611d10565b34801561064857600080fd5b5061065c610657366004613b2f565b611db2565b6040516102ae9190613bb3565b34801561067557600080fd5b506102a2610684366004613915565b611deb565b34801561069557600080fd5b506103106106a4366004613bc6565b611e16565b3480156106b557600080fd5b506103106106c43660046137e0565b612158565b3480156106d557600080fd5b506103906101635481565b3480156106ec57600080fd5b50610390600081565b34801561070157600080fd5b506103106107103660046137e0565b6121cc565b34801561072157600080fd5b506103106107303660046138fc565b61229c565b34801561074157600080fd5b506103106107503660046138fc565b61230e565b34801561076157600080fd5b506103106107703660046137e0565b612380565b34801561078157600080fd5b506107cd610790366004613945565b61016760209081526000928352604080842090915290825290208054600182015460028301546003909301546001600160a01b0390921692909184565b604080516001600160a01b03909516855260208501939093529183015260608201526080016102ae565b34801561080357600080fd5b50610310610812366004613bc6565b6123f4565b34801561082357600080fd5b50610310610832366004613915565b61280c565b34801561084357600080fd5b506103106108523660046137e0565b612831565b34801561086357600080fd5b50610166546102d8906001600160a01b031681565b34801561088457600080fd5b5061039060008051602061406083398151915281565b3480156108a657600080fd5b506103906101645481565b3480156108bd57600080fd5b50610160546102d8906001600160a01b031681565b3480156108de57600080fd5b5061065c6108ed366004613b2f565b6128a5565b3480156108fe57600080fd5b5061039060008051602061402083398151915281565b60006001600160e01b03198216637965db0b60e01b148061094557506301ffc9a760e01b6001600160e01b03198316145b92915050565b6000610956816128d7565b61095e6128e1565b8382146109bc5760405162461bcd60e51b815260206004820152602160248201527f506c756767696e673a204172726179206c656e677468206d6973732d6d6174636044820152600d60fb1b60648201526084015b60405180910390fd5b60005b84811015610b1a576109f68686838181106109dc576109dc613c80565b90506020020160208101906109f191906137e0565b612929565b838382818110610a0857610a08613c80565b9050602002016020810190610a1d9190613c96565b61016c6000888885818110610a3457610a34613c80565b9050602002016020810190610a4991906137e0565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055858582818110610a8357610a83613c80565b9050602002016020810190610a9891906137e0565b6001600160a01b03167f5eebc2c7781bdf97cd290973f8ca664cfda1f3493d108af97c1b2a6b61fb5236858584818110610ad457610ad4613c80565b9050602002016020810190610ae99190613c96565b604080519115158252426020830152339082015260600160405180910390a280610b1281613cce565b9150506109bf565b505050505050565b600054610100900460ff1615808015610b425750600054600160ff909116105b80610b5c5750303b158015610b5c575060005460ff166001145b610bbf5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016109b3565b6000805460ff191660011790558015610be2576000805461ff0019166101001790555b610bea6129c5565b610bf26129f4565b610bfa612a1b565b610c026129f4565b610c0b86612a4a565b610c1485612a4a565b610c1d84612a4a565b610c2682612a4a565b61015f80546001600160a01b038089166001600160a01b03199283161790925561016080548884169083161790556101618054878416908316179055604b61016555610166805492851692909116919091179055610c85600084612a9c565b610c9d60008051602061406083398151915284612a9c565b610cb560008051602061402083398151915284612a9c565b8015610b1a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050505050565b61015f546001600160a01b03908116600090815261016a6020908152604080832093851683529290529081206060918291610d3c90612b22565b610160546001600160a01b03908116600090815261016a60209081526040808320938916835292905290812091925090610d7590612b22565b9050600082516001600160401b03811115610d9257610d926139a5565b604051908082528060200260200182016040528015610dcb57816020015b610db861361f565b815260200190600190039081610db05790505b509050600082516001600160401b03811115610de957610de96139a5565b604051908082528060200260200182016040528015610e2257816020015b610e0f61361f565b815260200190600190039081610e075790505b50905060005b8451811015610f805761015f546001600160a01b03166000908152610169602052604081208651909190879084908110610e6457610e64613c80565b602002602001015181526020019081526020016000206040518060600160405290816000820160009054906101000a90046001600160a01b03166001600160a01b03166001600160a01b03168152602001600182018054610ec490613ce7565b80601f0160208091040260200160405190810160405280929190818152602001828054610ef090613ce7565b8015610f3d5780601f10610f1257610100808354040283529160200191610f3d565b820191906000526020600020905b815481529060010190602001808311610f2057829003601f168201915b50505050508152602001600282015481525050838281518110610f6257610f62613c80565b60200260200101819052508080610f7890613cce565b915050610e28565b5060005b83518110156110dc57610160546001600160a01b03166000908152610169602052604081208551909190869084908110610fc057610fc0613c80565b602002602001015181526020019081526020016000206040518060600160405290816000820160009054906101000a90046001600160a01b03166001600160a01b03166001600160a01b0316815260200160018201805461102090613ce7565b80601f016020809104026020016040519081016040528092919081815260200182805461104c90613ce7565b80156110995780601f1061106e57610100808354040283529160200191611099565b820191906000526020600020905b81548152906001019060200180831161107c57829003601f168201915b505050505081526020016002820154815250508282815181106110be576110be613c80565b602002602001018190525080806110d490613cce565b915050610f84565b5090969095509350505050565b600082815260976020526040902060010154611104816128d7565b61110e8383612a9c565b505050565b6001600160a01b03811633146111835760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016109b3565b61118d8282612b2f565b5050565b6001600160a01b037f0000000000000000000000007dcaa8aebca8d38cdae3882786a54553b1b709a31630036111d95760405162461bcd60e51b81526004016109b390613d21565b7f0000000000000000000000007dcaa8aebca8d38cdae3882786a54553b1b709a36001600160a01b031661120b612b96565b6001600160a01b0316146112315760405162461bcd60e51b81526004016109b390613d6d565b61123a81612bb2565b6040805160008082526020820190925261125691839190612bca565b50565b600080516020614060833981519152611271816128d7565b611256612d35565b610169602090815260009283526040808420909152908252902080546001820180546001600160a01b0390921692916112b190613ce7565b80601f01602080910402602001604051908101604052809291908181526020018280546112dd90613ce7565b801561132a5780601f106112ff5761010080835404028352916020019161132a565b820191906000526020600020905b81548152906001019060200180831161130d57829003601f168201915b5050505050908060020154905083565b6001600160a01b037f0000000000000000000000007dcaa8aebca8d38cdae3882786a54553b1b709a31630036113825760405162461bcd60e51b81526004016109b390613d21565b7f0000000000000000000000007dcaa8aebca8d38cdae3882786a54553b1b709a36001600160a01b03166113b4612b96565b6001600160a01b0316146113da5760405162461bcd60e51b81526004016109b390613d6d565b6113e382612bb2565b61118d82826001612bca565b6000306001600160a01b037f0000000000000000000000007dcaa8aebca8d38cdae3882786a54553b1b709a3161461148a5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b60648201526084016109b3565b5060008051602061404083398151915290565b60006114a8816128d7565b6114b06128e1565b600082116114d05760405162461bcd60e51b81526004016109b390613db9565b6101638054908390556040517fde52fa83109493c55c085b54becbf0aac762479e5f436e38d15b66d1fdd387739061150f908390869042903390613df0565b60405180910390a1505050565b61015f546001600160a01b039081166000908152610168602090815260408083209385168352929052908120606091829182919061155990612b22565b610160546001600160a01b03908116600090815261016860209081526040808320938a1683529290529081209192509061159290612b22565b610161546001600160a01b03908116600090815261016860209081526040808320938b168352929052908120919250906115cb90612b22565b9050600083516001600160401b038111156115e8576115e86139a5565b60405190808252806020026020018201604052801561162157816020015b61160e613649565b8152602001906001900390816116065790505b509050600083516001600160401b0381111561163f5761163f6139a5565b60405190808252806020026020018201604052801561167857816020015b611665613649565b81526020019060019003908161165d5790505b509050600083516001600160401b03811115611696576116966139a5565b6040519080825280602002602001820160405280156116cf57816020015b6116bc613649565b8152602001906001900390816116b45790505b50905060005b86518110156117965761015f546001600160a01b0316600090815261016760205260408120885190919089908490811061171157611711613c80565b6020908102919091018101518252818101929092526040908101600020815160808101835281546001600160a01b03168152600182015493810193909352600281015491830191909152600301546060820152845185908390811061177857611778613c80565b6020026020010181905250808061178e90613cce565b9150506116d5565b5060005b855181101561185b57610160546001600160a01b031660009081526101676020526040812087519091908890849081106117d6576117d6613c80565b6020908102919091018101518252818101929092526040908101600020815160808101835281546001600160a01b03168152600182015493810193909352600281015491830191909152600301546060820152835184908390811061183d5761183d613c80565b6020026020010181905250808061185390613cce565b91505061179a565b5060005b845181101561192057610161546001600160a01b0316600090815261016760205260408120865190919087908490811061189b5761189b613c80565b6020908102919091018101518252818101929092526040908101600020815160808101835281546001600160a01b03168152600182015493810193909352600281015491830191909152600301546060820152825183908390811061190257611902613c80565b6020026020010181905250808061191890613cce565b91505061185f565b509199909850909650945050505050565b600061193c816128d7565b6119446128e1565b61194d82612a4a565b61016680546001600160a01b038481166001600160a01b0319831681179093556040519116919082907f111d7d9ba75ec299e3ad78ca28dd6647b17b87fc2292dad7a0a2e4ac2e3cb15c906119a59042903390613e14565b60405180910390a3505050565b6000805160206140608339815191526119ca816128d7565b611256612d87565b6001600160a01b03808316600090815261016860209081526040808320938516835292905290812060609190611a0790612b22565b9050600081516001600160401b03811115611a2457611a246139a5565b604051908082528060200260200182016040528015611a5d57816020015b611a4a613649565b815260200190600190039081611a425790505b50905060005b8251811015611b21576001600160a01b0386166000908152610167602052604081208451909190859084908110611a9c57611a9c613c80565b6020908102919091018101518252818101929092526040908101600020815160808101835281546001600160a01b031681526001820154938101939093526002810154918301919091526003015460608201528251839083908110611b0357611b03613c80565b60200260200101819052508080611b1990613cce565b915050611a63565b50949350505050565b6001600160a01b03808316600090815261016a60209081526040808320938516835292905290812060609190611b5f90612b22565b9050600081516001600160401b03811115611b7c57611b7c6139a5565b604051908082528060200260200182016040528015611bb557816020015b611ba261361f565b815260200190600190039081611b9a5790505b50905060005b8251811015611b21576001600160a01b0386166000908152610169602052604081208451909190859084908110611bf457611bf4613c80565b602002602001015181526020019081526020016000206040518060600160405290816000820160009054906101000a90046001600160a01b03166001600160a01b03166001600160a01b03168152602001600182018054611c5490613ce7565b80601f0160208091040260200160405190810160405280929190818152602001828054611c8090613ce7565b8015611ccd5780601f10611ca257610100808354040283529160200191611ccd565b820191906000526020600020905b815481529060010190602001808311611cb057829003601f168201915b50505050508152602001600282015481525050828281518110611cf257611cf2613c80565b60200260200101819052508080611d0890613cce565b915050611bbb565b6000611d1b816128d7565b611d236128e1565b60008211611d735760405162461bcd60e51b815260206004820152601e60248201527f506c756767696e673a20496e76616c6964206172726179206c656e677468000060448201526064016109b3565b6101658054908390556040517f1ec459126636bfe98c20f9b92a13924caedbae653da45c756e3bade3ed2c12599061150f908390869042903390613df0565b6001600160a01b03808316600090815261016860209081526040808320938516835292905220606090611de490612b22565b9392505050565b60009182526097602090815260408084206001600160a01b0393909316845291905290205460ff1690565b611e1e612dc4565b611e266128e1565b611e2f82612929565b611e3881612e1d565b611e4182612e88565b60005b8151811015612101576001600160a01b0383166000908152610167602052604081208351339290859085908110611e7d57611e7d613c80565b6020908102919091018101518252810191909152604001600020546001600160a01b031614611eee5760405162461bcd60e51b815260206004820181905260248201527f506c756767696e673a20596f7520646f6e2774206f776e20616c6c20706c756760448201526064016109b3565b6001600160a01b0383166000908152610167602052604081208351909190849084908110611f1e57611f1e613c80565b6020026020010151815260200190815260200160002060030154421015611fa35760405162461bcd60e51b815260206004820152603360248201527f506c756767696e673a2043616e277420756e706c7567206265666f72652074686044820152726520706c7567676564556e74696c2074696d6560681b60648201526084016109b3565b6001600160a01b0383166000908152610167602052604081208351909190849084908110611fd357611fd3613c80565b6020908102919091018101518252810191909152604001600090812080546001600160a01b0319168155600181018290556002810182905560030155815161205c9083908390811061202757612027613c80565b6020908102919091018101516001600160a01b0386166000908152610168835260408082203383529093529190912090612f0b565b50826001600160a01b03166323b872dd61016660009054906101000a90046001600160a01b03163385858151811061209657612096613c80565b60200260200101516040518463ffffffff1660e01b81526004016120bc93929190613e2b565b600060405180830381600087803b1580156120d657600080fd5b505af11580156120ea573d6000803e3d6000fd5b5050505080806120f990613cce565b915050611e44565b50816001600160a01b0316336001600160a01b03167fc0f5a2a48d41af8ec29bf97ba6dac4335a15389d01989b0fc57c3158516cae6e8342604051612147929190613e4f565b60405180910390a361118d60018055565b6000612163816128d7565b61216b6128e1565b61217482612f1d565b61015f80546001600160a01b038481166001600160a01b0319831681179093556040519116919082907ff495a93845b6fdfbea2aaf56581914a5230c393b90ca893c62e320fd8cca41df906119a59042903390613e14565b60006121d7816128d7565b6121e082612a4a565b336121ec600082612b2f565b61220460008051602061406083398151915233612b2f565b61221c60008051602061402083398151915233612b2f565b612227600084612a9c565b61223f60008051602061406083398151915284612a9c565b61225760008051602061402083398151915284612a9c565b826001600160a01b0316816001600160a01b03167f1fb25c9e60d7a2ccc6262983e9e56cec2491bb6aad543e1e25459c789b313ced42336040516119a5929190613e14565b60006122a7816128d7565b6122af6128e1565b600082116122cf5760405162461bcd60e51b81526004016109b390613db9565b6101628054908390556040517f371d83057fbe64ef78f5b5e6b33dc2834b4ded888e4364e6fe99ad2679c791259061150f908390869042903390613df0565b6000612319816128d7565b6123216128e1565b600082116123415760405162461bcd60e51b81526004016109b390613db9565b6101648054908390556040517fd882d6ec557d912997df6094f8c7ea5fc7aa7f919161033eb3ae028e680506319061150f908390869042903390613df0565b600061238b816128d7565b6123936128e1565b61239c82612f1d565b61016180546001600160a01b038481166001600160a01b0319831681179093556040519116919082907fa7fba29371f41c1844426fabd1e548061569003bb4e61baf861dd1d3d9661ae0906119a59042903390613e14565b6123fc612dc4565b6124046128e1565b61240d82612929565b61241681612e1d565b60008290506000806101625442101561247d5760405162461bcd60e51b8152602060048201526024808201527f506c756767696e673a20536561736f6e20686173206e6f742073746172746564604482015263081e595d60e21b60648201526084016109b3565b610163544211156124d05760405162461bcd60e51b815260206004820152601a60248201527f506c756767696e673a20536561736f6e2068617320656e64656400000000000060448201526064016109b3565b6101645442116124e45750610162546124e7565b50425b61016354915060005b84518110156127b057336001600160a01b0316846001600160a01b0316636352211e87848151811061252457612524613c80565b60200260200101516040518263ffffffff1660e01b815260040161254a91815260200190565b602060405180830381865afa158015612567573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061258b9190613e71565b6001600160a01b0316146125eb5760405162461bcd60e51b815260206004820152602160248201527f506c756767696e673a20596f7520646f6e2774206f776e20616c6c20746f6b656044820152603760f91b60648201526084016109b3565b6040518060800160405280336001600160a01b0316815260200186838151811061261757612617613c80565b60200260200101518152602001838152602001848152506101676000886001600160a01b03166001600160a01b03168152602001908152602001600020600087848151811061266857612668613c80565b6020908102919091018101518252818101929092526040908101600020835181546001600160a01b0319166001600160a01b039091161781559183015160018301558201516002820155606090910151600390910155845161270b908690839081106126d6576126d6613c80565b6020908102919091018101516001600160a01b0389166000908152610168835260408082203383529093529190912090612f82565b50836001600160a01b03166323b872dd3361016660009054906101000a90046001600160a01b031688858151811061274557612745613c80565b60200260200101516040518463ffffffff1660e01b815260040161276b93929190613e2b565b600060405180830381600087803b15801561278557600080fd5b505af1158015612799573d6000803e3d6000fd5b5050505080806127a890613cce565b9150506124f0565b50846001600160a01b0316336001600160a01b03167fc8ba7816ccd1af249a8182d28ac11f15d5c4825982acfae63e67dafd2475a9fe8684866040516127f893929190613e8e565b60405180910390a350505061118d60018055565b600082815260976020526040902060010154612827816128d7565b61110e8383612b2f565b600061283c816128d7565b6128446128e1565b61284d82612f1d565b61016080546001600160a01b038481166001600160a01b0319831681179093556040519116919082907f274d37081e988ceba5e2e4076ede8ca88774faf820679d40774b39081e3fd292906119a59042903390613e14565b6001600160a01b03808316600090815261016a60209081526040808320938516835292905220606090611de490612b22565b6112568133612f8e565b60c95460ff16156129275760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016109b3565b565b610161546001600160a01b03828116911614806129545750610160546001600160a01b038281169116145b8061296d575061015f546001600160a01b038281169116145b6112565760405162461bcd60e51b8152602060048201526024808201527f506c756767696e673a20496e76616c696420636f6c6c656374696f6e206164646044820152637265737360e01b60648201526084016109b3565b600054610100900460ff166129ec5760405162461bcd60e51b81526004016109b390613eb3565b612927612fe7565b600054610100900460ff166129275760405162461bcd60e51b81526004016109b390613eb3565b600054610100900460ff16612a425760405162461bcd60e51b81526004016109b390613eb3565b61292761300e565b6001600160a01b0381166112565760405162461bcd60e51b8152602060048201526019602482015278506c756767696e673a20496e76616c6964206164647265737360381b60448201526064016109b3565b612aa68282611deb565b61118d5760008281526097602090815260408083206001600160a01b03851684529091529020805460ff19166001179055612ade3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60606000611de483613041565b612b398282611deb565b1561118d5760008281526097602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080516020614040833981519152546001600160a01b031690565b60008051602061402083398151915261118d816128d7565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615612bfd5761110e8361309d565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612c57575060408051601f3d908101601f19168201909252612c5491810190613efe565b60015b612cba5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b60648201526084016109b3565b6000805160206140408339815191528114612d295760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b60648201526084016109b3565b5061110e838383613139565b612d3d613164565b60c9805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b612d8f6128e1565b60c9805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612d6a3390565b600260015403612e165760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016109b3565b6002600155565b61016554815111156112565760405162461bcd60e51b815260206004820152602e60248201527f506c756767696e673a20546f6b656e496473206172726179203c3d206d61782060448201526d0c2d8d8deeecac840d8cadccee8d60931b60648201526084016109b3565b6001600160a01b038116600090815261016c602052604090205460ff166112565760405162461bcd60e51b815260206004820152603160248201527f506c756767696e673a2043616e6e6f7420756e706c7567204e4654732066726f60448201527036903a3434b99031b7b63632b1ba34b7b760791b60648201526084016109b3565b6000611de483836131ad565b60018055565b6000816001600160a01b03163b116112565760405162461bcd60e51b815260206004820152602260248201527f506c756767696e673a20496e76616c696420636f6e7472616374206164647265604482015261737360f01b60648201526084016109b3565b6000611de483836132a0565b612f988282611deb565b61118d57612fa5816132ef565b612fb0836020613301565b604051602001612fc1929190613f17565b60408051601f198184030181529082905262461bcd60e51b82526109b391600401613f86565b600054610100900460ff16612f175760405162461bcd60e51b81526004016109b390613eb3565b600054610100900460ff166130355760405162461bcd60e51b81526004016109b390613eb3565b60c9805460ff19169055565b60608160000180548060200260200160405190810160405280929190818152602001828054801561309157602002820191906000526020600020905b81548152602001906001019080831161307d575b50505050509050919050565b6001600160a01b0381163b61310a5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016109b3565b60008051602061404083398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6131428361349c565b60008251118061314f5750805b1561110e5761315e83836134dc565b50505050565b60c95460ff166129275760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016109b3565b600081815260018301602052604081205480156132965760006131d1600183613f99565b85549091506000906131e590600190613f99565b905081811461324a57600086600001828154811061320557613205613c80565b906000526020600020015490508087600001848154811061322857613228613c80565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061325b5761325b613fac565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610945565b6000915050610945565b60008181526001830160205260408120546132e757508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610945565b506000610945565b60606109456001600160a01b03831660145b60606000613310836002613fc2565b61331b906002613fd9565b6001600160401b03811115613332576133326139a5565b6040519080825280601f01601f19166020018201604052801561335c576020820181803683370190505b509050600360fc1b8160008151811061337757613377613c80565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106133a6576133a6613c80565b60200101906001600160f81b031916908160001a90535060006133ca846002613fc2565b6133d5906001613fd9565b90505b600181111561344d576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061340957613409613c80565b1a60f81b82828151811061341f5761341f613c80565b60200101906001600160f81b031916908160001a90535060049490941c9361344681613fec565b90506133d8565b508315611de45760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109b3565b6134a58161309d565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060611de48383604051806060016040528060278152602001614080602791396060600080856001600160a01b0316856040516135199190614003565b600060405180830381855af49150503d8060008114613554576040519150601f19603f3d011682016040523d82523d6000602084013e613559565b606091505b509150915061356a86838387613574565b9695505050505050565b606083156135e35782516000036135dc576001600160a01b0385163b6135dc5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109b3565b50816135ed565b6135ed83836135f5565b949350505050565b8151156136055781518083602001fd5b8060405162461bcd60e51b81526004016109b39190613f86565b604051806060016040528060006001600160a01b0316815260200160608152602001600081525090565b604051806080016040528060006001600160a01b031681526020016000815260200160008152602001600081525090565b60006020828403121561368c57600080fd5b81356001600160e01b031981168114611de457600080fd5b60008083601f8401126136b657600080fd5b5081356001600160401b038111156136cd57600080fd5b6020830191508360208260051b85010111156136e857600080fd5b9250929050565b6000806000806040858703121561370557600080fd5b84356001600160401b038082111561371c57600080fd5b613728888389016136a4565b9096509450602087013591508082111561374157600080fd5b5061374e878288016136a4565b95989497509550505050565b6001600160a01b038116811461125657600080fd5b600080600080600060a0868803121561378757600080fd5b85356137928161375a565b945060208601356137a28161375a565b935060408601356137b28161375a565b925060608601356137c28161375a565b915060808601356137d28161375a565b809150509295509295909350565b6000602082840312156137f257600080fd5b8135611de48161375a565b60005b83811015613818578181015183820152602001613800565b50506000910152565b600081518084526138398160208601602086016137fd565b601f01601f19169290920160200192915050565b600081518084526020808501808196508360051b8101915082860160005b858110156138c1578284038952815180516001600160a01b03168552858101516060878701819052906138a082880182613821565b6040938401519790930196909652509885019893509084019060010161386b565b5091979650505050505050565b6040815260006138e1604083018561384d565b82810360208401526138f3818561384d565b95945050505050565b60006020828403121561390e57600080fd5b5035919050565b6000806040838503121561392857600080fd5b82359150602083013561393a8161375a565b809150509250929050565b6000806040838503121561395857600080fd5b82356139638161375a565b946020939093013593505050565b6001600160a01b038416815260606020820181905260009061399590830185613821565b9050826040830152949350505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156139e3576139e36139a5565b604052919050565b600080604083850312156139fe57600080fd5b8235613a098161375a565b91506020838101356001600160401b0380821115613a2657600080fd5b818601915086601f830112613a3a57600080fd5b813581811115613a4c57613a4c6139a5565b613a5e601f8201601f191685016139bb565b91508082528784828501011115613a7457600080fd5b80848401858401376000848284010152508093505050509250929050565b600081518084526020808501945080840160005b83811015613aeb57815180516001600160a01b031688528381015184890152604080820151908901526060908101519088015260809096019590820190600101613aa6565b509495945050505050565b606081526000613b096060830186613a92565b8281036020840152613b1b8186613a92565b9050828103604084015261356a8185613a92565b60008060408385031215613b4257600080fd5b8235613b4d8161375a565b9150602083013561393a8161375a565b602081526000611de46020830184613a92565b602081526000611de4602083018461384d565b600081518084526020808501945080840160005b83811015613aeb57815187529582019590820190600101613b97565b602081526000611de46020830184613b83565b60008060408385031215613bd957600080fd5b8235613be48161375a565b91506020838101356001600160401b0380821115613c0157600080fd5b818601915086601f830112613c1557600080fd5b813581811115613c2757613c276139a5565b8060051b9150613c388483016139bb565b8181529183018401918481019089841115613c5257600080fd5b938501935b83851015613c7057843582529385019390850190613c57565b8096505050505050509250929050565b634e487b7160e01b600052603260045260246000fd5b600060208284031215613ca857600080fd5b81358015158114611de457600080fd5b634e487b7160e01b600052601160045260246000fd5b600060018201613ce057613ce0613cb8565b5060010190565b600181811c90821680613cfb57607f821691505b602082108103613d1b57634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b6020808252601b908201527f506c756767696e673a20496e76616c69642074696d657374616d700000000000604082015260600190565b938452602084019290925260408301526001600160a01b0316606082015260800190565b9182526001600160a01b0316602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b604081526000613e626040830185613b83565b90508260208301529392505050565b600060208284031215613e8357600080fd5b8151611de48161375a565b606081526000613ea16060830186613b83565b60208301949094525060400152919050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600060208284031215613f1057600080fd5b5051919050565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351613f498160178501602088016137fd565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613f7a8160288401602088016137fd565b01602801949350505050565b602081526000611de46020830184613821565b8181038181111561094557610945613cb8565b634e487b7160e01b600052603160045260246000fd5b808202811582820484141761094557610945613cb8565b8082018082111561094557610945613cb8565b600081613ffb57613ffb613cb8565b506000190190565b600082516140158184602087016137fd565b919091019291505056fe189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e3360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212208f7570aa5778bf7b054d086915c5a4737a35c8f24042223dc1e2b31c8bacf85564736f6c63430008140033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.