Source Code
Overview
APE Balance
More Info
ContractCreator
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
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 Source Code Verified (Exact Match)
Contract Name:
TheMine
Compiler Version
v0.8.28+commit.7893614a
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/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/utils/Base64.sol"; import {OreMine, GoldOreChunkData} from "./OreMine.sol"; import {PickaxeMerchant, PickaxeTypeMetadata} from "./PickaxeMerchant.sol"; import {IPickaxes} from "./Pickaxes.sol"; import {IOreChunks} from "./OreChunks.sol"; interface ITheMine { function getPickaxeMetadata( uint256 pickaxeId ) external view returns (string memory); } interface IDelegateRegistry { function checkDelegateForAll( address to, address from, bytes32 rights ) external view returns (bool); } contract TheMine is UUPSUpgradeable, OwnableUpgradeable, ReentrancyGuardUpgradeable, PausableUpgradeable, IERC721ReceiverUpgradeable, PickaxeMerchant, OreMine { using Strings for string; address internal constant DEAD_ADDRESS = 0x000000000000000000000000000000000000dEaD; /// @custom:oz-upgrades-unsafe-allow state-variable-immutable address internal immutable PICKAXES_CONTRACT; /// @custom:oz-upgrades-unsafe-allow state-variable-immutable address internal immutable ORE_CHUNKS_CONTRACT; /// @custom:oz-upgrades-unsafe-allow state-variable-immutable address internal immutable DELEGATE_REGISTRY; uint256 public PICKAXE_RENTAL_PRICE; address internal management; uint256 public goldCap; bool internal pickaxeMerchantEnabled; bool internal oreMerchantEnabled; // NFT contracts that can mine mapping(address => bool) internal minerNFTContracts; // Pickaxe state mapping(uint256 => uint256) public pickaxeTotalOresMined; mapping(uint256 => uint256) public pickaxeTotalGoldMined; // Rented pickaxes mapping(address => uint256) public rentedPickaxes; mapping(uint256 => bool) public rentedPickaxeUsed; uint256 internal nextRentedPickaxeId; mapping(uint256 => uint256) internal chunkSoldPrice; uint256 public pickaxeRentalCount; // Events event OrePurchased( uint256 indexed oreId, address indexed buyer, uint256 price ); event OreSold(uint256 indexed oreId, address indexed seller, uint256 price); event MinerPaymentFailed(address indexed miner, uint256 amount); /// @custom:oz-upgrades-unsafe-allow constructor constructor( address _pickaxesContract, address _oreChunksContract, address _delegateRegistry ) { _disableInitializers(); require(_pickaxesContract != address(0), "Invalid pickaxes contract"); require( _oreChunksContract != address(0), "Invalid ore chunks contract" ); PICKAXES_CONTRACT = _pickaxesContract; ORE_CHUNKS_CONTRACT = _oreChunksContract; DELEGATE_REGISTRY = _delegateRegistry; } function initialize(address _signer) public initializer { __Ownable_init(); __ReentrancyGuard_init(); __Pausable_init(); __PickaxeMerchant_init(_signer); __OreMine_init(); management = msg.sender; nextRentedPickaxeId = 10000; } receive() external payable { goldCap += msg.value; } function addMinerNFTContract(address nftContract) external onlyOwner { require(nftContract != address(0), "Invalid NFT contract"); require( IERC721(nftContract).supportsInterface(type(IERC721).interfaceId), "NFT contract does not support IERC721" ); minerNFTContracts[nftContract] = true; } function removeMinerNFTContract(address nftContract) external onlyOwner { require( minerNFTContracts[nftContract], "NFT contract is not a valid miner NFT contract" ); minerNFTContracts[nftContract] = false; } function setManagement(address newManagement) external onlyOwner { require(newManagement != address(0), "Invalid management address"); management = newManagement; } function buyPickaxes( address receiver, uint256 pickaxeType_, uint256 quantity, uint256 allowance, bytes calldata signature, bool ) external payable nonReentrant whenNotPaused { require(pickaxeMerchantEnabled, "Pickaxe merchant is not enabled"); if (receiver != msg.sender) { require( IDelegateRegistry(DELEGATE_REGISTRY).checkDelegateForAll( msg.sender, receiver, "" ), "Sender is not delegated to mint on behalf of receiver" ); } uint256 actualPrice = _mintPickaxes( receiver, pickaxeType_, quantity, allowance, signature ); // Calculate management share based on actual price uint256 managementAmount = actualPrice / 2; // assign 50% of actual price to goldCap goldCap += actualPrice - managementAmount; // Transfer management amount (bool mTransferSuccess, ) = management.call{value: managementAmount}( "" ); require(mTransferSuccess, "Management payment failed"); // Refund excess payment if (msg.value > actualPrice) { (bool refundSuccess, ) = payable(msg.sender).call{ value: msg.value - actualPrice }(""); require(refundSuccess, "Refund failed"); } } /** * @notice Rent a pickaxe for 1 ether * @return pickaxeId The id of the rented pickaxe * @dev If the user already has a rented pickaxe, it will be used again * @dev If the user doesn't have a rented pickaxe, a new one will be created */ function rentPickaxe() external payable whenNotPaused returns (uint256) { require(PICKAXE_RENTAL_PRICE > 0, "Pickaxe rental not enabled"); require(msg.value == PICKAXE_RENTAL_PRICE, "Invalid payment"); uint256 pickaxeId = rentedPickaxes[msg.sender]; if (pickaxeId == 0) { nextRentedPickaxeId++; pickaxeId = nextRentedPickaxeId; rentedPickaxes[msg.sender] = pickaxeId; } else { require( rentedPickaxeUsed[pickaxeId], "Already rented pickaxe not used" ); rentedPickaxeUsed[pickaxeId] = false; } goldCap += PICKAXE_RENTAL_PRICE; pickaxeRentalCount++; return pickaxeId; } function setPickaxeRentalPrice(uint256 newPrice) external onlyOwner { PICKAXE_RENTAL_PRICE = newPrice; } function setPickaxeMerchantEnabled(bool enabled) external onlyOwner { pickaxeMerchantEnabled = enabled; } function setOreMerchantEnabled(bool enabled) external onlyOwner { oreMerchantEnabled = enabled; } function mineGoldOre( address nftContract, uint256 nftId, uint256 pickaxeId, uint256 goldRatio, uint256 attempts ) external nonReentrant whenNotPaused { require(miningEnabled, "Mining is not enabled"); require( minerNFTContracts[nftContract], "NFT contract is not a valid miner NFT contract" ); bool isRented = pickaxeId > 10000; if (isRented) { require(rentedPickaxes[msg.sender] == pickaxeId, "Invalid pickaxe"); require(!rentedPickaxeUsed[pickaxeId], "Pickaxe already used"); rentedPickaxeUsed[pickaxeId] = true; } uint256 goldQuantity = _mineGoldOre( nftContract, nftId, pickaxeId, goldRatio, attempts, isRented ); pickaxeTotalOresMined[pickaxeId] += 1; pickaxeTotalGoldMined[pickaxeId] += goldQuantity; if (!isRented) { IPickaxes(pickaxesContract()).emitMetadataUpdate(pickaxeId); } } function buyOres( uint256[] calldata oreIds ) external payable nonReentrant whenNotPaused { require(oreMerchantEnabled, "Ore merchant is not enabled"); uint256 totalChunkValue = 0; uint256 totalChunkValueIncrease = 0; uint256[] memory mineOwnedOres = new uint256[](oreIds.length); uint256[] memory mineOwnedOresRoyalties = new uint256[](oreIds.length); address[] memory mineOwnedOresMiner = new address[](oreIds.length); uint256 mineOwnedOresCount = 0; for (uint256 i = 0; i < oreIds.length; i++) { address oreOwner = IERC721(oreChunksContract()).ownerOf(oreIds[i]); if (oreOwner == address(this)) { mineOwnedOres[mineOwnedOresCount] = oreIds[i]; // Get owner of the pick that mined the ore GoldOreChunkData memory chunk = getOreChunk(oreIds[i]); mineOwnedOresMiner[mineOwnedOresCount] = IERC721( pickaxesContract() ).ownerOf(chunk.pickaxeId); // Calculate chunk royalty uint256 _chunkValue = chunkValue(oreIds[i]); mineOwnedOresRoyalties[mineOwnedOresCount] = (_chunkValue * 5) / 100; // Update total chunks value required for purchase totalChunkValue += _chunkValue; // Calculate chunk value increase since sold to the mine totalChunkValueIncrease += _chunkValue - chunkSoldPrice[oreIds[i]]; mineOwnedOresCount++; emit OrePurchased(oreIds[i], msg.sender, _chunkValue); } } if (mineOwnedOresCount == 0) { revert("No ore chunks to buy"); } uint256 _chunkBuyPremium = (totalChunkValue * 20) / 100; uint256 price = totalChunkValue + _chunkBuyPremium; require(msg.value >= price, "Insufficient payment"); // Distribute revenue uint256 royaltyOrFee = (totalChunkValue * 5) / 100; // 5% to revenue share (bool success2, ) = management.call{value: royaltyOrFee}(""); require(success2, "Revenue share payment failed"); uint256 unpaidRoyalties = 0; for (uint256 i = 0; i < mineOwnedOresCount; i++) { uint256 _royalty = mineOwnedOresRoyalties[i]; bool royaltyPaid = _payMiner(mineOwnedOresMiner[i], _royalty); if (!royaltyPaid) { unpaidRoyalties += _royalty; } IERC721(oreChunksContract()).safeTransferFrom( address(this), msg.sender, mineOwnedOres[i] ); } // Gold Cap already accounts for the value of the ore chunks when previously sold to the mine, so only add the premium and the increase in value goldCap += _chunkBuyPremium + totalChunkValueIncrease - (2 * royaltyOrFee - unpaidRoyalties); // Refund excess payment if (msg.value > price) { (bool refundSuccess, ) = msg.sender.call{value: msg.value - price}( "" ); require(refundSuccess, "Refund failed"); } } /** * @notice Sell an ore chunk to the mine * @param oreId The id of the ore chunk to sell * @dev The ore chunk must be owned by the mine * @dev The mine will pay the original miner 5% of the price * @dev The mine will pay the seller the remaining 95% of the price */ function sellOre(uint256 oreId) external nonReentrant whenNotPaused { require(oreMerchantEnabled, "Ore merchant is not enabled"); address oreOwner = IERC721(oreChunksContract()).ownerOf(oreId); require(oreOwner == msg.sender, "Not ore owner"); uint256 _chunkValue = chunkValue(oreId); chunkSoldPrice[oreId] = _chunkValue; // Transfer ore to mine IOreChunks(oreChunksContract()).transferToMine(oreOwner, oreId); // Get miner address GoldOreChunkData memory chunk = getOreChunk(oreId); uint256 pickaxeId = chunk.pickaxeId; address miner = address(this); if (pickaxeId < 10000) { miner = IERC721(pickaxesContract()).ownerOf(pickaxeId); } uint256 minerShare; // Miner share 0 assuming the miner is the oreOwner // If miner is not the seller, we pay them 5% of the chunk value if (miner != oreOwner) { minerShare = (_chunkValue * 5) / 100; bool royaltyPaid = _payMiner(miner, minerShare); if (!royaltyPaid) { goldCap += minerShare; } } // Pay seller (bool success, ) = msg.sender.call{value: _chunkValue - minerShare}(""); require(success, "Payment failed"); emit OreSold(oreId, oreOwner, _chunkValue); } function _payMiner( address _miner, uint256 _royalty ) internal returns (bool) { if ( _miner == address(this) || _miner == DEAD_ADDRESS || _miner == address(0) ) { return false; } (bool success, ) = _miner.call{value: _royalty}(""); if (!success) { emit MinerPaymentFailed(_miner, _royalty); } return success; } function getPickaxeMetadata( uint256 pickaxeId ) external view returns (string memory) { string memory metadata = ""; PickaxeTypeMetadata memory pickaxeTypeMetadata = _pickaxeTypeMetadata[ pickaxeType(pickaxeId) ]; metadata = string.concat( metadata, '{"name": "Pick #', Strings.toString(pickaxeId), '", "description": "', pickaxeTypeMetadata.description, '", "image": "', pickaxeTypeMetadata.image, '", "attributes": [', '{"trait_type": "Total Ores Mined", "value": ', Strings.toString(pickaxeTotalOresMined[pickaxeId]), "}, ", '{"trait_type": "Total Gold Mined", "value": ', Strings.toString(pickaxeTotalGoldMined[pickaxeId]), '}, {"trait_type": "Type", "value": "', pickaxeTypeMetadata.name, '"}]}' ); return string( abi.encodePacked( "data:application/json;base64,", Base64.encode(bytes(metadata)) ) ); } function getOreChunkMetadata( uint256 oreId ) external view returns (string memory) { string memory metadata = ""; GoldOreChunkData memory chunk = goldOreChunks[oreId]; metadata = string.concat( metadata, '{"name": "Gold Ore Chunk #', Strings.toString(oreId), '", "description": "A chunk of gold ore containing ', Strings.toString(chunk.goldQuantity), ' gold specks.", ', '"mined_by": "', Strings.toHexString(uint160(chunk.minedBy), 20), '", "mining_hash": "', Strings.toHexString(uint256(chunk.miningHash), 32), '", "mined_at": "', Strings.toString(chunk.minedAt), '", "attributes": [{"trait_type": "Gold Quantity", "value": ', Strings.toString(chunk.goldQuantity), '}, {"trait_type": "Pickaxe ID", "value": ', Strings.toString(chunk.pickaxeId), '}, {"trait_type": "Gold Ratio", "value": ', Strings.toString(chunk.goldRatio), '}, {"trait_type": "Mining Difficulty", "value": ', Strings.toString(chunk.miningDifficulty), '}, {"trait_type": "Mining Attempts", "value": ', Strings.toString(chunk.miningAttempts), "}]}" ); return string( abi.encodePacked( "data:application/json;base64,", Base64.encode(bytes(metadata)) ) ); } function chunkValue(uint256 oreId) public view returns (uint256) { GoldOreChunkData memory chunk = getOreChunk(oreId); return goldValue() * chunk.goldQuantity; } function goldValue() public view returns (uint256) { return goldCap / MAX_GOLD; } function pause() external onlyOwner { _pause(); } function unpause() external onlyOwner { _unpause(); } // OVERRIDES // function _authorizeUpgrade(address) internal virtual override { _requireCallerIsContractOwner(); } function _requireCallerIsContractOwner() internal view virtual override(PickaxeMerchant, OreMine) { require( msg.sender == owner(), "Only the contract owner can call this function" ); } function onERC721Received( address operator, address, uint256, bytes calldata ) external view override returns (bytes4) { require(operator == address(this), "Invalid operator"); return this.onERC721Received.selector; } function pickaxesContract() internal view virtual override(PickaxeMerchant, OreMine) returns (address) { return PICKAXES_CONTRACT; } function oreChunksContract() internal view virtual override returns (address) { return ORE_CHUNKS_CONTRACT; } function pickaxeType( uint256 pickaxeId ) public view override returns (uint256) { if (pickaxeId > 10000) { return 1; } uint256 pickaxeType_ = _pickaxeType[pickaxeId]; if (pickaxeType_ == 0) { revert("Invalid pickaxe"); } return pickaxeType_; } // ** Upgradeable Gap ** // uint256[37] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; interface ICreatorToken { event TransferValidatorUpdated(address oldValidator, address newValidator); function getTransferValidator() external view returns (address validator); function setTransferValidator(address validator) external; function getTransferValidationFunction() external view returns (bytes4 functionSignature, bool isViewFunction); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; interface ICreatorTokenLegacy { event TransferValidatorUpdated(address oldValidator, address newValidator); function getTransferValidator() external view returns (address validator); function setTransferValidator(address validator) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; interface ITransferValidator { function applyCollectionTransferPolicy(address caller, address from, address to) external view; function validateTransfer(address caller, address from, address to) external view; function validateTransfer(address caller, address from, address to, uint256 tokenId) external view; function validateTransfer(address caller, address from, address to, uint256 tokenId, uint256 amount) external; function beforeAuthorizedTransfer(address operator, address token, uint256 tokenId) external; function afterAuthorizedTransfer(address token, uint256 tokenId) external; function beforeAuthorizedTransfer(address operator, address token) external; function afterAuthorizedTransfer(address token) external; function beforeAuthorizedTransfer(address token, uint256 tokenId) external; function beforeAuthorizedTransferWithAmount(address token, uint256 tokenId, uint256 amount) external; function afterAuthorizedTransferWithAmount(address token, uint256 tokenId) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; interface ITransferValidatorSetTokenType { function setTokenTypeOfCollection(address collection, uint16 tokenType) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @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.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.8.3) (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.9._ */ 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.8.3) (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 "../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._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable { function __ERC1967Upgrade_init() internal onlyInitializing { } function __ERC1967Upgrade_init_unchained() internal onlyInitializing { } // 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; /** * @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) { _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) { _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data); } } /** * @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) private returns (bytes memory) { require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed"); } /** * @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.8.1) (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] * ``` * 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.8.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../ERC1967/ERC1967UpgradeUpgradeable.sol"; import "./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 { function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /// @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"); _; } /** * @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. */ function upgradeTo(address newImplementation) external 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. */ function upgradeToAndCall(address newImplementation, bytes memory data) external 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 "../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.8.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import "../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 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.8.2) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721Upgradeable.sol"; import "./IERC721ReceiverUpgradeable.sol"; import "./extensions/IERC721MetadataUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../utils/StringsUpgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable { using AddressUpgradeable for address; using StringsUpgradeable for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC721Upgradeable).interfaceId || interfaceId == type(IERC721MetadataUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _ownerOf(tokenId); require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721Upgradeable.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner or approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _safeTransfer(from, to, tokenId, data); } /** * @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. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _ownerOf(tokenId) != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721Upgradeable.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId, 1); // Check that tokenId was not minted by `_beforeTokenTransfer` hook require(!_exists(tokenId), "ERC721: token already minted"); unchecked { // Will not overflow unless all 2**256 token ids are minted to the same owner. // Given that tokens are minted one by one, it is impossible in practice that // this ever happens. Might change if we allow batch minting. // The ERC fails to describe this case. _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721Upgradeable.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId, 1); // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook owner = ERC721Upgradeable.ownerOf(tokenId); // Clear approvals delete _tokenApprovals[tokenId]; unchecked { // Cannot overflow, as that would require more tokens to be burned/transferred // out than the owner initially received through minting and transferring in. _balances[owner] -= 1; } delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId, 1); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId, 1); // Check that tokenId was not transferred by `_beforeTokenTransfer` hook require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); // Clear approvals from the previous owner delete _tokenApprovals[tokenId]; unchecked { // `_balances[from]` cannot overflow for the same reason as described in `_burn`: // `from`'s balance is the number of token held, which is at least one before the current // transfer. // `_balances[to]` could overflow in the conditions described in `_mint`. That would require // all 2**256 token ids to be minted, which in practice is impossible. _balances[from] -= 1; _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721ReceiverUpgradeable.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`. * - When `from` is zero, the tokens will be minted for `to`. * - When `to` is zero, ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`. * - When `from` is zero, the tokens were minted for `to`. * - When `to` is zero, ``from``'s tokens were burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual {} /** * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override. * * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such * that `ownerOf(tokenId)` is `a`. */ // solhint-disable-next-line func-name-mixedcase function __unsafe_increaseBalance(address account, uint256 amount) internal { _balances[account] += amount; } /** * @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[44] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.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.8.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 * ==== * * [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://diligence.consensys.net/posts/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.5.11/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 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 v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../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; } /** * @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 "../../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.8.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) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 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 10, 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 * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol) 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: * ``` * 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`, and `uint256`._ */ library StorageSlotUpgradeable { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 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 } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/MathUpgradeable.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 `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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol) pragma solidity ^0.8.0; import "../utils/introspection/IERC165.sol"; /** * @dev Interface for the NFT Royalty Standard. * * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal * support for royalty payments across all NFT marketplaces and ecosystem participants. * * _Available since v4.5._ */ interface IERC2981 is IERC165 { /** * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be paid in that same unit of exchange. */ function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721.sol) pragma solidity ^0.8.0; import "../token/ERC721/IERC721.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the 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.7.0) (utils/Base64.sol) pragma solidity ^0.8.0; /** * @dev Provides a set of functions to operate with Base64 strings. * * _Available since v4.5._ */ library Base64 { /** * @dev Base64 Encoding/Decoding Table */ string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /** * @dev Converts a `bytes` to its Bytes64 `string` representation. */ function encode(bytes memory data) internal pure returns (string memory) { /** * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol */ if (data.length == 0) return ""; // Loads the table into memory string memory table = _TABLE; // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter // and split into 4 numbers of 6 bits. // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up // - `data.length + 2` -> Round up // - `/ 3` -> Number of 3-bytes chunks // - `4 *` -> 4 characters for each chunk string memory result = new string(4 * ((data.length + 2) / 3)); /// @solidity memory-safe-assembly assembly { // Prepare the lookup table (skip the first "length" byte) let tablePtr := add(table, 1) // Prepare result pointer, jump over length let resultPtr := add(result, 32) // Run over the input, 3 bytes at a time for { let dataPtr := data let endPtr := add(data, mload(data)) } lt(dataPtr, endPtr) { } { // Advance 3 bytes dataPtr := add(dataPtr, 3) let input := mload(dataPtr) // To write each character, shift the 3 bytes (18 bits) chunk // 4 times in blocks of 6 bits for each character (18, 12, 6, 0) // and apply logical AND with 0x3F which is the number of // the previous character in the ASCII table prior to the Base64 Table // The result is then added to the table to get the character to write, // and finally write it in the result pointer but with a left shift // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F)))) resultPtr := add(resultPtr, 1) // Advance } // When data `bytes` is not exactly 3 bytes long // it is padded with `=` characters at the end switch mod(mload(data), 3) case 1 { mstore8(sub(resultPtr, 1), 0x3d) mstore8(sub(resultPtr, 2), 0x3d) } case 2 { mstore8(sub(resultPtr, 1), 0x3d) } } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV // Deprecated in v4.8 } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
// 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 IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { 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) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 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 10, 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 * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; /** * @dev String operations. */ library Strings { 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 = 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), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @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) { 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); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@limitbreak/creator-token-standards/src/interfaces/ICreatorToken.sol"; import "@limitbreak/creator-token-standards/src/interfaces/ITransferValidator.sol"; import "@limitbreak/creator-token-standards/src/interfaces/ITransferValidatorSetTokenType.sol"; /** * @title CreatorTokenBase * @author Limit Break, Inc. * @notice CreatorTokenBaseV3 is an abstract contract that provides basic functionality for managing token * transfer policies through an implementation of ICreatorTokenTransferValidator/ICreatorTokenTransferValidatorV2/ICreatorTokenTransferValidatorV3. * This contract is intended to be used as a base for creator-specific token contracts, enabling customizable transfer * restrictions and security policies. * * <h4>Features:</h4> * <ul>Ownable: This contract can have an owner who can set and update the transfer validator.</ul> * <ul>TransferValidation: Implements the basic token transfer validation interface.</ul> * * <h4>Benefits:</h4> * <ul>Provides a flexible and modular way to implement custom token transfer restrictions and security policies.</ul> * <ul>Allows creators to enforce policies such as account and codehash blacklists, whitelists, and graylists.</ul> * <ul>Can be easily integrated into other token contracts as a base contract.</ul> * * <h4>Intended Usage:</h4> * <ul>Use as a base contract for creator token implementations that require advanced transfer restrictions and * security policies.</ul> * <ul>Set and update the ICreatorTokenTransferValidator implementation contract to enforce desired policies for the * creator token.</ul> * * <h4>Compatibility:</h4> * <ul>Backward and Forward Compatible - V1/V2/V3 Creator Token Base will work with V1/V2/V3 Transfer Validators.</ul> */ abstract contract CreatorTokenBaseUpgradeable is Initializable, ICreatorToken { /// @dev Thrown when setting a transfer validator address that has no deployed code. error CreatorTokenBase__InvalidTransferValidatorContract(); /// @dev The default transfer validator that will be used if no transfer validator has been set by the creator. address public constant DEFAULT_TRANSFER_VALIDATOR = address(0x721C002B0059009a671D00aD1700c9748146cd1B); /// @dev Used to determine if the default transfer validator is applied. /// @dev Set to true when the creator sets a transfer validator address. bool private isValidatorInitialized; /// @dev Address of the transfer validator to apply to transactions. address private transferValidator; function __CreatorTokenBaseUpgradeable_init() internal onlyInitializing { _emitDefaultTransferValidator(); _registerTokenType(DEFAULT_TRANSFER_VALIDATOR); } /** * @notice Sets the transfer validator for the token contract. * * @dev Throws when provided validator contract is not the zero address and does not have code. * @dev Throws when the caller is not the contract owner. * * @dev <h4>Postconditions:</h4> * 1. The transferValidator address is updated. * 2. The `TransferValidatorUpdated` event is emitted. * * @param transferValidator_ The address of the transfer validator contract. */ function setTransferValidator(address transferValidator_) public { _requireCallerIsContractOwner(); bool isValidTransferValidator = transferValidator_.code.length > 0; if (transferValidator_ != address(0) && !isValidTransferValidator) { revert CreatorTokenBase__InvalidTransferValidatorContract(); } emit TransferValidatorUpdated( address(getTransferValidator()), transferValidator_ ); isValidatorInitialized = true; transferValidator = transferValidator_; if (transferValidator_ != address(0)) { _registerTokenType(transferValidator_); } } /** * @notice Returns the transfer validator contract address for this token contract. */ function getTransferValidator() public view override returns (address validator) { validator = transferValidator; if (validator == address(0)) { if (!isValidatorInitialized) { validator = DEFAULT_TRANSFER_VALIDATOR; } } if (validator != address(0)) { uint256 validatorCodeSize; assembly { validatorCodeSize := extcodesize(validator) } if (validatorCodeSize == 0) { validator = address(0); } } } /** * @dev Pre-validates a token transfer, reverting if the transfer is not allowed by this token's security policy. * Inheriting contracts are responsible for overriding the _beforeTokenTransfer function, or its equivalent * and calling _validateBeforeTransfer so that checks can be properly applied during token transfers. * * @dev Be aware that if the msg.sender is the transfer validator, the transfer is automatically permitted, as the * transfer validator is expected to pre-validate the transfer. * * @dev Throws when the transfer doesn't comply with the collection's transfer policy, if the transferValidator is * set to a non-zero address. * * @param caller The address of the caller. * @param from The address of the sender. * @param to The address of the receiver. * @param tokenId The token id being transferred. */ function _preValidateTransfer( address caller, address from, address to, uint256 tokenId ) internal virtual { address validator = getTransferValidator(); if (validator != address(0)) { if (msg.sender == validator) { return; } ITransferValidator(validator).validateTransfer( caller, from, to, tokenId ); } } /** * @dev Pre-validates a token transfer, reverting if the transfer is not allowed by this token's security policy. * Inheriting contracts are responsible for overriding the _beforeTokenTransfer function, or its equivalent * and calling _validateBeforeTransfer so that checks can be properly applied during token transfers. * * @dev Be aware that if the msg.sender is the transfer validator, the transfer is automatically permitted, as the * transfer validator is expected to pre-validate the transfer. * * @dev Used for ERC20 and ERC1155 token transfers which have an amount value to validate in the transfer validator. * @dev The `tokenId` for ERC20 tokens should be set to `0`. * * @dev Throws when the transfer doesn't comply with the collection's transfer policy, if the transferValidator is * set to a non-zero address. * * @param caller The address of the caller. * @param from The address of the sender. * @param to The address of the receiver. * @param tokenId The token id being transferred. * @param amount The amount of token being transferred. */ function _preValidateTransfer( address caller, address from, address to, uint256 tokenId, uint256 amount ) internal virtual { address validator = getTransferValidator(); if (validator != address(0)) { if (msg.sender == validator) { return; } ITransferValidator(validator).validateTransfer( caller, from, to, tokenId, amount ); } } function _registerTokenType(address validator) internal { if (validator != address(0)) { uint256 validatorCodeSize; assembly { validatorCodeSize := extcodesize(validator) } if (validatorCodeSize > 0) { try ITransferValidatorSetTokenType(validator) .setTokenTypeOfCollection(address(this), _tokenType()) {} catch {} } } } /** * @dev Used during contract deployment for constructable and cloneable creator tokens * @dev to emit the `TransferValidatorUpdated` event signaling the validator for the contract * @dev is the default transfer validator. */ function _emitDefaultTransferValidator() internal { emit TransferValidatorUpdated(address(0), DEFAULT_TRANSFER_VALIDATOR); } function _tokenType() internal pure virtual returns (uint16); function _requireCallerIsContractOwner() internal view virtual; uint256[48] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "../NPC721CUpgradeable.sol"; import "@openzeppelin/contracts/utils/Base64.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import {GoldOreChunkData, IOreMine} from "./OreMine.sol"; import {IPickaxes} from "./Pickaxes.sol"; interface IOreChunks is IERC721 { function mint(address to) external returns (uint256 tokenId); function transferToMine(address from, uint256 tokenId) external; } contract OreChunks is UUPSUpgradeable, NPC721CUpgradeable { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable uint256 immutable ROYALTY_FEE_NUMERATOR; // State variables IPickaxes public pickaxes; IOreMine public oreMine; uint256 public totalSupply; modifier onlyTheMine() { require( address(oreMine) != address(0) && msg.sender == address(oreMine), "Only mine contract can call this" ); _; } event MetadataUpdate(uint256 tokenId); event BatchMetadataUpdate(uint256 startTokenId, uint256 endTokenId); /// @custom:oz-upgrades-unsafe-allow constructor constructor(uint256 _royaltyFeeNumerator) { require( _royaltyFeeNumerator <= ROYALTY_FEE_DENOMINATOR, "Invalid royalty fee" ); ROYALTY_FEE_NUMERATOR = _royaltyFeeNumerator; _disableInitializers(); } function initialize( string memory name_, string memory symbol_, address _pickaxes ) public initializer { __NPC721CUpgradeable_init(name_, symbol_); pickaxes = IPickaxes(_pickaxes); } function setMineContract(address _oreMine) external onlyOwner { require(_oreMine != address(0), "Invalid mine contract"); oreMine = IOreMine(_oreMine); } function mint(address to) external onlyTheMine returns (uint256) { uint256 tokenId = ++totalSupply; _safeMint(to, tokenId); return tokenId; } function royaltyInfo( uint256 tokenId, uint256 salePrice ) external view override returns (address receiver, uint256 royaltyAmount) { require(_exists(tokenId), "Token does not exist"); GoldOreChunkData memory chunk = oreMine.getOreChunk(tokenId); if (chunk.pickaxeId > 9999) { receiver = address(oreMine); } else { // call the pickaxes contract to get the owner, but if it reverts, return the mine contract try pickaxes.ownerOf(chunk.pickaxeId) returns (address owner) { receiver = owner; } catch { receiver = address(oreMine); } } if (receiver == address(0)) { receiver = address(oreMine); } royaltyAmount = (salePrice * ROYALTY_FEE_NUMERATOR) / ROYALTY_FEE_DENOMINATOR; } function tokenURI( uint256 tokenId ) public view virtual override returns (string memory) { require(_exists(tokenId), "Token does not exist"); return oreMine.getOreChunkMetadata(tokenId); } function transferToMine( address from, uint256 tokenId ) external onlyTheMine { _safeTransfer(from, address(oreMine), tokenId, ""); } function emitMetadataUpdate(uint256 tokenId) external { emit MetadataUpdate(tokenId); } function emitMetadataUpdateAll() external { emit BatchMetadataUpdate(1, totalSupply); } // OVERRIDES // function _authorizeUpgrade(address) internal view override onlyOwner {} function _beforeTokenTransfer( address from, address to, uint256 tokenId, uint256 ) internal override { address sender = _msgSender(); address mineContract = address(oreMine); if ( sender != mineContract && from != mineContract && to != mineContract ) { _preValidateTransfer(_msgSender(), from, to, tokenId); } super._beforeTokenTransfer(from, to, tokenId, 1); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import {IOreChunks} from "./OreChunks.sol"; import {IPickaxes} from "./Pickaxes.sol"; struct GoldOreChunkData { address minedBy; bytes32 miningHash; uint256 minedAt; uint256 miningAttempts; uint256 miningDifficulty; uint256 pickaxeId; uint256 pickaxeType; uint256 pickaxePreviousMined; uint256 goldRatio; uint256 goldQuantity; } struct MiningParams { address minedBy; uint256 pickaxeId; uint256 goldRatio; uint256 attempts; bool isRented; } struct MinerNFT { address nftContract; uint256 nftId; } interface IOreMine { function getOreChunk( uint256 tokenId ) external view returns (GoldOreChunkData memory); function getOreChunkMetadata( uint256 tokenId ) external view returns (string memory); } abstract contract OreMine is Initializable, IOreMine { bytes3 internal constant REQUIRED_GOLD_SUFFIX = 0xFFD700; uint256 internal constant MAX_GOLD = 21_000_000; uint256 internal constant MAX_ATTEMPTS_PER_SECOND = 4444; uint256 internal constant ATTEMPTS_PER_GOLD_RATIO = 1864; uint256 internal constant MIN_GOLD_RATIO = 1000; uint256 internal constant MAX_GOLD_RATIO = 9999; // 99.99% bool public miningEnabled; uint256 public goldMined; uint256 internal nftMiningCooldownHours; uint256 internal lastOreChunkMined; mapping(bytes32 => uint256) public miningHashToOreChunkId; mapping(uint256 => uint256) public pickaxeLastMinedOre; // pickaxeId => oreId mapping(uint256 => uint256) public pickaxeLastMiningTime; // pickaxeId => timestamp mapping(address => mapping(uint256 => uint256)) internal _previousNftMiningTime; // nftContract => nftId => timestamp mapping(uint256 => GoldOreChunkData) internal goldOreChunks; mapping(uint256 => MinerNFT) internal oreMinedByNFT; // oreId => MinerNFT event MiningEnabled(bool enabled); function __OreMine_init() internal onlyInitializing { nftMiningCooldownHours = 24; } // ** OWNER ** // function setMiningEnabled() external { _requireCallerIsContractOwner(); miningEnabled = !miningEnabled; emit MiningEnabled(miningEnabled); } function setNftMiningCooldownHours(uint256 hours_) external { _requireCallerIsContractOwner(); nftMiningCooldownHours = hours_; } // ** PUBLIC ** // function getOreChunk( uint256 tokenId ) public view returns (GoldOreChunkData memory) { return goldOreChunks[tokenId]; } /// mining difficulty is increased based on the duration within which the previous 100 ore chunks were mined /// if more than 1 hour has passed, the mining difficulty multiplier is set to 100 /// if less than 1 hour has passed, the mining difficulty multiplier is reduced by the percentage of 1 hour that has passed /// the minimum mining difficulty is 1 /// the maximum mining difficulty is 90 function miningDifficulty() public view returns (uint256 difficulty) { if (lastOreChunkMined <= 100) { return 0; } GoldOreChunkData memory oreMined100Ago = goldOreChunks[ lastOreChunkMined - 100 ]; uint256 secondsSinceLast100 = block.timestamp - oreMined100Ago.minedAt; if (secondsSinceLast100 > 3564) { return 0; } else if (secondsSinceLast100 < 360) { return 90; } else { // difficulty is the percentage of 1 hour remaining after substracting secondsSinceLast100 difficulty = ((3600 - secondsSinceLast100) * 100) / 3600; } } function nftMiningCooldown() internal view virtual returns (uint256) { return nftMiningCooldownHours * 3600; } function nftLastMinedTime( address nftContract, uint256 nftId ) public view returns (uint256) { return _previousNftMiningTime[nftContract][nftId]; } // Helper function to verify hash off-chain function verifyMiningHash( uint256 pickaxeId, uint256 goldRatio, uint256 attempts, uint256 previousChunkId ) public pure returns (bytes32 miningHash) { miningHash = sha256( abi.encodePacked(pickaxeId, goldRatio, attempts, previousChunkId) ); require( bytes3(miningHash) == REQUIRED_GOLD_SUFFIX, "Invalid mining hash" ); } // ** INTERNAL ** // function _mineGoldOre( address nftContract, uint256 nftId, uint256 pickaxeId, uint256 goldRatio, uint256 attempts, bool isRented ) internal returns (uint256) { address minedBy = msg.sender; address nftOwner = IERC721(nftContract).ownerOf(nftId); require(nftOwner == minedBy, "NFT not owned by miner"); require( block.timestamp - _previousNftMiningTime[nftContract][nftId] > nftMiningCooldown(), "NFT mining cooldown not passed" ); _previousNftMiningTime[nftContract][nftId] = block.timestamp; MiningParams memory params = MiningParams({ minedBy: minedBy, pickaxeId: pickaxeId, goldRatio: goldRatio, attempts: attempts, isRented: isRented }); (uint256 oreId, uint256 goldQuantity) = _processMining(params); oreMinedByNFT[oreId] = MinerNFT({ nftContract: nftContract, nftId: nftId }); return goldQuantity; } function _processMining( MiningParams memory params ) internal returns (uint256, uint256) { (bytes32 miningHash, uint256 pickaxePreviousMined) = _verifyMining( params ); uint256 pickaxeType_ = pickaxeType(params.pickaxeId); (uint256 goldQuantity, uint256 difficulty) = _calculateGoldQuantity( pickaxeType_, params.goldRatio ); goldMined += goldQuantity; uint256 oreId = IOreChunks(oreChunksContract()).mint(params.minedBy); GoldOreChunkData memory newOreChunk = GoldOreChunkData({ minedBy: params.minedBy, miningHash: miningHash, minedAt: block.timestamp, miningAttempts: params.attempts, miningDifficulty: difficulty, pickaxeId: params.pickaxeId, pickaxeType: pickaxeType_, pickaxePreviousMined: pickaxePreviousMined, goldRatio: params.goldRatio, goldQuantity: goldQuantity }); lastOreChunkMined = oreId; goldOreChunks[oreId] = newOreChunk; pickaxeLastMinedOre[params.pickaxeId] = oreId; pickaxeLastMiningTime[params.pickaxeId] = block.timestamp; return (oreId, goldQuantity); } function _verifyMining( MiningParams memory params ) internal view returns (bytes32 miningHash, uint256 pickaxePreviousMined) { if (!params.isRented) { address pickaxes = pickaxesContract(); require( IERC721(pickaxes).ownerOf(params.pickaxeId) == params.minedBy, "Pickaxe not owned by miner" ); } _verifyAttempts(params.pickaxeId, params.goldRatio, params.attempts); pickaxePreviousMined = pickaxeLastMinedOre[params.pickaxeId]; miningHash = verifyMiningHash( params.pickaxeId, params.goldRatio, params.attempts, pickaxePreviousMined ); return (miningHash, pickaxePreviousMined); } /** * @dev Verifies that the number of attempts is valid for the given pickaxe since the last mining time * @param pickaxeId The pickaxe ID * @param goldRatio The gold ratio * @param attempts The number of attempts */ function _verifyAttempts( uint256 pickaxeId, uint256 goldRatio, uint256 attempts ) internal view { require( goldRatio >= MIN_GOLD_RATIO && goldRatio <= MAX_GOLD_RATIO, "Invalid gold ratio" ); require(attempts > 0, "Invalid attempts"); if (goldRatio > MIN_GOLD_RATIO) { require(attempts <= ATTEMPTS_PER_GOLD_RATIO, "Invalid attempts"); } uint256 _pickaxeLastMinedTime = pickaxeLastMiningTime[pickaxeId]; uint256 ratiosChecked = MAX_GOLD_RATIO - goldRatio; uint256 totalAttempts = ratiosChecked * ATTEMPTS_PER_GOLD_RATIO + attempts; uint256 secondsSinceLastMining = block.timestamp - _pickaxeLastMinedTime; uint256 maxAttempts = secondsSinceLastMining * MAX_ATTEMPTS_PER_SECOND; require( totalAttempts <= maxAttempts, "Too many attempts since last mining" ); } /** * @dev Calculates the gold quantity and the mining difficulty * @dev The gold quantity is the number of gold specks that the ore chunk will contain * @param pickaxeType_ The pickaxe type * @param goldRatio The gold ratio * @return goldQuantity The number of gold specks that the ore chunk will contain * @return difficulty The difficulty of mining which affects the gold quantity */ function _calculateGoldQuantity( uint256 pickaxeType_, uint256 goldRatio ) internal view returns (uint256 goldQuantity, uint256 difficulty) { uint256 _goldMined = goldMined; require(_goldMined < MAX_GOLD, "No more gold can be mined"); // Gold specks are calculated based on the pickaxe type and the gold ratio and the mining difficulty multiplier difficulty = miningDifficulty(); goldQuantity = (pickaxeType_ * goldRatio * (100 - difficulty)) / 1000; // e.g. pickaxeType = 1, goldRatio = 1000, difficulty = 0 => goldQuantity = 100 // If the gold quantity is greater than the remaining gold, set the gold quantity to the remaining gold // If the remaining gold after subtracting the gold quantity is less than 100, set the gold quantity to the remaining gold if (goldQuantity + _goldMined > MAX_GOLD) { goldQuantity = MAX_GOLD - _goldMined; } else if (MAX_GOLD - _goldMined - goldQuantity < 100) { goldQuantity = MAX_GOLD - _goldMined; } } // ** VIRTUAL ** // function pickaxeType( uint256 pickaxeId ) public view virtual returns (uint256); function pickaxesContract() internal view virtual returns (address); function oreChunksContract() internal view virtual returns (address); function _requireCallerIsContractOwner() internal view virtual; // ** Upgradeable Gap ** // uint256[40] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {IPickaxes} from "./Pickaxes.sol"; interface IPickaxeMerchant {} struct PickaxeTypeMetadata { string name; string description; string image; } abstract contract PickaxeMerchant is Initializable { using ECDSA for bytes32; bytes32 internal constant NON_GTD_ALLOWANCE_TYPEHASH = keccak256("NonGtdAllowance(address minter,uint256 allowance)"); uint256 internal nonGtdMinted; bool internal GTD_RESERVE_ENDED; mapping(uint256 => uint256) internal _pickaxeType; // tokenId => pickaxe type mapping(address => uint256) public boughtPickaxes; // address => total pickaxes bought mapping(uint256 => uint256) internal pickaxeTypeSupply; // pickaxe type => current supply mapping(uint256 => uint256) internal pickaxeTypeMaxSupply; // pickaxe type => max supply mapping(uint256 => PickaxeTypeMetadata) internal _pickaxeTypeMetadata; // pickaxe type => metadata address internal signer; // signer of the allowance signature /// @custom:oz-upgrades-unsafe-allow constructor constructor() {} function __PickaxeMerchant_init(address _signer) internal onlyInitializing { signer = _signer; } function _domainSeparator() internal view returns (bytes32) { return keccak256( abi.encode( keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ), keccak256(bytes("PickaxeMerchant")), keccak256(bytes("1")), block.chainid, address(this) ) ); } function setSigner(address newSigner) external { _requireCallerIsContractOwner(); signer = newSigner; } function setPickaxeTypeMetadata( uint256 pickaxeType_, PickaxeTypeMetadata memory metadata ) external { _requireCallerIsContractOwner(); _pickaxeTypeMetadata[pickaxeType_] = metadata; } function setPickaxeTypeMaxSupply( uint256 pickaxeType_, uint256 maxSupply ) external { _requireCallerIsContractOwner(); require( maxSupply >= pickaxeTypeSupply[pickaxeType_], "Max supply must be greater than or equal to current supply" ); pickaxeTypeMaxSupply[pickaxeType_] = maxSupply; } function pickaxeTypeRemainingSupply( uint256 pickaxeType_ ) public view returns (uint256) { return pickaxeTypeMaxSupply[pickaxeType_] - pickaxeTypeSupply[pickaxeType_]; } function _verifyAllowanceSignature( address minter, uint256 allowance, bytes memory signature ) internal view { bytes32 structHash = keccak256( abi.encode(NON_GTD_ALLOWANCE_TYPEHASH, minter, allowance) ); bytes32 digest = keccak256( abi.encodePacked("\x19\x01", _domainSeparator(), structHash) ); address recoveredSigner = digest.recover(signature); require(recoveredSigner == signer, "Invalid signature"); } function _mintPickaxes( address receiver, uint256 pickaxeType_, uint256 quantity, uint256 allowance, bytes memory signature ) internal returns (uint256 actualPrice) { require(pickaxeType_ > 1, "Invalid pickaxe type"); require(quantity > 0 && quantity <= 10, "Invalid quantity"); uint256 actualQuantity = quantity; uint256 remainingSupply = pickaxeTypeMaxSupply[pickaxeType_] - pickaxeTypeSupply[pickaxeType_]; if (actualQuantity > remainingSupply) { actualQuantity = remainingSupply; } // Verify signature _verifyAllowanceSignature(receiver, allowance, signature); uint256 remainingAllowance = allowance - boughtPickaxes[receiver]; if (actualQuantity > remainingAllowance) { actualQuantity = remainingAllowance; } require(actualQuantity > 0, "No pickaxes available to mint"); actualPrice = pickaxePrice(pickaxeType_) * actualQuantity; require(msg.value >= actualPrice, "Insufficient payment"); boughtPickaxes[receiver] += actualQuantity; pickaxeTypeSupply[pickaxeType_] += actualQuantity; // Mint pickaxes uint256 firstTokenId = IPickaxes(pickaxesContract()).mint( receiver, actualQuantity ); for (uint256 i = 0; i < actualQuantity; i++) { _pickaxeType[firstTokenId + i] = pickaxeType_; } return actualPrice; } function pickaxePrice( uint256 pickaxeType_ ) internal pure returns (uint256) { return (pickaxeType_ * 2 ether); } function pickaxesContract() internal view virtual returns (address); function _requireCallerIsContractOwner() internal view virtual; // upgradeable gap uint256[42] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "../NPC721CUpgradeable.sol"; import "@openzeppelin/contracts/utils/Base64.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import {ITheMine} from "./Mine.sol"; interface IPickaxes is IERC721 { function mint( address to, uint256 amount ) external returns (uint256 tokenId); function tokenPickaxeType(uint256 tokenId) external view returns (uint256); function emitMetadataUpdate(uint256 tokenId) external; function emitMetadataUpdateAll() external; } contract Pickaxes is UUPSUpgradeable, NPC721CUpgradeable { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable uint256 immutable ROYALTY_FEE_NUMERATOR; // State variables address public THE_MINE; uint256 public totalSupply; event RoyaltyFeeUpdated(uint256 oldFee, uint256 newFee); event MetadataUpdate(uint256 tokenId); event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId); modifier onlyTheMine() { require( THE_MINE != address(0) && msg.sender == THE_MINE, "Only The Mine can do this" ); _; } /// @custom:oz-upgrades-unsafe-allow constructor constructor(uint256 _royaltyFeeNumerator) { _disableInitializers(); require( _royaltyFeeNumerator <= ROYALTY_FEE_DENOMINATOR, "Invalid royalty fee" ); ROYALTY_FEE_NUMERATOR = _royaltyFeeNumerator; } function initialize( string memory name_, string memory symbol_ ) public initializer { __NPC721CUpgradeable_init(name_, symbol_); } function setMineContract(address _theMine) external onlyOwner { require(_theMine != address(0), "Invalid mine contract"); THE_MINE = _theMine; } function mint( address to, uint256 amount ) external onlyTheMine returns (uint256) { uint256 tokenId = totalSupply + 1; for (uint256 i = 0; i < amount; i++) { _safeMint(to, tokenId + i); } totalSupply += amount; return tokenId; } function royaltyInfo( uint256 tokenId, uint256 salePrice ) external view override returns (address receiver, uint256 royaltyAmount) { require(_exists(tokenId), "Token does not exist"); receiver = address(THE_MINE); royaltyAmount = (salePrice * ROYALTY_FEE_NUMERATOR) / ROYALTY_FEE_DENOMINATOR; } function tokenURI( uint256 tokenId ) public view virtual override returns (string memory) { require(_exists(tokenId), "Token does not exist"); return ITheMine(THE_MINE).getPickaxeMetadata(tokenId); } function emitMetadataUpdate(uint256 tokenId) external { emit MetadataUpdate(tokenId); } function emitMetadataUpdateAll() external { emit BatchMetadataUpdate(1, totalSupply); } function _authorizeUpgrade( address newImplementation ) internal view override onlyOwner {} function _beforeTokenTransfer( address from, address to, uint256 tokenId, uint256 ) internal override { address sender = _msgSender(); if (sender != THE_MINE) { _preValidateTransfer(sender, from, to, tokenId); } super._beforeTokenTransfer(from, to, tokenId, 1); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "./limitbreak-upgradeable/CreatorTokenBaseUpgradeable.sol"; import "@limitbreak/creator-token-standards/src/interfaces/ICreatorToken.sol"; import "@limitbreak/creator-token-standards/src/interfaces/ICreatorTokenLegacy.sol"; import "@openzeppelin/contracts/interfaces/IERC721.sol"; import "@openzeppelin/contracts/interfaces/IERC2981.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; abstract contract NPC721CUpgradeable is OwnableUpgradeable, ReentrancyGuardUpgradeable, ERC721Upgradeable, CreatorTokenBaseUpgradeable { uint256 internal constant ROYALTY_FEE_DENOMINATOR = 10000; function __NPC721CUpgradeable_init( string memory name_, string memory symbol_ ) public initializer { __Ownable_init(); __ReentrancyGuard_init(); __ERC721_init(name_, symbol_); __CreatorTokenBaseUpgradeable_init(); } function supportsInterface( bytes4 interfaceId ) public view virtual override(ERC721Upgradeable) returns (bool) { return interfaceId == type(IERC2981).interfaceId || interfaceId == type(ICreatorToken).interfaceId || interfaceId == type(ICreatorTokenLegacy).interfaceId || super.supportsInterface(interfaceId); } function _requireCallerIsContractOwner() internal view virtual override { _checkOwner(); } function _tokenType() internal pure override returns (uint16) { return 721; } function getTransferValidationFunction() external pure override returns (bytes4 functionSignature, bool isViewFunction) { return ( bytes4( keccak256("validateTransfer(address,address,address,uint256)") ), true ); } function royaltyInfo( uint256 tokenId, uint256 salePrice ) external view virtual returns (address receiver, uint256 royaltyAmount); }
{ "viaIR": true, "optimizer": { "enabled": true, "runs": 100, "details": { "yulDetails": { "optimizerSteps": "u" } } }, "debug": { "revertStrings": "debug" }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_pickaxesContract","type":"address"},{"internalType":"address","name":"_oreChunksContract","type":"address"},{"internalType":"address","name":"_delegateRegistry","type":"address"}],"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":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"miner","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"MinerPaymentFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"MiningEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"oreId","type":"uint256"},{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"OrePurchased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"oreId","type":"uint256"},{"indexed":true,"internalType":"address","name":"seller","type":"address"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"OreSold","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","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":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"PICKAXE_RENTAL_PRICE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"nftContract","type":"address"}],"name":"addMinerNFTContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"boughtPickaxes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"oreIds","type":"uint256[]"}],"name":"buyOres","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"pickaxeType_","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bool","name":"","type":"bool"}],"name":"buyPickaxes","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"oreId","type":"uint256"}],"name":"chunkValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getOreChunk","outputs":[{"components":[{"internalType":"address","name":"minedBy","type":"address"},{"internalType":"bytes32","name":"miningHash","type":"bytes32"},{"internalType":"uint256","name":"minedAt","type":"uint256"},{"internalType":"uint256","name":"miningAttempts","type":"uint256"},{"internalType":"uint256","name":"miningDifficulty","type":"uint256"},{"internalType":"uint256","name":"pickaxeId","type":"uint256"},{"internalType":"uint256","name":"pickaxeType","type":"uint256"},{"internalType":"uint256","name":"pickaxePreviousMined","type":"uint256"},{"internalType":"uint256","name":"goldRatio","type":"uint256"},{"internalType":"uint256","name":"goldQuantity","type":"uint256"}],"internalType":"struct GoldOreChunkData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"oreId","type":"uint256"}],"name":"getOreChunkMetadata","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"pickaxeId","type":"uint256"}],"name":"getPickaxeMetadata","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"goldCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"goldMined","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"goldValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_signer","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"nftContract","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"uint256","name":"pickaxeId","type":"uint256"},{"internalType":"uint256","name":"goldRatio","type":"uint256"},{"internalType":"uint256","name":"attempts","type":"uint256"}],"name":"mineGoldOre","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"miningDifficulty","outputs":[{"internalType":"uint256","name":"difficulty","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"miningEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"miningHashToOreChunkId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"nftContract","type":"address"},{"internalType":"uint256","name":"nftId","type":"uint256"}],"name":"nftLastMinedTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","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":"uint256","name":"","type":"uint256"}],"name":"pickaxeLastMinedOre","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pickaxeLastMiningTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pickaxeRentalCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pickaxeTotalGoldMined","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pickaxeTotalOresMined","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"pickaxeId","type":"uint256"}],"name":"pickaxeType","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"pickaxeType_","type":"uint256"}],"name":"pickaxeTypeRemainingSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"nftContract","type":"address"}],"name":"removeMinerNFTContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rentPickaxe","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rentedPickaxeUsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rentedPickaxes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"oreId","type":"uint256"}],"name":"sellOre","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newManagement","type":"address"}],"name":"setManagement","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setMiningEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"hours_","type":"uint256"}],"name":"setNftMiningCooldownHours","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setOreMerchantEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setPickaxeMerchantEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newPrice","type":"uint256"}],"name":"setPickaxeRentalPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pickaxeType_","type":"uint256"},{"internalType":"uint256","name":"maxSupply","type":"uint256"}],"name":"setPickaxeTypeMaxSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pickaxeType_","type":"uint256"},{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"description","type":"string"},{"internalType":"string","name":"image","type":"string"}],"internalType":"struct PickaxeTypeMetadata","name":"metadata","type":"tuple"}],"name":"setPickaxeTypeMetadata","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newSigner","type":"address"}],"name":"setSigner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","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"},{"inputs":[{"internalType":"uint256","name":"pickaxeId","type":"uint256"},{"internalType":"uint256","name":"goldRatio","type":"uint256"},{"internalType":"uint256","name":"attempts","type":"uint256"},{"internalType":"uint256","name":"previousChunkId","type":"uint256"}],"name":"verifyMiningHash","outputs":[{"internalType":"bytes32","name":"miningHash","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
610100604052346100575761001b6100156101ba565b9161028b565b604051615f1761046182396080518181816121b00152612b09015260a05181614115015260c051816140f1015260e051816138ed0152615f1790f35b608461006260405190565b62461bcd60e51b815260206004820152602260248201527f45746865722073656e7420746f206e6f6e2d70617961626c652066756e63746960448201526137b760f11b6064820152fd5b634e487b7160e01b600052604160045260246000fd5b90601f01601f191681019081106001600160401b038211176100e357604052565b6100ac565b906100fc6100f560405190565b92836100c2565b565b608461010960405190565b62461bcd60e51b815260206004820152602260248201527f414249206465636f64696e673a207475706c65206461746120746f6f2073686f6044820152611c9d60f21b6064820152fd5b6001600160a01b031690565b90565b6001600160a01b0381160361017357565b600080fd5b905051906100fc82610162565b90916060828403126101b55761015f61019e8484610178565b9360406101ae8260208701610178565b9401610178565b6100fe565b6101d8616378803803806101cd816100e8565b928339810190610185565b909192565b61015361015f61015f9290565b61015f906101dd565b156101fa57565b60405162461bcd60e51b815260206004820152601960248201527f496e76616c6964207069636b6178657320636f6e7472616374000000000000006044820152606490fd5b1561024657565b60405162461bcd60e51b815260206004820152601b60248201527f496e76616c6964206f7265206368756e6b7320636f6e747261637400000000006044820152606490fd5b6102936102e5565b61029b6103f1565b6102da6102c96102ab60006101ea565b6101536001600160a01b0382166001600160a01b03861614156101f3565b6001600160a01b038416141561023f565b60a05260c05260e052565b6100fc6100fc6100fc6100fc6100fc6100fc6100fc6100fc610328565b61015f90610153906001600160a01b031682565b61015f90610302565b61015f90610316565b6103313061031f565b608052565b61015f9060081c5b60ff1690565b61015f9054610336565b1561035557565b60405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b6064820152608490fd5b61015f9061033e565b61015f90546103aa565b61033e61015f61015f9260ff1690565b906103dd61015f6103ed926103bd565b825460ff191660ff919091161790565b9055565b61040a6104056104016000610344565b1590565b61034e565b61041460006103b3565b60ff9081161061042057565b61042c60ff60006103cd565b7f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249861045660405190565b60ff8152602090a156fe6080604052600436101561001d575b366112a95761001b613f85565b005b60003560e01c8063141b0dc11461033d578063150b7a02146103385780631747ea12146103335780631a483f741461032e5780632c3f6bba14610329578063313f82aa14610324578063362917261461031f5780633659cfe61461031a5780633a503f9f146103155780633b74a185146103105780633f4ba83a1461030b57806346a5440914610306578063495396bd146103015780634a7ccd3e146102fc5780634be68445146102f75780634f1ef286146102f257806352d1902d146102ed57806359d006b8146102e85780635bd156e9146102e35780635c975abb146102de57806360bf8f2b146102d95780636c19e783146102d45780636c656086146102cf5780636cce5bf9146102ca578063715018a6146102c55780637d854bc7146102c05780637e3ee3b0146102bb5780637f128135146102b65780638456cb59146102b157806389805224146102ac5780638a89f2b3146102a75780638da5cb5b146102a25780639bc737191461029d578063ae7ec0f714610298578063b21ec4b114610293578063b40b9bb61461028e578063be8eb67e14610289578063bfd8121714610284578063bfe29cbf1461027f578063c4d66de81461027a578063d090c63f14610275578063d4a22bde14610270578063d9cc59821461026b578063dda3c2ee14610266578063e08ac27f14610261578063f2fde38b1461025c578063f4429c3314610257578063f760794414610252578063fa3229351461024d5763fc4172e80361000e5761128e565b611266565b61124b565b61122c565b6111df565b6111c4565b61119f565b611187565b61116f565b611155565b6110cf565b6110b4565b611088565b611060565b611038565b61101f565b610feb565b610fd3565b610fac565b610f80565b610f49565b610ef0565b610ed5565b610ea9565b610e91565b610e79565b610e5d565b610df6565b610dc7565b610daf565b610d94565b610d79565b610d53565b610bcf565b610bbb565b610a3e565b6109a5565b61095a565b61092e565b610905565b6108ed565b6108d2565b610869565b61082e565b610762565b61073c565b610728565b6106b7565b610663565b61047e565b608461034d60405190565b62461bcd60e51b815260206004820152602260248201527f45746865722073656e7420746f206e6f6e2d70617961626c652066756e63746960448201526137b760f11b6064820152fd5b60846103a260405190565b62461bcd60e51b815260206004820152602260248201527f414249206465636f64696e673a207475706c65206461746120746f6f2073686f6044820152611c9d60f21b6064820152fd5b60846103f760405190565b62461bcd60e51b815260206004820152602260248201527f414249206465636f64696e673a20696e76616c6964207475706c65206f666673604482015261195d60f21b6064820152fd5b805b0361044a57565b600080fd5b9050359061045c82610441565b565b90602082820312610475576104729161044f565b90565b610397565b9052565b346104ae576104aa61049961049436600461045e565b61133e565b6040515b9182918290815260200190565b0390f35b610342565b6001600160a01b031690565b610443816104b3565b9050359061045c826104bf565b60846104e060405190565b62461bcd60e51b815260206004820152602b6024820152600080516020615ec283398151915260448201526a1c9c985e481bd9999cd95d60aa1b6064820152fd5b608461052c60405190565b62461bcd60e51b815260206004820152602b6024820152600080516020615ec283398151915260448201526a0e4e4c2f240d8cadccee8d60ab1b6064820152fd5b608461057860405190565b62461bcd60e51b815260206004820152602b6024820152600080516020615ec283398151915260448201526a727261792073747269646560a81b6064820152fd5b909182601f830112156105f2578135916001600160401b0383116105ed5760200192600183028401116105e857565b61056d565b610521565b6104d5565b906080828203126104755761060c81836104c8565b9261061a82602085016104c8565b92610628836040830161044f565b9260608201356001600160401b03811161064a5761064692016105b9565b9091565b6103ec565b6001600160e01b0319909116815260200190565b346104ae576104aa6106826106793660046105f7565b939290926113d5565b6040519182918261064f565b801515610443565b9050359061045c8261068e565b906020828203126104755761047291610696565b346104ae576106cf6106ca3660046106a3565b61145f565b604051005b909182601f830112156105f2578135916001600160401b0383116105ed5760200192602083028401116105e857565b906020828203126104755781356001600160401b03811161064a5761064692016106d4565b6106cf610736366004610703565b90611d21565b346104ae576104aa61049961075236600461045e565b611d2b565b600091031261047557565b61076d366004610757565b6104aa610499611f6a565b61047a906104b3565b906101208061045c9361079c60008201516000860190610778565b6107ab60208201516020860152565b6107ba60408201516040860152565b6107c960608201516060860152565b6107d860808201516080860152565b6107e760a082015160a0860152565b6107f660c082015160c0860152565b61080560e082015160e0860152565b610816610100820151610100860152565b0151910152565b6101408101929161045c9190610781565b346104ae576104aa61084961084436600461045e565b6120bc565b6040519182918261081d565b9060208282031261047557610472916104c8565b346104ae576106cf61087c366004610855565b61223e565b6104726104726104729290565b9061089890610881565b600052602052604060002090565b610472916008021c81565b9061047291546108a6565b60006108cd6104729261019661088e565b6108b1565b346104ae576104aa6104996108e836600461045e565b6108bc565b346104ae576106cf61090036600461045e565b6125bc565b346104ae57610915366004610757565b6106cf6125d8565b60006108cd6104729261016561088e565b346104ae576104aa61049961094436600461045e565b61091d565b60006108cd6104729261019761088e565b346104ae576104aa61049961097036600461045e565b610949565b610472916008021c5b60ff1690565b906104729154610975565b60006109a06104729261019961088e565b610984565b346104ae576104aa6109c06109bb36600461045e565b61098f565b60405191829182901515815260200190565b60005b8381106109e55750506000910152565b81810151838201526020016109d5565b610a16610a1f602093610a2993610a0a815190565b80835293849260200190565b958691016109d2565b601f01601f191690565b0190565b6020808252610472929101906109f5565b346104ae576104aa610a59610a5436600461045e565b612918565b60405191829182610a2d565b6084610a7060405190565b62461bcd60e51b815260206004820152602760248201527f414249206465636f64696e673a20696e76616c69642062797465206172726179604482015266040d8cadccee8d60cb1b6064820152fd5b634e487b7160e01b600052604160045260246000fd5b90601f01601f191681019081106001600160401b03821117610af657604052565b610abf565b9061045c610b0860405190565b9283610ad5565b6001600160401b038111610af657602090601f01601f19160190565b90826000939282370152565b90929192610b4c610b4782610b0f565b610afb565b9381855281830111610b665761045c916020850190610b2b565b610a65565b9080601f830112156105f25781602061047293359101610b37565b91909160408184031261047557610b9d83826104c8565b9260208201356001600160401b03811161064a576104729201610b6b565b6106cf610bc9366004610b86565b90612a7a565b346104ae57610bdf366004610757565b6104aa610499612b6a565b6084610bf560405190565b62461bcd60e51b815260206004820152602360248201527f414249206465636f64696e673a20737472756374206461746120746f6f2073686044820152621bdc9d60ea1b6064820152fd5b6084610c4b60405190565b62461bcd60e51b815260206004820152602360248201527f414249206465636f64696e673a20696e76616c696420737472756374206f66666044820152621cd95d60ea1b6064820152fd5b919091606081840312610d1957610cad6060610afb565b9281356001600160401b038111610d145781610cca918401610b6b565b845260208201356001600160401b038111610d145781610ceb918401610b6b565b602085015260408201356001600160401b038111610d1457610d0d9201610b6b565b6040830152565b610c40565b610bea565b91909160408184031261047557610d35838261044f565b9260208201356001600160401b03811161064a576104729201610c96565b346104ae576106cf610d66366004610d1e565b90612d91565b610472600061019c6108b1565b346104ae57610d89366004610757565b6104aa610499610d6c565b346104ae57610da4366004610757565b6104aa6109c0612dae565b346104ae576106cf610dc236600461045e565b612db8565b346104ae576106cf610dda366004610855565b612df2565b90610898565b60006108cd61047292610163610ddf565b346104ae576104aa610499610e0c36600461045e565b610de5565b919060a08382031261047557610e2781846104c8565b92610e35826020830161044f565b92610472610e46846040850161044f565b936080610e56826060870161044f565b940161044f565b346104ae576106cf610e70366004610e11565b93929092613088565b346104ae57610e89366004610757565b6106cf6130cd565b346104ae576106cf610ea4366004610855565b613262565b346104ae576104aa610499610ebf36600461045e565b61326b565b60006108cd6104729261016461088e565b346104ae576104aa610499610eeb36600461045e565b610ec4565b346104ae57610f00366004610757565b6106cf6132bc565b610472906104b3906001600160a01b031682565b61047290610f08565b61047290610f1c565b9061089890610f25565b60006108cd61047292610130610f2e565b346104ae576104aa610499610f5f366004610855565b610f38565b919060408382031261047557610472906020610e5682866104c8565b346104ae576104aa610499610f96366004610f64565b906132c4565b60208101929161045c9190610778565b346104ae57610fbc366004610757565b6104aa610fc76132e0565b60405191829182610f9c565b346104ae57610fe3366004610757565b6106cf6132ea565b346104ae576106cf610ffe36600461045e565b613357565b919060408382031261047557610472906020610e56828661044f565b346104ae576106cf611032366004611003565b906133d2565b346104ae57611048366004610757565b6104aa610499613407565b610472600061015f610984565b346104ae57611070366004610757565b6104aa6109c0611053565b61047260006101916108b1565b346104ae57611098366004610757565b6104aa61049961107b565b60006108cd61047292610198610f2e565b346104ae576104aa6104996110ca366004610855565b6110a3565b346104ae576106cf6110e2366004610855565b6136b5565b9060c082820312610475576110fc81836104c8565b9261110a826020850161044f565b92611118836040830161044f565b92611126816060840161044f565b9260808301356001600160401b03811161064a578261114c60a0946104729387016105b9565b94909501610696565b6106cf6111633660046110e7565b9594909493919361398d565b346104ae576106cf611182366004610855565b613a25565b346104ae576106cf61119a3660046106a3565b613a46565b346104ae576106cf6111b2366004610855565b613a7c565b61047260006101936108b1565b346104ae576111d4366004610757565b6104aa6104996111b7565b346104ae576106cf6111f2366004610855565b613b15565b6080818303126104755761120b828261044f565b9261047261121c846020850161044f565b936060610e56826040870161044f565b346104ae576104aa6104996112423660046111f7565b92919091613b9b565b346104ae576104aa610a5961126136600461045e565b613ec2565b346104ae57611276366004610757565b6104aa610499613f6f565b61047260006101606108b1565b346104ae5761129e366004610757565b6104aa610499611281565b60846112b460405190565b62461bcd60e51b815260206004820152602960248201527f556e6b6e6f776e207369676e617475726520616e64206e6f2066616c6c6261636044820152681ac81919599a5b995960ba1b6064820152fd5b6104729081565b6104729054611305565b634e487b7160e01b600052601160045260246000fd5b9190820391821161133957565b611316565b6104729061136561135761135c6113578461013261088e565b61130c565b9261013161088e565b9061132c565b1561137257565b60405162461bcd60e51b815260206004820152601060248201526f24b73b30b634b21037b832b930ba37b960811b604482015280606481015b0390fd5b6113c86113c26104729263ffffffff1690565b60e01b90565b6001600160e01b03191690565b9250505061140791506113e6600090565b506114016113fb6113f630610f25565b6104b3565b916104b3565b1461136b565b61047263150b7a026113af565b61045c90611420613fed565b611453565b9061ff009060081b5b9181191691161790565b9061144861047261144f92151590565b8254611425565b9055565b61045c90610194611438565b61045c90611414565b9061147a91611475614060565b611482565b61045c614092565b9061045c9161148f6140dc565b6117e7565b6104729060081c61097e565b6104729054611494565b156114b157565b60405162461bcd60e51b815260206004820152601b60248201527f4f7265206d65726368616e74206973206e6f7420656e61626c656400000000006044820152606490fd5b6001600160401b038111610af65760208091020190565b9061151a610b47836114f6565b918252565b369037565b9061045c61153a6115348461150d565b936114f6565b601f19016020840161151f565b634e487b7160e01b600052603260045260246000fd5b919081101561156d576020020190565b611547565b3561047281610441565b608461158760405190565b62461bcd60e51b815260206004820152602560248201527f54617267657420636f6e747261637420646f6573206e6f7420636f6e7461696e60448201526420636f646560d81b6064820152fd5b9050519061045c826104bf565b9060208282031261047557610472916115d4565b6040513d6000823e3d90fd5b9061160a825190565b81101561156d576020809102010190565b9061047a906104b3565b8181029291811591840414171561133957565b634e487b7160e01b600052601260045260246000fd5b90611658565b9190565b908115611663570490565b611638565b9190820180921161133957565b60001981146113395760010190565b1561168b57565b60405162461bcd60e51b8152602060048201526014602482015273125b9cdd59999a58da595b9d081c185e5b595b9d60621b6044820152606490fd5b610472906104b3565b61047290546116c7565b9061151a610b4783610b0f565b3d15611701576116f63d6116da565b903d6000602084013e565b606090565b1561170d57565b60405162461bcd60e51b815260206004820152601c60248201527f526576656e7565207368617265207061796d656e74206661696c6564000000006044820152606490fd5b61047290516104b3565b60409061178661045c949695939661177c60608401986000850190610778565b6020830190610778565b0152565b906000199061142e565b906117a461047261144f92610881565b825461178a565b156117b257565b60405162461bcd60e51b815260206004820152600d60248201526c1499599d5b990819985a5b1959609a1b6044820152606490fd5b6117fa6117f56101946114a0565b6114aa565b60009061180682610881565b9083908261181383611524565b9261181d87611524565b9261182788611524565b968399845b8a811015611aba576118476118426118426140ef565b610f25565b636352211e9061186061185b84898961155d565b611572565b90803b15611a97576118959160209161187860405190565b80809581946118878960e01b90565b835260048301526024820190565b03915afa908115611a9257600091611a9c575b506118b86113fb6113f630610f25565b146118c7575b5060010161182c565b6118e96118dc61185b989e9b9884898961155d565b6118e68c8c611601565b52565b6118fa61084461185b84898961155d565b9061191460a061190e611842611842614113565b93015190565b823b15611a975761193b9261188760209361192e60405190565b9586948593849360e01b90565b03915afa908115611a9257600091611a64575b506119598a8c611601565b906119639161161b565b61196e81868661155d565b61197790611572565b61198090611d2b565b9b8c61198c6005610881565b6119969082611625565b6119a06064610881565b6119a99161164e565b6119b38c8b611601565b526119bd91611668565b958c61019b6119cd84898961155d565b6119d690611572565b6119df9161088e565b6119e89061130c565b6119f19161132c565b6119fa91611668565b98611a0490611675565b9b611a1082878761155d565b611a1990611572565b611a2290610881565b611a2b33610f25565b91611a3560405190565b9081527f176bc82be3934df3915f77a103b930d01d585f6112985e08d53c9bbbca1e643290602090a3386118be565b611a85915060203d8111611a8b575b611a7d8183610ad5565b8101906115e1565b3861194e565b503d611a73565b6115f5565b61157c565b611ab4915060203d8111611a8b57611a7d8183610ad5565b386118a8565b50939250969498975050611acd86610881565b8714611ce557611af9611ae9611ae36014610881565b83611625565b611af36064610881565b9061164e565b94611b28611ae9611b0a8885611668565b93611b18855b341015611684565b611b226005610881565b90611625565b90611b518880611b396101926116d0565b60405160009187905af1611b4b6116e7565b50611706565b611b5a88610881565b96875b8a5b811015611c625780611b9b611b978a611b92611b8d611b85611b81878f611601565b5190565b958693611601565b611752565b614137565b1590565b611c51575b50611baf6118426118426140ef565b908c611bc7611b8183611bc130610f25565b93611601565b833b15611a9757611bff938d9283611bde60405190565b809781958294611bf26342842e0e60e01b90565b845233906004850161175c565b03925af1908115611a9257611b5f92611c1e92611c25575b5060010190565b9050611b5d565b611c44908d803d10611c4a575b611c3c8183610ad5565b810190610757565b38611c17565b503d611c32565b611c5b9199611668565b9738611ba0565b50611cb59792949a50611365939950611cad9650611c9d9550611c9891611c8891611668565b93611c936002610881565b611625565b61132c565b611ca861019361130c565b611668565b610193611794565b813411611cc0575050565b80611cce61045c933461132c565b604051600091335af1611cdf6116e7565b506117ab565b60405162461bcd60e51b81526020600482015260146024820152734e6f206f7265206368756e6b7320746f2062757960601b6044820152606490fd5b9061045c91611468565b611d4061047291611d3a600090565b506120bc565b611b22610120611d4e613f6f565b92015190565b61047290611d606140dc565b611e6e565b15611d6c57565b60405162461bcd60e51b815260206004820152601a60248201527f5069636b6178652072656e74616c206e6f7420656e61626c65640000000000006044820152606490fd5b15611db857565b60405162461bcd60e51b815260206004820152600f60248201526e125b9d985b1a59081c185e5b595b9d608a1b6044820152606490fd5b6104729061097e565b6104729054611def565b15611e0957565b60405162461bcd60e51b815260206004820152601f60248201527f416c72656164792072656e746564207069636b617865206e6f742075736564006044820152606490fd5b9060ff9061142e565b90611e6761047261144f92151590565b8254611e4e565b50611e90611e7d61019161130c565b611e8a6116546000610881565b11611d65565b611ea8611ea161047261019161130c565b3414611db1565b610198611eb86113573383610f2e565b80611ec36000610881565b8103611f32575050611ee9611ee1611edc61019a61130c565b611675565b61019a611794565b611f08611ef761019a61130c565b611f0381933390610f2e565b611794565b611f19611cad611c9d61019161130c565b610472611f2a611edc61019c61130c565b61019c611794565b611f65919250611f60600091610199611f5b611f56611f51848461088e565b611df8565b611e02565b61088e565b611e57565b611f08565b6104726000611d54565b610472610140610afb565b611f87611f74565b906000825260208080808080808080808b01600081520160008152016000815201600081520160008152016000815201600081520160008152016000905250565b610472611f7f565b9061045c6120ab6009611fe1611f74565b94611ff4611fee826116d0565b8761161b565b61200a6120036001830161130c565b6020880152565b6120206120196002830161130c565b6040880152565b61203661202f6003830161130c565b6060880152565b61204c6120456004830161130c565b6080880152565b61206261205b6005830161130c565b60a0880152565b6120786120716006830161130c565b60c0880152565b61208e6120876007830161130c565b60e0880152565b6120a561209d6008830161130c565b610100880152565b0161130c565b610120840152565b61047290611fd0565b6120d4610472916120cb611fc8565b5061016761088e565b6120b3565b156120e057565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608490fd5b1561214157565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608490fd5b61045c906121fd6121ab30610f25565b6121e37f0000000000000000000000000000000000000000000000000000000000000000916121dc6113fb846104b3565b14156120d9565b6121f76113fb6121f1614204565b926104b3565b1461213a565b612218565b9061045c61153a612212846116da565b93610b0f565b600061045c916122278161421a565b61223861223383610881565b612202565b906142cb565b61045c9061219b565b61147a90612253614060565b61045c9061225f6140dc565b6122f8565b1561226b57565b60405162461bcd60e51b815260206004820152600d60248201526c2737ba1037b9329037bbb732b960991b6044820152606490fd5b91602061045c92949361178660408201966000830190610778565b156122c257565b60405162461bcd60e51b815260206004820152600e60248201526d14185e5b595b9d0819985a5b195960921b6044820152606490fd5b6123066117f56101946114a0565b61230e6140ef565b9061231b61184283610f25565b90636352211e90823b15611a9757602061233460405190565b80946123408560e01b90565b82526004820184905260249082905afa928315611a925760009361259b575b5061237b61236c336104b3565b612375856104b3565b14612264565b61239b61184261238a83611d2b565b9561184287611f038661019b61088e565b803b15611a975760006123ad60405190565b9182906332b2835f60e21b82528183816123cb888b600484016122a0565b03925af18015611a9257612585575b506123ee60a06123e9836120bc565b015190565b6123f730610f25565b92612403612710610881565b82106124d8575b505061248b612485612495926124806000806124697fee3964a289d03bf62aa9aad77f906aa0bebfa79947a18a57865d1c6384a949de98612449600090565b906124538c6104b3565b61245c826104b3565b0361249a575b508b61132c565b604051600091335af161247a6116e7565b506122bb565b610881565b93610f25565b9361049d60405190565b0390a3565b90506124ad611ae98d611b226005610881565b6124bb611b97828094614137565b1561246257611cad6124d291611ca861019361130c565b38612462565b9092506124e9611842611842614113565b92833b15611a97576125119361188760209361250460405190565b9687948593849360e01b90565b03915afa8015611a92576124856124959261248060008061246961248b967fee3964a289d03bf62aa9aad77f906aa0bebfa79947a18a57865d1c6384a949de998391612566575b50985050505050925061240a565b61257f915060203d602011611a8b57611a7d8183610ad5565b38612558565b612595906000611c3c8183610ad5565b386123da565b6125b591935060203d602011611a8b57611a7d8183610ad5565b913861235f565b61045c90612247565b6125cd613fed565b61045c61045c614423565b61045c6125c5565b61047260006116da565b6104726125e0565b6104729081906001600160a01b031681565b61047290610881565b610a296126259260209261261f815190565b94859290565b938491016109d2565b976126f06127af612867996126f060039f9d976128a79f9b60106126f09f6126f09d60136127276128259f600d6126f09f6127ea9f6127609a6126f06126ac8b94601a6126816127459d6126f69761260d565b7f7b226e616d65223a2022476f6c64204f7265204368756e6b202300000000000081525b019061260d565b7f222c20226465736372697074696f6e223a202241206368756e6b206f6620676f815271036321037b9329031b7b73a30b4b734b733960751b602082015260320190565b9061260d565b6f01033b7b6321039b832b1b5b9971116160851b81526c1136b4b732b22fb13c911d101160991b91019081526126a5565b721116101136b4b734b733afb430b9b4111d101160691b81526126a5565b6f1116101136b4b732b22fb0ba111d101160811b81526126a5565b7f222c202261747472696275746573223a205b7b2274726169745f74797065223a81527f2022476f6c64205175616e74697479222c202276616c7565223a2000000000006020820152603b0190565b7f7d2c207b2274726169745f74797065223a20225069636b617865204944222c208152680113b30b63ab2911d160bd1b602082015260290190565b7f7d2c207b2274726169745f74797065223a2022476f6c6420526174696f222c208152680113b30b63ab2911d160bd1b602082015260290190565b7f7d2c207b2274726169745f74797065223a20224d696e696e672044696666696381526f03ab63a3c911610113b30b63ab2911d160851b602082015260300190565b7f7d2c207b2274726169745f74797065223a20224d696e696e6720417474656d7081526d03a39911610113b30b63ab2911d160951b6020820152602e0190565b627d5d7d60e81b81520190565b96919a999461045c99946128dc979299946128ce60405190565b9d8e9b60208d019b8c61262e565b90810382520383610ad5565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c00000081526104729190601d016126f0565b6129206125ea565b9061292d8161016761088e565b612936906120b3565b906129409061442b565b90610120810161294e815190565b6129579061442b565b9061296183611752565b61296a90610f1c565b612973906125f2565b61297d6014610881565b61298691614545565b90612992602085015190565b61299b90612604565b6129a56020610881565b6129ae91614545565b906129ba604086015190565b6129c39061442b565b90516129ce9061442b565b916129da60a087015190565b6129e39061442b565b936129f061010088015190565b6129f99061442b565b95612a05608089015190565b612a0e9061442b565b606090980151612a1d9061442b565b98612a279a6128b4565b612a30906146c7565b60405180916020820190612a4490826128e8565b9081038252036104729082610ad5565b9061045c91612a656121ab30610f25565b61045c91600191612a758161421a565b6142cb565b9061045c91612a54565b15612a8b57565b60405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b6064820152608490fd5b61047290612b33612b0130610f25565b612b2d6113fb7f00000000000000000000000000000000000000000000000000000000000000006104b3565b14612a84565b612b61565b6104727f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610881565b50610472612b38565b6104726000612af1565b634e487b7160e01b600052602260045260246000fd5b9060016002830492168015612baa575b6020831014612ba557565b612b74565b91607f1691612b9a565b9160001960089290920291821b911b61142e565b9190612bd961047261144f93610881565b908354612bb4565b61045c91600091612bc8565b818110612bf8575050565b80612c066000600193612be1565b01612bed565b9190601f8111612c1b57505050565b612c2d61045c93600052602060002090565b906020601f840181900483019310612c4f575b6020601f909101040190612bed565b9091508190612c40565b9060001960089091021c191690565b81612c7291612c59565b906002021790565b90612c83815190565b906001600160401b038211610af657612ca682612ca08554612b8a565b85612c0c565b602090601f8311600114612cd45761144f929160009183612cc9575b5050612c68565b015190503880612cc2565b601f19831691612ce985600052602060002090565b9260005b818110612d2857509160029391856001969410612d0e575b50505002019055565b612d1e910151601f841690612c59565b9055388080612d05565b91936020600181928787015181550195019201612ced565b9061045c91612c7a565b6002612d80604061045c94612d69612d63600083015190565b86612d40565b6123e9612d77602083015190565b60018701612d40565b9101612d40565b9061045c91612d4a565b90612da961045c92612da1614814565b61013361088e565b612d87565b61047260fb611df8565b61045c90612dc4614814565b610161611794565b906001600160a01b039061142e565b90612deb61047261144f92610f25565b8254612dcc565b61045c90612dfe614814565b610134612ddb565b9061147a94939291612e16614060565b9061045c94939291612e266140dc565b612f53565b15612e3257565b60405162461bcd60e51b8152602060048201526015602482015274135a5b9a5b99c81a5cc81b9bdd08195b98589b1959605a1b6044820152606490fd5b15612e7657565b60405162461bcd60e51b815260206004820152602e60248201527f4e465420636f6e7472616374206973206e6f7420612076616c6964206d696e6560448201526d1c881391950818dbdb9d1c9858dd60921b6064820152608490fd5b15612ed957565b60405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964207069636b61786560881b6044820152606490fd5b15612f1757565b60405162461bcd60e51b8152602060048201526014602482015273141a58dad85e1948185b1c9958591e481d5cd95960621b6044820152606490fd5b612fa690611b97929395612fe195612f74612f6f61015f611df8565b612e2b565b612f8b612f86611f5185610195610f2e565b612e6f565b87612f97612710610881565b81119687948561304657614907565b612fd2612fb36001610881565b612fcc612fc28861019661088e565b91611ca88361130c565b90611794565b612fcc612fc28661019761088e565b612fe9575b50565b612ff7611842611842614113565b803b15611a975761302560009291839261301060405190565b94859384928391906318c85cf560e11b611887565b03925af18015611a92576130365750565b61045c906000611c3c8183610ad5565b61305f61305861135733610198610f2e565b8414612ed2565b6130836001611f6085610199611f5b61307e611b97611f51858561088e565b612f10565b614907565b9061045c94939291612e06565b61309d613fed565b61045c6130bb565b6104b36104726104729290565b610472906130a5565b61045c6130c860006130b2565b614a46565b61045c613095565b61045c906130e1613fed565b6131a4565b156130ed57565b60405162461bcd60e51b8152602060048201526014602482015273125b9d985b1a59081391950818dbdb9d1c9858dd60621b6044820152606490fd5b9050519061045c8261068e565b906020828203126104755761047291613129565b1561315157565b60405162461bcd60e51b815260206004820152602560248201527f4e465420636f6e747261637420646f6573206e6f7420737570706f7274204945604482015264524337323160d81b6064820152608490fd5b6131c46131b46113f660006130b2565b6131bd836104b3565b14156130e6565b6131d061184282610f25565b803b15611a975760206131e260405190565b9182906301ffc9a760e01b825281806132056380ac58cd60e01b6004830161064f565b03915afa8015611a925761045c9261322b611f6092600194600091613233575b5061314a565b610195610f2e565b613255915060203d60201161325b575b61324d8183610ad5565b810190613136565b38613225565b503d613243565b61045c906130d5565b613276612710610881565b811161329e5761135761328b9161012f61088e565b6132956000610881565b8114612ed95790565b506104726001610881565b6132b1613fed565b61045c61045c614ada565b61045c6132a9565b61047291611f5b611357926132d7600090565b50610166610f2e565b61047260976116d0565b6132f2614814565b61330b613303611b9761015f611df8565b61015f611e57565b7fd07c370fab3a218ea71c161d4c9008b25a6f112a4bd8474e6ed204557fc6389b61333a6109c061015f611df8565b0390a1565b61045c9061334b613fed565b61045c90610191611794565b61045c9061333f565b1561336757565b60405162461bcd60e51b815260206004820152603a60248201527f4d617820737570706c79206d7573742062652067726561746572207468616e2060448201527f6f7220657175616c20746f2063757272656e7420737570706c790000000000006064820152608490fd5b90611f0361045c926133e2614814565b6133ff6133f76104726113578461013161088e565b841015613360565b61013261088e565b61341261016261130c565b61341f6116546064610881565b11156134be5761345a61345460406123e96120d461016761344e61344461016261130c565b6113656064610881565b9061088e565b4261132c565b613465610dec610881565b81111561347757506104726000610881565b613482610168610881565b8110156134945750610472605a610881565b61047290611af36134b86134ae610e1093611c9885610881565b611b226064610881565b91610881565b6104726000610881565b61097e6104726104729290565b156134dc57565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b61097e6104726104729260ff1690565b90611e6761047261144f92613538565b61047a906134c8565b60208101929161045c9190613558565b6135b7613581611b9760006114a0565b918280613654575b801561360f575b613599906134d5565b826135ae6135a760016134c8565b6000613548565b6135fe57613672565b6135bd57565b6135c8600080611438565b7f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024986135f260405190565b8061333a600182613561565b61360a60016000611438565b613672565b50613624611b9761361f30610f25565b614ae2565b801561359057506135996136386000611df8565b61364c61364560016134c8565b9160ff1690565b149050613590565b5061365f6000611df8565b61366c61364560016134c8565b10613589565b6136939061367e614b71565b613686614b91565b61368e614bb1565b614bd6565b61369b614bfc565b6136a733610192612ddb565b61045c611ee1612710610881565b61045c90613571565b9061147a9695949392916136d0614060565b9061045c9695949392916136e26140dc565b613815565b156136ee57565b60405162461bcd60e51b815260206004820152601f60248201527f5069636b617865206d65726368616e74206973206e6f7420656e61626c6564006044820152606490fd5b60409061375161045c93959461177c60608401976000850190610778565b0160009052565b1561375f57565b60405162461bcd60e51b815260206004820152603560248201527f53656e646572206973206e6f742064656c65676174656420746f206d696e742060448201527437b7103132b430b6331037b3103932b1b2b4bb32b960591b6064820152608490fd5b610472913691610b37565b156137d457565b60405162461bcd60e51b815260206004820152601960248201527813585b9859d95b595b9d081c185e5b595b9d0819985a5b1959603a1b6044820152606490fd5b94955090919261382e613829610194611df8565b6136e7565b613837336104b3565b613840866104b3565b036138e5575b61385995613853916137c2565b93614cd2565b6138ac60008061387261386c6002610881565b8561164e565b613882611cad611c9d838861132c565b61388d6101926116d0565b9061389760405190565b90818003925af16138a66116e7565b506137cd565b8034116138b65750565b60008061045c926138d36138cc61184233610f25565b913461132c565b60405190818003925af1611cdf6116e7565b6139116118427f0000000000000000000000000000000000000000000000000000000000000000610f25565b95863b15611a9757602061392460405190565b97889063e839bd5360e01b825281806139418b3360048401613733565b03915afa918215611a9257613965613853936138599960009161396e575b50613758565b91509550613846565b613987915060203d60201161325b5761324d8183610ad5565b3861395f565b9061045c9695949392916136be565b61045c906139a8613fed565b6139f9565b156139b457565b60405162461bcd60e51b815260206004820152601a60248201527f496e76616c6964206d616e6167656d656e7420616464726573730000000000006044820152606490fd5b61045c90613a1d613a0d6113f660006130b2565b613a16836104b3565b14156139ad565b610192612ddb565b61045c9061399c565b61045c90613a3a613fed565b61045c90610194611e57565b61045c90613a2e565b61045c90613a5b613fed565b6000611f6061045c92610195613a77612f86611f518484610f2e565b610f2e565b61045c90613a4f565b61045c90613a91613fed565b613af1565b15613a9d57565b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b61045c906130c8613b056113f660006130b2565b613b0e836104b3565b1415613a96565b61045c90613a85565b01918252565b6104729161260d565b6001600160e81b03191690565b613b2d613b476104729290565b60e81b90565b61047262ffd700613b3a565b15613b6057565b60405162461bcd60e51b8152602060048201526013602482015272092dcecc2d8d2c840dad2dcd2dcce40d0c2e6d606b1b6044820152606490fd5b91613be7613bf392600094613bdb602097613bb4600090565b506040519586948a8601948592613b1e6020610a2994613b1e8288613b1e829b9a83999052565b90810382520382610ad5565b60405191829182613b24565b039060025afa15611a92576000519061045c613c0e83613b2d565b613c2a613c1c613b2d613b4d565b916001600160e81b03191690565b14613b59565b80546000939291613c4d613c4383612b8a565b8085529360200190565b9160018116908115613c9f5750600114613c6657505050565b613c799192939450600052602060002090565b916000925b818410613c8b5750500190565b805484840152602090930192600101613c7e565b92949550505060ff1916825215156020020190565b9061047291613c30565b9061045c613cd892613ccf60405190565b93848092613cb4565b0383610ad5565b6104726060610afb565b9061045c613d206002613cfa613cdf565b94613d0b613d0782613cbe565b8752565b613d1a61200360018301613cbe565b01613cbe565b6040840152565b61047290613ce9565b613e11600498966126f06012613dba6126f099600d613da2613e599b613e8f9f9b613d846013916010613d696126f09f9e60039f61260d565b6f7b226e616d65223a20225069636b202360801b81526126a5565b72111610113232b9b1b934b83a34b7b7111d101160691b81526126a5565b6c1116101134b6b0b3b2911d101160991b81526126a5565b71222c202261747472696275746573223a205b60701b8152017f7b2274726169745f74797065223a2022546f74616c204f726573204d696e656481526b0111610113b30b63ab2911d160a51b6020820152602c0190565b6203e96160ed1b8152017f7b2274726169745f74797065223a2022546f74616c20476f6c64204d696e656481526b0111610113b30b63ab2911d160a51b6020820152602c0190565b7f7d2c207b2274726169745f74797065223a202254797065222c202276616c7565815263111d101160e11b602082015260240190565b63227d5d7d60e01b81520190565b92946128dc929796919461045c96613eb460405190565b998a97602089019788613d30565b613f46613f4161047261047293613ed7606090565b50613ee06125ea565b90613ef8613ef361013361344e8461326b565b613d27565b90613f028161442b565b60208301516040840151916000613f38613f2a611357613f2f613f2a6113578a61019661088e565b61442b565b9761019761088e565b95015195613e9d565b6146c7565b610472613f5260405190565b8092613bdb6020830191826128e8565b6104726301406f40610881565b610472613f7d61019361130c565b611af3613f62565b61045c611cad613f9661019361130c565b3490611668565b15613fa457565b60405162461bcd60e51b8152806113ab600482016020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b61045c613ff86132e0565b6140046113fb336104b3565b14613f9d565b6104726002610881565b1561401b57565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b61045c61406d60c961130c565b61408161407861400a565b91821415614014565b60c9611794565b6104726001610881565b61045c614081614088565b156140a457565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b61045c6140ea611b97612dae565b61409d565b7f000000000000000000000000000000000000000000000000000000000000000090565b7f000000000000000000000000000000000000000000000000000000000000000090565b906141446113f630610f25565b61414d836104b3565b1480156141e9575b80156141cc575b6141c55760008061416c60405190565b60009084865af19161417c6116e7565b50821561418857505090565b6141bf6141b57f9e32a39d1582a00a2c4d76cef332ee741c4ec2ed801c796519038d51099b7e6192610f25565b9261049d60405190565b0390a290565b5050600090565b506141da6113f660006130b2565b6141e3836104b3565b1461415c565b506141f561dead6104b3565b6141fe836104b3565b14614155565b6104726000614214610472612b38565b016116d0565b5061045c614814565b6104727f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143610881565b9050519061045c82610441565b90602082820312610475576104729161424c565b1561427457565b60405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608490fd5b91906142e360006142dd610472614223565b01611df8565b156142f357505061045c90614f54565b6142ff61184284610f25565b803b15611a9757602061431160405190565b6352d1902d60e01b815291829060049082905afa600091816143b1575b50614390575060405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608490fd5b926143ac61045c946143a6611654610472612b38565b1461426d565b614eb6565b6143d491925060203d6020116143db575b6143cc8183610ad5565b810190614259565b903861432e565b503d6143c2565b6143ea614fbf565b61045c6143f9600060fb611e57565b7f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa61333a33610fc7565b61045c6143e2565b61443481614fcf565b90614445600192610a296001610881565b918061445084612202565b936020018401905b614463575b50505090565b81156144b3576144979060001901926f181899199a1a9b1b9c1cb0b131b232b360811b600a82061a8453611af3600a610881565b90816144a66116546000610881565b146144b357909181614458565b61445d565b906144c1825190565b81101561156d570160200190565b8015611339576000190190565b610472906144f06116546104729460ff1690565b901c90565b156144fc57565b60405162461bcd60e51b8152806113ab600482016020808252818101527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604082015260600190565b90919061456c61223361455c85611c936002610881565b6145666002610881565b90611668565b906000603061458361457d83610881565b856144b8565b53600f60fb1b6145bc6145b36001978893851a6145a86145a286610881565b896144b8565b53611c936002610881565b61456683610881565b905b6145e0575b50610472939450906145da61165461047293610881565b146144f5565b916145ea86610881565b831115614658576f181899199a1a9b1b9c1cb0b131b232b360811b61460f600f610881565b821690601082101561156d57879261462f61464c92614652941a60f81b90565b851a61463b87896144b8565b5361464660046134c8565b906144dc565b936144cf565b906145be565b916145c3565b61466860406116da565b7f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208201527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f604082015290565b61047261465e565b6104726146b7565b80516146d66116546000610881565b146147a8576146e36146bf565b906146ef61455c825190565b906001614712612233614708600395611af36003610881565b611c936004610881565b9301916020840192829183518401925b838110614760575050505060039051068060011461474f57600214614745575090565b6001603d91035390565b50600281603d600181940353035390565b8160019196929394960191603f828080865194848660121c168a01518153018385600c1c16890151815301828460061c16880151815301911685015181530194929190614722565b506104726125ea565b156147b857565b60405162461bcd60e51b815260206004820152602e60248201527f4f6e6c792074686520636f6e7472616374206f776e65722063616e2063616c6c60448201526d103a3434b990333ab731ba34b7b760911b6064820152608490fd5b61045c6148226113f66132e0565b61482b336104b3565b146147b1565b1561483857565b60405162461bcd60e51b815260206004820152601660248201527527232a103737ba1037bbb732b210313c9036b4b732b960511b6044820152606490fd5b1561487d57565b60405162461bcd60e51b815260206004820152601e60248201527f4e4654206d696e696e6720636f6f6c646f776e206e6f742070617373656400006044820152606490fd5b61047260a0610afb565b6104726040610afb565b60016148f6602061045c946123e96148f060008301611752565b86612ddb565b9101611794565b9061045c916148d6565b92939161491661184285610f25565b90813b15611a9757602061492960405190565b6331a9108f60e11b81526004810185905292839060249082905afa958615611a9257614a1a976149f0614a22966149e96149f9946149c56149be8a611f5b6104729f8f90614990906149fe9e600091614a27575b5061498a6113fb336104b3565b14614831565b610166613a776149aa61345461135787611f5b8787610f2e565b6149b861165461047261516c565b11614876565b4290611794565b6149e26149d06148c2565b976149db338a61161b565b6020890152565b6040870152565b6060850152565b15156080830152565b615271565b959091614a13614a0c6148cc565b958661161b565b6020850152565b61016861088e565b6148fd565b614a40915060203d602011611a8b57611a7d8183610ad5565b3861497d565b614a67614a61614a5660976116d0565b611842846097612ddb565b91610f25565b907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0614a9260405190565b8080612495565b614aa16140dc565b61045c614ab0600160fb611e57565b7f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861333a33610fc7565b61045c614a99565b3b614af06116546000610881565b1190565b15614afb57565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b614b66614b6160006114a0565b614af4565b61045c61045c615418565b61045c614b54565b614b86614b6160006114a0565b61045c61045c61542d565b61045c614b79565b614ba6614b6160006114a0565b61045c61045c615451565b61045c614b99565b61045c90614bca614b6160006114a0565b61045c90610134612ddb565b61045c90614bb9565b614bec614b6160006114a0565b61045c61045c612dc46018610881565b61045c614bdf565b15614c0b57565b60405162461bcd60e51b8152602060048201526014602482015273496e76616c6964207069636b617865207479706560601b6044820152606490fd5b15614c4e57565b60405162461bcd60e51b815260206004820152601060248201526f496e76616c6964207175616e7469747960801b6044820152606490fd5b15614c8d57565b60405162461bcd60e51b815260206004820152601d60248201527f4e6f207069636b6178657320617661696c61626c6520746f206d696e740000006044820152606490fd5b909293611b1094614ce1600090565b5084600194614cfa614cf36001610881565b8311614c04565b84600093614d0785610881565b831180614e9e575b614d1890614c47565b8295614d296113578661013261088e565b93614d3e61013195611365611357898961088e565b908110614e94575b50614d529082846154d1565b614d66610130916113656113578585610f2e565b808711614e8a575b5091611f5b614da7614dc19593614db495614d92614d8b8a610881565b8b11614c86565b613a77614da28b611c9389615578565b9e8f90565b612fcc88611ca88361130c565b612fcc84611ca88361130c565b614dcf611842611842614113565b803b15611a975782602091614e079584614de860405190565b809881958294614dfc6340c10f1960e01b90565b8452600484016122a0565b03925af1928315611a9257600093614e65575b50614e258491610881565b905b614e34575b505050505090565b81811015614e6057614e5a90614e5486611f0361012f61344e8589611668565b60010190565b83614e27565b614e2c565b614e25919350614e839060203d6020116143db576143cc8183610ad5565b9290614e1a565b9550611f5b614d6e565b9650614d52614d46565b50614d18614eac600a610881565b8411159050614d0f565b91614ec08361558d565b8151614ecf6116546000610881565b11908115614eea575b50614ee1575050565b612fe691615670565b905038614ed8565b15614ef957565b60405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b61045c90614f69614f6482614ae2565b614ef2565b6000614f76610472612b38565b01612ddb565b15614f8357565b60405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606490fd5b61045c614fca612dae565b614f7c565b614fd96000610881565b9072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b614ffa81610881565b82101561514a575b506d04ee2d6d415b85acef810000000061501b81610881565b821015615128575b50662386f26fc1000061503581610881565b821015615106575b506305f5e10061504c81610881565b8210156150e4575b5061271061506181610881565b8210156150c2575b506150746064610881565b8110156150a0575b615089611654600a610881565b10156150925790565b61047290610a296001610881565b6150b16150bc91611af36064610881565b91610a296002610881565b9061507c565b6150dd91611af36150d292610881565b91610a296004610881565b9038615069565b6150ff91611af36150f492610881565b91610a296008610881565b9038615054565b61512191611af361511692610881565b91610a296010610881565b903861503d565b61514391611af361513892610881565b91610a296020610881565b9038615023565b61516591611af361515a92610881565b91610a296040610881565b9038615002565b61047261517a61016161130c565b611b22610e10610881565b906117a461047261144f9290565b60096148f661012061045c946151ae6148f060008301611752565b6151c56151bc602083015190565b60018701615185565b6151dc6151d3604083015190565b60028701611794565b6151f36151ea606083015190565b60038701611794565b61520a615201608083015190565b60048701611794565b61522161521860a083015190565b60058701611794565b61523861522f60c083015190565b60068701611794565b61524f61524660e083015190565b60078701611794565b6123e961525e61010083015190565b60088701611794565b9061045c91615193565b9061527b826156fd565b92602081019061528c610ebf835190565b9260408201956152a361529d885190565b86615862565b9590976152c06152b88a611ca861016061130c565b610160611794565b6152ce6118426118426140ef565b96856152d981611752565b98803b15611a975761530e60209160009b6152f360405190565b9c8d9384928391906335313c2160e11b835260048301610f9c565b03925af1988915611a92576000996153dc575b5061532b90611752565b606090960151875192519561533e611f74565b97615349908961161b565b6020880152615359426040890152565b6060870152608086015260a085015260c084015260e083015261010082015261538485610120830152565b61539083610162611794565b61539c8361016761088e565b906153a691615267565b816101646153b2835190565b6153bb9161088e565b906153c591611794565b516153d29061016561088e565b4261165491611794565b61532b9199506153fa9060203d6020116143db576143cc8183610ad5565b9890615321565b61540e614b6160006114a0565b61045c8033614a46565b61045c615401565b61147a614b6160006114a0565b61045c615420565b615442614b6160006114a0565b61045c61045c600060fb611e57565b61045c615435565b90815260608101939261045c9290916040916117869061177c565b6020809392613b1e61151a610a299461190160f01b815260020190565b1561549857565b60405162461bcd60e51b8152602060048201526011602482015270496e76616c6964207369676e617475726560781b6044820152606490fd5b91613bdb6155506155619361552461045c9661550a7f6e12393101ad1c70176b60a4035d41979b99db2b38474e0ac20e7fd93005302790565b613bdb61551660405190565b948593602085019384615459565b61553661552f825190565b9160200190565b2061553f615997565b604051938492602084019283615474565b61555b61552f825190565b20615a19565b6155726113fb6113f66101346116d0565b14615491565b61047290611b22671bc16d674ec80000610881565b61559a9061184281614f54565b7fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b6155c460405190565b600090a2565b156155d157565b60405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608490fd5b61562f60276116da565b7f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c6020820152660819985a5b195960ca1b604082015290565b610472615625565b6000610472928192615680606090565b5061569261568d82614ae2565b6155ca565b602082519201905af46156a36116e7565b6156ab615668565b91615a2e565b156156b857565b60405162461bcd60e51b815260206004820152601a60248201527f5069636b617865206e6f74206f776e6564206279206d696e65720000000000006044820152606490fd5b9061570e611b976080840151151590565b615779575b611654826020615769940190615727825190565b9061574b6040820192606061573a855190565b930192615745845190565b91615b44565b61577361576e61576261135761016461344e885190565b9788955190565b935190565b915190565b91613b9b565b615787611842611842614113565b91615793602082015190565b92803b15611a97576157bf936020916157ab60405190565b958692839182916331a9108f60e11b611887565b03915afa908115611a92576157f361165492615769956000916157fb575b506157ed6113fb6113f685611752565b146156b1565b925050615713565b615814915060203d602011611a8b57611a7d8183610ad5565b386157dd565b1561582157565b60405162461bcd60e51b8152602060048201526019602482015278139bc81b5bdc994819dbdb190818d85b881899481b5a5b9959603a1b6044820152606490fd5b90919061587061016061130c565b6158b66158ab61587e613f62565b9561588a87851061581a565b611b226158a0615898613407565b928397611625565b91611c986064610881565b611af36103e8610881565b93846158c28382611668565b8210156158d957506158d69293945061132c565b91565b6158ea90611c98848497969761132c565b6158f76116546064610881565b10615900575050565b6158d692945061132c565b615915600f6116da565b6e141a58dad85e1953595c98da185b9d608a1b602082015290565b61047261590b565b61594260016116da565b603160f81b602082015290565b610472615938565b9095949261045c946159896159909261598260809661597b60a088019c6000890152565b6020870152565b6040850152565b6060830152565b0190610778565b61599f615930565b6159aa61552f825190565b20615a0a6159b661594f565b6159c161552f825190565b20916159cc30610f25565b92613bdb6159d960405190565b948593602085019346917f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f86615957565b615a1561552f825190565b2090565b61047291615a2691615c02565b919091615c75565b90919015615a3a575090565b90615daf565b6104726103e8610881565b61047261270f610881565b15615a5d57565b60405162461bcd60e51b8152602060048201526012602482015271496e76616c696420676f6c6420726174696f60701b6044820152606490fd5b15615a9e57565b60405162461bcd60e51b815260206004820152601060248201526f496e76616c696420617474656d70747360801b6044820152606490fd5b610472610748610881565b61047261115c610881565b15615af357565b60405162461bcd60e51b815260206004820152602360248201527f546f6f206d616e7920617474656d7074732073696e6365206c617374206d696e604482015262696e6760e81b6064820152608490fd5b611654610472615bc0615bb961045c96611ca8615bb1615ba8611357615bc899615b998c615b85615b73615a40565b91828110159081615bea575b50615a56565b610472615b926000610881565b8911615a97565b8c11615bcf575b61016561088e565b98611c98615a4b565b611b22615ad6565b944261132c565b611b22615ae1565b1115615aec565b615be5615bdd610472615ad6565b871115615a97565b615ba0565b9050615bfa611654610472615a4b565b11158f615b7f565b908051615c126116546041610881565b03615c3457610646916020820151906060604084015193015160001a90615e1f565b5050615c4060006130b2565b90600290565b634e487b7160e01b600052602160045260246000fd5b60051115615c6657565b615c46565b9061045c82615c5c565b615c7f6000615c6b565b615c8882615c6b565b03615c905750565b615c9a6001615c6b565b615ca382615c6b565b03615ce85760405162461bcd60e51b815260206004820152601860248201527745434453413a20696e76616c6964207369676e617475726560401b6044820152606490fd5b615cf26002615c6b565b615cfb82615c6b565b03615d455760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606490fd5b615d58615d526003615c6b565b91615c6b565b14615d5f57565b60405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608490fd5b90615db8825190565b615dc56116546000610881565b1115615dd45750805190602001fd5b6113ab90615de160405190565b62461bcd60e51b815291829160048301610a2d565b61178661045c94610d0d606094989795615e15608086019a6000870152565b60ff166020850152565b919291615e2b83612604565b615e4d6116546fa2a8918ca85bafe22016d0b997e4df60600160ff1b03610881565b11615ead57615e6d600093602095615e6460405190565b94859485615df6565b838052039060015afa15611a9257600051615e8860006130b2565b615e91816104b3565b615e9a836104b3565b14615ea6575090600090565b9160019150565b50505050615ebb60006130b2565b9060039056fe414249206465636f64696e673a20696e76616c69642063616c6c646174612061a26469706673582212200a33f1850f3549acce32eb1ac5f0b221986f697769219acd4a5eed5b5270e9ee64736f6c634300081c0033000000000000000000000000aa93f7f16a8069aafb60254612416b3cdf818be000000000000000000000000071f746615cbfdbd4805d788dfc11d4960ddc4eea00000000000000000000000000000000000000447e69651d841bd8d104bed493
Deployed Bytecode
0x6080604052600436101561001d575b366112a95761001b613f85565b005b60003560e01c8063141b0dc11461033d578063150b7a02146103385780631747ea12146103335780631a483f741461032e5780632c3f6bba14610329578063313f82aa14610324578063362917261461031f5780633659cfe61461031a5780633a503f9f146103155780633b74a185146103105780633f4ba83a1461030b57806346a5440914610306578063495396bd146103015780634a7ccd3e146102fc5780634be68445146102f75780634f1ef286146102f257806352d1902d146102ed57806359d006b8146102e85780635bd156e9146102e35780635c975abb146102de57806360bf8f2b146102d95780636c19e783146102d45780636c656086146102cf5780636cce5bf9146102ca578063715018a6146102c55780637d854bc7146102c05780637e3ee3b0146102bb5780637f128135146102b65780638456cb59146102b157806389805224146102ac5780638a89f2b3146102a75780638da5cb5b146102a25780639bc737191461029d578063ae7ec0f714610298578063b21ec4b114610293578063b40b9bb61461028e578063be8eb67e14610289578063bfd8121714610284578063bfe29cbf1461027f578063c4d66de81461027a578063d090c63f14610275578063d4a22bde14610270578063d9cc59821461026b578063dda3c2ee14610266578063e08ac27f14610261578063f2fde38b1461025c578063f4429c3314610257578063f760794414610252578063fa3229351461024d5763fc4172e80361000e5761128e565b611266565b61124b565b61122c565b6111df565b6111c4565b61119f565b611187565b61116f565b611155565b6110cf565b6110b4565b611088565b611060565b611038565b61101f565b610feb565b610fd3565b610fac565b610f80565b610f49565b610ef0565b610ed5565b610ea9565b610e91565b610e79565b610e5d565b610df6565b610dc7565b610daf565b610d94565b610d79565b610d53565b610bcf565b610bbb565b610a3e565b6109a5565b61095a565b61092e565b610905565b6108ed565b6108d2565b610869565b61082e565b610762565b61073c565b610728565b6106b7565b610663565b61047e565b608461034d60405190565b62461bcd60e51b815260206004820152602260248201527f45746865722073656e7420746f206e6f6e2d70617961626c652066756e63746960448201526137b760f11b6064820152fd5b60846103a260405190565b62461bcd60e51b815260206004820152602260248201527f414249206465636f64696e673a207475706c65206461746120746f6f2073686f6044820152611c9d60f21b6064820152fd5b60846103f760405190565b62461bcd60e51b815260206004820152602260248201527f414249206465636f64696e673a20696e76616c6964207475706c65206f666673604482015261195d60f21b6064820152fd5b805b0361044a57565b600080fd5b9050359061045c82610441565b565b90602082820312610475576104729161044f565b90565b610397565b9052565b346104ae576104aa61049961049436600461045e565b61133e565b6040515b9182918290815260200190565b0390f35b610342565b6001600160a01b031690565b610443816104b3565b9050359061045c826104bf565b60846104e060405190565b62461bcd60e51b815260206004820152602b6024820152600080516020615ec283398151915260448201526a1c9c985e481bd9999cd95d60aa1b6064820152fd5b608461052c60405190565b62461bcd60e51b815260206004820152602b6024820152600080516020615ec283398151915260448201526a0e4e4c2f240d8cadccee8d60ab1b6064820152fd5b608461057860405190565b62461bcd60e51b815260206004820152602b6024820152600080516020615ec283398151915260448201526a727261792073747269646560a81b6064820152fd5b909182601f830112156105f2578135916001600160401b0383116105ed5760200192600183028401116105e857565b61056d565b610521565b6104d5565b906080828203126104755761060c81836104c8565b9261061a82602085016104c8565b92610628836040830161044f565b9260608201356001600160401b03811161064a5761064692016105b9565b9091565b6103ec565b6001600160e01b0319909116815260200190565b346104ae576104aa6106826106793660046105f7565b939290926113d5565b6040519182918261064f565b801515610443565b9050359061045c8261068e565b906020828203126104755761047291610696565b346104ae576106cf6106ca3660046106a3565b61145f565b604051005b909182601f830112156105f2578135916001600160401b0383116105ed5760200192602083028401116105e857565b906020828203126104755781356001600160401b03811161064a5761064692016106d4565b6106cf610736366004610703565b90611d21565b346104ae576104aa61049961075236600461045e565b611d2b565b600091031261047557565b61076d366004610757565b6104aa610499611f6a565b61047a906104b3565b906101208061045c9361079c60008201516000860190610778565b6107ab60208201516020860152565b6107ba60408201516040860152565b6107c960608201516060860152565b6107d860808201516080860152565b6107e760a082015160a0860152565b6107f660c082015160c0860152565b61080560e082015160e0860152565b610816610100820151610100860152565b0151910152565b6101408101929161045c9190610781565b346104ae576104aa61084961084436600461045e565b6120bc565b6040519182918261081d565b9060208282031261047557610472916104c8565b346104ae576106cf61087c366004610855565b61223e565b6104726104726104729290565b9061089890610881565b600052602052604060002090565b610472916008021c81565b9061047291546108a6565b60006108cd6104729261019661088e565b6108b1565b346104ae576104aa6104996108e836600461045e565b6108bc565b346104ae576106cf61090036600461045e565b6125bc565b346104ae57610915366004610757565b6106cf6125d8565b60006108cd6104729261016561088e565b346104ae576104aa61049961094436600461045e565b61091d565b60006108cd6104729261019761088e565b346104ae576104aa61049961097036600461045e565b610949565b610472916008021c5b60ff1690565b906104729154610975565b60006109a06104729261019961088e565b610984565b346104ae576104aa6109c06109bb36600461045e565b61098f565b60405191829182901515815260200190565b60005b8381106109e55750506000910152565b81810151838201526020016109d5565b610a16610a1f602093610a2993610a0a815190565b80835293849260200190565b958691016109d2565b601f01601f191690565b0190565b6020808252610472929101906109f5565b346104ae576104aa610a59610a5436600461045e565b612918565b60405191829182610a2d565b6084610a7060405190565b62461bcd60e51b815260206004820152602760248201527f414249206465636f64696e673a20696e76616c69642062797465206172726179604482015266040d8cadccee8d60cb1b6064820152fd5b634e487b7160e01b600052604160045260246000fd5b90601f01601f191681019081106001600160401b03821117610af657604052565b610abf565b9061045c610b0860405190565b9283610ad5565b6001600160401b038111610af657602090601f01601f19160190565b90826000939282370152565b90929192610b4c610b4782610b0f565b610afb565b9381855281830111610b665761045c916020850190610b2b565b610a65565b9080601f830112156105f25781602061047293359101610b37565b91909160408184031261047557610b9d83826104c8565b9260208201356001600160401b03811161064a576104729201610b6b565b6106cf610bc9366004610b86565b90612a7a565b346104ae57610bdf366004610757565b6104aa610499612b6a565b6084610bf560405190565b62461bcd60e51b815260206004820152602360248201527f414249206465636f64696e673a20737472756374206461746120746f6f2073686044820152621bdc9d60ea1b6064820152fd5b6084610c4b60405190565b62461bcd60e51b815260206004820152602360248201527f414249206465636f64696e673a20696e76616c696420737472756374206f66666044820152621cd95d60ea1b6064820152fd5b919091606081840312610d1957610cad6060610afb565b9281356001600160401b038111610d145781610cca918401610b6b565b845260208201356001600160401b038111610d145781610ceb918401610b6b565b602085015260408201356001600160401b038111610d1457610d0d9201610b6b565b6040830152565b610c40565b610bea565b91909160408184031261047557610d35838261044f565b9260208201356001600160401b03811161064a576104729201610c96565b346104ae576106cf610d66366004610d1e565b90612d91565b610472600061019c6108b1565b346104ae57610d89366004610757565b6104aa610499610d6c565b346104ae57610da4366004610757565b6104aa6109c0612dae565b346104ae576106cf610dc236600461045e565b612db8565b346104ae576106cf610dda366004610855565b612df2565b90610898565b60006108cd61047292610163610ddf565b346104ae576104aa610499610e0c36600461045e565b610de5565b919060a08382031261047557610e2781846104c8565b92610e35826020830161044f565b92610472610e46846040850161044f565b936080610e56826060870161044f565b940161044f565b346104ae576106cf610e70366004610e11565b93929092613088565b346104ae57610e89366004610757565b6106cf6130cd565b346104ae576106cf610ea4366004610855565b613262565b346104ae576104aa610499610ebf36600461045e565b61326b565b60006108cd6104729261016461088e565b346104ae576104aa610499610eeb36600461045e565b610ec4565b346104ae57610f00366004610757565b6106cf6132bc565b610472906104b3906001600160a01b031682565b61047290610f08565b61047290610f1c565b9061089890610f25565b60006108cd61047292610130610f2e565b346104ae576104aa610499610f5f366004610855565b610f38565b919060408382031261047557610472906020610e5682866104c8565b346104ae576104aa610499610f96366004610f64565b906132c4565b60208101929161045c9190610778565b346104ae57610fbc366004610757565b6104aa610fc76132e0565b60405191829182610f9c565b346104ae57610fe3366004610757565b6106cf6132ea565b346104ae576106cf610ffe36600461045e565b613357565b919060408382031261047557610472906020610e56828661044f565b346104ae576106cf611032366004611003565b906133d2565b346104ae57611048366004610757565b6104aa610499613407565b610472600061015f610984565b346104ae57611070366004610757565b6104aa6109c0611053565b61047260006101916108b1565b346104ae57611098366004610757565b6104aa61049961107b565b60006108cd61047292610198610f2e565b346104ae576104aa6104996110ca366004610855565b6110a3565b346104ae576106cf6110e2366004610855565b6136b5565b9060c082820312610475576110fc81836104c8565b9261110a826020850161044f565b92611118836040830161044f565b92611126816060840161044f565b9260808301356001600160401b03811161064a578261114c60a0946104729387016105b9565b94909501610696565b6106cf6111633660046110e7565b9594909493919361398d565b346104ae576106cf611182366004610855565b613a25565b346104ae576106cf61119a3660046106a3565b613a46565b346104ae576106cf6111b2366004610855565b613a7c565b61047260006101936108b1565b346104ae576111d4366004610757565b6104aa6104996111b7565b346104ae576106cf6111f2366004610855565b613b15565b6080818303126104755761120b828261044f565b9261047261121c846020850161044f565b936060610e56826040870161044f565b346104ae576104aa6104996112423660046111f7565b92919091613b9b565b346104ae576104aa610a5961126136600461045e565b613ec2565b346104ae57611276366004610757565b6104aa610499613f6f565b61047260006101606108b1565b346104ae5761129e366004610757565b6104aa610499611281565b60846112b460405190565b62461bcd60e51b815260206004820152602960248201527f556e6b6e6f776e207369676e617475726520616e64206e6f2066616c6c6261636044820152681ac81919599a5b995960ba1b6064820152fd5b6104729081565b6104729054611305565b634e487b7160e01b600052601160045260246000fd5b9190820391821161133957565b611316565b6104729061136561135761135c6113578461013261088e565b61130c565b9261013161088e565b9061132c565b1561137257565b60405162461bcd60e51b815260206004820152601060248201526f24b73b30b634b21037b832b930ba37b960811b604482015280606481015b0390fd5b6113c86113c26104729263ffffffff1690565b60e01b90565b6001600160e01b03191690565b9250505061140791506113e6600090565b506114016113fb6113f630610f25565b6104b3565b916104b3565b1461136b565b61047263150b7a026113af565b61045c90611420613fed565b611453565b9061ff009060081b5b9181191691161790565b9061144861047261144f92151590565b8254611425565b9055565b61045c90610194611438565b61045c90611414565b9061147a91611475614060565b611482565b61045c614092565b9061045c9161148f6140dc565b6117e7565b6104729060081c61097e565b6104729054611494565b156114b157565b60405162461bcd60e51b815260206004820152601b60248201527f4f7265206d65726368616e74206973206e6f7420656e61626c656400000000006044820152606490fd5b6001600160401b038111610af65760208091020190565b9061151a610b47836114f6565b918252565b369037565b9061045c61153a6115348461150d565b936114f6565b601f19016020840161151f565b634e487b7160e01b600052603260045260246000fd5b919081101561156d576020020190565b611547565b3561047281610441565b608461158760405190565b62461bcd60e51b815260206004820152602560248201527f54617267657420636f6e747261637420646f6573206e6f7420636f6e7461696e60448201526420636f646560d81b6064820152fd5b9050519061045c826104bf565b9060208282031261047557610472916115d4565b6040513d6000823e3d90fd5b9061160a825190565b81101561156d576020809102010190565b9061047a906104b3565b8181029291811591840414171561133957565b634e487b7160e01b600052601260045260246000fd5b90611658565b9190565b908115611663570490565b611638565b9190820180921161133957565b60001981146113395760010190565b1561168b57565b60405162461bcd60e51b8152602060048201526014602482015273125b9cdd59999a58da595b9d081c185e5b595b9d60621b6044820152606490fd5b610472906104b3565b61047290546116c7565b9061151a610b4783610b0f565b3d15611701576116f63d6116da565b903d6000602084013e565b606090565b1561170d57565b60405162461bcd60e51b815260206004820152601c60248201527f526576656e7565207368617265207061796d656e74206661696c6564000000006044820152606490fd5b61047290516104b3565b60409061178661045c949695939661177c60608401986000850190610778565b6020830190610778565b0152565b906000199061142e565b906117a461047261144f92610881565b825461178a565b156117b257565b60405162461bcd60e51b815260206004820152600d60248201526c1499599d5b990819985a5b1959609a1b6044820152606490fd5b6117fa6117f56101946114a0565b6114aa565b60009061180682610881565b9083908261181383611524565b9261181d87611524565b9261182788611524565b968399845b8a811015611aba576118476118426118426140ef565b610f25565b636352211e9061186061185b84898961155d565b611572565b90803b15611a97576118959160209161187860405190565b80809581946118878960e01b90565b835260048301526024820190565b03915afa908115611a9257600091611a9c575b506118b86113fb6113f630610f25565b146118c7575b5060010161182c565b6118e96118dc61185b989e9b9884898961155d565b6118e68c8c611601565b52565b6118fa61084461185b84898961155d565b9061191460a061190e611842611842614113565b93015190565b823b15611a975761193b9261188760209361192e60405190565b9586948593849360e01b90565b03915afa908115611a9257600091611a64575b506119598a8c611601565b906119639161161b565b61196e81868661155d565b61197790611572565b61198090611d2b565b9b8c61198c6005610881565b6119969082611625565b6119a06064610881565b6119a99161164e565b6119b38c8b611601565b526119bd91611668565b958c61019b6119cd84898961155d565b6119d690611572565b6119df9161088e565b6119e89061130c565b6119f19161132c565b6119fa91611668565b98611a0490611675565b9b611a1082878761155d565b611a1990611572565b611a2290610881565b611a2b33610f25565b91611a3560405190565b9081527f176bc82be3934df3915f77a103b930d01d585f6112985e08d53c9bbbca1e643290602090a3386118be565b611a85915060203d8111611a8b575b611a7d8183610ad5565b8101906115e1565b3861194e565b503d611a73565b6115f5565b61157c565b611ab4915060203d8111611a8b57611a7d8183610ad5565b386118a8565b50939250969498975050611acd86610881565b8714611ce557611af9611ae9611ae36014610881565b83611625565b611af36064610881565b9061164e565b94611b28611ae9611b0a8885611668565b93611b18855b341015611684565b611b226005610881565b90611625565b90611b518880611b396101926116d0565b60405160009187905af1611b4b6116e7565b50611706565b611b5a88610881565b96875b8a5b811015611c625780611b9b611b978a611b92611b8d611b85611b81878f611601565b5190565b958693611601565b611752565b614137565b1590565b611c51575b50611baf6118426118426140ef565b908c611bc7611b8183611bc130610f25565b93611601565b833b15611a9757611bff938d9283611bde60405190565b809781958294611bf26342842e0e60e01b90565b845233906004850161175c565b03925af1908115611a9257611b5f92611c1e92611c25575b5060010190565b9050611b5d565b611c44908d803d10611c4a575b611c3c8183610ad5565b810190610757565b38611c17565b503d611c32565b611c5b9199611668565b9738611ba0565b50611cb59792949a50611365939950611cad9650611c9d9550611c9891611c8891611668565b93611c936002610881565b611625565b61132c565b611ca861019361130c565b611668565b610193611794565b813411611cc0575050565b80611cce61045c933461132c565b604051600091335af1611cdf6116e7565b506117ab565b60405162461bcd60e51b81526020600482015260146024820152734e6f206f7265206368756e6b7320746f2062757960601b6044820152606490fd5b9061045c91611468565b611d4061047291611d3a600090565b506120bc565b611b22610120611d4e613f6f565b92015190565b61047290611d606140dc565b611e6e565b15611d6c57565b60405162461bcd60e51b815260206004820152601a60248201527f5069636b6178652072656e74616c206e6f7420656e61626c65640000000000006044820152606490fd5b15611db857565b60405162461bcd60e51b815260206004820152600f60248201526e125b9d985b1a59081c185e5b595b9d608a1b6044820152606490fd5b6104729061097e565b6104729054611def565b15611e0957565b60405162461bcd60e51b815260206004820152601f60248201527f416c72656164792072656e746564207069636b617865206e6f742075736564006044820152606490fd5b9060ff9061142e565b90611e6761047261144f92151590565b8254611e4e565b50611e90611e7d61019161130c565b611e8a6116546000610881565b11611d65565b611ea8611ea161047261019161130c565b3414611db1565b610198611eb86113573383610f2e565b80611ec36000610881565b8103611f32575050611ee9611ee1611edc61019a61130c565b611675565b61019a611794565b611f08611ef761019a61130c565b611f0381933390610f2e565b611794565b611f19611cad611c9d61019161130c565b610472611f2a611edc61019c61130c565b61019c611794565b611f65919250611f60600091610199611f5b611f56611f51848461088e565b611df8565b611e02565b61088e565b611e57565b611f08565b6104726000611d54565b610472610140610afb565b611f87611f74565b906000825260208080808080808080808b01600081520160008152016000815201600081520160008152016000815201600081520160008152016000905250565b610472611f7f565b9061045c6120ab6009611fe1611f74565b94611ff4611fee826116d0565b8761161b565b61200a6120036001830161130c565b6020880152565b6120206120196002830161130c565b6040880152565b61203661202f6003830161130c565b6060880152565b61204c6120456004830161130c565b6080880152565b61206261205b6005830161130c565b60a0880152565b6120786120716006830161130c565b60c0880152565b61208e6120876007830161130c565b60e0880152565b6120a561209d6008830161130c565b610100880152565b0161130c565b610120840152565b61047290611fd0565b6120d4610472916120cb611fc8565b5061016761088e565b6120b3565b156120e057565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608490fd5b1561214157565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608490fd5b61045c906121fd6121ab30610f25565b6121e37f00000000000000000000000008e66799f4daef0403e83640f8d87d9721529313916121dc6113fb846104b3565b14156120d9565b6121f76113fb6121f1614204565b926104b3565b1461213a565b612218565b9061045c61153a612212846116da565b93610b0f565b600061045c916122278161421a565b61223861223383610881565b612202565b906142cb565b61045c9061219b565b61147a90612253614060565b61045c9061225f6140dc565b6122f8565b1561226b57565b60405162461bcd60e51b815260206004820152600d60248201526c2737ba1037b9329037bbb732b960991b6044820152606490fd5b91602061045c92949361178660408201966000830190610778565b156122c257565b60405162461bcd60e51b815260206004820152600e60248201526d14185e5b595b9d0819985a5b195960921b6044820152606490fd5b6123066117f56101946114a0565b61230e6140ef565b9061231b61184283610f25565b90636352211e90823b15611a9757602061233460405190565b80946123408560e01b90565b82526004820184905260249082905afa928315611a925760009361259b575b5061237b61236c336104b3565b612375856104b3565b14612264565b61239b61184261238a83611d2b565b9561184287611f038661019b61088e565b803b15611a975760006123ad60405190565b9182906332b2835f60e21b82528183816123cb888b600484016122a0565b03925af18015611a9257612585575b506123ee60a06123e9836120bc565b015190565b6123f730610f25565b92612403612710610881565b82106124d8575b505061248b612485612495926124806000806124697fee3964a289d03bf62aa9aad77f906aa0bebfa79947a18a57865d1c6384a949de98612449600090565b906124538c6104b3565b61245c826104b3565b0361249a575b508b61132c565b604051600091335af161247a6116e7565b506122bb565b610881565b93610f25565b9361049d60405190565b0390a3565b90506124ad611ae98d611b226005610881565b6124bb611b97828094614137565b1561246257611cad6124d291611ca861019361130c565b38612462565b9092506124e9611842611842614113565b92833b15611a97576125119361188760209361250460405190565b9687948593849360e01b90565b03915afa8015611a92576124856124959261248060008061246961248b967fee3964a289d03bf62aa9aad77f906aa0bebfa79947a18a57865d1c6384a949de998391612566575b50985050505050925061240a565b61257f915060203d602011611a8b57611a7d8183610ad5565b38612558565b612595906000611c3c8183610ad5565b386123da565b6125b591935060203d602011611a8b57611a7d8183610ad5565b913861235f565b61045c90612247565b6125cd613fed565b61045c61045c614423565b61045c6125c5565b61047260006116da565b6104726125e0565b6104729081906001600160a01b031681565b61047290610881565b610a296126259260209261261f815190565b94859290565b938491016109d2565b976126f06127af612867996126f060039f9d976128a79f9b60106126f09f6126f09d60136127276128259f600d6126f09f6127ea9f6127609a6126f06126ac8b94601a6126816127459d6126f69761260d565b7f7b226e616d65223a2022476f6c64204f7265204368756e6b202300000000000081525b019061260d565b7f222c20226465736372697074696f6e223a202241206368756e6b206f6620676f815271036321037b9329031b7b73a30b4b734b733960751b602082015260320190565b9061260d565b6f01033b7b6321039b832b1b5b9971116160851b81526c1136b4b732b22fb13c911d101160991b91019081526126a5565b721116101136b4b734b733afb430b9b4111d101160691b81526126a5565b6f1116101136b4b732b22fb0ba111d101160811b81526126a5565b7f222c202261747472696275746573223a205b7b2274726169745f74797065223a81527f2022476f6c64205175616e74697479222c202276616c7565223a2000000000006020820152603b0190565b7f7d2c207b2274726169745f74797065223a20225069636b617865204944222c208152680113b30b63ab2911d160bd1b602082015260290190565b7f7d2c207b2274726169745f74797065223a2022476f6c6420526174696f222c208152680113b30b63ab2911d160bd1b602082015260290190565b7f7d2c207b2274726169745f74797065223a20224d696e696e672044696666696381526f03ab63a3c911610113b30b63ab2911d160851b602082015260300190565b7f7d2c207b2274726169745f74797065223a20224d696e696e6720417474656d7081526d03a39911610113b30b63ab2911d160951b6020820152602e0190565b627d5d7d60e81b81520190565b96919a999461045c99946128dc979299946128ce60405190565b9d8e9b60208d019b8c61262e565b90810382520383610ad5565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c00000081526104729190601d016126f0565b6129206125ea565b9061292d8161016761088e565b612936906120b3565b906129409061442b565b90610120810161294e815190565b6129579061442b565b9061296183611752565b61296a90610f1c565b612973906125f2565b61297d6014610881565b61298691614545565b90612992602085015190565b61299b90612604565b6129a56020610881565b6129ae91614545565b906129ba604086015190565b6129c39061442b565b90516129ce9061442b565b916129da60a087015190565b6129e39061442b565b936129f061010088015190565b6129f99061442b565b95612a05608089015190565b612a0e9061442b565b606090980151612a1d9061442b565b98612a279a6128b4565b612a30906146c7565b60405180916020820190612a4490826128e8565b9081038252036104729082610ad5565b9061045c91612a656121ab30610f25565b61045c91600191612a758161421a565b6142cb565b9061045c91612a54565b15612a8b57565b60405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b6064820152608490fd5b61047290612b33612b0130610f25565b612b2d6113fb7f00000000000000000000000008e66799f4daef0403e83640f8d87d97215293136104b3565b14612a84565b612b61565b6104727f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610881565b50610472612b38565b6104726000612af1565b634e487b7160e01b600052602260045260246000fd5b9060016002830492168015612baa575b6020831014612ba557565b612b74565b91607f1691612b9a565b9160001960089290920291821b911b61142e565b9190612bd961047261144f93610881565b908354612bb4565b61045c91600091612bc8565b818110612bf8575050565b80612c066000600193612be1565b01612bed565b9190601f8111612c1b57505050565b612c2d61045c93600052602060002090565b906020601f840181900483019310612c4f575b6020601f909101040190612bed565b9091508190612c40565b9060001960089091021c191690565b81612c7291612c59565b906002021790565b90612c83815190565b906001600160401b038211610af657612ca682612ca08554612b8a565b85612c0c565b602090601f8311600114612cd45761144f929160009183612cc9575b5050612c68565b015190503880612cc2565b601f19831691612ce985600052602060002090565b9260005b818110612d2857509160029391856001969410612d0e575b50505002019055565b612d1e910151601f841690612c59565b9055388080612d05565b91936020600181928787015181550195019201612ced565b9061045c91612c7a565b6002612d80604061045c94612d69612d63600083015190565b86612d40565b6123e9612d77602083015190565b60018701612d40565b9101612d40565b9061045c91612d4a565b90612da961045c92612da1614814565b61013361088e565b612d87565b61047260fb611df8565b61045c90612dc4614814565b610161611794565b906001600160a01b039061142e565b90612deb61047261144f92610f25565b8254612dcc565b61045c90612dfe614814565b610134612ddb565b9061147a94939291612e16614060565b9061045c94939291612e266140dc565b612f53565b15612e3257565b60405162461bcd60e51b8152602060048201526015602482015274135a5b9a5b99c81a5cc81b9bdd08195b98589b1959605a1b6044820152606490fd5b15612e7657565b60405162461bcd60e51b815260206004820152602e60248201527f4e465420636f6e7472616374206973206e6f7420612076616c6964206d696e6560448201526d1c881391950818dbdb9d1c9858dd60921b6064820152608490fd5b15612ed957565b60405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964207069636b61786560881b6044820152606490fd5b15612f1757565b60405162461bcd60e51b8152602060048201526014602482015273141a58dad85e1948185b1c9958591e481d5cd95960621b6044820152606490fd5b612fa690611b97929395612fe195612f74612f6f61015f611df8565b612e2b565b612f8b612f86611f5185610195610f2e565b612e6f565b87612f97612710610881565b81119687948561304657614907565b612fd2612fb36001610881565b612fcc612fc28861019661088e565b91611ca88361130c565b90611794565b612fcc612fc28661019761088e565b612fe9575b50565b612ff7611842611842614113565b803b15611a975761302560009291839261301060405190565b94859384928391906318c85cf560e11b611887565b03925af18015611a92576130365750565b61045c906000611c3c8183610ad5565b61305f61305861135733610198610f2e565b8414612ed2565b6130836001611f6085610199611f5b61307e611b97611f51858561088e565b612f10565b614907565b9061045c94939291612e06565b61309d613fed565b61045c6130bb565b6104b36104726104729290565b610472906130a5565b61045c6130c860006130b2565b614a46565b61045c613095565b61045c906130e1613fed565b6131a4565b156130ed57565b60405162461bcd60e51b8152602060048201526014602482015273125b9d985b1a59081391950818dbdb9d1c9858dd60621b6044820152606490fd5b9050519061045c8261068e565b906020828203126104755761047291613129565b1561315157565b60405162461bcd60e51b815260206004820152602560248201527f4e465420636f6e747261637420646f6573206e6f7420737570706f7274204945604482015264524337323160d81b6064820152608490fd5b6131c46131b46113f660006130b2565b6131bd836104b3565b14156130e6565b6131d061184282610f25565b803b15611a975760206131e260405190565b9182906301ffc9a760e01b825281806132056380ac58cd60e01b6004830161064f565b03915afa8015611a925761045c9261322b611f6092600194600091613233575b5061314a565b610195610f2e565b613255915060203d60201161325b575b61324d8183610ad5565b810190613136565b38613225565b503d613243565b61045c906130d5565b613276612710610881565b811161329e5761135761328b9161012f61088e565b6132956000610881565b8114612ed95790565b506104726001610881565b6132b1613fed565b61045c61045c614ada565b61045c6132a9565b61047291611f5b611357926132d7600090565b50610166610f2e565b61047260976116d0565b6132f2614814565b61330b613303611b9761015f611df8565b61015f611e57565b7fd07c370fab3a218ea71c161d4c9008b25a6f112a4bd8474e6ed204557fc6389b61333a6109c061015f611df8565b0390a1565b61045c9061334b613fed565b61045c90610191611794565b61045c9061333f565b1561336757565b60405162461bcd60e51b815260206004820152603a60248201527f4d617820737570706c79206d7573742062652067726561746572207468616e2060448201527f6f7220657175616c20746f2063757272656e7420737570706c790000000000006064820152608490fd5b90611f0361045c926133e2614814565b6133ff6133f76104726113578461013161088e565b841015613360565b61013261088e565b61341261016261130c565b61341f6116546064610881565b11156134be5761345a61345460406123e96120d461016761344e61344461016261130c565b6113656064610881565b9061088e565b4261132c565b613465610dec610881565b81111561347757506104726000610881565b613482610168610881565b8110156134945750610472605a610881565b61047290611af36134b86134ae610e1093611c9885610881565b611b226064610881565b91610881565b6104726000610881565b61097e6104726104729290565b156134dc57565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b61097e6104726104729260ff1690565b90611e6761047261144f92613538565b61047a906134c8565b60208101929161045c9190613558565b6135b7613581611b9760006114a0565b918280613654575b801561360f575b613599906134d5565b826135ae6135a760016134c8565b6000613548565b6135fe57613672565b6135bd57565b6135c8600080611438565b7f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024986135f260405190565b8061333a600182613561565b61360a60016000611438565b613672565b50613624611b9761361f30610f25565b614ae2565b801561359057506135996136386000611df8565b61364c61364560016134c8565b9160ff1690565b149050613590565b5061365f6000611df8565b61366c61364560016134c8565b10613589565b6136939061367e614b71565b613686614b91565b61368e614bb1565b614bd6565b61369b614bfc565b6136a733610192612ddb565b61045c611ee1612710610881565b61045c90613571565b9061147a9695949392916136d0614060565b9061045c9695949392916136e26140dc565b613815565b156136ee57565b60405162461bcd60e51b815260206004820152601f60248201527f5069636b617865206d65726368616e74206973206e6f7420656e61626c6564006044820152606490fd5b60409061375161045c93959461177c60608401976000850190610778565b0160009052565b1561375f57565b60405162461bcd60e51b815260206004820152603560248201527f53656e646572206973206e6f742064656c65676174656420746f206d696e742060448201527437b7103132b430b6331037b3103932b1b2b4bb32b960591b6064820152608490fd5b610472913691610b37565b156137d457565b60405162461bcd60e51b815260206004820152601960248201527813585b9859d95b595b9d081c185e5b595b9d0819985a5b1959603a1b6044820152606490fd5b94955090919261382e613829610194611df8565b6136e7565b613837336104b3565b613840866104b3565b036138e5575b61385995613853916137c2565b93614cd2565b6138ac60008061387261386c6002610881565b8561164e565b613882611cad611c9d838861132c565b61388d6101926116d0565b9061389760405190565b90818003925af16138a66116e7565b506137cd565b8034116138b65750565b60008061045c926138d36138cc61184233610f25565b913461132c565b60405190818003925af1611cdf6116e7565b6139116118427f00000000000000000000000000000000000000447e69651d841bd8d104bed493610f25565b95863b15611a9757602061392460405190565b97889063e839bd5360e01b825281806139418b3360048401613733565b03915afa918215611a9257613965613853936138599960009161396e575b50613758565b91509550613846565b613987915060203d60201161325b5761324d8183610ad5565b3861395f565b9061045c9695949392916136be565b61045c906139a8613fed565b6139f9565b156139b457565b60405162461bcd60e51b815260206004820152601a60248201527f496e76616c6964206d616e6167656d656e7420616464726573730000000000006044820152606490fd5b61045c90613a1d613a0d6113f660006130b2565b613a16836104b3565b14156139ad565b610192612ddb565b61045c9061399c565b61045c90613a3a613fed565b61045c90610194611e57565b61045c90613a2e565b61045c90613a5b613fed565b6000611f6061045c92610195613a77612f86611f518484610f2e565b610f2e565b61045c90613a4f565b61045c90613a91613fed565b613af1565b15613a9d57565b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b61045c906130c8613b056113f660006130b2565b613b0e836104b3565b1415613a96565b61045c90613a85565b01918252565b6104729161260d565b6001600160e81b03191690565b613b2d613b476104729290565b60e81b90565b61047262ffd700613b3a565b15613b6057565b60405162461bcd60e51b8152602060048201526013602482015272092dcecc2d8d2c840dad2dcd2dcce40d0c2e6d606b1b6044820152606490fd5b91613be7613bf392600094613bdb602097613bb4600090565b506040519586948a8601948592613b1e6020610a2994613b1e8288613b1e829b9a83999052565b90810382520382610ad5565b60405191829182613b24565b039060025afa15611a92576000519061045c613c0e83613b2d565b613c2a613c1c613b2d613b4d565b916001600160e81b03191690565b14613b59565b80546000939291613c4d613c4383612b8a565b8085529360200190565b9160018116908115613c9f5750600114613c6657505050565b613c799192939450600052602060002090565b916000925b818410613c8b5750500190565b805484840152602090930192600101613c7e565b92949550505060ff1916825215156020020190565b9061047291613c30565b9061045c613cd892613ccf60405190565b93848092613cb4565b0383610ad5565b6104726060610afb565b9061045c613d206002613cfa613cdf565b94613d0b613d0782613cbe565b8752565b613d1a61200360018301613cbe565b01613cbe565b6040840152565b61047290613ce9565b613e11600498966126f06012613dba6126f099600d613da2613e599b613e8f9f9b613d846013916010613d696126f09f9e60039f61260d565b6f7b226e616d65223a20225069636b202360801b81526126a5565b72111610113232b9b1b934b83a34b7b7111d101160691b81526126a5565b6c1116101134b6b0b3b2911d101160991b81526126a5565b71222c202261747472696275746573223a205b60701b8152017f7b2274726169745f74797065223a2022546f74616c204f726573204d696e656481526b0111610113b30b63ab2911d160a51b6020820152602c0190565b6203e96160ed1b8152017f7b2274726169745f74797065223a2022546f74616c20476f6c64204d696e656481526b0111610113b30b63ab2911d160a51b6020820152602c0190565b7f7d2c207b2274726169745f74797065223a202254797065222c202276616c7565815263111d101160e11b602082015260240190565b63227d5d7d60e01b81520190565b92946128dc929796919461045c96613eb460405190565b998a97602089019788613d30565b613f46613f4161047261047293613ed7606090565b50613ee06125ea565b90613ef8613ef361013361344e8461326b565b613d27565b90613f028161442b565b60208301516040840151916000613f38613f2a611357613f2f613f2a6113578a61019661088e565b61442b565b9761019761088e565b95015195613e9d565b6146c7565b610472613f5260405190565b8092613bdb6020830191826128e8565b6104726301406f40610881565b610472613f7d61019361130c565b611af3613f62565b61045c611cad613f9661019361130c565b3490611668565b15613fa457565b60405162461bcd60e51b8152806113ab600482016020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b61045c613ff86132e0565b6140046113fb336104b3565b14613f9d565b6104726002610881565b1561401b57565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b61045c61406d60c961130c565b61408161407861400a565b91821415614014565b60c9611794565b6104726001610881565b61045c614081614088565b156140a457565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b61045c6140ea611b97612dae565b61409d565b7f00000000000000000000000071f746615cbfdbd4805d788dfc11d4960ddc4eea90565b7f000000000000000000000000aa93f7f16a8069aafb60254612416b3cdf818be090565b906141446113f630610f25565b61414d836104b3565b1480156141e9575b80156141cc575b6141c55760008061416c60405190565b60009084865af19161417c6116e7565b50821561418857505090565b6141bf6141b57f9e32a39d1582a00a2c4d76cef332ee741c4ec2ed801c796519038d51099b7e6192610f25565b9261049d60405190565b0390a290565b5050600090565b506141da6113f660006130b2565b6141e3836104b3565b1461415c565b506141f561dead6104b3565b6141fe836104b3565b14614155565b6104726000614214610472612b38565b016116d0565b5061045c614814565b6104727f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143610881565b9050519061045c82610441565b90602082820312610475576104729161424c565b1561427457565b60405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608490fd5b91906142e360006142dd610472614223565b01611df8565b156142f357505061045c90614f54565b6142ff61184284610f25565b803b15611a9757602061431160405190565b6352d1902d60e01b815291829060049082905afa600091816143b1575b50614390575060405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608490fd5b926143ac61045c946143a6611654610472612b38565b1461426d565b614eb6565b6143d491925060203d6020116143db575b6143cc8183610ad5565b810190614259565b903861432e565b503d6143c2565b6143ea614fbf565b61045c6143f9600060fb611e57565b7f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa61333a33610fc7565b61045c6143e2565b61443481614fcf565b90614445600192610a296001610881565b918061445084612202565b936020018401905b614463575b50505090565b81156144b3576144979060001901926f181899199a1a9b1b9c1cb0b131b232b360811b600a82061a8453611af3600a610881565b90816144a66116546000610881565b146144b357909181614458565b61445d565b906144c1825190565b81101561156d570160200190565b8015611339576000190190565b610472906144f06116546104729460ff1690565b901c90565b156144fc57565b60405162461bcd60e51b8152806113ab600482016020808252818101527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604082015260600190565b90919061456c61223361455c85611c936002610881565b6145666002610881565b90611668565b906000603061458361457d83610881565b856144b8565b53600f60fb1b6145bc6145b36001978893851a6145a86145a286610881565b896144b8565b53611c936002610881565b61456683610881565b905b6145e0575b50610472939450906145da61165461047293610881565b146144f5565b916145ea86610881565b831115614658576f181899199a1a9b1b9c1cb0b131b232b360811b61460f600f610881565b821690601082101561156d57879261462f61464c92614652941a60f81b90565b851a61463b87896144b8565b5361464660046134c8565b906144dc565b936144cf565b906145be565b916145c3565b61466860406116da565b7f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208201527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f604082015290565b61047261465e565b6104726146b7565b80516146d66116546000610881565b146147a8576146e36146bf565b906146ef61455c825190565b906001614712612233614708600395611af36003610881565b611c936004610881565b9301916020840192829183518401925b838110614760575050505060039051068060011461474f57600214614745575090565b6001603d91035390565b50600281603d600181940353035390565b8160019196929394960191603f828080865194848660121c168a01518153018385600c1c16890151815301828460061c16880151815301911685015181530194929190614722565b506104726125ea565b156147b857565b60405162461bcd60e51b815260206004820152602e60248201527f4f6e6c792074686520636f6e7472616374206f776e65722063616e2063616c6c60448201526d103a3434b990333ab731ba34b7b760911b6064820152608490fd5b61045c6148226113f66132e0565b61482b336104b3565b146147b1565b1561483857565b60405162461bcd60e51b815260206004820152601660248201527527232a103737ba1037bbb732b210313c9036b4b732b960511b6044820152606490fd5b1561487d57565b60405162461bcd60e51b815260206004820152601e60248201527f4e4654206d696e696e6720636f6f6c646f776e206e6f742070617373656400006044820152606490fd5b61047260a0610afb565b6104726040610afb565b60016148f6602061045c946123e96148f060008301611752565b86612ddb565b9101611794565b9061045c916148d6565b92939161491661184285610f25565b90813b15611a9757602061492960405190565b6331a9108f60e11b81526004810185905292839060249082905afa958615611a9257614a1a976149f0614a22966149e96149f9946149c56149be8a611f5b6104729f8f90614990906149fe9e600091614a27575b5061498a6113fb336104b3565b14614831565b610166613a776149aa61345461135787611f5b8787610f2e565b6149b861165461047261516c565b11614876565b4290611794565b6149e26149d06148c2565b976149db338a61161b565b6020890152565b6040870152565b6060850152565b15156080830152565b615271565b959091614a13614a0c6148cc565b958661161b565b6020850152565b61016861088e565b6148fd565b614a40915060203d602011611a8b57611a7d8183610ad5565b3861497d565b614a67614a61614a5660976116d0565b611842846097612ddb565b91610f25565b907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0614a9260405190565b8080612495565b614aa16140dc565b61045c614ab0600160fb611e57565b7f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861333a33610fc7565b61045c614a99565b3b614af06116546000610881565b1190565b15614afb57565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b614b66614b6160006114a0565b614af4565b61045c61045c615418565b61045c614b54565b614b86614b6160006114a0565b61045c61045c61542d565b61045c614b79565b614ba6614b6160006114a0565b61045c61045c615451565b61045c614b99565b61045c90614bca614b6160006114a0565b61045c90610134612ddb565b61045c90614bb9565b614bec614b6160006114a0565b61045c61045c612dc46018610881565b61045c614bdf565b15614c0b57565b60405162461bcd60e51b8152602060048201526014602482015273496e76616c6964207069636b617865207479706560601b6044820152606490fd5b15614c4e57565b60405162461bcd60e51b815260206004820152601060248201526f496e76616c6964207175616e7469747960801b6044820152606490fd5b15614c8d57565b60405162461bcd60e51b815260206004820152601d60248201527f4e6f207069636b6178657320617661696c61626c6520746f206d696e740000006044820152606490fd5b909293611b1094614ce1600090565b5084600194614cfa614cf36001610881565b8311614c04565b84600093614d0785610881565b831180614e9e575b614d1890614c47565b8295614d296113578661013261088e565b93614d3e61013195611365611357898961088e565b908110614e94575b50614d529082846154d1565b614d66610130916113656113578585610f2e565b808711614e8a575b5091611f5b614da7614dc19593614db495614d92614d8b8a610881565b8b11614c86565b613a77614da28b611c9389615578565b9e8f90565b612fcc88611ca88361130c565b612fcc84611ca88361130c565b614dcf611842611842614113565b803b15611a975782602091614e079584614de860405190565b809881958294614dfc6340c10f1960e01b90565b8452600484016122a0565b03925af1928315611a9257600093614e65575b50614e258491610881565b905b614e34575b505050505090565b81811015614e6057614e5a90614e5486611f0361012f61344e8589611668565b60010190565b83614e27565b614e2c565b614e25919350614e839060203d6020116143db576143cc8183610ad5565b9290614e1a565b9550611f5b614d6e565b9650614d52614d46565b50614d18614eac600a610881565b8411159050614d0f565b91614ec08361558d565b8151614ecf6116546000610881565b11908115614eea575b50614ee1575050565b612fe691615670565b905038614ed8565b15614ef957565b60405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b61045c90614f69614f6482614ae2565b614ef2565b6000614f76610472612b38565b01612ddb565b15614f8357565b60405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606490fd5b61045c614fca612dae565b614f7c565b614fd96000610881565b9072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b614ffa81610881565b82101561514a575b506d04ee2d6d415b85acef810000000061501b81610881565b821015615128575b50662386f26fc1000061503581610881565b821015615106575b506305f5e10061504c81610881565b8210156150e4575b5061271061506181610881565b8210156150c2575b506150746064610881565b8110156150a0575b615089611654600a610881565b10156150925790565b61047290610a296001610881565b6150b16150bc91611af36064610881565b91610a296002610881565b9061507c565b6150dd91611af36150d292610881565b91610a296004610881565b9038615069565b6150ff91611af36150f492610881565b91610a296008610881565b9038615054565b61512191611af361511692610881565b91610a296010610881565b903861503d565b61514391611af361513892610881565b91610a296020610881565b9038615023565b61516591611af361515a92610881565b91610a296040610881565b9038615002565b61047261517a61016161130c565b611b22610e10610881565b906117a461047261144f9290565b60096148f661012061045c946151ae6148f060008301611752565b6151c56151bc602083015190565b60018701615185565b6151dc6151d3604083015190565b60028701611794565b6151f36151ea606083015190565b60038701611794565b61520a615201608083015190565b60048701611794565b61522161521860a083015190565b60058701611794565b61523861522f60c083015190565b60068701611794565b61524f61524660e083015190565b60078701611794565b6123e961525e61010083015190565b60088701611794565b9061045c91615193565b9061527b826156fd565b92602081019061528c610ebf835190565b9260408201956152a361529d885190565b86615862565b9590976152c06152b88a611ca861016061130c565b610160611794565b6152ce6118426118426140ef565b96856152d981611752565b98803b15611a975761530e60209160009b6152f360405190565b9c8d9384928391906335313c2160e11b835260048301610f9c565b03925af1988915611a92576000996153dc575b5061532b90611752565b606090960151875192519561533e611f74565b97615349908961161b565b6020880152615359426040890152565b6060870152608086015260a085015260c084015260e083015261010082015261538485610120830152565b61539083610162611794565b61539c8361016761088e565b906153a691615267565b816101646153b2835190565b6153bb9161088e565b906153c591611794565b516153d29061016561088e565b4261165491611794565b61532b9199506153fa9060203d6020116143db576143cc8183610ad5565b9890615321565b61540e614b6160006114a0565b61045c8033614a46565b61045c615401565b61147a614b6160006114a0565b61045c615420565b615442614b6160006114a0565b61045c61045c600060fb611e57565b61045c615435565b90815260608101939261045c9290916040916117869061177c565b6020809392613b1e61151a610a299461190160f01b815260020190565b1561549857565b60405162461bcd60e51b8152602060048201526011602482015270496e76616c6964207369676e617475726560781b6044820152606490fd5b91613bdb6155506155619361552461045c9661550a7f6e12393101ad1c70176b60a4035d41979b99db2b38474e0ac20e7fd93005302790565b613bdb61551660405190565b948593602085019384615459565b61553661552f825190565b9160200190565b2061553f615997565b604051938492602084019283615474565b61555b61552f825190565b20615a19565b6155726113fb6113f66101346116d0565b14615491565b61047290611b22671bc16d674ec80000610881565b61559a9061184281614f54565b7fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b6155c460405190565b600090a2565b156155d157565b60405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608490fd5b61562f60276116da565b7f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c6020820152660819985a5b195960ca1b604082015290565b610472615625565b6000610472928192615680606090565b5061569261568d82614ae2565b6155ca565b602082519201905af46156a36116e7565b6156ab615668565b91615a2e565b156156b857565b60405162461bcd60e51b815260206004820152601a60248201527f5069636b617865206e6f74206f776e6564206279206d696e65720000000000006044820152606490fd5b9061570e611b976080840151151590565b615779575b611654826020615769940190615727825190565b9061574b6040820192606061573a855190565b930192615745845190565b91615b44565b61577361576e61576261135761016461344e885190565b9788955190565b935190565b915190565b91613b9b565b615787611842611842614113565b91615793602082015190565b92803b15611a97576157bf936020916157ab60405190565b958692839182916331a9108f60e11b611887565b03915afa908115611a92576157f361165492615769956000916157fb575b506157ed6113fb6113f685611752565b146156b1565b925050615713565b615814915060203d602011611a8b57611a7d8183610ad5565b386157dd565b1561582157565b60405162461bcd60e51b8152602060048201526019602482015278139bc81b5bdc994819dbdb190818d85b881899481b5a5b9959603a1b6044820152606490fd5b90919061587061016061130c565b6158b66158ab61587e613f62565b9561588a87851061581a565b611b226158a0615898613407565b928397611625565b91611c986064610881565b611af36103e8610881565b93846158c28382611668565b8210156158d957506158d69293945061132c565b91565b6158ea90611c98848497969761132c565b6158f76116546064610881565b10615900575050565b6158d692945061132c565b615915600f6116da565b6e141a58dad85e1953595c98da185b9d608a1b602082015290565b61047261590b565b61594260016116da565b603160f81b602082015290565b610472615938565b9095949261045c946159896159909261598260809661597b60a088019c6000890152565b6020870152565b6040850152565b6060830152565b0190610778565b61599f615930565b6159aa61552f825190565b20615a0a6159b661594f565b6159c161552f825190565b20916159cc30610f25565b92613bdb6159d960405190565b948593602085019346917f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f86615957565b615a1561552f825190565b2090565b61047291615a2691615c02565b919091615c75565b90919015615a3a575090565b90615daf565b6104726103e8610881565b61047261270f610881565b15615a5d57565b60405162461bcd60e51b8152602060048201526012602482015271496e76616c696420676f6c6420726174696f60701b6044820152606490fd5b15615a9e57565b60405162461bcd60e51b815260206004820152601060248201526f496e76616c696420617474656d70747360801b6044820152606490fd5b610472610748610881565b61047261115c610881565b15615af357565b60405162461bcd60e51b815260206004820152602360248201527f546f6f206d616e7920617474656d7074732073696e6365206c617374206d696e604482015262696e6760e81b6064820152608490fd5b611654610472615bc0615bb961045c96611ca8615bb1615ba8611357615bc899615b998c615b85615b73615a40565b91828110159081615bea575b50615a56565b610472615b926000610881565b8911615a97565b8c11615bcf575b61016561088e565b98611c98615a4b565b611b22615ad6565b944261132c565b611b22615ae1565b1115615aec565b615be5615bdd610472615ad6565b871115615a97565b615ba0565b9050615bfa611654610472615a4b565b11158f615b7f565b908051615c126116546041610881565b03615c3457610646916020820151906060604084015193015160001a90615e1f565b5050615c4060006130b2565b90600290565b634e487b7160e01b600052602160045260246000fd5b60051115615c6657565b615c46565b9061045c82615c5c565b615c7f6000615c6b565b615c8882615c6b565b03615c905750565b615c9a6001615c6b565b615ca382615c6b565b03615ce85760405162461bcd60e51b815260206004820152601860248201527745434453413a20696e76616c6964207369676e617475726560401b6044820152606490fd5b615cf26002615c6b565b615cfb82615c6b565b03615d455760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606490fd5b615d58615d526003615c6b565b91615c6b565b14615d5f57565b60405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608490fd5b90615db8825190565b615dc56116546000610881565b1115615dd45750805190602001fd5b6113ab90615de160405190565b62461bcd60e51b815291829160048301610a2d565b61178661045c94610d0d606094989795615e15608086019a6000870152565b60ff166020850152565b919291615e2b83612604565b615e4d6116546fa2a8918ca85bafe22016d0b997e4df60600160ff1b03610881565b11615ead57615e6d600093602095615e6460405190565b94859485615df6565b838052039060015afa15611a9257600051615e8860006130b2565b615e91816104b3565b615e9a836104b3565b14615ea6575090600090565b9160019150565b50505050615ebb60006130b2565b9060039056fe414249206465636f64696e673a20696e76616c69642063616c6c646174612061a26469706673582212200a33f1850f3549acce32eb1ac5f0b221986f697769219acd4a5eed5b5270e9ee64736f6c634300081c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000aa93f7f16a8069aafb60254612416b3cdf818be000000000000000000000000071f746615cbfdbd4805d788dfc11d4960ddc4eea00000000000000000000000000000000000000447e69651d841bd8d104bed493
-----Decoded View---------------
Arg [0] : _pickaxesContract (address): 0xaa93F7f16A8069AAFb60254612416B3Cdf818BE0
Arg [1] : _oreChunksContract (address): 0x71F746615cBfDbd4805D788Dfc11d4960ddc4eEa
Arg [2] : _delegateRegistry (address): 0x00000000000000447e69651d841bD8D104Bed493
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000aa93f7f16a8069aafb60254612416b3cdf818be0
Arg [1] : 00000000000000000000000071f746615cbfdbd4805d788dfc11d4960ddc4eea
Arg [2] : 00000000000000000000000000000000000000447e69651d841bd8d104bed493
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
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.