Source Code
Overview
MATIC Balance
0 MATIC
More Info
ContractCreator:
Multichain Info
N/A
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
0x60806040 | 21933766 | 853 days ago | IN | Create: CipherStore | 0 MATIC | 0.01053113 |
Loading...
Loading
Contract Name:
CipherStore
Compiler Version
v0.6.5+commit.f956cc89
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
pragma solidity ^0.6.0; pragma experimental ABIEncoderV2; import '@openzeppelin/contracts-upgradeable/proxy/Initializable.sol'; import '@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol'; import '@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol'; import '@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol'; import '@openzeppelin/contracts/math/SafeMath.sol'; import '@openzeppelin/contracts/utils/Pausable.sol'; import '@openzeppelin/contracts/utils/ReentrancyGuard.sol'; import 'abdk-libraries-solidity/ABDKMath64x64.sol'; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import "@openzeppelin/contracts-upgradeable/token/ERC20/SafeERC20Upgradeable.sol"; import './characters.sol'; import './interfaces/IRandoms.sol'; import './interfaces/ICharacter.sol'; contract CipherStore is Initializable, AccessControlUpgradeable, PausableUpgradeable, ReentrancyGuardUpgradeable, ICharacter { using SafeMath for uint8; using SafeMath for uint256; using SafeERC20Upgradeable for IERC20; Characters public characters; IRandoms public randoms; IERC20 public TAG; IERC20 public CORE; IERC20 public USDC; IERC20 public TAGUsdcLPToken; function initialize( Characters _characters, IRandoms _randoms, address _usdc, address _tag, address _core, address _tagUsdcLPTokens, address _treasury, uint256 _overflowChance, address[] memory _earlyAdopters ) public initializer { __AccessControl_init(); _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); USDC = IERC20(_usdc); TAG = IERC20(_tag); CORE = IERC20(_core); TAGUsdcLPToken = IERC20(_tagUsdcLPTokens); characters = _characters; randoms = _randoms; treasury = _treasury; overflowChance = _overflowChance; storeTagPrice = 2000; storeTagBasePrice = 2000; tagSoldInPercentage = 0; priceIncreaseForTag = 400; storeSaleStarts = 0; bundleTokensCount[0] = 2500; bundleTokensCount[1] = 12500; bundleTokensCount[2] = 25000; bundleTokensCount[3] = 50000; overflowCore = 0; earlyAdopters = _earlyAdopters; } uint256 public storeTagPrice; uint256 public storeTagBasePrice; uint256 public priceIncreaseForTag; uint256 public tagSoldInPercentage; uint256 public storeSaleStarts; uint256 public constant earlyAdoptersDuration = 3600; uint256 public constant referralPercent = 25; uint256 public constant totalTags = 200000000 ether; uint256 public constant maxPercent = 100; uint256 public overflowCore; uint256 public overflowChance; address public treasury; mapping(address => uint256) lastBlockNumberCalled; mapping(uint8 => uint256) public bundleTokensCount; mapping(address => uint256) public referralEarning; address[] public earlyAdopters; uint256 public totalMiniFeaturesFee; mapping(uint8 => uint256) public miniFeatures; event tagTokensSold(address indexed buyer, uint256 amount); event coreTokensSold(address indexed buyer, uint256 amount); event overflowed(address indexed user, uint256 amount); modifier onlyValidReferrer(address referrer) { if(referrer != address(0)) { require(msg.sender != referrer, "Use valid referral" ); // require(characters.balanceOf(referrer) > 0, "Use valid referral"); } _; } modifier onlyEarlyAdopters() { if((block.timestamp < storeSaleStarts.add(earlyAdoptersDuration))) { bool isEarlyAdopter = false; for(uint256 i = 0; i < earlyAdopters.length; i++) { if(earlyAdopters[i] == msg.sender) { isEarlyAdopter = true; } } require(isEarlyAdopter, "Only Early Adopters access now!"); } _; } function setMiniFeaturesFee(uint8 customType, uint256 amount) external onlyOwner { miniFeatures[customType] = amount; } function setTreasury(address _treasury) external onlyOwner { treasury = _treasury; } function setLPTokenAddress(address _lpToken) external onlyOwner { TAGUsdcLPToken = IERC20(_lpToken); } function setOverflowChance(uint256 _overflowChance) external onlyOwner { overflowChance = _overflowChance; } function setStoreStartTime() external onlyOwner { require(storeSaleStarts == 0, "Early sale already started."); storeSaleStarts = block.timestamp; } function buyTagUsingUSDC(uint8 bundleType, uint256 characterId, address referral) public whenNotPaused onlyNonContract oncePerBlock(msg.sender) nonReentrant onlyEarlyAdopters onlyValidReferrer(referral) isCharacterOwner(characterId) buyTAGChecks(characterId,bundleType) { uint256 tagsCount = bundleTokensCount[bundleType]; uint256 sellPrice = tagsCount.mul(storeTagPrice); uint256 referralFee = sellPrice.mul(referralPercent).div(1000); require(USDC.allowance(msg.sender, address(this)) >= sellPrice, "Not enough USDC allowance"); uint256 seed = randoms.getRandomSeed(msg.sender); // update tag-percent-buy and store-tagPrice tagSoldInPercentage = maxPercent.sub(TAG.balanceOf(address(this)).mul(100).div(totalTags)); if(tagSoldInPercentage>=50 && tagSoldInPercentage<60) { storeTagPrice = storeTagBasePrice.add(priceIncreaseForTag); } else if(tagSoldInPercentage>=60 && tagSoldInPercentage<70) { storeTagPrice = storeTagBasePrice.add(priceIncreaseForTag.mul(2)); } else if(tagSoldInPercentage>=70 && tagSoldInPercentage<80) { storeTagPrice = storeTagBasePrice.add(priceIncreaseForTag.mul(3)); } else if(tagSoldInPercentage>=80 && tagSoldInPercentage<90) { storeTagPrice = storeTagBasePrice.add(priceIncreaseForTag.mul(4)); } else if(tagSoldInPercentage>=90 && tagSoldInPercentage<100) { storeTagPrice = storeTagBasePrice.add(priceIncreaseForTag.mul(5)); } // add overflow CORE overflowCore = overflowCore.add(tagsCount.mul(5).div(100)); // get USDC USDC.transferFrom(msg.sender, address(this), sellPrice.sub(referralFee.mul(2))); if(referral != address(0)) { USDC.transferFrom(msg.sender,referral,referralFee); referralEarning[referral] = referralEarning[referral].add(referralFee); } else { USDC.transferFrom(msg.sender,treasury,referralFee); } USDC.transferFrom(msg.sender,treasury,referralFee); _drainStaminaAndGainXp(characterId,bundleType); // transfer TAGs TAG.transfer(msg.sender, tagsCount.mul(10**18)); // check if user gets overflow & transfer CORE if(seed.mod(overflowChance) == 0) { CORE.transfer(msg.sender, overflowCore.mul(10**18)); emit overflowed(msg.sender, overflowCore); overflowCore = 0; } emit tagTokensSold(msg.sender, bundleTokensCount[bundleType]); } function _drainStaminaAndGainXp(uint256 characterId, uint8 bundleType) internal { // drain stamina characters.getFightDataAndDrainStamina(characterId,40); // increment XP characters.gainXp(characterId, uint16(referralPercent.mul(bundleType.add(1)).div(10))); } // function buyTagUsingLP(uint8 bundleType, uint256 characterId, address referral) // public // whenNotPaused // onlyNonContract // oncePerBlock(msg.sender) // nonReentrant // onlyEarlyAdopters // onlyValidReferrer(referral) // isCharacterOwner(characterId) // buyTAGChecks(characterId,bundleType) // { // uint256 tagsCount = bundleTokensCount[bundleType]; // // update sell-price, allowance in terms of LP // // uint256 sellPrice = ? // // require LP allowance // uint256 seed = randoms.getRandomSeed(msg.sender); // // update tag-percent-buy and store-tagPrice // tagSoldInPercentage = maxPercent.sub(TAG.balanceOf(address(this)).mul(100).div(totalTags)); // if(tagSoldInPercentage>=50 && tagSoldInPercentage<60) { // storeTagPrice = storeTagBasePrice.add(priceIncreaseForTag); // } else if(tagSoldInPercentage>=60 && tagSoldInPercentage<70) { // storeTagPrice = storeTagBasePrice.add(priceIncreaseForTag.mul(2)); // } else if(tagSoldInPercentage>=70 && tagSoldInPercentage<80) { // storeTagPrice = storeTagBasePrice.add(priceIncreaseForTag.mul(3)); // } else if(tagSoldInPercentage>=80 && tagSoldInPercentage<90) { // storeTagPrice = storeTagBasePrice.add(priceIncreaseForTag.mul(4)); // } else if(tagSoldInPercentage>=90 && tagSoldInPercentage<100) { // storeTagPrice = storeTagBasePrice.add(priceIncreaseForTag.mul(5)); // } // _drainStaminaAndGainXp(characterId,bundleType); // // transfer LP tokens, TAGs and CORE tokens // // TAGUsdcLPToken.transferFrom(msg.sender, address(this), sell-price); // // TAG.transfer(msg.sender, tagsCount); // // CORE.transfer(msg.sender, tagsCount.mul(5).div(100)); // // check if user gets overflow & transfer CORE // if(seed.mod(overflowChance) == 0) { // CORE.transfer(msg.sender, overflowCore.mul(10**18)); // emit overflowed(msg.sender, overflowCore); // overflowCore = 0; // } // emit tagTokensSold(msg.sender, tagsCount); // emit coreTokensSold(msg.sender, tagsCount.mul(5).div(100)); // } function addEarlyAdopters(address[] memory users) public onlyOwner { require(users.length > 0, "No addresses!"); for(uint i=0; i< users.length; i++) { require(users[i] != address(0), "Address(0) error"); earlyAdopters.push(users[i]); } } function getAllEarlyAdopters() public view returns(address[] memory) { return earlyAdopters; } function withdrawUSDC(uint256 amount) public nonReentrant onlyOwner { require(USDC.balanceOf(address(this)) >= amount, "Not enough amount"); USDC.transfer(msg.sender, amount); } function withdrawTAG(uint256 amount) public nonReentrant onlyOwner { require(TAG.balanceOf(address(this)) >= amount, "Not enough amount"); TAG.transfer(msg.sender, amount); } function withdrawCORE(uint256 amount) public nonReentrant onlyOwner { require(CORE.balanceOf(address(this)) >= amount, "Not enough amount"); CORE.transfer(msg.sender, amount); } function withdrawLPTokens(uint256 amount) public nonReentrant onlyOwner { require(TAGUsdcLPToken.balanceOf(address(this)) >= amount, "Not enough amount"); TAGUsdcLPToken.transfer(msg.sender, amount); } function customizeOperators(uint256 characterId, uint8 customType) public whenNotPaused nonReentrant oncePerBlock(msg.sender) onlyNonContract isCharacterOwner(characterId) { require(customType>=0 && customType <=2, "Invalid custom type"); uint256 amount = miniFeatures[customType].mul(10**18); require(TAG.allowance(msg.sender, address(this)) >= amount, "Not enough TAG approved"); uint256 seed = randoms.getRandomSeed(msg.sender); totalMiniFeaturesFee = totalMiniFeaturesFee.add(amount); TAG.transferFrom(msg.sender, treasury, amount); characters.customizeCharacter(characterId, customType, seed); } function setOperatorName(uint256 characterId, string memory firstN, string memory lastN) public whenNotPaused nonReentrant oncePerBlock(msg.sender) onlyNonContract isCharacterOwner(characterId) { uint256 amount = miniFeatures[3].mul(10**18); require(TAG.allowance(msg.sender, address(this)) >= amount, "Not enough TAG approved"); totalMiniFeaturesFee = totalMiniFeaturesFee.add(amount); TAG.transferFrom(msg.sender, treasury, amount); characters.setCharacterName(characterId, firstN, lastN); } function pause() external onlyOwner { _pause(); } function unpause() external onlyOwner { _unpause(); } function _onlyOwner() internal view { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Admin role needed."); } function _oncePerBlock(address user) internal { require(lastBlockNumberCalled[user] < block.number, 'OCS'); lastBlockNumberCalled[user] = block.number; } function _onlyNonContract() internal view { require(tx.origin == msg.sender); } function _isCharacterOwner(uint256 character) internal view { require( characters.ownerOf(character) == msg.sender, 'Not the character owner' ); } function _buyTAGChecks(uint256 characterId, uint8 bundleType) internal view { require(characters.balanceOf(msg.sender) > 0, "Please buy an operator to buy TAG tokens"); require(characters.getStaminaPoints(characterId) >= 40, "Not enough stamina for Buy"); require(bundleType>=0 && bundleType<=3, "Invalid bundle type"); require(TAG.balanceOf(address(this)) >= bundleTokensCount[bundleType], "Not enough TAG tokens left"); } modifier buyTAGChecks(uint256 characterId, uint8 bundleType) { _buyTAGChecks(characterId, bundleType); _; } modifier isCharacterOwner(uint256 character) { _isCharacterOwner(character); _; } modifier oncePerBlock(address user) { _oncePerBlock(user); _; } modifier onlyOwner() { _onlyOwner(); _; } modifier onlyNonContract() { _onlyNonContract(); _; } }
pragma solidity ^0.6.0; import "abdk-libraries-solidity/ABDKMath64x64.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; library RandomUtil { using SafeMath for uint256; // using SafeMath for int128; function randomSeededMinMax(uint min, uint max, uint seed) internal pure returns (uint) { // inclusive,inclusive (don't use absolute min and max values of uint256) // deterministic based on seed provided uint diff = max.sub(min).add(1); uint randomVar = uint(keccak256(abi.encodePacked(seed))).mod(diff); randomVar = randomVar.add(min); return randomVar; } // function randomSeededMinMax128(int128 min, int128 max, uint seed) internal pure returns (int128) { // // inclusive,inclusive (don't use absolute min and max values of uint256) // // deterministic based on seed provided // int128 diff = max-min+1; // uint randomVar = uint(keccak256(abi.encodePacked(seed))).mod(uint(diff)); // randomVar = randomVar.add(uint(min)); // return int128(randomVar); // } function combineSeeds(uint seed1, uint seed2) internal pure returns (uint) { return uint(keccak256(abi.encodePacked(seed1, seed2))); } function combineSeeds(uint[] memory seeds) internal pure returns (uint) { return uint(keccak256(abi.encodePacked(seeds))); } function plusMinus10PercentSeeded(uint256 num, uint256 seed) internal pure returns (uint256) { uint256 tenPercent = num.div(10); return num.sub(tenPercent).add(randomSeededMinMax(0, tenPercent.mul(2), seed)); } function uint2str(uint _i) internal pure returns (string memory _uintAsString) { if (_i == 0) { return "0"; } uint j = _i; uint len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint k = len - 1; while (_i != 0) { bstr[k--] = byte(uint8(48 + _i % 10)); _i /= 10; } return string(bstr); } }
pragma solidity ^0.6.5; // ERC165 Interface ID: 0xe62e6974 interface ITransferCooldownable { // Views function lastTransferTimestamp(uint256 tokenId) external view returns (uint256); function transferCooldownEnd(uint256 tokenId) external view returns (uint256); function transferCooldownLeft(uint256 tokenId) external view returns (uint256); } library TransferCooldownableInterfaceId { function interfaceId() internal pure returns (bytes4) { return ITransferCooldownable.lastTransferTimestamp.selector ^ ITransferCooldownable.transferCooldownEnd.selector ^ ITransferCooldownable.transferCooldownLeft.selector; } }
pragma solidity ^0.6.5; interface IRandoms { // Views function getRandomSeed(address user) external view returns (uint256 seed); function getRandomSeedUsingHash(address user, bytes32 hash) external view returns (uint256 seed); }
interface ICharacter { enum CharacterType {Elite, Trainee, Citizen} }
pragma solidity ^0.6.0; import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "./util.sol"; import "./interfaces/ITransferCooldownable.sol"; import "./interfaces/ICharacter.sol"; contract Characters is Initializable, ERC721Upgradeable, AccessControlUpgradeable, ITransferCooldownable, ICharacter { using SafeMath for uint16; using SafeMath for uint8; bytes32 public constant GAME_ADMIN = keccak256("GAME_ADMIN"); bytes32 public constant NO_OWNED_LIMIT = keccak256("NO_OWNED_LIMIT"); bytes32 public constant RECEIVE_DOES_NOT_SET_TRANSFER_TIMESTAMP = keccak256("RECEIVE_DOES_NOT_SET_TRANSFER_TIMESTAMP"); uint256 public constant TRANSFER_COOLDOWN = 1 days; function initialize () public initializer { __ERC721_init("CipherShooters operator", "CSO"); __AccessControl_init_unchained(); _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); } function setExperienceTable() public { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Admin role needed."); experienceTable = [ 16, 17, 18, 19, 20, 22, 24, 26, 28, 30, 33, 36, 39, 42, 46, 50, 55, 60, 66 , 72, 79, 86, 94, 103, 113, 124, 136, 149, 163, 178, 194, 211, 229, 248, 268 , 289, 311, 334, 358, 383, 409, 436, 464, 493, 523, 554, 586, 619, 653, 688 , 724, 761, 799, 838, 878, 919, 961, 1004, 1048, 1093, 1139, 1186, 1234, 1283 , 1333, 1384, 1436, 1489, 1543, 1598, 1654, 1711, 1769, 1828, 1888, 1949, 2011 , 2074, 2138, 2203, 2269, 2336, 2404, 2473, 2543, 2614, 2686, 2759, 2833, 2908 , 2984, 3061, 3139, 3218, 3298, 3379, 3461, 3544, 3628, 3713, 3799, 3886, 3974 , 4063, 4153, 4244, 4336, 4429, 4523, 4618, 4714, 4811, 4909, 5008, 5108, 5209 , 5311, 5414, 5518, 5623, 5729, 5836, 5944, 6053, 6163, 6274, 6386, 6499, 6613 , 6728, 6844, 6961, 7079, 7198, 7318, 7439, 7561, 7684, 7808, 7933, 8059, 8186 , 8314, 8443, 8573, 8704, 8836, 8969, 9103, 9238, 9374, 9511, 9649, 9788, 9928 , 10069, 10211, 10354, 10498, 10643, 10789, 10936, 11084, 11233, 11383, 11534 , 11686, 11839, 11993, 12148, 12304, 12461, 12619, 12778, 12938, 13099, 13261 , 13424, 13588, 13753, 13919, 14086, 14254, 14423, 14593, 14764, 14936, 15109 , 15283, 15458, 15634, 15811, 15989, 16168, 16348, 16529, 16711, 16894, 17078 , 17263, 17449, 17636, 17824, 18013, 18203, 18394, 18586, 18779, 18973, 19168 , 19364, 19561, 19759, 19958, 20158, 20359, 20561, 20764, 20968, 21173, 21379 , 21586, 21794, 22003, 22213, 22424, 22636, 22849, 23063, 23278, 23494, 23711 , 23929, 24148, 24368, 24589, 24811, 25034, 25258, 25483, 25709, 25936, 26164 , 26393, 26623, 26854, 27086, 27319, 27553, 27788, 28024, 28261, 28499, 28738 , 28978 ]; } function setAccuracyTable() public { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Admin role needed"); accuracyTable = [ 0,1,1,2,2,2,3,3,4,4,4,5,5,5,6,6,7,7,7,8,8,8,9, 9,9,10,10,11,11,11,12,12,12,13,13,13,14,14,14,15, 15,15,16,16,16,17,17,17,18,18,18,18,19,19,19,20,20, 20,21,21,21,22,22,22,22,23,23,23,24,24,24,24,25,25, 25,25,26,26,26,27,27,27,27,28,28,28,28,29,29,29,29, 30,30,30,30,31,31,31,31,32,32,32,32,32,33,33,33,33, 34,34,34,34,34,35,35,35,35,35,36,36,36,36,36,37,37, 37,37,37,38,38,38,38,38,39,39,39,39,39,39,40,40,40, 40,40,40,41,41,41,41,41,41,41,42,42,42,42,42,42,42, 43,43,43,43,43,43,43,43,44,44,44,44,44,44,44,44,44, 45,45,45,45,45,45,45,45,45,45,46,46,46,46,46,46,46, 46,46,46,46,46,46,47,47,47,47,47,47,47,47,47,47,47, 47,47,47,47,47,47,47,47,48,48,48,48,48,48,48,48,48, 48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48, 48,48,48,48,48,48,48,48,48,48,48]; } function setRegisterInterface() public { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Admin role needed"); _registerInterface(TransferCooldownableInterfaceId.interfaceId()); } function setCharacterLimitInit() external { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Admin role needed"); characterLimit = 4; } function setURIFirstIndex() external { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Admin role needed"); firstIndex[0] = 1; firstIndex[1] = 1; } function setURILastIndex() external { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Admin role needed"); lastIndex[0] = 3072; lastIndex[1] = 8190; } /* visual numbers start at 0, increment values by 1 levels: 1-256 elements: 0-3 [0(fire) > 1(water) > 2(lighting) > 3(earth) > repeat] class: 0-4 [0(Sentry) 1(Spy) 2(Commando) 3(Vanguard) 4(Hunter)] */ // enum CharacterType {Elite, Trainee} struct Character { CharacterType ctype; uint16 xp; // xp to next level uint8 accuracy; // upto 48 cap uint8 level; // up to 256 cap uint8 element; uint8 class; uint64 staminaTimestamp; // standard timestamp in seconds-resolution marking regen start from 0 uint256 eliteId; bool holographic; } struct CharacterName { string firstName; string familyName; } Character[] private tokens; uint256 public constant maxStamina = 200; uint256 public constant secondsPerStamina = 300; //5 * 60 uint256[256] private experienceTable; uint8[256] private accuracyTable; string[5] private classURIs; mapping(uint256 => uint256) public override lastTransferTimestamp; mapping(uint256 => uint256[]) public eliteTraineeMap; uint256 private lastMintedBlock; uint256 private firstMintedOfLastBlock; uint256 public characterLimit; uint256[5] private firstIndex; uint256[5] private lastIndex; mapping(uint256 => CharacterName) public characterNames; event NewCharacter(uint256 indexed character, address indexed minter); event LevelUp(address indexed owner, uint256 indexed character, uint16 level); event CustomizedCharacter(address indexed owner, uint256 character, uint8 customType); event UpdatedCharacterName(address indexed owner, uint256 character); modifier restricted() { _restricted(); _; } function _restricted() internal view { require(hasRole(GAME_ADMIN, msg.sender), "Game admin role needed."); } modifier noFreshLookup(uint256 id) { _noFreshLookup(id); _; } function _noFreshLookup(uint256 id) internal view { require(id < firstMintedOfLastBlock || lastMintedBlock < block.number, "Too fresh for lookup"); } function transferCooldownEnd(uint256 tokenId) public override view returns (uint256) { return lastTransferTimestamp[tokenId].add(TRANSFER_COOLDOWN); } function transferCooldownLeft(uint256 tokenId) public override view returns (uint256) { (bool success, uint256 secondsLeft) = lastTransferTimestamp[tokenId].trySub( block.timestamp.sub(TRANSFER_COOLDOWN) ); return success ? secondsLeft : 0; } function get(uint256 id) public view returns (uint16, uint8, uint8, uint8, uint8, uint64, CharacterType, uint256, bool) { Character memory c = tokens[id]; return ( c.xp, c.accuracy, c.level, c.element, c.class, c.staminaTimestamp, c.ctype, c.eliteId, c.holographic); } function mint(address minter, uint256 seed, CharacterType ctype, uint256 eliteId) public restricted { uint256 tokenID = tokens.length; if(block.number != lastMintedBlock) firstMintedOfLastBlock = tokenID; lastMintedBlock = block.number; uint16 xp = 0; uint8 level = 0; // 1 uint8 accuracy = accuracyTable[0]; uint8 class = 0; if(ctype == CharacterType.Elite) { class = uint8(RandomUtil.randomSeededMinMax(2,3,seed)); } else { class = uint8(RandomUtil.randomSeededMinMax(0,3,seed)); } uint8 element = uint8(RandomUtil.randomSeededMinMax(0,3,seed.add(now))); uint64 pp = uint64(now.sub(getStaminaMaxWait())); uint8 holographicRoll = uint8((seed.add(now))%1000); uint256 selectedURI = RandomUtil.randomSeededMinMax(firstIndex[class], lastIndex[class], seed); tokens.push(Character(ctype, xp, accuracy, level, element, class, pp, eliteId, holographicRoll == 2 )); if(ctype == CharacterType.Trainee) { eliteTraineeMap[eliteId].push(tokenID); } _mint(minter, tokenID); _setTokenURI(tokenID, string(abi.encodePacked(classURIs[class], selectedURI.toString()))); // classURIs[class]+"/selectedURI" emit NewCharacter(tokenID, minter); } function customizeCharacter(uint256 id, uint8 customType, uint256 seed) public restricted { Character storage char = tokens[id]; if(customType == 0) { // faction uint8 currrentElement = char.element; uint8 newElement = uint8(RandomUtil.randomSeededMinMax(0,3,seed)); char.element = newElement != currrentElement ? newElement : newElement == 3 ? 0 : uint8(newElement.add(1)); } else if(customType == 1) { // class uint8 currrentClass = char.class; uint8 newClass = uint8(RandomUtil.randomSeededMinMax(0,3,seed)); char.class = newClass != currrentClass ? newClass : newClass == 3 ? 0 : uint8(newClass.add(1)); uint256 selectedURI = RandomUtil.randomSeededMinMax(firstIndex[newClass], lastIndex[newClass], seed.add(now)); _setTokenURI(id, string(abi.encodePacked(classURIs[newClass], selectedURI.toString()))); } else if(customType == 2) { // art string memory currentUri = tokenURI(id); uint256 newSelectedURI = RandomUtil.randomSeededMinMax(firstIndex[char.class], lastIndex[char.class], seed); string memory newUri = string(abi.encodePacked(classURIs[char.class], newSelectedURI.toString())); if(keccak256(abi.encodePacked(currentUri)) != keccak256(abi.encodePacked(newUri))) { _setTokenURI(id, newUri); } else if(newSelectedURI == lastIndex[char.class]) { newSelectedURI = 1; _setTokenURI(id, string(abi.encodePacked(classURIs[char.class], newSelectedURI.toString()))); } else { newSelectedURI = newSelectedURI.add(1); _setTokenURI(id, string(abi.encodePacked(classURIs[char.class], newSelectedURI.toString()))); } } emit CustomizedCharacter(ownerOf(id), id, customType); } function setCharacterName(uint256 id, string memory firstN, string memory lastN) public restricted { require(bytes(firstN).length > 0 && bytes(firstN).length <= 10, "First name characters limit error"); require(bytes(lastN).length > 0 && bytes(lastN).length <= 10, "Family name characters limit error"); characterNames[id] = CharacterName({ firstName: firstN, familyName: lastN }); emit UpdatedCharacterName(ownerOf(id), id); } function getLevel(uint256 id) public view noFreshLookup(id) returns (uint8) { return tokens[id].level; // this is used by dataminers and it benefits us } function getRequiredXpForNextLevel(uint8 currentLevel) public view returns (uint16) { return uint16(experienceTable[currentLevel]); // this is helpful to users as the array is private } function getPower(uint256 id) public view noFreshLookup(id) returns (uint24) { return getPowerAtLevel(tokens[id].level); } function getPowerAtLevel(uint8 level) public pure returns (uint24) { // does not use fixed points since the numbers are simple // the breakpoints every 10 levels are floored as expected // level starts at 0 (visually 1) // 1000 at lvl 1 // 9000 at lvl 51 (~3months) // 22440 at lvl 105 (~3 years) // 92300 at lvl 255 (heat death of the universe) return uint24( uint256(1000) .add(level.mul(10)) .mul(level.div(10).add(1)) ); } function getElement(uint256 id) public view noFreshLookup(id) returns (uint8) { return tokens[id].element; } function getClass(uint256 id) public view noFreshLookup(id) returns (uint8) { return tokens[id].class; } function getXp(uint256 id) public view noFreshLookup(id) returns (uint32) { return tokens[id].xp; } function getAccuracy(uint256 id) public view noFreshLookup(id) returns (uint32) { return tokens[id].accuracy; } function getCharacterType(uint256 id) public view noFreshLookup(id) returns (CharacterType) { return tokens[id].ctype; // this is used by dataminers and it benefits us } function gainXp(uint256 id, uint16 xp) public restricted { Character storage char = tokens[id]; if(char.level < 255) { uint newXp = char.xp.add(xp); uint requiredToLevel = experienceTable[char.level]; // technically next level while(newXp >= requiredToLevel) { newXp = newXp - requiredToLevel; char.level += 1; char.accuracy = accuracyTable[char.level]; emit LevelUp(ownerOf(id), id, char.level); if(char.level < 255) requiredToLevel = experienceTable[char.level]; else newXp = 0; } char.xp = uint16(newXp); } } function getStaminaTimestamp(uint256 id) public view noFreshLookup(id) returns (uint64) { return tokens[id].staminaTimestamp; } function setStaminaTimestamp(uint256 id, uint64 timestamp) public restricted { tokens[id].staminaTimestamp = timestamp; } function getStaminaPoints(uint256 id) public view noFreshLookup(id) returns (uint8) { return getStaminaPointsFromTimestamp(tokens[id].staminaTimestamp); } function getStaminaPointsFromTimestamp(uint64 timestamp) public view returns (uint8) { if(timestamp > now) return 0; uint256 points = (now - timestamp) / secondsPerStamina; if(points > maxStamina) { points = maxStamina; } return uint8(points); } function isStaminaFull(uint256 id) public view noFreshLookup(id) returns (bool) { return getStaminaPoints(id) >= maxStamina; } function getStaminaMaxWait() public pure returns (uint64) { return uint64(maxStamina * secondsPerStamina); } function getFightDataAndDrainStamina(uint256 id, uint8 amount) public restricted returns(uint112) { Character storage char = tokens[id]; uint8 staminaPoints = getStaminaPointsFromTimestamp(char.staminaTimestamp); require(staminaPoints >= amount, "Not enough stamina!"); uint64 drainTime = uint64(amount * secondsPerStamina); uint64 preTimestamp = char.staminaTimestamp; if(staminaPoints >= maxStamina) { // if stamina full, we reset timestamp and drain from that char.staminaTimestamp = uint64(now - getStaminaMaxWait() + drainTime); } else { char.staminaTimestamp = uint64(char.staminaTimestamp + drainTime); } // bitwise magic to avoid stacking limitations later on return uint112(char.element | (char.accuracy << 8) | (char.class << 16) | (getPowerAtLevel(char.level) << 24) | (preTimestamp << 48)); } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override { if(to != address(0) && to != address(0x000000000000000000000000000000000000dEaD) && !hasRole(NO_OWNED_LIMIT, to)) { require(balanceOf(to) < characterLimit, "Only limited operators allowed."); } // when not minting or burning... if(from != address(0) && to != address(0)) { // only allow transferring a particular token every TRANSFER_COOLDOWN seconds require(lastTransferTimestamp[tokenId] < block.timestamp.sub(TRANSFER_COOLDOWN), "Transfer cooldown"); if(!hasRole(RECEIVE_DOES_NOT_SET_TRANSFER_TIMESTAMP, to)) { lastTransferTimestamp[tokenId] = block.timestamp; } } } function setCharacterLimit(uint256 max) public restricted { characterLimit = max; } function setURIStartIndex(uint8 class, uint256 first) public restricted { firstIndex[class] = first; } function setURILastIndex(uint8 class, uint256 last) public restricted { lastIndex[class] = last; } function setXp(uint256 id, uint256 xpNew) external restricted { tokens[id].xp = uint16(tokens[id].xp.add(uint(xpNew))); } function setClassURIs(uint256 index, string memory uri) public restricted { classURIs[index] = uri; } }
// SPDX-License-Identifier: BSD-4-Clause /* * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting. * Author: Mikhail Vladimirov <[email protected]> */ pragma solidity ^0.5.0 || ^0.6.0 || ^0.7.0; /** * Smart contract library of mathematical functions operating with signed * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is * basically a simple fraction whose numerator is signed 128-bit integer and * denominator is 2^64. As long as denominator is always the same, there is no * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are * represented by int128 type holding only the numerator. */ library ABDKMath64x64 { /* * Minimum value signed 64.64-bit fixed point number may have. */ int128 private constant MIN_64x64 = -0x80000000000000000000000000000000; /* * Maximum value signed 64.64-bit fixed point number may have. */ int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; /** * Convert signed 256-bit integer number into signed 64.64-bit fixed point * number. Revert on overflow. * * @param x signed 256-bit integer number * @return signed 64.64-bit fixed point number */ function fromInt (int256 x) internal pure returns (int128) { require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF); return int128 (x << 64); } /** * Convert signed 64.64 fixed point number into signed 64-bit integer number * rounding down. * * @param x signed 64.64-bit fixed point number * @return signed 64-bit integer number */ function toInt (int128 x) internal pure returns (int64) { return int64 (x >> 64); } /** * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point * number. Revert on overflow. * * @param x unsigned 256-bit integer number * @return signed 64.64-bit fixed point number */ function fromUInt (uint256 x) internal pure returns (int128) { require (x <= 0x7FFFFFFFFFFFFFFF); return int128 (x << 64); } /** * Convert signed 64.64 fixed point number into unsigned 64-bit integer * number rounding down. Revert on underflow. * * @param x signed 64.64-bit fixed point number * @return unsigned 64-bit integer number */ function toUInt (int128 x) internal pure returns (uint64) { require (x >= 0); return uint64 (x >> 64); } /** * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point * number rounding down. Revert on overflow. * * @param x signed 128.128-bin fixed point number * @return signed 64.64-bit fixed point number */ function from128x128 (int256 x) internal pure returns (int128) { int256 result = x >> 64; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } /** * Convert signed 64.64 fixed point number into signed 128.128 fixed point * number. * * @param x signed 64.64-bit fixed point number * @return signed 128.128 fixed point number */ function to128x128 (int128 x) internal pure returns (int256) { return int256 (x) << 64; } /** * Calculate x + y. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function add (int128 x, int128 y) internal pure returns (int128) { int256 result = int256(x) + y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } /** * Calculate x - y. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function sub (int128 x, int128 y) internal pure returns (int128) { int256 result = int256(x) - y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } /** * Calculate x * y rounding down. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function mul (int128 x, int128 y) internal pure returns (int128) { int256 result = int256(x) * y >> 64; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } /** * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point * number and y is signed 256-bit integer number. Revert on overflow. * * @param x signed 64.64 fixed point number * @param y signed 256-bit integer number * @return signed 256-bit integer number */ function muli (int128 x, int256 y) internal pure returns (int256) { if (x == MIN_64x64) { require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF && y <= 0x1000000000000000000000000000000000000000000000000); return -y << 63; } else { bool negativeResult = false; if (x < 0) { x = -x; negativeResult = true; } if (y < 0) { y = -y; // We rely on overflow behavior here negativeResult = !negativeResult; } uint256 absoluteResult = mulu (x, uint256 (y)); if (negativeResult) { require (absoluteResult <= 0x8000000000000000000000000000000000000000000000000000000000000000); return -int256 (absoluteResult); // We rely on overflow behavior here } else { require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return int256 (absoluteResult); } } } /** * Calculate x * y rounding down, where x is signed 64.64 fixed point number * and y is unsigned 256-bit integer number. Revert on overflow. * * @param x signed 64.64 fixed point number * @param y unsigned 256-bit integer number * @return unsigned 256-bit integer number */ function mulu (int128 x, uint256 y) internal pure returns (uint256) { if (y == 0) return 0; require (x >= 0); uint256 lo = (uint256 (x) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64; uint256 hi = uint256 (x) * (y >> 128); require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); hi <<= 64; require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo); return hi + lo; } /** * Calculate x / y rounding towards zero. Revert on overflow or when y is * zero. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function div (int128 x, int128 y) internal pure returns (int128) { require (y != 0); int256 result = (int256 (x) << 64) / y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } /** * Calculate x / y rounding towards zero, where x and y are signed 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x signed 256-bit integer number * @param y signed 256-bit integer number * @return signed 64.64-bit fixed point number */ function divi (int256 x, int256 y) internal pure returns (int128) { require (y != 0); bool negativeResult = false; if (x < 0) { x = -x; // We rely on overflow behavior here negativeResult = true; } if (y < 0) { y = -y; // We rely on overflow behavior here negativeResult = !negativeResult; } uint128 absoluteResult = divuu (uint256 (x), uint256 (y)); if (negativeResult) { require (absoluteResult <= 0x80000000000000000000000000000000); return -int128 (absoluteResult); // We rely on overflow behavior here } else { require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return int128 (absoluteResult); // We rely on overflow behavior here } } /** * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x unsigned 256-bit integer number * @param y unsigned 256-bit integer number * @return signed 64.64-bit fixed point number */ function divu (uint256 x, uint256 y) internal pure returns (int128) { require (y != 0); uint128 result = divuu (x, y); require (result <= uint128 (MAX_64x64)); return int128 (result); } /** * Calculate -x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function neg (int128 x) internal pure returns (int128) { require (x != MIN_64x64); return -x; } /** * Calculate |x|. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function abs (int128 x) internal pure returns (int128) { require (x != MIN_64x64); return x < 0 ? -x : x; } /** * Calculate 1 / x rounding towards zero. Revert on overflow or when x is * zero. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function inv (int128 x) internal pure returns (int128) { require (x != 0); int256 result = int256 (0x100000000000000000000000000000000) / x; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); } /** * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function avg (int128 x, int128 y) internal pure returns (int128) { return int128 ((int256 (x) + int256 (y)) >> 1); } /** * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down. * Revert on overflow or in case x * y is negative. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function gavg (int128 x, int128 y) internal pure returns (int128) { int256 m = int256 (x) * int256 (y); require (m >= 0); require (m < 0x4000000000000000000000000000000000000000000000000000000000000000); return int128 (sqrtu (uint256 (m))); } /** * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number * and y is unsigned 256-bit integer number. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y uint256 value * @return signed 64.64-bit fixed point number */ function pow (int128 x, uint256 y) internal pure returns (int128) { uint256 absoluteResult; bool negativeResult = false; if (x >= 0) { absoluteResult = powu (uint256 (x) << 63, y); } else { // We rely on overflow behavior here absoluteResult = powu (uint256 (uint128 (-x)) << 63, y); negativeResult = y & 1 > 0; } absoluteResult >>= 63; if (negativeResult) { require (absoluteResult <= 0x80000000000000000000000000000000); return -int128 (absoluteResult); // We rely on overflow behavior here } else { require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return int128 (absoluteResult); // We rely on overflow behavior here } } /** * Calculate sqrt (x) rounding down. Revert if x < 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function sqrt (int128 x) internal pure returns (int128) { require (x >= 0); return int128 (sqrtu (uint256 (x) << 64)); } /** * Calculate binary logarithm of x. Revert if x <= 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function log_2 (int128 x) internal pure returns (int128) { require (x > 0); int256 msb = 0; int256 xc = x; if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; } if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore int256 result = msb - 64 << 64; uint256 ux = uint256 (x) << uint256 (127 - msb); for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) { ux *= ux; uint256 b = ux >> 255; ux >>= 127 + b; result += bit * int256 (b); } return int128 (result); } /** * Calculate natural logarithm of x. Revert if x <= 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function ln (int128 x) internal pure returns (int128) { require (x > 0); return int128 ( uint256 (log_2 (x)) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128); } /** * Calculate binary exponent of x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function exp_2 (int128 x) internal pure returns (int128) { require (x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow uint256 result = 0x80000000000000000000000000000000; if (x & 0x8000000000000000 > 0) result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128; if (x & 0x4000000000000000 > 0) result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128; if (x & 0x2000000000000000 > 0) result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128; if (x & 0x1000000000000000 > 0) result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128; if (x & 0x800000000000000 > 0) result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128; if (x & 0x400000000000000 > 0) result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128; if (x & 0x200000000000000 > 0) result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128; if (x & 0x100000000000000 > 0) result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128; if (x & 0x80000000000000 > 0) result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128; if (x & 0x40000000000000 > 0) result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128; if (x & 0x20000000000000 > 0) result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128; if (x & 0x10000000000000 > 0) result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128; if (x & 0x8000000000000 > 0) result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128; if (x & 0x4000000000000 > 0) result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128; if (x & 0x2000000000000 > 0) result = result * 0x1000162E525EE054754457D5995292026 >> 128; if (x & 0x1000000000000 > 0) result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128; if (x & 0x800000000000 > 0) result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128; if (x & 0x400000000000 > 0) result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128; if (x & 0x200000000000 > 0) result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128; if (x & 0x100000000000 > 0) result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128; if (x & 0x80000000000 > 0) result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128; if (x & 0x40000000000 > 0) result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128; if (x & 0x20000000000 > 0) result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128; if (x & 0x10000000000 > 0) result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128; if (x & 0x8000000000 > 0) result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128; if (x & 0x4000000000 > 0) result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128; if (x & 0x2000000000 > 0) result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128; if (x & 0x1000000000 > 0) result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128; if (x & 0x800000000 > 0) result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128; if (x & 0x400000000 > 0) result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128; if (x & 0x200000000 > 0) result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128; if (x & 0x100000000 > 0) result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128; if (x & 0x80000000 > 0) result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128; if (x & 0x40000000 > 0) result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128; if (x & 0x20000000 > 0) result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128; if (x & 0x10000000 > 0) result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128; if (x & 0x8000000 > 0) result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128; if (x & 0x4000000 > 0) result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128; if (x & 0x2000000 > 0) result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128; if (x & 0x1000000 > 0) result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128; if (x & 0x800000 > 0) result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128; if (x & 0x400000 > 0) result = result * 0x100000000002C5C85FDF477B662B26945 >> 128; if (x & 0x200000 > 0) result = result * 0x10000000000162E42FEFA3AE53369388C >> 128; if (x & 0x100000 > 0) result = result * 0x100000000000B17217F7D1D351A389D40 >> 128; if (x & 0x80000 > 0) result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128; if (x & 0x40000 > 0) result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128; if (x & 0x20000 > 0) result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128; if (x & 0x10000 > 0) result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128; if (x & 0x8000 > 0) result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128; if (x & 0x4000 > 0) result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128; if (x & 0x2000 > 0) result = result * 0x1000000000000162E42FEFA39F02B772C >> 128; if (x & 0x1000 > 0) result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128; if (x & 0x800 > 0) result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128; if (x & 0x400 > 0) result = result * 0x100000000000002C5C85FDF473DEA871F >> 128; if (x & 0x200 > 0) result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128; if (x & 0x100 > 0) result = result * 0x100000000000000B17217F7D1CF79E949 >> 128; if (x & 0x80 > 0) result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128; if (x & 0x40 > 0) result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128; if (x & 0x20 > 0) result = result * 0x100000000000000162E42FEFA39EF366F >> 128; if (x & 0x10 > 0) result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128; if (x & 0x8 > 0) result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128; if (x & 0x4 > 0) result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128; if (x & 0x2 > 0) result = result * 0x1000000000000000162E42FEFA39EF358 >> 128; if (x & 0x1 > 0) result = result * 0x10000000000000000B17217F7D1CF79AB >> 128; result >>= uint256 (63 - (x >> 64)); require (result <= uint256 (MAX_64x64)); return int128 (result); } /** * Calculate natural exponent of x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function exp (int128 x) internal pure returns (int128) { require (x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow return exp_2 ( int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128)); } /** * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x unsigned 256-bit integer number * @param y unsigned 256-bit integer number * @return unsigned 64.64-bit fixed point number */ function divuu (uint256 x, uint256 y) private pure returns (uint128) { require (y != 0); uint256 result; if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) result = (x << 64) / y; else { uint256 msb = 192; uint256 xc = x >> 192; if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1); require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 hi = result * (y >> 128); uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 xh = x >> 192; uint256 xl = x << 64; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here lo = hi << 128; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here assert (xh == hi >> 128); result += xl / y; } require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return uint128 (result); } /** * Calculate x^y assuming 0^0 is 1, where x is unsigned 129.127 fixed point * number and y is unsigned 256-bit integer number. Revert on overflow. * * @param x unsigned 129.127-bit fixed point number * @param y uint256 value * @return unsigned 129.127-bit fixed point number */ function powu (uint256 x, uint256 y) private pure returns (uint256) { if (y == 0) return 0x80000000000000000000000000000000; else if (x == 0) return 0; else { int256 msb = 0; uint256 xc = x; if (xc >= 0x100000000000000000000000000000000) { xc >>= 128; msb += 128; } if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; } if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore int256 xe = msb - 127; if (xe > 0) x >>= uint256 (xe); else x <<= uint256 (-xe); uint256 result = 0x80000000000000000000000000000000; int256 re = 0; while (y > 0) { if (y & 1 > 0) { result = result * x; y -= 1; re += xe; if (result >= 0x8000000000000000000000000000000000000000000000000000000000000000) { result >>= 128; re += 1; } else result >>= 127; if (re < -127) return 0; // Underflow require (re < 128); // Overflow } else { x = x * x; y >>= 1; xe <<= 1; if (x >= 0x8000000000000000000000000000000000000000000000000000000000000000) { x >>= 128; xe += 1; } else x >>= 127; if (xe < -127) return 0; // Underflow require (xe < 128); // Overflow } } if (re > 0) result <<= uint256 (re); else if (re < 0) result >>= uint256 (-re); return result; } } /** * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer * number. * * @param x unsigned 256-bit integer number * @return unsigned 128-bit integer number */ function sqrtu (uint256 x) private pure returns (uint128) { if (x == 0) return 0; else { uint256 xx = x; uint256 r = 1; if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; } if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; } if (xx >= 0x100000000) { xx >>= 32; r <<= 16; } if (xx >= 0x10000) { xx >>= 16; r <<= 8; } if (xx >= 0x100) { xx >>= 8; r <<= 4; } if (xx >= 0x10) { xx >>= 4; r <<= 2; } if (xx >= 0x8) { r <<= 1; } r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; // Seven iterations should be enough uint256 r1 = x / r; return uint128 (r < r1 ? r : r1); } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @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 ReentrancyGuard { // 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; constructor () internal { _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 make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor () internal { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 GSN 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 payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount) external returns (bool); /** * @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); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev String operations. */ library StringsUpgradeable { /** * @dev Converts a `uint256` to its ASCII `string` representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../proxy/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 initializer { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal initializer { _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 make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./ContextUpgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal initializer { __Context_init_unchained(); __Pausable_init_unchained(); } function __Pausable_init_unchained() internal initializer { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are * supported. */ library EnumerableMapUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Map type with // bytes32 keys and values. // The Map implementation uses private functions, and user-facing // implementations (such as Uint256ToAddressMap) are just wrappers around // the underlying Map. // This means that we can only create new EnumerableMaps for types that fit // in bytes32. struct MapEntry { bytes32 _key; bytes32 _value; } struct Map { // Storage of map keys and values MapEntry[] _entries; // Position of the entry defined by a key in the `entries` array, plus 1 // because index 0 means a key is not in the map. mapping (bytes32 => uint256) _indexes; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) { // Equivalent to !contains(map, key) map._entries.push(MapEntry({ _key: key, _value: value })); // The entry is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value map._indexes[key] = map._entries.length; return true; } else { map._entries[keyIndex - 1]._value = value; return false; } } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function _remove(Map storage map, bytes32 key) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex != 0) { // Equivalent to contains(map, key) // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one // in the array, and then remove the last entry (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = keyIndex - 1; uint256 lastIndex = map._entries.length - 1; // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. MapEntry storage lastEntry = map._entries[lastIndex]; // Move the last entry to the index where the entry to delete is map._entries[toDeleteIndex] = lastEntry; // Update the index for the moved entry map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved entry was stored map._entries.pop(); // Delete the index for the deleted slot delete map._indexes[key]; return true; } else { return false; } } /** * @dev Returns true if the key is in the map. O(1). */ function _contains(Map storage map, bytes32 key) private view returns (bool) { return map._indexes[key] != 0; } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function _length(Map storage map) private view returns (uint256) { return map._entries.length; } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) { require(map._entries.length > index, "EnumerableMap: index out of bounds"); MapEntry storage entry = map._entries[index]; return (entry._key, entry._value); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) { uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key) return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function _get(Map storage map, bytes32 key) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {_tryGet}. */ function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } // UintToAddressMap struct UintToAddressMap { Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return _remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return _contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); } /** * @dev Returns the element stored at position `index` in the set. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (uint256(key), address(uint160(uint256(value)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. * * _Available since v3.4._ */ function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage)))); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../proxy/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 GSN 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 initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @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 * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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 functionCall(target, data, "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"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(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) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "../../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`, 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * 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 Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @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 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); /** * @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; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 `IERC721.onERC721Received.selector`. */ function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <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 pragma solidity >=0.6.2 <0.8.0; import "./IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721EnumerableUpgradeable is IERC721Upgradeable { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/ContextUpgradeable.sol"; import "./IERC721Upgradeable.sol"; import "./IERC721MetadataUpgradeable.sol"; import "./IERC721EnumerableUpgradeable.sol"; import "./IERC721ReceiverUpgradeable.sol"; import "../../introspection/ERC165Upgradeable.sol"; import "../../math/SafeMathUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/EnumerableSetUpgradeable.sol"; import "../../utils/EnumerableMapUpgradeable.sol"; import "../../utils/StringsUpgradeable.sol"; import "../../proxy/Initializable.sol"; /** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable, IERC721EnumerableUpgradeable { using SafeMathUpgradeable for uint256; using AddressUpgradeable for address; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.UintSet; using EnumerableMapUpgradeable for EnumerableMapUpgradeable.UintToAddressMap; using StringsUpgradeable for uint256; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from holder address to their (enumerable) set of owned tokens mapping (address => EnumerableSetUpgradeable.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMapUpgradeable.UintToAddressMap private _tokenOwners; // 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; // Token name string private _name; // Token symbol string private _symbol; // Optional mapping for token URIs mapping (uint256 => string) private _tokenURIs; // Base URI string private _baseURI; /* * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde * * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ * 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; /* * bytes4(keccak256('totalSupply()')) == 0x18160ddd * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59 * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 * * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63 */ bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; /** * @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 initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal initializer { _name = name_; _symbol = symbol_; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); _registerInterface(_INTERFACE_ID_ERC721_METADATA); _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _holderTokens[owner].length(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token"); } /** * @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) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); 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)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString())); } /** * @dev Returns the base URI set via {_setBaseURI}. This will be * automatically added as a prefix in {tokenURI} to each token's URI, or * to the token ID if no specific URI is set for that token ID. */ function baseURI() public view virtual returns (string memory) { return _baseURI; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { return _holderTokens[owner].at(index); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { (uint256 tokenId, ) = _tokenOwners.at(index); return tokenId; } /** * @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 || ERC721Upgradeable.isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_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: transfer caller is not owner nor 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: transfer caller is not owner nor 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 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 _tokenOwners.contains(tokenId); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721Upgradeable.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || ERC721Upgradeable.isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: d* * - `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); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721Upgradeable.ownerOf(tokenId); // internal owner _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } _holderTokens[owner].remove(tokenId); _tokenOwners.remove(tokenId); emit Transfer(owner, address(0), tokenId); } /** * @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 of token that is not own"); // internal owner require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _holderTokens[from].remove(tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(from, to, 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), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}, * or to the token ID if {tokenURI} is empty. */ function _setBaseURI(string memory baseURI_) internal virtual { _baseURI = baseURI_; } /** * @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()) { return true; } bytes memory returndata = to.functionCall(abi.encodeWithSelector( IERC721ReceiverUpgradeable(to).onERC721Received.selector, _msgSender(), from, tokenId, _data ), "ERC721: transfer to non ERC721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } /** * @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); // internal owner } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } uint256[41] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC20Upgradeable.sol"; import "../../math/SafeMathUpgradeable.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 SafeMathUpgradeable for uint256; 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' // solhint-disable-next-line max-line-length 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).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @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 // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount) external returns (bool); /** * @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); }
// SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version pragma solidity >=0.4.24 <0.8.0; 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 a proxied contract can't have 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. * * 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 {UpgradeableProxy-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. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMathUpgradeable { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 pragma solidity >=0.6.0 <0.8.0; import "./IERC165Upgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; function __ERC165_init() internal initializer { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal initializer { // Derived contracts need only register support for their own interfaces, // we register support for ERC165 itself here _registerInterface(_INTERFACE_ID_ERC165); } /** * @dev See {IERC165-supportsInterface}. * * Time complexity O(1), guaranteed to always use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return _supportedInterfaces[interfaceId]; } /** * @dev Registers the contract as an implementer of the interface defined by * `interfaceId`. Support of the actual ERC165 interface is automatic and * registering its interface id is not required. * * See {IERC165-supportsInterface}. * * Requirements: * * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). */ function _registerInterface(bytes4 interfaceId) internal virtual { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/EnumerableSetUpgradeable.sol"; import "../utils/AddressUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. * * 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 { function __AccessControl_init() internal initializer { __Context_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal initializer { } using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; using AddressUpgradeable for address; struct RoleData { EnumerableSetUpgradeable.AddressSet members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @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 {_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) public view returns (bool) { return _roles[role].members.contains(account); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view returns (uint256) { return _roles[role].members.length(); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view returns (address) { return _roles[role].members.at(index); } /** * @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 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. */ function grantRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); _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. */ function revokeRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); _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 granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual { 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. * * [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}. * ==== */ 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 { emit RoleAdminChanged(role, _roles[role].adminRole, adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } uint256[49] private __gap; }
{ "remappings": [], "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "istanbul", "libraries": {}, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } } }
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"coreTokensSold","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"overflowed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"tagTokensSold","type":"event"},{"inputs":[],"name":"CORE","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TAG","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TAGUsdcLPToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USDC","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"users","type":"address[]"}],"name":"addEarlyAdopters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"","type":"uint8"}],"name":"bundleTokensCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"bundleType","type":"uint8"},{"internalType":"uint256","name":"characterId","type":"uint256"},{"internalType":"address","name":"referral","type":"address"}],"name":"buyTagUsingUSDC","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"characters","outputs":[{"internalType":"contract Characters","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"characterId","type":"uint256"},{"internalType":"uint8","name":"customType","type":"uint8"}],"name":"customizeOperators","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"earlyAdopters","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"earlyAdoptersDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllEarlyAdopters","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract Characters","name":"_characters","type":"address"},{"internalType":"contract IRandoms","name":"_randoms","type":"address"},{"internalType":"address","name":"_usdc","type":"address"},{"internalType":"address","name":"_tag","type":"address"},{"internalType":"address","name":"_core","type":"address"},{"internalType":"address","name":"_tagUsdcLPTokens","type":"address"},{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"uint256","name":"_overflowChance","type":"uint256"},{"internalType":"address[]","name":"_earlyAdopters","type":"address[]"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxPercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"","type":"uint8"}],"name":"miniFeatures","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"overflowChance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"overflowCore","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceIncreaseForTag","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"randoms","outputs":[{"internalType":"contract IRandoms","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"referralEarning","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referralPercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_lpToken","type":"address"}],"name":"setLPTokenAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"customType","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setMiniFeaturesFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"characterId","type":"uint256"},{"internalType":"string","name":"firstN","type":"string"},{"internalType":"string","name":"lastN","type":"string"}],"name":"setOperatorName","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_overflowChance","type":"uint256"}],"name":"setOverflowChance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setStoreStartTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasury","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"storeSaleStarts","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"storeTagBasePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"storeTagPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tagSoldInPercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalMiniFeaturesFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalTags","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawCORE","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawLPTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawTAG","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawUSDC","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50613577806100206000396000f3fe608060405234801561001057600080fd5b50600436106102ba5760003560e01c80638a7130a011610182578063ca15c873116100e9578063e03a4eb5116100a2578063e5cb196c1161007c578063e5cb196c14610558578063f0f4426014610560578063f42ebbe014610573578063fff5e04214610586576102ba565b8063e03a4eb514610533578063e1b85fc914610548578063e4658b5014610550576102ba565b8063ca15c873146104d7578063cf5ed7f7146104ea578063d070bb54146104f2578063d547741f146104fa578063daeaea531461050d578063db81f99b14610520576102ba565b8063a1cae8e11161013b578063a1cae8e114610491578063a217fddf146104a4578063b2efd34f146104ac578063b9949541146104bf578063bee666d8146104c7578063c2763cd6146104cf576102ba565b80638a7130a0146104355780638f53bdf4146104485780639010d07c1461045b57806391d148541461046e57806397f8c8e514610481578063a1a2335814610489576102ba565b8063438e11f8116102265780636b6c0774116101df5780636b6c0774146103ef5780637c6863d4146103f75780638456cb591461040a578063851dc1111461041257806388b2436e1461041a57806389a302711461042d576102ba565b8063438e11f81461039a578063452d003f146103a257806347221ac7146103b557806359a153ba146103ca5780635c975abb146103d257806361d027b3146103e7576102ba565b80632670492011610278578063267049201461033e5780632f2ff15d1461035157806331285e1c14610364578063343dfb7e1461037757806336568abe1461037f5780633f4ba83a14610392576102ba565b8062e9236f146102bf5780630145d384146102dd57806301b32c1f146102f25780630c3f41ee146103055780631bd8225d14610318578063248a9ca31461032b575b600080fd5b6102c761058e565b6040516102d49190612e3e565b60405180910390f35b6102f06102eb366004612cc4565b61059d565b005b6102f0610300366004612a88565b6105bb565b6102f0610313366004612cef565b61071f565b6102c76103263660046129f5565b611067565b6102c7610339366004612a88565b611079565b6102c761034c366004612c8c565b61108e565b6102f061035f366004612aa0565b6110a0565b6102f0610372366004612af0565b6110e8565b6102c76112cf565b6102f061038d366004612aa0565b6112d4565b6102f0611316565b6102c7611328565b6102f06103b0366004612a88565b61132e565b6103bd61142e565b6040516102d49190612d7b565b6102c761143d565b6103da611442565b6040516102d49190612e33565b6103bd61144c565b6103bd61145b565b6102c7610405366004612c8c565b61146a565b6102f061147c565b6102f061148c565b6103bd610428366004612a88565b6114ba565b6103bd6114e1565b6102f0610443366004612a88565b6114f0565b6102f0610456366004612c68565b6115f0565b6103bd610469366004612acf565b6118e6565b6103da61047c366004612aa0565b61190d565b6102c761192b565b6102c7611931565b6102f061049f366004612a88565b611937565b6102c7611944565b6102f06104ba366004612bfe565b611949565b6102c7611b73565b6103bd611b79565b6103bd611b88565b6102c76104e5366004612a88565b611b97565b6102c7611bae565b6103bd611bb4565b6102f0610508366004612aa0565b611bc3565b6102f061051b366004612a2d565b611bfd565b6102f061052e366004612a88565b611ccb565b61053b611dcb565b6040516102d49190612de6565b6102c7611e2d565b6102c7611e33565b6102c7611e39565b6102f061056e3660046129f5565b611e3f565b6102f06105813660046129f5565b611e69565b6102c7611e93565b6aa56fa5b99019a5c800000081565b6105a5611e99565b60ff909116600090815260dc6020526040902055565b600260975414156105e75760405162461bcd60e51b81526004016105de906133d4565b60405180910390fd5b60026097556105f4611e99565b60cb546040516370a0823160e01b815282916001600160a01b0316906370a0823190610624903090600401612d7b565b60206040518083038186803b15801561063c57600080fd5b505afa158015610650573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106749190612be6565b10156106925760405162461bcd60e51b81526004016105de9061345a565b60cb5460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb906106c49033908590600401612dcd565b602060405180830381600087803b1580156106de57600080fd5b505af11580156106f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107169190612a68565b50506001609755565b610727611442565b156107445760405162461bcd60e51b81526004016105de90613115565b61074c611ec0565b3361075681611ecc565b600260975414156107795760405162461bcd60e51b81526004016105de906133d4565b600260975560d35461079390610e1063ffffffff611f1f16565b421015610807576000805b60da548110156107e757336001600160a01b031660da82815481106107bf57fe5b6000918252602090912001546001600160a01b031614156107df57600191505b60010161079e565b50806108055760405162461bcd60e51b81526004016105de90612fe9565b505b816001600160a01b0381161561084057336001600160a01b03821614156108405760405162461bcd60e51b81526004016105de906133a8565b8361084a81611f44565b84866108568282611fed565b60ff8816600090815260d8602052604081205460cf5490919061088090839063ffffffff61220316565b905060006108a76103e861089b84601963ffffffff61220316565b9063ffffffff61223d16565b60cd54604051636eb1769f60e11b815291925083916001600160a01b039091169063dd62ed3e906108de9033903090600401612d8f565b60206040518083038186803b1580156108f657600080fd5b505afa15801561090a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061092e9190612be6565b101561094c5760405162461bcd60e51b81526004016105de9061326c565b60ca54604051630e20f61560e21b81526000916001600160a01b031690633883d8549061097d903390600401612d7b565b60206040518083038186803b15801561099557600080fd5b505afa1580156109a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109cd9190612be6565b60cb546040516370a0823160e01b8152919250610a8691610a78916aa56fa5b99019a5c80000009161089b916064916001600160a01b03909116906370a0823190610a1c903090600401612d7b565b60206040518083038186803b158015610a3457600080fd5b505afa158015610a48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a6c9190612be6565b9063ffffffff61220316565b60649063ffffffff61226f16565b60d2819055603211801590610a9d5750603c60d254105b15610abf5760d15460d054610ab79163ffffffff611f1f16565b60cf55610b9a565b603c60d25410158015610ad45750604660d254105b15610b005760d154610ab790610af190600263ffffffff61220316565b60d0549063ffffffff611f1f16565b604660d25410158015610b155750605060d254105b15610b325760d154610ab790610af190600363ffffffff61220316565b605060d25410158015610b475750605a60d254105b15610b645760d154610ab790610af190600463ffffffff61220316565b605a60d25410158015610b795750606460d254105b15610b9a5760d154610b9690610af190600563ffffffff61220316565b60cf555b610bc2610bb3606461089b87600563ffffffff61220316565b60d4549063ffffffff611f1f16565b60d45560cd546001600160a01b03166323b872dd3330610bf9610bec87600263ffffffff61220316565b889063ffffffff61226f16565b6040518463ffffffff1660e01b8152600401610c1793929190612da9565b602060405180830381600087803b158015610c3157600080fd5b505af1158015610c45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c699190612a68565b506001600160a01b038a1615610d475760cd546040516323b872dd60e01b81526001600160a01b03909116906323b872dd90610cad9033908e908790600401612da9565b602060405180830381600087803b158015610cc757600080fd5b505af1158015610cdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cff9190612a68565b506001600160a01b038a16600090815260d96020526040902054610d29908363ffffffff611f1f16565b6001600160a01b038b16600090815260d96020526040902055610dd4565b60cd5460d6546040516323b872dd60e01b81526001600160a01b03928316926323b872dd92610d80923392909116908790600401612da9565b602060405180830381600087803b158015610d9a57600080fd5b505af1158015610dae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd29190612a68565b505b60cd5460d6546040516323b872dd60e01b81526001600160a01b03928316926323b872dd92610e0d923392909116908790600401612da9565b602060405180830381600087803b158015610e2757600080fd5b505af1158015610e3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5f9190612a68565b50610e6a8b8d612297565b60cb546001600160a01b031663a9059cbb33610e9487670de0b6b3a764000063ffffffff61220316565b6040518363ffffffff1660e01b8152600401610eb1929190612dcd565b602060405180830381600087803b158015610ecb57600080fd5b505af1158015610edf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f039190612a68565b5060d554610f1890829063ffffffff6123ac16565b6110075760cc5460d4546001600160a01b039091169063a9059cbb903390610f4e90670de0b6b3a764000063ffffffff61220316565b6040518363ffffffff1660e01b8152600401610f6b929190612dcd565b602060405180830381600087803b158015610f8557600080fd5b505af1158015610f99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fbd9190612a68565b50336001600160a01b03167fb70ba9473dd6cf656adf13fb552af08c98ed2db7617cbd30d2ed91cbd950fe0960d454604051610ff99190612e3e565b60405180910390a2600060d4555b60ff8c16600090815260d860205260409081902054905133917f6bf09d88df35e3a9f078672669e47fac71dda4136decc107b4c9d4b9f9c25fec9161104c9190612e3e565b60405180910390a25050600160975550505050505050505050565b60d96020526000908152604090205481565b60009081526033602052604090206002015490565b60dc6020526000908152604090205481565b6000828152603360205260409020600201546110be9061047c6123de565b6110da5760405162461bcd60e51b81526004016105de90612efe565b6110e482826123e2565b5050565b600054610100900460ff16806111015750611101612451565b8061110f575060005460ff16155b61112b5760405162461bcd60e51b81526004016105de906131ca565b600054610100900460ff16158015611156576000805460ff1961ff0019909116610100171660011790555b61115e612462565b6111696000336110da565b60cd80546001600160a01b03199081166001600160a01b038b81169190911790925560cb805482168a841617905560cc8054821689841617905560ce8054821688841617905560c9805482168d841617905560ca805482168c841617905560d6805490911691861691909117905560d58390556107d060cf81905560d055600060d281905561019060d15560d381905560d860209081526109c47fa1c22ab04d5a14eb0b9d727ce553bde77dd4c57869bd47735629b3593c2d1364556130d47fdd1fd626b6a6510e3f131ed76f8d2c0ac44a92fbf50a4ce319f246853c5b5a09556161a87f7e178e8cc2471df3be8871998633f08a591282fb3a8961cb5d8a7a2413d2aac8556003825261c3507f60a592c01b1028f28cf4d7ce4c92f34a7df548ac23775b70c0b8b662d9347dcc5560d49190915582516112b09160da919085019061287a565b5080156112c3576000805461ff00191690555b50505050505050505050565b601981565b6112dc6123de565b6001600160a01b0316816001600160a01b03161461130c5760405162461bcd60e51b81526004016105de9061340b565b6110e482826124f4565b61131e611e99565b611326612563565b565b60cf5481565b600260975414156113515760405162461bcd60e51b81526004016105de906133d4565b600260975561135e611e99565b60ce546040516370a0823160e01b815282916001600160a01b0316906370a082319061138e903090600401612d7b565b60206040518083038186803b1580156113a657600080fd5b505afa1580156113ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113de9190612be6565b10156113fc5760405162461bcd60e51b81526004016105de9061345a565b60ce5460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb906106c49033908590600401612dcd565b60cb546001600160a01b031681565b606481565b60655460ff165b90565b60d6546001600160a01b031681565b60cc546001600160a01b031681565b60d86020526000908152604090205481565b611484611e99565b6113266125d1565b611494611e99565b60d354156114b45760405162461bcd60e51b81526004016105de9061331b565b4260d355565b60da81815481106114c757fe5b6000918252602090912001546001600160a01b0316905081565b60cd546001600160a01b031681565b600260975414156115135760405162461bcd60e51b81526004016105de906133d4565b6002609755611520611e99565b60cc546040516370a0823160e01b815282916001600160a01b0316906370a0823190611550903090600401612d7b565b60206040518083038186803b15801561156857600080fd5b505afa15801561157c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115a09190612be6565b10156115be5760405162461bcd60e51b81526004016105de9061345a565b60cc5460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb906106c49033908590600401612dcd565b6115f8611442565b156116155760405162461bcd60e51b81526004016105de90613115565b600260975414156116385760405162461bcd60e51b81526004016105de906133d4565b60026097553361164781611ecc565b61164f611ec0565b8261165981611f44565b60028360ff16111561167d5760405162461bcd60e51b81526004016105de90613218565b60ff8316600090815260dc60205260408120546116a890670de0b6b3a764000063ffffffff61220316565b60cb54604051636eb1769f60e11b815291925082916001600160a01b039091169063dd62ed3e906116df9033903090600401612d8f565b60206040518083038186803b1580156116f757600080fd5b505afa15801561170b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061172f9190612be6565b101561174d5760405162461bcd60e51b81526004016105de90612f7b565b60ca54604051630e20f61560e21b81526000916001600160a01b031690633883d8549061177e903390600401612d7b565b60206040518083038186803b15801561179657600080fd5b505afa1580156117aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ce9190612be6565b60db549091506117e4908363ffffffff611f1f16565b60db5560cb5460d6546040516323b872dd60e01b81526001600160a01b03928316926323b872dd92611820923392909116908790600401612da9565b602060405180830381600087803b15801561183a57600080fd5b505af115801561184e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118729190612a68565b5060c9546040516370f71efd60e01b81526001600160a01b03909116906370f71efd906118a7908990899086906004016134dd565b600060405180830381600087803b1580156118c157600080fd5b505af11580156118d5573d6000803e3d6000fd5b505060016097555050505050505050565b6000828152603360205260408120611904908363ffffffff61262c16565b90505b92915050565b6000828152603360205260408120611904908363ffffffff61263816565b60d35481565b60d45481565b61193f611e99565b60d555565b600081565b611951611442565b1561196e5760405162461bcd60e51b81526004016105de90613115565b600260975414156119915760405162461bcd60e51b81526004016105de906133d4565b6002609755336119a081611ecc565b6119a8611ec0565b836119b281611f44565b6003600090815260dc6020527fd424594b947c18da8f3a6f93819695640a748b6d74709a708102e14e3e81669c546119f890670de0b6b3a764000063ffffffff61220316565b60cb54604051636eb1769f60e11b815291925082916001600160a01b039091169063dd62ed3e90611a2f9033903090600401612d8f565b60206040518083038186803b158015611a4757600080fd5b505afa158015611a5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7f9190612be6565b1015611a9d5760405162461bcd60e51b81526004016105de90612f7b565b60db54611ab0908263ffffffff611f1f16565b60db5560cb5460d6546040516323b872dd60e01b81526001600160a01b03928316926323b872dd92611aec923392909116908690600401612da9565b602060405180830381600087803b158015611b0657600080fd5b505af1158015611b1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b3e9190612a68565b5060c954604051630786e20160e11b81526001600160a01b0390911690630f0dc402906118a790899089908990600401613496565b60d25481565b60ca546001600160a01b031681565b60ce546001600160a01b031681565b60008181526033602052604081206119079061264d565b60d15481565b60c9546001600160a01b031681565b600082815260336020526040902060020154611be19061047c6123de565b61130c5760405162461bcd60e51b81526004016105de906130c5565b611c05611e99565b6000815111611c265760405162461bcd60e51b81526004016105de90613245565b60005b81518110156110e45760006001600160a01b0316828281518110611c4957fe5b60200260200101516001600160a01b03161415611c785760405162461bcd60e51b81526004016105de9061337e565b60da828281518110611c8657fe5b60209081029190910181015182546001808201855560009485529290932090920180546001600160a01b0319166001600160a01b039093169290921790915501611c29565b60026097541415611cee5760405162461bcd60e51b81526004016105de906133d4565b6002609755611cfb611e99565b60cd546040516370a0823160e01b815282916001600160a01b0316906370a0823190611d2b903090600401612d7b565b60206040518083038186803b158015611d4357600080fd5b505afa158015611d57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d7b9190612be6565b1015611d995760405162461bcd60e51b81526004016105de9061345a565b60cd5460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb906106c49033908590600401612dcd565b606060da805480602002602001604051908101604052809291908181526020018280548015611e2357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611e05575b5050505050905090565b60db5481565b60d05481565b60d55481565b611e47611e99565b60d680546001600160a01b0319166001600160a01b0392909216919091179055565b611e71611e99565b60ce80546001600160a01b0319166001600160a01b0392909216919091179055565b610e1081565b611ea460003361190d565b6113265760405162461bcd60e51b81526004016105de90613352565b32331461132657600080fd5b6001600160a01b038116600090815260d760205260409020544311611f035760405162461bcd60e51b81526004016105de9061313f565b6001600160a01b0316600090815260d760205260409020439055565b6000828201838110156119045760405162461bcd60e51b81526004016105de90613020565b60c9546040516331a9108f60e11b815233916001600160a01b031690636352211e90611f74908590600401612e3e565b60206040518083038186803b158015611f8c57600080fd5b505afa158015611fa0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fc49190612a11565b6001600160a01b031614611fea5760405162461bcd60e51b81526004016105de906132e4565b50565b60c9546040516370a0823160e01b81526000916001600160a01b0316906370a082319061201e903390600401612d7b565b60206040518083038186803b15801561203657600080fd5b505afa15801561204a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061206e9190612be6565b1161208b5760405162461bcd60e51b81526004016105de90612e89565b60c9546040516302e9ec9d60e11b81526028916001600160a01b0316906305d3d93a906120bc908690600401612e3e565b60206040518083038186803b1580156120d457600080fd5b505afa1580156120e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210c9190612ca8565b60ff16101561212d5760405162461bcd60e51b81526004016105de90612fb2565b60038160ff1611156121515760405162461bcd60e51b81526004016105de90612ed1565b60ff8116600090815260d86020526040908190205460cb5491516370a0823160e01b815290916001600160a01b0316906370a0823190612195903090600401612d7b565b60206040518083038186803b1580156121ad57600080fd5b505afa1580156121c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121e59190612be6565b10156110e45760405162461bcd60e51b81526004016105de90613193565b60008261221257506000611907565b8282028284828161221f57fe5b04146119045760405162461bcd60e51b81526004016105de906132a3565b600080821161225e5760405162461bcd60e51b81526004016105de9061308e565b81838161226757fe5b049392505050565b6000828211156122915760405162461bcd60e51b81526004016105de90613057565b50900390565b60c954604051632ee6accf60e01b81526001600160a01b0390911690632ee6accf906122ca908590602890600401613485565b602060405180830381600087803b1580156122e457600080fd5b505af11580156122f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061231c9190612bb8565b5060c9546001600160a01b0316630fc0057583612359600a61089b61234b60ff8816600163ffffffff611f1f16565b60199063ffffffff61220316565b6040518363ffffffff1660e01b81526004016123769291906134cb565b600060405180830381600087803b15801561239057600080fd5b505af11580156123a4573d6000803e3d6000fd5b505050505050565b60008082116123cd5760405162461bcd60e51b81526004016105de9061315c565b8183816123d657fe5b069392505050565b3390565b6000828152603360205260409020612400908263ffffffff61265816565b156110e45761240d6123de565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600061245c3061266d565b15905090565b600054610100900460ff168061247b575061247b612451565b80612489575060005460ff16155b6124a55760405162461bcd60e51b81526004016105de906131ca565b600054610100900460ff161580156124d0576000805460ff1961ff0019909116610100171660011790555b6124d8612673565b6124e0612673565b8015611fea576000805461ff001916905550565b6000828152603360205260409020612512908263ffffffff6126f416565b156110e45761251f6123de565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b61256b611442565b6125875760405162461bcd60e51b81526004016105de90612f4d565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6125ba6123de565b6040516125c79190612d7b565b60405180910390a1565b6125d9611442565b156125f65760405162461bcd60e51b81526004016105de90613115565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586125ba6123de565b60006119048383612709565b6000611904836001600160a01b03841661274e565b600061190782612766565b6000611904836001600160a01b03841661276a565b3b151590565b600054610100900460ff168061268c575061268c612451565b8061269a575060005460ff16155b6126b65760405162461bcd60e51b81526004016105de906131ca565b600054610100900460ff161580156124e0576000805460ff1961ff0019909116610100171660011790558015611fea576000805461ff001916905550565b6000611904836001600160a01b0384166127b4565b8154600090821061272c5760405162461bcd60e51b81526004016105de90612e47565b82600001828154811061273b57fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b6000612776838361274e565b6127ac57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611907565b506000611907565b6000818152600183016020526040812054801561287057835460001980830191908101906000908790839081106127e757fe5b906000526020600020015490508087600001848154811061280457fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061283457fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050611907565b6000915050611907565b8280548282559060005260206000209081019282156128cf579160200282015b828111156128cf57825182546001600160a01b0319166001600160a01b0390911617825560209092019160019091019061289a565b506128db9291506128df565b5090565b61144991905b808211156128db5780546001600160a01b03191681556001016128e5565b600082601f830112612913578081fd5b813567ffffffffffffffff811115612929578182fd5b60208082026129398282016134f6565b8381529350818401858301828701840188101561295557600080fd5b600092505b8483101561298157803561296d8161351d565b82526001929092019190830190830161295a565b505050505092915050565b600082601f83011261299c578081fd5b813567ffffffffffffffff8111156129b2578182fd5b6129c5601f8201601f19166020016134f6565b91508082528360208285010111156129dc57600080fd5b8060208401602084013760009082016020015292915050565b600060208284031215612a06578081fd5b81356119048161351d565b600060208284031215612a22578081fd5b81516119048161351d565b600060208284031215612a3e578081fd5b813567ffffffffffffffff811115612a54578182fd5b612a6084828501612903565b949350505050565b600060208284031215612a79578081fd5b81518015158114611904578182fd5b600060208284031215612a99578081fd5b5035919050565b60008060408385031215612ab2578081fd5b823591506020830135612ac48161351d565b809150509250929050565b60008060408385031215612ae1578182fd5b50508035926020909101359150565b60008060008060008060008060006101208a8c031215612b0e578485fd5b8935612b198161351d565b985060208a0135612b298161351d565b975060408a0135612b398161351d565b965060608a0135612b498161351d565b955060808a0135612b598161351d565b945060a08a0135612b698161351d565b935060c08a0135612b798161351d565b925060e08a013591506101008a013567ffffffffffffffff811115612b9c578182fd5b612ba88c828d01612903565b9150509295985092959850929598565b600060208284031215612bc9578081fd5b81516dffffffffffffffffffffffffffff81168114611904578182fd5b600060208284031215612bf7578081fd5b5051919050565b600080600060608486031215612c12578283fd5b83359250602084013567ffffffffffffffff80821115612c30578384fd5b612c3c8783880161298c565b93506040860135915080821115612c51578283fd5b50612c5e8682870161298c565b9150509250925092565b60008060408385031215612c7a578182fd5b823591506020830135612ac481613532565b600060208284031215612c9d578081fd5b813561190481613532565b600060208284031215612cb9578081fd5b815161190481613532565b60008060408385031215612cd6578182fd5b8235612ce181613532565b946020939093013593505050565b600080600060608486031215612d03578081fd5b8335612d0e81613532565b9250602084013591506040840135612d258161351d565b809150509250925092565b60008151808452815b81811015612d5557602081850181015186830182015201612d39565b81811115612d665782602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b81811015612e275783516001600160a01b031683529284019291840191600101612e02565b50909695505050505050565b901515815260200190565b90815260200190565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b60208082526028908201527f506c656173652062757920616e206f70657261746f7220746f206275792054416040820152674720746f6b656e7360c01b606082015260800190565b602080825260139082015272496e76616c69642062756e646c65207479706560681b604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201526e0818591b5a5b881d1bc819dc985b9d608a1b606082015260800190565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b60208082526017908201527f4e6f7420656e6f7567682054414720617070726f766564000000000000000000604082015260600190565b6020808252601a908201527f4e6f7420656e6f756768207374616d696e6120666f7220427579000000000000604082015260600190565b6020808252601f908201527f4f6e6c79204561726c792041646f707465727320616363657373206e6f772100604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b60208082526030908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201526f2061646d696e20746f207265766f6b6560801b606082015260800190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252600390820152624f435360e81b604082015260600190565b60208082526018908201527f536166654d6174683a206d6f64756c6f206279207a65726f0000000000000000604082015260600190565b6020808252601a908201527f4e6f7420656e6f7567682054414720746f6b656e73206c656674000000000000604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b602080825260139082015272496e76616c696420637573746f6d207479706560681b604082015260600190565b6020808252600d908201526c4e6f206164647265737365732160981b604082015260600190565b60208082526019908201527f4e6f7420656e6f756768205553444320616c6c6f77616e636500000000000000604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b60208082526017908201527f4e6f742074686520636861726163746572206f776e6572000000000000000000604082015260600190565b6020808252601b908201527f4561726c792073616c6520616c726561647920737461727465642e0000000000604082015260600190565b60208082526012908201527120b236b4b7103937b632903732b2b232b21760711b604082015260600190565b60208082526010908201526f20b2323932b9b99418149032b93937b960811b604082015260600190565b602080825260129082015271155cd9481d985b1a59081c9959995c9c985b60721b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201526e103937b632b9903337b91039b2b63360891b606082015260800190565b602080825260119082015270139bdd08195b9bdd59da08185b5bdd5b9d607a1b604082015260600190565b91825260ff16602082015260400190565b6000848252606060208301526134af6060830185612d30565b82810360408401526134c18185612d30565b9695505050505050565b91825261ffff16602082015260400190565b92835260ff919091166020830152604082015260600190565b60405181810167ffffffffffffffff8111828210171561351557600080fd5b604052919050565b6001600160a01b0381168114611fea57600080fd5b60ff81168114611fea57600080fdfea2646970667358221220b79f86eb3ea18ece2e6c6faae0e8edde5a853c91432c201181a9f93044c3dac264736f6c63430006050033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102ba5760003560e01c80638a7130a011610182578063ca15c873116100e9578063e03a4eb5116100a2578063e5cb196c1161007c578063e5cb196c14610558578063f0f4426014610560578063f42ebbe014610573578063fff5e04214610586576102ba565b8063e03a4eb514610533578063e1b85fc914610548578063e4658b5014610550576102ba565b8063ca15c873146104d7578063cf5ed7f7146104ea578063d070bb54146104f2578063d547741f146104fa578063daeaea531461050d578063db81f99b14610520576102ba565b8063a1cae8e11161013b578063a1cae8e114610491578063a217fddf146104a4578063b2efd34f146104ac578063b9949541146104bf578063bee666d8146104c7578063c2763cd6146104cf576102ba565b80638a7130a0146104355780638f53bdf4146104485780639010d07c1461045b57806391d148541461046e57806397f8c8e514610481578063a1a2335814610489576102ba565b8063438e11f8116102265780636b6c0774116101df5780636b6c0774146103ef5780637c6863d4146103f75780638456cb591461040a578063851dc1111461041257806388b2436e1461041a57806389a302711461042d576102ba565b8063438e11f81461039a578063452d003f146103a257806347221ac7146103b557806359a153ba146103ca5780635c975abb146103d257806361d027b3146103e7576102ba565b80632670492011610278578063267049201461033e5780632f2ff15d1461035157806331285e1c14610364578063343dfb7e1461037757806336568abe1461037f5780633f4ba83a14610392576102ba565b8062e9236f146102bf5780630145d384146102dd57806301b32c1f146102f25780630c3f41ee146103055780631bd8225d14610318578063248a9ca31461032b575b600080fd5b6102c761058e565b6040516102d49190612e3e565b60405180910390f35b6102f06102eb366004612cc4565b61059d565b005b6102f0610300366004612a88565b6105bb565b6102f0610313366004612cef565b61071f565b6102c76103263660046129f5565b611067565b6102c7610339366004612a88565b611079565b6102c761034c366004612c8c565b61108e565b6102f061035f366004612aa0565b6110a0565b6102f0610372366004612af0565b6110e8565b6102c76112cf565b6102f061038d366004612aa0565b6112d4565b6102f0611316565b6102c7611328565b6102f06103b0366004612a88565b61132e565b6103bd61142e565b6040516102d49190612d7b565b6102c761143d565b6103da611442565b6040516102d49190612e33565b6103bd61144c565b6103bd61145b565b6102c7610405366004612c8c565b61146a565b6102f061147c565b6102f061148c565b6103bd610428366004612a88565b6114ba565b6103bd6114e1565b6102f0610443366004612a88565b6114f0565b6102f0610456366004612c68565b6115f0565b6103bd610469366004612acf565b6118e6565b6103da61047c366004612aa0565b61190d565b6102c761192b565b6102c7611931565b6102f061049f366004612a88565b611937565b6102c7611944565b6102f06104ba366004612bfe565b611949565b6102c7611b73565b6103bd611b79565b6103bd611b88565b6102c76104e5366004612a88565b611b97565b6102c7611bae565b6103bd611bb4565b6102f0610508366004612aa0565b611bc3565b6102f061051b366004612a2d565b611bfd565b6102f061052e366004612a88565b611ccb565b61053b611dcb565b6040516102d49190612de6565b6102c7611e2d565b6102c7611e33565b6102c7611e39565b6102f061056e3660046129f5565b611e3f565b6102f06105813660046129f5565b611e69565b6102c7611e93565b6aa56fa5b99019a5c800000081565b6105a5611e99565b60ff909116600090815260dc6020526040902055565b600260975414156105e75760405162461bcd60e51b81526004016105de906133d4565b60405180910390fd5b60026097556105f4611e99565b60cb546040516370a0823160e01b815282916001600160a01b0316906370a0823190610624903090600401612d7b565b60206040518083038186803b15801561063c57600080fd5b505afa158015610650573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106749190612be6565b10156106925760405162461bcd60e51b81526004016105de9061345a565b60cb5460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb906106c49033908590600401612dcd565b602060405180830381600087803b1580156106de57600080fd5b505af11580156106f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107169190612a68565b50506001609755565b610727611442565b156107445760405162461bcd60e51b81526004016105de90613115565b61074c611ec0565b3361075681611ecc565b600260975414156107795760405162461bcd60e51b81526004016105de906133d4565b600260975560d35461079390610e1063ffffffff611f1f16565b421015610807576000805b60da548110156107e757336001600160a01b031660da82815481106107bf57fe5b6000918252602090912001546001600160a01b031614156107df57600191505b60010161079e565b50806108055760405162461bcd60e51b81526004016105de90612fe9565b505b816001600160a01b0381161561084057336001600160a01b03821614156108405760405162461bcd60e51b81526004016105de906133a8565b8361084a81611f44565b84866108568282611fed565b60ff8816600090815260d8602052604081205460cf5490919061088090839063ffffffff61220316565b905060006108a76103e861089b84601963ffffffff61220316565b9063ffffffff61223d16565b60cd54604051636eb1769f60e11b815291925083916001600160a01b039091169063dd62ed3e906108de9033903090600401612d8f565b60206040518083038186803b1580156108f657600080fd5b505afa15801561090a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061092e9190612be6565b101561094c5760405162461bcd60e51b81526004016105de9061326c565b60ca54604051630e20f61560e21b81526000916001600160a01b031690633883d8549061097d903390600401612d7b565b60206040518083038186803b15801561099557600080fd5b505afa1580156109a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109cd9190612be6565b60cb546040516370a0823160e01b8152919250610a8691610a78916aa56fa5b99019a5c80000009161089b916064916001600160a01b03909116906370a0823190610a1c903090600401612d7b565b60206040518083038186803b158015610a3457600080fd5b505afa158015610a48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a6c9190612be6565b9063ffffffff61220316565b60649063ffffffff61226f16565b60d2819055603211801590610a9d5750603c60d254105b15610abf5760d15460d054610ab79163ffffffff611f1f16565b60cf55610b9a565b603c60d25410158015610ad45750604660d254105b15610b005760d154610ab790610af190600263ffffffff61220316565b60d0549063ffffffff611f1f16565b604660d25410158015610b155750605060d254105b15610b325760d154610ab790610af190600363ffffffff61220316565b605060d25410158015610b475750605a60d254105b15610b645760d154610ab790610af190600463ffffffff61220316565b605a60d25410158015610b795750606460d254105b15610b9a5760d154610b9690610af190600563ffffffff61220316565b60cf555b610bc2610bb3606461089b87600563ffffffff61220316565b60d4549063ffffffff611f1f16565b60d45560cd546001600160a01b03166323b872dd3330610bf9610bec87600263ffffffff61220316565b889063ffffffff61226f16565b6040518463ffffffff1660e01b8152600401610c1793929190612da9565b602060405180830381600087803b158015610c3157600080fd5b505af1158015610c45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c699190612a68565b506001600160a01b038a1615610d475760cd546040516323b872dd60e01b81526001600160a01b03909116906323b872dd90610cad9033908e908790600401612da9565b602060405180830381600087803b158015610cc757600080fd5b505af1158015610cdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cff9190612a68565b506001600160a01b038a16600090815260d96020526040902054610d29908363ffffffff611f1f16565b6001600160a01b038b16600090815260d96020526040902055610dd4565b60cd5460d6546040516323b872dd60e01b81526001600160a01b03928316926323b872dd92610d80923392909116908790600401612da9565b602060405180830381600087803b158015610d9a57600080fd5b505af1158015610dae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd29190612a68565b505b60cd5460d6546040516323b872dd60e01b81526001600160a01b03928316926323b872dd92610e0d923392909116908790600401612da9565b602060405180830381600087803b158015610e2757600080fd5b505af1158015610e3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5f9190612a68565b50610e6a8b8d612297565b60cb546001600160a01b031663a9059cbb33610e9487670de0b6b3a764000063ffffffff61220316565b6040518363ffffffff1660e01b8152600401610eb1929190612dcd565b602060405180830381600087803b158015610ecb57600080fd5b505af1158015610edf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f039190612a68565b5060d554610f1890829063ffffffff6123ac16565b6110075760cc5460d4546001600160a01b039091169063a9059cbb903390610f4e90670de0b6b3a764000063ffffffff61220316565b6040518363ffffffff1660e01b8152600401610f6b929190612dcd565b602060405180830381600087803b158015610f8557600080fd5b505af1158015610f99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fbd9190612a68565b50336001600160a01b03167fb70ba9473dd6cf656adf13fb552af08c98ed2db7617cbd30d2ed91cbd950fe0960d454604051610ff99190612e3e565b60405180910390a2600060d4555b60ff8c16600090815260d860205260409081902054905133917f6bf09d88df35e3a9f078672669e47fac71dda4136decc107b4c9d4b9f9c25fec9161104c9190612e3e565b60405180910390a25050600160975550505050505050505050565b60d96020526000908152604090205481565b60009081526033602052604090206002015490565b60dc6020526000908152604090205481565b6000828152603360205260409020600201546110be9061047c6123de565b6110da5760405162461bcd60e51b81526004016105de90612efe565b6110e482826123e2565b5050565b600054610100900460ff16806111015750611101612451565b8061110f575060005460ff16155b61112b5760405162461bcd60e51b81526004016105de906131ca565b600054610100900460ff16158015611156576000805460ff1961ff0019909116610100171660011790555b61115e612462565b6111696000336110da565b60cd80546001600160a01b03199081166001600160a01b038b81169190911790925560cb805482168a841617905560cc8054821689841617905560ce8054821688841617905560c9805482168d841617905560ca805482168c841617905560d6805490911691861691909117905560d58390556107d060cf81905560d055600060d281905561019060d15560d381905560d860209081526109c47fa1c22ab04d5a14eb0b9d727ce553bde77dd4c57869bd47735629b3593c2d1364556130d47fdd1fd626b6a6510e3f131ed76f8d2c0ac44a92fbf50a4ce319f246853c5b5a09556161a87f7e178e8cc2471df3be8871998633f08a591282fb3a8961cb5d8a7a2413d2aac8556003825261c3507f60a592c01b1028f28cf4d7ce4c92f34a7df548ac23775b70c0b8b662d9347dcc5560d49190915582516112b09160da919085019061287a565b5080156112c3576000805461ff00191690555b50505050505050505050565b601981565b6112dc6123de565b6001600160a01b0316816001600160a01b03161461130c5760405162461bcd60e51b81526004016105de9061340b565b6110e482826124f4565b61131e611e99565b611326612563565b565b60cf5481565b600260975414156113515760405162461bcd60e51b81526004016105de906133d4565b600260975561135e611e99565b60ce546040516370a0823160e01b815282916001600160a01b0316906370a082319061138e903090600401612d7b565b60206040518083038186803b1580156113a657600080fd5b505afa1580156113ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113de9190612be6565b10156113fc5760405162461bcd60e51b81526004016105de9061345a565b60ce5460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb906106c49033908590600401612dcd565b60cb546001600160a01b031681565b606481565b60655460ff165b90565b60d6546001600160a01b031681565b60cc546001600160a01b031681565b60d86020526000908152604090205481565b611484611e99565b6113266125d1565b611494611e99565b60d354156114b45760405162461bcd60e51b81526004016105de9061331b565b4260d355565b60da81815481106114c757fe5b6000918252602090912001546001600160a01b0316905081565b60cd546001600160a01b031681565b600260975414156115135760405162461bcd60e51b81526004016105de906133d4565b6002609755611520611e99565b60cc546040516370a0823160e01b815282916001600160a01b0316906370a0823190611550903090600401612d7b565b60206040518083038186803b15801561156857600080fd5b505afa15801561157c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115a09190612be6565b10156115be5760405162461bcd60e51b81526004016105de9061345a565b60cc5460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb906106c49033908590600401612dcd565b6115f8611442565b156116155760405162461bcd60e51b81526004016105de90613115565b600260975414156116385760405162461bcd60e51b81526004016105de906133d4565b60026097553361164781611ecc565b61164f611ec0565b8261165981611f44565b60028360ff16111561167d5760405162461bcd60e51b81526004016105de90613218565b60ff8316600090815260dc60205260408120546116a890670de0b6b3a764000063ffffffff61220316565b60cb54604051636eb1769f60e11b815291925082916001600160a01b039091169063dd62ed3e906116df9033903090600401612d8f565b60206040518083038186803b1580156116f757600080fd5b505afa15801561170b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061172f9190612be6565b101561174d5760405162461bcd60e51b81526004016105de90612f7b565b60ca54604051630e20f61560e21b81526000916001600160a01b031690633883d8549061177e903390600401612d7b565b60206040518083038186803b15801561179657600080fd5b505afa1580156117aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ce9190612be6565b60db549091506117e4908363ffffffff611f1f16565b60db5560cb5460d6546040516323b872dd60e01b81526001600160a01b03928316926323b872dd92611820923392909116908790600401612da9565b602060405180830381600087803b15801561183a57600080fd5b505af115801561184e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118729190612a68565b5060c9546040516370f71efd60e01b81526001600160a01b03909116906370f71efd906118a7908990899086906004016134dd565b600060405180830381600087803b1580156118c157600080fd5b505af11580156118d5573d6000803e3d6000fd5b505060016097555050505050505050565b6000828152603360205260408120611904908363ffffffff61262c16565b90505b92915050565b6000828152603360205260408120611904908363ffffffff61263816565b60d35481565b60d45481565b61193f611e99565b60d555565b600081565b611951611442565b1561196e5760405162461bcd60e51b81526004016105de90613115565b600260975414156119915760405162461bcd60e51b81526004016105de906133d4565b6002609755336119a081611ecc565b6119a8611ec0565b836119b281611f44565b6003600090815260dc6020527fd424594b947c18da8f3a6f93819695640a748b6d74709a708102e14e3e81669c546119f890670de0b6b3a764000063ffffffff61220316565b60cb54604051636eb1769f60e11b815291925082916001600160a01b039091169063dd62ed3e90611a2f9033903090600401612d8f565b60206040518083038186803b158015611a4757600080fd5b505afa158015611a5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7f9190612be6565b1015611a9d5760405162461bcd60e51b81526004016105de90612f7b565b60db54611ab0908263ffffffff611f1f16565b60db5560cb5460d6546040516323b872dd60e01b81526001600160a01b03928316926323b872dd92611aec923392909116908690600401612da9565b602060405180830381600087803b158015611b0657600080fd5b505af1158015611b1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b3e9190612a68565b5060c954604051630786e20160e11b81526001600160a01b0390911690630f0dc402906118a790899089908990600401613496565b60d25481565b60ca546001600160a01b031681565b60ce546001600160a01b031681565b60008181526033602052604081206119079061264d565b60d15481565b60c9546001600160a01b031681565b600082815260336020526040902060020154611be19061047c6123de565b61130c5760405162461bcd60e51b81526004016105de906130c5565b611c05611e99565b6000815111611c265760405162461bcd60e51b81526004016105de90613245565b60005b81518110156110e45760006001600160a01b0316828281518110611c4957fe5b60200260200101516001600160a01b03161415611c785760405162461bcd60e51b81526004016105de9061337e565b60da828281518110611c8657fe5b60209081029190910181015182546001808201855560009485529290932090920180546001600160a01b0319166001600160a01b039093169290921790915501611c29565b60026097541415611cee5760405162461bcd60e51b81526004016105de906133d4565b6002609755611cfb611e99565b60cd546040516370a0823160e01b815282916001600160a01b0316906370a0823190611d2b903090600401612d7b565b60206040518083038186803b158015611d4357600080fd5b505afa158015611d57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d7b9190612be6565b1015611d995760405162461bcd60e51b81526004016105de9061345a565b60cd5460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb906106c49033908590600401612dcd565b606060da805480602002602001604051908101604052809291908181526020018280548015611e2357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611e05575b5050505050905090565b60db5481565b60d05481565b60d55481565b611e47611e99565b60d680546001600160a01b0319166001600160a01b0392909216919091179055565b611e71611e99565b60ce80546001600160a01b0319166001600160a01b0392909216919091179055565b610e1081565b611ea460003361190d565b6113265760405162461bcd60e51b81526004016105de90613352565b32331461132657600080fd5b6001600160a01b038116600090815260d760205260409020544311611f035760405162461bcd60e51b81526004016105de9061313f565b6001600160a01b0316600090815260d760205260409020439055565b6000828201838110156119045760405162461bcd60e51b81526004016105de90613020565b60c9546040516331a9108f60e11b815233916001600160a01b031690636352211e90611f74908590600401612e3e565b60206040518083038186803b158015611f8c57600080fd5b505afa158015611fa0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fc49190612a11565b6001600160a01b031614611fea5760405162461bcd60e51b81526004016105de906132e4565b50565b60c9546040516370a0823160e01b81526000916001600160a01b0316906370a082319061201e903390600401612d7b565b60206040518083038186803b15801561203657600080fd5b505afa15801561204a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061206e9190612be6565b1161208b5760405162461bcd60e51b81526004016105de90612e89565b60c9546040516302e9ec9d60e11b81526028916001600160a01b0316906305d3d93a906120bc908690600401612e3e565b60206040518083038186803b1580156120d457600080fd5b505afa1580156120e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210c9190612ca8565b60ff16101561212d5760405162461bcd60e51b81526004016105de90612fb2565b60038160ff1611156121515760405162461bcd60e51b81526004016105de90612ed1565b60ff8116600090815260d86020526040908190205460cb5491516370a0823160e01b815290916001600160a01b0316906370a0823190612195903090600401612d7b565b60206040518083038186803b1580156121ad57600080fd5b505afa1580156121c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121e59190612be6565b10156110e45760405162461bcd60e51b81526004016105de90613193565b60008261221257506000611907565b8282028284828161221f57fe5b04146119045760405162461bcd60e51b81526004016105de906132a3565b600080821161225e5760405162461bcd60e51b81526004016105de9061308e565b81838161226757fe5b049392505050565b6000828211156122915760405162461bcd60e51b81526004016105de90613057565b50900390565b60c954604051632ee6accf60e01b81526001600160a01b0390911690632ee6accf906122ca908590602890600401613485565b602060405180830381600087803b1580156122e457600080fd5b505af11580156122f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061231c9190612bb8565b5060c9546001600160a01b0316630fc0057583612359600a61089b61234b60ff8816600163ffffffff611f1f16565b60199063ffffffff61220316565b6040518363ffffffff1660e01b81526004016123769291906134cb565b600060405180830381600087803b15801561239057600080fd5b505af11580156123a4573d6000803e3d6000fd5b505050505050565b60008082116123cd5760405162461bcd60e51b81526004016105de9061315c565b8183816123d657fe5b069392505050565b3390565b6000828152603360205260409020612400908263ffffffff61265816565b156110e45761240d6123de565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600061245c3061266d565b15905090565b600054610100900460ff168061247b575061247b612451565b80612489575060005460ff16155b6124a55760405162461bcd60e51b81526004016105de906131ca565b600054610100900460ff161580156124d0576000805460ff1961ff0019909116610100171660011790555b6124d8612673565b6124e0612673565b8015611fea576000805461ff001916905550565b6000828152603360205260409020612512908263ffffffff6126f416565b156110e45761251f6123de565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b61256b611442565b6125875760405162461bcd60e51b81526004016105de90612f4d565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6125ba6123de565b6040516125c79190612d7b565b60405180910390a1565b6125d9611442565b156125f65760405162461bcd60e51b81526004016105de90613115565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586125ba6123de565b60006119048383612709565b6000611904836001600160a01b03841661274e565b600061190782612766565b6000611904836001600160a01b03841661276a565b3b151590565b600054610100900460ff168061268c575061268c612451565b8061269a575060005460ff16155b6126b65760405162461bcd60e51b81526004016105de906131ca565b600054610100900460ff161580156124e0576000805460ff1961ff0019909116610100171660011790558015611fea576000805461ff001916905550565b6000611904836001600160a01b0384166127b4565b8154600090821061272c5760405162461bcd60e51b81526004016105de90612e47565b82600001828154811061273b57fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b6000612776838361274e565b6127ac57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611907565b506000611907565b6000818152600183016020526040812054801561287057835460001980830191908101906000908790839081106127e757fe5b906000526020600020015490508087600001848154811061280457fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061283457fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050611907565b6000915050611907565b8280548282559060005260206000209081019282156128cf579160200282015b828111156128cf57825182546001600160a01b0319166001600160a01b0390911617825560209092019160019091019061289a565b506128db9291506128df565b5090565b61144991905b808211156128db5780546001600160a01b03191681556001016128e5565b600082601f830112612913578081fd5b813567ffffffffffffffff811115612929578182fd5b60208082026129398282016134f6565b8381529350818401858301828701840188101561295557600080fd5b600092505b8483101561298157803561296d8161351d565b82526001929092019190830190830161295a565b505050505092915050565b600082601f83011261299c578081fd5b813567ffffffffffffffff8111156129b2578182fd5b6129c5601f8201601f19166020016134f6565b91508082528360208285010111156129dc57600080fd5b8060208401602084013760009082016020015292915050565b600060208284031215612a06578081fd5b81356119048161351d565b600060208284031215612a22578081fd5b81516119048161351d565b600060208284031215612a3e578081fd5b813567ffffffffffffffff811115612a54578182fd5b612a6084828501612903565b949350505050565b600060208284031215612a79578081fd5b81518015158114611904578182fd5b600060208284031215612a99578081fd5b5035919050565b60008060408385031215612ab2578081fd5b823591506020830135612ac48161351d565b809150509250929050565b60008060408385031215612ae1578182fd5b50508035926020909101359150565b60008060008060008060008060006101208a8c031215612b0e578485fd5b8935612b198161351d565b985060208a0135612b298161351d565b975060408a0135612b398161351d565b965060608a0135612b498161351d565b955060808a0135612b598161351d565b945060a08a0135612b698161351d565b935060c08a0135612b798161351d565b925060e08a013591506101008a013567ffffffffffffffff811115612b9c578182fd5b612ba88c828d01612903565b9150509295985092959850929598565b600060208284031215612bc9578081fd5b81516dffffffffffffffffffffffffffff81168114611904578182fd5b600060208284031215612bf7578081fd5b5051919050565b600080600060608486031215612c12578283fd5b83359250602084013567ffffffffffffffff80821115612c30578384fd5b612c3c8783880161298c565b93506040860135915080821115612c51578283fd5b50612c5e8682870161298c565b9150509250925092565b60008060408385031215612c7a578182fd5b823591506020830135612ac481613532565b600060208284031215612c9d578081fd5b813561190481613532565b600060208284031215612cb9578081fd5b815161190481613532565b60008060408385031215612cd6578182fd5b8235612ce181613532565b946020939093013593505050565b600080600060608486031215612d03578081fd5b8335612d0e81613532565b9250602084013591506040840135612d258161351d565b809150509250925092565b60008151808452815b81811015612d5557602081850181015186830182015201612d39565b81811115612d665782602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b81811015612e275783516001600160a01b031683529284019291840191600101612e02565b50909695505050505050565b901515815260200190565b90815260200190565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b60208082526028908201527f506c656173652062757920616e206f70657261746f7220746f206275792054416040820152674720746f6b656e7360c01b606082015260800190565b602080825260139082015272496e76616c69642062756e646c65207479706560681b604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201526e0818591b5a5b881d1bc819dc985b9d608a1b606082015260800190565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b60208082526017908201527f4e6f7420656e6f7567682054414720617070726f766564000000000000000000604082015260600190565b6020808252601a908201527f4e6f7420656e6f756768207374616d696e6120666f7220427579000000000000604082015260600190565b6020808252601f908201527f4f6e6c79204561726c792041646f707465727320616363657373206e6f772100604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b60208082526030908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201526f2061646d696e20746f207265766f6b6560801b606082015260800190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252600390820152624f435360e81b604082015260600190565b60208082526018908201527f536166654d6174683a206d6f64756c6f206279207a65726f0000000000000000604082015260600190565b6020808252601a908201527f4e6f7420656e6f7567682054414720746f6b656e73206c656674000000000000604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b602080825260139082015272496e76616c696420637573746f6d207479706560681b604082015260600190565b6020808252600d908201526c4e6f206164647265737365732160981b604082015260600190565b60208082526019908201527f4e6f7420656e6f756768205553444320616c6c6f77616e636500000000000000604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b60208082526017908201527f4e6f742074686520636861726163746572206f776e6572000000000000000000604082015260600190565b6020808252601b908201527f4561726c792073616c6520616c726561647920737461727465642e0000000000604082015260600190565b60208082526012908201527120b236b4b7103937b632903732b2b232b21760711b604082015260600190565b60208082526010908201526f20b2323932b9b99418149032b93937b960811b604082015260600190565b602080825260129082015271155cd9481d985b1a59081c9959995c9c985b60721b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201526e103937b632b9903337b91039b2b63360891b606082015260800190565b602080825260119082015270139bdd08195b9bdd59da08185b5bdd5b9d607a1b604082015260600190565b91825260ff16602082015260400190565b6000848252606060208301526134af6060830185612d30565b82810360408401526134c18185612d30565b9695505050505050565b91825261ffff16602082015260400190565b92835260ff919091166020830152604082015260600190565b60405181810167ffffffffffffffff8111828210171561351557600080fd5b604052919050565b6001600160a01b0381168114611fea57600080fd5b60ff81168114611fea57600080fdfea2646970667358221220b79f86eb3ea18ece2e6c6faae0e8edde5a853c91432c201181a9f93044c3dac264736f6c63430006050033
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.