Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
D4AProtocolWithPermission
Compiler Version
v0.8.18+commit.87f61d96
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity >=0.8.10; import "./D4AProtocol.sol"; import "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol"; contract D4AProtocolWithPermission is D4AProtocol, EIP712Upgradeable { bytes32 internal constant MINTNFT_TYPEHASH = keccak256("MintNFT(bytes32 canvasID,bytes32 tokenURIHash,uint256 flatPrice)"); mapping(bytes32 => NftMintTracker) public nftMintTrackers; function createCanvas(bytes32 daoId, string calldata canvasUri, bytes32[] calldata proof) external payable nonReentrant returns (bytes32) { if (settings.permission_control().isCanvasCreatorBlacklisted(daoId, msg.sender)) revert Blacklisted(); if (!settings.permission_control().inCanvasCreatorWhitelist(daoId, msg.sender, proof)) { revert NotInWhitelist(); } return _createCanvas(daoId, canvasUri); } /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function initialize(address _settings) public initializer { __ReentrancyGuard_init(); settings = ID4ASetting(_settings); project_num = settings.reserved_slots(); __EIP712_init("D4AProtocolWithPermission", "1"); } error ExceedMaxMintAmount(); modifier ableToMint(bytes32 daoId, bytes32[] calldata proof, uint256 amount) { _checkMintEligibility(daoId, msg.sender, proof, amount); _; } function _checkMintEligibility(bytes32 daoId, address account, bytes32[] calldata proof, uint256 amount) internal view { if (!_ableToMint(daoId, account, proof, amount)) revert ExceedMaxMintAmount(); } function mintNFT( bytes32 daoId, bytes32 _canvas_id, string calldata _token_uri, bytes32[] calldata proof, uint256 _flat_price, bytes calldata _signature ) external payable nonReentrant returns (uint256) { { _checkMintEligibility(daoId, msg.sender, proof, 1); } _verifySignature(_canvas_id, _token_uri, _flat_price, _signature); nftMintTrackers[daoId].mintInfos[msg.sender].minted += 1; return _mintNft(_canvas_id, _token_uri, _flat_price); } function batchMint( bytes32 daoId, bytes32 canvasId, bytes32[] calldata proof, MintNftInfo[] calldata mintNftInfos, bytes[] calldata signatures ) external payable nonReentrant returns (uint256[] memory) { uint32 length = uint32(mintNftInfos.length); { _checkMintEligibility(daoId, msg.sender, proof, length); for (uint32 i = 0; i < length;) { _verifySignature(canvasId, mintNftInfos[i].tokenUri, mintNftInfos[i].flatPrice, signatures[i]); unchecked { ++i; } } } nftMintTrackers[daoId].mintInfos[msg.sender].minted += length; return _mintNft(daoId, canvasId, mintNftInfos); } event MintCapSet(bytes32 indexed DAO_id, uint32 mintCap, DesignatedCap[] designatedMintCaps); error NotDaoOwner(); function setMintCapAndPermission( bytes32 daoId, uint32 _mintCap, DesignatedCap[] calldata designatedMintCaps, IPermissionControl.Whitelist memory whitelist, IPermissionControl.Blacklist memory blacklist, IPermissionControl.Blacklist memory unblacklist ) public override { if (msg.sender != settings.project_proxy() && msg.sender != settings.owner_proxy().ownerOf(daoId)) { revert NotDaoOwner(); } NftMintTracker storage mintTracker = nftMintTrackers[daoId]; mintTracker.mintCap = _mintCap; uint256 length = designatedMintCaps.length; for (uint256 i = 0; i < length;) { mintTracker.mintInfos[designatedMintCaps[i].account].designatedCap = designatedMintCaps[i].cap; unchecked { ++i; } } emit MintCapSet(daoId, _mintCap, designatedMintCaps); settings.permission_control().modifyPermission(daoId, whitelist, blacklist, unblacklist); } error Blacklisted(); error NotInWhitelist(); function _ableToMint(bytes32 daoId, address account, bytes32[] calldata proof, uint256 amount) internal view returns (bool) { // check priority // 1. blacklist // 2. designated mint cap // 3. whitelist (merkle tree || ERC721) // 4. DAO mint cap IPermissionControl permissionControl = settings.permission_control(); if (permissionControl.isMinterBlacklisted(daoId, account)) { revert Blacklisted(); } uint32 mintCap; uint128 minted; uint128 designatedCap; { NftMintTracker storage mintTracker = nftMintTrackers[daoId]; mintCap = mintTracker.mintCap; MintInfo memory mintInfo = mintTracker.mintInfos[account]; minted = mintInfo.minted; designatedCap = mintInfo.designatedCap; } bool isWhitelistOff; { IPermissionControl.Whitelist memory whitelist = permissionControl.getWhitelist(daoId); isWhitelistOff = whitelist.minterMerkleRoot == bytes32(0) && whitelist.minterNFTHolderPasses.length == 0; } uint256 expectedMinted = minted + amount; // no whitelist if (isWhitelistOff) { return mintCap == 0 ? true : expectedMinted <= mintCap; } // whitelist on && not in whitelist if (!permissionControl.inMinterWhitelist(daoId, account, proof)) { revert NotInWhitelist(); } // designated mint cap return designatedCap != 0 ? expectedMinted <= designatedCap : mintCap != 0 ? expectedMinted <= mintCap : true; } error InvalidSignature(); function _verifySignature( bytes32 _canvas_id, string calldata _token_uri, uint256 _flat_price, bytes calldata _signature ) internal view { bytes32 digest = _hashTypedDataV4( keccak256(abi.encode(MINTNFT_TYPEHASH, _canvas_id, keccak256(bytes(_token_uri)), _flat_price)) ); address signer = ECDSAUpgradeable.recover(digest, _signature); if ( !IAccessControlUpgradeable(address(settings)).hasRole(keccak256("SIGNER_ROLE"), signer) && signer != settings.owner_proxy().ownerOf(_canvas_id) ) revert InvalidSignature(); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.10; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol"; import "./impl/D4AProject.sol"; import "./impl/D4ACanvas.sol"; import "./impl/D4APrice.sol"; import "./impl/D4AReward.sol"; import "./interface/ID4ASetting.sol"; import "./interface/ID4AProtocol.sol"; abstract contract D4AProtocol is Initializable, ReentrancyGuardUpgradeable, ID4AProtocol { using D4AProject for mapping(bytes32 => D4AProject.project_info); using D4ACanvas for mapping(bytes32 => D4ACanvas.canvas_info); using D4APrice for D4APrice.project_price_info; using D4AReward for mapping(bytes32 => D4AReward.reward_info); mapping(bytes32 => bool) public uri_exists; uint256 public project_num; mapping(bytes32 => mapping(uint256 => uint256)) public round_2_total_eth; uint256 public canvas_num; uint256 public project_bitmap; // event from library event NewProject( bytes32 project_id, string uri, address fee_pool, address erc20_token, address erc721_token, uint256 royalty_fee ); event NewCanvas(bytes32 project_id, bytes32 canvas_id, string uri); /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } error NotRole(bytes32 role, address account); /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev Revert with a standard message if `msg.sender` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, msg.sender); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!_hasRole(role, account)) { revert NotRole(role, account); } } function _hasRole(bytes32 role, address account) internal view virtual returns (bool) { return IAccessControlUpgradeable(address(settings)).hasRole(role, account); } function changeProjectNum(uint256 _project_num) public onlyRole(bytes32(0)) { project_num = _project_num; } function changeSetting(address _settings) public onlyRole(bytes32(0)) { settings = ID4ASetting(_settings); } error NotCaller(address caller); modifier onlyCaller(address caller) { _checkCaller(caller); _; } function _checkCaller(address caller) internal view { if (caller != msg.sender) { revert NotCaller(caller); } } modifier d4aNotPaused() { _checkPauseStatus(); _; } error D4APaused(); function _checkPauseStatus() internal view { if (settings.d4a_pause()) { revert D4APaused(); } } modifier notPaused(bytes32 id) { _checkPauseStatus(id); _; } error Paused(bytes32 id); function _checkPauseStatus(bytes32 id) internal view { if (settings.pause_status(id)) { revert Paused(id); } } error UriAlreadyExist(string uri); error UriNotExist(string uri); modifier uriExist(string calldata uri) { _checkUriExist(uri); _; } modifier uriNotExist(string calldata uri) { _checkUriNotExist(uri); _; } function _uriExist(string calldata uri) internal view returns (bool) { return uri_exists[keccak256(abi.encodePacked(uri))]; } function _checkUriExist(string calldata uri) internal view { if (!_uriExist(uri)) { revert UriNotExist(uri); } } function _checkUriNotExist(string calldata uri) internal view { if (_uriExist(uri)) { revert UriAlreadyExist(uri); } } function createProject( uint256 _start_prb, uint256 _mintable_rounds, uint256 _floor_price_rank, uint256 _max_nft_rank, uint96 _royalty_fee, string calldata _project_uri ) public payable override nonReentrant onlyCaller(settings.project_proxy()) d4aNotPaused uriNotExist(_project_uri) returns (bytes32 project_id) { uri_exists[keccak256(abi.encodePacked(_project_uri))] = true; project_id = all_projects.createProject( settings, _start_prb, _mintable_rounds, _floor_price_rank, _max_nft_rank, _royalty_fee, project_num, _project_uri ); project_num++; } error DaoIndexTooLarge(); error DaoIndexAlreadyExist(); function createOwnerProject( uint256 _start_prb, uint256 _mintable_rounds, uint256 _floor_price_rank, uint256 _max_nft_rank, uint96 _royalty_fee, string calldata _project_uri, uint256 _project_index ) public payable override nonReentrant onlyCaller(settings.project_proxy()) d4aNotPaused returns ( // uriNotExist(_project_uri) bytes32 project_id ) { { _checkUriNotExist(_project_uri); } { if (_project_index >= settings.reserved_slots()) revert DaoIndexTooLarge(); if (((project_bitmap >> _project_index) & 1) != 0) revert DaoIndexAlreadyExist(); } { project_bitmap |= (1 << _project_index); uri_exists[keccak256(abi.encodePacked(_project_uri))] = true; } { return all_projects.createProject( settings, _start_prb, _mintable_rounds, _floor_price_rank, _max_nft_rank, _royalty_fee, _project_index, _project_uri ); } } function getProjectCanvasCount(bytes32 _project_id) public view returns (uint256) { return all_projects.getProjectCanvasCount(_project_id); } error DaoNotExist(); error CanvasNotExist(); modifier daoExist(bytes32 daoId) { _checkDaoExist(daoId); _; } function _checkDaoExist(bytes32 daoId) internal view { if (!all_projects[daoId].exist) revert DaoNotExist(); } modifier canvasExist(bytes32 canvasId) { _checkCanvasExist(canvasId); _; } function _checkCanvasExist(bytes32 canvasId) internal view { if (!all_canvases[canvasId].exist) revert CanvasNotExist(); } function _createCanvas(bytes32 _project_id, string calldata _canvas_uri) internal d4aNotPaused daoExist(_project_id) notPaused(_project_id) uriNotExist(_canvas_uri) returns (bytes32 canvas_id) { uri_exists[keccak256(abi.encodePacked(_canvas_uri))] = true; canvas_id = all_canvases.createCanvas( settings, all_projects[_project_id].fee_pool, _project_id, all_projects[_project_id].start_prb, all_projects.getProjectCanvasCount(_project_id), _canvas_uri ); all_projects[_project_id].canvases.push(canvas_id); } event D4AMintNFT(bytes32 project_id, bytes32 canvas_id, uint256 token_id, string token_uri, uint256 price); error NftExceedMaxAmount(); error PriceTooLow(); function _mintNft(bytes32 canvasId, string calldata _token_uri, uint256 flatPrice) internal returns ( // d4aNotPaused // notPaused(canvasId) // canvasExist(canvasId) // uriNotExist(_token_uri) uint256 token_id ) { { _checkPauseStatus(); _checkPauseStatus(canvasId); _checkCanvasExist(canvasId); _checkUriNotExist(_token_uri); } bytes32 daoId = all_canvases[canvasId].project_id; if (flatPrice != 0 && flatPrice < all_projects.getProjectFloorPrice(daoId)) revert PriceTooLow(); _checkPauseStatus(daoId); D4AProject.project_info storage pi = all_projects[daoId]; D4ACanvas.canvas_info storage ci = all_canvases[canvasId]; if (pi.nft_supply >= pi.max_nft_amount) revert NftExceedMaxAmount(); MintVars memory vars; vars.currentRound = settings.PRB().currentRound(); vars.nftPriceMultiplyFactor = pi.nftPriceMultiplyFactor == 0 ? settings.defaultNftPriceMultiplyFactor() : pi.nftPriceMultiplyFactor; { bytes32 token_uri_hash = keccak256(abi.encodePacked(_token_uri)); uri_exists[token_uri_hash] = true; } // get next mint price GetCanvasNextPriceVars memory getCanvasNextPriceVar; getCanvasNextPriceVar.daoId = daoId; getCanvasNextPriceVar.canvasId = canvasId; getCanvasNextPriceVar.currentRound = vars.currentRound; getCanvasNextPriceVar.floorPrices = pi.floor_prices; getCanvasNextPriceVar.floorPriceRank = pi.floor_price_rank; getCanvasNextPriceVar.startPrb = pi.start_prb; getCanvasNextPriceVar.nftPriceMultiplyFactor = vars.nftPriceMultiplyFactor; getCanvasNextPriceVar.flatPrice = flatPrice; uint256 price = _getCanvasNextPrice(getCanvasNextPriceVar); // split fee { address protocolFeePool = settings.protocol_fee_pool(); address daoFeePool = pi.fee_pool; address canvasOwner = settings.owner_proxy().ownerOf(canvasId); uint256 daoShare = ( flatPrice == 0 ? settings.mint_project_fee_ratio() : settings.mint_project_fee_ratio_flat_price() ) * price; (vars.daoFee, vars.protocolFee) = _splitFee(protocolFeePool, daoFeePool, canvasOwner, price, daoShare); } // update _updatePrice(vars.currentRound, daoId, canvasId, price, flatPrice, vars.nftPriceMultiplyFactor); _updateReward(daoId, canvasId, vars.daoFee, vars.protocolFee, price); // mint token_id = ID4AERC721(pi.erc721_token).mintItem(msg.sender, _token_uri); { pi.nft_supply++; ci.nft_tokens.push(token_id); ci.nft_token_number++; tokenid_2_canvas[keccak256(abi.encodePacked(daoId, token_id))] = canvasId; } emit D4AMintNFT(daoId, canvasId, token_id, _token_uri, price); } function _updatePrice( uint256 currentRound, bytes32 daoId, bytes32 canvasId, uint256 price, uint256 flatPrice, uint256 nftPriceMultiplyFactor ) internal { if (flatPrice == 0) { all_prices[daoId].updateCanvasPrice(currentRound, canvasId, price, nftPriceMultiplyFactor); } } struct MintNftInfo { string tokenUri; uint256 flatPrice; } struct MintVars { uint32 length; uint256 currentRound; uint256 nftPriceMultiplyFactor; uint256 priceChangeBasisPoint; uint256 price; uint256 daoTotalShare; uint256 totalPrice; uint256 daoFee; uint256 protocolFee; uint256 initialPrice; } function _mintNft(bytes32 daoId, bytes32 canvasId, MintNftInfo[] calldata mintNftInfos) internal returns ( // d4aNotPaused // notPaused(daoId) // canvasExist(canvasId) // notPaused(canvasId) uint256[] memory ) { { _checkPauseStatus(); _checkPauseStatus(daoId); _checkCanvasExist(canvasId); _checkPauseStatus(canvasId); } MintVars memory vars; vars.length = uint32(mintNftInfos.length); { uint256 projectFloorPrice = all_projects.getProjectFloorPrice(daoId); for (uint32 i = 0; i < vars.length;) { _checkUriNotExist(mintNftInfos[i].tokenUri); if (mintNftInfos[i].flatPrice != 0 && mintNftInfos[i].flatPrice < projectFloorPrice) { revert PriceTooLow(); } unchecked { ++i; } } } D4AProject.project_info storage pi = all_projects[daoId]; D4ACanvas.canvas_info storage ci = all_canvases[canvasId]; if (pi.nft_supply >= pi.max_nft_amount) revert NftExceedMaxAmount(); vars.currentRound = settings.PRB().currentRound(); vars.nftPriceMultiplyFactor = pi.nftPriceMultiplyFactor == 0 ? settings.defaultNftPriceMultiplyFactor() : pi.nftPriceMultiplyFactor; vars.priceChangeBasisPoint = D4APrice._PRICE_CHANGE_BASIS_POINT; GetCanvasNextPriceVars memory getCanvasNextPriceVar; getCanvasNextPriceVar.daoId = daoId; getCanvasNextPriceVar.currentRound = vars.currentRound; getCanvasNextPriceVar.floorPrices = pi.floor_prices; getCanvasNextPriceVar.floorPriceRank = pi.floor_price_rank; getCanvasNextPriceVar.startPrb = pi.start_prb; getCanvasNextPriceVar.nftPriceMultiplyFactor = vars.nftPriceMultiplyFactor; vars.price = _getCanvasNextPrice(getCanvasNextPriceVar); vars.initialPrice = vars.price; vars.daoTotalShare; vars.totalPrice; uint256[] memory tokenIds = new uint256[](vars.length); { uint256 mintProjectFeeRatio = settings.mint_project_fee_ratio(); uint256 mintProjectFeeRatioFlatPrice = settings.mint_project_fee_ratio_flat_price(); for (uint32 i = 0; i < vars.length;) { { bytes32 token_uri_hash = keccak256(abi.encodePacked(mintNftInfos[i].tokenUri)); uri_exists[token_uri_hash] = true; } tokenIds[i] = ID4AERC721(pi.erc721_token).mintItem(msg.sender, mintNftInfos[i].tokenUri); { pi.nft_supply++; ci.nft_tokens.push(tokenIds[i]); ci.nft_token_number++; tokenid_2_canvas[keccak256(abi.encodePacked(daoId, tokenIds[i]))] = canvasId; } uint256 flatPrice = mintNftInfos[i].flatPrice; if (flatPrice == 0) { vars.daoTotalShare += mintProjectFeeRatio * vars.price; vars.totalPrice += vars.price; emit D4AMintNFT(daoId, canvasId, tokenIds[i], mintNftInfos[i].tokenUri, vars.price); vars.price *= vars.nftPriceMultiplyFactor / vars.priceChangeBasisPoint; } else { vars.daoTotalShare += mintProjectFeeRatioFlatPrice * flatPrice; vars.totalPrice += flatPrice; emit D4AMintNFT(daoId, canvasId, tokenIds[i], mintNftInfos[i].tokenUri, flatPrice); } unchecked { ++i; } } } { // split fee address protocolFeePool = settings.protocol_fee_pool(); address daoFeePool = pi.fee_pool; address canvasOwner = settings.owner_proxy().ownerOf(canvasId); (vars.daoFee, vars.protocolFee) = _splitFee(protocolFeePool, daoFeePool, canvasOwner, vars.totalPrice, vars.daoTotalShare); } // update canvas price if (vars.price != vars.initialPrice) { vars.price = vars.price * vars.priceChangeBasisPoint / vars.nftPriceMultiplyFactor; _updatePrice(vars.currentRound, daoId, canvasId, vars.price, 0, vars.nftPriceMultiplyFactor); } _updateReward(daoId, canvasId, vars.daoFee, vars.protocolFee, vars.totalPrice); return tokenIds; } struct GetCanvasNextPriceVars { bytes32 daoId; bytes32 canvasId; uint256 currentRound; uint256[] floorPrices; uint256 floorPriceRank; uint256 startPrb; uint256 nftPriceMultiplyFactor; uint256 flatPrice; } function _getCanvasNextPrice(GetCanvasNextPriceVars memory vars) internal view returns (uint256 price) { if (vars.flatPrice == 0) { price = all_prices[vars.daoId].getCanvasNextPrice( vars.currentRound, vars.floorPrices, vars.floorPriceRank, vars.startPrb, vars.canvasId, vars.nftPriceMultiplyFactor ); } else { price = vars.flatPrice; } } function _updateReward(bytes32 _project_id, bytes32 canvasId, uint256 daoFee, uint256 protocolFee, uint256 price) internal { D4AProject.project_info memory pi = all_projects[_project_id]; all_rewards.updateMintWithAmount( settings, _project_id, canvasId, price - daoFee - protocolFee, daoFee, pi.mintable_rounds, round_2_total_eth ); all_rewards.updateRewardForCanvas( settings, _project_id, canvasId, pi.start_prb, pi.mintable_rounds, pi.erc20_total_supply ); } error NotEnoughEther(); error EthTransferFailed(); function _splitFee( address protocolFeePool, address daoFeePool, address canvasOwner, uint256 price, uint256 daoShare ) internal returns (uint256 daoFee, uint256 protocolFee) { if (msg.value < price) revert NotEnoughEther(); uint256 exchange = msg.value - price; uint256 ratioBasisPoint = settings.ratio_base(); daoFee = daoShare / ratioBasisPoint; protocolFee = price * settings.mint_d4a_fee_ratio() / ratioBasisPoint; _transferEth(protocolFeePool, protocolFee); _transferEth(daoFeePool, daoFee); _transferEth(canvasOwner, price - daoFee - protocolFee); _transferEth(msg.sender, exchange); } function _transferEth(address to, uint256 amount) internal { if (amount == 0) return; (bool succ,) = to.call{value: amount}(""); if (!succ) revert EthTransferFailed(); } function getNFTTokenCanvas(bytes32 _project_id, uint256 _token_id) public view returns (bytes32) { return tokenid_2_canvas[keccak256(abi.encodePacked(_project_id, _token_id))]; } event D4AClaimProjectERC20Reward(bytes32 project_id, address erc20_token, uint256 amount); event D4AExchangeERC20ToETH( bytes32 project_id, address owner, address to, uint256 erc20_amount, uint256 eth_amount ); function claimProjectERC20Reward(bytes32 _project_id) public nonReentrant d4aNotPaused notPaused(_project_id) daoExist(_project_id) returns (uint256) { D4AProject.project_info storage pi = all_projects[_project_id]; all_rewards.issueTokenToCurrentRound( settings, _project_id, pi.erc20_token, pi.start_prb, pi.mintable_rounds, pi.erc20_total_supply ); uint256 amount = all_rewards.claimProjectReward( settings, _project_id, pi.erc20_token, pi.start_prb, pi.mintable_rounds, pi.erc20_total_supply ); emit D4AClaimProjectERC20Reward(_project_id, pi.erc20_token, amount); return amount; } function claimProjectERC20RewardWithETH(bytes32 _project_id) public returns (uint256) { uint256 erc20_amount = claimProjectERC20Reward(_project_id); D4AProject.project_info storage pi = all_projects[_project_id]; return D4AReward.claimProjectERC20RewardWithETH( settings, _project_id, pi.erc20_token, erc20_amount, all_projects[_project_id].fee_pool, round_2_total_eth ); } event D4AClaimCanvasReward(bytes32 project_id, bytes32 canvas_id, address erc20_token, uint256 amount); function claimCanvasReward(bytes32 canvasId) public nonReentrant d4aNotPaused notPaused(canvasId) canvasExist(canvasId) returns (uint256) { bytes32 project_id = all_canvases[canvasId].project_id; _checkDaoExist(project_id); _checkPauseStatus(project_id); D4AProject.project_info storage pi = all_projects[project_id]; all_rewards.issueTokenToCurrentRound( settings, project_id, pi.erc20_token, pi.start_prb, pi.mintable_rounds, pi.erc20_total_supply ); uint256 amount = all_rewards.claimCanvasReward( settings, project_id, canvasId, pi.erc20_token, pi.start_prb, pi.mintable_rounds, pi.erc20_total_supply ); emit D4AClaimCanvasReward(project_id, canvasId, pi.erc20_token, amount); return amount; } function claimCanvasRewardWithETH(bytes32 canvasId) public returns (uint256) { uint256 erc20_amount = claimCanvasReward(canvasId); bytes32 project_id = all_canvases[canvasId].project_id; D4AProject.project_info storage pi = all_projects[project_id]; return D4AReward.claimCanvasRewardWithETH( settings, project_id, canvasId, pi.erc20_token, erc20_amount, all_projects[project_id].fee_pool, round_2_total_eth ); } function exchangeERC20ToETH(bytes32 _project_id, uint256 amount, address _to) public nonReentrant d4aNotPaused notPaused(_project_id) returns (uint256) { D4AProject.project_info storage pi = all_projects[_project_id]; all_rewards.issueTokenToCurrentRound( settings, _project_id, pi.erc20_token, pi.start_prb, pi.mintable_rounds, pi.erc20_total_supply ); return D4AReward.ToETH( settings, pi.erc20_token, pi.fee_pool, _project_id, msg.sender, _to, amount, round_2_total_eth ); } function changeDaoNftPriceMultiplyFactor(bytes32 daoId, uint256 newNftPriceMultiplyFactor) public onlyRole(bytes32(0)) { require(newNftPriceMultiplyFactor >= 10_000); all_projects[daoId].nftPriceMultiplyFactor = newNftPriceMultiplyFactor; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol) pragma solidity ^0.8.0; import "./ECDSAUpgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ * * @custom:storage-size 52 */ abstract contract EIP712Upgradeable is Initializable { /* solhint-disable var-name-mixedcase */ bytes32 private _HASHED_NAME; bytes32 private _HASHED_VERSION; bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ function __EIP712_init(string memory name, string memory version) internal onlyInitializing { __EIP712_init_unchained(name, version); } function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash()); } function _buildDomainSeparator( bytes32 typeHash, bytes32 nameHash, bytes32 versionHash ) private view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev The hash of the name parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712NameHash() internal virtual view returns (bytes32) { return _HASHED_NAME; } /** * @dev The hash of the version parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712VersionHash() internal virtual view returns (bytes32) { return _HASHED_VERSION; } /** * @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) (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 v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.10; import "../interface/ID4ASetting.sol"; import "../interface/ID4AChangeAdmin.sol"; import "../D4AERC721.sol"; import "../feepool/D4AFeePool.sol"; import "../D4AERC20.sol"; import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; library D4AProject { struct project_info { uint256 start_prb; uint256 mintable_rounds; uint256 floor_price_rank; uint256 max_nft_amount; uint256 nft_supply; uint96 royalty_fee; uint256 index; address erc20_token; address erc721_token; address fee_pool; string project_uri; //from setting uint256 erc20_total_supply; uint256[] floor_prices; bytes32[] canvases; bool exist; uint256 nftPriceMultiplyFactor; } using StringsUpgradeable for uint256; error D4AInsufficientEther(uint256 required); error D4AProjectAlreadyExist(bytes32 project_id); event NewProject( bytes32 project_id, string uri, address fee_pool, address erc20_token, address erc721_token, uint256 royalty_fee ); function createProject( mapping(bytes32 => project_info) storage all_projects, ID4ASetting _settings, uint256 _start_prb, uint256 _mintable_rounds, uint256 _floor_price_rank, uint256 _max_nft_rank, uint96 _royalty_fee, uint256 _project_index, string memory _project_uri ) public returns (bytes32 project_id) { require(_settings.project_max_rounds() >= _mintable_rounds, "rounds too long, not support"); { uint256 protocol_fee = _settings.mint_d4a_fee_ratio(); require( _royalty_fee >= _settings.rf_lower_bound() + protocol_fee && _royalty_fee <= _settings.rf_upper_bound() + protocol_fee, "royalty fee out of range" ); } { uint256 minimal = _settings.create_project_fee(); require(msg.value >= minimal, "not enough ether to create project"); (bool succ,) = _settings.protocol_fee_pool().call{value: minimal}(""); require(succ, "transfer fee failed"); uint256 exchange = msg.value - minimal; if (exchange != 0) { (succ,) = msg.sender.call{value: exchange}(""); require(succ, "transfer exchange failed"); } } project_id = keccak256(abi.encodePacked(block.number, msg.sender, msg.data, tx.origin)); if (all_projects[project_id].exist) revert D4AProjectAlreadyExist(project_id); { project_info storage pi = all_projects[project_id]; pi.start_prb = _start_prb; { ID4APRB prb = _settings.PRB(); uint256 cur_round = prb.currentRound(); require(_start_prb >= cur_round, "start round already passed"); } pi.mintable_rounds = _mintable_rounds; pi.floor_price_rank = _floor_price_rank; pi.max_nft_amount = _settings.max_nft_amounts(_max_nft_rank); pi.project_uri = _project_uri; pi.royalty_fee = _royalty_fee; pi.index = _project_index; pi.erc20_token = _createERC20Token(_settings, _project_index); D4AERC20(pi.erc20_token).grantRole(keccak256("MINTER"), address(this)); D4AERC20(pi.erc20_token).grantRole(keccak256("BURNER"), address(this)); address pool = _settings.feepool_factory().createD4AFeePool( string(abi.encodePacked("Asset Pool for DAO4Art Project ", _project_index.toString())) ); D4AFeePool(payable(pool)).grantRole(keccak256("AUTO_TRANSFER"), address(this)); ID4AChangeAdmin(pool).changeAdmin(_settings.asset_pool_owner()); ID4AChangeAdmin(pi.erc20_token).changeAdmin(_settings.asset_pool_owner()); pi.fee_pool = pool; _settings.owner_proxy().initOwnerOf(project_id, msg.sender); pi.erc721_token = _createERC721Token(_settings, _project_index); D4AERC721(pi.erc721_token).grantRole(keccak256("ROYALTY"), msg.sender); D4AERC721(pi.erc721_token).grantRole(keccak256("MINTER"), address(this)); D4AERC721(pi.erc721_token).setContractUri(_project_uri); ID4AChangeAdmin(pi.erc721_token).changeAdmin(_settings.asset_pool_owner()); ID4AChangeAdmin(pi.erc721_token).transferOwnership(msg.sender); //We copy from setting in case setting may change later. pi.erc20_total_supply = _settings.erc20_total_supply(); for (uint256 i = 0; i < _settings.floor_prices_length(); i++) { pi.floor_prices.push(_settings.floor_prices(i)); } require(pi.floor_price_rank < pi.floor_prices.length, "invalid floor price rank"); pi.exist = true; emit NewProject(project_id, _project_uri, pool, pi.erc20_token, pi.erc721_token, _royalty_fee); } } function getProjectCanvasCount(mapping(bytes32 => project_info) storage all_projects, bytes32 _project_id) internal view returns (uint256) { project_info storage pi = all_projects[_project_id]; return pi.canvases.length; } function getProjectCanvasAt( mapping(bytes32 => project_info) storage all_projects, bytes32 _project_id, uint256 _index ) internal view returns (bytes32) { project_info storage pi = all_projects[_project_id]; return pi.canvases[_index]; } function getProjectInfo(mapping(bytes32 => project_info) storage all_projects, bytes32 _project_id) internal view returns ( uint256 start_prb, uint256 mintable_rounds, uint256 floor_price_rank, uint256 max_nft_amount, address fee_pool, uint96 royalty_fee, uint256 index, string memory uri, uint256 erc20_total_supply ) { project_info storage pi = all_projects[_project_id]; start_prb = pi.start_prb; mintable_rounds = pi.mintable_rounds; floor_price_rank = pi.floor_price_rank; max_nft_amount = pi.max_nft_amount; fee_pool = pi.fee_pool; royalty_fee = pi.royalty_fee; index = pi.index; uri = pi.project_uri; erc20_total_supply = pi.erc20_total_supply; } function getProjectFloorPrice(mapping(bytes32 => project_info) storage all_projects, bytes32 _project_id) internal view returns (uint256) { project_info storage pi = all_projects[_project_id]; return pi.floor_prices[pi.floor_price_rank]; } /*function toHex16 (bytes16 data) internal pure returns (bytes32 result) { result = bytes32 (data) & 0xFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000000 | (bytes32 (data) & 0x0000000000000000FFFFFFFFFFFFFFFF00000000000000000000000000000000) >> 64; result = result & 0xFFFFFFFF000000000000000000000000FFFFFFFF000000000000000000000000 | (result & 0x00000000FFFFFFFF000000000000000000000000FFFFFFFF0000000000000000) >> 32; result = result & 0xFFFF000000000000FFFF000000000000FFFF000000000000FFFF000000000000 | (result & 0x0000FFFF000000000000FFFF000000000000FFFF000000000000FFFF00000000) >> 16; result = result & 0xFF000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000 | (result & 0x00FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF0000) >> 8; result = (result & 0xF000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000) >> 4 | (result & 0x0F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F00) >> 8; result = bytes32 (0x3030303030303030303030303030303030303030303030303030303030303030 + uint256 (result) + (uint256 (result) + 0x0606060606060606060606060606060606060606060606060606060606060606 >> 4 & 0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F) * 7); } function toHex (bytes32 data) internal pure returns (string memory) { return string (abi.encodePacked (toHex16 (bytes16 (data)), toHex16 (bytes16 (data << 128)))); } function subString(string memory str, uint startIndex, uint endIndex) internal pure returns (string memory) { bytes memory strBytes = bytes(str); bytes memory result = new bytes(endIndex-startIndex); for(uint i = startIndex; i < endIndex; i++) { result[i-startIndex] = strBytes[i]; } return string(result); }*/ function _createERC20Token(ID4ASetting _settings, uint256 _project_num) internal returns (address) { string memory name = string(abi.encodePacked("D4A Token for No.", _project_num.toString())); string memory sym = string(abi.encodePacked("D4A.T", _project_num.toString())); return _settings.erc20_factory().createD4AERC20(name, sym, address(this)); } function _createERC721Token(ID4ASetting _settings, uint256 _project_num) internal returns (address) { string memory name = string(abi.encodePacked("D4A NFT for No.", _project_num.toString())); string memory sym = string(abi.encodePacked("D4A.N", _project_num.toString())); return _settings.erc721_factory().createD4AERC721(name, sym); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.10; import "../interface/ID4ASetting.sol"; library D4ACanvas { struct canvas_info { bytes32 project_id; uint256[] nft_tokens; uint256 nft_token_number; uint256 index; string canvas_uri; bool exist; } error D4AInsufficientEther(uint256 required); error D4ACanvasAlreadyExist(bytes32 canvas_id); event NewCanvas(bytes32 project_id, bytes32 canvas_id, string uri); function createCanvas( mapping(bytes32 => canvas_info) storage all_canvases, ID4ASetting _settings, address fee_pool, bytes32 _project_id, uint256 _project_start_prb, uint256 canvas_num, string memory _canvas_uri ) public returns (bytes32) { { ID4APRB prb = _settings.PRB(); uint256 cur_round = prb.currentRound(); require(cur_round >= _project_start_prb, "project not start yet"); } { uint256 minimal = _settings.create_canvas_fee(); require(minimal <= msg.value, "not enough ether to create canvas"); if (msg.value < minimal) revert D4AInsufficientEther(minimal); (bool succ,) = fee_pool.call{value: minimal}(""); require(succ, "transfer fee failed"); uint256 exchange = msg.value - minimal; if (exchange != 0) { (succ,) = msg.sender.call{value: exchange}(""); require(succ, "transfer exchange failed"); } } bytes32 canvas_id = keccak256(abi.encodePacked(block.number, msg.sender, msg.data, tx.origin)); if (all_canvases[canvas_id].exist) revert D4ACanvasAlreadyExist(canvas_id); { canvas_info storage ci = all_canvases[canvas_id]; ci.project_id = _project_id; ci.canvas_uri = _canvas_uri; ci.index = canvas_num + 1; _settings.owner_proxy().initOwnerOf(canvas_id, msg.sender); ci.exist = true; } emit NewCanvas(_project_id, canvas_id, _canvas_uri); return canvas_id; } function getCanvasNFTCount(mapping(bytes32 => canvas_info) storage all_canvases, bytes32 _canvas_id) internal view returns (uint256) { canvas_info storage ci = all_canvases[_canvas_id]; return ci.nft_token_number; } function getTokenIDAt(mapping(bytes32 => canvas_info) storage all_canvases, bytes32 _canvas_id, uint256 _index) internal view returns (uint256) { canvas_info storage ci = all_canvases[_canvas_id]; return ci.nft_tokens[_index]; } function getCanvasURI(mapping(bytes32 => canvas_info) storage all_canvases, bytes32 _canvas_id) internal view returns (string memory) { canvas_info storage ci = all_canvases[_canvas_id]; return ci.canvas_uri; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.10; import "../interface/ID4ASetting.sol"; library D4APrice { uint256 internal constant _PRICE_CHANGE_BASIS_POINT = 10_000; struct last_price { uint256 round; uint256 value; } struct project_price_info { last_price max_price; uint256 price_rank; uint256[] price_slots; mapping(bytes32 => last_price) canvas_price; } function getCanvasLastPrice(project_price_info storage ppi, bytes32 _canvas_id) public view returns (uint256 round, uint256 value) { last_price storage lp = ppi.canvas_price[_canvas_id]; round = lp.round; value = lp.value; } function getCanvasNextPrice( project_price_info storage ppi, uint256 currentRound, uint256[] memory price_slots, uint256 price_rank, uint256 start_prb, bytes32 _canvas_id, uint256 multiplyFactor ) internal view returns (uint256 price) { uint256 floor_price = price_slots[price_rank]; if (ppi.max_price.round == 0) { if (currentRound == start_prb) return floor_price; else return (floor_price * _PRICE_CHANGE_BASIS_POINT) / multiplyFactor; } uint256 first_guess = _get_price_in_round(ppi.canvas_price[_canvas_id], currentRound, multiplyFactor); if (first_guess >= floor_price) { return first_guess; } first_guess = _get_price_in_round(ppi.max_price, currentRound, multiplyFactor); if (first_guess >= floor_price) { return floor_price; } if ( ppi.max_price.value == (floor_price * _PRICE_CHANGE_BASIS_POINT) / multiplyFactor && currentRound <= ppi.max_price.round + 1 ) { return floor_price; } return (floor_price * _PRICE_CHANGE_BASIS_POINT) / multiplyFactor; } function updateCanvasPrice( project_price_info storage ppi, uint256 currentRound, bytes32 _canvas_id, uint256 price, uint256 multiplyFactor ) internal { uint256 cp = 0; { cp = _get_price_in_round(ppi.max_price, currentRound, multiplyFactor); } if (price >= cp) { ppi.max_price.round = currentRound; ppi.max_price.value = price; } ppi.canvas_price[_canvas_id].round = currentRound; ppi.canvas_price[_canvas_id].value = price; } function _get_price_in_round(last_price memory lp, uint256 round, uint256 multiplyFactor) internal pure returns (uint256) { if (round == lp.round) { return (lp.value * multiplyFactor) / _PRICE_CHANGE_BASIS_POINT; } uint256 k = round - lp.round - 1; uint256 value = lp.value; for (uint256 i = 0; i < k;) { value = (value * _PRICE_CHANGE_BASIS_POINT) / multiplyFactor; if (value == 0) { return 0; } unchecked { ++i; } } return value; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.10; import "../interface/ID4ASetting.sol"; import "../feepool/D4AFeePool.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; interface ID4AMintableERC20 { function mint(address to, uint256 amount) external; function burn(address from, uint256 amount) external; } library D4AReward { using SafeERC20Upgradeable for IERC20Upgradeable; struct reward_info { uint256[] active_rounds; uint256 to_issue_round_index; uint256 final_issued_round_index; uint256 project_owner_to_claim_round_index; uint256 issued_rounds; mapping(uint256 => uint256) round_2_total_amount; mapping(bytes32 => uint256) canvas_2_to_claim_round_index; mapping(bytes32 => mapping(uint256 => uint256)) canvas_2_block_2_amount; mapping(bytes32 => uint256) canvas_2_unclaimed_amount; } function issueTokenToCurrentRound( mapping(bytes32 => reward_info) storage all_rewards, ID4ASetting _settings, bytes32 _project_id, address erc20_token, uint256 _start_round, uint256 total_rounds, uint256 erc20_total_supply ) public returns (uint256) { ID4APRB prb = _settings.PRB(); uint256 cur_round = prb.currentRound(); if (cur_round <= _start_round) { return 0; } reward_info storage ri = all_rewards[_project_id]; uint256 n = ri.issued_rounds; if (n >= total_rounds) { return 0; } { uint256 i = 0; for (i = ri.to_issue_round_index; i < ri.active_rounds.length; i++) { if (ri.active_rounds[i] == cur_round) { break; } if (all_rewards[_project_id].round_2_total_amount[ri.active_rounds[i]] != 0) { n = n + 1; all_rewards[_project_id].final_issued_round_index = i; all_rewards[_project_id].to_issue_round_index = i + 1; if (n == total_rounds) { break; } } } } uint256 amount = (n - all_rewards[_project_id].issued_rounds) * erc20_total_supply / total_rounds; if (amount > 0) ID4AMintableERC20(erc20_token).mint(address(this), amount); all_rewards[_project_id].issued_rounds = n; return amount; } function updateMintWithAmount( mapping(bytes32 => reward_info) storage all_rewards, ID4ASetting _settings, bytes32 _project_id, bytes32 _canvas_id, uint256 _amount, uint256 _eth_amount, uint256 total_rounds, mapping(bytes32 => mapping(uint256 => uint256)) storage round_2_total_eth ) public { ID4APRB prb = _settings.PRB(); uint256 cur_round = prb.currentRound(); reward_info storage ri = all_rewards[_project_id]; if (ri.active_rounds.length != 0 && ri.active_rounds[ri.active_rounds.length - 1] != cur_round) { require(ri.active_rounds.length < total_rounds, "rounds end, cannot mint"); } ri.round_2_total_amount[cur_round] += _amount; ri.canvas_2_block_2_amount[_canvas_id][cur_round] += _amount; round_2_total_eth[_project_id][cur_round] += _eth_amount; if (ri.active_rounds.length == 0) { ri.active_rounds.push(cur_round); } else { if (ri.active_rounds[ri.active_rounds.length - 1] != cur_round) { ri.active_rounds.push(cur_round); } } } function claimCanvasReward( mapping(bytes32 => reward_info) storage all_rewards, ID4ASetting _settings, bytes32 _project_id, bytes32 _canvas_id, address _erc20_token, uint256 _start_round, uint256 _total_rounds, uint256 erc20_total_supply ) public returns (uint256) { updateRewardForCanvas( all_rewards, _settings, _project_id, _canvas_id, _start_round, _total_rounds, erc20_total_supply ); reward_info storage ri = all_rewards[_project_id]; uint256 total_amount = ri.canvas_2_unclaimed_amount[_canvas_id]; ri.canvas_2_unclaimed_amount[_canvas_id] = 0; if (total_amount > 0) { address canvas_owner = _settings.owner_proxy().ownerOf(_canvas_id); IERC20Upgradeable(_erc20_token).safeTransfer(canvas_owner, total_amount); } return total_amount; } function updateRewardForCanvas( mapping(bytes32 => reward_info) storage all_rewards, ID4ASetting _settings, bytes32 _project_id, bytes32 _canvas_id, uint256 _start_round, uint256 _total_rounds, uint256 erc20_total_supply ) public { uint256 cur_round; { ID4APRB prb = _settings.PRB(); cur_round = prb.currentRound(); } if (cur_round == _start_round) { return; } uint256 total_amount = 0; { reward_info storage ri = all_rewards[_project_id]; if (ri.active_rounds.length == 0) { return; } if (ri.active_rounds.length <= ri.canvas_2_to_claim_round_index[_canvas_id]) { return; } uint256 tk = erc20_total_supply * _settings.canvas_erc20_ratio() / (_settings.ratio_base() * _total_rounds); for (uint256 i = ri.canvas_2_to_claim_round_index[_canvas_id]; i <= ri.final_issued_round_index; i++) { if (ri.active_rounds[i] == cur_round) { break; } total_amount += tk * ri.canvas_2_block_2_amount[_canvas_id][ri.active_rounds[i]] / ri.round_2_total_amount[ri.active_rounds[i]]; ri.canvas_2_to_claim_round_index[_canvas_id] = i + 1; } ri.canvas_2_unclaimed_amount[_canvas_id] += total_amount; } } function claimCanvasRewardWithETH( ID4ASetting _settings, bytes32 _project_id, bytes32 _canvas_id, address erc20_token, uint256 erc20_amount, address _fee_pool, mapping(bytes32 => mapping(uint256 => uint256)) storage round_2_total_eth ) public returns (uint256) { if (erc20_amount == 0) return 0; address _owner = _settings.owner_proxy().ownerOf(_canvas_id); uint256 to_send = sendETH(_settings, erc20_token, _fee_pool, _project_id, _owner, _owner, erc20_amount, round_2_total_eth); return to_send; } function claimProjectReward( mapping(bytes32 => reward_info) storage all_rewards, ID4ASetting _settings, bytes32 _project_id, address erc20_token, uint256 _start_round, uint256 _total_rounds, uint256 erc20_total_supply ) public returns (uint256) { reward_info storage ri = all_rewards[_project_id]; if (ri.active_rounds.length == 0) { return 0; } if (ri.active_rounds.length <= ri.project_owner_to_claim_round_index) { return 0; } uint256 from = ri.active_rounds[ri.project_owner_to_claim_round_index]; if (from == 0) { from = _start_round; } ID4APRB prb = _settings.PRB(); uint256 cur_round = prb.currentRound(); if (from == cur_round) { return 0; } uint256 n = ri.final_issued_round_index - ri.project_owner_to_claim_round_index + 1; ri.project_owner_to_claim_round_index = ri.final_issued_round_index + 1; uint256 d4a_amount = erc20_total_supply * _settings.d4a_erc20_ratio() * n / (_settings.ratio_base() * _total_rounds); uint256 project_amount = erc20_total_supply * _settings.project_erc20_ratio() * n / (_settings.ratio_base() * _total_rounds); if (project_amount != 0) { address project_owner = _settings.owner_proxy().ownerOf(_project_id); IERC20Upgradeable(erc20_token).safeTransfer(project_owner, project_amount); } if (d4a_amount != 0) { IERC20Upgradeable(erc20_token).safeTransfer(_settings.protocol_fee_pool(), d4a_amount); } return project_amount; } event D4AExchangeERC20ToETH( bytes32 project_id, address owner, address to, uint256 erc20_amount, uint256 eth_amount ); function claimProjectERC20RewardWithETH( ID4ASetting _settings, bytes32 _project_id, address erc20_token, uint256 erc20_amount, address _fee_pool, mapping(bytes32 => mapping(uint256 => uint256)) storage round_2_total_eth ) public returns (uint256) { if (erc20_amount == 0) return 0; address _owner = _settings.owner_proxy().ownerOf(_project_id); uint256 to_send = sendETH(_settings, erc20_token, _fee_pool, _project_id, _owner, _owner, erc20_amount, round_2_total_eth); return to_send; } function sendETH( ID4ASetting _settings, address erc20_token, address fee_pool, bytes32 project_id, address _owner, address _to, uint256 erc20_amount, mapping(bytes32 => mapping(uint256 => uint256)) storage round_2_total_eth ) public returns (uint256) { ID4AMintableERC20(erc20_token).burn(_owner, erc20_amount); ID4AMintableERC20(erc20_token).mint(fee_pool, erc20_amount); ID4APRB prb = _settings.PRB(); uint256 cur_round = prb.currentRound(); uint256 circulate_erc20 = IERC20Upgradeable(erc20_token).totalSupply() + erc20_amount - IERC20Upgradeable(erc20_token).balanceOf(fee_pool); if (circulate_erc20 == 0) return 0; uint256 avaliable_eth = fee_pool.balance - round_2_total_eth[project_id][cur_round]; uint256 to_send = erc20_amount * avaliable_eth / circulate_erc20; if (to_send != 0) { D4AFeePool(payable(fee_pool)).transfer(address(0x0), payable(_to), to_send); } emit D4AExchangeERC20ToETH(project_id, _owner, _to, erc20_amount, to_send); return to_send; } function ToETH( ID4ASetting _settings, address erc20_token, address fee_pool, bytes32 project_id, address _owner, address _to, uint256 amount, mapping(bytes32 => mapping(uint256 => uint256)) storage round_2_total_eth ) public returns (uint256) { return sendETH(_settings, erc20_token, fee_pool, project_id, _owner, _to, amount, round_2_total_eth); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.10; import "./ID4APRB.sol"; import "./ID4AFeePoolFactory.sol"; import "./ID4AERC20Factory.sol"; import "./ID4AOwnerProxy.sol"; import "./ID4AERC721.sol"; import "./ID4AERC721Factory.sol"; import "./IPermissionControl.sol"; interface ID4AProtocolForSetting { function getCanvasProject(bytes32 _canvas_id) external view returns (bytes32); } contract ID4ASetting { uint256 public ratio_base; uint256 public min_stamp_duty; //TODO uint256 public max_stamp_duty; uint256 public create_project_fee; address public protocol_fee_pool; uint256 public create_canvas_fee; uint256 public mint_d4a_fee_ratio; uint256 public trade_d4a_fee_ratio; uint256 public mint_project_fee_ratio; uint256 public mint_project_fee_ratio_flat_price; uint256 public erc20_total_supply; uint256 public project_max_rounds; //366 uint256 public project_erc20_ratio; uint256 public canvas_erc20_ratio; uint256 public d4a_erc20_ratio; uint256 public rf_lower_bound; uint256 public rf_upper_bound; uint256[] public floor_prices; uint256[] public max_nft_amounts; ID4APRB public PRB; string public erc20_name_prefix; string public erc20_symbol_prefix; ID4AERC721Factory public erc721_factory; ID4AERC20Factory public erc20_factory; ID4AFeePoolFactory public feepool_factory; ID4AOwnerProxy public owner_proxy; ID4AProtocolForSetting public protocol; IPermissionControl public permission_control; address public asset_pool_owner; bool public d4a_pause; mapping(bytes32 => bool) public pause_status; address public WETH; address public project_proxy; uint256 public reserved_slots; uint256 public defaultNftPriceMultiplyFactor; constructor() { //some default value here ratio_base = 10000; create_project_fee = 0.1 ether; create_canvas_fee = 0.01 ether; mint_d4a_fee_ratio = 250; trade_d4a_fee_ratio = 250; mint_project_fee_ratio = 3000; mint_project_fee_ratio_flat_price = 3500; rf_lower_bound = 500; rf_upper_bound = 1000; project_erc20_ratio = 300; d4a_erc20_ratio = 200; canvas_erc20_ratio = 9500; project_max_rounds = 366; reserved_slots = 110; defaultNftPriceMultiplyFactor = 20_000; } function floor_prices_length() public view returns (uint256) { return floor_prices.length; } function max_nft_amounts_length() public view returns (uint256) { return max_nft_amounts.length; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.10; import "../impl/D4AProject.sol"; import "../impl/D4ACanvas.sol"; import "../impl/D4APrice.sol"; import "../impl/D4AReward.sol"; struct MintInfo { uint32 minted; uint32 designatedCap; } struct NftMintTracker { uint32 mintCap; mapping(address => MintInfo) mintInfos; } struct DesignatedCap { address account; uint32 cap; } abstract contract ID4AProtocol { using D4AProject for mapping(bytes32 => D4AProject.project_info); using D4ACanvas for mapping(bytes32 => D4ACanvas.canvas_info); using D4APrice for D4APrice.project_price_info; using D4AReward for mapping(bytes32 => D4AReward.reward_info); mapping(bytes32 => D4AProject.project_info) public all_projects; mapping(bytes32 => D4ACanvas.canvas_info) public all_canvases; mapping(bytes32 => D4APrice.project_price_info) public all_prices; mapping(bytes32 => D4AReward.reward_info) public all_rewards; mapping(bytes32 => bytes32) public tokenid_2_canvas; ID4ASetting public settings; function createProject( uint256 _start_prb, uint256 _mintable_rounds, uint256 _floor_price_rank, uint256 _max_nft_rank, uint96 _royalty_fee, string memory _project_uri ) external payable virtual returns (bytes32 project_id); function createOwnerProject( uint256 _start_prb, uint256 _mintable_rounds, uint256 _floor_price_rank, uint256 _max_nft_rank, uint96 _royalty_fee, string memory _project_uri, uint256 _project_index ) external payable virtual returns (bytes32 project_id); function getProjectCanvasAt(bytes32 _project_id, uint256 _index) public view returns (bytes32) { return all_projects.getProjectCanvasAt(_project_id, _index); } function getProjectInfo(bytes32 _project_id) public view returns ( uint256 start_prb, uint256 mintable_rounds, uint256 floor_price_rank, uint256 max_nft_amount, address fee_pool, uint96 royalty_fee, uint256 index, string memory uri, uint256 erc20_total_supply ) { return all_projects.getProjectInfo(_project_id); } function getProjectFloorPrice(bytes32 _project_id) public view returns (uint256) { return all_projects.getProjectFloorPrice(_project_id); } function getProjectTokens(bytes32 _project_id) public view returns (address erc20_token, address erc721_token) { erc20_token = all_projects[_project_id].erc20_token; erc721_token = all_projects[_project_id].erc721_token; } function getCanvasNFTCount(bytes32 _canvas_id) public view returns (uint256) { return all_canvases.getCanvasNFTCount(_canvas_id); } function getTokenIDAt(bytes32 _canvas_id, uint256 _index) public view returns (uint256) { return all_canvases.getTokenIDAt(_canvas_id, _index); } function getCanvasProject(bytes32 _canvas_id) public view returns (bytes32) { return all_canvases[_canvas_id].project_id; } function getCanvasIndex(bytes32 _canvas_id) public view returns (uint256) { return all_canvases[_canvas_id].index; } function getCanvasURI(bytes32 _canvas_id) public view returns (string memory) { return all_canvases.getCanvasURI(_canvas_id); } function getCanvasLastPrice(bytes32 _canvas_id) public view returns (uint256 round, uint256 price) { bytes32 proj_id = all_canvases[_canvas_id].project_id; return all_prices[proj_id].getCanvasLastPrice(_canvas_id); } function getCanvasNextPrice(bytes32 _canvas_id) public view returns (uint256) { bytes32 project_id = all_canvases[_canvas_id].project_id; D4AProject.project_info storage pi = all_projects[project_id]; return all_prices[project_id].getCanvasNextPrice( settings.PRB().currentRound(), pi.floor_prices, pi.floor_price_rank, pi.start_prb, _canvas_id, pi.nftPriceMultiplyFactor == 0 ? settings.defaultNftPriceMultiplyFactor() : pi.nftPriceMultiplyFactor ); } function setMintCapAndPermission( bytes32 _DAO_id, uint32 _mintCap, DesignatedCap[] calldata designatedMintCaps, IPermissionControl.Whitelist memory whitelist, IPermissionControl.Blacklist memory blacklist, IPermissionControl.Blacklist memory unblacklist ) external virtual; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../StringsUpgradeable.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 ECDSAUpgradeable { 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", StringsUpgradeable.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 (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 pragma solidity >=0.8.10; interface ID4AChangeAdmin { function changeAdmin(address new_admin) external; function transferOwnership(address new_owner) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.10; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721RoyaltyUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts/proxy/Clones.sol"; import "./interface/ID4AERC721Factory.sol"; contract D4AERC721 is Initializable, ERC721URIStorageUpgradeable, AccessControlUpgradeable, ERC721RoyaltyUpgradeable, OwnableUpgradeable { using CountersUpgradeable for CountersUpgradeable.Counter; CountersUpgradeable.Counter internal _tokenIds; bytes32 public constant MINTER = keccak256("MINTER"); bytes32 public constant ROYALTY_OWNER = keccak256("ROYALTY"); string internal project_uri; /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function setContractUri(string memory _uri) public onlyOwner { project_uri = _uri; } function contractURI() public view returns (string memory) { return project_uri; } function initialize(string memory name, string memory symbol) public virtual initializer { __D4AERC721_init(name, symbol); } function __D4AERC721_init(string memory name, string memory symbol) internal onlyInitializing { __ERC721_init(name, symbol); __ERC721URIStorage_init(); __ERC721Royalty_init(); __AccessControl_init(); __Ownable_init(); _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _tokenIds.reset(); } function mintItem(address player, string memory uri) public onlyRole(MINTER) returns (uint256) { _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); _mint(player, newItemId); _setTokenURI(newItemId, uri); return newItemId; } function setRoyaltyInfo(address _receiver, uint96 _royaltyFeeInBips) public onlyRole(ROYALTY_OWNER) { _setDefaultRoyalty(_receiver, _royaltyFeeInBips); } function _burn(uint256 _tokenId) internal override(ERC721URIStorageUpgradeable, ERC721RoyaltyUpgradeable) { super._burn(_tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721Upgradeable, AccessControlUpgradeable, ERC721RoyaltyUpgradeable) returns (bool) { return super.supportsInterface(interfaceId); } function tokenURI(uint256 tokenId) public view override(ERC721Upgradeable, ERC721URIStorageUpgradeable) returns (string memory) { return super.tokenURI(tokenId); } function changeAdmin(address new_admin) public onlyRole(DEFAULT_ADMIN_ROLE) { require(msg.sender != new_admin, "new admin cannot be same as old one"); _grantRole(DEFAULT_ADMIN_ROLE, new_admin); _revokeRole(DEFAULT_ADMIN_ROLE, msg.sender); } } contract D4AERC721Factory is ID4AERC721Factory { using Clones for address; D4AERC721 impl; event NewD4AERC721(address addr); constructor() { impl = new D4AERC721(); } function createD4AERC721(string memory _name, string memory _symbol) public returns (address) { address t = address(impl).clone(); D4AERC721(t).initialize(_name, _symbol); D4AERC721(t).changeAdmin(msg.sender); D4AERC721(t).transferOwnership(msg.sender); emit NewD4AERC721(t); return t; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.10; import "@openzeppelin/contracts/proxy/Clones.sol"; import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; contract D4AFeePool is AccessControlUpgradeable, ReentrancyGuardUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; string public name; bytes32 public constant AUTO_TRANSFER = keccak256("AUTO_TRANSFER"); /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function initialize(string memory _name) public initializer { __ReentrancyGuard_init(); __AccessControl_init(); _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); name = _name; } function transfer(address erc20_token_addr, address payable to, uint256 tokens) public nonReentrant returns (bool success) { require( hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || hasRole(AUTO_TRANSFER, msg.sender), "only admin or auto transfer can call this" ); if (erc20_token_addr == address(0x0)) { (bool succ,) = to.call{value: tokens}(""); require(succ, "transfer eth failed"); return true; } IERC20Upgradeable(erc20_token_addr).safeTransfer(to, tokens); return true; } receive() external payable {} function changeAdmin(address new_admin) public onlyRole(DEFAULT_ADMIN_ROLE) { require(msg.sender != new_admin, "new admin cannot be same as old one"); _grantRole(DEFAULT_ADMIN_ROLE, new_admin); _revokeRole(DEFAULT_ADMIN_ROLE, msg.sender); } } contract D4AFeePoolFactory { using Clones for address; D4AFeePool public impl; address public proxy_admin; constructor() { proxy_admin = address(new ProxyAdmin()); ProxyAdmin(proxy_admin).transferOwnership(msg.sender); impl = new D4AFeePool(); } event NewD4AFeePool(address proxy, address admin); function createD4AFeePool(string memory _name) public returns (address pool) { bytes memory data = abi.encodeWithSignature("initialize(string)", _name); TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(impl), proxy_admin, data); D4AFeePool(payable(address(proxy))).changeAdmin(msg.sender); emit NewD4AFeePool(address(proxy), proxy_admin); return address(proxy); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.10; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts/proxy/Clones.sol"; import "./interface/ID4AERC20Factory.sol"; contract D4AERC20 is Initializable, ERC20PermitUpgradeable, AccessControlUpgradeable { bytes32 public constant MINTER = keccak256("MINTER"); bytes32 public constant BURNER = keccak256("BURNER"); /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function initialize(string memory name, string memory symbol, address _minter) public initializer { __ERC20Permit_init(name); __ERC20_init(name, symbol); __AccessControl_init(); _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _setupRole(MINTER, _minter); } function mint(address to, uint256 amount) public { require(hasRole(MINTER, msg.sender), "only for minter"); super._mint(to, amount); } function burn(address from, uint256 amount) public { require(hasRole(BURNER, msg.sender), "only for burner"); super._burn(from, amount); } function changeAdmin(address new_admin) public onlyRole(DEFAULT_ADMIN_ROLE) { require(msg.sender != new_admin, "new admin cannot be same as old one"); _grantRole(DEFAULT_ADMIN_ROLE, new_admin); _revokeRole(DEFAULT_ADMIN_ROLE, msg.sender); } } contract D4AERC20Factory is ID4AERC20Factory { using Clones for address; D4AERC20 public impl; event NewD4AERC20(address addr); constructor() { impl = new D4AERC20(); } function createD4AERC20(string memory _name, string memory _symbol, address _minter) public returns (address) { address t = address(impl).clone(); D4AERC20(t).initialize(_name, _symbol, _minter); D4AERC20(t).changeAdmin(msg.sender); emit NewD4AERC20(t); return t; } }
// 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.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../extensions/draft-IERC20PermitUpgradeable.sol"; import "../../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using AddressUpgradeable for address; function safeTransfer( IERC20Upgradeable token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20Upgradeable token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20PermitUpgradeable token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.10; interface ID4APRB { function isStart() external view returns (bool); function currentRound() external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.10; interface ID4AFeePoolFactory { function createD4AFeePool(string memory _name) external returns (address pool); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.10; interface ID4AERC20Factory { function createD4AERC20(string memory _name, string memory _symbol, address _minter) external returns (address); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.10; interface ID4AOwnerProxy { function ownerOf(bytes32 hash) external view returns (address); function initOwnerOf(bytes32 hash, address addr) external returns (bool); function transferOwnership(bytes32 hash, address newOwner) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.10; interface ID4AERC721 { function mintItem(address player, string memory tokenURI) external returns (uint256); function setRoyaltyInfo(address _receiver, uint96 _royaltyFeeInBips) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.10; interface ID4AERC721Factory { function createD4AERC721(string memory _name, string memory _symbol) external returns (address); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.10; import "./ID4AOwnerProxy.sol"; interface IPermissionControl { struct Blacklist { address[] minterAccounts; address[] canvasCreatorAccounts; } struct Whitelist { bytes32 minterMerkleRoot; address[] minterNFTHolderPasses; bytes32 canvasCreatorMerkleRoot; address[] canvasCreatorNFTHolderPasses; } event MinterBlacklisted(bytes32 indexed daoId, address indexed account); event CanvasCreatorBlacklisted(bytes32 indexed daoId, address indexed account); event MinterUnBlacklisted(bytes32 indexed daoId, address indexed account); event CanvasCreatorUnBlacklisted(bytes32 indexed daoId, address indexed account); event WhitelistModified(bytes32 indexed daoId, Whitelist whitelist); function getWhitelist(bytes32 daoId) external view returns (Whitelist calldata whitelist); function addPermissionWithSignature( bytes32 daoId, Whitelist calldata whitelist, Blacklist calldata blacklist, bytes calldata signature ) external; function addPermission(bytes32 daoId, Whitelist calldata whitelist, Blacklist calldata blacklist) external; function modifyPermission( bytes32 daoId, Whitelist calldata whitelist, Blacklist calldata blacklist, Blacklist calldata unblacklist ) external; function isMinterBlacklisted(bytes32 daoId, address _account) external view returns (bool); function isCanvasCreatorBlacklisted(bytes32 daoId, address _account) external view returns (bool); function inMinterWhitelist(bytes32 daoId, address _account, bytes32[] calldata _proof) external view returns (bool); function inCanvasCreatorWhitelist(bytes32 daoId, address _account, bytes32[] calldata _proof) external view returns (bool); function setOwnerProxy(ID4AOwnerProxy _ownerProxy) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/extensions/ERC721URIStorage.sol) pragma solidity ^0.8.0; import "../ERC721Upgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev ERC721 token with storage based token URI management. */ abstract contract ERC721URIStorageUpgradeable is Initializable, ERC721Upgradeable { function __ERC721URIStorage_init() internal onlyInitializing { } function __ERC721URIStorage_init_unchained() internal onlyInitializing { } using StringsUpgradeable for uint256; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = _baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(base, _tokenURI)); } return super.tokenURI(tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721URIStorage: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev See {ERC721-_burn}. This override additionally checks to see if a * token-specific URI was set for the token, and if so, it deletes the token URI from * the storage mapping. */ function _burn(uint256 tokenId) internal virtual override { super._burn(tokenId); if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } } /** * @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) (token/ERC721/extensions/ERC721Royalty.sol) pragma solidity ^0.8.0; import "../ERC721Upgradeable.sol"; import "../../common/ERC2981Upgradeable.sol"; import "../../../utils/introspection/ERC165Upgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev Extension of ERC721 with the ERC2981 NFT Royalty Standard, a standardized way to retrieve royalty payment * information. * * Royalty information can be specified globally for all token ids via {ERC2981-_setDefaultRoyalty}, and/or individually for * specific token ids via {ERC2981-_setTokenRoyalty}. The latter takes precedence over the first. * * IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See * https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to * voluntarily pay royalties together with sales, but note that this standard is not yet widely supported. * * _Available since v4.5._ */ abstract contract ERC721RoyaltyUpgradeable is Initializable, ERC2981Upgradeable, ERC721Upgradeable { function __ERC721Royalty_init() internal onlyInitializing { } function __ERC721Royalty_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable, ERC2981Upgradeable) returns (bool) { return super.supportsInterface(interfaceId); } /** * @dev See {ERC721-_burn}. This override additionally clears the royalty information for the token. */ function _burn(uint256 tokenId) internal virtual override { super._burn(tokenId); _resetTokenRoyalty(tokenId); } /** * @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/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library CountersUpgradeable { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(account), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (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.8.0) (proxy/Clones.sol) pragma solidity ^0.8.0; /** * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for * deploying minimal proxy contracts, also known as "clones". * * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies * > a minimal bytecode implementation that delegates all calls to a known, fixed address. * * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2` * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the * deterministic method. * * _Available since v3.4._ */ library Clones { /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create opcode, which should never revert. */ function clone(address implementation) internal returns (address instance) { /// @solidity memory-safe-assembly assembly { // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes // of the `implementation` address with the bytecode before the address. mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000)) // Packs the remaining 17 bytes of `implementation` with the bytecode after the address. mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3)) instance := create(0, 0x09, 0x37) } require(instance != address(0), "ERC1167: create failed"); } /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create2 opcode and a `salt` to deterministically deploy * the clone. Using the same `implementation` and `salt` multiple time will revert, since * the clones cannot be deployed twice at the same address. */ function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) { /// @solidity memory-safe-assembly assembly { // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes // of the `implementation` address with the bytecode before the address. mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000)) // Packs the remaining 17 bytes of `implementation` with the bytecode after the address. mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3)) instance := create2(0, 0x09, 0x37, salt) } require(instance != address(0), "ERC1167: create2 failed"); } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress( address implementation, bytes32 salt, address deployer ) internal pure returns (address predicted) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(add(ptr, 0x38), deployer) mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff) mstore(add(ptr, 0x14), implementation) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73) mstore(add(ptr, 0x58), salt) mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37)) predicted := keccak256(add(ptr, 0x43), 0x55) } } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress(address implementation, bytes32 salt) internal view returns (address predicted) { return predictDeterministicAddress(implementation, salt, address(this)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol) pragma solidity ^0.8.0; import "./TransparentUpgradeableProxy.sol"; import "../../access/Ownable.sol"; /** * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}. */ contract ProxyAdmin is Ownable { /** * @dev Returns the current implementation of `proxy`. * * Requirements: * * - This contract must be the admin of `proxy`. */ function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) { // We need to manually run the static call since the getter cannot be flagged as view // bytes4(keccak256("implementation()")) == 0x5c60da1b (bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b"); require(success); return abi.decode(returndata, (address)); } /** * @dev Returns the current admin of `proxy`. * * Requirements: * * - This contract must be the admin of `proxy`. */ function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) { // We need to manually run the static call since the getter cannot be flagged as view // bytes4(keccak256("admin()")) == 0xf851a440 (bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440"); require(success); return abi.decode(returndata, (address)); } /** * @dev Changes the admin of `proxy` to `newAdmin`. * * Requirements: * * - This contract must be the current admin of `proxy`. */ function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner { proxy.changeAdmin(newAdmin); } /** * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}. * * Requirements: * * - This contract must be the admin of `proxy`. */ function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner { proxy.upgradeTo(implementation); } /** * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See * {TransparentUpgradeableProxy-upgradeToAndCall}. * * Requirements: * * - This contract must be the admin of `proxy`. */ function upgradeAndCall( TransparentUpgradeableProxy proxy, address implementation, bytes memory data ) public payable virtual onlyOwner { proxy.upgradeToAndCall{value: msg.value}(implementation, data); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol) pragma solidity ^0.8.0; import "../ERC1967/ERC1967Proxy.sol"; /** * @dev This contract implements a proxy that is upgradeable by an admin. * * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector * clashing], which can potentially be used in an attack, this contract uses the * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two * things that go hand in hand: * * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if * that call matches one of the admin functions exposed by the proxy itself. * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the * implementation. If the admin tries to call a function on the implementation it will fail with an error that says * "admin cannot fallback to proxy target". * * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due * to sudden errors when trying to call a function from the proxy implementation. * * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy. */ contract TransparentUpgradeableProxy is ERC1967Proxy { /** * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}. */ constructor( address _logic, address admin_, bytes memory _data ) payable ERC1967Proxy(_logic, _data) { _changeAdmin(admin_); } /** * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin. */ modifier ifAdmin() { if (msg.sender == _getAdmin()) { _; } else { _fallback(); } } /** * @dev Returns the current admin. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function admin() external ifAdmin returns (address admin_) { admin_ = _getAdmin(); } /** * @dev Returns the current implementation. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc` */ function implementation() external ifAdmin returns (address implementation_) { implementation_ = _implementation(); } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. * * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}. */ function changeAdmin(address newAdmin) external virtual ifAdmin { _changeAdmin(newAdmin); } /** * @dev Upgrade the implementation of the proxy. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeToAndCall(newImplementation, bytes(""), false); } /** * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the * proxied contract. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeToAndCall(newImplementation, data, true); } /** * @dev Returns the current admin. */ function _admin() internal view virtual returns (address) { return _getAdmin(); } /** * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}. */ function _beforeFallback() internal virtual override { require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target"); super._beforeFallback(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/extensions/draft-ERC20Permit.sol) pragma solidity ^0.8.0; import "./draft-IERC20PermitUpgradeable.sol"; import "../ERC20Upgradeable.sol"; import "../../../utils/cryptography/ECDSAUpgradeable.sol"; import "../../../utils/cryptography/EIP712Upgradeable.sol"; import "../../../utils/CountersUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * _Available since v3.4._ * * @custom:storage-size 51 */ abstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable { using CountersUpgradeable for CountersUpgradeable.Counter; mapping(address => CountersUpgradeable.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private constant _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`. * However, to ensure consistency with the upgradeable transpiler, we will continue * to reserve a slot. * @custom:oz-renamed-from _PERMIT_TYPEHASH */ // solhint-disable-next-line var-name-mixedcase bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT; /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ function __ERC20Permit_init(string memory name) internal onlyInitializing { __EIP712_init_unchained(name, "1"); } function __ERC20Permit_init_unchained(string memory) internal onlyInitializing {} /** * @dev See {IERC20Permit-permit}. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSAUpgradeable.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } /** * @dev "Consume a nonce": return the current value and increment. * * _Available since v4.1._ */ function _useNonce(address owner) internal virtual returns (uint256 current) { CountersUpgradeable.Counter storage nonce = _nonces[owner]; current = nonce.current(); nonce.increment(); } /** * @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) (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 v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20PermitUpgradeable { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// 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 (last updated v4.7.0) (token/common/ERC2981.sol) pragma solidity ^0.8.0; import "../../interfaces/IERC2981Upgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information. * * Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for * specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first. * * Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the * fee is specified in basis points by default. * * IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See * https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to * voluntarily pay royalties together with sales, but note that this standard is not yet widely supported. * * _Available since v4.5._ */ abstract contract ERC2981Upgradeable is Initializable, IERC2981Upgradeable, ERC165Upgradeable { function __ERC2981_init() internal onlyInitializing { } function __ERC2981_init_unchained() internal onlyInitializing { } struct RoyaltyInfo { address receiver; uint96 royaltyFraction; } RoyaltyInfo private _defaultRoyaltyInfo; mapping(uint256 => RoyaltyInfo) private _tokenRoyaltyInfo; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165Upgradeable, ERC165Upgradeable) returns (bool) { return interfaceId == type(IERC2981Upgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @inheritdoc IERC2981Upgradeable */ function royaltyInfo(uint256 _tokenId, uint256 _salePrice) public view virtual override returns (address, uint256) { RoyaltyInfo memory royalty = _tokenRoyaltyInfo[_tokenId]; if (royalty.receiver == address(0)) { royalty = _defaultRoyaltyInfo; } uint256 royaltyAmount = (_salePrice * royalty.royaltyFraction) / _feeDenominator(); return (royalty.receiver, royaltyAmount); } /** * @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a * fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an * override. */ function _feeDenominator() internal pure virtual returns (uint96) { return 10000; } /** * @dev Sets the royalty information that all ids in this contract will default to. * * Requirements: * * - `receiver` cannot be the zero address. * - `feeNumerator` cannot be greater than the fee denominator. */ function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual { require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice"); require(receiver != address(0), "ERC2981: invalid receiver"); _defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator); } /** * @dev Removes default royalty information. */ function _deleteDefaultRoyalty() internal virtual { delete _defaultRoyaltyInfo; } /** * @dev Sets the royalty information for a specific token id, overriding the global default. * * Requirements: * * - `receiver` cannot be the zero address. * - `feeNumerator` cannot be greater than the fee denominator. */ function _setTokenRoyalty( uint256 tokenId, address receiver, uint96 feeNumerator ) internal virtual { require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice"); require(receiver != address(0), "ERC2981: Invalid parameters"); _tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator); } /** * @dev Resets royalty information for the token id back to the global default. */ function _resetTokenRoyalty(uint256 tokenId) internal virtual { delete _tokenRoyaltyInfo[tokenId]; } /** * @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[48] 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/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 (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.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 Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol) pragma solidity ^0.8.0; import "../Proxy.sol"; import "./ERC1967Upgrade.sol"; /** * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an * implementation address that can be changed. This address is stored in storage in the location specified by * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the * implementation behind the proxy. */ contract ERC1967Proxy is Proxy, ERC1967Upgrade { /** * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`. * * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded * function call, and allows initializing the storage of the proxy like a Solidity constructor. */ constructor(address _logic, bytes memory _data) payable { _upgradeToAndCall(_logic, _data, false); } /** * @dev Returns the current implementation address. */ function _implementation() internal view virtual override returns (address impl) { return ERC1967Upgrade._getImplementation(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20Upgradeable.sol"; import "./extensions/IERC20MetadataUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by // decrementing then incrementing. _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; unchecked { // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above. _balances[account] += amount; } emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; // Overflow not possible: amount <= accountBalance <= totalSupply. _totalSupply -= amount; } emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) 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[45] private __gap; }
// 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.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 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) (interfaces/IERC2981.sol) pragma solidity ^0.8.0; import "../utils/introspection/IERC165Upgradeable.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 IERC2981Upgradeable is IERC165Upgradeable { /** * @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 (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 v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @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 Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overridden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeacon.sol"; import "../../interfaces/draft-IERC1822.sol"; import "../../utils/Address.sol"; import "../../utils/StorageSlot.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 ERC1967Upgrade { // 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 Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlot.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) { Address.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 (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else { try IERC1822Proxiable(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 Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlot.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 Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( Address.isContract(IBeacon(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlot.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) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// 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 IBeacon { /** * @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.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 IERC1822Proxiable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// 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 Address { /** * @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 Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.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 StorageSlot { 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 } } }
{ "remappings": [ "@ensdomains/=node_modules/@ensdomains/", "@ganache/=node_modules/@ganache/", "@openzeppelin/=node_modules/@openzeppelin/", "ds-test/=lib/forge-std/lib/ds-test/src/", "eth-gas-reporter/=node_modules/eth-gas-reporter/", "forge-std/=lib/forge-std/src/", "truffle/=node_modules/truffle/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "london", "libraries": { "contracts/impl/D4ACanvas.sol": { "D4ACanvas": "0x4815525d8a3765589cfc8986452a6c0192bc0a01" }, "contracts/impl/D4APrice.sol": { "D4APrice": "0x04f3b90a9cdd13d7474af8bbdaefbfa6cfa6f52b" }, "contracts/impl/D4AProject.sol": { "D4AProject": "0xe000362b382a2fd0c0b5e1dddabcb73154a961fa" }, "contracts/impl/D4AReward.sol": { "D4AReward": "0x9db91240165e2a5463d3e53903c646b7f1a7058b" } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"Blacklisted","type":"error"},{"inputs":[],"name":"CanvasNotExist","type":"error"},{"inputs":[],"name":"D4APaused","type":"error"},{"inputs":[],"name":"DaoIndexAlreadyExist","type":"error"},{"inputs":[],"name":"DaoIndexTooLarge","type":"error"},{"inputs":[],"name":"DaoNotExist","type":"error"},{"inputs":[],"name":"EthTransferFailed","type":"error"},{"inputs":[],"name":"ExceedMaxMintAmount","type":"error"},{"inputs":[],"name":"InvalidSignature","type":"error"},{"inputs":[],"name":"NftExceedMaxAmount","type":"error"},{"inputs":[{"internalType":"address","name":"caller","type":"address"}],"name":"NotCaller","type":"error"},{"inputs":[],"name":"NotDaoOwner","type":"error"},{"inputs":[],"name":"NotEnoughEther","type":"error"},{"inputs":[],"name":"NotInWhitelist","type":"error"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"NotRole","type":"error"},{"inputs":[{"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"Paused","type":"error"},{"inputs":[],"name":"PriceTooLow","type":"error"},{"inputs":[{"internalType":"string","name":"uri","type":"string"}],"name":"UriAlreadyExist","type":"error"},{"inputs":[{"internalType":"string","name":"uri","type":"string"}],"name":"UriNotExist","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"project_id","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"canvas_id","type":"bytes32"},{"indexed":false,"internalType":"address","name":"erc20_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"D4AClaimCanvasReward","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"project_id","type":"bytes32"},{"indexed":false,"internalType":"address","name":"erc20_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"D4AClaimProjectERC20Reward","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"project_id","type":"bytes32"},{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"erc20_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"eth_amount","type":"uint256"}],"name":"D4AExchangeERC20ToETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"project_id","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"canvas_id","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"token_id","type":"uint256"},{"indexed":false,"internalType":"string","name":"token_uri","type":"string"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"D4AMintNFT","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"DAO_id","type":"bytes32"},{"indexed":false,"internalType":"uint32","name":"mintCap","type":"uint32"},{"components":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint32","name":"cap","type":"uint32"}],"indexed":false,"internalType":"struct DesignatedCap[]","name":"designatedMintCaps","type":"tuple[]"}],"name":"MintCapSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"project_id","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"canvas_id","type":"bytes32"},{"indexed":false,"internalType":"string","name":"uri","type":"string"}],"name":"NewCanvas","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"project_id","type":"bytes32"},{"indexed":false,"internalType":"string","name":"uri","type":"string"},{"indexed":false,"internalType":"address","name":"fee_pool","type":"address"},{"indexed":false,"internalType":"address","name":"erc20_token","type":"address"},{"indexed":false,"internalType":"address","name":"erc721_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"royalty_fee","type":"uint256"}],"name":"NewProject","type":"event"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"all_canvases","outputs":[{"internalType":"bytes32","name":"project_id","type":"bytes32"},{"internalType":"uint256","name":"nft_token_number","type":"uint256"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"string","name":"canvas_uri","type":"string"},{"internalType":"bool","name":"exist","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"all_prices","outputs":[{"components":[{"internalType":"uint256","name":"round","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"internalType":"struct D4APrice.last_price","name":"max_price","type":"tuple"},{"internalType":"uint256","name":"price_rank","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"all_projects","outputs":[{"internalType":"uint256","name":"start_prb","type":"uint256"},{"internalType":"uint256","name":"mintable_rounds","type":"uint256"},{"internalType":"uint256","name":"floor_price_rank","type":"uint256"},{"internalType":"uint256","name":"max_nft_amount","type":"uint256"},{"internalType":"uint256","name":"nft_supply","type":"uint256"},{"internalType":"uint96","name":"royalty_fee","type":"uint96"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"address","name":"erc20_token","type":"address"},{"internalType":"address","name":"erc721_token","type":"address"},{"internalType":"address","name":"fee_pool","type":"address"},{"internalType":"string","name":"project_uri","type":"string"},{"internalType":"uint256","name":"erc20_total_supply","type":"uint256"},{"internalType":"bool","name":"exist","type":"bool"},{"internalType":"uint256","name":"nftPriceMultiplyFactor","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"all_rewards","outputs":[{"internalType":"uint256","name":"to_issue_round_index","type":"uint256"},{"internalType":"uint256","name":"final_issued_round_index","type":"uint256"},{"internalType":"uint256","name":"project_owner_to_claim_round_index","type":"uint256"},{"internalType":"uint256","name":"issued_rounds","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"daoId","type":"bytes32"},{"internalType":"bytes32","name":"canvasId","type":"bytes32"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"components":[{"internalType":"string","name":"tokenUri","type":"string"},{"internalType":"uint256","name":"flatPrice","type":"uint256"}],"internalType":"struct D4AProtocol.MintNftInfo[]","name":"mintNftInfos","type":"tuple[]"},{"internalType":"bytes[]","name":"signatures","type":"bytes[]"}],"name":"batchMint","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"canvas_num","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"daoId","type":"bytes32"},{"internalType":"uint256","name":"newNftPriceMultiplyFactor","type":"uint256"}],"name":"changeDaoNftPriceMultiplyFactor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_project_num","type":"uint256"}],"name":"changeProjectNum","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_settings","type":"address"}],"name":"changeSetting","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"canvasId","type":"bytes32"}],"name":"claimCanvasReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"canvasId","type":"bytes32"}],"name":"claimCanvasRewardWithETH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_project_id","type":"bytes32"}],"name":"claimProjectERC20Reward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_project_id","type":"bytes32"}],"name":"claimProjectERC20RewardWithETH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"daoId","type":"bytes32"},{"internalType":"string","name":"canvasUri","type":"string"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"createCanvas","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_start_prb","type":"uint256"},{"internalType":"uint256","name":"_mintable_rounds","type":"uint256"},{"internalType":"uint256","name":"_floor_price_rank","type":"uint256"},{"internalType":"uint256","name":"_max_nft_rank","type":"uint256"},{"internalType":"uint96","name":"_royalty_fee","type":"uint96"},{"internalType":"string","name":"_project_uri","type":"string"},{"internalType":"uint256","name":"_project_index","type":"uint256"}],"name":"createOwnerProject","outputs":[{"internalType":"bytes32","name":"project_id","type":"bytes32"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_start_prb","type":"uint256"},{"internalType":"uint256","name":"_mintable_rounds","type":"uint256"},{"internalType":"uint256","name":"_floor_price_rank","type":"uint256"},{"internalType":"uint256","name":"_max_nft_rank","type":"uint256"},{"internalType":"uint96","name":"_royalty_fee","type":"uint96"},{"internalType":"string","name":"_project_uri","type":"string"}],"name":"createProject","outputs":[{"internalType":"bytes32","name":"project_id","type":"bytes32"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_project_id","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"exchangeERC20ToETH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_canvas_id","type":"bytes32"}],"name":"getCanvasIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_canvas_id","type":"bytes32"}],"name":"getCanvasLastPrice","outputs":[{"internalType":"uint256","name":"round","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_canvas_id","type":"bytes32"}],"name":"getCanvasNFTCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_canvas_id","type":"bytes32"}],"name":"getCanvasNextPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_canvas_id","type":"bytes32"}],"name":"getCanvasProject","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_canvas_id","type":"bytes32"}],"name":"getCanvasURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_project_id","type":"bytes32"},{"internalType":"uint256","name":"_token_id","type":"uint256"}],"name":"getNFTTokenCanvas","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_project_id","type":"bytes32"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"getProjectCanvasAt","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_project_id","type":"bytes32"}],"name":"getProjectCanvasCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_project_id","type":"bytes32"}],"name":"getProjectFloorPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_project_id","type":"bytes32"}],"name":"getProjectInfo","outputs":[{"internalType":"uint256","name":"start_prb","type":"uint256"},{"internalType":"uint256","name":"mintable_rounds","type":"uint256"},{"internalType":"uint256","name":"floor_price_rank","type":"uint256"},{"internalType":"uint256","name":"max_nft_amount","type":"uint256"},{"internalType":"address","name":"fee_pool","type":"address"},{"internalType":"uint96","name":"royalty_fee","type":"uint96"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"string","name":"uri","type":"string"},{"internalType":"uint256","name":"erc20_total_supply","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_project_id","type":"bytes32"}],"name":"getProjectTokens","outputs":[{"internalType":"address","name":"erc20_token","type":"address"},{"internalType":"address","name":"erc721_token","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_canvas_id","type":"bytes32"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"getTokenIDAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_settings","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"daoId","type":"bytes32"},{"internalType":"bytes32","name":"_canvas_id","type":"bytes32"},{"internalType":"string","name":"_token_uri","type":"string"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"_flat_price","type":"uint256"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"mintNFT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"nftMintTrackers","outputs":[{"internalType":"uint32","name":"mintCap","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"project_bitmap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"project_num","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"round_2_total_eth","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"daoId","type":"bytes32"},{"internalType":"uint32","name":"_mintCap","type":"uint32"},{"components":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint32","name":"cap","type":"uint32"}],"internalType":"struct DesignatedCap[]","name":"designatedMintCaps","type":"tuple[]"},{"components":[{"internalType":"bytes32","name":"minterMerkleRoot","type":"bytes32"},{"internalType":"address[]","name":"minterNFTHolderPasses","type":"address[]"},{"internalType":"bytes32","name":"canvasCreatorMerkleRoot","type":"bytes32"},{"internalType":"address[]","name":"canvasCreatorNFTHolderPasses","type":"address[]"}],"internalType":"struct IPermissionControl.Whitelist","name":"whitelist","type":"tuple"},{"components":[{"internalType":"address[]","name":"minterAccounts","type":"address[]"},{"internalType":"address[]","name":"canvasCreatorAccounts","type":"address[]"}],"internalType":"struct IPermissionControl.Blacklist","name":"blacklist","type":"tuple"},{"components":[{"internalType":"address[]","name":"minterAccounts","type":"address[]"},{"internalType":"address[]","name":"canvasCreatorAccounts","type":"address[]"}],"internalType":"struct IPermissionControl.Blacklist","name":"unblacklist","type":"tuple"}],"name":"setMintCapAndPermission","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"settings","outputs":[{"internalType":"contract ID4ASetting","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"tokenid_2_canvas","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"uri_exists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b506200001c6200002c565b620000266200002c565b620000ee565b600054610100900460ff1615620000995760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff9081161015620000ec576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b61600080620000fe6000396000f3fe60806040526004361061023b5760003560e01c8063aca81db41161012e578063df6803f0116100ab578063ecf7c7361161006f578063ecf7c736146107c4578063edd11881146107f1578063f538965f14610811578063f566469c14610831578063f841058d1461089d57600080fd5b8063df6803f0146106b2578063e0566833146106d2578063e06174e414610707578063e2ec78ea1461073f578063eb6b4e8a1461075f57600080fd5b8063cc54d2b9116100f2578063cc54d2b9146105cd578063d2c8079214610632578063d3736e6314610652578063d40723f814610672578063d8ede6841461069257600080fd5b8063aca81db414610510578063ba0b881b1461054a578063c4d66de81461056a578063caafefa61461058a578063cafdf2b4146105a057600080fd5b8063454b03d1116101bc57806373c4c7d01161018057806373c4c7d014610451578063795ca680146104675780637c420877146104875780638e8cf027146104bf578063a708f535146104df57600080fd5b8063454b03d1146103a05780634d8a9ba9146103c057806357ded0ef1461040857806369755dcd1461041e578063716f9aed1461043e57600080fd5b806321001e071161020357806321001e0714610325578063262bbf8b146103455780633228fe2614610367578063348647cb1461037a5780633ec1ce3d1461038d57600080fd5b80630ceccb05146102405780630f6eb8b81461027a57806313d01e84146102a85780631f058c5e146102c85780631fcca49c146102f8575b600080fd5b34801561024c57600080fd5b5061026061025b366004614fe0565b6108dd565b604080519283526020830191909152015b60405180910390f35b34801561028657600080fd5b5061029a610295366004614ff9565b610986565b604051908152602001610271565b6102bb6102b636600461505f565b6109d6565b604051610271919061510b565b3480156102d457600080fd5b5061029a6102e3366004614fe0565b60009081526034602052604090206003015490565b34801561030457600080fd5b5061029a610313366004614fe0565b60009081526034602052604090205490565b34801561033157600080fd5b5061029a610340366004614ff9565b610b1d565b34801561035157600080fd5b50610365610360366004614fe0565b610b32565b005b61029a610375366004615190565b610b43565b61029a61038836600461525f565b610be0565b61029a61039b3660046152e0565b610e3d565b3480156103ac57600080fd5b5061029a6103bb366004614fe0565b611001565b3480156103cc57600080fd5b506103f36103db366004614fe0565b60726020526000908152604090205463ffffffff1681565b60405163ffffffff9091168152602001610271565b34801561041457600080fd5b5061029a603c5481565b34801561042a57600080fd5b5061029a610439366004614fe0565b6111f8565b61029a61044c36600461535a565b611426565b34801561045d57600080fd5b5061029a603a5481565b34801561047357600080fd5b5061029a610482366004614fe0565b61165b565b34801561049357600080fd5b5061029a6104a2366004614ff9565b603b60209081526000928352604080842090915290825290205481565b3480156104cb57600080fd5b506103656104da3660046153e8565b611672565b3480156104eb57600080fd5b506104ff6104fa366004614fe0565b6116a0565b60405161027195949392919061544b565b34801561051c57600080fd5b5061053061052b366004614fe0565b61175c565b6040516102719e9d9c9b9a99989796959493929190615484565b34801561055657600080fd5b5061029a610565366004614fe0565b61186f565b34801561057657600080fd5b506103656105853660046153e8565b61187c565b34801561059657600080fd5b5061029a603d5481565b3480156105ac57600080fd5b506105c06105bb366004614fe0565b611a6e565b6040516102719190615533565b3480156105d957600080fd5b506106126105e8366004614fe0565b600090815260336020526040902060078101546008909101546001600160a01b0391821692911690565b604080516001600160a01b03938416815292909116602083015201610271565b34801561063e57600080fd5b5061029a61064d366004614fe0565b611a7b565b34801561065e57600080fd5b5061029a61066d366004614fe0565b611a92565b34801561067e57600080fd5b5061036561068d366004614ff9565b611c8d565b34801561069e57600080fd5b5061029a6106ad366004614ff9565b611cbd565b3480156106be57600080fd5b5061029a6106cd366004614fe0565b611ccb565b3480156106de57600080fd5b506106f26106ed366004614fe0565b611dae565b60405161027199989796959493929190615546565b34801561071357600080fd5b50603854610727906001600160a01b031681565b6040516001600160a01b039091168152602001610271565b34801561074b57600080fd5b5061036561075a366004615815565b611de3565b34801561076b57600080fd5b506107a461077a366004614fe0565b60366020526000908152604090206001810154600282015460038301546004909301549192909184565b604080519485526020850193909352918301526060820152608001610271565b3480156107d057600080fd5b5061029a6107df366004614fe0565b60376020526000908152604090205481565b3480156107fd57600080fd5b5061029a61080c366004614fe0565b61217c565b34801561081d57600080fd5b5061029a61082c3660046158e1565b612248565b34801561083d57600080fd5b5061087d61084c366004614fe0565b6035602090815260009182526040918290208251808401909352805483526001810154918301919091526002015482565b604080518351815260209384015193810193909352820152606001610271565b3480156108a957600080fd5b506108cd6108b8366004614fe0565b60396020526000908152604090205460ff1681565b6040519015158152602001610271565b600081815260346020908152604080832054808452603590925280832090516326b2783560e21b81528392917304f3b90a9cdd13d7474af8bbdaefbfa6cfa6f52b91639ac9e0d49161093c918890600401918252602082015260400190565b6040805180830381865af4158015610958573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097c919061591a565b9250925050915091565b60006037600084846040516020016109a8929190918252602082015260400190565b6040516020818303038152906040528051906020012081526020019081526020016000205490505b92915050565b60606109e0612405565b836109f48a338a8a63ffffffff861661245e565b60005b8163ffffffff168163ffffffff161015610aa857610aa08a88888463ffffffff16818110610a2757610a2761593e565b9050602002810190610a399190615954565b610a439080615974565b8a8a8663ffffffff16818110610a5b57610a5b61593e565b9050602002810190610a6d9190615954565b6020013589898763ffffffff16818110610a8957610a8961593e565b9050602002810190610a9b9190615974565b61248f565b6001016109f7565b5060008a815260726020908152604080832033845260010190915281208054839290610adb90849063ffffffff166159d0565b92506101000a81548163ffffffff021916908363ffffffff160217905550610b058a8a8888612715565b915050610b1160018055565b98975050505050505050565b6000610b2b60348484613223565b9392505050565b6000610b3d8161325c565b50603a55565b6000610b4d612405565b610b5b8a338888600161245e565b610b6989898987878761248f565b60008a815260726020908152604080832033845260019081019092528220805491929091610b9e90849063ffffffff166159d0565b92506101000a81548163ffffffff021916908363ffffffff160217905550610bc889898987613269565b9050610bd360018055565b9998505050505050505050565b6000610bea612405565b603860009054906101000a90046001600160a01b03166001600160a01b0316636c099bad6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c3d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c6191906159f4565b610c6a81613996565b610c726139ca565b610c7c8585613a61565b603860009054906101000a90046001600160a01b03166001600160a01b031663b5b33f3c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ccf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cf39190615a11565b8310610d125760405163a41b6c2160e01b815260040160405180910390fd5b603d54831c60011615610d3857604051633863d17960e11b815260040160405180910390fd5b603d8054600180861b909117909155604051603990600090610d609089908990602001615a2a565b60405160208183030381529060405280519060200120815260200190815260200160002060006101000a81548160ff021916908315150217905550603373e000362b382a2fd0c0b5e1dddabcb73154a961fa63af5c918c9091603860009054906101000a90046001600160a01b03168d8d8d8d8d8b8e8e6040518b63ffffffff1660e01b8152600401610dfc9a99989796959493929190615a63565b602060405180830381865af4158015610e19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b059190615a11565b6000610e47612405565b603860009054906101000a90046001600160a01b03166001600160a01b0316636c099bad6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ebe91906159f4565b610ec781613996565b610ecf6139ca565b8383610edb8282613a61565b6001603960008888604051602001610ef4929190615a2a565b60405160208183030381529060405280519060200120815260200190815260200160002060006101000a81548160ff021916908315150217905550603373e000362b382a2fd0c0b5e1dddabcb73154a961fa63af5c918c9091603860009054906101000a90046001600160a01b03168e8e8e8e8e603a548f8f6040518b63ffffffff1660e01b8152600401610f929a99989796959493929190615a63565b602060405180830381865af4158015610faf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd39190615a11565b603a80549195506000610fe583615acb565b9190505550505050610ff660018055565b979650505050505050565b60008181526034602090815260408083205480845260338352818420603854835163c82e011f60e01b81529351929491936111f0936001600160a01b039092169263c82e011f926004808401938290030181865afa158015611067573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061108b91906159f4565b6001600160a01b0316638a19c8bc6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ec9190615a11565b82600c0180548060200260200160405190810160405280929190818152602001828054801561113a57602002820191906000526020600020905b815481526020019060010190808311611126575b5050505050836002015484600001548886600f01546000146111605786600f01546111d7565b603860009054906101000a90046001600160a01b03166001600160a01b0316639a876e296040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111d79190615a11565b6000898152603560205260409020959493929190613a8d565b949350505050565b6000611202612405565b61120a6139ca565b8161121481613bca565b8261121e81613c58565b60008481526034602052604090205461123681613c8a565b61123f81613bca565b60008181526033602052604090819020603854600782015482546001840154600b8501549551630b16ddef60e41b81529495739db91240165e2a5463d3e53903c646b7f1a7058b9563b16ddef0956112b2956036956001600160a01b03928316958c959390921693909290600401615ae4565b602060405180830381865af41580156112cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f39190615a11565b50603854600782015482546001840154600b8501546040516392ba1b8960e01b8152603660048201526001600160a01b03958616602482015260448101889052606481018c905294909316608485015260a484019190915260c483015260e4820152600090739db91240165e2a5463d3e53903c646b7f1a7058b906392ba1b899061010401602060405180830381865af4158015611395573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b99190615a11565b600783015460408051868152602081018b90526001600160a01b0390921690820152606081018290529091507fbe12aa6db02b67b3415bcd1b86c2d53ad3b2a71feb9e0fd23f683b2e69f918409060800160405180910390a194505050505061142160018055565b919050565b6000611430612405565b603860009054906101000a90046001600160a01b03166001600160a01b03166337ccefc96040518163ffffffff1660e01b8152600401602060405180830381865afa158015611483573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114a791906159f4565b6040516388c9546960e01b8152600481018890523360248201526001600160a01b0391909116906388c9546990604401602060405180830381865afa1580156114f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115189190615b23565b15611536576040516309550c7760e01b815260040160405180910390fd5b603860009054906101000a90046001600160a01b03166001600160a01b03166337ccefc96040518163ffffffff1660e01b8152600401602060405180830381865afa158015611589573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ad91906159f4565b6001600160a01b031663c64929c5873386866040518563ffffffff1660e01b81526004016115de9493929190615b45565b602060405180830381865afa1580156115fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061161f9190615b23565b61163c57604051632d85515d60e11b815260040160405180910390fd5b611647868686613cbc565b905061165260018055565b95945050505050565b6000818152603460205260408120600201546109d0565b600061167d8161325c565b50603880546001600160a01b0319166001600160a01b0392909216919091179055565b6034602052600090815260409020805460028201546003830154600484018054939492939192916116d090615b96565b80601f01602080910402602001604051908101604052809291908181526020018280546116fc90615b96565b80156117495780601f1061171e57610100808354040283529160200191611749565b820191906000526020600020905b81548152906001019060200180831161172c57829003601f168201915b5050506005909301549192505060ff1685565b603360205260009081526040902080546001820154600283015460038401546004850154600586015460068701546007880154600889015460098a0154600a8b0180549a9b999a9899979896976001600160601b039096169694956001600160a01b039485169593851694909216926117d490615b96565b80601f016020809104026020016040519081016040528092919081815260200182805461180090615b96565b801561184d5780601f106118225761010080835404028352916020019161184d565b820191906000526020600020905b81548152906001019060200180831161183057829003601f168201915b50505050600b830154600e840154600f909401549293909260ff90911691508e565b60006109d0603383613e1b565b600054610100900460ff161580801561189c5750600054600160ff909116105b806118b65750303b1580156118b6575060005460ff166001145b61191e5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff191660011790558015611941576000805461ff0019166101001790555b611949613e59565b603880546001600160a01b0319166001600160a01b03841690811790915560408051632d6ccfcf60e21b8152905163b5b33f3c916004808201926020929091908290030181865afa1580156119a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119c69190615a11565b603a81905550611a246040518060400160405280601981526020017f44344150726f746f636f6c576974685065726d697373696f6e00000000000000815250604051806040016040528060018152602001603160f81b815250613e88565b8015611a6a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b60606109d0603483613eb9565b6000818152603360205260408120600d01546109d0565b6000611a9c612405565b611aa46139ca565b81611aae81613bca565b82611ab881613c8a565b60008481526033602052604090819020603854600782015482546001840154600b8501549551630b16ddef60e41b81529495739db91240165e2a5463d3e53903c646b7f1a7058b9563b16ddef095611b2b956036956001600160a01b03928316958f959390921693909290600401615ae4565b602060405180830381865af4158015611b48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b6c9190615a11565b5060006036739db91240165e2a5463d3e53903c646b7f1a7058b636b5159e49091603860009054906101000a90046001600160a01b0316898660070160009054906101000a90046001600160a01b03168760000154886001015489600b01546040518863ffffffff1660e01b8152600401611bed9796959493929190615ae4565b602060405180830381865af4158015611c0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c2e9190615a11565b6007830154604080518981526001600160a01b03909216602083015281018290529091507f0759b1bb04364351c56f2db6d1a0283eb1a5d122b14dceec6df12408451500679060600160405180910390a1935050505061142160018055565b6000611c988161325c565b612710821015611ca757600080fd5b50600091825260336020526040909120600f0155565b6000610b2b60338484613f62565b600080611cd7836111f8565b600084815260346020908152604080832054808452603390925291829020603854600782015460098301549451631545c34f60e11b81526001600160a01b03928316600482015260248101859052604481018a9052908216606482015260848101869052931660a4840152603b60c48401529293509190739db91240165e2a5463d3e53903c646b7f1a7058b90632a8b869e9060e401602060405180830381865af4158015611d8a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116529190615a11565b6000808080808080606081611dc460338b613f86565b9850985098509850985098509850985098509193959799909294969850565b603860009054906101000a90046001600160a01b03166001600160a01b0316636c099bad6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e5a91906159f4565b6001600160a01b0316336001600160a01b031614158015611f715750603860009054906101000a90046001600160a01b03166001600160a01b031663cb023e6d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ec9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eed91906159f4565b6001600160a01b0316637dd56411886040518263ffffffff1660e01b8152600401611f1a91815260200190565b602060405180830381865afa158015611f37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f5b91906159f4565b6001600160a01b0316336001600160a01b031614155b15611f8f576040516308b3412160e31b815260040160405180910390fd5b6000878152607260205260408120805463ffffffff191663ffffffff89161781559085905b8181101561205a57878782818110611fce57611fce61593e565b9050604002016020016020810190611fe69190615bd0565b8360010160008a8a85818110611ffe57611ffe61593e565b61201492602060409092020190810191506153e8565b6001600160a01b031681526020810191909152604001600020805463ffffffff929092166401000000000267ffffffff0000000019909216919091179055600101611fb4565b50887f21f6fa02312382a44060ea83b88540e2bacbf8142d73d968893a89adfdada97989898960405161208f93929190615beb565b60405180910390a2603860009054906101000a90046001600160a01b03166001600160a01b03166337ccefc96040518163ffffffff1660e01b8152600401602060405180830381865afa1580156120ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210e91906159f4565b6001600160a01b031663a0e29b3d8a8787876040518563ffffffff1660e01b815260040161213f9493929190615ccf565b600060405180830381600087803b15801561215957600080fd5b505af115801561216d573d6000803e3d6000fd5b50505050505050505050505050565b60008061218883611a92565b6000848152603360205260409081902060385460078201546009830154935163db2a72db60e01b81526001600160a01b0392831660048201526024810189905290821660448201526064810185905292166084830152603b60a4830152919250739db91240165e2a5463d3e53903c646b7f1a7058b9063db2a72db9060c401602060405180830381865af4158015612224573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111f09190615a11565b6000612252612405565b61225a6139ca565b8361226481613bca565b60006033600087815260200190815260200160002090506036739db91240165e2a5463d3e53903c646b7f1a7058b63b16ddef09091603860009054906101000a90046001600160a01b0316898560070160009054906101000a90046001600160a01b03168660000154876001015488600b01546040518863ffffffff1660e01b81526004016122f99796959493929190615ae4565b602060405180830381865af4158015612316573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061233a9190615a11565b5060385460078201546009830154604051636b42b9f760e11b81526001600160a01b0393841660048201529183166024830152821660448201526064810188905233608482015290851660a482015260c48101869052603b60e4820152739db91240165e2a5463d3e53903c646b7f1a7058b9063d68573ee9061010401602060405180830381865af41580156123d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123f89190615a11565b92505050610b2b60018055565b6002600154036124575760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401611915565b6002600155565b61246b8585858585614082565b612488576040516360be3b5960e01b815260040160405180910390fd5b5050505050565b60006125107f4713f5ab3c889f9d03bca02aa53c0e46eea41f9844ed52981b46bce7261fb9498888886040516124c6929190615a2a565b6040519081900381206124f5939291899060200193845260208401929092526040830152606082015260800190565b60405160208183030381529060405280519060200120614394565b905060006125548285858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506143e292505050565b603854604051632474521560e21b81527fe2f4eaae4a9751e85a3e4a7b9587827a877f29914755229b07a7b2da98285f7060048201526001600160a01b0380841660248301529293509116906391d1485490604401602060405180830381865afa1580156125c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125ea9190615b23565b1580156126ed5750603860009054906101000a90046001600160a01b03166001600160a01b031663cb023e6d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612645573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061266991906159f4565b6001600160a01b0316637dd56411896040518263ffffffff1660e01b815260040161269691815260200190565b602060405180830381865afa1580156126b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126d791906159f4565b6001600160a01b0316816001600160a01b031614155b1561270b57604051638baa579f60e01b815260040160405180910390fd5b5050505050505050565b606061271f6139ca565b61272885613bca565b61273184613c58565b61273a84613bca565b612742614f3c565b63ffffffff808416825260009061275e906033908990613e1b16565b905060005b826000015163ffffffff168163ffffffff161015612845576127b786868363ffffffff168181106127965761279661593e565b90506020028101906127a89190615954565b6127b29080615974565b613a61565b85858263ffffffff168181106127cf576127cf61593e565b90506020028101906127e19190615954565b602001351580159061281f57508186868363ffffffff168181106128075761280761593e565b90506020028101906128199190615954565b60200135105b1561283d57604051636dddf41160e11b815260040160405180910390fd5b600101612763565b505060008681526033602090815260408083208884526034909252909120600382015460048301541061288b5760405163156c453b60e31b815260040160405180910390fd5b603860009054906101000a90046001600160a01b03166001600160a01b031663c82e011f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156128de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061290291906159f4565b6001600160a01b0316638a19c8bc6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561293f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129639190615a11565b6020840152600f8201541561297c5781600f01546129f3565b603860009054906101000a90046001600160a01b03166001600160a01b0316639a876e296040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129f39190615a11565b60408401526127106060840152612a08614f95565b888152602080850151604080840191909152600c850180548251818502810185019093528083529192909190830182828015612a6357602002820191906000526020600020905b815481526020019060010190808311612a4f575b5050505050606082015260028301546080820152825460a0820152604084015160c0820152612a9181614406565b60808501819052610120850152835160009063ffffffff166001600160401b03811115612ac057612ac0615605565b604051908082528060200260200182016040528015612ae9578160200160208202803683370190505b5090506000603860009054906101000a90046001600160a01b03166001600160a01b031663bd33275f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b659190615a11565b90506000603860009054906101000a90046001600160a01b03166001600160a01b0316634c66124c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be09190615a11565b905060005b876000015163ffffffff168163ffffffff1610156130225760008b8b8363ffffffff16818110612c1757612c1761593e565b9050602002810190612c299190615954565b612c339080615974565b604051602001612c44929190615a2a565b60408051601f198184030181529181528151602092830120600090815260399092529020805460ff191660011790555060088701546001600160a01b031663110bcd45338d8d63ffffffff8616818110612ca057612ca061593e565b9050602002810190612cb29190615954565b612cbc9080615974565b6040518463ffffffff1660e01b8152600401612cda93929190615d4c565b6020604051808303816000875af1158015612cf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d1d9190615a11565b848263ffffffff1681518110612d3557612d3561593e565b6020908102919091010152600487018054906000612d5283615acb565b919050555085600101848263ffffffff1681518110612d7357612d7361593e565b602090810291909101810151825460018101845560009384529183209091015560028701805491612da383615acb565b91905055508b603760008f878563ffffffff1681518110612dc657612dc661593e565b6020026020010151604051602001612de8929190918252602082015260400190565b6040516020818303038152906040528051906020012081526020019081526020016000208190555060008b8b8363ffffffff16818110612e2a57612e2a61593e565b9050602002810190612e3c9190615954565b60200135905080600003612f4d576080890151612e599085615d71565b8960a001818151612e6a9190615d88565b905250608089015160c08a018051612e83908390615d88565b915081815250507f5a2ad185679629c6f79a7ca8c3b2f337d1c8bce787a38af1b8a6b798a9d01e898e8e878563ffffffff1681518110612ec557612ec561593e565b60200260200101518f8f8763ffffffff16818110612ee557612ee561593e565b9050602002810190612ef79190615954565b612f019080615974565b8e60800151604051612f1896959493929190615d9b565b60405180910390a188606001518960400151612f349190615dd4565b89608001818151612f459190615d71565b905250613019565b612f578184615d71565b8960a001818151612f689190615d88565b90525060c089018051829190612f7f908390615d88565b915081815250507f5a2ad185679629c6f79a7ca8c3b2f337d1c8bce787a38af1b8a6b798a9d01e898e8e878563ffffffff1681518110612fc157612fc161593e565b60200260200101518f8f8763ffffffff16818110612fe157612fe161593e565b9050602002810190612ff39190615954565b612ffd9080615974565b8660405161301096959493929190615d9b565b60405180910390a15b50600101612be5565b5050506000603860009054906101000a90046001600160a01b03166001600160a01b031663117ec9196040518163ffffffff1660e01b8152600401602060405180830381865afa15801561307a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061309e91906159f4565b60098601546038546040805163cb023e6d60e01b815290519394506001600160a01b03928316936000939092169163cb023e6d916004808201926020929091908290030181865afa1580156130f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061311b91906159f4565b6001600160a01b0316637dd564118d6040518263ffffffff1660e01b815260040161314891815260200190565b602060405180830381865afa158015613165573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061318991906159f4565b90506131a08383838b60c001518c60a0015161445c565b6101008a015260e0890152505050610120850151608086015114613203578460400151856060015186608001516131d79190615d71565b6131e19190615dd4565b6080860181905260208601516040870151613203928d918d91906000906145eb565b610bd38a8a8760e001518861010001518960c00151614616565b60018055565b6000828152602084905260408120600181018054849081106132475761324761593e565b90600052602060002001549150509392505050565b6132668133614991565b50565b60006132736139ca565b61327c85613bca565b61328585613c58565b61328f8484613a61565b60008581526034602052604090205482158015906132b657506132b3603382613e1b565b83105b156132d457604051636dddf41160e11b815260040160405180910390fd5b6132dd81613bca565b6000818152603360209081526040808320898452603490925290912060038201546004830154106133215760405163156c453b60e31b815260040160405180910390fd5b613329614f3c565b603860009054906101000a90046001600160a01b03166001600160a01b031663c82e011f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561337c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133a091906159f4565b6001600160a01b0316638a19c8bc6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156133dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134019190615a11565b6020820152600f8301541561341a5782600f0154613491565b603860009054906101000a90046001600160a01b03166001600160a01b0316639a876e296040518163ffffffff1660e01b8152600401602060405180830381865afa15801561346d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134919190615a11565b816040018181525050600088886040516020016134af929190615a2a565b60408051601f198184030181529181528151602092830120600090815260399092529020805460ff19166001179055506134e7614f95565b84815260208082018b905282810151604080840191909152600c86018054825181850281018501909352808352919290919083018282801561354857602002820191906000526020600020905b815481526020019060010190808311613534575b5050505050606082015260028401546080820152835460a0820152604082015160c082015260e08101879052600061357f82614406565b90506000603860009054906101000a90046001600160a01b03166001600160a01b031663117ec9196040518163ffffffff1660e01b8152600401602060405180830381865afa1580156135d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135fa91906159f4565b60098701546038546040805163cb023e6d60e01b815290519394506001600160a01b03928316936000939092169163cb023e6d916004808201926020929091908290030181865afa158015613653573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061367791906159f4565b6001600160a01b0316637dd564118f6040518263ffffffff1660e01b81526004016136a491815260200190565b602060405180830381865afa1580156136c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136e591906159f4565b90506000848c1561376c57603860009054906101000a90046001600160a01b03166001600160a01b0316634c66124c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613743573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137679190615a11565b6137e3565b603860009054906101000a90046001600160a01b03166001600160a01b031663bd33275f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156137bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137e39190615a11565b6137ed9190615d71565b90506137fc848484888561445c565b61010089015260e088015250505060208401516040850151613826925088908e9085908d906145eb565b61383c868c8560e0015186610100015185614616565b600885015460405163110bcd4560e01b81526001600160a01b039091169063110bcd45906138729033908e908e90600401615d4c565b6020604051808303816000875af1158015613891573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138b59190615a11565b60048601805491985060006138c983615acb565b9091555050600180850180549182018155600090815260208120909101889055600285018054916138f983615acb565b91905055508a60376000888a60405160200161391f929190918252602082015260400190565b604051602081830303815290604052805190602001208152602001908152602001600020819055507f5a2ad185679629c6f79a7ca8c3b2f337d1c8bce787a38af1b8a6b798a9d01e89868c898d8d8660405161398096959493929190615d9b565b60405180910390a1505050505050949350505050565b6001600160a01b0381163314613266576040516377ed384360e11b81526001600160a01b0382166004820152602401611915565b603860009054906101000a90046001600160a01b03166001600160a01b0316632a53c6b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015613a1d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a419190615b23565b15613a5f576040516314f8ad9d60e01b815260040160405180910390fd5b565b613a6b82826149ca565b15611a6a5781816040516362eb37c960e01b8152600401611915929190615df6565b600080868681518110613aa257613aa261593e565b602002602001015190508860000160000154600003613ae857848803613ac9579050610ff6565b82613ad661271083615d71565b613ae09190615dd4565b915050610ff6565b600084815260048a01602090815260408083208151808301909252805482526001015491810191909152613b1d908a86614a13565b9050818110613b2f579150610ff69050565b604080518082019091528a54815260018b01546020820152613b52908a86614a13565b9050818110613b6357509050610ff6565b83613b7061271084615d71565b613b7a9190615dd4565b60018b0154148015613b9857508954613b94906001615d88565b8911155b15613ba557509050610ff6565b83613bb261271084615d71565b613bbc9190615dd4565b9a9950505050505050505050565b60385460405163520b085b60e11b8152600481018390526001600160a01b039091169063a41610b690602401602060405180830381865afa158015613c13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c379190615b23565b1561326657604051630cb09dc760e01b815260048101829052602401611915565b60008181526034602052604090206005015460ff166132665760405163052bdfe560e41b815260040160405180910390fd5b6000818152603360205260409020600e015460ff16613266576040516361b7c4e560e01b815260040160405180910390fd5b6000613cc66139ca565b83613cd081613c8a565b84613cda81613bca565b8484613ce68282613a61565b6001603960008989604051602001613cff929190615a2a565b60408051808303601f1901815291815281516020928301208352828201939093529082016000908120805460ff1916941515949094179093556038548b84526033909152912060098101548154600d90920154734815525d8a3765589cfc8986452a6c0192bc0a01936372964a45936034936001600160a01b03928316939216918e91908e8e6040518963ffffffff1660e01b8152600401613da8989796959493929190615e0a565b602060405180830381865af4158015613dc5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613de99190615a11565b60009889526033602090815260408a20600d018054600181018255908b52992090980188905550959695505050505050565b60008181526020839052604081206002810154600c820180549091908110613e4557613e4561593e565b906000526020600020015491505092915050565b600054610100900460ff16613e805760405162461bcd60e51b815260040161191590615e4e565b613a5f614ab0565b600054610100900460ff16613eaf5760405162461bcd60e51b815260040161191590615e4e565b611a6a8282614ad7565b60008181526020839052604090206004810180546060929190613edb90615b96565b80601f0160208091040260200160405190810160405280929190818152602001828054613f0790615b96565b8015613f545780601f10613f2957610100808354040283529160200191613f54565b820191906000526020600020905b815481529060010190602001808311613f3757829003601f168201915b505050505091505092915050565b6000828152602084905260408120600d81018054849081106132475761324761593e565b60008181526020839052604081208054600182015460028301546003840154600985015460058601546006870154600a8801805497999698959794966001600160a01b03909416956001600160601b039093169491936060939092909190613fed90615b96565b80601f016020809104026020016040519081016040528092919081815260200182805461401990615b96565b80156140665780601f1061403b57610100808354040283529160200191614066565b820191906000526020600020905b81548152906001019060200180831161404957829003601f168201915b5050505050925080600b01549150509295985092959850929598565b600080603860009054906101000a90046001600160a01b03166001600160a01b03166337ccefc96040518163ffffffff1660e01b8152600401602060405180830381865afa1580156140d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140fc91906159f4565b60405163f863a81360e01b8152600481018990526001600160a01b0388811660248301529192509082169063f863a81390604401602060405180830381865afa15801561414d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141719190615b23565b1561418f576040516309550c7760e01b815260040160405180910390fd5b600087815260726020908152604080832080546001600160a01b038b811686526001909201845282852083518085018552905463ffffffff808216808452640100000000909204811692909601829052935163dabd56a560e01b8152600481018e90529490911694929390929182919087169063dabd56a590602401600060405180830381865afa158015614228573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526142509190810190615efd565b80519091501580156142655750602081015151155b91506000905061427e886001600160801b038616615d88565b905081156142b15763ffffffff8516156142a1578463ffffffff168111156142a4565b60015b9650505050505050611652565b6040516332903e6f60e11b81526001600160a01b038716906365207cde906142e3908f908f908f908f90600401615b45565b602060405180830381865afa158015614300573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143249190615b23565b61434157604051632d85515d60e11b815260040160405180910390fd5b826001600160801b0316600003614376578463ffffffff16600003614367576001614384565b8463ffffffff16811115614384565b826001600160801b03168111155b9c9b505050505050505050505050565b60006109d06143a1614b18565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b60008060006143f18585614b98565b915091506143fe81614bdd565b509392505050565b60008160e00151600003614454576040808301516060840151608085015160a086015160208088015160c0890151895160009081526035909352969091206109d09690959493929190613a8d565b5060e0015190565b6000808334101561448057604051638a0d377960e01b815260040160405180910390fd5b600061448c8534615fa1565b90506000603860009054906101000a90046001600160a01b03166001600160a01b0316630e7752746040518163ffffffff1660e01b8152600401602060405180830381865afa1580156144e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145079190615a11565b90506145138186615dd4565b935080603860009054906101000a90046001600160a01b03166001600160a01b0316630a8027da6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614569573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061458d9190615a11565b6145979088615d71565b6145a19190615dd4565b92506145ad8984614d27565b6145b78885614d27565b6145d587846145c6878a615fa1565b6145d09190615fa1565b614d27565b6145df3383614d27565b50509550959350505050565b8160000361460e57600085815260356020526040902061460e9087868685614dac565b505050505050565b600085815260336020908152604080832081516102008101835281548152600182015493810193909352600281015491830191909152600381015460608301526004810154608083015260058101546001600160601b031660a0830152600681015460c083015260078101546001600160a01b0390811660e084015260088201548116610100840152600982015416610120830152600a81018054610140840191906146c190615b96565b80601f01602080910402602001604051908101604052809291908181526020018280546146ed90615b96565b801561473a5780601f1061470f5761010080835404028352916020019161473a565b820191906000526020600020905b81548152906001019060200180831161471d57829003601f168201915b50505050508152602001600b8201548152602001600c820180548060200260200160405190810160405280929190818152602001828054801561479c57602002820191906000526020600020905b815481526020019060010190808311614788575b50505050508152602001600d82018054806020026020016040519081016040528092919081815260200182805480156147f457602002820191906000526020600020905b8154815260200190600101908083116147e0575b5050509183525050600e82015460ff1615156020820152600f90910154604090910152603854909150739db91240165e2a5463d3e53903c646b7f1a7058b90633dedcf9a906036906001600160a01b03168989886148528b8a615fa1565b61485c9190615fa1565b60208801516040516001600160e01b031960e089901b16815260048101969096526001600160a01b03909416602486015260448501929092526064840152608483015260a4820188905260c4820152603b60e48201526101040160006040518083038186803b1580156148ce57600080fd5b505af41580156148e2573d6000803e3d6000fd5b50506038548351602085015161016086015160405163566f93a160e11b8152603660048201526001600160a01b039094166024850152604484018c9052606484018b9052608484019290925260a483015260c4820152739db91240165e2a5463d3e53903c646b7f1a7058b925063acdf2742915060e40160006040518083038186803b15801561497157600080fd5b505af4158015614985573d6000803e3d6000fd5b50505050505050505050565b61499b8282614e02565b611a6a5760405163678f4fa960e01b8152600481018390526001600160a01b0382166024820152604401611915565b60006039600084846040516020016149e3929190615a2a565b60408051808303601f190181529181528151602092830120835290820192909252016000205460ff169392505050565b82516000908303614a4257612710828560200151614a319190615d71565b614a3b9190615dd4565b9050610b2b565b8351600090600190614a549086615fa1565b614a5e9190615fa1565b602086015190915060005b82811015614aa65784614a7e61271084615d71565b614a889190615dd4565b915081600003614a9e5760009350505050610b2b565b600101614a69565b5095945050505050565b600054610100900460ff1661321d5760405162461bcd60e51b815260040161191590615e4e565b600054610100900460ff16614afe5760405162461bcd60e51b815260040161191590615e4e565b815160209283012081519190920120603e91909155603f55565b6000614b937f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f614b47603e5490565b603f546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b905090565b6000808251604103614bce5760208301516040840151606085015160001a614bc287828585614e78565b94509450505050614bd6565b506000905060025b9250929050565b6000816004811115614bf157614bf1615fb4565b03614bf95750565b6001816004811115614c0d57614c0d615fb4565b03614c5a5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401611915565b6002816004811115614c6e57614c6e615fb4565b03614cbb5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401611915565b6003816004811115614ccf57614ccf615fb4565b036132665760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401611915565b80600003614d33575050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114614d80576040519150601f19603f3d011682016040523d82523d6000602084013e614d85565b606091505b5050905080614da757604051630db2c7f160e31b815260040160405180910390fd5b505050565b604080518082019091528554815260018601546020820152600090614dd2908684614a13565b9050808310614de657848655600186018390555b5050600091825260049093016020526040902090815560010155565b603854604051632474521560e21b8152600481018490526001600160a01b03838116602483015260009216906391d1485490604401602060405180830381865afa158015614e54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2b9190615b23565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115614eaf5750600090506003614f33565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015614f03573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116614f2c57600060019250925050614f33565b9150600090505b94509492505050565b604051806101400160405280600063ffffffff1681526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60405180610100016040528060008019168152602001600080191681526020016000815260200160608152602001600081526020016000815260200160008152602001600081525090565b600060208284031215614ff257600080fd5b5035919050565b6000806040838503121561500c57600080fd5b50508035926020909101359150565b60008083601f84011261502d57600080fd5b5081356001600160401b0381111561504457600080fd5b6020830191508360208260051b8501011115614bd657600080fd5b60008060008060008060008060a0898b03121561507b57600080fd5b883597506020890135965060408901356001600160401b03808211156150a057600080fd5b6150ac8c838d0161501b565b909850965060608b01359150808211156150c557600080fd5b6150d18c838d0161501b565b909650945060808b01359150808211156150ea57600080fd5b506150f78b828c0161501b565b999c989b5096995094979396929594505050565b6020808252825182820181905260009190848201906040850190845b8181101561514357835183529284019291840191600101615127565b50909695505050505050565b60008083601f84011261516157600080fd5b5081356001600160401b0381111561517857600080fd5b602083019150836020828501011115614bd657600080fd5b600080600080600080600080600060c08a8c0312156151ae57600080fd5b8935985060208a0135975060408a01356001600160401b03808211156151d357600080fd5b6151df8d838e0161514f565b909950975060608c01359150808211156151f857600080fd5b6152048d838e0161501b565b909750955060808c0135945060a08c013591508082111561522457600080fd5b506152318c828d0161514f565b915080935050809150509295985092959850929598565b80356001600160601b038116811461142157600080fd5b60008060008060008060008060e0898b03121561527b57600080fd5b883597506020890135965060408901359550606089013594506152a060808a01615248565b935060a08901356001600160401b038111156152bb57600080fd5b6152c78b828c0161514f565b999c989b50969995989497949560c00135949350505050565b600080600080600080600060c0888a0312156152fb57600080fd5b8735965060208801359550604088013594506060880135935061532060808901615248565b925060a08801356001600160401b0381111561533b57600080fd5b6153478a828b0161514f565b989b979a50959850939692959293505050565b60008060008060006060868803121561537257600080fd5b8535945060208601356001600160401b038082111561539057600080fd5b61539c89838a0161514f565b909650945060408801359150808211156153b557600080fd5b506153c28882890161501b565b969995985093965092949392505050565b6001600160a01b038116811461326657600080fd5b6000602082840312156153fa57600080fd5b8135610b2b816153d3565b6000815180845260005b8181101561542b5760208185018101518683018201520161540f565b506000602082860101526020601f19601f83011685010191505092915050565b85815284602082015283604082015260a06060820152600061547060a0830185615405565b905082151560808301529695505050505050565b8e81528d60208201528c60408201528b60608201528a60808201526001600160601b038a1660a08201528860c082015260018060a01b03881660e08201526154d86101008201886001600160a01b03169052565b6001600160a01b0386166101208201526101c061014082015260006155016101c0830187615405565b90508461016083015261551961018083018515159052565b826101a08301529f9e505050505050505050505050505050565b602081526000610b2b6020830184615405565b60006101208b83528a602084015289604084015288606084015260018060a01b03881660808401526001600160601b03871660a08401528560c08401528060e084015261559581840186615405565b915050826101008301529a9950505050505050505050565b803563ffffffff8116811461142157600080fd5b60008083601f8401126155d357600080fd5b5081356001600160401b038111156155ea57600080fd5b6020830191508360208260061b8501011115614bd657600080fd5b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b038111828210171561563d5761563d615605565b60405290565b604051601f8201601f191681016001600160401b038111828210171561566b5761566b615605565b604052919050565b60006001600160401b0382111561568c5761568c615605565b5060051b60200190565b600082601f8301126156a757600080fd5b813560206156bc6156b783615673565b615643565b82815260059290921b840181019181810190868411156156db57600080fd5b8286015b848110156156ff5780356156f2816153d3565b83529183019183016156df565b509695505050505050565b60006080828403121561571c57600080fd5b61572461561b565b90508135815260208201356001600160401b038082111561574457600080fd5b61575085838601615696565b602084015260408401356040840152606084013591508082111561577357600080fd5b5061578084828501615696565b60608301525092915050565b60006040828403121561579e57600080fd5b604051604081016001600160401b0382821081831117156157c1576157c1615605565b8160405282935084359150808211156157d957600080fd5b6157e586838701615696565b835260208501359150808211156157fb57600080fd5b5061580885828601615696565b6020830152505092915050565b600080600080600080600060c0888a03121561583057600080fd5b87359650615840602089016155ad565b955060408801356001600160401b038082111561585c57600080fd5b6158688b838c016155c1565b909750955060608a013591508082111561588157600080fd5b61588d8b838c0161570a565b945060808a01359150808211156158a357600080fd5b6158af8b838c0161578c565b935060a08a01359150808211156158c557600080fd5b506158d28a828b0161578c565b91505092959891949750929550565b6000806000606084860312156158f657600080fd5b8335925060208401359150604084013561590f816153d3565b809150509250925092565b6000806040838503121561592d57600080fd5b505080516020909101519092909150565b634e487b7160e01b600052603260045260246000fd5b60008235603e1983360301811261596a57600080fd5b9190910192915050565b6000808335601e1984360301811261598b57600080fd5b8301803591506001600160401b038211156159a557600080fd5b602001915036819003821315614bd657600080fd5b634e487b7160e01b600052601160045260246000fd5b63ffffffff8181168382160190808211156159ed576159ed6159ba565b5092915050565b600060208284031215615a0657600080fd5b8151610b2b816153d3565b600060208284031215615a2357600080fd5b5051919050565b8183823760009101908152919050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60006101208c835260018060a01b038c1660208401528a60408401528960608401528860808401528760a08401526001600160601b03871660c08401528560e084015280610100840152615aba8184018587615a3a565b9d9c50505050505050505050505050565b600060018201615add57615add6159ba565b5060010190565b9687526001600160a01b0395861660208801526040870194909452919093166060850152608084019290925260a083019190915260c082015260e00190565b600060208284031215615b3557600080fd5b81518015158114610b2b57600080fd5b8481526001600160a01b0384166020820152606060408201819052810182905260006001600160fb1b03831115615b7b57600080fd5b8260051b808560808501379190910160800195945050505050565b600181811c90821680615baa57607f821691505b602082108103615bca57634e487b7160e01b600052602260045260246000fd5b50919050565b600060208284031215615be257600080fd5b610b2b826155ad565b63ffffffff848116825260406020808401829052838201859052600092869160608601855b88811015615c4f578435615c23816153d3565b6001600160a01b0316825283615c3a8685016155ad565b16828401529385019390850190600101615c10565b509998505050505050505050565b600081518084526020808501945080840160005b83811015615c965781516001600160a01b031687529582019590820190600101615c71565b509495945050505050565b6000815160408452615cb66040850182615c5d565b9050602083015184820360208601526116528282615c5d565b848152608060208201528351608082015260006020850151608060a0840152615cfc610100840182615c5d565b9050604086015160c08401526060860151607f198483030160e0850152615d238282615c5d565b9150508281036040840152615d388186615ca1565b90508281036060840152610ff68185615ca1565b6001600160a01b03841681526040602082018190526000906116529083018486615a3a565b80820281158282048414176109d0576109d06159ba565b808201808211156109d0576109d06159ba565b86815285602082015284604082015260a060608201526000615dc160a083018587615a3a565b9050826080830152979650505050505050565b600082615df157634e487b7160e01b600052601260045260246000fd5b500490565b6020815260006111f0602083018486615a3a565b888152600060018060a01b03808a1660208401528089166040840152508660608301528560808301528460a083015260e060c0830152613bbc60e083018486615a3a565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600082601f830112615eaa57600080fd5b81516020615eba6156b783615673565b82815260059290921b84018101918181019086841115615ed957600080fd5b8286015b848110156156ff578051615ef0816153d3565b8352918301918301615edd565b600060208284031215615f0f57600080fd5b81516001600160401b0380821115615f2657600080fd5b9083019060808286031215615f3a57600080fd5b615f4261561b565b82518152602083015182811115615f5857600080fd5b615f6487828601615e99565b60208301525060408301516040820152606083015182811115615f8657600080fd5b615f9287828601615e99565b60608301525095945050505050565b818103818111156109d0576109d06159ba565b634e487b7160e01b600052602160045260246000fdfea26469706673582212209de17805a6e6eb421d4453a3b70901293b0f0fde7a9f7628e1ab1ef72bfa630d64736f6c63430008120033
Deployed Bytecode
0x60806040526004361061023b5760003560e01c8063aca81db41161012e578063df6803f0116100ab578063ecf7c7361161006f578063ecf7c736146107c4578063edd11881146107f1578063f538965f14610811578063f566469c14610831578063f841058d1461089d57600080fd5b8063df6803f0146106b2578063e0566833146106d2578063e06174e414610707578063e2ec78ea1461073f578063eb6b4e8a1461075f57600080fd5b8063cc54d2b9116100f2578063cc54d2b9146105cd578063d2c8079214610632578063d3736e6314610652578063d40723f814610672578063d8ede6841461069257600080fd5b8063aca81db414610510578063ba0b881b1461054a578063c4d66de81461056a578063caafefa61461058a578063cafdf2b4146105a057600080fd5b8063454b03d1116101bc57806373c4c7d01161018057806373c4c7d014610451578063795ca680146104675780637c420877146104875780638e8cf027146104bf578063a708f535146104df57600080fd5b8063454b03d1146103a05780634d8a9ba9146103c057806357ded0ef1461040857806369755dcd1461041e578063716f9aed1461043e57600080fd5b806321001e071161020357806321001e0714610325578063262bbf8b146103455780633228fe2614610367578063348647cb1461037a5780633ec1ce3d1461038d57600080fd5b80630ceccb05146102405780630f6eb8b81461027a57806313d01e84146102a85780631f058c5e146102c85780631fcca49c146102f8575b600080fd5b34801561024c57600080fd5b5061026061025b366004614fe0565b6108dd565b604080519283526020830191909152015b60405180910390f35b34801561028657600080fd5b5061029a610295366004614ff9565b610986565b604051908152602001610271565b6102bb6102b636600461505f565b6109d6565b604051610271919061510b565b3480156102d457600080fd5b5061029a6102e3366004614fe0565b60009081526034602052604090206003015490565b34801561030457600080fd5b5061029a610313366004614fe0565b60009081526034602052604090205490565b34801561033157600080fd5b5061029a610340366004614ff9565b610b1d565b34801561035157600080fd5b50610365610360366004614fe0565b610b32565b005b61029a610375366004615190565b610b43565b61029a61038836600461525f565b610be0565b61029a61039b3660046152e0565b610e3d565b3480156103ac57600080fd5b5061029a6103bb366004614fe0565b611001565b3480156103cc57600080fd5b506103f36103db366004614fe0565b60726020526000908152604090205463ffffffff1681565b60405163ffffffff9091168152602001610271565b34801561041457600080fd5b5061029a603c5481565b34801561042a57600080fd5b5061029a610439366004614fe0565b6111f8565b61029a61044c36600461535a565b611426565b34801561045d57600080fd5b5061029a603a5481565b34801561047357600080fd5b5061029a610482366004614fe0565b61165b565b34801561049357600080fd5b5061029a6104a2366004614ff9565b603b60209081526000928352604080842090915290825290205481565b3480156104cb57600080fd5b506103656104da3660046153e8565b611672565b3480156104eb57600080fd5b506104ff6104fa366004614fe0565b6116a0565b60405161027195949392919061544b565b34801561051c57600080fd5b5061053061052b366004614fe0565b61175c565b6040516102719e9d9c9b9a99989796959493929190615484565b34801561055657600080fd5b5061029a610565366004614fe0565b61186f565b34801561057657600080fd5b506103656105853660046153e8565b61187c565b34801561059657600080fd5b5061029a603d5481565b3480156105ac57600080fd5b506105c06105bb366004614fe0565b611a6e565b6040516102719190615533565b3480156105d957600080fd5b506106126105e8366004614fe0565b600090815260336020526040902060078101546008909101546001600160a01b0391821692911690565b604080516001600160a01b03938416815292909116602083015201610271565b34801561063e57600080fd5b5061029a61064d366004614fe0565b611a7b565b34801561065e57600080fd5b5061029a61066d366004614fe0565b611a92565b34801561067e57600080fd5b5061036561068d366004614ff9565b611c8d565b34801561069e57600080fd5b5061029a6106ad366004614ff9565b611cbd565b3480156106be57600080fd5b5061029a6106cd366004614fe0565b611ccb565b3480156106de57600080fd5b506106f26106ed366004614fe0565b611dae565b60405161027199989796959493929190615546565b34801561071357600080fd5b50603854610727906001600160a01b031681565b6040516001600160a01b039091168152602001610271565b34801561074b57600080fd5b5061036561075a366004615815565b611de3565b34801561076b57600080fd5b506107a461077a366004614fe0565b60366020526000908152604090206001810154600282015460038301546004909301549192909184565b604080519485526020850193909352918301526060820152608001610271565b3480156107d057600080fd5b5061029a6107df366004614fe0565b60376020526000908152604090205481565b3480156107fd57600080fd5b5061029a61080c366004614fe0565b61217c565b34801561081d57600080fd5b5061029a61082c3660046158e1565b612248565b34801561083d57600080fd5b5061087d61084c366004614fe0565b6035602090815260009182526040918290208251808401909352805483526001810154918301919091526002015482565b604080518351815260209384015193810193909352820152606001610271565b3480156108a957600080fd5b506108cd6108b8366004614fe0565b60396020526000908152604090205460ff1681565b6040519015158152602001610271565b600081815260346020908152604080832054808452603590925280832090516326b2783560e21b81528392917304f3b90a9cdd13d7474af8bbdaefbfa6cfa6f52b91639ac9e0d49161093c918890600401918252602082015260400190565b6040805180830381865af4158015610958573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097c919061591a565b9250925050915091565b60006037600084846040516020016109a8929190918252602082015260400190565b6040516020818303038152906040528051906020012081526020019081526020016000205490505b92915050565b60606109e0612405565b836109f48a338a8a63ffffffff861661245e565b60005b8163ffffffff168163ffffffff161015610aa857610aa08a88888463ffffffff16818110610a2757610a2761593e565b9050602002810190610a399190615954565b610a439080615974565b8a8a8663ffffffff16818110610a5b57610a5b61593e565b9050602002810190610a6d9190615954565b6020013589898763ffffffff16818110610a8957610a8961593e565b9050602002810190610a9b9190615974565b61248f565b6001016109f7565b5060008a815260726020908152604080832033845260010190915281208054839290610adb90849063ffffffff166159d0565b92506101000a81548163ffffffff021916908363ffffffff160217905550610b058a8a8888612715565b915050610b1160018055565b98975050505050505050565b6000610b2b60348484613223565b9392505050565b6000610b3d8161325c565b50603a55565b6000610b4d612405565b610b5b8a338888600161245e565b610b6989898987878761248f565b60008a815260726020908152604080832033845260019081019092528220805491929091610b9e90849063ffffffff166159d0565b92506101000a81548163ffffffff021916908363ffffffff160217905550610bc889898987613269565b9050610bd360018055565b9998505050505050505050565b6000610bea612405565b603860009054906101000a90046001600160a01b03166001600160a01b0316636c099bad6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c3d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c6191906159f4565b610c6a81613996565b610c726139ca565b610c7c8585613a61565b603860009054906101000a90046001600160a01b03166001600160a01b031663b5b33f3c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ccf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cf39190615a11565b8310610d125760405163a41b6c2160e01b815260040160405180910390fd5b603d54831c60011615610d3857604051633863d17960e11b815260040160405180910390fd5b603d8054600180861b909117909155604051603990600090610d609089908990602001615a2a565b60405160208183030381529060405280519060200120815260200190815260200160002060006101000a81548160ff021916908315150217905550603373e000362b382a2fd0c0b5e1dddabcb73154a961fa63af5c918c9091603860009054906101000a90046001600160a01b03168d8d8d8d8d8b8e8e6040518b63ffffffff1660e01b8152600401610dfc9a99989796959493929190615a63565b602060405180830381865af4158015610e19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b059190615a11565b6000610e47612405565b603860009054906101000a90046001600160a01b03166001600160a01b0316636c099bad6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ebe91906159f4565b610ec781613996565b610ecf6139ca565b8383610edb8282613a61565b6001603960008888604051602001610ef4929190615a2a565b60405160208183030381529060405280519060200120815260200190815260200160002060006101000a81548160ff021916908315150217905550603373e000362b382a2fd0c0b5e1dddabcb73154a961fa63af5c918c9091603860009054906101000a90046001600160a01b03168e8e8e8e8e603a548f8f6040518b63ffffffff1660e01b8152600401610f929a99989796959493929190615a63565b602060405180830381865af4158015610faf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd39190615a11565b603a80549195506000610fe583615acb565b9190505550505050610ff660018055565b979650505050505050565b60008181526034602090815260408083205480845260338352818420603854835163c82e011f60e01b81529351929491936111f0936001600160a01b039092169263c82e011f926004808401938290030181865afa158015611067573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061108b91906159f4565b6001600160a01b0316638a19c8bc6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ec9190615a11565b82600c0180548060200260200160405190810160405280929190818152602001828054801561113a57602002820191906000526020600020905b815481526020019060010190808311611126575b5050505050836002015484600001548886600f01546000146111605786600f01546111d7565b603860009054906101000a90046001600160a01b03166001600160a01b0316639a876e296040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111d79190615a11565b6000898152603560205260409020959493929190613a8d565b949350505050565b6000611202612405565b61120a6139ca565b8161121481613bca565b8261121e81613c58565b60008481526034602052604090205461123681613c8a565b61123f81613bca565b60008181526033602052604090819020603854600782015482546001840154600b8501549551630b16ddef60e41b81529495739db91240165e2a5463d3e53903c646b7f1a7058b9563b16ddef0956112b2956036956001600160a01b03928316958c959390921693909290600401615ae4565b602060405180830381865af41580156112cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f39190615a11565b50603854600782015482546001840154600b8501546040516392ba1b8960e01b8152603660048201526001600160a01b03958616602482015260448101889052606481018c905294909316608485015260a484019190915260c483015260e4820152600090739db91240165e2a5463d3e53903c646b7f1a7058b906392ba1b899061010401602060405180830381865af4158015611395573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b99190615a11565b600783015460408051868152602081018b90526001600160a01b0390921690820152606081018290529091507fbe12aa6db02b67b3415bcd1b86c2d53ad3b2a71feb9e0fd23f683b2e69f918409060800160405180910390a194505050505061142160018055565b919050565b6000611430612405565b603860009054906101000a90046001600160a01b03166001600160a01b03166337ccefc96040518163ffffffff1660e01b8152600401602060405180830381865afa158015611483573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114a791906159f4565b6040516388c9546960e01b8152600481018890523360248201526001600160a01b0391909116906388c9546990604401602060405180830381865afa1580156114f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115189190615b23565b15611536576040516309550c7760e01b815260040160405180910390fd5b603860009054906101000a90046001600160a01b03166001600160a01b03166337ccefc96040518163ffffffff1660e01b8152600401602060405180830381865afa158015611589573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ad91906159f4565b6001600160a01b031663c64929c5873386866040518563ffffffff1660e01b81526004016115de9493929190615b45565b602060405180830381865afa1580156115fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061161f9190615b23565b61163c57604051632d85515d60e11b815260040160405180910390fd5b611647868686613cbc565b905061165260018055565b95945050505050565b6000818152603460205260408120600201546109d0565b600061167d8161325c565b50603880546001600160a01b0319166001600160a01b0392909216919091179055565b6034602052600090815260409020805460028201546003830154600484018054939492939192916116d090615b96565b80601f01602080910402602001604051908101604052809291908181526020018280546116fc90615b96565b80156117495780601f1061171e57610100808354040283529160200191611749565b820191906000526020600020905b81548152906001019060200180831161172c57829003601f168201915b5050506005909301549192505060ff1685565b603360205260009081526040902080546001820154600283015460038401546004850154600586015460068701546007880154600889015460098a0154600a8b0180549a9b999a9899979896976001600160601b039096169694956001600160a01b039485169593851694909216926117d490615b96565b80601f016020809104026020016040519081016040528092919081815260200182805461180090615b96565b801561184d5780601f106118225761010080835404028352916020019161184d565b820191906000526020600020905b81548152906001019060200180831161183057829003601f168201915b50505050600b830154600e840154600f909401549293909260ff90911691508e565b60006109d0603383613e1b565b600054610100900460ff161580801561189c5750600054600160ff909116105b806118b65750303b1580156118b6575060005460ff166001145b61191e5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff191660011790558015611941576000805461ff0019166101001790555b611949613e59565b603880546001600160a01b0319166001600160a01b03841690811790915560408051632d6ccfcf60e21b8152905163b5b33f3c916004808201926020929091908290030181865afa1580156119a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119c69190615a11565b603a81905550611a246040518060400160405280601981526020017f44344150726f746f636f6c576974685065726d697373696f6e00000000000000815250604051806040016040528060018152602001603160f81b815250613e88565b8015611a6a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b60606109d0603483613eb9565b6000818152603360205260408120600d01546109d0565b6000611a9c612405565b611aa46139ca565b81611aae81613bca565b82611ab881613c8a565b60008481526033602052604090819020603854600782015482546001840154600b8501549551630b16ddef60e41b81529495739db91240165e2a5463d3e53903c646b7f1a7058b9563b16ddef095611b2b956036956001600160a01b03928316958f959390921693909290600401615ae4565b602060405180830381865af4158015611b48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b6c9190615a11565b5060006036739db91240165e2a5463d3e53903c646b7f1a7058b636b5159e49091603860009054906101000a90046001600160a01b0316898660070160009054906101000a90046001600160a01b03168760000154886001015489600b01546040518863ffffffff1660e01b8152600401611bed9796959493929190615ae4565b602060405180830381865af4158015611c0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c2e9190615a11565b6007830154604080518981526001600160a01b03909216602083015281018290529091507f0759b1bb04364351c56f2db6d1a0283eb1a5d122b14dceec6df12408451500679060600160405180910390a1935050505061142160018055565b6000611c988161325c565b612710821015611ca757600080fd5b50600091825260336020526040909120600f0155565b6000610b2b60338484613f62565b600080611cd7836111f8565b600084815260346020908152604080832054808452603390925291829020603854600782015460098301549451631545c34f60e11b81526001600160a01b03928316600482015260248101859052604481018a9052908216606482015260848101869052931660a4840152603b60c48401529293509190739db91240165e2a5463d3e53903c646b7f1a7058b90632a8b869e9060e401602060405180830381865af4158015611d8a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116529190615a11565b6000808080808080606081611dc460338b613f86565b9850985098509850985098509850985098509193959799909294969850565b603860009054906101000a90046001600160a01b03166001600160a01b0316636c099bad6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e5a91906159f4565b6001600160a01b0316336001600160a01b031614158015611f715750603860009054906101000a90046001600160a01b03166001600160a01b031663cb023e6d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ec9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eed91906159f4565b6001600160a01b0316637dd56411886040518263ffffffff1660e01b8152600401611f1a91815260200190565b602060405180830381865afa158015611f37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f5b91906159f4565b6001600160a01b0316336001600160a01b031614155b15611f8f576040516308b3412160e31b815260040160405180910390fd5b6000878152607260205260408120805463ffffffff191663ffffffff89161781559085905b8181101561205a57878782818110611fce57611fce61593e565b9050604002016020016020810190611fe69190615bd0565b8360010160008a8a85818110611ffe57611ffe61593e565b61201492602060409092020190810191506153e8565b6001600160a01b031681526020810191909152604001600020805463ffffffff929092166401000000000267ffffffff0000000019909216919091179055600101611fb4565b50887f21f6fa02312382a44060ea83b88540e2bacbf8142d73d968893a89adfdada97989898960405161208f93929190615beb565b60405180910390a2603860009054906101000a90046001600160a01b03166001600160a01b03166337ccefc96040518163ffffffff1660e01b8152600401602060405180830381865afa1580156120ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210e91906159f4565b6001600160a01b031663a0e29b3d8a8787876040518563ffffffff1660e01b815260040161213f9493929190615ccf565b600060405180830381600087803b15801561215957600080fd5b505af115801561216d573d6000803e3d6000fd5b50505050505050505050505050565b60008061218883611a92565b6000848152603360205260409081902060385460078201546009830154935163db2a72db60e01b81526001600160a01b0392831660048201526024810189905290821660448201526064810185905292166084830152603b60a4830152919250739db91240165e2a5463d3e53903c646b7f1a7058b9063db2a72db9060c401602060405180830381865af4158015612224573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111f09190615a11565b6000612252612405565b61225a6139ca565b8361226481613bca565b60006033600087815260200190815260200160002090506036739db91240165e2a5463d3e53903c646b7f1a7058b63b16ddef09091603860009054906101000a90046001600160a01b0316898560070160009054906101000a90046001600160a01b03168660000154876001015488600b01546040518863ffffffff1660e01b81526004016122f99796959493929190615ae4565b602060405180830381865af4158015612316573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061233a9190615a11565b5060385460078201546009830154604051636b42b9f760e11b81526001600160a01b0393841660048201529183166024830152821660448201526064810188905233608482015290851660a482015260c48101869052603b60e4820152739db91240165e2a5463d3e53903c646b7f1a7058b9063d68573ee9061010401602060405180830381865af41580156123d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123f89190615a11565b92505050610b2b60018055565b6002600154036124575760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401611915565b6002600155565b61246b8585858585614082565b612488576040516360be3b5960e01b815260040160405180910390fd5b5050505050565b60006125107f4713f5ab3c889f9d03bca02aa53c0e46eea41f9844ed52981b46bce7261fb9498888886040516124c6929190615a2a565b6040519081900381206124f5939291899060200193845260208401929092526040830152606082015260800190565b60405160208183030381529060405280519060200120614394565b905060006125548285858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506143e292505050565b603854604051632474521560e21b81527fe2f4eaae4a9751e85a3e4a7b9587827a877f29914755229b07a7b2da98285f7060048201526001600160a01b0380841660248301529293509116906391d1485490604401602060405180830381865afa1580156125c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125ea9190615b23565b1580156126ed5750603860009054906101000a90046001600160a01b03166001600160a01b031663cb023e6d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612645573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061266991906159f4565b6001600160a01b0316637dd56411896040518263ffffffff1660e01b815260040161269691815260200190565b602060405180830381865afa1580156126b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126d791906159f4565b6001600160a01b0316816001600160a01b031614155b1561270b57604051638baa579f60e01b815260040160405180910390fd5b5050505050505050565b606061271f6139ca565b61272885613bca565b61273184613c58565b61273a84613bca565b612742614f3c565b63ffffffff808416825260009061275e906033908990613e1b16565b905060005b826000015163ffffffff168163ffffffff161015612845576127b786868363ffffffff168181106127965761279661593e565b90506020028101906127a89190615954565b6127b29080615974565b613a61565b85858263ffffffff168181106127cf576127cf61593e565b90506020028101906127e19190615954565b602001351580159061281f57508186868363ffffffff168181106128075761280761593e565b90506020028101906128199190615954565b60200135105b1561283d57604051636dddf41160e11b815260040160405180910390fd5b600101612763565b505060008681526033602090815260408083208884526034909252909120600382015460048301541061288b5760405163156c453b60e31b815260040160405180910390fd5b603860009054906101000a90046001600160a01b03166001600160a01b031663c82e011f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156128de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061290291906159f4565b6001600160a01b0316638a19c8bc6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561293f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129639190615a11565b6020840152600f8201541561297c5781600f01546129f3565b603860009054906101000a90046001600160a01b03166001600160a01b0316639a876e296040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129f39190615a11565b60408401526127106060840152612a08614f95565b888152602080850151604080840191909152600c850180548251818502810185019093528083529192909190830182828015612a6357602002820191906000526020600020905b815481526020019060010190808311612a4f575b5050505050606082015260028301546080820152825460a0820152604084015160c0820152612a9181614406565b60808501819052610120850152835160009063ffffffff166001600160401b03811115612ac057612ac0615605565b604051908082528060200260200182016040528015612ae9578160200160208202803683370190505b5090506000603860009054906101000a90046001600160a01b03166001600160a01b031663bd33275f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b659190615a11565b90506000603860009054906101000a90046001600160a01b03166001600160a01b0316634c66124c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be09190615a11565b905060005b876000015163ffffffff168163ffffffff1610156130225760008b8b8363ffffffff16818110612c1757612c1761593e565b9050602002810190612c299190615954565b612c339080615974565b604051602001612c44929190615a2a565b60408051601f198184030181529181528151602092830120600090815260399092529020805460ff191660011790555060088701546001600160a01b031663110bcd45338d8d63ffffffff8616818110612ca057612ca061593e565b9050602002810190612cb29190615954565b612cbc9080615974565b6040518463ffffffff1660e01b8152600401612cda93929190615d4c565b6020604051808303816000875af1158015612cf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d1d9190615a11565b848263ffffffff1681518110612d3557612d3561593e565b6020908102919091010152600487018054906000612d5283615acb565b919050555085600101848263ffffffff1681518110612d7357612d7361593e565b602090810291909101810151825460018101845560009384529183209091015560028701805491612da383615acb565b91905055508b603760008f878563ffffffff1681518110612dc657612dc661593e565b6020026020010151604051602001612de8929190918252602082015260400190565b6040516020818303038152906040528051906020012081526020019081526020016000208190555060008b8b8363ffffffff16818110612e2a57612e2a61593e565b9050602002810190612e3c9190615954565b60200135905080600003612f4d576080890151612e599085615d71565b8960a001818151612e6a9190615d88565b905250608089015160c08a018051612e83908390615d88565b915081815250507f5a2ad185679629c6f79a7ca8c3b2f337d1c8bce787a38af1b8a6b798a9d01e898e8e878563ffffffff1681518110612ec557612ec561593e565b60200260200101518f8f8763ffffffff16818110612ee557612ee561593e565b9050602002810190612ef79190615954565b612f019080615974565b8e60800151604051612f1896959493929190615d9b565b60405180910390a188606001518960400151612f349190615dd4565b89608001818151612f459190615d71565b905250613019565b612f578184615d71565b8960a001818151612f689190615d88565b90525060c089018051829190612f7f908390615d88565b915081815250507f5a2ad185679629c6f79a7ca8c3b2f337d1c8bce787a38af1b8a6b798a9d01e898e8e878563ffffffff1681518110612fc157612fc161593e565b60200260200101518f8f8763ffffffff16818110612fe157612fe161593e565b9050602002810190612ff39190615954565b612ffd9080615974565b8660405161301096959493929190615d9b565b60405180910390a15b50600101612be5565b5050506000603860009054906101000a90046001600160a01b03166001600160a01b031663117ec9196040518163ffffffff1660e01b8152600401602060405180830381865afa15801561307a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061309e91906159f4565b60098601546038546040805163cb023e6d60e01b815290519394506001600160a01b03928316936000939092169163cb023e6d916004808201926020929091908290030181865afa1580156130f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061311b91906159f4565b6001600160a01b0316637dd564118d6040518263ffffffff1660e01b815260040161314891815260200190565b602060405180830381865afa158015613165573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061318991906159f4565b90506131a08383838b60c001518c60a0015161445c565b6101008a015260e0890152505050610120850151608086015114613203578460400151856060015186608001516131d79190615d71565b6131e19190615dd4565b6080860181905260208601516040870151613203928d918d91906000906145eb565b610bd38a8a8760e001518861010001518960c00151614616565b60018055565b6000828152602084905260408120600181018054849081106132475761324761593e565b90600052602060002001549150509392505050565b6132668133614991565b50565b60006132736139ca565b61327c85613bca565b61328585613c58565b61328f8484613a61565b60008581526034602052604090205482158015906132b657506132b3603382613e1b565b83105b156132d457604051636dddf41160e11b815260040160405180910390fd5b6132dd81613bca565b6000818152603360209081526040808320898452603490925290912060038201546004830154106133215760405163156c453b60e31b815260040160405180910390fd5b613329614f3c565b603860009054906101000a90046001600160a01b03166001600160a01b031663c82e011f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561337c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133a091906159f4565b6001600160a01b0316638a19c8bc6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156133dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134019190615a11565b6020820152600f8301541561341a5782600f0154613491565b603860009054906101000a90046001600160a01b03166001600160a01b0316639a876e296040518163ffffffff1660e01b8152600401602060405180830381865afa15801561346d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134919190615a11565b816040018181525050600088886040516020016134af929190615a2a565b60408051601f198184030181529181528151602092830120600090815260399092529020805460ff19166001179055506134e7614f95565b84815260208082018b905282810151604080840191909152600c86018054825181850281018501909352808352919290919083018282801561354857602002820191906000526020600020905b815481526020019060010190808311613534575b5050505050606082015260028401546080820152835460a0820152604082015160c082015260e08101879052600061357f82614406565b90506000603860009054906101000a90046001600160a01b03166001600160a01b031663117ec9196040518163ffffffff1660e01b8152600401602060405180830381865afa1580156135d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135fa91906159f4565b60098701546038546040805163cb023e6d60e01b815290519394506001600160a01b03928316936000939092169163cb023e6d916004808201926020929091908290030181865afa158015613653573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061367791906159f4565b6001600160a01b0316637dd564118f6040518263ffffffff1660e01b81526004016136a491815260200190565b602060405180830381865afa1580156136c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136e591906159f4565b90506000848c1561376c57603860009054906101000a90046001600160a01b03166001600160a01b0316634c66124c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613743573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137679190615a11565b6137e3565b603860009054906101000a90046001600160a01b03166001600160a01b031663bd33275f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156137bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137e39190615a11565b6137ed9190615d71565b90506137fc848484888561445c565b61010089015260e088015250505060208401516040850151613826925088908e9085908d906145eb565b61383c868c8560e0015186610100015185614616565b600885015460405163110bcd4560e01b81526001600160a01b039091169063110bcd45906138729033908e908e90600401615d4c565b6020604051808303816000875af1158015613891573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138b59190615a11565b60048601805491985060006138c983615acb565b9091555050600180850180549182018155600090815260208120909101889055600285018054916138f983615acb565b91905055508a60376000888a60405160200161391f929190918252602082015260400190565b604051602081830303815290604052805190602001208152602001908152602001600020819055507f5a2ad185679629c6f79a7ca8c3b2f337d1c8bce787a38af1b8a6b798a9d01e89868c898d8d8660405161398096959493929190615d9b565b60405180910390a1505050505050949350505050565b6001600160a01b0381163314613266576040516377ed384360e11b81526001600160a01b0382166004820152602401611915565b603860009054906101000a90046001600160a01b03166001600160a01b0316632a53c6b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015613a1d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a419190615b23565b15613a5f576040516314f8ad9d60e01b815260040160405180910390fd5b565b613a6b82826149ca565b15611a6a5781816040516362eb37c960e01b8152600401611915929190615df6565b600080868681518110613aa257613aa261593e565b602002602001015190508860000160000154600003613ae857848803613ac9579050610ff6565b82613ad661271083615d71565b613ae09190615dd4565b915050610ff6565b600084815260048a01602090815260408083208151808301909252805482526001015491810191909152613b1d908a86614a13565b9050818110613b2f579150610ff69050565b604080518082019091528a54815260018b01546020820152613b52908a86614a13565b9050818110613b6357509050610ff6565b83613b7061271084615d71565b613b7a9190615dd4565b60018b0154148015613b9857508954613b94906001615d88565b8911155b15613ba557509050610ff6565b83613bb261271084615d71565b613bbc9190615dd4565b9a9950505050505050505050565b60385460405163520b085b60e11b8152600481018390526001600160a01b039091169063a41610b690602401602060405180830381865afa158015613c13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c379190615b23565b1561326657604051630cb09dc760e01b815260048101829052602401611915565b60008181526034602052604090206005015460ff166132665760405163052bdfe560e41b815260040160405180910390fd5b6000818152603360205260409020600e015460ff16613266576040516361b7c4e560e01b815260040160405180910390fd5b6000613cc66139ca565b83613cd081613c8a565b84613cda81613bca565b8484613ce68282613a61565b6001603960008989604051602001613cff929190615a2a565b60408051808303601f1901815291815281516020928301208352828201939093529082016000908120805460ff1916941515949094179093556038548b84526033909152912060098101548154600d90920154734815525d8a3765589cfc8986452a6c0192bc0a01936372964a45936034936001600160a01b03928316939216918e91908e8e6040518963ffffffff1660e01b8152600401613da8989796959493929190615e0a565b602060405180830381865af4158015613dc5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613de99190615a11565b60009889526033602090815260408a20600d018054600181018255908b52992090980188905550959695505050505050565b60008181526020839052604081206002810154600c820180549091908110613e4557613e4561593e565b906000526020600020015491505092915050565b600054610100900460ff16613e805760405162461bcd60e51b815260040161191590615e4e565b613a5f614ab0565b600054610100900460ff16613eaf5760405162461bcd60e51b815260040161191590615e4e565b611a6a8282614ad7565b60008181526020839052604090206004810180546060929190613edb90615b96565b80601f0160208091040260200160405190810160405280929190818152602001828054613f0790615b96565b8015613f545780601f10613f2957610100808354040283529160200191613f54565b820191906000526020600020905b815481529060010190602001808311613f3757829003601f168201915b505050505091505092915050565b6000828152602084905260408120600d81018054849081106132475761324761593e565b60008181526020839052604081208054600182015460028301546003840154600985015460058601546006870154600a8801805497999698959794966001600160a01b03909416956001600160601b039093169491936060939092909190613fed90615b96565b80601f016020809104026020016040519081016040528092919081815260200182805461401990615b96565b80156140665780601f1061403b57610100808354040283529160200191614066565b820191906000526020600020905b81548152906001019060200180831161404957829003601f168201915b5050505050925080600b01549150509295985092959850929598565b600080603860009054906101000a90046001600160a01b03166001600160a01b03166337ccefc96040518163ffffffff1660e01b8152600401602060405180830381865afa1580156140d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140fc91906159f4565b60405163f863a81360e01b8152600481018990526001600160a01b0388811660248301529192509082169063f863a81390604401602060405180830381865afa15801561414d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141719190615b23565b1561418f576040516309550c7760e01b815260040160405180910390fd5b600087815260726020908152604080832080546001600160a01b038b811686526001909201845282852083518085018552905463ffffffff808216808452640100000000909204811692909601829052935163dabd56a560e01b8152600481018e90529490911694929390929182919087169063dabd56a590602401600060405180830381865afa158015614228573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526142509190810190615efd565b80519091501580156142655750602081015151155b91506000905061427e886001600160801b038616615d88565b905081156142b15763ffffffff8516156142a1578463ffffffff168111156142a4565b60015b9650505050505050611652565b6040516332903e6f60e11b81526001600160a01b038716906365207cde906142e3908f908f908f908f90600401615b45565b602060405180830381865afa158015614300573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143249190615b23565b61434157604051632d85515d60e11b815260040160405180910390fd5b826001600160801b0316600003614376578463ffffffff16600003614367576001614384565b8463ffffffff16811115614384565b826001600160801b03168111155b9c9b505050505050505050505050565b60006109d06143a1614b18565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b60008060006143f18585614b98565b915091506143fe81614bdd565b509392505050565b60008160e00151600003614454576040808301516060840151608085015160a086015160208088015160c0890151895160009081526035909352969091206109d09690959493929190613a8d565b5060e0015190565b6000808334101561448057604051638a0d377960e01b815260040160405180910390fd5b600061448c8534615fa1565b90506000603860009054906101000a90046001600160a01b03166001600160a01b0316630e7752746040518163ffffffff1660e01b8152600401602060405180830381865afa1580156144e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145079190615a11565b90506145138186615dd4565b935080603860009054906101000a90046001600160a01b03166001600160a01b0316630a8027da6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614569573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061458d9190615a11565b6145979088615d71565b6145a19190615dd4565b92506145ad8984614d27565b6145b78885614d27565b6145d587846145c6878a615fa1565b6145d09190615fa1565b614d27565b6145df3383614d27565b50509550959350505050565b8160000361460e57600085815260356020526040902061460e9087868685614dac565b505050505050565b600085815260336020908152604080832081516102008101835281548152600182015493810193909352600281015491830191909152600381015460608301526004810154608083015260058101546001600160601b031660a0830152600681015460c083015260078101546001600160a01b0390811660e084015260088201548116610100840152600982015416610120830152600a81018054610140840191906146c190615b96565b80601f01602080910402602001604051908101604052809291908181526020018280546146ed90615b96565b801561473a5780601f1061470f5761010080835404028352916020019161473a565b820191906000526020600020905b81548152906001019060200180831161471d57829003601f168201915b50505050508152602001600b8201548152602001600c820180548060200260200160405190810160405280929190818152602001828054801561479c57602002820191906000526020600020905b815481526020019060010190808311614788575b50505050508152602001600d82018054806020026020016040519081016040528092919081815260200182805480156147f457602002820191906000526020600020905b8154815260200190600101908083116147e0575b5050509183525050600e82015460ff1615156020820152600f90910154604090910152603854909150739db91240165e2a5463d3e53903c646b7f1a7058b90633dedcf9a906036906001600160a01b03168989886148528b8a615fa1565b61485c9190615fa1565b60208801516040516001600160e01b031960e089901b16815260048101969096526001600160a01b03909416602486015260448501929092526064840152608483015260a4820188905260c4820152603b60e48201526101040160006040518083038186803b1580156148ce57600080fd5b505af41580156148e2573d6000803e3d6000fd5b50506038548351602085015161016086015160405163566f93a160e11b8152603660048201526001600160a01b039094166024850152604484018c9052606484018b9052608484019290925260a483015260c4820152739db91240165e2a5463d3e53903c646b7f1a7058b925063acdf2742915060e40160006040518083038186803b15801561497157600080fd5b505af4158015614985573d6000803e3d6000fd5b50505050505050505050565b61499b8282614e02565b611a6a5760405163678f4fa960e01b8152600481018390526001600160a01b0382166024820152604401611915565b60006039600084846040516020016149e3929190615a2a565b60408051808303601f190181529181528151602092830120835290820192909252016000205460ff169392505050565b82516000908303614a4257612710828560200151614a319190615d71565b614a3b9190615dd4565b9050610b2b565b8351600090600190614a549086615fa1565b614a5e9190615fa1565b602086015190915060005b82811015614aa65784614a7e61271084615d71565b614a889190615dd4565b915081600003614a9e5760009350505050610b2b565b600101614a69565b5095945050505050565b600054610100900460ff1661321d5760405162461bcd60e51b815260040161191590615e4e565b600054610100900460ff16614afe5760405162461bcd60e51b815260040161191590615e4e565b815160209283012081519190920120603e91909155603f55565b6000614b937f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f614b47603e5490565b603f546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b905090565b6000808251604103614bce5760208301516040840151606085015160001a614bc287828585614e78565b94509450505050614bd6565b506000905060025b9250929050565b6000816004811115614bf157614bf1615fb4565b03614bf95750565b6001816004811115614c0d57614c0d615fb4565b03614c5a5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401611915565b6002816004811115614c6e57614c6e615fb4565b03614cbb5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401611915565b6003816004811115614ccf57614ccf615fb4565b036132665760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401611915565b80600003614d33575050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114614d80576040519150601f19603f3d011682016040523d82523d6000602084013e614d85565b606091505b5050905080614da757604051630db2c7f160e31b815260040160405180910390fd5b505050565b604080518082019091528554815260018601546020820152600090614dd2908684614a13565b9050808310614de657848655600186018390555b5050600091825260049093016020526040902090815560010155565b603854604051632474521560e21b8152600481018490526001600160a01b03838116602483015260009216906391d1485490604401602060405180830381865afa158015614e54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2b9190615b23565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115614eaf5750600090506003614f33565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015614f03573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116614f2c57600060019250925050614f33565b9150600090505b94509492505050565b604051806101400160405280600063ffffffff1681526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60405180610100016040528060008019168152602001600080191681526020016000815260200160608152602001600081526020016000815260200160008152602001600081525090565b600060208284031215614ff257600080fd5b5035919050565b6000806040838503121561500c57600080fd5b50508035926020909101359150565b60008083601f84011261502d57600080fd5b5081356001600160401b0381111561504457600080fd5b6020830191508360208260051b8501011115614bd657600080fd5b60008060008060008060008060a0898b03121561507b57600080fd5b883597506020890135965060408901356001600160401b03808211156150a057600080fd5b6150ac8c838d0161501b565b909850965060608b01359150808211156150c557600080fd5b6150d18c838d0161501b565b909650945060808b01359150808211156150ea57600080fd5b506150f78b828c0161501b565b999c989b5096995094979396929594505050565b6020808252825182820181905260009190848201906040850190845b8181101561514357835183529284019291840191600101615127565b50909695505050505050565b60008083601f84011261516157600080fd5b5081356001600160401b0381111561517857600080fd5b602083019150836020828501011115614bd657600080fd5b600080600080600080600080600060c08a8c0312156151ae57600080fd5b8935985060208a0135975060408a01356001600160401b03808211156151d357600080fd5b6151df8d838e0161514f565b909950975060608c01359150808211156151f857600080fd5b6152048d838e0161501b565b909750955060808c0135945060a08c013591508082111561522457600080fd5b506152318c828d0161514f565b915080935050809150509295985092959850929598565b80356001600160601b038116811461142157600080fd5b60008060008060008060008060e0898b03121561527b57600080fd5b883597506020890135965060408901359550606089013594506152a060808a01615248565b935060a08901356001600160401b038111156152bb57600080fd5b6152c78b828c0161514f565b999c989b50969995989497949560c00135949350505050565b600080600080600080600060c0888a0312156152fb57600080fd5b8735965060208801359550604088013594506060880135935061532060808901615248565b925060a08801356001600160401b0381111561533b57600080fd5b6153478a828b0161514f565b989b979a50959850939692959293505050565b60008060008060006060868803121561537257600080fd5b8535945060208601356001600160401b038082111561539057600080fd5b61539c89838a0161514f565b909650945060408801359150808211156153b557600080fd5b506153c28882890161501b565b969995985093965092949392505050565b6001600160a01b038116811461326657600080fd5b6000602082840312156153fa57600080fd5b8135610b2b816153d3565b6000815180845260005b8181101561542b5760208185018101518683018201520161540f565b506000602082860101526020601f19601f83011685010191505092915050565b85815284602082015283604082015260a06060820152600061547060a0830185615405565b905082151560808301529695505050505050565b8e81528d60208201528c60408201528b60608201528a60808201526001600160601b038a1660a08201528860c082015260018060a01b03881660e08201526154d86101008201886001600160a01b03169052565b6001600160a01b0386166101208201526101c061014082015260006155016101c0830187615405565b90508461016083015261551961018083018515159052565b826101a08301529f9e505050505050505050505050505050565b602081526000610b2b6020830184615405565b60006101208b83528a602084015289604084015288606084015260018060a01b03881660808401526001600160601b03871660a08401528560c08401528060e084015261559581840186615405565b915050826101008301529a9950505050505050505050565b803563ffffffff8116811461142157600080fd5b60008083601f8401126155d357600080fd5b5081356001600160401b038111156155ea57600080fd5b6020830191508360208260061b8501011115614bd657600080fd5b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b038111828210171561563d5761563d615605565b60405290565b604051601f8201601f191681016001600160401b038111828210171561566b5761566b615605565b604052919050565b60006001600160401b0382111561568c5761568c615605565b5060051b60200190565b600082601f8301126156a757600080fd5b813560206156bc6156b783615673565b615643565b82815260059290921b840181019181810190868411156156db57600080fd5b8286015b848110156156ff5780356156f2816153d3565b83529183019183016156df565b509695505050505050565b60006080828403121561571c57600080fd5b61572461561b565b90508135815260208201356001600160401b038082111561574457600080fd5b61575085838601615696565b602084015260408401356040840152606084013591508082111561577357600080fd5b5061578084828501615696565b60608301525092915050565b60006040828403121561579e57600080fd5b604051604081016001600160401b0382821081831117156157c1576157c1615605565b8160405282935084359150808211156157d957600080fd5b6157e586838701615696565b835260208501359150808211156157fb57600080fd5b5061580885828601615696565b6020830152505092915050565b600080600080600080600060c0888a03121561583057600080fd5b87359650615840602089016155ad565b955060408801356001600160401b038082111561585c57600080fd5b6158688b838c016155c1565b909750955060608a013591508082111561588157600080fd5b61588d8b838c0161570a565b945060808a01359150808211156158a357600080fd5b6158af8b838c0161578c565b935060a08a01359150808211156158c557600080fd5b506158d28a828b0161578c565b91505092959891949750929550565b6000806000606084860312156158f657600080fd5b8335925060208401359150604084013561590f816153d3565b809150509250925092565b6000806040838503121561592d57600080fd5b505080516020909101519092909150565b634e487b7160e01b600052603260045260246000fd5b60008235603e1983360301811261596a57600080fd5b9190910192915050565b6000808335601e1984360301811261598b57600080fd5b8301803591506001600160401b038211156159a557600080fd5b602001915036819003821315614bd657600080fd5b634e487b7160e01b600052601160045260246000fd5b63ffffffff8181168382160190808211156159ed576159ed6159ba565b5092915050565b600060208284031215615a0657600080fd5b8151610b2b816153d3565b600060208284031215615a2357600080fd5b5051919050565b8183823760009101908152919050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60006101208c835260018060a01b038c1660208401528a60408401528960608401528860808401528760a08401526001600160601b03871660c08401528560e084015280610100840152615aba8184018587615a3a565b9d9c50505050505050505050505050565b600060018201615add57615add6159ba565b5060010190565b9687526001600160a01b0395861660208801526040870194909452919093166060850152608084019290925260a083019190915260c082015260e00190565b600060208284031215615b3557600080fd5b81518015158114610b2b57600080fd5b8481526001600160a01b0384166020820152606060408201819052810182905260006001600160fb1b03831115615b7b57600080fd5b8260051b808560808501379190910160800195945050505050565b600181811c90821680615baa57607f821691505b602082108103615bca57634e487b7160e01b600052602260045260246000fd5b50919050565b600060208284031215615be257600080fd5b610b2b826155ad565b63ffffffff848116825260406020808401829052838201859052600092869160608601855b88811015615c4f578435615c23816153d3565b6001600160a01b0316825283615c3a8685016155ad565b16828401529385019390850190600101615c10565b509998505050505050505050565b600081518084526020808501945080840160005b83811015615c965781516001600160a01b031687529582019590820190600101615c71565b509495945050505050565b6000815160408452615cb66040850182615c5d565b9050602083015184820360208601526116528282615c5d565b848152608060208201528351608082015260006020850151608060a0840152615cfc610100840182615c5d565b9050604086015160c08401526060860151607f198483030160e0850152615d238282615c5d565b9150508281036040840152615d388186615ca1565b90508281036060840152610ff68185615ca1565b6001600160a01b03841681526040602082018190526000906116529083018486615a3a565b80820281158282048414176109d0576109d06159ba565b808201808211156109d0576109d06159ba565b86815285602082015284604082015260a060608201526000615dc160a083018587615a3a565b9050826080830152979650505050505050565b600082615df157634e487b7160e01b600052601260045260246000fd5b500490565b6020815260006111f0602083018486615a3a565b888152600060018060a01b03808a1660208401528089166040840152508660608301528560808301528460a083015260e060c0830152613bbc60e083018486615a3a565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600082601f830112615eaa57600080fd5b81516020615eba6156b783615673565b82815260059290921b84018101918181019086841115615ed957600080fd5b8286015b848110156156ff578051615ef0816153d3565b8352918301918301615edd565b600060208284031215615f0f57600080fd5b81516001600160401b0380821115615f2657600080fd5b9083019060808286031215615f3a57600080fd5b615f4261561b565b82518152602083015182811115615f5857600080fd5b615f6487828601615e99565b60208301525060408301516040820152606083015182811115615f8657600080fd5b615f9287828601615e99565b60608301525095945050505050565b818103818111156109d0576109d06159ba565b634e487b7160e01b600052602160045260246000fdfea26469706673582212209de17805a6e6eb421d4453a3b70901293b0f0fde7a9f7628e1ab1ef72bfa630d64736f6c63430008120033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.